Skip to content

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

editor: fix keyboard shortcut for internal link not working

Abdullah Attaf7de4c90845d
diff --git a/packages/editor/src/extensions/key-map/key-map.ts b/packages/editor/src/extensions/key-map/key-map.ts
index f20a8407b..e0108a717 100644
--- a/packages/editor/src/extensions/key-map/key-map.ts
+++ b/packages/editor/src/extensions/key-map/key-map.ts
@@ -52,7 +52,18 @@ export const KeyMap = Extension.create({
return true;
},
"Shift-Mod-L": ({ editor }) => {
- editor.storage.createInternalLink?.();
+ editor.storage.createInternalLink?.().then((link) => {
+ if (!link) return;
+
+ const selectedText = editor.state.doc.textBetween(
+ editor.state.selection.from,
+ editor.state.selection.to
+ );
+ editor.commands.setLink({
+ ...link,
+ title: selectedText || link.title
+ });
+ });
return true;
}
};