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

GHS: Preserving empty inline elements. #14406

Merged
merged 23 commits into from
Jul 13, 2023

Conversation

niegowski
Copy link
Contributor

@niegowski niegowski commented Jun 16, 2023

Suggested merge commit message (convention)

Feature (html-support): Introduced configuration option to allow empty inline elements. Closes #9888.

Other (engine): The DomConverter should allow registering custom matchers to detect inline object elements. See #9888.

Other (source-editing): Fixed formatting of <br> elements in source editing. Whitespaces before <br> element should not be added.


Additional information

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

packages/ckeditor5-html-support/src/converters.ts Outdated Show resolved Hide resolved
editor.data.htmlProcessor.domConverter.registerInlineObjectMatcher( element => (
element.name == definition.view && element.isEmpty ? { name: true } : null
) );
// TODO should it affect spaces vs NBSP in editing pipeline?
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO - resolve before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if an inline object should affect whether NBSPs are rendered around an inline empty element.

Editing view not aware of empty inline object:
2023-07-12 18 14 43
Screenshot 2023-07-12 at 18 17 46

Editing view aware of empty inline object:
2023-07-12 18 16 09
Screenshot 2023-07-12 at 18 18 01

Data output (no matter which option). If rendered as style: inline-block the spaces are visible, otherwise space are collapsed to a single one.
Screenshot 2023-07-12 at 18 16 52

The main problem is that rendering of an inline empty element depends on the style of that element (if it is an inline-block or not).

cc @Reinmar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another approach would be to ignore empty inline elements without any attributes. There still are some side effects but maybe this would be good enough. We simply do not know if the custom CSS class sets the style display: inline-block on the given element.
Screenshot 2023-07-12 at 19 16 31

packages/ckeditor5-html-support/src/dataschema.ts Outdated Show resolved Hide resolved
@niegowski niegowski changed the title PoC of preserving empty inline elements. GHS: Preserving empty inline elements. Jul 12, 2023
@niegowski niegowski requested a review from arkflpc July 12, 2023 17:33
@niegowski niegowski marked this pull request as ready for review July 12, 2023 17:35
@niegowski niegowski merged commit 899250e into master Jul 13, 2023
@niegowski niegowski deleted the ck/9888-preserving-inline-empty-elements branch July 13, 2023 08:56
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] Preserve empty inline elements
2 participants