Skip to content

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

editor: if selected text is link, autofill url field in insert link popup Signed-off-by: 01zulfi <[email protected]>

01zulfiae5b422965c5
diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsx
index 8afa5a616..ab713aab5 100644
--- a/packages/editor/src/toolbar/tools/link.tsx
+++ b/packages/editor/src/toolbar/tools/link.tsx
@@ -32,6 +32,7 @@ import { Link as LinkNode } from "../../extensions/link/index.js";
import { getMarkAttributes } from "@tiptap/core";
import { useHoverPopupContext } from "../floating-menus/hover-popup/context.js";
import { strings } from "@notesnook/intl";
+import { find } from "linkifyjs";
export function LinkSettings(props: ToolProps) {
const { editor } = props;
@@ -69,7 +70,11 @@ export function AddLink(props: ToolProps) {
editor.state.selection.from,
editor.state.selection.to
);
- return { title: selectedText, href: "" };
+ const href =
+ find(selectedText).find(
+ (item) => item.isLink && item.href === selectedText
+ )?.href ?? "";
+ return { title: selectedText, href };
}}
/>
);