Problem/Motivation

run Drupal 10 with both Ckeditor5 and/or ckeditor4 and we want to do so without losing ckeditor4 functionality such as codemirror markup (we love codemirror!).

Features

Codemirror with Drupal 10 for ckeditor4 which does not interfere with codemirror support for Drupal 10 ckeditor_codemirror with ckeditor5. This module is for those that want to have codemirror for ckeditor4 and still use ckeditor_codemirror 3.x which only supports ckeditor5 so you end up with two modules ckeditor4_codemirror and ckeditor_codemirror 3.x.

see patch:
https://www.drupal.org/files/issues/2023-06-12/wxt5-3362801.patch
New module solves this:
forked ckeditor_codemirror 2x into ckeditor4_codemirror , fork required some attention to details but is working as expected.
https://drupal.org/project/ckeditor4_codemirror

see upstream
#3362797: ckeditor 4 and ckeditor 5 support simultaneously?

Steps to reproduce

#3362797: ckeditor 4 and ckeditor 5 support simultaneously?

Proposed resolution

#3362797: ckeditor 4 and ckeditor 5 support simultaneously?

Remaining tasks

#3362797: ckeditor 4 and ckeditor 5 support simultaneously?

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Comments

joseph.olstad created an issue. See original summary.

joseph.olstad’s picture

Status: Active » Postponed
joseph.olstad’s picture

perhaps the easiest way would be to fork the 2.x version of this project into a ckeditor4_codemirror project and install both this module for ck5 and the forked one for ck4 at the same time.

This would be the easiest thing to try first! I will try this soon hopefully!

joseph.olstad’s picture

Assigned: Unassigned » joseph.olstad

I'll get to this hopefully in the next 72 hours

joseph.olstad’s picture

https://www.drupal.org/project/ckeditor4_codemirror/releases/1.0.0-alpha1

it's working but I'll polish it up soon, needs likely manual path renames and path fixing for the libraries

joseph.olstad’s picture

Drupalcon 2023 contribution, ckeditor4_codemirror

joseph.olstad’s picture

Status: Postponed » Active
joseph.olstad’s picture

StatusFileSize
new2.19 KB

see patch

joseph.olstad’s picture

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

Might also need something in site-wxt, hoping @smulvih2 can review this.

joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Hmm, this isn't quite ready, when using ckeditor 5 and ckeditor 4 at the same time and installing ckeditor4_codemirror ^1 and ckeditor_codemirror ^3 , ckeditor5 will crash and not load, some js errors, some sort of conflict to resolve.

joseph.olstad’s picture

Assigned: Unassigned » joseph.olstad
Status: Needs review » Active
sylus’s picture

Status: Active » Closed (won't fix)

I talked with @smulvih with this and I think to limit the maintenance and potential problems we just want to go pure CKeditor 5 and address any problems as they arise.

I believe we are close for Drupal 10 and this should be feasible for CKEditor 5.

I hope this is ok any makes sense although I appreciate that this issue was filed so others know they can do both should they choose.

sylus’s picture

Status: Closed (won't fix) » Needs review
sylus’s picture

Ok @smulvih2 talked to me a bit more and I think we agreed that sadly this is probably the best way forward to get people on Drupal 10, and push any content issues in CKEditor 5 to a later release. All of our plugins do work in both CKEditor 4 and 5 except for codemirror in CKEditor 4 which this ticket addresses.

As long as we set a timebox and don't end up support CKEditor 4 for longer then we should then I'm ok with this. :)

joseph.olstad’s picture

ckeditor4_codemirror is working well for us, I updated the installation instructions on the project page.

I will have to double check again to see how well it's working in harmony with ckeditor 5

smulvih2’s picture

Status: Needs review » Needs work

I was able to get working in CKE4, but get an error in console for CKE5:

CKEditorError: plugincollection-soft-required {"missingPlugin":"SourceEditing","requiredBy":"SourceEditingCodeMirror"}
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#erro...

I just added the following to the require section of composer.json, didn't have to use the merge plugin:

"drupal/ckeditor4_codemirror": "^1.0",
"w8tcha/ckeditor-codemirror": "^1.16"
smulvih2’s picture

Status: Needs work » Needs review
StatusFileSize
new546 bytes

I was able to get codemirror working with cke4/cke5 simultaneously, patch attached. I was getting the error when the Source button is not added to CKE5. Once I added the Source button to my new CKE5 text format it works as expected. I can toggle content between CKE4 and CKE5 and get codemirror in both.

Would like to run some more tests against this, like upgrading D9->D10, and fresh install of D10.

joseph.olstad’s picture

ok so I just re-tested ckeditor4_codemirror on a wxt5/D10.0.10 site that has ckeditor 4 , I enabled the ckeditor 5, configured a new text format with ckeditor5 as a wysiwyg

both code mirror in ckeditor 4 and code mirror in ckeditor 5 are working this way.

The way to make this happen is to install and set up the ckeditor4_codemirror module according to the project page installation instructions https://drupal.org/project/ckeditor4_codemirror

This way both ckeditor4 AND ckeditor 5 are able to work correctly with code mirror no conflicts.

I forked the ck4 ckeditor_codemirror branch over into a new project, massaged everything and it's tested , success.
no conflicts with ckeditor_codemirror

Install and configure ckeditor4_codemirror

1. Download and install CKEditor4 CodeMirror module. composer require drupal/ckeditor4_codemirror

2. Install the CKEditor-CodeMirror-Plugin library

For Composer-managed Drupal installations, the recommended method is to use

the Composer Merge Plugin and this module's composer.libraries.json file. From a Composer project root:

a) Execute composer require wikimedia/composer-merge-plugin.

Add the following to the extra section of the root composer.json

file:

        "merge-plugin": {
            "include": [
                "{DOCROOT}/modules/contrib/ckeditor4_codemirror/composer.libraries.json"
            ]
        },

Note: Remember to replace {DOCROOT} with the appropriate root folder for the Drupal installation -- this is likely web or docroot or html.

c) Execute composer install (or, in some cases, composer update --lock).

d) composer require "w8tcha/ckeditor-codemirror":"*"

Post-Installation

  1. Go to "Administration » Configuration » Content authoring » Text formats and editors" (admin/config/content/formats) page.
  2. Click "Configure" for any text format using CKEditor as the text editor.
  3. Under "CKEditor plugin settings", click "CodeMirror" and check "Enable CodeMirror source view syntax highlighting". Make sure that the current toolbar has the "Source" button. Adjust other settings as desired.
  4. Scroll down and click "Save configuration".
  5. Go to node create/edit page, choose the text format with CodeMirror plugin. Press the "Source" button.
joseph.olstad’s picture

@smulvih2 , I was saving my comment after you put yours in,

yes that plugin and module does the trick, no conflict!

smulvih2’s picture

Yep, and don't need the merge plugin to get working. If you were to add "w8tcha/ckeditor-codemirror" to the composer.json for your module then only one require would be needed for WxT. I added a patch for this here - https://www.drupal.org/project/ckeditor4_codemirror/issues/3380761#comment-15189687

sylus’s picture

I got this working and am now calling @joseph drupal module, but for the w8tcha/ckeditor-codemirror I just added it to composer-extdeps as we did for the earlier version to keep things clean. I also took the 1.18.5 version of codemirror which is closer to what we are shipping supporting "codemirror": "^5.65.5"

joseph.olstad’s picture

ya whatever works, as long as it works and looks good, great :)
That merge plugin is from the ckeditor_codemirror instructions, maybe we already have something similar or that functionality is included now in composer by default, not sure.

joseph.olstad’s picture

Wow thanks @smulvih2 for the patch , I'll make a new release of ckeditor4_codemirror with patch from @smulvih2
#3380761: Require w8tcha/ckeditor-codemirror

new release coming right up

joseph.olstad’s picture

ok this simplifies the require process, let me know how this works for you  @smulvih2 / @sylus

  • sylus committed 122c2712 on 5.0.x authored by joseph.olstad
    Issue #3362801 by joseph.olstad, smulvih2: [D10] - codemirror support...
joseph.olstad’s picture

Ok I'll publish release 1.0.2 right away that will specify the ^1.18.5 version of the library instead of ^1.16.0

This way it should avoid a conflict when doing composer up

sylus’s picture

I think you need to revert the patch that @smilvih provided in the other repo since this only works in wxt because that version and others is defined in composer-extdeps.

How your module worked before is the correct way for people using the merge plugin, we just don't need it because we have our own composer registry which push this stuff but others won't have that.

https://github.com/drupalwxt/composer-extdeps/commit/ea80c3339ff6da7bb84...

sylus’s picture

Status: Needs review » Fixed

So just revert this:

https://www.drupal.org/project/ckeditor4_codemirror/issues/3380761

But then in your composer.libraries can update to 1.18.5 if want to target close to the codemirror library. :D We use.

Closing this issue out :)

Committed and attributed!

joseph.olstad’s picture

@sylus, ah oops ok I'll revert and re-tag, thanks for the heads up

Status: Fixed » Closed (fixed)

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

joseph.olstad’s picture

Assigned: joseph.olstad » Unassigned