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

Fixed issues with keyboard-shortcuts in tiptap starter kit #1011

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Extension } from "@tiptap/core";

const KeyboardShortcuts = ({ onSubmit, shortcuts }) =>
const KeyboardShortcuts = ({ onSubmit, shortcuts, isBlockQuoteActive }) =>
Extension.create({
name: "keyboard-shortcuts",

Expand All @@ -11,12 +11,21 @@ const KeyboardShortcuts = ({ onSubmit, shortcuts }) =>

return true;
},
"Mod-Shift-b": () => {
if (isBlockQuoteActive) {
this.editor.chain().focus().toggleBlockquote().run();

return true;
}

return false;
},
...shortcuts,
};
},
});

export default {
configure: ({ onSubmit, shortcuts }) =>
KeyboardShortcuts({ onSubmit, shortcuts }),
configure: ({ onSubmit, shortcuts, isBlockQuoteActive }) =>
KeyboardShortcuts({ onSubmit, shortcuts, isBlockQuoteActive }),
};
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const useCustomExtensions = ({
document: false,
codeBlock: false,
code: false,
blockquote: options.includes(EDITOR_OPTIONS.BLOCKQUOTE),
orderedList: options.includes(EDITOR_OPTIONS.LIST_ORDERED),
bulletList: options.includes(EDITOR_OPTIONS.LIST_BULLETS),
}),
Expand All @@ -78,6 +79,7 @@ const useCustomExtensions = ({
KeyboardShortcuts.configure({
onSubmit,
shortcuts: keyboardShortcuts,
isBlockQuoteActive: options.includes(EDITOR_OPTIONS.BLOCKQUOTE),
}),
];
if (isVideoEmbedActive) {
Expand Down
15 changes: 8 additions & 7 deletions stories/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@ export const EDITOR_SHORTCUTS_TABLE_COLUMNS = [
];

export const EDITOR_SHORTCUTS_TABLE_ROWS = [
["Blockquote", "Ctrl + Shift + B", "Cmd + Shift + B"],
["Bold", "Ctrl + B", "Cmd + B"],
["Bullet List", "Ctrl + Shift + 8", "Cmd + Shift + 8"],
["Emoji", "Ctrl + Alt + E", "Cmd + Opt + E"],
["Highlight", "Ctrl + Shift + H", "Cmd + Shift + H"],
["Image uploader", "Ctrl + Alt + I", "Cmd + Opt + K"],
["Italicize", "Ctrl + I", "Cmd + I"],
["Ordered List", "Ctrl + Shift + 7", "Cmd + Shift + 7"],
["Underline", "Ctrl + U", "Cmd + U"],
["Strikethrough", "Ctrl + Shift + X", "Cmd + Shift + X"],
["Blockquote", "Ctrl + Shift + B", "Cmd + Shift + B"],
["Bullet List", "Ctrl + Shift + 8", "Cmd + Shift + 8"],
["Ordered List", "Ctrl + Shift + 7", "Cmd + Shift + 7"],
["Table", "Ctrl + Alt + T", "Cmd + Opt + T"],
["Underline", "Ctrl + U", "Cmd + U"],
["Highlight", "Ctrl + Shift + H", "Cmd + Shift + H"],
["Emoji", "Ctrl + Alt + E", "Cmd + Opt + E"],
["Code Block", "Ctrl + Alt + C", "Cmd + Opt + C"],
["Image uploader", "Ctrl + Alt + I", "Cmd + Opt + K"],
["Upload attachments", "Ctrl + Alt + A", "Cmd + Opt + A"],
["Video uploader", "Ctrl + Alt + V", "Cmd + Opt + V"],
];
Expand Down
Loading