1
votes

I´m using TinyMCE v4.7.9

When working with templates (https://www.tinymce.com/docs/plugins/template/)

I would like to insert the templates last in content editor, not where i stand, is there some hack to do that? Can i add a button "insert after" on dialog?

Now i'm stuck in some other P tag and my templates are DIVs.

Regards

2

2 Answers

1
votes

After some trial and error and no way to find an answer to this, i found a work around.

I start the templates with <div data-insertafter

in setup on event "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
    }
});
0
votes

You can certainly modify the template plugin to do that...each plugin ships in a minified and non-minified version so you can just modify the non-minified version to address this need.