Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: exit a link by pressing space (#3122)

Muhammad Ali2962f1345710
diff --git a/packages/editor/src/extensions/link/link.ts b/packages/editor/src/extensions/link/link.ts
index 5a9f7570a..8683159c3 100644
--- a/packages/editor/src/extensions/link/link.ts
+++ b/packages/editor/src/extensions/link/link.ts
@@ -290,6 +290,22 @@ export const Link = Mark.create<LinkOptions>({
}
return plugins;
+ },
+
+ addKeyboardShortcuts() {
+ return {
+ Space: ({ editor }) => {
+ const { from, to } = editor.state.selection;
+
+ if (!editor.state.doc.rangeHasMark(from, to + 1, this.type)) {
+ const { tr } = editor.state;
+ tr.removeStoredMark(editor.schema.marks.link);
+ editor.view.dispatch(tr);
+ }
+
+ return false;
+ }
+ };
}
});