Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Status
colourYellow
title릴리즈 3.2

...

.0 이상
 
Status
colourYellow
title릴리즈 2.

...

20.0 이상


현재 에디터의 목차 모델을 JSON Array으로 반환합니다. (트리 구조 모델)

...

Note

컨텐츠 내 목차 요소와 목차 모델의 ID를 동기화하려면 updateTableOfContentsIds를 호출해야 합니다.
이 메서드는 에디터 내 실제 목차 요소의 ID를 최신 목차 모델과 일치하도록 갱신합니다.

ex) editor.updateTableOfContentsIds();



Note

'editor.titleStyle' 설정 시 특정 class를 가진 요소를 목차로 추출 가능합니다.

자세한 내용 보기: 환경설정


Example:

Code Block
languagejs
themeEmacs
// model 가져오는 방법

// 1. 에디터 내부에서 사용되는 ID를 적용한 목차 모델
var model = editor.getTableOfContentsModelJSON();

// 2. 목차 전용 prefix가 붙은 ID를 적용한 목차 모델
var model = editor.getTableOfContentsModelJSON(true);


Code Block
languagejs
themeEmacs
// 저장/불러오기 시 컨텐츠 내 목차 ID 유지하는 방법

// 1. 목차 전용 prefix가 붙은 ID를 적용한 목차 모델 가져오기
editor.getTableOfContentsModelJSON(true);

// 2. 컨텐츠 내 목차 요소와 목차 모델의 ID 동기화
editor.updateTableOfContentsIds();


Code Block
languagejs
themeEmacs
titleshouldAssignId: false
[
    {
        "id": "se_011fb8a1-b74d-49a9-a7ef-a16c3eecb939",
        "text": "제목1",
        "children": [
            {
                "id": "se_ab77dbab-8fcc-418a-bdd2-365930aab960",
                "text": "제목2",
                "children": [
                    {
                        "id": "se_2e4330a5-ef87-404c-99d3-1c6d79937289",
                        "text": "제목3",
                        "children": [
                            {
                                "id": "se_19102d03-cb41-430d-b9c9-b7a8ce823525",
                                "text": "제목4",
                                "children": [
                                    {
                                        "id": "se_c45d1628-cc3f-4ab2-b2bc-6cd23ef6fec1",
                                        "text": "제목5",
                                        "children": [
                                            {
                                                "id": "se_85d9cfed-46af-497d-9670-f85cc467dafa",
                                                "text": "제목6",
                                                "children": [],
                                                "level": 5
                                            }
                                        ],
                                        "level": 4
                                    }
                                ],
                                "level": 3
                            }
                        ],
                        "level": 2
                    }
                ],
                "level": 1
            }
        ],
        "level": 0
    }
]

...