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

Impossible to place the cursor after a mark (bold, code, etc.) #2572

Open
2 tasks done
rfgamaral opened this issue Feb 23, 2022 · 14 comments
Open
2 tasks done

Impossible to place the cursor after a mark (bold, code, etc.) #2572

rfgamaral opened this issue Feb 23, 2022 · 14 comments
Labels
Info: Help Wanted The issue or pullrequest needs help from the community Type: Bug The issue or pullrequest is related to a bug

Comments

@rfgamaral
Copy link
Contributor

rfgamaral commented Feb 23, 2022

What’s the bug you are facing?

When a mark, such as block, code, etc, is at the end of a paragraph, it's impossible to place the cursor after said mark. Here's a demo with the official Code example:

PowerToys_ZGqX587oSI

How can we reproduce the bug on our side?

See the demo above 👆

Can you provide a CodeSandbox?

n/a

What did you expect to happen?

One should always be able to type anything after a mark, even if it's the last mark on a paragraph.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖 (on behalf of Doist)
@rfgamaral rfgamaral added the Type: Bug The issue or pullrequest is related to a bug label Feb 23, 2022
@sjdemartini
Copy link
Contributor

I'm also encountering this problem. This seems related to these other two issues #514, #2571 (the first of which is a longstanding one).

@rfgamaral
Copy link
Contributor Author

I'm assuming this is the default behavior, and that one can "exit" the mark by using a keyboard shortcut (or the toolbar buttons, if available). However, I don't think the Link extension should work like that, and I've personally disabled this for us: https://tiptap.dev/api/schema#inclusive

@philippkuehn
Copy link
Contributor

Yes, this is a problem, but I don't know yet in which scope we want to solve this problem. Just adding keyboard shortcuts for this could be enough, but it also helps to show this visually with another cursor. That is rather hacky though.

@rfgamaral
Copy link
Contributor Author

Keyboards shortcuts already work to "leave the mark", so it's not so bad as I originally thought.

It would be nice to have something like that for all marks, built-in, and less hacky. But I understand it might be tricky to implement.

Thanks for getting back to me on this, and hopefully you folks will be able to improve this in the future 👍

@stale
Copy link

stale bot commented Jul 6, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 6, 2022
@stale stale bot closed this as completed Jul 14, 2022
@rfgamaral
Copy link
Contributor Author

@bdbch This issue still exists, and it's a very annoying one, can we reopen it, and keep it tracked?

Although workarounds exists for some marks, I don't think it's possible to exit an inclusive link mark. This is a very annoying issue for us, and that's why we have inclusive: false, but we'd rather have it set to true.

@rfgamaral rfgamaral changed the title It's impossible to place the cursor after a mark (bold, code, etc.) Impossible to place the cursor after a mark (bold, code, etc.) Nov 24, 2022
@bdbch bdbch reopened this Nov 25, 2022
@bdbch
Copy link
Contributor

bdbch commented Nov 25, 2022

I've reopened this issue and added it to our tracker. Thanks for pinging @rfgamaral

@github-actions
Copy link
Contributor

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label Feb 26, 2023
@bdbch
Copy link
Contributor

bdbch commented Feb 26, 2023

bump

@github-actions github-actions bot removed the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label Feb 27, 2023
@chrislicodes
Copy link

Same issue here

@linuxhackr
Copy link

Any update on this?

@bdbch
Copy link
Contributor

bdbch commented Aug 4, 2023

Sadly not. I didn't had time to get to this issue yet.

@bdbch bdbch added the Info: Help Wanted The issue or pullrequest needs help from the community label Aug 4, 2023
@olejorgenb
Copy link

I think I've seen other editors handle this (though, usually semi-buggy..) by using the right key to "break free" from the mark. I think this has only been active when there's nothing to the right of the mark[1]. Eg.: BOLD| pressing right would not move the cursor, but it would move "out" of the mark, disabling bold.

[1] which make sense, since if there's something there you can usually just move until you're outside the mark.

@C-Hess
Copy link
Contributor

C-Hess commented Oct 30, 2023

I'm currently experimenting with an interesting solution using zero-width characters:

  addKeyboardShortcuts() {
    return {
      'Mod-e': () => this.editor.commands.toggleCode(),
      // right arrow
      'ArrowRight': () => this.editor.commands.command(({ tr }) => {
        tr.removeStoredMark(this.type)
        // Insert zero-width character to escape the mark
        tr.insertText('\u200B', tr.selection.from, tr.selection.to)
        return true;
      }),
    }
  },

An advantage of this approach is we don't have to "simulate" a separate cursor. Now the tougher question is how can we strip out this zero-width character. Maybe I could create some pseudo-node that removes itself whenever content is added to it and insert that instead... I'll try and mess around with this more when I have the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Info: Help Wanted The issue or pullrequest needs help from the community Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Triage Done
Development

No branches or pull requests

8 participants