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

Merged

Conversation

Mathias-S
Copy link
Contributor

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

Sorry, something went wrong.

Copy link

netlify bot commented Mar 20, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit 03e6f23
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/66857f3dfa0452000881e7a0
😎 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
Contributor 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
Contributor 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
Member

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
Member

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)

@Mathias-S
Copy link
Contributor Author

Anything that should be changed in order to get this merged?

I agree with other commenters that finding a more reliable way of fixing this issue would be a good idea, but this specific change will simply fix the bug in starter-kit without really introducing any other possible issues, so it should be the lowest-risk way of fixing the bug and will help everyone just using the starter-kit.

@nperez0111
Copy link

Yea, I think that this is fine to merge in as is. I'll get it in

@nperez0111 nperez0111 changed the base branch from main to develop July 3, 2024 16:40
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
@nperez0111 nperez0111 force-pushed the fix/starter-kit-blockquote-shortcut branch from 59c3ca1 to dea216c Compare July 3, 2024 16:40
Copy link

changeset-bot bot commented Jul 3, 2024

🦋 Changeset detected

Latest commit: 03e6f23

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 54 packages
Name Type
@tiptap/starter-kit Patch
@tiptap/core Patch
@tiptap/extension-blockquote Patch
@tiptap/extension-bold Patch
@tiptap/extension-bubble-menu Patch
@tiptap/extension-bullet-list Patch
@tiptap/extension-character-count Patch
@tiptap/extension-code-block-lowlight Patch
@tiptap/extension-code-block Patch
@tiptap/extension-code Patch
@tiptap/extension-collaboration-cursor Patch
@tiptap/extension-collaboration Patch
@tiptap/extension-color Patch
@tiptap/extension-document Patch
@tiptap/extension-dropcursor Patch
@tiptap/extension-floating-menu Patch
@tiptap/extension-focus Patch
@tiptap/extension-font-family Patch
@tiptap/extension-gapcursor Patch
@tiptap/extension-hard-break Patch
@tiptap/extension-heading Patch
@tiptap/extension-highlight Patch
@tiptap/extension-history Patch
@tiptap/extension-horizontal-rule Patch
@tiptap/extension-image Patch
@tiptap/extension-italic Patch
@tiptap/extension-link Patch
@tiptap/extension-list-item Patch
@tiptap/extension-list-keymap Patch
@tiptap/extension-mention Patch
@tiptap/extension-ordered-list Patch
@tiptap/extension-paragraph Patch
@tiptap/extension-placeholder Patch
@tiptap/extension-strike Patch
@tiptap/extension-subscript Patch
@tiptap/extension-superscript Patch
@tiptap/extension-table-cell Patch
@tiptap/extension-table-header Patch
@tiptap/extension-table-row Patch
@tiptap/extension-table Patch
@tiptap/extension-task-item Patch
@tiptap/extension-task-list Patch
@tiptap/extension-text-align Patch
@tiptap/extension-text-style Patch
@tiptap/extension-text Patch
@tiptap/extension-typography Patch
@tiptap/extension-underline Patch
@tiptap/extension-youtube Patch
@tiptap/html Patch
@tiptap/pm Patch
@tiptap/react Patch
@tiptap/suggestion Patch
@tiptap/vue-2 Patch
@tiptap/vue-3 Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Verified

This commit was created on github.com and signed with GitHub’s verified signature.
@nperez0111 nperez0111 merged commit d5e10dc into ueberdosis:develop Jul 3, 2024
7 of 14 checks passed
@nperez0111 nperez0111 mentioned this pull request Jul 13, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

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