getBodyModelJSONForAI

3.4.0 버전부터 지원합니다.

현재 에디터의 Body 모델을 반환합니다 — AI 요청에 필요한 속성만 포함하도록 필터링되어 있으며, JSON 객체 또는 JSON 문자열로 반환됩니다. AI에 불필요한 모델 정보를 생략함으로써, 요청과 함께 전송되는 데이터의 양을 줄입니다.

전체(필터링되지 않은) 본문 모델에 대해서는 getBodyModelJSON을 참고합니다.

매개변수

이름타입속성설명
toStringboolean기본값: falseBody 모델을 JSON 문자열로 받을지 여부를 설정합니다.
useStyleboolean기본값: false반환되는 모델에 스타일 정보를 포함할지 여부를 설정합니다.

반환값

타입설명
Object | String본문 모델 JSON 객체 또는 JSON 문자열입니다.

예시

샘플 에디터 내용 (서로 다른 글꼴 색상의 두 텍스트 실행):

1.00

var model = editor.getBodyModelJSONForAI();            // Object, no style
var model = editor.getBodyModelJSONForAI(false, true); // Object, with style
var model = editor.getBodyModelJSONForAI(true);        // String

toString: false (기본값)

{
    "type": "Body",
    "children": [
        {
            "children": [
                {
                    "text": "Hello",
                    "type": "TextRun"
                },
                {
                    "text": "World",
                    "type": "TextRun"
                }
            ],
            "type": "Paragraph"
        }
    ]
}

useStyle: true

{
    "type": "Body",
    "children": [
        {
            "children": [
                {
                    "text": "Hello",
                    "style": {
                        "color": {
                            "r": 128,
                            "g": 128,
                            "b": 255
                        }
                    },
                    "type": "TextRun"
                },
                {
                    "text": "World",
                    "style": {
                        "color": {
                            "r": 255,
                            "g": 128,
                            "b": 128
                        }
                    },
                    "type": "TextRun"
                }
            ],
            "type": "Paragraph"
        }
    ]
}

toString: true

'{"type":"Body","children":[{"children":[{"text":"Hello","type":"TextRun"},{"text":"World","type":"TextRun"}],"type":"Paragraph"}]}'