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
core: db.notes.internalLinks() should only return note internal links
Ammar Ahmed8d3d173762f8
diff --git a/packages/core/src/content-types/tiptap.ts b/packages/core/src/content-types/tiptap.tsindex 2a2f667f8..6714644ca 100644--- a/packages/core/src/content-types/tiptap.ts+++ b/packages/core/src/content-types/tiptap.ts@@ -38,7 +38,7 @@ import { HTMLRewriter } from "../utils/html-rewriter.js";import { ContentBlock } from "../types.js";import {InternalLink,- isInternalLink,+ isNoteLink,parseInternalLink} from "../utils/internal-link.js";import { Element } from "domhandler";@@ -215,7 +215,8 @@ export class Tiptap {(node) =>isTag(node) &&node.tagName === "a" &&- isInternalLink(node.attribs.href)+ isNoteLink(node.attribs.href) &&+ parseInternalLink(node.attribs.href)?.type === "note"));}, document.childNodes).map((element) => {@@ -250,9 +251,7 @@ export class Tiptap {result.internalLinks.push(...findAll((e) =>- e.tagName === "a" &&- !!e.attribs.href &&- e.attribs.href.startsWith("nn://"),+ e.tagName === "a" && !!e.attribs.href && isNoteLink(e.attribs.href),document.childNodes).map((e) => parseInternalLink(e.attribs.href))diff --git a/packages/core/src/utils/internal-link.ts b/packages/core/src/utils/internal-link.tsindex 7f9cd307f..b3823e48c 100644--- a/packages/core/src/utils/internal-link.ts+++ b/packages/core/src/utils/internal-link.ts@@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.*/const InternalLinkTypes = ["note", "notebook", "tag", "color"] as const;-type InternalLinkType = (typeof InternalLinkTypes)[number];-type NoteLink = BaseInternalLink<"note">;-type NotebookLink = BaseInternalLink<"notebook">;-type TagLink = BaseInternalLink<"tag">;-type ColorLink = BaseInternalLink<"color">;+export type InternalLinkType = (typeof InternalLinkTypes)[number];+export type NoteLink = BaseInternalLink<"note">;+export type NotebookLink = BaseInternalLink<"notebook">;+export type TagLink = BaseInternalLink<"tag">;+export type ColorLink = BaseInternalLink<"color">;type BaseInternalLink<T extends InternalLinkType = InternalLinkType,TParams extends InternalLinkParams[T] = InternalLinkParams[T]@@ -82,7 +82,11 @@ export function parseInternalLink(link: string): InternalLink | undefined {}export function isInternalLink(link: string) {- return link && link.startsWith("nn://");+ return link ? link.startsWith("nn://") : false;+}++export function isNoteLink(link: string) {+ return link ? link.startsWith("nn://note/") : false;}function isValidInternalType(type: string): type is InternalLinkType {