TinyMCE Nested User Formats

I am trying to create a series of inline text templates to split the contents of the TinyMCE editor (4.3.2) into <span>s. I can create my new custom format and register a new text template just fine, but the problem occurs when trying to match nested templates.

TinyMCE initialization code for these custom formats:

formats: {
    'innerFormat': {
        inline: 'span',
        classes: 'inner',
        exact: true,
        selector: 'span.inner'
    },
    'outerFormat': {
        inline: 'span',
        classes: 'outer',
        exact: true,
        selector: 'span.outer'
    }
},
textpattern_patterns: [
    {start: '{{', end: '}}', format: 'innerFormat'},
    {start: '[[', end: ']]', format: 'outerFormat'}
]

I want to type this line in the editor:

[[outerText({{innerText}})]]

and get this markup:

<span class="outer">outerText(<span class="inner">innerText</span>)</span>

but TinyMCE does not recognize the external format ("[[]]") after it matches the internal format ("{{}}"), leaving me with:

[[outerText(<span class="inner">innerText</span>)]]

As far as I know, this is caused by this block of code in the file textpattern/plugin.js: (~ line 101)

rng = selection.getRng(true);
container = rng.startContainer;
offset = rng.startOffset;
text = container.data;
delta = space ? 1 : 0;

, rng.startContainer, <p> text .

TailsMCE textpattern ?

+4

Source: https://habr.com/ru/post/1624903/


All Articles