Closed Mgsy closed 10 months ago
This issue is only reproducible in a very specific situation where:
import 'vanilla-colorful/hex-color-picker.js';
to import { HexColorPicker } from 'vanilla-colorful/hex-color-picker.js';
doesn't help because the whole file is executed during import anyway.import 'vanilla-colorful/hex-color-picker.js';
to import { type HexColorPicker } from 'vanilla-colorful/hex-color-picker.js';
doesn't help because we need the actual class to register it in the CustomElementRegistry
.HexBase
class (parent of HexColorPicker
) instead and defining the custom element conditionally (i.e. if it wasn't defined yet). Unfortunately it's not exported by the vanilla-colorful
package and therefore can't be used. We could ask the package author if they could add an export for us.vanilla-colorful
author to make the custom elements definitions conditional on his end.Still, using a single CKEditor bundle instead of two is the recommended solution in this case as it would allow to avoid code duplication and improve the performance. The details regarding how to do this are in this guide.
Edit: Changing the import from import 'vanilla-colorful/hex-color-picker.js';
to import { HexBase } from 'vanilla-colorful/lib/entrypoints/hex';
(notice no .js
at the end) looks to be working.
📝 Provide detailed reproduction steps (if any)
✔️ Expected result
The editor initializes properly.
❌ Actual result
The error is thrown.
📃 Other details
It seems that the issue is caused by the color picker library, which registers a custom element -
hex-color-picker
(https://github.com/web-padawan/vanilla-colorful/blob/master/src/hex-color-picker.ts#L20). It's fine if we use one build, but when the second one is loaded, the error occurs, as the second build also imports the library (https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/colorpicker/colorpickerview.ts#L20), which tries to registerhex-color-picker
element again, resulting in the mentioned error.If you'd like to see this fixed sooner, add a 👍 reaction to this post.