mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
d3235250a8
* perf: Move text serialization to task runner * tsc * test * refactor * fix: Restore previous default of toMarkdown behavior * Stop writing text to revisions
19 lines
616 B
TypeScript
19 lines
616 B
TypeScript
import { Node } from "prosemirror-model";
|
|
import { schema, serializer } from "@server/editor";
|
|
import { Document } from "@server/models";
|
|
import { DocumentEvent } from "@server/types";
|
|
import BaseTask from "./BaseTask";
|
|
|
|
export default class DocumentUpdateTextTask extends BaseTask<DocumentEvent> {
|
|
public async perform(event: DocumentEvent) {
|
|
const document = await Document.findByPk(event.documentId);
|
|
if (!document?.content) {
|
|
return;
|
|
}
|
|
|
|
const node = Node.fromJSON(schema, document.content);
|
|
document.text = serializer.serialize(node);
|
|
await document.save({ silent: true });
|
|
}
|
|
}
|