76

Re: Limit the Number of characters entered in the editor

Chrazy wrote:

Having a document structure that is interrupted and incomplete by a character limit is a good idea?

Of course,

Isn't Tinymce designed to meet a myriad of user needs?  The thread clearly underlines that this is a useful and necessary requirment.

I am stunned that admins et al cannot see how necessary it is to limit the users interaction (on occasion) prior to upload.  It is nonsensical to assume that a user will not make mistakes.

It is simple to sanitise the data on posting an pose limitations but modern day users expect limitations to be transparent.  There are some good solutions here (changing colour of background, displaying counter limits et al), I think it would be an excellent addition to tinymce and to be honest currently limits its application.

It is bad business sense to adopt the approach of 'thats not what we designed it for' as ultimately people will go elsewhere.  Tinymce is a brillinat package as are the paid extras.  You should really consider the feedback and requirements of your clients.  I appriciate it is difficult to please everyone but increased capability is surely a strength.

my 2 cents smile

I would also like to see the limit called dynamically (ie via a variable passed per user).  This would be an excellent feature as it would enable rollout capability for specific users who meet different criterea.  I currently use this approach on several of my sites, it works well as spammers tend to walk away whilst real world users stick around and get full usage.  It would be nice to enable this without hacking the life out of an excellent package.

77

Re: Limit the Number of characters entered in the editor

I've been thinking of implementing this as I said in an earlier post. But the main problem is how, what is the purpose of the plugin, how should it function in various scenarios and until I can get a good idea on how to make the plugin I can't develop it. I will try to outline the scenarios below:

Character counting for visual presentation
The problem with having a character limit for visual presentation in a rich text editor is that the same amount of characters can have a dramatically different visual size.

Take these two for example they have the same amount of HTML and Text characters but they are very different in size:
<span style="font-size:10px">TEXT</span>
<span style="font-size:99px">TEXT</span>

Another example where only the characters are different but the width if different:
<b>IIII</b>
<b>MMMM</b>

Character counting for limiting the data length
Another common request is the ability to limit the number of characters since there are limits in the field size at the backend for example when a varchar or char is used for a text field. I can see that this is a problem when using TinyMCE with such systems and swtiching those fields to text fields might produce other issues in the backend system. But the problem here is how to we limit the HTML code for the user in a user friendly way.

This example has the same visual amount of text but they are different in HTML length:
<b>TEXT</b>
<span style="font-weight:bold">TEXT</span>

How do we inform the user that the content is to long in the above example. "Hey your HTML code is to long you need to modify it using the source editor". Does that have any meaning for an end user that knows nothing or little about HTML or database fields.

Also we can't just chop it as suggested in this thread. That would result in broken HTML and then you would have to parse it before presenting it and auto add the closing tags again.

Blocking submit of the form based on the char length
We have the focus for the TinyMCE project to not mess around with the rest of the page unless we really really need to. Having a character counter plugin that would block the submit of the form would go against that philosophy and it's something we don't want to do. So form blocking has do be done by the individual developers and then they can simply do the character length checking they selfs by using these methods.

// Check the actual text
if (tinyMCE.activeEditor.getContent().replace(/<[^>]+>/g, '').length > 100)
   return false;

// Check the actual HTML
if (tinyMCE.activeEditor.getContent().length > 100)
   return false;
Best regards,
Spocke - Main developer of TinyMCE

78

Re: Limit the Number of characters entered in the editor

@spocke:

This is a beautiful explanation of the problem at hand! I've added a link to the relevant FAQ section.

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

79

Re: Limit the Number of characters entered in the editor

spocke wrote:

But the main problem is how, what is the purpose of the plugin, how should it function in various scenarios and until I can get a good idea on how to make the plugin I can't develop it.

Agreed. And your examples fit. But as you wrote yourself, you are looking at the entire scope of capabilities that tinemce has.

So here is a scenario from my own experience:

For visual trimming I found out that 100% of the times I've been asked to limit a character count in wysiwyg editors they lacked 95% (I dare 99.9%) from their actual capabilities.

Such tinymce instance may only allow bold, underscore, italic and maybe a link options for the user.  They are specifically designed to to show some text in some designer's poor template.

Conclusion - chars trimming has nothing to do with their size (in this scenario).

I'm pretty sure writing an all-in-one visual trimmer for tinymce (or any other editor) is quite impossible and must be based on function callback to allow specific cases. Any visual trimmer plug-in I can think of become to specific to implement (you can handle any combination of rules like width, height, curves, char-count or words count (what about links count? let's add this as well, it sound important!).

But I am not sure that  char-count is by any definition a visual trimmer, it counts characters. either visible characters or source characters.

Currently the editor provides the source (and its length) , and with little regex magic (like the one given earlier) anyone can get the visible letters for the scenario I described. If someone needs a more specific solution may he raise his voice and be heard and maybe the mighy spocke will wish to grant him one smile - or write one yourself and share back.

I feel the code above is more than satisfying for most business logic cases, Adding it straight to the documentation would be nice.

(I can't spell or phrase - so I edit.)

Last edited by lilo (2009-12-24 16:21:02)

80

Re: Limit the Number of characters entered in the editor

lilo wrote:

(like the one given earlier) [...] and maybe [...] write one yourself and share back.

[...](I can't spell or phrase - so I edit.)

Gotcha! Why don't you "edit" the solution in question to the wiki? It is a wiki after all...

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

81

Re: Limit the Number of characters entered in the editor

my word and character count:

    tinyMCE.init({
        // General options
        ... etc. etc. ....
       
        setup : function(ed)
        {
            var CW="C";                    // C= count characters - W count words           
            var mCh=255;                  // max  characters
            var mWr=100;                  // max words
            var gia=0;                        // to see alert only 1 time
                        var text;

            ed.onKeyUp.add(function(ed,e)
            {
                var sH=tinyMCE.activeEditor.getContent();
                var sW = (sH.replace(/(<([^>]+)>)/ig,""));
                if (CW=="C")
                {                   
                    if (sH.length>mCh)
                    {                    
                     if (gia==0) alert("NON PUOI SCRIVERE\nPIU' DI"+mCh+"\nCARATTERI");
                     gia=1;
                     tinyMCE.activeEditor.undoManager.undo(); // se super il numero di catatteri ammesso eseguo undo;
                    }
                                        text="<b>NON puoi scrivere più di "+mCh+" caratteri.</b>";
                }
                else if(CW=="W")
                {
                    if (sW.split(' ').length>mWr)
                    {                    
                     if (gia==0) alert("NON PUOI SCRIVERE\nPIU' DI"+mWr+"\nPAROLE");
                     gia=1;
                     tinyMCE.activeEditor.undoManager.undo(); // se super il numero di parole ammesse eseguo undo;
                    }
                                        text="<b>NON puoi scrivere più di "+mWr+" parole.</b>";
                }               
                text="Hai scritto <b>"+sW.split(' ').length+"</b> parole, per un totale di <b>"+sH.length+"</b> caratteri."+text;
                                tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);   
            });
                     }
        });

Last edited by avweb (2010-05-27 13:05:09)

82

Re: Limit the Number of characters entered in the editor

Folks .. check this out:

http://snipt.net/tamewhale/add-word-cou … to-tinymce

Thanks to @tamewhale wink

R

83

Re: Limit the Number of characters entered in the editor

Ok, I can think of an example where I would need this functionality to limit the raw number of characters entered and NOT the number of formatted characters including hidden HTML.

In my example I will be storing the raw text output in a field X in a database. In addition I will also be storing the text including all the HTML formatting in a separate field Y.

Now, I will be applying compression to field Y using an algorythm. Given that my limits will be somewhere around the 32k mark for these fields. I can reliably state that Y's size will *usually* be less than X's. If you're wondering why I don't also want to compress X's value given that I want to compress Y's value, or why indeed I want to store both of these values in the first place instead of just storing the HTML formatted version, the reason is because I need the ability to query over the raw unformatted text, and compressing this value or only storing the HTML formatted value would not facilitate this need.

Also, yes of course I will be performing server side validation *as well* so as to ensure that neither of these values exceed my desired sizes in the event that a user tries to hack the javascript etc. But it would be *nice* for the average user to know what this limit is before they type out war and peace only to hit a button that will perform said server side validation and present them with a warning after the fact. Very frustrating from a user perspective.

Ergo, I could most definitely use a character limiter plugin that simply counted raw text and prevented the user from hitting any key other than backspace when said limit is exceeded.

Cheers,

DaCheat

Last edited by DaCheat (2010-11-30 23:18:34)

84

Re: Limit the Number of characters entered in the editor

I have a suggestion for this - something I've done in the past.
Don't refer to it as a character count limit- Call it "Memory" (inaccurate, but most people get the idea), "Resources", "Space", etc, and show it as either a 0000/4000 or, better yet, as a color changing progress bar that ranges from 0% to 100%, when it reaches 100% (red), you can't enter any more characters.  Will probably want to caption this bar with a note below it stating something along the lines of: "Where did all my resources go?" with a hotlink to switch to HTML view and back.
Just a suggestion.  Someone else can take it and run with it.
Thanks for doing what you do, everyone smile

Edit - this does take a bit of prediction - if you have 4 characters left, and the user tries to create a tag which has a 20 character result, it has to be planned for accordingly- perhaps flashing the memory bar in red to signify there is not enough remaining memory/resources. (Or, perhaps just say that.)

Last edited by theorified (2010-12-29 05:34:05)

85

Re: Limit the Number of characters entered in the editor

sigh...

An outline to count chars / words:

This is the basis for an TMCE implementation which will be included in my next VizBook major upgrade (a guest book style program in Perl been around for years) and ListMerge Perl newsletter mailer major upgrade. This works well and quick even tested parsing very large input.

    //various global vars and reference values
    // included some here to give idea of what I have been doing
    // can easily be implemented for multi textareas on same page

    var element_id_Of_This_TextArea = 'msg';
    var myCharCountDiv = 'charcnt';
    var myWordCountDiv = 'wordcnt';
    var myMaxLengthIs = 2000;
    var useMyLength = true;
    var myMaxWordsIs = 500;
    var useMyWords = true; // **
    // **using 'useMyWords' overrides the character limit option

    var stoppit = false, stoppit2 = false;

    var editorID;
    var rootdom = 'http://dom.dom/';
    var stoppit = false, stoppit2 = false;

    tinyMCE.init({
        // General options  //"textareas",
        mode : "exact",
        elements :  element_id_Of_This_TextArea,   //"msg",
        theme : "advanced",
        skin : "vbook",
        plugins : "emotions,inlinepopups,save",
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,bullist,numlist,outdent,indent,hr,|,forecolor,backcolor,emotions,|,placemailpic,|,undo,redo,removeformat,cleanup",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_buttons4 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "none",
        theme_advanced_resizing : false,

        convert_urls : true,
        relative_urls : false,
        remove_script_host : false,
        document_base_url : rootdom,

        // Example content CSS (should be your site CSS)
        content_css : "tmce/css/vbook.css?" + new Date().getTime(),

        force_p_newlines : true,
        force_br_newlines : false,
        cleanup_on_startup : true,
        cleanup: true,
        entity_encoding : "numeric", //"numeric" "named" "raw"
        object_resizing : false,

        force_hex_style_colors : true,
        paste_remove_spans : true,
        paste_strip_class_attributes : "all",
        paste_remove_styles : true,
        paste_auto_cleanup_on_paste : true,

        paste_block_drop : true,
        paste_text_use_dialog : false,
        convert_fonts_to_spans : true,
        dialog_type : "modal",
        cleanup_callback: 'myCustomCleanup',
        remove_linebreaks : true,

        valid_elements : blah blah,

        //###############
        setup : function(ed) {

            ed.onPaste.add(function(ed, e) {
                //alert('onPaste '+ed+' '+e);
                //var copyContent = myCustomSetContent();
                //tinyMCE.execCommand('mceSetContent',true,copyContent);
                myCustomOnChangeHandler();
            });

            ed.onInit.add(function(ed) {
                var copyContent = myCustomSetFixedContent();
                tinyMCE.execCommand('mceSetContent',true,copyContent);
                myCustomOnChangeHandler();
                showCounters();
            });

            ed.onKeyDown.add(
                function(ed, e) {
                }//end function(ed,e)
            );//end ed.onKeyDown.add
            ed.onChange.add(
                function(ed, e) {
                    myCustomOnChangeHandler();
                }//end function(ed,e)
            );//end ed.onChange.add
            ed.onClick.add(
                function(ed, e) {
                }//end function(ed,e)
            );//end ed.onClick.add
            ed.onReset.add(
                function(ed, e) {
                    myCustomOnChangeHandler();
                }//end function(ed,e)
            );//end ed.onReset.add
            ed.onUndo.add(
                function(ed, e) {
                    myCustomOnChangeHandler();
                }//end function(ed,e)
            );//end ed.onUndo.add
            ed.onRedo.add(
                function(ed, e) {
                    myCustomOnChangeHandler();
                }//end function(ed,e)
            );//end ed.onRedo.add
            ed.onKeyUp.add(
                function(ed, e) {
                    myCustomOnChangeHandler();
                }//end function(ed,e)
            );//end ed.onKeyUp.add

            editorID = ed.id;

        },//end setup : function(ed)
        //##################################


            spellchecker_languages : "+English=en",
            spellchecker_rpc_url : "/tmce/spellchecker/rpc.php",

        init_instance_callback : showstuff()

    });

Note the "entity_encoding..." above. That makes it easy to detect entities and convert to single chars.

The counting html parser "function myCustomOnChangeHandler()" begins with...

var TextAreaLength = tinyMCE.activeEditor.getBody().innerHTML.replace(/(\&nbsp;|\&#160;)+/ig, ' ').replace(/( )+/ig, ' ');

... calling active editor only once with the rest parsing an in-memory variable (TextAreaLength).

That is followed by extensive stripping of various html tags links embeds framesets iframes scripts meta and etc with multiple RegX finishing with...
        TextAreaLength = TextAreaLength.replace(/\s+/, ' ');
        TextAreaLength = TextAreaLength.replace(/ +/g, ' ');
        TextAreaLength = TextAreaLength.replace(/(^\s+|\s+$)/g, '');

So the in memory var ends up with only single characters (some '+' characters and spaces).

Because the entities are forced to "numeric" it is easy to simply...
TextAreaLength = TextAreaLength.replace(/(\&#\d+;)/g, '+');
...converting them to single characters for counting as single chars too.

Words can be easily counted by...
wcount = TextAreaLength.match(/ /g);
...(per wcount.length) after all conversions of superfluous parts are converted to spaces and multiple spaces to singles.

The entire RegX block (mine is many lines) can easily be converted to your preferred server side language so the server side length checking matches that of the JavaScript function (server side checking is FAR more important than client side but its a nice touch for your visitors for you to use both)

Finally in the "myCustomOnChangeHandler()" function the count / warning results are written to innerHTML of a couple of in-your-face larg"ish" DIVs, colour changing PLUS form submission is blocked when limits are reached (and vicky-vercky).

Forget trying to stop further input after max reached as that will cause havoc with the cursor position and drive users nuts; very bad for successful conversions whether part of a transaction form or just info entry form as p****d off users historically VERY often give up and leave.

My implementation also includes a warning when the entire un-parsed input length tags and all exceeds the allowed char max X 2 (or 3.5; you do your own tests to decide that). This entails appearence of another div in RED warning "input is too complex, please simplify" (occasionaly some wallies / morons will paste only html tags just for fun??).

That is about it in a nut shell. My modules include quite a bit more bits and pieces but individuals will want to do their own thing. Just don't try and be too pedantic and work with what TMCE offers; warnings are better than buggy input blocks. Every browser's editor methods create different html code. So that's why TMCE (and other editors) attempt to (forcefully) bring them in to some sort of common output so work with it not against it.

There are MANY different reasons we may want to apply some sort of char / word counting restrictions / notifications and NO ONE has the right to arrogantly put you down or argue your needs if that's what you decide is what you need to do.

As my new sites are still some time off (and therefore so too the inclusion of TMCE text editing methods in a couple of upgraded programs) I hope that helps some put their own counting parser processors together. Try it this way it works well.

Regards.

============================================

PS To observe your parser during development add a plain texarea to your form...
<textarea name="fred" id="fred" rows="10" cols="60"></textarea>

...and write to it at bottom of  myCustomOnChangeHandler() function...
    var observeobj = idIs( 'fred' );
    observeobj.innerHTML = TextAreaLength;

...helped by this object finder function in the page head...

function idIs( id ){  //returnObjById
    var object = null;
    if(document.getElementById) {object = document.getElementById(id);}
    else if(document.all) {object = document.all[id];}
    else if(document.layers) {object = document.layers[id];}
    return object;
}

Also consider copying html code from random real web pages and paste them into your TMCE form; it really helps as you will otherwise invariably enter code as you'd expect it to be.

Last edited by Wombat_AU (2011-01-27 20:21:37)

86

Re: Limit the Number of characters entered in the editor

Could you giva link to demo with this code?

87

Re: Limit the Number of characters entered in the editor

I had some success with this method - but it definitely needs more development (even for my own needs) - i thought i would share in the meantime though


javascript:

tinyMCE.init({
  ...
  handle_event_callback: "charactercount"
});

function charactercount() {
    var text = tinyMCE.selectedInstance.getBody().innerHTML.replace(/(<([^>]+)>)/ig,"");  //'temporary' replace all html code (do not count the html code)
    var tinymce = tinyMCE.selectedInstance; //id of the current tinymce (i had multiple ones)
    var id = tinymce.id.replace('slidetext',''); //# of the tinymce id [mine: id="slidetext<num>"]
    var charleft = (192-(text.length));  //num of characters left
  
    $('#characterlimit'+id).show(); //p tag containing the character limit

     if (text.length >= 192) {
       $('#limit-left-'+tinymce.id).text(charleft+'/192').attr('style','color:red'); //set to red text
     } else {
       $('#limit-left-'+tinymce.id).text(charleft+'/192').attr('style','color:black'); //set to black text
     }
     return true;
  }

html:

  <textarea id="slidetext41"></textarea>
  <p style="float:right;">Characters Left: <span id="limit-left-slidetext41">0/192</span></p>

I would like to STOP the user from continuing to create text once they have reached the limit, but I have yet to figure this out successfully..

Last edited by swiggy (2011-07-20 22:46:24)

88

Re: Limit the Number of characters entered in the editor

swiggy wrote:

I would like to STOP the user from continuing to create text once they have reached the limit

I trust you do "cut" the text on the server-side also? JavaScript can be disabled...

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

89

Re: Limit the Number of characters entered in the editor

Felix Riesterer wrote:
swiggy wrote:

I would like to STOP the user from continuing to create text once they have reached the limit

I trust you do "cut" the text on the server-side also? JavaScript can be disabled...

of course - but to clarify, i want the RTE to stop allowing text input once they reach my selected limit (192 characters after html has been stripped out)

90

Re: Limit the Number of characters entered in the editor

All you can do is listen for keystrokes and remove the redundant content(s).

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

91

Re: Limit the Number of characters entered in the editor

how would i remove just the last character the user entered?

i tried this (but it was VERY buggy because of HTML markup)

var text = tinyMCE.selectedInstance.getBody().innerHTML.replace(/(<([^>]+)>)/ig,"");
if (text.length >= 192){
   var newtext = tinyMCE.selectedInstance.getBody().innerHTML;
   var newtext = text.substring(0,192);
   tinyMCE.activeEditor.setContent(newtext);
}

Last edited by swiggy (2011-07-25 23:06:55)

92

Re: Limit the Number of characters entered in the editor

Yeah, the very idea of "character counting" is a problem when dealing with HTML code, isn't it? This is why I say it is poor application design.

Why don't you cut the contents from within your backend. And if the contents have been cut why don't you inform the author and let him/her re-edit the stuff?

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

93

Re: Limit the Number of characters entered in the editor

Felix Riesterer wrote:

Yeah, the very idea of "character counting" is a problem when dealing with HTML code, isn't it? This is why I say it is poor application design.

Why don't you cut the contents from within your backend. And if the contents have been cut why don't you inform the author and let him/her re-edit the stuff?

might have to consider that

94

Re: Limit the Number of characters entered in the editor

I'm on a crusade to get programmers to abide by two simple rules:
(1) Develop for the end user and
(2) Use quality control measures before releasing software.

TinyMCE is well developed with no inexcusable bugs (follows rule #2). IMHO, it is the best out there that I found. However the response to this post fails the first rule - develop for the end user. TinyMCE is for the copywriter, so put yourself in the mind of a professional copywriter who knows little about HTML coding. TinyMCE is great for that professional.

I've been on numerous forums where the software representative doesn't understand the issue being requested so they come up with excuses why to not accommodate the end user. I'm tired of being told what I need and don't need when they are not immersed in the pages of code and logic that I am.

Although exact character counting is a problem with HTML code present, it can be used as a tool to render the proper format for both design layout and to make the application (TinyMCE) useable by the most inexperienced copywriter. Isn't that what TinyMCE is all about, allowing the inexperienced HTML writer to create properly formatted code?

Character counting is possible, HTML code or not. The limitations should be defined and understood by all end users and employed appropriately. Statistically, counting copy comprised of characters of different widths should result in an average total width [of all copy] plus or minus some standard deviation. The longer the copy, the tighter the standard deviation.

E.g., the savvy user will set the max char limit to the very max (plus some to consider HTML code that wasn't stripped during the counting) and realize that if they go over the limit, then the design will definitely suffer. They will also understand that the design may require fewer characters and adjust appropriately. A character-counting tool will help them visualize, on-the-fly, how many ideas they have left to enter and help prevent them from entering too many ideas in the content before realizing it's too long. Yes Johnnie, it's not a perfect world but limiting the characters will greatly help in the copywriting task.

Why not take the challenge and develop for the end user requests? If you find it may be used by only a couple users, then charge for it and make some money.

Now, go ahead and take on the day.

Last edited by Alta (2011-07-26 16:36:15)

95

Re: Limit the Number of characters entered in the editor

Hey Alta,

you're mixing up two things:

1.) I'm not Moxiecode.
2.) Implementing TinyMCE is not for end-users but for developers.

If you're so bound to write software for the end user then why would you need to put a character limit into your application in the first place? Because the "design" would break otherwise? Because your database structure has a limit on how many characters a post/page/article/whatever can have? In both cases I daresay it's poor application design. Especially for the end user.

Prove me wrong!

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --

96

Re: Limit the Number of characters entered in the editor

Hm... there are some circumstances where you'd want to limit the input size on the front-end though, and it would be handy to be able to do it with a simple option. For instance, now I'm trying to do it to stop users from posting massive blocks of text on their pages in order to 'protect them from themselves.' It doesn't break anything if they do it, but nobody would read anything like that and it looks terrible, so it'd be good to limit it to a sane amount of chars.

97

Re: Limit the Number of characters entered in the editor

What do you want to limit? The number of words, the number of characters, the number of HTML characters or the size of the contents, It sounds like you want to limit the size of the content if so then limiting the number of chars wont do much as explained earlier in this thread.

Best regards,
Spocke - Main developer of TinyMCE

98

Re: Limit the Number of characters entered in the editor

spocke wrote:

What do you want to limit? The number of words, the number of characters, the number of HTML characters or the size of the contents, It sounds like you want to limit the size of the content if so then limiting the number of chars wont do much as explained earlier in this thread.

I think that as base functionality it would be good to simply have a way to limit the number of characters both with and without html included. It would then become the problem of the end user/developer using tinymce to decide and determine how best to implement these to get the results they need for their end users.

I currently need a way to limit the number of characters that are input as a way to control the size of the content. I, however, will not be relying solely on tinymce to make sure that this happens properly. First of all I will not allow my end user to change the font size which will eliminate the possibility to have vastly different font sizes. Quite frankly allowing the user to have the ability to change font sizes in such a varying degree would be foolish on my part and would pretty much guarantee that it will be misused and broken. If I have content that needs to be a different size I will create a new box and store it in a way that will allow me to control that size using CSS and again I remove the possibility to break it from my end user and maintain control. If I am going to allow my end user to create lists I need to make sure that I do the proper testing so that I know how that will end up in my page. Basically if I am going to allow any sort of formatting to happen by my end user and I want to limit characters to maintain design consistency this is on me not on the developers of tinymce to make sure that my end user is not allowed to do something that will break my design consistency. All I really want is a quick and easy way for my end user to see and know if and when they go over the limit I have provided.   

There is no way to totally fix this and give everyone what they want but at least giving the ability to limit text both with and without html added would be a great step and a great addition to the product. It seems like there is a hang up on the development end that if it cannot meet the needs of everyone it is better to do nothing. While I think that makes a bit of sense it is also limiting usage and adding frustration. There is no way to use a limit to control overall display size if you allow the user to change font size(and probably a few other options), however it can be achieved by not allow this to happen. I think that any reasonable person will agree with this either before they spend time testing or shortly after they try to use it that way. Since it is fairly easy to pick and choose which options are included it is not unreasonable to think that the developer will then just remove the elements that cause problems.


So from what I could see reading through the comments basically "simple" additions that will allow a count of the characters both with and without HTML is really all that is needed to appease the majority of the people who have posted here. Of course some people are not going to be able to use it they want they probably think they can but I am sure they can make the necessary adjustments on their own.

99

Re: Limit the Number of characters entered in the editor

One more thing that I forgot to mention above. As I mentioned above it is up to the developer using tinymce to determine which features get included and are available to their end user. If I want to use a character limit as a way to make sure my end user does not put more text into the box than I would like to accommodate I have to limit the ways they can format that text to ensure it will 99.999% of the time work properly. This is no different than if I want to display text of infinite length and size somewhere that has a background other than white(or even white itself). If I do not want my end user to change the color of the text...I simply remove that option. If I do not want my end user to be able to highlight text...I remove that option also. The ability to allow for text to be highlighted and change in color is there even though doing so might cause undesired results in the project or task an individual developer is completing.

Personally I just want to use tinymce to allow the end user to do the little things such as bold and italics. If I choose to have another larger scale sort of style I can do that using style_formats and again I have to be sure that in doing so I am going to maintain the design consistency that I am hoping to achieve.

100

Re: Limit the Number of characters entered in the editor

ahdindy wrote:

I have to be sure that in doing so I am going to maintain the design consistency that I am hoping to achieve.

Usually the "design consistency" is kept by disallowing everything that would require special attributes. The rest is (hopefully semantic) markup which gets styled using CSS.

However a character count in TinyMCE will always be a fishy solution since it can be "wrong" (count <strong>look</strong>: 21 characters for four visible ones!) or manipulated.

Greetings from Germany,

Felix Riesterer.
-- I am neither Moxiecode nor Ephox! --