Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest an entirely different approach. (F)CKEditor can already do what you want. Just try to add a table in the middle of a paragraph. It will close the inline tag stack, add the table, and reopen the stack again.</p> <p>I suggest that, instead of having your users write {widget}, you write an (F)CKEditor plugin that adds the widgets for you. You can take a look at the code for the table button (or any other block-level element) to see how (F)CKEditor inserts them.</p> <p>There are two things you can do when a user hits the "widget" button. Eitther you insert some custom tag such as <code>&lt;widget type="foo" /&gt;</code>, or you insert a HTML tag that you can recognise later on, like <code>&lt;div class="widget foo"&gt;&lt;/div&gt;</code>.</p> <p>With some extra elbow grease you can even make this fancier by actually loading the widget itself, wrapped in such tags. That way, the user would see exactly the same in the editor window as when it was stored. When the editor saves to the server, simply empty the tags wrapping the widget to get rid of it.</p> <p>Example workflow (cursor marked by | sign):</p> <p>User types text:</p> <pre><code>&lt;p&gt;foo bar| baz&lt;/p&gt; </code></pre> <p>User hits "widget" button:</p> <pre><code>&lt;p&gt;foo bar&lt;/p&gt; &lt;div class="widget foo"&gt; ... contents of "foo" widget ... &lt;/div&gt; &lt;p&gt;|baz&lt;/p&gt; </code></pre> <p>When saving, drop the widget contents:</p> <pre><code>&lt;p&gt;foo bar&lt;/p&gt; &lt;div class="widget foo"&gt;&lt;/div&gt; &lt;p&gt;baz&lt;/p&gt; </code></pre> <p>When displaying the saved contents, parse for div tags with a "widget" class and dynamically fill it:</p> <pre><code>&lt;p&gt;foo bar&lt;/p&gt; &lt;div class="widget foo"&gt; ... contents of "foo" widget ... &lt;/div&gt; &lt;p&gt;baz&lt;/p&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload