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.
I've installed the latest version of CKeditor and everything works great. However, I wanted to install the CodeMirror Syntax Highlighting Plugin to use it for my editor.
- Downloaded the plugin: http://ckeditor.com/addon/codemirror
- Extracted the plugin into the plugins directory
- Added this line config.extraPlugins = '[ codemirror ]'; to config.js
When I go to the WYSIWYG Profiles section to enable the plugin it's not there? Has anyone successfully done this? I've also cleared cache multiple times...
Comments
Comment #1
TwoDWysiwyg doesn't use the default config.js file.
You will need to create a small [and reusable] Drupal module to tell Wysiwyg about the plugin instead. See wysiwyg.api.php
sites/all/modules/MYMODULE/MYMODULE.info
sites/all/modules/MYMODULE/MYMODULE.module
Then place the plugin files in sites/all/libraries/ckeditor_plugins/codemirror and you won't have to put them back in sites/all/ckeditor/plugins when you upgrade CKEditor.
If that doesn't work, it may be because CodeMirror doesn't like being an external plugin. In that case, simply change 'internal' to
TRUE
and remove the 'path' key. You should now have "CodeMirror" listed under "Buttons and Plugins".Note however that this may be better suited for integration with the Wysiwyg CodeMagic module, which could do this for you as well as manage any global CodeMirror settings.
Comment #2
superjerms CreditAttribution: superjerms commented@jsheffers - Better yet, add codemirror as a standalone editor, so that effort is focused on making it work directly with WYSIWYG instead of using CKeditor as a proxy. There's work to do on it still, but I was able to get 2.38 working from the patches in that thread.
Comment #3
sirtet@jsheffers
so you had to patch your WYSIWYG Module to get 4.x CKEditor working? WYSIWYG is not yet supporting the 4.x CKEditor. Or did you try the plugin on a 3.6 CKEditor Version? This will not work (for me, changing the version-checking was enough).
@TwoD
your .module code gave me a good challenge, which i luckily completed step by step: missing bracket >> wrong hook name >> wrong array structure.
After finally studying another example, i ended up with this working .module code
so thanks, a nice success-feeling. ;-)
maybe this snippet can be put into CodeMagic, but codemagic (currently) works quite different from the CKEditor-Plugin, so you'd need 2 Vesions of the CodeMirror Lib, which might clash?
@superjerms
sure, standalone CodeMagic would be usefull too. But i guess jsheffers wants to use CodeMirror and CKeditor together, that's my use-case too.
PS:
What currently does work out of the box (no file editing needed) is CodeMirror with CKeditor Module.
Comment #4
TwoDOops, I really messed up that copy-pasted snippet. Sorry about that.
Yes, the CKEditor module guys have [mostly] implemented something I've been wanting to do for a long time; automated plugin file parsing and extraction of the plugin name and all its buttons. It could even be implemented as a separate module using the plugin hook as to not interfere with Wysiwyg while bugs are being worked out, but I've simply not had the time to make something stable enough yet. :(