Doesn't work with tinyMCE
loze - September 28, 2008 - 15:12
| Project: | Maxlength |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
this is a nice little module. thanks.
it doesn't work with tinyMCE however.
any plans to support that?

#1
#2
Can you give us some more details? What exactly happens when tinyMCE is present?
Can you also check the browser's JavaScript console, to see if there are any JavaScript issues?
#3
this is related to http://drupal.org/node/207230
with tinyMCE enabled the javascript counter doesn't update.
Presumably, if it did, it would count the html tags that the text editor adds as characters. is that correct?
You should consider supporting not counting html tags as characters in the max chars.
#4
Can you please look at the JavaScript console?
#5
No errors in the console.
I dont think the onkeyup event is being triggered. or tiymce is overriding it.
#6
see: http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=7512
and http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/handle_event_c...
#7
tinymce (and other editors) do not edit the normal form input, they copy the data from the input into their own window, which they place over the original input box. Only when the form is submitted is the new data put back. Which is why we would need to use the hooks mentioned in the wiki's above.
We would also need to detect if tinymce was being used, as well as strip out any tags used.
#8
I have sort of found a way around this problem, after many hours of messing with tiny.
What I did was write a plugin for tiny as follows.
Added the directory maxlength to tinymce/jscripts/tiny_mce/plugins
I added the attached file to that dir and duplicated the file calling it editor_plugin_src.js (don’t think this is needed).
Then I added the following to plugin_reg.php in tiny’s module dir.
I placed this at the end of the file just above the
return $plugins;<?php$plugins['maxlength'] = array();
?>
Once this is all done you should now see a new plugin that you can activate when creating your tiny profiles called "Drupal maxlength"
Hope you find that all helpful.
PS. This is all on D5.x. I don’t know if the 6.x js is different.
#9
Hello,
I tried the module + patch and yes indeed a new plugin was added on tinymce, however, it didn't work. What tinymce version did you use for the patch?
Thanks!!
#10
I used TinyMCE Drupal module 5.x-1.9 and TinyMCE version 2.1.3 and Maxlength 5.x-2.0-beta2.
#11
I just tried this combination. It worked with CCK text fields that had tinymce turned on, but I did have issues.
Granville
#12
Have the same problem with wysiwyg API with Tinymce on Druapl 6.10. Javascript couter does not work on Tinymce box.
Subscribing.
#13
Thanks so much for the TinyMCE plugin, NaX.
I modified it to work with TinyMCE 3.x.
First, open sites/all/modules/wysiwyg/editors/tinymce.inc. At the bottom of the file, add this just before " } return $plugins; "
$plugins['maxlength'] = array('path' => $editor['library path'] .'/plugins/maxlength',
'buttons' => array('maxlength' => t('Maxlength compatibility')),
'internal' => TRUE,
'load' => TRUE,
);
Then save the attached file as sites/all/modules/wysiwyg/tinymce/jscripts/tiny_mce/plugins/maxlength/editor_plugin.js
Then enable the "maxlength compatibility" plugin in your WYSIWYG settings.
#14
With the 3.5 version of TinyMCE the plugins path has changed. So the editor_plugin.js should be in sites/all/libraries/tinymce/jscripts/tiny_mce/plugins/maxlength.
I also noticed that this (comment #13) does not work with the 6.x-1.x-dev version of the maxlength module.