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
fix: selected text is replaced with link
thecodrrb5d10a4b783d
diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsxindex 0c3e5d0fa..ae4cdc30f 100644--- a/packages/editor/src/toolbar/tools/link.tsx+++ b/packages/editor/src/toolbar/tools/link.tsx@@ -36,14 +36,18 @@ export function AddLink(props: ToolProps) {let commandChain = editor.current?.chain().focus();if (!commandChain) return;+ const isSelection = !editor.current?.state.selection.empty;+commandChain.extendMarkRange("link").toggleLink({ href, target: "_blank" }).insertContent(text || href)- .focus()- .unsetMark("link")- .insertContent(" ")- .run();+ .focus();++ if (!isSelection)+ commandChain = commandChain.unsetMark("link").insertContent(" ");++ commandChain.run();}, []);if (isActive) return <EditLink {...props} />;@@ -52,8 +56,10 @@ export function AddLink(props: ToolProps) {{...props}onDone={onDone}onClick={() => {- let { from, to } = editor.state.selection;- const selectedText = editor.state.doc.textBetween(from, to);+ if (!editor.current) return;+ const { state } = editor.current;+ let { from, to } = state.selection;+ const selectedText = state.doc.textBetween(from, to);return { text: selectedText };}}/>