Problem/Motivation

Fix in this order:

Maintainer must:

  1. Merge MR #9
  2. Tag a new release of ckeditor_codemirror 3.1.1 that includes this merge request fix.
  3. Publish the newly tagged 3.1.1

Once the above is completed and a new 3.1.1 release is published:

  1. composer up ckeditor_codemirror codemirror/codemirror
  2. Verify that codemirror/codemirror has been upgraded to 5.6.21
  3. Rebuild drupal caches
  4. 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 attention

Body:
Hello Christopher and plazik

I 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....

Command icon 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:

Comments

leducdubleuet created an issue. See original summary.

leducdubleuet’s picture

Priority: Normal » Major
someshver’s picture

I am also getting the same issue. Do we have any fix for this issue?

feng-shui’s picture

Bumping 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.

leducdubleuet’s picture

Status: Active » Needs work

I 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 function

Thank you.

cms_macgyver’s picture

Tried 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.

cms_macgyver’s picture

update 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.

liam morland’s picture

It would be helpful for this to be added as a patch that can be applied with Composer.

feng-shui’s picture

I'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.

reepy’s picture

@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/...

feng-shui’s picture

liam morland’s picture

@#11 I was referring to the patch in #8, which is not a patch to this module.

feng-shui’s picture

We'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.

nkasprak’s picture

wisneskit’s picture

Had 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.

protitude’s picture

#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:

    "scripts": {
        "post-drupal-scaffold-cmd": [
            "rm web/libraries/codemirror/lib/codemirror.js && cp patches/codemirror.js web/libraries/codemirror/lib/codemirror.js"
        ],
    }

Now everything is working happily in my deployment. Hopefully this will help others until we get a proper fix upstream

wisneskit’s picture

The 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.

solideogloria’s picture

@reepy, you can download the file to the patches directory and reference the downloaded patch/diff file.

leducdubleuet’s picture

I 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!

solideogloria’s picture

This module is essentially doing nothing when on these versions of Drupal. I don't know how to contribute toward fixing this.

solideogloria changed the visibility of the branch 3531472-drupal-10.5- to hidden.

solideogloria’s picture

Re #16,

Had tried the suggested fix in the docroot/libraries/ckeditor5-source-editing-codemirror/src/sourceeditingcodemirror.js file.

The library wouldn't use the code in the src folder, it uses the minified code file in the build folder.

solideogloria’s picture

Here 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:

  "patches": {
    "codemirror/codemirror": {
      "#3531472: Drupal 10.5 / 11.2 incompatibility": "./patches/ckeditor_codemirror-codemirror-LIBRARY-3531472-copyobj-hasownproperty-fix.diff"
    },

Or use the URL:

  "patches": {
    "codemirror/codemirror": {
      "#3531472: Drupal 10.5 / 11.2 incompatibility": "https://www.drupal.org/files/issues/2025-11-13/ckeditor_codemirror-codemirror-LIBRARY-3531472-copyobj-hasownproperty-fix.diff"
    },

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.

jesss’s picture

Thank you @solideogloria! #24 worked great for me.

ryan-l-robinson’s picture

Patch in #24 worked for me as well.

andrew.wang’s picture

Priority: Major » Critical

Increasing the priority to critical now that Drupal 10.4/11.1 is end-of-life.

ldenna’s picture

Patch in #24 worked for me as well. Thank you so much @solideogloria!

joseph.olstad made their first commit to this issue’s fork.

joseph.olstad’s picture

The 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

joseph.olstad’s picture

Status: Needs work » Reviewed & tested by the community

Upstream MR needs to be merged.

joseph.olstad changed the visibility of the branch 3531472-fix to hidden.

joseph.olstad’s picture

Issue summary: View changes
solideogloria’s picture

The upstream pull request was merged. Now we just wait for the next release, and then update this module's dependencies, right?

joseph.olstad’s picture

yes, that's correct, once it's released we run composer up codemirror/codemirror

specifically, we're looking for codemirror 5.65.21

so once it is tagged/released:

composer require codemirror/codemirror:'^5.65.21'

joseph.olstad’s picture

5.65.21 is now out

composer require codemirror/codemirror:'^5.65.21'
joseph.olstad’s picture

Component: Code » Documentation
Category: Bug report » Support request
Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joseph.olstad’s picture

Maintainer, please credit everyone!

leducdubleuet’s picture

This is great news, thanks to everyone involved!

joseph.olstad’s picture

Status: Fixed » Needs work

This isn't fixed, for some reason asset-packagist or packagist.org has the old version of codemirror 5.65.8

joseph.olstad’s picture

registry.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.

joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Assigned: Unassigned » joseph.olstad
Status: Needs work » Active

joseph.olstad changed the visibility of the branch 3531472-fix to active.

joseph.olstad’s picture

Assigned: joseph.olstad » Unassigned
Issue summary: View changes
Status: Active » Needs review

Please reach out to the maintainers and let them know that they need to action this.

joseph.olstad’s picture

Ok, it's passing tests now. Unrelated fix included for sanity sake.

joseph.olstad’s picture

Component: Documentation » Code
Category: Support request » Bug report
Related issues: +#3540842: Fix test failure
joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Issue summary: View changes

Sent messages to both maintainers of this project.

joseph.olstad’s picture

Issue summary: View changes

  • wells committed 91a6393e on 3.1.x authored by joseph.olstad
    Resolve #3531472 Fix ckeditor 5 regression issue as well as fix broken...
wells’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joseph.olstad’s picture

@wells, please add contribution to us in the contribution record. Currently no one is creditted with fixing this.

Many thanks!

joseph.olstad’s picture

Assigned: Unassigned » joseph.olstad
Status: Fixed » Active

I'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.json

        "codemirror": {
            "type": "package",
            "package": {
                "name": "codemirror/codemirror",
                "version": "5.65.12",
                "type": "drupal-library",
                "extra": {
                    "installer-name": "codemirror"
                },
                "dist": {
                    "url": "https://github.com/components/codemirror/archive/refs/tags/5.65.12.zip",
                    "type": "zip"
                },
                "license": "MIT"
            }
        },
solideogloria’s picture

joseph.olstad’s picture

Status: Active » Fixed

@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.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joseph.olstad’s picture

@wells, reminder, please add contribution to us in the contribution record. Currently no one is creditted with fixing this.

Many thanks!

wells’s picture

@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?

joseph.olstad’s picture

ok 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.

joseph.olstad’s picture

Assigned: joseph.olstad » Unassigned
solideogloria’s picture

Status: Fixed » Needs work

Edit: never mind. I tried again and the dependency updated

solideogloria’s picture

Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.