问题
Currently I have a textarea using TinyMCE: http://fiddle.tinymce.com/D2gaab
I want to highlight the text between the opening/closing braces. Does someone know if this is possible, and how I can do this?
回答1:
You could consider inserting a <mark>
tag, or another element with inline styling. Also, maybe only insert when the selection has any length.
editor.addButton('spintax', {
text: 'Spintax',
icon: false,
onclick: function () {
editor.focus();
if (editor.selection.getContent().length) {
editor.selection.setContent("{<mark>" + editor.selection.getContent() + '</mark>}');
}
}
});
http://fiddle.tinymce.com/E2gaab
来源:https://stackoverflow.com/questions/52976156/highlight-text-with-tinymce