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.
Hello,
I wanna add a custom plugin to TinyMCE editor. It does not add any button to the editor but it ads a feature where users can right click on a word inside the editor and plugin provides an option to add that word to a custom dictionary and my module will take care of.
How can I achieve that?
Thanks
Comments
Comment #1
TwoDYou can tell Wysiwyg module about plugins by implementing hook_wysiwyg_plugin(), following the example in wysiwyg.api.php.
Then place your plugin's script file as sites/default/libraries/tinymce_plugins/myplugin/editor_plugin.js. You can also place it in your module's folder, and use
base_path() . drupal_get_path('module', 'mymodule') . '/......'
for 'path' instead.Comment #2
atomicreach CreditAttribution: atomicreach commentedThanks, that seems to be working.
One question tho.. What should I call the actual .js file ? Right now I have it called "editor_plugin" in a folder called "customDictionaryContextMenu" inside "inc" folder and extension is "customDictionaryContextMenu" as well....
But it is throwing following errors in the console. What am I missing. Path is right though.
TypeError: this.getDoc(...) is undefined ...urce for: http://domain.com/drupal6/sites/all/libraries/tinymce/jscrip...
tiny_mce.js?0 (line 1)
"NetworkError: 404 Not Found - http://omain.ca/.errordocs/403.html"
403.html
Failed to load: /drupal6/sites/all/modules/xyz/inc/customDictionaryContextMenu
Here is how the hook look like
Comment #3
atomicreach CreditAttribution: atomicreach commentedfollowing fixed it
'path' => drupal_get_path('module', 'xyz') . '/inc/customDictionaryContextMenu/editor_plugin.js',
However, my plugin cannot find TinyMCE instance.... any idea ?
Comment #4
atomicreach CreditAttribution: atomicreach commentedall fixed!! thanks :)
Comment #6
TwoDHehe, you're welcome. :)