mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-05-18 05:05:36 +02:00
editor: remove hardcoded keybind definitions
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { keybindings } from "@notesnook/common";
|
||||
import { KeyboardShortcutCommand, mergeAttributes, Node } from "@tiptap/core";
|
||||
import { Node as ProseMirrorNode } from "@tiptap/pm/model";
|
||||
|
||||
@@ -80,7 +81,8 @@ export const CheckListItem = Node.create<CheckListItemOptions>({
|
||||
[key: string]: KeyboardShortcutCommand;
|
||||
} = {
|
||||
Enter: () => this.editor.commands.splitListItem(this.name),
|
||||
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
||||
[keybindings.liftListItem.keys]: () =>
|
||||
this.editor.commands.liftListItem(this.name)
|
||||
};
|
||||
|
||||
if (!this.options.nested) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from "@tiptap/core";
|
||||
import { findParentNodeOfTypeClosestToPos } from "../../utils/prosemirror.js";
|
||||
import { OutlineList } from "../outline-list/outline-list.js";
|
||||
import { tiptapKeys } from "@notesnook/common";
|
||||
import { keybindings, tiptapKeys } from "@notesnook/common";
|
||||
|
||||
export interface ListItemOptions {
|
||||
HTMLAttributes: Record<string, unknown>;
|
||||
@@ -105,7 +105,8 @@ export const OutlineListItem = Node.create<ListItemOptions>({
|
||||
return this.editor.commands.splitListItem(this.name);
|
||||
},
|
||||
Tab: () => this.editor.commands.sinkListItem(this.name),
|
||||
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
||||
[keybindings.liftListItem.keys]: () =>
|
||||
this.editor.commands.liftListItem(this.name)
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { keybindings } from "@notesnook/common";
|
||||
import { Editor, mergeAttributes, Node } from "@tiptap/core";
|
||||
import { NodeType } from "prosemirror-model";
|
||||
|
||||
@@ -120,7 +121,8 @@ export const Paragraph = Node.create<ParagraphOptions>({
|
||||
createParagraph(editor, this.type, false, true),
|
||||
"Shift-Enter": ({ editor }) =>
|
||||
createParagraph(editor, this.type, false, true),
|
||||
"Mod-Alt-0": () => this.editor.commands.setParagraph()
|
||||
[keybindings.insertParapraph.keys]: () =>
|
||||
this.editor.commands.setParagraph()
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,6 +30,7 @@ import { showPopup } from "../../components/popup-presenter/index.js";
|
||||
import { ImageUploadPopup } from "../popups/image-upload.js";
|
||||
import { Button } from "../../components/button.js";
|
||||
import { strings } from "@notesnook/intl";
|
||||
import { keybindings } from "@notesnook/common";
|
||||
|
||||
export function InsertBlock(props: ToolProps) {
|
||||
const { editor } = props;
|
||||
@@ -114,7 +115,7 @@ const codeblock = (editor: Editor): MenuItem => ({
|
||||
icon: Icons.codeblock,
|
||||
isChecked: editor.isActive("codeBlock"),
|
||||
onClick: () => editor.chain().focus().toggleCodeBlock().run(),
|
||||
modifier: "Mod-Shift-C"
|
||||
modifier: keybindings.toggleCodeBlock.keys
|
||||
});
|
||||
|
||||
const blockquote = (editor: Editor): MenuItem => ({
|
||||
@@ -124,7 +125,7 @@ const blockquote = (editor: Editor): MenuItem => ({
|
||||
icon: Icons.blockquote,
|
||||
isChecked: editor.isActive("blockQuote"),
|
||||
onClick: () => editor.chain().focus().toggleBlockquote().run(),
|
||||
modifier: "Mod-Shift-B"
|
||||
modifier: keybindings.insertBlockquote.keys
|
||||
});
|
||||
|
||||
const mathblock = (editor: Editor): MenuItem => ({
|
||||
@@ -134,7 +135,7 @@ const mathblock = (editor: Editor): MenuItem => ({
|
||||
icon: Icons.mathBlock,
|
||||
isChecked: editor.isActive("mathBlock"),
|
||||
onClick: () => editor.chain().focus().insertMathBlock().run(),
|
||||
modifier: "Mod-Shift-M"
|
||||
modifier: keybindings.insertMathBlock.keys
|
||||
});
|
||||
|
||||
const callout = (editor: Editor): MenuItem => ({
|
||||
@@ -181,7 +182,7 @@ const image = (editor: Editor, isMobile: boolean): MenuItem => ({
|
||||
title: strings.uploadFromDisk(),
|
||||
icon: Icons.upload,
|
||||
onClick: () => editor.storage.openAttachmentPicker?.("image"),
|
||||
modifier: "Mod-Shift-I"
|
||||
modifier: keybindings.addImage.keys
|
||||
},
|
||||
{
|
||||
key: "camera",
|
||||
@@ -284,7 +285,7 @@ const attachment = (editor: Editor): MenuItem => ({
|
||||
icon: Icons.attachment,
|
||||
isChecked: editor.isActive("attachment"),
|
||||
onClick: () => editor.storage.openAttachmentPicker?.("file"),
|
||||
modifier: "Mod-Shift-A"
|
||||
modifier: keybindings.addAttachment.keys
|
||||
});
|
||||
|
||||
const tasklist = (editor: Editor): MenuItem => ({
|
||||
@@ -294,7 +295,7 @@ const tasklist = (editor: Editor): MenuItem => ({
|
||||
icon: Icons.checkbox,
|
||||
isChecked: editor.isActive("taskList"),
|
||||
onClick: () => editor.chain().focus().toggleTaskList().run(),
|
||||
modifier: "Mod-Shift-T"
|
||||
modifier: keybindings.toggleTaskList.keys
|
||||
});
|
||||
|
||||
const outlinelist = (editor: Editor): MenuItem => ({
|
||||
@@ -304,7 +305,7 @@ const outlinelist = (editor: Editor): MenuItem => ({
|
||||
icon: Icons.outlineList,
|
||||
isChecked: editor.isActive("outlineList"),
|
||||
onClick: () => editor.chain().focus().toggleOutlineList().run(),
|
||||
modifier: "Mod-Shift-O"
|
||||
modifier: keybindings.toggleOutlineList.keys
|
||||
});
|
||||
|
||||
const uploadImageFromURLMobile = (editor: Editor): MenuItem => ({
|
||||
|
||||
Reference in New Issue
Block a user