From 898c7a3e33488c7a776151c725a8539b6b950740 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Wed, 29 May 2024 16:50:37 +0200 Subject: [PATCH 1/2] Added link keyboard shortcut and removed warning --- packages/core/src/editor/BlockNoteEditor.ts | 1 - packages/core/src/editor/BlockNoteExtensions.ts | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/core/src/editor/BlockNoteEditor.ts b/packages/core/src/editor/BlockNoteEditor.ts index 53ec4d9f83..79fbab18cb 100644 --- a/packages/core/src/editor/BlockNoteEditor.ts +++ b/packages/core/src/editor/BlockNoteEditor.ts @@ -777,7 +777,6 @@ export class BlockNoteEditor< for (const mark of marks) { const config = this.schema.styleSchema[mark.type.name]; if (!config) { - console.warn("mark not found in styleschema", mark.type.name); continue; } if (config.propSchema === "boolean") { diff --git a/packages/core/src/editor/BlockNoteExtensions.ts b/packages/core/src/editor/BlockNoteExtensions.ts index 7fe0ac94ca..0dc6775bcf 100644 --- a/packages/core/src/editor/BlockNoteExtensions.ts +++ b/packages/core/src/editor/BlockNoteExtensions.ts @@ -75,7 +75,16 @@ export const getBlockNoteExtensions = < Text, // marks: - Link, + Link.extend({ + addKeyboardShortcuts() { + return { + "Mod-k": () => { + this.editor.commands.toggleLink({ href: "" }); + return true; + }, + }; + }, + }), ...Object.values(opts.styleSpecs).map((styleSpec) => { return styleSpec.implementation.mark; }), From 0dc851d448eae0445f3bd715e45e330689d3755d Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Tue, 4 Jun 2024 19:03:54 +0200 Subject: [PATCH 2/2] Re-added warning conditionally --- packages/core/src/editor/BlockNoteEditor.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/editor/BlockNoteEditor.ts b/packages/core/src/editor/BlockNoteEditor.ts index 79fbab18cb..69287f7959 100644 --- a/packages/core/src/editor/BlockNoteEditor.ts +++ b/packages/core/src/editor/BlockNoteEditor.ts @@ -777,6 +777,10 @@ export class BlockNoteEditor< for (const mark of marks) { const config = this.schema.styleSchema[mark.type.name]; if (!config) { + if (mark.type.name !== "link") { + console.warn("mark not found in styleschema", mark.type.name); + } + continue; } if (config.propSchema === "boolean") {