Sunday, 23 September 2018

Custom Format div in TinyMCE Merges with previous div

I have created a custom format in the editor with

array(  
'title' => 'Tab',  
'block' => 'div',  
'classes' => 'tab',
'wrapper' => true,
'exact' => true,
),

I can then use it by selecting some text and choosing my format to get:

<div class="tab">
   <h3>My Content heading 1</h3>
   <p>My first bit of content here...</p>
</div>

So far, so good. However when I select the following text and choose my format it extends the existing div rather than inserting a new one so I end up with:

<div class="tab">
  <h3>My Content heading 1</h3>
  <p>My first bit of content here...</p>
  <h3>My Content heading 2</h3>
  <p>My second bit of content here...</p>
</div>

When what I want is this:

<div class="tab">
  <h3>My Content heading 1</h3>
  <p>My first bit of content here...</p>
</div>
<div class="tab">
  <h3>My Content heading 2</h3>
  <p>My second bit of content here...</p>
</div>

Setting the "exact" parameter when creating the format doesn't seem to change this behaviour when I would expect it to. Help me, please.



from Custom Format div in TinyMCE Merges with previous div

No comments:

Post a Comment