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

Zero-width spaces cause unwanted wrapping / empty newlines before inline blocks #2231

Closed
k7d opened this issue Oct 5, 2018 · 3 comments · Fixed by #2234
Closed

Zero-width spaces cause unwanted wrapping / empty newlines before inline blocks #2231

k7d opened this issue Oct 5, 2018 · 3 comments · Fixed by #2234

Comments

@k7d
Copy link
Contributor

k7d commented Oct 5, 2018

Do you want to request a feature or report a bug?

Bug

What's the current behavior?

Slate inserts span with zero-width spaces in front of inline blocks
starting at the begging of a line. If the inline block is longer than the line and doesn't have any whitespace in it, it causes a permanent newline before the block. Another sideeffect is that you cannot use key down to move down - the caret is just stuck there. This can be repeated with included links example. Just type some text without whitespace and add a link to it:

image

(see the empty line abobe "longlong..")

This is a common scenario when implementing automatic link wrapping (ie. if I paste a link I want it to get automatically converted to a clickable link).

For now my workaround is to just do this:

span[data-slate-zero-width='z'] {display: none;}

It fixes the issue and seem to not break anything (but I'm not 100% sure).

What's the expected behavior?

There should be no line breaks/empty lines before inline block in the above scenario.

@k7d
Copy link
Contributor Author

k7d commented Oct 5, 2018

Actually display: none on zero-width spans does cause issues. @ianstormtaylor what if we replace U+200B with U+FEFF (ZERO WIDTH NO-BREAK SPACE)?

It seems to both fix the linebreak issue and doesn't breaking existing behaviour (for example adding text before inline block at a beginning of a line).

@ianstormtaylor
Copy link
Owner

@k7d good call, that sounds like a good solution to me!

@k7d
Copy link
Contributor Author

k7d commented Oct 5, 2018

okay cool i'll pr

k7d added a commit to WhimsicalCode/slate that referenced this issue Oct 6, 2018
This fixes ianstormtaylor#2231 where
a rogue empty line appears before an inline block.
k7d added a commit to WhimsicalCode/slate that referenced this issue Oct 6, 2018
This fixes ianstormtaylor#2231 where
a rogue empty line appears before an inline block.
ianstormtaylor pushed a commit that referenced this issue Oct 9, 2018
…2234)

This fixes #2231 where
a rogue empty line appears before an inline block.
jtadmor pushed a commit to jtadmor/slate that referenced this issue Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants