TinyMCE add div around in the body from the iframe

时光总嘲笑我的痴心妄想 提交于 2021-01-29 16:50:38

问题


I use the TinyMCE. The textarea create the tiny-editor. And the tiny-code create the iframe and in this iframe is the editor. So is it normal!

But now I want a div around the editor, in the body of the iframe. Is there an option to solve my problem?

enter image description here


回答1:


I tried to make something

tinymce.init({
  selector: "#mytextarea",
  tinymce options: ... ,

  toolbar: "add_div",

  setup: function(editor) {

    editor.ui.registry.addButton("add_div", {
    text: "Add Div",
    icon: "plus", // look editor-icon-identifiers page
      onAction: function() {
        var element = tinymce.activeEditor.dom.select("#tinymce");
        var content = element[0].innerHTML;
        element[0].innerHTML = "<div>"+content+"</div>";
      }
    }); // close registry.addButton

  }, // close setup function

}); // close tinymce.init



来源:https://stackoverflow.com/questions/62503369/tinymce-add-div-around-in-the-body-from-the-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!