本文整理汇总了TypeScript中tinymce/core/api/Editor.setContent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setContent函数的具体用法?TypeScript setContent怎么用?TypeScript setContent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setContent函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
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();
}
}
};
示例3: function
suite.asyncTest('_scanForImages', function (editor: Editor, done, fail) {
editor.setContent(imageHtml(testBlobDataUri));
editor._scanForImages().then(function (result) {
const blobInfo = result[0].blobInfo;
LegacyUnit.equal('data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64(), testBlobDataUri);
LegacyUnit.equal(editor.getBody().innerHTML, '<p><img src="' + blobInfo.blobUri() + '"></p>');
LegacyUnit.equal(
'<p><img src="data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64() + '" /></p>',
editor.getContent()
);
LegacyUnit.strictEqual(editor.editorUpload.blobCache.get(blobInfo.id()), blobInfo);
}).then(done).catch(fail);
});
示例4:
tableOpt.filter(Fun.not(isRoot)).each((table) => {
const cursor = Element.fromText('');
Insert.after(table, cursor);
Remove.remove(table);
if (editor.dom.isEmpty(editor.getBody())) {
editor.setContent('');
editor.selection.setCursorLocation();
} else {
const rng = editor.dom.createRng();
rng.setStart(cursor.dom(), 0);
rng.setEnd(cursor.dom(), 0);
editor.selection.setRng(rng);
editor.nodeChanged();
}
});
示例5: switch
const handleMessage = (editor: Editor, api: Types.UrlDialog.UrlDialogInstanceApi, data: any) => {
switch (data.mceAction) {
case 'insertContent':
editor.insertContent(data.content);
break;
case 'setContent':
editor.setContent(data.content);
break;
case 'execCommand':
const ui = Type.isBoolean(data.ui) ? data.ui : false;
editor.execCommand(data.cmd, ui, data.value);
break;
case 'close':
api.close();
break;
case 'block':
api.block(data.message);
break;
case 'unblock':
api.unblock();
break;
}
};