Minor fixes from enterprise codebase

This commit is contained in:
Tom Moor
2023-02-12 16:31:15 -05:00
parent 33afa2f029
commit e028715afb
3 changed files with 14 additions and 0 deletions

View File

@@ -164,6 +164,12 @@ function Editor(props: Props, ref: React.RefObject<SharedEditor> | 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 // 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 // share route to the URL so that the document is loaded in context
if (shareId && navigateTo.includes("/doc/")) { if (shareId && navigateTo.includes("/doc/")) {

View File

@@ -202,6 +202,10 @@ async function documentImporter({
// to match our hardbreak parser. // to match our hardbreak parser.
text = text.replace(/<br>/gi, "\\n"); text = text.replace(/<br>/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 // find data urls, convert to blobs, upload and write attachments
const images = parseImages(text); const images = parseImages(text);
const dataURIs = images.filter((href) => href.startsWith("data:")); const dataURIs = images.filter((href) => href.startsWith("data:"));

View File

@@ -20,6 +20,10 @@ function isLinkClose(token: Token) {
function isAttachment(token: Token) { function isAttachment(token: Token) {
const href = token.attrGet("href"); const href = token.attrGet("href");
if (href?.includes("display=link")) {
return false;
}
return ( return (
// internal // internal
href?.startsWith("/api/attachments.redirect") || href?.startsWith("/api/attachments.redirect") ||