Skip to content

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

editor: fix editing note link replaces link text with note name (#6768)

Muhammad Aliccd1b6d69b56
diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsx
index fcb270a29..fc3185945 100644
--- a/packages/editor/src/toolbar/tools/link.tsx
+++ b/packages/editor/src/toolbar/tools/link.tsx
@@ -118,7 +118,17 @@ export function EditLink(props: ToolProps) {
const { from, to } = editor.state.selection;
if (selectedNode.current)
editor.commands.setTextSelection(selectedNode.current);
- editor.commands.setLink(link);
+
+ const selectedText =
+ !!selectedNode.current &&
+ editor.state.doc.textBetween(
+ selectedNode.current.from,
+ selectedNode.current.to
+ );
+ editor.commands.setLink({
+ ...link,
+ title: selectedText || link.title
+ });
if (selectedNode.current)
editor.commands.setTextSelection({ from, to });
}}