mirror of
https://github.com/docmost/docmost.git
synced 2025-11-16 17:21:14 +10:00
remove comment mark in shares
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import { Node } from '@tiptap/pm/model';
|
import { Node } from '@tiptap/pm/model';
|
||||||
import { jsonToNode } from '../../../collaboration/collaboration.util';
|
import { jsonToNode } from '../../../collaboration/collaboration.util';
|
||||||
import { validate as isValidUUID } from 'uuid';
|
import { validate as isValidUUID } from 'uuid';
|
||||||
|
import { Transform } from '@tiptap/pm/transform';
|
||||||
|
|
||||||
export interface MentionNode {
|
export interface MentionNode {
|
||||||
id: string;
|
id: string;
|
||||||
@ -94,4 +95,16 @@ export function getAttachmentIds(prosemirrorJson: any) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return attachmentIds;
|
return attachmentIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeMarkTypeFromDoc(doc: Node, markName: string): Node {
|
||||||
|
const { schema } = doc.type;
|
||||||
|
const markType = schema.marks[markName];
|
||||||
|
|
||||||
|
if (!markType) {
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tr = new Transform(doc).removeMark(0, doc.content.size, markType);
|
||||||
|
return tr.doc;
|
||||||
}
|
}
|
||||||
@ -15,6 +15,7 @@ import {
|
|||||||
getAttachmentIds,
|
getAttachmentIds,
|
||||||
getProsemirrorContent,
|
getProsemirrorContent,
|
||||||
isAttachmentNode,
|
isAttachmentNode,
|
||||||
|
removeMarkTypeFromDoc,
|
||||||
} from '../../common/helpers/prosemirror/utils';
|
} from '../../common/helpers/prosemirror/utils';
|
||||||
import { Node } from '@tiptap/pm/model';
|
import { Node } from '@tiptap/pm/model';
|
||||||
import { ShareRepo } from '@docmost/db/repos/share/share.repo';
|
import { ShareRepo } from '@docmost/db/repos/share/share.repo';
|
||||||
@ -223,11 +224,7 @@ export class ShareService {
|
|||||||
.end()
|
.end()
|
||||||
.as('found'),
|
.as('found'),
|
||||||
])
|
])
|
||||||
.where(
|
.where(isValidUUID(childPageId) ? 'id' : 'slugId', '=', childPageId)
|
||||||
isValidUUID(childPageId) ? 'id' : 'slugId',
|
|
||||||
'=',
|
|
||||||
childPageId,
|
|
||||||
)
|
|
||||||
.unionAll((exp) =>
|
.unionAll((exp) =>
|
||||||
exp
|
exp
|
||||||
.selectFrom('pages as p')
|
.selectFrom('pages as p')
|
||||||
@ -292,6 +289,7 @@ export class ShareService {
|
|||||||
updateAttachmentAttr(node, 'url', token);
|
updateAttachmentAttr(node, 'url', token);
|
||||||
});
|
});
|
||||||
|
|
||||||
return doc.toJSON();
|
const removeCommentMarks = removeMarkTypeFromDoc(doc, 'comment');
|
||||||
|
return removeCommentMarks.toJSON();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user