diff --git a/app/components/Editor.tsx b/app/components/Editor.tsx index 4d43d1f6d..4af0de3b1 100644 --- a/app/components/Editor.tsx +++ b/app/components/Editor.tsx @@ -164,6 +164,12 @@ function Editor(props: Props, ref: React.RefObject | null) { } } + // Link to our own API should be opened in a new tab, not in the app + if (navigateTo.startsWith("/api/")) { + window.open(href, "_blank"); + return; + } + // If we're navigating to an internal document link then prepend the // share route to the URL so that the document is loaded in context if (shareId && navigateTo.includes("/doc/")) { diff --git a/server/commands/documentImporter.ts b/server/commands/documentImporter.ts index 97667d61d..222478bba 100644 --- a/server/commands/documentImporter.ts +++ b/server/commands/documentImporter.ts @@ -202,6 +202,10 @@ async function documentImporter({ // to match our hardbreak parser. text = text.replace(/
/gi, "\\n"); + // Escape any dollar signs in the text to prevent them being interpreted as + // math blocks + text = text.replace(/\$/g, "\\$"); + // find data urls, convert to blobs, upload and write attachments const images = parseImages(text); const dataURIs = images.filter((href) => href.startsWith("data:")); diff --git a/shared/editor/rules/attachments.ts b/shared/editor/rules/attachments.ts index 5ea0385dd..59f3d0f19 100644 --- a/shared/editor/rules/attachments.ts +++ b/shared/editor/rules/attachments.ts @@ -20,6 +20,10 @@ function isLinkClose(token: Token) { function isAttachment(token: Token) { const href = token.attrGet("href"); + if (href?.includes("display=link")) { + return false; + } + return ( // internal href?.startsWith("/api/attachments.redirect") ||