Add 'Copy as Markdown' action

Remove smart quotes from Markdown export, closes #5303
This commit is contained in:
Tom Moor
2023-12-09 15:00:33 -05:00
parent f9c3b0e193
commit 3f3d7b4978
5 changed files with 55 additions and 13 deletions

View File

@@ -10,6 +10,7 @@ import { Transaction } from "sequelize";
import * as Y from "yjs";
import textBetween from "@shared/editor/lib/textBetween";
import { AttachmentPreset } from "@shared/types";
import MarkdownHelper from "@shared/utils/MarkdownHelper";
import {
getCurrentDateAsString,
getCurrentDateTimeAsString,
@@ -88,13 +89,7 @@ export default class DocumentHelper {
* @returns The document title and content as a Markdown string
*/
static toMarkdown(document: Document | Revision) {
const text = document.text.replace(/\n\\\n/g, "\n\n");
if (document.version) {
return `# ${document.title}\n\n${text}`;
}
return text;
return MarkdownHelper.toMarkdown(document);
}
/**

View File

@@ -536,13 +536,8 @@ router.post(
contentType = "text/markdown";
content = DocumentHelper.toMarkdown(document);
} else {
contentType = "application/json";
content = DocumentHelper.toMarkdown(document);
}
if (contentType === "application/json") {
ctx.body = {
data: content,
data: DocumentHelper.toMarkdown(document),
};
return;
}