TinyMCE模板插件在编辑器中最后插入



我正在使用TinyMCE v4.7.9

使用模板时 (https://www.tinymce.com/docs/plugins/template/(

我想在内容编辑器中最后插入模板,而不是我站立的地方,有什么技巧可以做到这一点吗?我可以在对话框中添加"插入之后"按钮吗?

现在我被困在其他一些 P 标签中,我的模板是 DIV。

问候

经过一些反复试验,没有办法找到答案,我找到了解决方法。

我用

在事件"BeforeSetContent"上的设置中:

editor.on('BeforeSetContent', function (e) {
if (e.content.indexOf("<div data-insertafter") === 0) { //okej, insert after
editor.setContent(editor.getContent() + '<div class="row"></div>');//add an element to in the end
editor.selection.select(editor.getBody(), true);//select al
editor.selection.collapse(false);//set focus on that last div by inverting selection
e.content = e.content.replace("data-insertafter", "");//remove
}
});

您当然可以修改模板插件来执行此操作...每个插件都提供缩小版本和非缩小版本,因此您只需修改非缩小版本即可满足此需求。

最新更新