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

Handle <style> tag #11235

Merged
merged 8 commits into from
Feb 9, 2022
Merged

Handle <style> tag #11235

merged 8 commits into from
Feb 9, 2022

Conversation

maxbarnas
Copy link
Contributor

@maxbarnas maxbarnas commented Feb 8, 2022

Suggested merge commit message (convention)

Other (engine): The <style> tag will not interfere with the editing experience. Closes #11104.

Feature (html-support): Added <style> tag support. Closes #11104.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

@maxbarnas maxbarnas changed the title Ck/11104 handling style Handle <style> tag Feb 8, 2022
@maxbarnas maxbarnas force-pushed the ck/11104-handling-style branch from 3cc51eb to e71d3b5 Compare February 8, 2022 11:43
@maxbarnas maxbarnas marked this pull request as ready for review February 8, 2022 11:47
@maxbarnas maxbarnas force-pushed the ck/11104-handling-style branch from e71d3b5 to db8b2d9 Compare February 8, 2022 12:24
@maxbarnas maxbarnas force-pushed the ck/11104-handling-style branch from db8b2d9 to 003e537 Compare February 8, 2022 13:25
*/

/**
* The {@link module:engine/view/domconverter~DomConverter} detected a `<style>` element that may affect the editing experience.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"While rendering the editor content, the ..."

"To avoid this, the <style> element was replaced with ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


describe( 'StyleElementSupport', () => {
const STYLE = 'div { color: red; }';
const CODE_CPP = 'cout << "Hello World" << endl;';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a leftover from the <script>'s tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@maxbarnas maxbarnas force-pushed the ck/11104-handling-style branch from 420b4e7 to 8e3fede Compare February 9, 2022 11:10
@Reinmar
Copy link
Member

Reinmar commented Feb 9, 2022

I improved the manual tests a bit because there was no place where I could easily test the change.

Issue 1.

I stumbled upon an odd issue (probably not a blocker for this PR).

The below content works fine:

<p>
    x
</p>
<script>a</script><style>a</style>
<p>
    x
</p>

However, this gets miss-formatted after being passed via setData->getData:

<p>
    x
</p>
<script>a</script>
<style>a</style>
<p>
    x
</p>

Upon setData() this becomes:

<p>x</p><script>a</script><p>&nbsp;<style>a</style></p><p>x</p>

For some reason, the new line character is not correctly ignored by DomConverter and probably then we have a chain reaction of incorrect autoparagraphing.

Issue 2.

This issue is not a blocker as well, but should be resolved soon.

Try this:

editor.setData( '<script>a</script>');
editor.getData();

An empty string is returned. Same for a lone <style>. This is probably an excessive "empty content trimming".

@maxbarnas
Copy link
Contributor Author

Second issue is definitely a separate topic that exists for a long time. The first one though... that's new. Should I create a ticket for that?

@Reinmar
Copy link
Member

Reinmar commented Feb 9, 2022

Both deserve tickets. Could you search whether they exist already and if not open new ones? 

I'd also like to prioritize the second one because it may lead to data loss.

@Reinmar
Copy link
Member

Reinmar commented Feb 9, 2022

I commented under the second error, but it makes sense to update both. I'll do that.

@maxbarnas
Copy link
Contributor Author

I commented under the second error, but it makes sense to update both. I'll do that.

Ah! I thought it was specifically directed at the <style> error. Especially since the old one seemed fine before. Thanks for the fix.

@Reinmar
Copy link
Member

Reinmar commented Feb 9, 2022

Both had the same issue – they missed the context of what's happening. Something was detected... but when? Integrators have no idea what DomConverter is. They might even start worrying that their script tags were completely lost. My changes make the former clearer and slightly (although, not completely) help with the latter. So the error could be made even better, explaining that this is happening only inside the editor.

@Reinmar Reinmar merged commit 483bcf9 into master Feb 9, 2022
@Reinmar Reinmar deleted the ck/11104-handling-style branch February 9, 2022 11:36
@maxbarnas
Copy link
Contributor Author

maxbarnas commented Feb 9, 2022

Here are those two tickets for the problems found on review: #11247 and #11248.

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

Successfully merging this pull request may close these issues.

[GHS] Handle <style>
2 participants