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

Soft breaks not detected in macOS Safari #5500

Closed
peteshilling opened this issue Aug 23, 2023 · 2 comments
Closed

Soft breaks not detected in macOS Safari #5500

peteshilling opened this issue Aug 23, 2023 · 2 comments

Comments

@peteshilling
Copy link

Description
Soft breaks (shift + enter) are interpreted as hard breaks in Safari. They are detected correctly in Chrome. I tested the 'is-hotkey' library and 'shift+enter' works fine in Safari, so the bug must be somewhere in the Slate library. If no one has any ideas I can dig deeper and attempt to identify the issue.

Sandbox
https://codesandbox.io/s/slate-reproductions-forked-kxss7c?file=/index.tsx

Steps
To reproduce the behavior:

  1. Visit the sandbox above in Safari
  2. Focus the editor and press shift + enter
  3. An alert will appear saying that a hard break, not a soft break, was detected

Expectation
Soft breaks should be detected in Safari as they are in Chrome.

Environment

  • Slate Version: 0.94.1
  • Operating System: macOS 13.2.1
  • Browser: Safari 16..3

Context
One of the requirements for my editor is that hard and soft breaks are treated differently (double space vs single space)

@lauigi
Copy link
Contributor

lauigi commented Sep 4, 2023

I don't think it is a bug of slate. Please check this demo out: https://developer.mozilla.org/en-US/docs/Web/API/InputEvent/inputType . The behaviour is as same as your demo.
I also found this issue: ckeditor/ckeditor5#13321

And, the "is-hotkey" lib seems only to be using under no HAS_BEFORE_INPUT_SUPPORT env. Enters are handled here:

I suppose that there could be a new feature like checking the shift key's status in some ways if you wanna separate line breaks in safari

@peteshilling
Copy link
Author

Thanks for your reply, @frellica. It looks like you are correct, I wasn't looking deep enough. For whatever reason Safari has designated control+return for the insertLineBreak event type.

I may end up making a special rule for this, since our users expect shift + return to produce a line break, but it doesn't seem like something that Slate should need to account for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants