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

loze - September 28, 2008 - 15:13
Title:Dosen't work with tinyMCE» Doesn't work with tinyMCE

#2

mariuss - September 28, 2008 - 17:33

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

loze - September 28, 2008 - 19:37

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

mariuss - September 28, 2008 - 19:49
Status:active» postponed (maintainer needs more info)

Can you please look at the JavaScript console?

#5

loze - September 28, 2008 - 19:56

No errors in the console.

I dont think the onkeyup event is being triggered. or tiymce is overriding it.

#7

a_c_m - September 28, 2008 - 21:00

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

NaX - November 21, 2008 - 11:11
Status:postponed (maintainer needs more info)» needs review

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.

AttachmentSize
editor_plugin.js_.txt 1.43 KB

#9

mike_gie12 - March 9, 2009 - 12:26
Version:6.x-1.x-dev» 5.x-1.0

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

NaX - March 9, 2009 - 13:15

I used TinyMCE Drupal module 5.x-1.9 and TinyMCE version 2.1.3 and Maxlength 5.x-2.0-beta2.

#11

graper - March 25, 2009 - 19:34

I just tried this combination. It worked with CCK text fields that had tinymce turned on, but I did have issues.

  1. Cut and Paste did not update character count
  2. making something bold, underline, or using any of the buttons that add in html did not update the character count
  3. using the link to disable the editor and editing something did not update the character count

Granville

#12

mcload - April 20, 2009 - 17:53

Have the same problem with wysiwyg API with Tinymce on Druapl 6.10. Javascript couter does not work on Tinymce box.
Subscribing.

#13

jberube - June 12, 2009 - 17:08
Version:5.x-1.0» 6.x-2.x-dev

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.

AttachmentSize
editor_plugin.js_.txt 1.21 KB

#14

rolfmeijer - July 1, 2009 - 12:05

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.

 
 

Drupal is a registered trademark of Dries Buytaert.