mirror of
https://github.com/outline/outline.git
synced 2026-12-06 19:22:29 +03:00
fix: Align static share rendering with document presenter (#14777)
This commit is contained in:
1 parent
46fc485a89
commit
e0a455e3be
3 files changed
+43
-3
No files matched your search
@@ -177,6 +177,39 @@ describe("DocumentHelper", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("toStaticHTML", () => {
|
||||
it("should remove comment marks", async () => {
|
||||
const document = await buildDocument({
|
||||
text: "hello",
|
||||
content: {
|
||||
type: "doc",
|
||||
content: [
|
||||
{
|
||||
type: "paragraph",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "hello",
|
||||
marks: [
|
||||
{
|
||||
type: "comment",
|
||||
attrs: { id: "comment-123", userId: "user-123" },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const html = await DocumentHelper.toStaticHTML(document);
|
||||
expect(html).toContain("hello");
|
||||
expect(html).not.toContain("comment-123");
|
||||
expect(html).not.toContain("user-123");
|
||||
});
|
||||
});
|
||||
|
||||
describe("toHTML", () => {
|
||||
it("should return html", async () => {
|
||||
const document = await buildDocument({
|
||||
|
||||
@@ -478,13 +478,20 @@ export class DocumentHelper {
|
||||
|
||||
/**
|
||||
* Returns the document or collection as static HTML with its title. The
|
||||
* output is rendered from the schema without node components or styles.
|
||||
* output is rendered from the schema without node components or styles, and
|
||||
* comment marks are removed because it is shown on public shares.
|
||||
*
|
||||
* @param model The document or collection to convert.
|
||||
* @returns The title and content as a HTML string.
|
||||
*/
|
||||
static async toStaticHTML(model: Document | Collection) {
|
||||
return ProsemirrorHelper.toStaticHTML(DocumentHelper.toProsemirror(model), {
|
||||
const node = Node.fromJSON(
|
||||
schema,
|
||||
ProsemirrorHelper.removeMarks(DocumentHelper.toProsemirror(model), [
|
||||
"comment",
|
||||
])
|
||||
);
|
||||
return ProsemirrorHelper.toStaticHTML(node, {
|
||||
title: model instanceof Collection ? model.name : model.title,
|
||||
headingPrefix:
|
||||
model instanceof Document
|
||||
|
||||
@@ -45,7 +45,7 @@ export class RedisPrefixHelper {
|
||||
* @returns the cache key string.
|
||||
*/
|
||||
public static getShareContentKey(id: string, updatedAt: Date) {
|
||||
return `share:html:${id}:${updatedAt.getTime()}`;
|
||||
return `share:html:v2:${id}:${updatedAt.getTime()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user