Issue #1664Opened December 17, 2018by frasza0 reactions

Span element gets stripped from editing

Question

We have added button on RTE toolbar so that we can put selected text inside <span>

image

Now, that functionality worked perfectly fine in our previously installed version (0.14.21) but now we updated to 0.14.43 and when I select the text and want to put it in <span> it does it in code, but RTE doesn't make it as element until I reload my template. It acts like part of all text instead of being selectable span block.

image

Generated code:

<div id="i3x1e" style="padding: 10px;">Insert your 
  <a href="" id="ib14x" class="link">text</a> 
  <span id="itjbi" class="span0">here</span>
</div>

Span button code:

rte.add('span', {
    icon: 'Span',
    result: rte => rte.insertHTML(`<span>${rte.selection()}</span>`)
});

Answers (2)

fraszaDecember 18, 20180 reactions

Okay, so we have found a solution by adding data-gjs-type='span' to a span element so the code becomes:

rte.add('span', {
    icon: 'Span',
    result: rte => rte.insertHTML(`<span data-gjs-type='span'>${rte.selection()}</span>`)
});
lock[bot]December 18, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.