Created
September 22, 2020 15:25
-
-
Save smailliwcs/8aaaa1324b02d97f5cb7091d14b9fc88 to your computer and use it in GitHub Desktop.
TinyMCE plugin: paragraphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tinymce.PluginManager.add("paragraphs", function (editor) { | |
function insert(place) { | |
var body = editor.getBody(); | |
var paragraph = editor.dom.create("p"); | |
place(paragraph, body); | |
editor.selection.setCursorLocation(paragraph); | |
editor.nodeChanged(); | |
} | |
editor.addMenuItem("paragraph", { | |
text: "Insert paragraph", | |
context: "insert", | |
menu: [ | |
{ | |
text: "At top", | |
onclick: function () { | |
insert(function (paragraph, body) { | |
body.insertBefore(paragraph, body.firstChild); | |
}); | |
} | |
}, | |
{ | |
text: "At bottom", | |
onclick: function () { | |
insert(function (paragraph, body) { | |
body.appendChild(paragraph); | |
}); | |
} | |
} | |
] | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment