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

Using right arrow key should exit out of inline code markup #2530

Open
zbeyens opened this issue Jul 20, 2023 Discussed in #2479 · 4 comments
Open

Using right arrow key should exit out of inline code markup #2530

zbeyens opened this issue Jul 20, 2023 Discussed in #2479 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed plugin:basic-marks

Comments

@zbeyens
Copy link
Member

zbeyens commented Jul 20, 2023

Discussed in #2479

Originally posted by sepsol August 12, 2021
Description
If I don't have the toolbar and I remove the space after the inline code markup, I have no way to go outside the inline code block on the same line.

Steps

  1. Go to the docs
  2. Scroll down to the bottom of the editor
  3. Try to write something after the inline code markup on the same line, without using the toolbar buttons.

Expectation

The user should be able to use their right arrow key at the very end position inside the inline code markup to either have the current behavior of going to the next existing character, or create a new node with the type of default if there aren't any nodes after the code markup on that line.

Environment

  • slate: 0.63.0
  • slate-react: 0.65.2
  • browser: chrome

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@zbeyens zbeyens added bug Something isn't working help wanted Extra attention is needed plugin:basic-marks labels Jul 20, 2023
@zbeyens
Copy link
Member Author

zbeyens commented Jul 20, 2023

@felixfeng33
Copy link
Collaborator

Do you think this should be fixed in the plate or slate? @zbeyens

@zbeyens
Copy link
Member Author

zbeyens commented Mar 30, 2024

@12joan may have some ideas on that

@12joan
Copy link
Collaborator

12joan commented Mar 30, 2024

I think this would work well as a Plate plugin with options to configure how arrow keys are handled for various marks.

In my app, I created a plugin that sets the "affinity" (whether the cursor is to the left or right of a mark boundary) based on the direction the cursor came from. It would be fairly simple to adapt the same code to stepping in and out of an inline code mark if that's what a particular app wants to implement. Having a toolkit that lets developers configure this for their app would be really powerful.

Handling mark affinity can be really complicated, since Firefox, WebKit and Chrome all handle it slightly differently. Here's a repo containing the plugin code I used in my app; particularly of note are the getMarkBoundaryAffinity and setMarkBoundaryAffinity functions, which I've found to be quite reliable for getting and setting which side of a mark the cursor is on in all browsers.

https://github.com/12joan/plate-mark-affinity/blob/main/src/createMarkAffinityPlugin.ts

I don't have time to add this to Plate, but hopefully if someone else wants to attempt this, the repo above will be a good starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed plugin:basic-marks
Projects
None yet
Development

No branches or pull requests

3 participants