Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Where is the right place to add this function: http://www.tinymce.com/wiki.php/API3:event.tinymce.Editor.onDblClick ?
[edit] link fixed
Comments
Comment #1
TwoDThat link didn't work for me, so I'm not sure exactly what you're trying to do. If you mean where to customize the settings, we've got a Drupal hook for that so you don't have to override or hack the init function used by Wysiwyg module.
To implement it, create these files:
sites/default/modules/MYMODULE/MYMODULE.info
sites/default/modules/MYMODULE/MYMODULE.module
Anything put in the
$settings
object will be passed directly to TinyMCE upon init of an instance as the settings parameter (after being converted from PHP types to JavaScript types).We can't however set JavaScript Functions, Function/Object references, or Regular Expressions at this point because those can't be accurately represented as JSON types. If you need that there are other ways, but I'd need to know exactly what part of TinyMCE you need to hook into so I can give an accurate answer which hopefully avoids modifying Wysiwyg or TinyMCE files - so upgrading them will still be easy.
Comment #2
raincloud CreditAttribution: raincloud commentedSorry, I just copied pasted the link.. anyway, here is the working link to tinymce forum post defining the exact same problem that I have now, and third answer in that post contains that link to tinymce onDblClick event which I'd like to override.
http://www.tinymce.com/forum/viewtopic.php?id=28556
In short, the problem is that when you double click a word inside any browser (not necessarily in tinymce, just anywhere) then the browser selects the word and a space behind the word. I need to eliminate that space on doubleclick inside tinymce (it's a special case app). Otherwise, user will have to eliminate it manually each time, many times.
I have some idea how to reach this goal using the onDblClick in tinymce, but the first thing is to be able to catch this event at all, and with Wysiwyg, I don't know the way.
Please let me know of *any* way to define the ed.onDblClick.add(), the less hacking Wysiwyg the better ofc.
Comment #3
alanom CreditAttribution: alanom commentedThe basic question is, how to add a custom function to TinyMCE's initialisation.
If the example in the original post has too many other side issues for a clean answer, here's a nice simple one: how to apply this simple setting, taken from here-
One simple function. Should be easy. How to add it? Adding it as a text string doesn't work. So how?
Then that will be a good general piece of documentation on how to add functions to Drupal wysiwyg tinymce configuration.
edit the original question was almost as simple actually. It's just, how to apply this:
Comment #4
TwoDAh, that makes it clearer, thanks.
Functions or function references can't be passed this way because everything gets passed to the client as a JSON object, which only handles basic data types.
However, TinyMCE also accepts the names of callback functions/methods as strings instead of directly specifying a function, so it is possible to get around this issue. The callback must be globally accessible so it can't be hidden inside closure, but it's possible to specify methods on global objects by typing out their full name: 'MyGlobalObject.SubArray.myCustomSetupCallback'.
First, put your callbacks in their own file:
sites/default/modules/MYMODULE/MYMODULE_tinymce_callbacks.js
Then modify the settings alter hook to add that file and put the callback names in the settings.
Note: I'm not sure exactly why you'd want to remove all
entities, they can be quite useful. Also, when this is done using.innerHTML
, it can have some bad side-effects in browsers, especially IE. The browser doesn't care about white-spaces used for source formatting ("pretty printing") or whether what is read from there gets output using a certain coding style at all. For example, depending on the DocType used in the editing area, all your tags may end up in ALL CAPS and your self-closing tags may be missing the slash. I can't tell for sure if this will happen when.innerHTML
is used in this particular callback, but our Teaser Break plugin suffers from this issue since it's being executed after the contents have been fetched from the editor. Just so you know in case your markup starts looking odd.Comment #5
TwoDComment #6.0
(not verified) CreditAttribution: commentedfix link
Comment #7
will_leamon CreditAttribution: will_leamon commentedCan you help me find out why the following code doesn't work? I'm trying to disable the disability warning in TinyMCE and turn the browser spellcheck back on:
ACK my bad - forgot to change...
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
...to the actual name of the module. Dunce cap accepted.
Comment #8
TwoD:)
Comment #9
rakshithtb CreditAttribution: rakshithtb commentedVery Helpfull. Thank you very much :)
Comment #10
myphi CreditAttribution: myphi commentedI tried the function MYMODULE_tinymce_paste_preprocess_callback.
When I try to paste something nothing happens and I get the error message:
What can I do?
Comment #11
Ali yah CreditAttribution: Ali yah commentedThank you so much :)