javascript - CKEditor plugin - How to have a span within a span, by using editor.applyStyle -
Currently, I have a custom plugin dialog with drop down box selection, which I Apple Or Samsung between the tags. Here's how < The code> onClick function looks like this. Suppose the following code does not work within my expectation, I have the following text My little sheep is "Small" was highlighted. "Apple" was selected right pressed One I got the following console output will get. "little lamb" was highlighted. "Samsung" was selected OK pressed In Lamb I will get the following console output . However, I'm expecting the following output. A period within a period Is there a way that I can get it this way, I can modify my original code in The styles of CK editor do not allow the system to apply a style twice, because its first task is to handle styling content. In this we are talking about inline styles and implementing it for example Education does not mean However, styles handles the system differently with the And you will be able to implement a style multiple times for the same selection.
onOk: function () {var dialog = this; // Drop Down box selection can be either "Apple" or "Samsung" var brand = dialog.get value ('tab-brand', 'brand'); Var style = new CKEDITOR.style ({element: 'span', attributes: {"brand": brand}}); Editor. App style (style); Console.log (editor.getData ()); }
step 1
small lamb in Mary
My a & lt; Span brand = "apple" & gt; Slightly & lt; / Span & gt; Lamb kids
phase 2
little lamb
Mary & lt; Span brand = "Samsung" & gt; A small memory & lt; / Span & gt;
Mary & lt; Span brand = "Samsung" & gt; A & lt; Span brand = "apple" & gt; Small & lt; / Span & gt; Lamb's & lt; / Span & gt;
on Oak
& lt; Strong> Tag twice.
data - * properties, because these attributes are used to add information on content rather than the style of the object Therefore instead of using
brand- attribute (which is incorrect in BTW HTML), use
data-brand :
var style = New CKEDITOR style ({element: 'span', attributes: {'data-brand': 'apple'}});
Comments
Post a Comment