Problem/Motivation
Fix in this order:
Maintainer must:
- Merge MR #9
- Tag a new release of ckeditor_codemirror 3.1.1 that includes this merge request fix.
- Publish the newly tagged 3.1.1
Once the above is completed and a new 3.1.1 release is published:
composer up ckeditor_codemirror codemirror/codemirror- Verify that codemirror/codemirror has been upgraded to 5.6.21
- Rebuild drupal caches
- problem is fixed
Reported regression
After upgrading to Drupal 10.5, this module does not work anymore but ckEditor is working.
Both maintainers Christopher and plazik have been sent the following message:
Date: February 8th 2026
Subject: Your module,ckeditor_codemirror requires attentionBody:
Hello Christopher and plazikI have provided a solution to an important fix for ckeditor_codemirror that affects Drupal 10.5.10, 10.6.2, 11.2.10, 11.3.2. This regression is caused by a CKE v45.x update. The fix is fully tested and provided and described in this issue:
https://www.drupal.org/project/ckeditor_codemirror/issues/3531472
We need you to action the proposed solution asap.
Thank you,
Steps to reproduce
Update to Drupal 10.5 and probably 11.2 and upon viewing source in the editor, it produces this error in the browser console :
Uncaught CKEditorError: obj.hasOwnProperty is not a function
Proposed resolution
See resolution as described above.
For reference purposes:
https://github.com/codemirror/codemirror5/pull/7154
Until then, patching the library as described in #3531472-24: Drupal 10.5 / 11.2 incompatibility
Remaining tasks
See proposed resolution
API changes
API changes have occurred in CKEditor 5 v45.0 that break the plugin. See : https://ckeditor.com/docs/ckeditor5/latest/updating/guides/update-to-45....
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | ckeditor_codemirror-codemirror-LIBRARY-3531472-copyobj-hasownproperty-fix.diff | 583 bytes | solideogloria |
Issue fork ckeditor_codemirror-3531472
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3531472-fix
changes, plain diff MR !9
- 3531472-drupal-10.5-
changes, plain diff MR !7
Comments
Comment #2
leducdubleuet commentedComment #3
someshver commentedI am also getting the same issue. Do we have any fix for this issue?
Comment #4
feng-shui commentedBumping the codemirror/codemirror package in composer.libraries.json from 5.65.8 to 5.65.19 (latest version on the 5.x branch) seems to resolve this issue.
Comment #6
leducdubleuet commentedI tried the patch in the MR but even with codemirror/codemirror version 5.65.19, it still does not work and I get the same error when clicking the "Source" button in the browser's console :
Uncaught CKEditorError: obj.hasOwnProperty is not a functionThank you.
Comment #7
cms_macgyver commentedTried the MR as well.
I even pulled down https://registry.npmjs.org/codemirror/-/codemirror-5.65.19.tgz
and updated libraries/codemirror, but I still get the error.
Comment #8
cms_macgyver commentedupdate libraries/codemirror/lib/codemirror.js
replace the copyObj function with the following
function copyObj(obj, target, overwrite) {
if (!target) { target = {}; }
for (var prop in obj)
{
if (Object.prototype.hasOwnProperty.call(obj, prop) && (overwrite !== false || !Object.prototype.hasOwnProperty.call(target, prop)))
{
target[prop] = obj[prop];
}
}
return target
}
be sure to clear Drupal caches before testing the change.
Comment #9
liam morlandIt would be helpful for this to be added as a patch that can be applied with Composer.
Comment #10
feng-shui commentedI'll try and get some more time on this today, I was working on that MR in the context of an existing site, I need to pull it into a clean D11 site.
Comment #11
reepy commented@liam-morland if you add `.diff` on the end of the MR you get a patch for composer. Just be aware it can change when the MR changes.
https://git.drupalcode.org/project/ckeditor_codemirror/-/merge_requests/...
Comment #12
feng-shui commentedIssue is upstream: https://github.com/cdubz/ckeditor5-source-editing-codemirror/issues/1
Comment #13
liam morland@#11 I was referring to the patch in #8, which is not a patch to this module.
Comment #14
feng-shui commentedWe've resolved this temporarily by building the patched version of the upstream library from the MR, adding a copy of the built js to our site, and then patching this module's ckeditor_codemirror.libraries.yml to load our local version.
Comment #15
nkasprak commentedIssue has been fixed upstream: https://github.com/cdubz/ckeditor5-source-editing-codemirror/issues/1#is...
Comment #16
wisneskit commentedHad tried the suggested fix in the docroot/libraries/ckeditor5-source-editing-codemirror/src/sourceeditingcodemirror.js file.
/**
* Initializes all CodeMirror instances when entering source edit mode.
*
* @param {module:core/editor/editor} editor
*/
function enterEditingSourceMode( editor ) {
const sourceEditing = editor.plugins.get( 'SourceEditing' );
const sourceEditingCodeMirror = editor.plugins.get( 'SourceEditingCodeMirror' );
for ( const [ , viewWrapper ] of sourceEditing._replacedRoots ) {
const textarea = viewWrapper.childNodes[ 0 ];
var options = {};
Object.assign(options, editor.config.get( 'sourceEditingCodeMirror.options' ));
const cmEditor = global.window.CodeMirror.fromTextArea( textarea, options );
cmEditor.on( 'change', () => {
textarea.value = cmEditor.getValue();
textarea.dispatchEvent( new global.window.Event( 'input' ) );
} );
sourceEditingCodeMirror._cmEditors.push( cmEditor );
}
}
However, after clearing cache in local ddev (drush cr) and in drupal itself, the editors in "CodeMirror source editing" options still do not work/display (highlighting, closing tags automatically, etc.). Also, the doing a browser inspect (using Chrome), still seeing the same console error; Uncaught CKEditorError: obj.hasOwnProperty is not a function...
This fix does not seem to work, we had recently updated from 10.4.7 to 10.5.1 when the CKeditor 5 source options stopped working.
Thanks.
Comment #17
protitude commented#8 worked for me, but this is an upstream issue as already stated so I had to hack it in there. Here is what I did to fix the issue temporarily for myself in case it's helpful to others. I patched the file (libraries/codemirror/lib/codemirror.js) as described in #8 — here's a gist in case someone just wants the full file: https://gist.github.com/protitude/9d2992291f86109d5806dbcd1ac5f999
Then I committed that fixed file to my patches directory and updated my composer file to copy the updated file under the scripts section, here's a snippet:
Now everything is working happily in my deployment. Hopefully this will help others until we get a proper fix upstream
Comment #18
wisneskit commentedThe fix does work that #8 had presented, but for me only after making the subsequent change that #17 suggested in the libraries/codemirror/lib/codemirror.js file. Thanks.
Comment #19
solideogloria commented@reepy, you can download the file to the patches directory and reference the downloaded patch/diff file.
Comment #20
leducdubleuet commentedI tried the proposed temporary manual fix with no success...
If this is fixed upstream, what's left to be done in the module to make it work?
Would it be possible to have a new version of this module using the fixed library?
Thank you!
Comment #21
solideogloria commentedThis module is essentially doing nothing when on these versions of Drupal. I don't know how to contribute toward fixing this.
Comment #23
solideogloria commentedRe #16,
The library wouldn't use the code in the
srcfolder, it uses the minified code file in thebuildfolder.Comment #24
solideogloria commentedHere is how to patch and fix the issue on your site automatically with Composer as a workaround.
Download the patch and add the following to your composer.patches.json file:
Or use the URL:
I apologize for the long and bulky file name. I wanted it to be clear that the file is patching the library and not the Drupal module, while still making it clear which module and issue it is for.
Note that the codemirror.js file that is patched does not exist in the GitHub repo. It is probably a build artifact or is specific to an older version. Regardless, I manually created the patch file line by line to apply to the file, and the patch file works.
I verified that the syntax highlighting works after applying the patch with Composer.
Comment #25
jesss commentedThank you @solideogloria! #24 worked great for me.
Comment #26
ryan-l-robinson commentedPatch in #24 worked for me as well.
Comment #27
andrew.wang commentedIncreasing the priority to critical now that Drupal 10.4/11.1 is end-of-life.
Comment #28
ldenna commentedPatch in #24 worked for me as well. Thank you so much @solideogloria!
Comment #31
joseph.olstadThe solution is for this MR upstream to be merged into a new release of the library.
https://github.com/codemirror/codemirror5/pull/7154
Until then, patching the library as described in #3531472-24: Drupal 10.5 / 11.2 incompatibility
Comment #32
joseph.olstadUpstream MR needs to be merged.
Comment #35
joseph.olstadComment #36
solideogloria commentedThe upstream pull request was merged. Now we just wait for the next release, and then update this module's dependencies, right?
Comment #37
joseph.olstadyes, that's correct, once it's released we run
composer up codemirror/codemirrorspecifically, we're looking for codemirror 5.65.21
so once it is tagged/released:
composer require codemirror/codemirror:'^5.65.21'Comment #38
joseph.olstad5.65.21 is now out
Comment #39
joseph.olstadComment #41
joseph.olstadMaintainer, please credit everyone!
Comment #42
leducdubleuet commentedThis is great news, thanks to everyone involved!
Comment #43
joseph.olstadThis isn't fixed, for some reason asset-packagist or packagist.org has the old version of codemirror 5.65.8
Comment #44
joseph.olstadregistry.npmjs.org/codemirror for somehow isn't getting a composer update or is not in asset-packagist.org .
Root composer.json requires codemirror/codemirror ^5.65.21, found codemirror/codemirror[5.65.8] but it does not match the constraint.Comment #45
joseph.olstadComment #46
joseph.olstadComment #49
joseph.olstadPlease reach out to the maintainers and let them know that they need to action this.
Comment #50
joseph.olstadOk, it's passing tests now. Unrelated fix included for sanity sake.
Comment #51
joseph.olstadComment #52
joseph.olstadComment #53
joseph.olstadSent messages to both maintainers of this project.
Comment #54
joseph.olstadComment #56
wellsComment #58
joseph.olstad@wells, please add contribution to us in the contribution record. Currently no one is creditted with fixing this.
Many thanks!
Comment #59
joseph.olstadI've upgraded to ckeditor_codemirror 3.1.1 yet for some reason I am having issues updating to codemirror/codemirror 5.65.21 .
Additionally, it looks like the webform module also needs to be updated. Not sure if this is conflicting in my case?
modules/contrib/webform/composer.libraries.jsonComment #60
solideogloria commentedSame. I opened an issue.
#3572421: Update codemirror/codemirror to 5.65.21
Comment #61
joseph.olstad@solideogloria thanks for opening the related webform issue! This should help also!
ok in my case, due to our stack, we had another spot that was pinned on 5.65.8, I figured it out, created a PR for that also.
Comment #63
joseph.olstad@wells, reminder, please add contribution to us in the contribution record. Currently no one is creditted with fixing this.
Many thanks!
Comment #64
wells@joseph.olstad I believe I have done that.
I’m not able to be active in the Drupal community these days, but I did try to follow the prompts for the new credit granting system.
https://new.drupal.org/contribution-record/11414257
Is something wrong there?
Comment #65
joseph.olstadok ya it looks good, I guess I'm used to seeing it as a maintainer since I maintain so many projects. It's greyed out and they're checked, so that's good.
Comment #66
joseph.olstadComment #67
solideogloria commentedEdit: never mind. I tried again and the dependency updated
Comment #68
solideogloria commented