A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: remove hardcoded keybind definitions Signed-off-by: 01zulfi <[email protected]>
01zulfi0185eea74059
diff --git a/packages/common/src/utils/keybindings.ts b/packages/common/src/utils/keybindings.tsindex 434f70e8e..a9f29f72f 100644--- a/packages/common/src/utils/keybindings.ts+++ b/packages/common/src/utils/keybindings.ts@@ -198,6 +198,12 @@ export const tiptapKeys = {category: "Editor",type: "tiptap"},+ insertParagraph: {+ keys: "Mod-Shift-0",+ description: "Insert paragraph",+ category: "Editor",+ type: "tiptap"+ },insertHeading1: {keys: "Mod-Alt-1",description: "Insert heading 1",diff --git a/packages/editor/src/extensions/check-list-item/check-list-item.ts b/packages/editor/src/extensions/check-list-item/check-list-item.tsindex 5c9869231..6f9b97a24 100644--- a/packages/editor/src/extensions/check-list-item/check-list-item.ts+++ b/packages/editor/src/extensions/check-list-item/check-list-item.ts@@ -16,6 +16,7 @@ GNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong 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) {diff --git a/packages/editor/src/extensions/outline-list-item/outline-list-item.ts b/packages/editor/src/extensions/outline-list-item/outline-list-item.tsindex 77bbb44f7..86fe24405 100644--- a/packages/editor/src/extensions/outline-list-item/outline-list-item.ts+++ b/packages/editor/src/extensions/outline-list-item/outline-list-item.ts@@ -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)};},diff --git a/packages/editor/src/extensions/paragraph/paragraph.ts b/packages/editor/src/extensions/paragraph/paragraph.tsindex a7fe3ea19..3f0ecfe46 100644--- a/packages/editor/src/extensions/paragraph/paragraph.ts+++ b/packages/editor/src/extensions/paragraph/paragraph.ts@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public Licensealong 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()};}});diff --git a/packages/editor/src/toolbar/tools/block.tsx b/packages/editor/src/toolbar/tools/block.tsxindex 6f06ec86c..21ae233e3 100644--- a/packages/editor/src/toolbar/tools/block.tsx+++ b/packages/editor/src/toolbar/tools/block.tsx@@ -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 => ({