chore: Remove reliance on Markdown for document.getSummary, towards #3000
This commit is contained in:
@@ -5,9 +5,7 @@ import { can } from "@server/policies";
|
||||
import { getUserForJWT } from "@server/utils/jwt";
|
||||
import { AuthenticationError } from "../errors";
|
||||
|
||||
@APM.trace({
|
||||
spanName: "authentication",
|
||||
})
|
||||
@APM.trace()
|
||||
export default class AuthenticationExtension implements Extension {
|
||||
async onAuthenticate({
|
||||
connection,
|
||||
|
||||
@@ -12,9 +12,7 @@ import Document from "@server/models/Document";
|
||||
import documentCollaborativeUpdater from "../commands/documentCollaborativeUpdater";
|
||||
import markdownToYDoc from "./utils/markdownToYDoc";
|
||||
|
||||
@APM.trace({
|
||||
spanName: "persistence",
|
||||
})
|
||||
@APM.trace()
|
||||
export default class PersistenceExtension implements Extension {
|
||||
/**
|
||||
* Map of documentId -> userIds that have modified the document since it
|
||||
|
||||
@@ -22,9 +22,7 @@ type SendMailOptions = {
|
||||
/**
|
||||
* Mailer class to send emails.
|
||||
*/
|
||||
@APM.trace({
|
||||
spanName: "mailer",
|
||||
})
|
||||
@APM.trace()
|
||||
export class Mailer {
|
||||
transporter: Transporter | undefined;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import removeMarkdown from "@tommoor/remove-markdown";
|
||||
import { compact, uniq } from "lodash";
|
||||
import randomstring from "randomstring";
|
||||
import type { SaveOptions } from "sequelize";
|
||||
@@ -34,7 +33,6 @@ import MarkdownSerializer from "slate-md-serializer";
|
||||
import isUUID from "validator/lib/isUUID";
|
||||
import getTasks from "@shared/utils/getTasks";
|
||||
import parseTitle from "@shared/utils/parseTitle";
|
||||
import unescape from "@shared/utils/unescape";
|
||||
import { SLUG_URL_REGEX } from "@shared/utils/urlHelpers";
|
||||
import { DocumentValidation } from "@shared/validations";
|
||||
import slugify from "@server/utils/slugify";
|
||||
@@ -48,6 +46,7 @@ import User from "./User";
|
||||
import View from "./View";
|
||||
import ParanoidModel from "./base/ParanoidModel";
|
||||
import Fix from "./decorators/Fix";
|
||||
import DocumentHelper from "./helpers/DocumentHelper";
|
||||
import Length from "./validators/Length";
|
||||
|
||||
const serializer = new MarkdownSerializer();
|
||||
@@ -740,10 +739,8 @@ class Document extends ParanoidModel {
|
||||
};
|
||||
|
||||
getSummary = () => {
|
||||
const plain = removeMarkdown(unescape(this.text), {
|
||||
stripHTML: false,
|
||||
});
|
||||
const lines = compact(plain.split("\n"));
|
||||
const plainText = DocumentHelper.toPlainText(this);
|
||||
const lines = compact(plainText.split("\n"));
|
||||
const notEmpty = lines.length >= 1;
|
||||
|
||||
if (this.version) {
|
||||
|
||||
@@ -23,7 +23,8 @@ import { isRTL } from "@shared/utils/rtl";
|
||||
import unescape from "@shared/utils/unescape";
|
||||
import { parser, schema } from "@server/editor";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import Document from "@server/models/Document";
|
||||
import { APM } from "@server/logging/tracing";
|
||||
import type Document from "@server/models/Document";
|
||||
import type Revision from "@server/models/Revision";
|
||||
import User from "@server/models/User";
|
||||
import diff from "@server/utils/diff";
|
||||
@@ -42,6 +43,7 @@ type HTMLOptions = {
|
||||
signedUrls?: boolean;
|
||||
};
|
||||
|
||||
@APM.trace()
|
||||
export default class DocumentHelper {
|
||||
/**
|
||||
* Returns the document as a Prosemirror Node. This method uses the
|
||||
@@ -176,7 +178,7 @@ export default class DocumentHelper {
|
||||
|
||||
let output = dom.serialize();
|
||||
|
||||
if (options?.signedUrls && document instanceof Document) {
|
||||
if (options?.signedUrls && "teamId" in document) {
|
||||
output = await DocumentHelper.attachmentsToSignedUrls(
|
||||
output,
|
||||
document.teamId
|
||||
|
||||
Reference in New Issue
Block a user