Posted by haggins on January 15, 2011 at 1:45pm
9 followers
| Project: | Maxlength |
| Version: | 6.x-2.0-beta2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
| Issue tags: | ckeditor, maxlength, needs backport to D6, tinymce, wysiwyg |
Issue Summary
Attached is a patch against 6.x-2.x-dev and a submodule. If the submodule is enabled your html markup won't be counted anymore. The submodule provides one plugin for each ckeditor and tinymce.
Tinymce untested.
This issue is forked from #314508: Doesn't work with WYSIWYG (tinyMCE and CKeditor)
| Attachment | Size |
|---|---|
| 314508.patch | 3.1 KB |
| wysiwyg_maxlength.tar_.gz | 1.82 KB |
Comments
#1
#2
There are some problems I could not solve so far:
#3
Hi there,
and thank you!
Your patch and module are working real good with TinyMCE right now, I'll be testing them more and more in the next days.
One question:
I'd like to add support for nodepicker and for imagebrowser modules - so I guess I should add something to the function strip_tags() of your module, in order to also strip any [nodepicker==*.] and [ibimage==*.] from the character count.
The two modules always put their output starting with these strings - but I wouldn't know how to add them to your function.
Could you please point me in the right direction?
#4
Hi smoothk,
nice to see it working fine with tinymce, too.
If you want to modify the regular expression of the strip function you need to edit two lines:
1. in line 248 of maxlength.module
2. line 62 of wysiwyg_maxlength/editor_plugin.js (or line 48 in ckeditor_plugin.js)
Maybe it would be more beautiful to call a hook so that everyone can implement it in his custom helper module. It should be possible in any way to deliver the additional regexp within Drupal.settings to the js.
But at the moment editing the lines directly is the only way...
#5
Don't currently have the need for this, but looked at the patch anyway.
The patch appears to have one place where there was no reason for a change (a ) was moved to a a line above), so that should likely be removed.
Personally, I dislike parts of the patch. Having it check if a module exists than calling the function seems a bit unflexiable; it would be better for it to have a way for others to hook in.
A tiny issue, but I think it would be more correct to call it maxlength_allowhtml or at least have maxlength as the start as you're looking to bundle it with maxlength, right? (I personally think it would be better if the main module provides the support if the functionality is light enough. Modulitist is a horrid, horrid disease u.u!)
As for the module itself, check the coding standards handbook page/s and/or use the module coder to clean it up.
#6
Hi folks,
I have a question about this topic, but first I'll contextualize my situation.
I'm putting maxlenght on a textearea that is affected by TinyMCE. It works fine, but there is a problem at the submit. It takes the content of the wysiwyg and validates it WITH the HTML tags.
ie:
* My maxlength is 18
* here is what is shown in tinyMCE --> "This is a sentence" (18 chars there!)
* here is what's in the source --> "<p><strong>This</strong> is a sentence</p>" (42 chars including html tags chars)
When I submit the form, CCK validates the wysiwyg content and notices that 42 chars is higher than 18, so it prints an error!
My question is, is there a way fix that problem.
Tell me what you think
thanks
#7
Any possiblity to get this working in drupal 7?
#8
yes! the new 7.x-3.0-beta1 Release has a new checkbox where you can select if HTML Tags should be stripped out (called "Truncate HTML").
If you enable this, HTML Tags are ignored during the JS Limit Calculation and also during the Drupal Core Calculation.
#9
closed, please create new issues if there is a problem
#10
reopening as this feature is still desired in D6.
haggins' original patch provides html tag stripping to wysiwyg integration, but it's broken for me, in 6.x-2.0-beta2 for non-wysiwyg fields.
#11
here is a patch that updates the patch in OP to work with 6.x-2.0-beta2 and to work when wysiwyg is not enabled (either the editor is disabled by the user, or the module is not enabled at all)
the following changes have been made:
before this is ripe, we should add a setting, so admins can enable and disable this feature. it would also be nice to find a good way to truncate. i haven't looked at the implementation in D7. if they have a good way to truncate we should steal it, otherwise we should punt.
#12
Sorry - above patch has a small but horribly fatal typo. Please try this instead
#13
Hi, thanx for your work. But I don't understand on how to apply it. Is this a patch I have to apply on the patch in #1? Or do I first have to apply patch #1 to the beta-Version of maxlenght (which does not work) and afterwards your patch?
Kind regards