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.

Enter image details here

Here's how < The code> onClick function looks like this.

  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 ()); }   

Suppose the following code does not work within my expectation, I have the following text

My little sheep is

step 1

"Small" was highlighted. "Apple" was selected right pressed

One small lamb in Mary

I got the following console output will get.

  My a & lt; Span brand = "apple" & gt; Slightly & lt; / Span & gt; Lamb kids   

phase 2

"little lamb" was highlighted. "Samsung" was selected OK pressed

In Lamb little lamb

I will get the following console output .

  Mary & lt; Span brand = "Samsung" & gt; A small memory & lt; / Span & gt;   

However, I'm expecting the following output. A period within a period

  Mary & lt; Span brand = "Samsung" & gt; A & lt; Span brand = "apple" & gt; Small & lt; / Span & gt; Lamb's & lt; / Span & gt;   

Is there a way that I can get it this way, I can modify my original code in on Oak

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 & lt; Strong> Tag twice.

However, styles handles the system differently with the 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'}});   

And you will be able to implement a style multiple times for the same selection.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -