Skip to content

Commit

Permalink
update: #921 getFullContents
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHong88 committed Feb 18, 2022
1 parent a74aa92 commit 00d34e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,9 @@ editor.getContext();
// Gets the contents of the suneditor
// onlyContents {Boolean}: Return only the contents of the body without headers when the "fullPage" option is true
editor.getContents(onlyContents: Boolean);
// Gets the current contents with containing parent div(div.sun-editor-editable).
// <div class="sun-editor-editable">{contents}</div>
editor.getFullContents(onlyContents: Boolean);

// Gets only the text of the suneditor contents
editor.getText();
Expand Down
3 changes: 3 additions & 0 deletions sample/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ <h4 style="color: #b94a48;">--Link</h4>
<span>&nbsp;check_new_window: 'noreferrer noopener',</span>
<span>&nbsp;check_bookmark: 'bookmark'</span>
<span>}</span>
<br><br>
<label><input type="checkbox" id="linkNoPrefix">&nbsp;&nbsp;linkNoPrefix</label>

<br>
<h4 style="color: #b94a48;">--HR</h4>
Expand Down Expand Up @@ -706,6 +708,7 @@ <h2 class="sub-title">Applied options</h2>
linkProtocol: document.getElementById('linkProtocol').checked ? document.getElementById('linkProtocol_value').value : undefined,
linkRel: document.getElementById('linkRel').checked ? ['author', 'external', 'help', 'license', 'next', 'follow', 'nofollow', 'noreferrer', 'noopener', 'prev', 'search', 'tag'] : undefined,
linkRelDefault: document.getElementById('linkRelDefault').checked ? {default: 'nofollow', check_new_window: 'noreferrer noopener', check_bookmark: 'bookmark'} : undefined,
linkNoPrefix: document.getElementById('linkNoPrefix').checked ? true : undefined,
shortcutsDisable: document.getElementById('shortcutsDisable').checked ? ['bold', 'strike', 'underline', 'italic', 'undo', 'indent'] : undefined,
shortcutsHint: document.getElementById('shortcutsHint').checked ? undefined : false,
callBackSave: document.getElementById('callBackSave').checked ? function (contents) { alert(contents) } : undefined,
Expand Down
10 changes: 10 additions & 0 deletions src/lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4828,6 +4828,16 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
}
},

/**
* @description Gets the current contents with containing parent div(div.sun-editor-editable).
* <div class="sun-editor-editable">{contents}</div>
* @param {Boolean} onlyContents Return only the contents of the body without headers when the "fullPage" option is true
* @returns {Object}
*/
getFullContents: function (onlyContents) {
return '<div class="sun-editor-editable' + options.rtl ? ' se-rtl' : '' + '">' + this.getContents(onlyContents) + '</div>';
},

/**
* @description Returns HTML string according to tag type and configuration.
* Use only "cleanHTML"
Expand Down

0 comments on commit 00d34e9

Please sign in to comment.