mirror of
https://github.com/codex-team/editor.js
synced 2024-06-28 10:20:29 +02:00
Update
This commit is contained in:
parent
5e9c0a175f
commit
6ebe8fa347
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -741,17 +741,37 @@ module.exports = (function (content) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
content.clear = function () {
|
/**
|
||||||
|
* Clear editors content
|
||||||
|
*
|
||||||
|
* @param {Boolean} all — if true, delete all article data (content, id, etc.)
|
||||||
|
*/
|
||||||
|
content.clear = function (all) {
|
||||||
|
|
||||||
editor.nodes.redactor.innerHTML = '';
|
editor.nodes.redactor.innerHTML = '';
|
||||||
editor.content.sync();
|
editor.content.sync();
|
||||||
editor.ui.saveInputs();
|
editor.ui.saveInputs();
|
||||||
if (editor.state.blocks) editor.state.blocks.items = [];
|
if (all) {
|
||||||
|
|
||||||
|
editor.state.blocks = null;
|
||||||
|
|
||||||
|
} else if (editor.state.blocks) {
|
||||||
|
|
||||||
|
editor.state.blocks.items = [];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
editor.content.currentNode = null;
|
editor.content.currentNode = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Load new data to editor
|
||||||
|
* If editor is not empty, just append articleData.items
|
||||||
|
*
|
||||||
|
* @param articleData.items
|
||||||
|
*/
|
||||||
content.load = function (articleData) {
|
content.load = function (articleData) {
|
||||||
|
|
||||||
var currentContent = editor.state.blocks ? Object.assign({}, editor.state.blocks) : null;
|
var currentContent = editor.state.blocks ? Object.assign({}, editor.state.blocks) : null;
|
||||||
|
|
Loading…
Reference in a new issue