Page tree

Versions Compared

Key

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

Status
colourYellow
title릴리즈 3.0.

...

2406 이상

Selection을 기준으로 HTML Element 배열을 반환합니다. Selection이 지정되지 않은 경우 현재 Selection에 해당하는 HTML Element를 현재 에디터의 Body모델을 JSON Object 또는 JSON String으로 반환합니다.


Parameters:

Name

Type

Attribute

Description

toString

boolean

default : false

[ Optional ]
현재 에디터 Body 모델을 JSON String으로 반환 받을지 설정합니다. 

Return:

TypeDescription
Object | StringtoString에 따른 Body 모델 JSON Object 또는 JSON String.



Example:

Image Added

Code Block
languagejs
themeEmacstitleselection을 지정하지 않은 경우
var elementsmodel = editor.getHTMLElementsgetBodyModelJSON();
console.log(elements[0].innerHTML
var model = editor.getBodyModelJSON(true);


var selection = editor.getSelection(); var elements = editor.getHTMLElements(selection); console.log(elements[0].innerHTML);
Code Block
languagejs
themeEmacs
titleSelection을 지정한 경우
toString: false
{
    "id": "se_5a9f922e-db5a-41cf-b026-00a020125348",
    "type": "Body",
    "fromHTMLBuilder": false,
    "style": {},
    "children": [
        {
            "style": {},
            "children": [
                {
                    "text": "안녕하세요.",
                    "isEmoji": false,
                    "style": {},
                    "id": "se_7e1a7f55-cb5d-4fa7-997f-a22b90969131",
                    "type": "TextRun"
                }
            ],
            "id": "se_2e8fd0e1-1a58-4e24-b939-09bac14c24a2",
            "className": "",
            "type": "Paragraph",
            "fromHTMLBuilder": false,
            "defaultStyle": {
                "margin": {
                    "top": 16,
                    "left": 0,
                    "right": 0,
                    "bottom": 16
                },
                "display": "block",
                "overflowWrap": "break-word"
            },
            "tagName": "P",
            "endRunStyle": {}
        }
    ],
    "pageInfo": {
        "padding": {
            "left": 23,
            "right": 23,
            "top": 18,
            "bottom": 18
        }
    },
    "styleSheet": "",
    "linkTagStr": "",
    "scriptStrs": []
}


Code Block
languagejs
themeEmacs
titletoString: true
'{"id":"se_5a9f922e-db5a-41cf-b026-00a020125348","type":"Body","fromHTMLBuilder":false,"style":{},"children":[{"style":{},"children":[{"text":"안녕하세요.","isEmoji":false,"style":{},"id":"se_7e1a7f55-cb5d-4fa7-997f-a22b90969131","type":"TextRun"}],"id":"se_2e8fd0e1-1a58-4e24-b939-09bac14c24a2","className":"","type":"Paragraph","fromHTMLBuilder":false,"defaultStyle":{"margin":{"top":16,"left":0,"right":0,"bottom":16},"display":"block","overflowWrap":"break-word"},"tagName":"P","endRunStyle":{}}],"pageInfo":{"padding":{"left":23,"right":23,"top":18,"bottom":18}},"styleSheet":"","linkTagStr":"","scriptStrs":[]}'