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

fix: make blockquote shortcut work in starter-kit #4995

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mathias-S
Copy link

Because blockquote uses Mod-Shift-b, and bold uses Mod-b, the bold shortcut will override the blockquote shortcut if added to the extensions later.

Fixes #4994

Please describe your changes

Changed the order in which the bold/blockquote extensions are added in the starter-kit. This is because plugins added later will override plugins added earlier, because of f8efdf7 (#1547).

How did you accomplish your changes

Changed the order in which the bold/blockquote extensions are added in the starter-kit. I realise that this breaks the alphabetical ordering, but it's more important that the shortcuts work correctly.

How have you tested your changes

Tested locally with the Examples/Default editor, which uses starter-kit.

How can we verify your changes

Load the Examples/Default example and check that Mod-shift-b (Control Shift B / Cmd Shift B) toggles Blockquote, and that Mod-b (Control B / Cmd B) toggles Bold, as expected.

Remarks

It would be better if Mod-b didn't override Mod-shift-b regardless of plugin order, but it seems like this is handled by Prosemirror.

Checklist

  • The changes are not breaking the editor
  • Added tests where possible
  • Followed the guidelines
  • Fixed linting issues

Related issues

Because blockquote uses Mod-Shift-b, and bold uses Mod-b,
the bold shortcut will override the blockquote shortcut if added
to the extensions later.

Fixes ueberdosis#4994
Copy link

netlify bot commented Mar 20, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 59c3ca1
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/65faadf211781d0008053cdc
😎 Deploy Preview https://deploy-preview-4995--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rfgamaral
Copy link
Contributor

Important

I'm not a Tiptap maintainer, just someone that cares about it. Opinions are my own, and not the views of Tiptap maintainers.

Relying on code order execution is generally not a good idea to fix an issue like this. There's nothing in the StarterKit code that would make you think that order is important for one to worry about when modifying that file.

IMO, a better solution is to increase the Blockquote extension priority to be higher than the Bold one. This is something we do ourselves in Typist (see here).

@Mathias-S
Copy link
Author

Mathias-S commented Mar 20, 2024

I agree that I'm not a huge fan of simply changing the order, and it should at least have a comment in the code explaining it.

In your own project, it makes a lot of sense to explicitly set priority, but I'm not sure it's the best way to solve it in starter-kit. Priority is explicitly modified based on execution order (see f8efdf7), and if we were to increase Blockquote's priority directly in starter-kit, this might cause other users' custom extensions to no longer override blockquote from the starter-kit.

@rfgamaral
Copy link
Contributor

and if we were to increase Blockquote's priority directly in starter-kit, this might cause other users' custom extensions to no longer override blockquote from the starter-kit.

I personally don't see that as a problem, as long as such a change is marked as breaking change.

Priority is explicitly modified based on execution order (see f8efdf7)

I could be wrong, but I don't think that's related to extensions priorities, that's the ProseMirror plugin order, which is what is run when an extension makes use of addProseMirrorPlugins.

@Mathias-S
Copy link
Author

Mathias-S commented Mar 20, 2024

and if we were to increase Blockquote's priority directly in starter-kit, this might cause other users' custom extensions to no longer override blockquote from the starter-kit.

I personally don't see that as a problem, as long as such a change is marked as breaking change.

I agree, but I doubt TipTap is going to make a breaking release/major version bump to fix such a minor bug. Changing the order within starter-kit fixes the bug without affecting anything else.

Priority is explicitly modified based on execution order (see f8efdf7)

I could be wrong, but I don't think that's related to extensions priorities, that's the ProseMirror plugin order, which is what is run when an extension makes use of addProseMirrorPlugins.

That commit was made in response to #1547, which was about shortcut priority, so it's quite related. In fact, I think this bug is caused by that commit.

@rfgamaral
Copy link
Contributor

I agree, but I doubt TipTap is going to make a breaking release/major version bump to fix such a minor bug.

I don't see why not. If it's a breaking change, no matter how small, it deserves its own major version. It's just a number.

But again, I'm not a maintainer, I don't make decisions, just voicing my own opinion. I tend to prefer explicit code where comments explaining things are avoided, if possible. But that's just me.

@bdbch
Copy link
Contributor

bdbch commented Mar 27, 2024

The change would be fine for me - yet it's something to be discussed as should all extension by themselves have the same priority as others or should they all come with their own "guessed" priorioty based on what could potentially overwrite them?

@bdbch
Copy link
Contributor

bdbch commented Mar 27, 2024

@svenadlung what are your thoughts?

@Nantris
Copy link
Contributor

Nantris commented Apr 12, 2024

yet it's something to be discussed as should all extension by themselves have the same priority as others or should they all come with their own "guessed" priorioty based on what could potentially overwrite them?

The team has already made Link extension a higher priority to address some issues. I think making one other exception is not unreasonable.

To change the priorities would probably fix #4006 (which I do not believe this PR as written would, since it might still affect anyone not using StarterKit)

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

Successfully merging this pull request may close these issues.

[Bug]: Blockquote shortcut does not work when using starter-kit
4 participants