VC has asked for the wisdom of the Perl Monks concerning the following question:
Tinymce ver 4.4
tinymce.init({ selector: "textarea.longdesc", mode: "specific_textareas", plugins: "preview wordcount code paste charmap", toolbar: "cut copy paste | charmap | bold | bullist numlis +t | outdent indent | undo redo | code | preview", menubar: false, toolbar_items_size: 'large', valid_elements: "a[href|target=_blank],strong/b,br,ol,ul,l +i,p,p/h1,p/h2,p/h3,p/h4", max_word: 1300, setup: function (ed) { ed.on('keyup', function (e) { var writtenWords = tinyMCE.activeEditor.getContent +().replace(/(<([^>]+)>)/ig,'').length; var maxWord = ed.settings.max_word; var limited = ""; var content = ed.getContent(); if (writtenWords >= maxWord) { $('.mce-wordcount').css("color", "red"); limited = $.trim(content).split(" ", maxWord); limited = limited.join(" "); ed.setContent(limited); }else if (writtenWords < maxWord) { $('.mce-wordcount').css("color", "green"); } }); } });
This code does not work correctly? help, it works just enough to make me nuts
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: [OT] Limiting word count with TinyMCE
by markong (Pilgrim) on Apr 08, 2019 at 00:39 UTC | |
by VC (Novice) on Apr 08, 2019 at 01:21 UTC | |
by LanX (Saint) on Apr 08, 2019 at 01:57 UTC | |
by VC (Novice) on Apr 08, 2019 at 02:29 UTC | |
Re: [OT] Limiting word count with TinyMCE
by AnomalousMonk (Archbishop) on Apr 07, 2019 at 23:38 UTC |