Html 如何在tinymce 5编辑器之后创建外部div
我已经尝试了两天,在tinymce编辑器之后从tinymce init内部创建一个外部div。我想创建nextElementSibling,以便文本直接显示在tinymce编辑器框的下方/后面。我有很多文档,尝试了很多东西,现在是时候寻求帮助了 下面是在tinymce之外工作的普通jsHtml 如何在tinymce 5编辑器之后创建外部div,html,tinymce,Html,Tinymce,我已经尝试了两天,在tinymce编辑器之后从tinymce init内部创建一个外部div。我想创建nextElementSibling,以便文本直接显示在tinymce编辑器框的下方/后面。我有很多文档,尝试了很多东西,现在是时候寻求帮助了 下面是在tinymce之外工作的普通js var id = getElementById('aboutme'); //this is the html textarea var dv = id.parentNode.insertBefore(
var id = getElementById('aboutme'); //this is the html textarea
var dv = id.parentNode.insertBefore(document.createElement("div"), id.nextSibling);
dv.id = "aboutme_countdown";
dv.textContent = "All Characters Remaining";
dv.style = "display: block";
我需要将js代码转换为tinymce代码,但我没有任何运气
setup: function(ed)
{
var limit = 25;
var pelem = $(ed.getContainer()).find('#aboutme'); //both id and name of html textarea
/* in case the countdown div has not been created we */
/* capture the error and create the element */
try{
var aboutme = pelem.prevObject[0].nextElementSibling || pelem.prevObject[0].nextSibling; //this works
} catch (error) {
/* create the new countdown div */
/* this creates the div after the tinyMCE editor as a separate div */
/* this is the part i cannot get to work after trying many many differt ways and syntax. It tells me the dom does not exist */
var dv = tinymce.activeEditor.dom.create('div', {id: 'aboutme_countdown', style: 'display:block'}, 'All Characters Remaining');
tinymce.activeEditor.selection.setNode(dv);
}//close try catch
}, //close setup
我已经读了很多tinymce文档,直到我准备好尖叫lol。。。帮忙,谢谢
那么这里的正确语法是什么?错误是dom为空
var dv = tinymce.activeEditor.dom.create('div', {id: 'aboutme_countdown', style: 'display:block'}, 'All Characters Remaining');
tinymce.activeEditor.selection.setNode(dv);