javascript - Tinymce 3 - insert new content in new block after custom button click -
i want ask if it's possible add new content "outside" of content has beed added recently. so, have custom button adds simple html. , want archive add same html outside of existing one, in place marked green on screenshot. i'm looking way how escape div, , add new html after existing one.
below screenshot, , code - how javascript button in generated - simple.
var oferta = '<div class="col-sm-3"><h1>test</h1></div>' setup: function (ed) { ed.addbutton('example', { title: 'example.desc', image: './/', text: 'oferta', icon: true, onclick: function () { tinymce.execcommand('mceinsertcontent', false, oferta); } }); },
edit: below how looks when hit button 3 times in row.(every next content added existing one.)
is easy try change code example.
setup: function (editor) { ed.addbutton('example', { title: 'example.desc', image: './/', text: 'oferta', icon: true, onclick: function () { var h1 = editor.dom.create('h1'); h1.innertext = 'test'; var oferta = editor.dom.create('div' ,{'class': 'col-sm-3'}); oferta.appendchild(h1); var divs = editor.dom.select('div'); if(divs && divs.length > 0){ editor.dom.insertafter(oferta,divs[divs.length-1]) }else{ tinymce.execcommand('mceinsertcontent', false,oferta.outerhtml); } editor.selection.select(oferta); editor.selection.collapse(true); } }); },
Comments
Post a Comment