Add CSS styles to classic editor when in a Web Component#7847
Add CSS styles to classic editor when in a Web Component#7847ywsang wants to merge 4 commits intockeditor:masterfrom
Conversation
|
Hi @ywsang! Sorry for the late reply here. This is an interesting approach. We'd need to add this snippet to all webpack configs (there are quite many of them :D) and cover this in the docs (in the advanced setup guide). What we'd need to be able to take over this from you is a sample of how you use CKEditor 5 in a shadow root and information on which browsers you test. If you could share that information, it'd ensure that we're looking at the same thing. |
Reinmar
left a comment
There was a problem hiding this comment.
As commented. Strongly related to #7846 (review).
|
There has been no activity on this PR for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the contribution, leave a comment or reaction under this PR. |
|
We've closed your PR due to inactivity over the last year. While time has passed, the core of your contribution might still be relevant. If you're able, consider reopening a similar PR. |
Suggested merge commit message (convention)
Other (build-classic): Update webpack config to save styles to global array.
Change any CSS rules with the :root selector to :root, :host to accommodate Web Components.
Additional information
Related to #3891 and #1483.
By default,
style-loaderwill add the CSS styles to the<head>of the document. However, document styles do not get applied to shadow roots as part of Shadow DOM's style encapsulation. Overriding the default behavior by providing a function to theinsertoption saves all of the styles in a global array in addition to adding them to the document<head>allows for adding the styles from the array into a shadow root after it's been initialized.For example, if creating a web component with CKEditor, one could do the following in the constructor:
to add the styles to the shadow root.
This PR also changes any CSS rules with the :root selector to :root, :host, as :root doesn't select anything inside of a web component.