I'm trying to use the codemirror plugin with my CKEditor and I've noticed an issue with its functionality. This plugin provides code coloring for the source view of CKEditor and after the plugin is installed into the ckeditor/plugins directory I enable it by adding these lines to my editor profile under the Advanced section.
config.extraPlugins = 'codemirror';
config.codemirror_theme : 'monokai';
After doing this the plugin appears to be working and the source view of my pages gets syntax highlighting. However, if I edit a page in the source view and click the save button the changes are not saved. The only way I can save the changes made to the source are by leaving the source view and then clicking the save button.
I noticed this issue was mentioned a few years ago but never really addressed. Is this a codemirror issue or a module issue?
Comments
Comment #1
johns996 CreditAttribution: johns996 commentedThis issue was fixed with a new version (1.02) of the plugin.
Comment #2
sirtetCan't get the Codemirror Plugin to work...
Can you post more detailed, what you did to get CodeMirror to work?
My confusion is, is your CodeMirror plugin ending up in the module's plugin directory?
sites/all/modules/ckeditor/ckeditor/plugins/codemirror
or the library's?
sites/all/modules/ckeditor/plugins/codemirror
Second, i am also unsure which file you refer to as the "editor profile":
the module's
sites/all/modules/ckeditor/ckeditor.config.js
or the library's
sites/all/modules/ckeditor/ckeditor/config.js
Third, also not sure about the "Advanced section".
The closest i found is a comment in
sites/all/modules/ckeditor/ckeditor.config.js
i found
http://docs.cksource.com/CKEditor_for_Drupal/Open_Source/Drupal_7/Configuration?page=0,3
which lets me think the module's file and directory are what i need to work with.
but this did not work.
so i tried the library's directory, also no avail...
Thanks,
Thomas
Comment #3
johns996 CreditAttribution: johns996 commentedThomas,
Here's how I got the plugin to work, and this is a bit different than my original method because I found a better way to add plugins to ckeditor in Drupal.
Here are another few notes on the process. First, if you don't see the plugin in the list, make sure that the Unix user the server is running as has permission to read the plugin files. Second, this is the same process I have used to install the now-missing check spelling plugins.
Technically, it is possible to install these plugins directly into your ckeditor download folder (the one located in the libraries directory). If you install a plugin in this way, you have to enable the plugin by adding the config parameters in an the editor profile's advanced section. It is much easier to install the plugins using the process I detailed above but this other method does work.
Comment #4
sirtetThanks, got it working with the libraries API.
What did not work were customisations like
i tried to add that to sites/all/modules/ckeditor/ckeditor.config.js as described in the plugin's readme,
as well as the Custom JavaScript configuration textfield under Configuration > CKEditor > [profile] > Advanced options
Comment #5
johns996 CreditAttribution: johns996 commentedI never got any of the customizations to work either. I only tried the same places you tried but nothing ever worked. If you find anything that does work, post it here.
Comment #6
sirtetNew title reflects the issue much better
Comment #7
Metasequoia CreditAttribution: Metasequoia commentedany progress on this? i would love to get codemirror customizations to work. especially the solarized theme. I tried different ways (as described above) but no success...
Comment #8
candelas CreditAttribution: candelas commentedi was not able to configure it. could someone explain, please? thanks
Comment #9
sirtetHi candelas.
Post #3 describes the needed steps.
Which steps could you execute, where did you fail? What exactly did not work?
Comment #10
whataboutdale CreditAttribution: whataboutdale commentedFor people asking how to add the customizations in order to use themes etc., add those to your ckeditor config.js file. I'm not using the wysiwyg module, but instead the ckeditor module, and I added the customizations to the ckeditor.config.js file and everything works great. Really nice to have those features right in ckeditor source.
PS. Just realized the items that should display buttons such as showFormatButton do not actually show any buttons, but the functions still exist using keyboard shortcuts.
Comment #11
kendouglass CreditAttribution: kendouglass commentedNo:
config.codemirror_theme : 'monokai';
Yes:
config.codemirror_theme = 'monokai';
Also, the only way I could make this plugin work was to add the two config lines in the "Advanced" textfield. Find this textfield at the bottom of the page at admin/config/content/ckeditor/edit/name-of-my-profile
See other themes here: http://codemirror.net/demo/theme.html
Comment #12
Metasequoia CreditAttribution: Metasequoia commented@kendouglass: yes, thats it! finally a decent theme in code editor. thanks a lot!!!
Comment #13
Dave KopecekThanks to @johns996 for #3 and @kendouglass for #11
I used #3 to get things working and #11 to set the theme. I did not need
config.extraPlugins = 'codemirror';
I am using:
If you are having issues MAKE SURE YOUR CODEMIRROR VERSION MATCHES YOUR CKEDITOR VERSION. (Can you tell what I didn't do? Hours of my life I'll never get back)
To check your ckEditor version -> admin/config/content/ckeditor/edit/[your profile] under Editor Appearance, drag the Question Mark "?" icon to your current toolbar and view using the editor.
Additional codemirror releases are available by scrolling down http://ckeditor.com/addon/codemirror
Comment #14
marcoka CreditAttribution: marcoka commentedgreat thank you Dave Kopeced.
BTW this does not worok with ckeditor 4.4.4 and codemirrro 1.11. I tried that first. It works if you download the exact versions Dave mentioned.
anyone got the config running? should this just work when placed in config.js?
Comment #15
Plazik CreditAttribution: Plazik as a volunteer commentedHere is working method:
1. Download CodeMirror http://ckeditor.com/addon/codemirror and place it to
sites/all/libraries/ckeditor/plugins/codemirror
folder.2. Create custom module with code:
3. Go to
admin/config/content/ckeditor
page, edit your profile and enable CodeMirror (Source) Syntax Highlighting plugin.That's all!
Comment #16
Plazik CreditAttribution: Plazik as a volunteer commentedI've created the CKEditor CodeMirror module https://www.drupal.org/project/ckeditor_codemirror.