getModelDiffHTML
2.18.2406 버전부터 지원, 3.0.2406 버전부터 지원합니다.
두 에디터 Body 모델을 비교하여 차이점이 강조된 HTML을 반환합니다.
Body 모델은 getBodyModelJSON을 통해 얻을 수 있습니다.
매개변수
| 이름 | 타입 | 설명 |
|---|---|---|
beforeBodyModel | Object | String | Body 모델 JSON 객체 또는 JSON 문자열입니다. |
currentBodyModel | Object | String | Body 모델 JSON 객체 또는 JSON 문자열입니다. |
options | Object | 옵션을 설정합니다. 아래 options를 참고합니다. |
options
2.18.2409 버전부터 지원, 3.0.2409 버전부터 지원합니다.
옵션을 설정합니다.
예시
{
/*
* Sets the color used to indicate the differences.
*/
style: {
// The color and border color shown on changed parts.
edit: { color: {string}, borderColor: {string} },
// The color and border color shown on removed parts.
delete: { color: {string}, borderColor: {string} }
}
}
반환값
| 타입 | 설명 |
|---|---|
| String | 두 모델 간의 차이점이 강조된 HTML입니다. |
예시 1
| 이전 모델 | 이후 모델 |
|---|---|
![]() | ![]() |
결과

// Hello.
var beforeBodyModel = editor.getBodyModelJSON();
// Hello.
// This is Synap Editor.
var currentBodyModel = editor.getBodyModelJSON();
var result = editor.getModelDiffHTML(beforeBodyModel, currentBodyModel);
결과 HTML
'<div class="se-contents" role="textbox" style="box-sizing: content-box; font-family: "맑은 고딕"; font-size: 11pt; line-height: 1.2;" data-document-padding-top="18" data-document-padding-bottom="18" data-document-padding-left="23" data-document-padding-right="23"><style>a:not(#se-t #se-tt) { pointer-events: auto !important; } .se-diff { position: relative; } .se-diff:not(a):not(.se-div):after { content: ''; position: absolute; width: 100%; height: 100%; top: 0; left: 0; } .se-diff.se-diff-edited:after { background-color: rgba(221, 255, 221, 0.70); } .se-diff.se-diff-deleted:after { background-color: rgba(255, 221, 221, 0.70); } .se-diff.se-diff-deleted:not(a) { text-decoration: line-through; } .se-div.se-diff.se-collabo-edited { background-color: rgba(221, 255, 221, 0.70) !important; } .se-div.se-diff.se-collabo-deleted { background-color: rgba(255, 221, 221, 0.70) !important; }</style><p style="margin: 16px 0px; display: block; overflow-wrap: break-word;"><span>Hello.</span></p><p class="se-diff se-diff-edited" style="margin: 16px 0px; display: block; overflow-wrap: break-word;"><span>This is Synap Editor.</span></p></div>'
예시 2
var beforeBodyModel = editor.getBodyModelJSON();
// Perform edit actions
var currentBodyModel = editor.getBodyModelJSON();
var options = {
style: {
edit: {
color: 'rgba(144, 213, 235, 0.7)', // default: 'rgba(221, 255, 221, 0.7)'
borderColor: 'rgb(93, 181, 209)' // default: 'rgba(0, 246, 0, 0.7)'
},
delete: {
color: 'rgba(211, 117, 124, 0.7)', // default: 'rgba(255, 221, 221, 0.7)'
borderColor: 'rgb(182, 80, 88)' // default: 'rgba(239, 24, 24, 0.7)'
}
}
};
var result = editor.getModelDiffHTML(beforeBodyModel, currentBodyModel, options);
| 이전 모델 | 이후 모델 |
|---|---|
![]() | ![]() |
| 스타일 옵션 적용 전(기본값) | 스타일 옵션 적용 후 |
|---|---|
![]() | ![]() |





