本文整理汇总了TypeScript中tinymce/core/api/Editor.Editor.setContent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor.setContent方法的具体用法?TypeScript Editor.setContent怎么用?TypeScript Editor.setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/Editor.Editor
的用法示例。
在下文中一共展示了Editor.setContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const restoreDraft = (editor: Editor) => {
const prefix = Settings.getAutoSavePrefix(editor);
if (hasDraft(editor)) {
editor.setContent(LocalStorage.getItem(prefix + 'draft'), { format: 'raw' });
Events.fireRestoreDraft(editor);
}
};
示例2: function
const applyToEditor = function (editor: Editor, level: UndoLevel, before: boolean) {
if (level.type === UndoLevelType.Fragmented) {
Fragments.write(level.fragments, editor.getBody());
} else {
editor.setContent(level.content, { format: 'raw' });
}
editor.selection.moveToBookmark(before ? level.beforeBookmark : level.bookmark);
};
示例3:
const deleteImage = (editor: Editor, image: HTMLElement) => {
if (image) {
const elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image;
editor.dom.remove(elm);
editor.focus();
editor.nodeChanged();
if (editor.dom.isEmpty(editor.getBody())) {
editor.setContent('');
editor.selection.setCursorLocation();
}
}
};
示例4: function
//.........这里部分代码省略.........
// Override commands to use the text formatter engine
'Bold,Italic,Underline,Strikethrough,Superscript,Subscript' (command) {
toggleFormat(command);
},
// Override commands to use the text formatter engine
'ForeColor,HiliteColor' (command, ui, value) {
toggleFormat(command, value);
},
'FontName' (command, ui, value) {
FontCommands.fontNameAction(editor, value);
},
'FontSize' (command, ui, value) {
FontCommands.fontSizeAction(editor, value);
},
'RemoveFormat' (command) {
formatter.remove(command);
},
'mceBlockQuote' () {
toggleFormat('blockquote');
},
'FormatBlock' (command, ui, value) {
return toggleFormat(value || 'p');
},
'mceCleanup' () {
const bookmark = selection.getBookmark();
editor.setContent(editor.getContent());
selection.moveToBookmark(bookmark);
},
'mceRemoveNode' (command, ui, value) {
const node = value || selection.getNode();
// Make sure that the body node isn't removed
if (node !== editor.getBody()) {
storeSelection();
editor.dom.remove(node, true);
restoreSelection();
}
},
'mceSelectNodeDepth' (command, ui, value) {
let counter = 0;
dom.getParent(selection.getNode(), function (node) {
if (node.nodeType === 1 && counter++ === value) {
selection.select(node);
return false;
}
}, editor.getBody());
},
'mceSelectNode' (command, ui, value) {
selection.select(value);
},
'mceInsertContent' (command, ui, value) {
InsertContent.insertAtCaret(editor, value);
},