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

A period does not stick to the preceding word during word-wrap #8852

Closed
neongreen opened this issue Jan 17, 2021 · 13 comments · Fixed by #8978
Closed

A period does not stick to the preceding word during word-wrap #8852

neongreen opened this issue Jan 17, 2021 · 13 comments · Fixed by #8978
Assignees
Labels
package:engine squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@neongreen
Copy link

📝 Provide detailed reproduction steps (if any)

  1. Open https://ckeditor.com/ckeditor-5/demo/
  2. Make sure you have one line that takes the full editor width and has a link at the end
  3. Type a period . after the link

✔️ Expected result

The link and the period are word-wrapped

❌ Actual result

The period is detached from the word; if I press Enter after that, everything re-wraps normally

Screen.Recording.2021-01-17.at.21.38.02.mov

📃 Other details

  • Browser: Chrome
  • OS: macOS Catalina
  • First affected CKEditor version: ?
  • Installed CKEditor plugins: ?

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

@neongreen neongreen added the type:bug This issue reports a buggy (incorrect) behavior. label Jan 17, 2021
@neongreen
Copy link
Author

Is also reproducible in Safari.

@Mgsy
Copy link
Member

Mgsy commented Jan 18, 2021

Hi, thanks for the report. I can confirm this behaviour.

@Mgsy Mgsy added the squad:core Issue to be handled by the Core team. label Jan 18, 2021
@Mgsy Mgsy added this to the backlog milestone Jan 18, 2021
@oleq
Copy link
Member

oleq commented Jan 26, 2021

This bug is related to the inline filler logic and the filler sequence appearing in the text node

@oleq
Copy link
Member

oleq commented Jan 26, 2021

It could be this method is too permissive

_needsInlineFillerAtSelection() {
if ( this.selection.rangeCount != 1 || !this.selection.isCollapsed ) {
return false;
}
const selectionPosition = this.selection.getFirstPosition();
const selectionParent = selectionPosition.parent;
const selectionOffset = selectionPosition.offset;
// If there is no DOM root we do not care about fillers.
if ( !this.domConverter.mapViewToDom( selectionParent.root ) ) {
return false;
}
if ( !( selectionParent.is( 'element' ) ) ) {
return false;
}
// Prevent adding inline filler inside elements with contenteditable=false.
// https://github.com/ckeditor/ckeditor5-engine/issues/1170
if ( !isEditable( selectionParent ) ) {
return false;
}
// We have block filler, we do not need inline one.
if ( selectionOffset === selectionParent.getFillerOffset() ) {
return false;
}
const nodeBefore = selectionPosition.nodeBefore;
const nodeAfter = selectionPosition.nodeAfter;
if ( nodeBefore instanceof ViewText || nodeAfter instanceof ViewText ) {
return false;
}
return true;
}

@oleq
Copy link
Member

oleq commented Jan 26, 2021

I'm also not sure why the filler persists in nodes that don't need it. This will require some research. 

@oleq oleq modified the milestones: backlog, iteration 40 Jan 26, 2021
@niegowski
Copy link
Contributor

I'm also not sure why the filler persists in nodes that don't need it. This will require some research.

It's to avoid breaking composition while the selection is inside the text node: https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/view/renderer.js#L343-L345

@oleq
Copy link
Member

oleq commented Feb 1, 2021

So this is a "have your cake and eat it" kind of situation? Either the composition works properly or the trailing punctuation behaves as it should?

Do you think there's a chance that moving to beforeinput will allow us to make this filler logic less intrusive?

@niegowski
Copy link
Contributor

Maybe we could consider switching from "zero-width space" to "zero-width no-break space".

@niegowski
Copy link
Contributor

I briefly checked it and replacing '\u200b' with '\ufeff' here

seems to do a trick.

@niegowski niegowski self-assigned this Feb 2, 2021
@niegowski
Copy link
Contributor

Seems that \ufeff is deprecated in the context of word joiner but it is not deprecated in general (https://en.wikipedia.org/wiki/Word_joiner). There is another Unicode character \u2060 (word joiner) that is supposed to replace the usage as word joiner but it has a side effect that it does not render in dev tools. I would still use \ufeff (zero-width non-breaking space) to avoid confusion while debugging in dev tools. WDYT @Reinmar ?

@Reinmar
Copy link
Member

Reinmar commented Feb 2, 2021

It's weird that a word joiner is not displayed in the dev tools. Could you file them a bug report? Their response may actually shed some light on this.

I laughed when I read that \ufeff is BOM :D I forgot about this gem. It makes mi slightly worried to use this character now because there may be some stupid BOM filters implemented in "enterprise" tooling. I've seen such things... But we'll never know if we don't try, so I think we could go with it. However, we'll need to pay attention during QA on whether this works in all browsers and OSes.

@niegowski
Copy link
Contributor

I noticed that some tests in the typing package started to fail after changing ZWS with ZWNBSP because the ZWNBSP does match in regexps to \s:

/\s/.test( '\u200b' ) -> false (ZWS)
/\s/.test( '\ufeff' ) -> true (ZWNBSP)
/\s/.test( '\u2060' ) -> false (WJ)

So there could be many places where this could fail. Taking this and the BOM case I decided to go with WJ option and to report DevTools bug.

@niegowski
Copy link
Contributor

I reported the issue for DevTools: https://bugs.chromium.org/p/chromium/issues/detail?id=1175133

Reinmar added a commit that referenced this issue Feb 18, 2021
Fix (engine): Words should not break on link boundaries. Closes #8852.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants