Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/text editor/link editor: fix an issue
Adorian Doran0ae8b3ba4a9d
diff --git a/apps/client/src/widgets/dialogs/edit_link.tsx b/apps/client/src/widgets/dialogs/edit_link.tsxindex dedeca115b..a667d5310e 100644--- a/apps/client/src/widgets/dialogs/edit_link.tsx+++ b/apps/client/src/widgets/dialogs/edit_link.tsx@@ -31,25 +31,6 @@ type LinkType = "reference-link" | "external-link" | "hyper-link";/** What the link points at: a note, an address outside Trilium, or an anchor in the document. */export type LinkTarget = "note" | "url" | "anchor";-function findAnchorIds(content: string): string[] {- const re = /<a\b([^>]*)>(<\/a>)?/g;- const ids: string[] = [];- let match;-- while ((match = re.exec(content))) {- const attrs = match[1];- if (/\bhref\s*=/.test(attrs)) continue;-- const idMatch = /\bid\s*=\s*"([^"]+)"/.exec(attrs) ?? /\bid\s*=\s*'([^']+)'/.exec(attrs);- if (!idMatch) continue;-- const id = idMatch[1];- if (!ids.includes(id)) ids.push(id);- }-- return ids;-}-export interface EditLinkOpts {text: string;hasSelection: boolean;@@ -704,6 +685,26 @@ function getInitialWebLink(opts: EditLinkOpts): string | null {return opts.target === "url" ? "" : null;}+/** The `id`s of the anchors in the HTML `content`, which are `<a>` elements without an `href`. */+function findAnchorIds(content: string): string[] {+ const re = /<a\b([^>]*)>(<\/a>)?/g;+ const ids: string[] = [];+ let match;++ while ((match = re.exec(content))) {+ const attrs = match[1];+ if (/\bhref\s*=/.test(attrs)) continue;++ const idMatch = /\bid\s*=\s*"([^"]+)"/.exec(attrs) ?? /\bid\s*=\s*'([^']+)'/.exec(attrs);+ if (!idMatch) continue;++ const id = idMatch[1];+ if (!ids.includes(id)) ids.push(id);+ }++ return ids;+}+/*** How the web link to `url` is displayed when `display` is picked: as a plain link when the address* is not a web page, and as a card in place of a player that the address does not have.