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

Add attribute to the <style> tag(s) with CKEditor content CSS styles #6454

Closed
wwalc opened this issue Mar 17, 2020 · 2 comments · Fixed by #6458
Closed

Add attribute to the <style> tag(s) with CKEditor content CSS styles #6454

wwalc opened this issue Mar 17, 2020 · 2 comments · Fixed by #6458
Assignees
Labels
type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@wwalc
Copy link
Member

wwalc commented Mar 17, 2020

Context: we soon may work on a feature, that in order to function properly, must be able to request from CKEditor 5 all CSS that its features defined for the content inside the editor (and pass it somewhere else). Something similar to https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/content-styles.html#the-full-list-of-content-styles but that can be done during runtime and that can be e.g. easily obtained also from builds made with the online builder.

There is a way to find CKEditor 5 styles inside the DOM already, but really hacky. Which is: find all <style> tags and use the content inside only if it contains .ck-content. This is due to the current webpack configuration that injects a <style> tag, which is hard to find in the DOM among other <style> tags.

test: /\.css$/,
use: [
	{
		loader: 'style-loader',
		options: {
			injectType: 'singletonStyleTag'
		}
	},

It would be easier to find this style tag if it was marked somehow (e.g. data-ck="true"). Webpack configuration allows for that: https://github.com/webpack-contrib/style-loader#attributes

So the final output with CKEditor 5 CSS could look:

<style data-ck="true">
...
</style>
@wwalc wwalc added the type:improvement This issue reports a possible enhancement of an existing feature. label Mar 17, 2020
@Reinmar
Copy link
Member

Reinmar commented Mar 17, 2020

👍 

I'm a bit unsure about the attribute name cause we have data-cke-filler and .ck-* prefix for classes. I'm leaning towards data-cke.

BTW, the problem here is that we need to update all our docs and  that people will have to update all of their integrations for this to start to work.

@Reinmar Reinmar added this to the iteration 31 milestone Mar 17, 2020
@pomek pomek self-assigned this Mar 18, 2020
jodator added a commit to ckeditor/ckeditor5-build-decoupled-document that referenced this issue Mar 26, 2020
Other: The inline `style` element which is being produced by Webpack and delivers styles for the editor will have the `[data-cke="true"]` attribute in order to help find CKEditor 5 styles. See ckeditor/ckeditor5#6454.
jodator added a commit to ckeditor/ckeditor5-build-classic that referenced this issue Mar 26, 2020
Other: The inline `style` element which is being produced by Webpack and delivers styles for the editor will have the `[data-cke="true"]` attribute in order to help find CKEditor 5 styles. See ckeditor/ckeditor5#6454.
jodator added a commit to ckeditor/ckeditor5-build-balloon-block that referenced this issue Mar 26, 2020
Other: The inline `style` element which is being produced by Webpack and delivers styles for the editor will have the `[data-cke="true"]` attribute in order to help find CKEditor 5 styles. See ckeditor/ckeditor5#6454.
jodator added a commit to ckeditor/ckeditor5-build-balloon that referenced this issue Mar 26, 2020
Other: The inline `style` element which is being produced by Webpack and delivers styles for the editor will have the `[data-cke="true"]` attribute in order to help find CKEditor 5 styles. See ckeditor/ckeditor5#6454.
jodator added a commit to ckeditor/ckeditor5-build-inline that referenced this issue Mar 26, 2020
Other: The inline `style` element which is being produced by Webpack and delivers styles for the editor will have the `[data-cke="true"]` attribute in order to help find CKEditor 5 styles. See ckeditor/ckeditor5#6454.
jodator added a commit that referenced this issue Mar 26, 2020
Other: The inline `style` element which is being produced by Webpack and delivers styles for the editor will have the `[data-cke="true"]` attribute in order to help find CKEditor 5 styles. Closes #6454.
@Reinmar Reinmar reopened this Apr 1, 2020
@Reinmar
Copy link
Member

Reinmar commented Apr 1, 2020

I think that you forgot about ckeditor5-dev. We need to have the same rules in all our envs, including manual tests and automated tests (if this loader is present there too).

pomek added a commit to ckeditor/ckeditor5-dev that referenced this issue Apr 1, 2020
…and delivers styles for the editor will have the `[data-cke="true"]` attribute in order to help find CKEditor 5 styles. See ckeditor/ckeditor5#6454.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants