mirror of
https://github.com/docmost/docmost.git
synced 2026-05-18 15:34:05 +08:00
feat: notifications (#1947)
* feat: notifications * feat: watchers * improvements * handle page move for watchers * make watchers non-blocking * more
This commit is contained in:
@@ -9,3 +9,7 @@ export const LOCAL_STORAGE_PATH = path.resolve(
|
||||
'..',
|
||||
LOCAL_STORAGE_DIR,
|
||||
);
|
||||
|
||||
export function getPageTitle(title: string | null | undefined): string {
|
||||
return title || 'untitled';
|
||||
}
|
||||
|
||||
@@ -64,6 +64,30 @@ export function extractPageMentions(mentionList: MentionNode[]): MentionNode[] {
|
||||
return pageMentionList as MentionNode[];
|
||||
}
|
||||
|
||||
export function extractUserMentionIdsFromJson(json: any): string[] {
|
||||
const userIds: string[] = [];
|
||||
|
||||
function walk(node: any) {
|
||||
if (!node) return;
|
||||
if (
|
||||
node.type === 'mention' &&
|
||||
node.attrs?.entityType === 'user' &&
|
||||
node.attrs?.entityId &&
|
||||
!userIds.includes(node.attrs.entityId)
|
||||
) {
|
||||
userIds.push(node.attrs.entityId);
|
||||
}
|
||||
if (Array.isArray(node.content)) {
|
||||
for (const child of node.content) {
|
||||
walk(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walk(json);
|
||||
return userIds;
|
||||
}
|
||||
|
||||
export function getProsemirrorContent(content: any) {
|
||||
return (
|
||||
content ?? {
|
||||
|
||||
Reference in New Issue
Block a user