Search code examples
javascripttinymce

tinyMCE textpattern plugin is not changing the text as per the patterns specified


I'm having real trouble with tinyMCE's textpattern plugin, which just simply doesn't appear to work. The code below is as basic as I can make it with an example taken directly from the tinyMCE website. But, if I type (c) (for-instance), and then press space or enter (as directed), nothing happens. I would expect tinyMCE to change it. What am I doing incorrectly?

<html>
<head>
    <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
    <script>

        tinymce.init({
            selector: 'textarea',  // change this value according to your HTML
            plugin: 'textpattern',
            textpattern_patterns: [
                {start: '---', replacement: '<hr/>'},
                {start: '--', replacement: '—'},
                {start: '-', replacement: '—'},
                {start: '(c)', replacement: '©'},
                {start: '//brb', replacement: 'Be Right Back'},
                {start: '//heading', replacement: '<h1 style="color: blue">Heading here</h1> <h2>Author: Name here</h2> <p><em>Date: 01/01/2000</em></p> <hr />'},
            ]
        });

    </script>
</head>
<body>
<textarea></textarea>
</body>
</html>```

Solution

  • In taking your configuration and using TinyMCE Fiddle these things seem to be working fine:

    http://fiddle.tinymce.com/zwhaab

    Do they work for you there? If so there is likely something else in your application impacting things.