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

(Non-breaking Space) Inserted After Custom Container Elements in Inline Widgets #17275

Open
enes-akguen opened this issue Oct 16, 2024 · 2 comments
Labels
type:question This issue asks a question (how to...).

Comments

@enes-akguen
Copy link

enes-akguen commented Oct 16, 2024

I have encountered an issue where   (non-breaking spaces) are automatically inserted after custom container elements (ContainerElement). This occurs specifically when using inline widgets.

I followed the official CKEditor 5 inline widget example to create a custom inline widget. The widget works well, but I noticed that after typing a space following the container element, a   is inserted automatically.

Is there a way to prevent CKEditor from inserting   after container elements, particularly in this scenario with inline widgets? I would appreciate any guidance or potential workarounds for this behavior.

@enes-akguen enes-akguen added the type:question This issue asks a question (how to...). label Oct 16, 2024
@niegowski
Copy link
Contributor

I do not know what element you use for your widget, but it is most probably an element not registered as an inline object in the DomConverter.

For common inline elements that should be treated as an inline object (display inline-block) you could specify more attributes of the element to be recognized as an inline object. For example <span class="placeholder"> could be an inline object but plain <span> would not.

Here is an example from not yet released bookmark feature:

editor.data.htmlProcessor.domConverter.registerInlineObjectMatcher( element => upcastMatcher( element ) );
// Register an inline object matcher so that bookmarks <a>s are correctly recognized as inline elements in editing pipeline.
// This prevents converting spaces around bookmarks to `&nbsp;`s.
editor.editing.view.domConverter.registerInlineObjectMatcher( element => upcastMatcher( element, false ) );

@enes-akguen
Copy link
Author

Thanks, this helped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question This issue asks a question (how to...).
Projects
None yet
Development

No branches or pull requests

2 participants