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

Clicking right side of inserted CKEditor5 element results in extra empty element #13507

Closed
pmagunia opened this issue Feb 21, 2023 · 3 comments
Closed
Labels
package:link squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@pmagunia
Copy link

📝 Provide detailed reproduction steps (if any)

I asked this question on StackOverflow but did not get an answer so re-asking here.

https://stackoverflow.com/questions/75502754/clicking-right-side-of-inserted-ckeditor5-element-results-in-extra-empty-element

I'm trying to insert a button in CKEditor5. Most of it is working OK but when I click on the right side of an inserted element it results in an extra empty element.

Here is the YouTube video of the behavior: https://www.youtube.com/watch?v=XXLyJcJJk00

...And here is the code to insert the View Fragment:

editor.model.change(writer => {
  const viewFragment = editor.data.processor.toView('<a href="' + value.url + '" class="btn btn-' + value.type.toLowerCase() + ' simple-button-plugin">' + value.text + '</a>');
  const modelFragment = editor.data.toModel(viewFragment);
  writer.model.insertContent(modelFragment);
  writer.setSelection( editor.model.document.getRoot(), 'end' );
});

✔️ Expected result

The extra empty element is not added.

❌ Actual result

You can see the result here. There are a number of &NoBreak;

❓ Possible solution

I'm not sure about possible solutions


If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@pmagunia pmagunia added the type:bug This issue reports a buggy (incorrect) behavior. label Feb 21, 2023
@LavrovE
Copy link

LavrovE commented Feb 23, 2024

any updates?

@Witoso
Copy link
Member

Witoso commented Feb 27, 2024

Cannot reproduce in our demos, this was most likely solved in #15051 (v40.2).

@Witoso Witoso closed this as completed Feb 27, 2024
@Witoso Witoso added this to the iteration 69 (v40.2.0) milestone Feb 27, 2024
@Witoso Witoso added package:link squad:core Issue to be handled by the Core team. labels Feb 27, 2024
@Witoso
Copy link
Member

Witoso commented Feb 27, 2024

To add on top of this, &NoBreaks are added only in editing to allow selection movement, it will not be added to the HTML data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:link squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

3 participants