Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some config data lost when toggling between JavaScript and JSON editors #152

Closed
realjoshharrison opened this issue Dec 4, 2023 · 2 comments
Assignees
Labels

Comments

@realjoshharrison
Copy link

realjoshharrison commented Dec 4, 2023

Description

I think this is more of a UI enhancement/clarification than a bug...

After defining CKEditor config options which include a callback property (using the 'JavaScript' editor mode), toggling to the JSON mode will delete the callback property. Toggling back again to JavaScript mode, the property has been lost.

I now appreciate this is because JSON can't contain functions. But I hadn't considered that when this happened to me, and I thought I was just switching between two different ways of viewing the same data. When I saved, I hadn't realised the callback had been deleted, and all my CKEditor fields which were using this config broke.

So perhaps a warning about potential data loss could be a good idea when switching back from JavaScript to JSON mode? Similar to the warnings you have on field type dropdowns?

Thanks for considering!

Steps to reproduce

  1. Create a new CKEditor config
  2. Switch to the JavaScript config options editor and enter something with a callback. I was using this:
return {
  link: {
    decorators: {
      detectExternalLinks: {
        mode: 'automatic',
        callback: url => ! url.startsWith(window.location.origin),
        attributes: {
          target: '_blank',
          rel: 'noopener noreferrer',
        },
      },
    },
  },
}
  1. Toggle to the JSON config options editor view
  2. The callback has been deleted

Additional info

  • Craft version: 4.5.11.1 Pro
  • PHP version: 8.2.0
  • Database driver & version: MySQL 5.7.39
  • Plugins & versions: CKEditor 3.6.0 (with "nystudio107/craft-code-editor": "1.0.13" in composer.json as per monaco is not defined on CP CKEditor configs #150); CP Field Inspect 1.4.4
@i-just
Copy link
Contributor

i-just commented Feb 22, 2024

Hi, thanks for reporting! We’ll discuss this internally and formulate a plan.

@brandonkelly
Copy link
Member

CKEditor 3.8.1 and 4.0.0-beta.8 are out with a solution for this (#180) 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants