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

Multiple hotkeys for headings #539

Merged
merged 2 commits into from
Mar 5, 2021
Merged

Conversation

dylans
Copy link
Collaborator

@dylans dylans commented Mar 3, 2021

Issue

When specifying options for headings, only 1 hotkey would get handled (refs #518)

What I did

  • Added support for multiple hotkey handlers by treating the key passed in as a string or array
  • Updated stories invoking the heading plugin to add hotkeys for h1, h2, and h3

Checklist

  • The new code matches the existing patterns and styles.
  • The stories still work (run yarn storybook).
  • The stories are updated when relevant: stories for plugins, knobs for options.

@dylans dylans requested a review from zbeyens as a code owner March 3, 2021 14:09
@codecov
Copy link

codecov bot commented Mar 3, 2021

Codecov Report

Merging #539 (21c7cd4) into next (fcc04f8) will decrease coverage by 0.31%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next     #539      +/-   ##
==========================================
- Coverage   76.93%   76.61%   -0.32%     
==========================================
  Files         339      339              
  Lines        4063     4076      +13     
  Branches      871      875       +4     
==========================================
- Hits         3126     3123       -3     
- Misses        933      949      +16     
  Partials        4        4              
Impacted Files Coverage Δ
...late-plugins/src/elements/heading/HeadingPlugin.ts 100.00% <ø> (ø)
...c/common/utils/getOnHotkeyToggleNodeTypeDefault.ts 70.00% <50.00%> (-30.00%) ⬇️
...gins/src/common/utils/getOnHotkeyToggleNodeType.ts 30.76% <0.00%> (-30.77%) ⬇️
...es/slate-plugins/src/common/queries/queryEditor.ts 0.00% <0.00%> (ø)
...late-plugins/src/dnd/hooks/useDropBlockOnEditor.ts 27.50% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcc04f8...21c7cd4. Read the comment docs.

Comment on lines 152 to 168
plugins.push(
HeadingPlugin({
...options,
h1: {
...options.h1,
hotkey: ['mod+opt+1', 'mod+shift+1'],
},
h2: {
...options.h2,
hotkey: ['mod+opt+2', 'mod+shift+2'],
},
h3: {
...options.h3,
hotkey: ['mod+opt+3', 'mod+shift+3'],
},
})
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you set these options in options so we don't have to duplicate in all stories?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if this update is what you had in mind, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@zbeyens zbeyens merged commit 7bca4d5 into udecode:next Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants