@allbluecn/collab-server 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/__tests__/exporters-bug.test.ts +8 -6
- package/src/__tests__/exporters-case.test.ts +1 -2
- package/src/__tests__/exporters-design.test.ts +1 -2
- package/src/__tests__/exporters-knowledge.test.ts +18 -13
- package/src/__tests__/exporters-story.test.ts +8 -6
- package/src/__tests__/internal-apply.test.ts +8 -6
- package/src/exporters/bug.ts +3 -3
- package/src/exporters/design.ts +9 -6
- package/src/exporters/knowledge.ts +26 -22
- package/src/exporters/story.ts +4 -4
- package/src/internal-apply.ts +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allbluecn/collab-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "AllBlue Hocuspocus WebSocket 协作服务(Yjs 多人协同;主形态为 web 后端内嵌模块,独立启动为退役回退)",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"./embed": "./src/embed.ts"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@allbluecn/collab-core": "0.2.
|
|
20
|
-
"@allbluecn/database": "0.14.
|
|
19
|
+
"@allbluecn/collab-core": "0.2.2",
|
|
20
|
+
"@allbluecn/database": "0.14.17",
|
|
21
21
|
"@hocuspocus/server": "^4.7.0",
|
|
22
22
|
"@tiptap/core": "3.31.3",
|
|
23
23
|
"@tiptap/extension-emoji": "3.31.3",
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
type ProviderSession,
|
|
45
45
|
type StartedServer,
|
|
46
46
|
} from "./test-utils";
|
|
47
|
-
import {
|
|
47
|
+
import { getServerDom, registerKnowledgeCollab } from "../exporters/knowledge";
|
|
48
48
|
import { registerBugCollab } from "../exporters/bug";
|
|
49
49
|
import { resetExporters, resetRoomGuards } from "../exporters";
|
|
50
50
|
|
|
@@ -132,12 +132,15 @@ async function cleanOwnRows(): Promise<void> {
|
|
|
132
132
|
expect(residue).toBe(0);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
const testDom = await getServerDom();
|
|
136
|
+
|
|
135
137
|
/** 与种子化同一扩展组合把 HTML 变成 Y update */
|
|
136
138
|
function htmlToUpdates(html: string): Uint8Array {
|
|
137
|
-
const yDoc = seedYDocFromHtml(
|
|
138
|
-
|
|
139
|
-
...createKnowledgeDocAdditions(),
|
|
140
|
-
|
|
139
|
+
const yDoc = seedYDocFromHtml(
|
|
140
|
+
html,
|
|
141
|
+
[...createKnowledgeExtensions(), ...createKnowledgeDocAdditions()],
|
|
142
|
+
testDom,
|
|
143
|
+
);
|
|
141
144
|
return Y.encodeStateAsUpdate(yDoc);
|
|
142
145
|
}
|
|
143
146
|
|
|
@@ -174,7 +177,6 @@ describe("bug exporter + /internal/apply entity-bug(真实 WS + 真实库)",
|
|
|
174
177
|
let session: ProviderSession | null = null;
|
|
175
178
|
|
|
176
179
|
beforeEach(async () => {
|
|
177
|
-
await ensureServerDom();
|
|
178
180
|
registerKnowledgeCollab();
|
|
179
181
|
registerBugCollab();
|
|
180
182
|
ctx = await startCollabServer({ persistence: {}, debounceMs: 300 });
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
type ProviderSession,
|
|
43
43
|
type StartedServer,
|
|
44
44
|
} from "./test-utils";
|
|
45
|
-
import {
|
|
45
|
+
import { registerKnowledgeCollab } from "../exporters/knowledge";
|
|
46
46
|
import { registerCaseCollab } from "../exporters/case";
|
|
47
47
|
import { resetExporters, resetRoomGuards } from "../exporters";
|
|
48
48
|
|
|
@@ -149,7 +149,6 @@ describe("case exporter + /internal/apply entity-case(真实 WS + 真实库)
|
|
|
149
149
|
let session: ProviderSession | null = null;
|
|
150
150
|
|
|
151
151
|
beforeEach(async () => {
|
|
152
|
-
await ensureServerDom();
|
|
153
152
|
registerKnowledgeCollab();
|
|
154
153
|
registerCaseCollab();
|
|
155
154
|
ctx = await startCollabServer({ persistence: {}, debounceMs: 300 });
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
type StartedServer,
|
|
45
45
|
} from "./test-utils";
|
|
46
46
|
import { CANVAS_TREE_FIXTURE } from "../../../../packages/collab-core/src/__tests__/canvas-tree-fixture";
|
|
47
|
-
import {
|
|
47
|
+
import { registerKnowledgeCollab } from "../exporters/knowledge";
|
|
48
48
|
import { registerDesignCollab } from "../exporters/design";
|
|
49
49
|
import { resetExporters, resetRoomGuards } from "../exporters";
|
|
50
50
|
|
|
@@ -138,7 +138,6 @@ describe("design exporter + /internal/apply design-canvas(真实 WS + 真实
|
|
|
138
138
|
let session: ProviderSession | null = null;
|
|
139
139
|
|
|
140
140
|
beforeEach(async () => {
|
|
141
|
-
await ensureServerDom();
|
|
142
141
|
registerKnowledgeCollab();
|
|
143
142
|
registerDesignCollab();
|
|
144
143
|
ctx = await startCollabServer({ persistence: {}, debounceMs: 300 });
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
type StartedServer,
|
|
49
49
|
} from "./test-utils";
|
|
50
50
|
import {
|
|
51
|
-
|
|
51
|
+
getServerDom,
|
|
52
52
|
registerKnowledgeCollab,
|
|
53
53
|
resetKnowledgeReindexNotifier,
|
|
54
54
|
setKnowledgeReindexNotifier,
|
|
@@ -117,12 +117,15 @@ async function cleanOwnRows(): Promise<void> {
|
|
|
117
117
|
expect(residue).toBe(0);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
const testDom = await getServerDom();
|
|
121
|
+
|
|
120
122
|
/** 与种子化同一扩展组合(默认集 + 追加集)把 HTML 变成 Y update */
|
|
121
123
|
function htmlToUpdates(html: string): Uint8Array {
|
|
122
|
-
const yDoc = seedYDocFromHtml(
|
|
123
|
-
|
|
124
|
-
...createKnowledgeDocAdditions(),
|
|
125
|
-
|
|
124
|
+
const yDoc = seedYDocFromHtml(
|
|
125
|
+
html,
|
|
126
|
+
[...createKnowledgeExtensions(), ...createKnowledgeDocAdditions()],
|
|
127
|
+
testDom,
|
|
128
|
+
);
|
|
126
129
|
return Y.encodeStateAsUpdate(yDoc);
|
|
127
130
|
}
|
|
128
131
|
|
|
@@ -173,7 +176,6 @@ describe("knowledge exporter 回写(真实 WS + 真实库)", () => {
|
|
|
173
176
|
|
|
174
177
|
beforeEach(async () => {
|
|
175
178
|
// 测试进程自身的 seed(htmlToUpdates)与被测导出器同走生产 DOM 注入路径
|
|
176
|
-
await ensureServerDom();
|
|
177
179
|
registerKnowledgeCollab();
|
|
178
180
|
ctx = await startCollabServer({ persistence: {}, debounceMs: 300 });
|
|
179
181
|
});
|
|
@@ -355,12 +357,15 @@ describe("knowledge exporter 回写(真实 WS + 真实库)", () => {
|
|
|
355
357
|
});
|
|
356
358
|
});
|
|
357
359
|
|
|
358
|
-
describe("DOM
|
|
359
|
-
test("
|
|
360
|
-
await
|
|
361
|
-
expect(
|
|
362
|
-
|
|
363
|
-
//
|
|
364
|
-
|
|
360
|
+
describe("局部 DOM(exporter 运行时前置)", () => {
|
|
361
|
+
test("getServerDom 返回局部 jsdom,且不向 globalThis 注入 DOM(进程级污染防护)", async () => {
|
|
362
|
+
const dom = await getServerDom();
|
|
363
|
+
expect(dom.document).toBeTruthy();
|
|
364
|
+
// 关键回归:注入 window/document 会让 @tanstack/openai-base 的
|
|
365
|
+
// isBrowserLike() 判定整个进程为浏览器,LLM 适配器随即抛 BROWSER_ERROR
|
|
366
|
+
expect((globalThis as Record<string, unknown>).window).toBeUndefined();
|
|
367
|
+
expect((globalThis as Record<string, unknown>).document).toBeUndefined();
|
|
368
|
+
// 幂等:二次调用返回同一实例
|
|
369
|
+
expect(await getServerDom()).toBe(dom);
|
|
365
370
|
});
|
|
366
371
|
});
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
type ProviderSession,
|
|
54
54
|
type StartedServer,
|
|
55
55
|
} from "./test-utils";
|
|
56
|
-
import {
|
|
56
|
+
import { getServerDom, registerKnowledgeCollab } from "../exporters/knowledge";
|
|
57
57
|
import { registerStoryCollab } from "../exporters/story";
|
|
58
58
|
import { resetExporters, resetRoomGuards } from "../exporters";
|
|
59
59
|
|
|
@@ -148,12 +148,15 @@ async function cleanOwnRows(): Promise<void> {
|
|
|
148
148
|
expect(residue).toBe(0);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
const testDom = await getServerDom();
|
|
152
|
+
|
|
151
153
|
/** 与种子化同一扩展组合(默认集 + 追加集)把 HTML 变成 Y update */
|
|
152
154
|
function htmlToUpdates(html: string): Uint8Array {
|
|
153
|
-
const yDoc = seedYDocFromHtml(
|
|
154
|
-
|
|
155
|
-
...createKnowledgeDocAdditions(),
|
|
156
|
-
|
|
155
|
+
const yDoc = seedYDocFromHtml(
|
|
156
|
+
html,
|
|
157
|
+
[...createKnowledgeExtensions(), ...createKnowledgeDocAdditions()],
|
|
158
|
+
testDom,
|
|
159
|
+
);
|
|
157
160
|
return Y.encodeStateAsUpdate(yDoc);
|
|
158
161
|
}
|
|
159
162
|
|
|
@@ -195,7 +198,6 @@ describe("story exporter + /internal/apply entity room(真实 WS + 真实库
|
|
|
195
198
|
let session: ProviderSession | null = null;
|
|
196
199
|
|
|
197
200
|
beforeEach(async () => {
|
|
198
|
-
await ensureServerDom();
|
|
199
201
|
registerKnowledgeCollab();
|
|
200
202
|
registerStoryCollab();
|
|
201
203
|
ctx = await startCollabServer({ persistence: {}, debounceMs: 300 });
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
type StartedServer,
|
|
60
60
|
} from "./test-utils";
|
|
61
61
|
import {
|
|
62
|
-
|
|
62
|
+
getServerDom,
|
|
63
63
|
registerKnowledgeCollab,
|
|
64
64
|
resetKnowledgeReindexNotifier,
|
|
65
65
|
setKnowledgeReindexNotifier,
|
|
@@ -129,12 +129,15 @@ async function cleanOwnRows(): Promise<void> {
|
|
|
129
129
|
expect(residue).toBe(0);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
const testDom = await getServerDom();
|
|
133
|
+
|
|
132
134
|
/** 与种子化同一扩展组合把 HTML 变成 Y update(建快照行用) */
|
|
133
135
|
function htmlToState(html: string): Uint8Array<ArrayBuffer> {
|
|
134
|
-
const yDoc = seedYDocFromHtml(
|
|
135
|
-
|
|
136
|
-
...createKnowledgeDocAdditions(),
|
|
137
|
-
|
|
136
|
+
const yDoc = seedYDocFromHtml(
|
|
137
|
+
html,
|
|
138
|
+
[...createKnowledgeExtensions(), ...createKnowledgeDocAdditions()],
|
|
139
|
+
testDom,
|
|
140
|
+
);
|
|
138
141
|
return new Uint8Array(Y.encodeStateAsUpdate(yDoc));
|
|
139
142
|
}
|
|
140
143
|
|
|
@@ -212,7 +215,6 @@ describe("/internal/apply(web → collab 旁路写入转发,真实 WS + 真
|
|
|
212
215
|
let reindexSpy: ReturnType<typeof vi.fn<(docId: string) => Promise<void>>>;
|
|
213
216
|
|
|
214
217
|
beforeEach(async () => {
|
|
215
|
-
await ensureServerDom();
|
|
216
218
|
registerKnowledgeCollab();
|
|
217
219
|
reindexSpy = vi.fn<(docId: string) => Promise<void>>().mockResolvedValue(undefined);
|
|
218
220
|
setKnowledgeReindexNotifier(reindexSpy);
|
package/src/exporters/bug.ts
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
registerRoomGuard,
|
|
52
52
|
type CollabAuthorStat,
|
|
53
53
|
} from "../exporters";
|
|
54
|
-
import {
|
|
54
|
+
import { getServerDom } from "./knowledge";
|
|
55
55
|
import {
|
|
56
56
|
isEmptyEditorHtml,
|
|
57
57
|
parseStoryDescription,
|
|
@@ -394,10 +394,10 @@ async function exportBug(input: {
|
|
|
394
394
|
});
|
|
395
395
|
if (!alive) return;
|
|
396
396
|
|
|
397
|
-
await
|
|
397
|
+
const dom = await getServerDom();
|
|
398
398
|
// description:default fragment → {html, markdown}(与种子化同一扩展组合)
|
|
399
399
|
const { yDocToContent } = await import("@allbluecn/collab-core/tiptap-export");
|
|
400
|
-
const content = yDocToContent(input.doc, storyDocExtensions());
|
|
400
|
+
const content = yDocToContent(input.doc, storyDocExtensions(), dom);
|
|
401
401
|
const fields = readBugFieldsPatch(input.doc);
|
|
402
402
|
// 空 Y.Array → null = Y 无意见,不触碰业务 steps 列
|
|
403
403
|
const steps = readStepsFromDoc(input.doc);
|
package/src/exporters/design.ts
CHANGED
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
yTreeToPackage,
|
|
50
50
|
type CollabLeaferJSONPackage,
|
|
51
51
|
} from "@allbluecn/collab-core/canvas-package";
|
|
52
|
-
import { yDocToContent } from "@allbluecn/collab-core/tiptap-export";
|
|
52
|
+
import { yDocToContent, type TiptapDom } from "@allbluecn/collab-core/tiptap-export";
|
|
53
53
|
import type * as Y from "yjs";
|
|
54
54
|
import {
|
|
55
55
|
computeAuthorAttribution,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
registerRoomGuard,
|
|
58
58
|
type CollabAuthorStat,
|
|
59
59
|
} from "../exporters";
|
|
60
|
-
import {
|
|
60
|
+
import { getServerDom } from "./knowledge";
|
|
61
61
|
import { isEmptyEditorHtml, storyDocExtensions, type StoryTx } from "./story";
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -207,8 +207,11 @@ export function readCanvasPackage(doc: Y.Doc): CollabLeaferJSONPackage | undefin
|
|
|
207
207
|
* 从 Y.Doc 导出文档 fragment(同 room 双载体 DESIGN_DOC_FRAGMENT="default")。
|
|
208
208
|
* 空产物(编辑器空文档)返回 undefined = Y 无意见不触碰 content 列。
|
|
209
209
|
*/
|
|
210
|
-
export function readDesignDocContent(
|
|
211
|
-
|
|
210
|
+
export function readDesignDocContent(
|
|
211
|
+
doc: Y.Doc,
|
|
212
|
+
dom?: TiptapDom,
|
|
213
|
+
): DesignDocContent | undefined {
|
|
214
|
+
const content = yDocToContent(doc, designDocExtensions(), dom);
|
|
212
215
|
if (isEmptyEditorHtml(content.html)) return undefined;
|
|
213
216
|
return { html: content.html, markdown: content.markdown };
|
|
214
217
|
}
|
|
@@ -239,9 +242,9 @@ async function exportDesign(input: {
|
|
|
239
242
|
});
|
|
240
243
|
if (!alive) return;
|
|
241
244
|
|
|
242
|
-
await
|
|
245
|
+
const dom = await getServerDom();
|
|
243
246
|
const canvas = readCanvasPackage(input.doc);
|
|
244
|
-
const content = readDesignDocContent(input.doc);
|
|
247
|
+
const content = readDesignDocContent(input.doc, dom);
|
|
245
248
|
// 双面皆无(空 room)→ 无可回写
|
|
246
249
|
if (canvas === undefined && content === undefined) return;
|
|
247
250
|
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
// 追加集已下沉 @allbluecn/collab-core/knowledge-additions(任务 16)。
|
|
40
40
|
//
|
|
41
41
|
// DOM 纪律:generateHTML/generateJSON 依赖浏览器 DOM 全局;生产 Node 由
|
|
42
|
-
//
|
|
42
|
+
// getServerDom 懒加载 jsdom(局部使用,禁止注入 globalThis;jsdom 为 apps/collab 运行时依赖)。
|
|
43
43
|
|
|
44
44
|
import type { CollabRoomName } from "@allbluecn/collab-core/rooms";
|
|
45
45
|
import {
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
import {
|
|
50
50
|
yDocToContent,
|
|
51
51
|
type KnowledgeDocContent,
|
|
52
|
+
type TiptapDom,
|
|
52
53
|
} from "@allbluecn/collab-core/tiptap-export";
|
|
53
54
|
import { createKnowledgeExtensions } from "@allbluecn/collab-core/knowledge-schema";
|
|
54
55
|
import { createKnowledgeDocAdditions } from "@allbluecn/collab-core/knowledge-additions";
|
|
@@ -60,27 +61,29 @@ import {
|
|
|
60
61
|
type CollabAuthorStat,
|
|
61
62
|
} from "../exporters";
|
|
62
63
|
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
/**
|
|
65
|
+
* 生产 Node 运行时的局部 DOM(jsdom,单例懒加载,与 web seed.ts 同构)。
|
|
66
|
+
* 只把 window 作为参数传给 tiptap-export 的 seedYDocFromHtml/yDocToContent,
|
|
67
|
+
* **绝不注入 globalThis**——注入会使整个进程被 @tanstack/openai-base 等库判定为
|
|
68
|
+
* 浏览器,后续所有 OpenAI 兼容 provider 的 LLM 调用立即抛 BROWSER_ERROR
|
|
69
|
+
* (2026-12-03 harness 首轮无回复的根因)。
|
|
70
|
+
*/
|
|
71
|
+
let serverDomPromise: Promise<TiptapDom> | null = null;
|
|
72
|
+
|
|
73
|
+
export async function getServerDom(): Promise<TiptapDom> {
|
|
74
|
+
if (typeof window !== "undefined") return window as unknown as TiptapDom;
|
|
75
|
+
if (!serverDomPromise) {
|
|
76
|
+
serverDomPromise = import("jsdom")
|
|
77
|
+
.then(({ JSDOM }) => {
|
|
78
|
+
const dom = new JSDOM("<!doctype html><html><body></body></html>");
|
|
79
|
+
return dom.window as unknown as TiptapDom;
|
|
80
|
+
})
|
|
81
|
+
.catch((error: unknown) => {
|
|
82
|
+
serverDomPromise = null;
|
|
83
|
+
throw error;
|
|
84
|
+
});
|
|
83
85
|
}
|
|
86
|
+
return serverDomPromise;
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
/** 与 web 种子化完全同一扩展组合(默认集 + 追加集)——漂移 = round-trip 丢内容 */
|
|
@@ -234,10 +237,11 @@ async function exportKnowledgeDoc(input: {
|
|
|
234
237
|
});
|
|
235
238
|
if (!doc || doc.isDeleted) return;
|
|
236
239
|
|
|
237
|
-
await
|
|
240
|
+
const dom = await getServerDom();
|
|
238
241
|
const content: KnowledgeDocContent = yDocToContent(
|
|
239
242
|
input.doc,
|
|
240
243
|
knowledgeDocExtensions(),
|
|
244
|
+
dom,
|
|
241
245
|
);
|
|
242
246
|
await db.prisma.knowledgeDocument.update({
|
|
243
247
|
where: { id: room.docId },
|
package/src/exporters/story.ts
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
// writeStoryColumns 同时被 /internal/apply 的离线直落路径(internal-apply.ts)
|
|
45
45
|
// 复用——同一 diff/活动/touch 语义单源。
|
|
46
46
|
//
|
|
47
|
-
// DOM 纪律:yDocToContent
|
|
47
|
+
// DOM 纪律:yDocToContent 的 HTML 序列化依赖 DOM;getServerDom 懒加载 jsdom
|
|
48
48
|
// 注入(复用 knowledge 导出器的实现)。
|
|
49
49
|
|
|
50
50
|
import type { CollabRoomName } from "@allbluecn/collab-core/rooms";
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
registerRoomGuard,
|
|
60
60
|
type CollabAuthorStat,
|
|
61
61
|
} from "../exporters";
|
|
62
|
-
import {
|
|
62
|
+
import { getServerDom } from "./knowledge";
|
|
63
63
|
|
|
64
64
|
// ── Y 结构契约常量(锚点 L;与 web bindings/fields.ts 镜像,apps 不可互 import)──
|
|
65
65
|
|
|
@@ -454,9 +454,9 @@ async function exportStory(input: {
|
|
|
454
454
|
});
|
|
455
455
|
if (!alive) return;
|
|
456
456
|
|
|
457
|
-
await
|
|
457
|
+
const dom = await getServerDom();
|
|
458
458
|
// description:default fragment → {html, markdown}(与种子化同一扩展组合)
|
|
459
|
-
const content = yDocToContent(input.doc, storyDocExtensions());
|
|
459
|
+
const content = yDocToContent(input.doc, storyDocExtensions(), dom);
|
|
460
460
|
const fields = readFieldsPatch(input.doc);
|
|
461
461
|
|
|
462
462
|
// per-author 占比(§10.2,共享助手单源):随活动 metadata 落流水
|
package/src/internal-apply.ts
CHANGED
|
@@ -67,7 +67,7 @@ import type { Document as CollabDocument } from "@hocuspocus/server";
|
|
|
67
67
|
import type { Prisma } from "@allbluecn/database";
|
|
68
68
|
import { runRoomGuard } from "./exporters";
|
|
69
69
|
import {
|
|
70
|
-
|
|
70
|
+
getServerDom,
|
|
71
71
|
notifyKnowledgeReindex,
|
|
72
72
|
} from "./exporters/knowledge";
|
|
73
73
|
import {
|
|
@@ -416,9 +416,9 @@ async function applyKnowledgeToLiveDoc(
|
|
|
416
416
|
html: string,
|
|
417
417
|
actor: string,
|
|
418
418
|
): Promise<InternalApplyResponse> {
|
|
419
|
-
await
|
|
419
|
+
const dom = await getServerDom();
|
|
420
420
|
const normalized = html.trim() === "" ? "<p></p>" : html;
|
|
421
|
-
const source = seedYDocFromHtml(normalized, knowledgeDocExtensions());
|
|
421
|
+
const source = seedYDocFromHtml(normalized, knowledgeDocExtensions(), dom);
|
|
422
422
|
const sourceUpdate = Y.encodeStateAsUpdate(source);
|
|
423
423
|
const fragment = document.getXmlFragment(COLLAB_XML_FRAGMENT);
|
|
424
424
|
document.transact(() => {
|
|
@@ -454,11 +454,11 @@ async function applyEntityToLiveDoc(
|
|
|
454
454
|
activityHint?: BugActivityHint;
|
|
455
455
|
},
|
|
456
456
|
): Promise<InternalApplyResponse> {
|
|
457
|
-
await
|
|
457
|
+
const dom = face.html === undefined ? null : await getServerDom();
|
|
458
458
|
document.transact(() => {
|
|
459
459
|
if (face.html !== undefined) {
|
|
460
460
|
const normalized = face.html.trim() === "" ? "<p></p>" : face.html;
|
|
461
|
-
const source = seedYDocFromHtml(normalized, storyDocExtensions());
|
|
461
|
+
const source = seedYDocFromHtml(normalized, storyDocExtensions(), dom ?? undefined);
|
|
462
462
|
const sourceUpdate = Y.encodeStateAsUpdate(source);
|
|
463
463
|
const fragment = document.getXmlFragment(COLLAB_XML_FRAGMENT);
|
|
464
464
|
fragment.delete(0, fragment.length);
|
|
@@ -522,14 +522,14 @@ async function applyDesignToLiveDoc(
|
|
|
522
522
|
actor: string;
|
|
523
523
|
},
|
|
524
524
|
): Promise<InternalApplyResponse> {
|
|
525
|
-
await
|
|
525
|
+
const dom = face.html === undefined ? null : await getServerDom();
|
|
526
526
|
document.transact(() => {
|
|
527
527
|
if (face.canvas !== undefined) {
|
|
528
528
|
seedYTreeFromCanvas(face.canvas, document);
|
|
529
529
|
}
|
|
530
530
|
if (face.html !== undefined) {
|
|
531
531
|
const normalized = face.html.trim() === "" ? "<p></p>" : face.html;
|
|
532
|
-
const source = seedYDocFromHtml(normalized, designDocExtensions());
|
|
532
|
+
const source = seedYDocFromHtml(normalized, designDocExtensions(), dom ?? undefined);
|
|
533
533
|
const sourceUpdate = Y.encodeStateAsUpdate(source);
|
|
534
534
|
const fragment = document.getXmlFragment(DESIGN_DOC_FRAGMENT);
|
|
535
535
|
fragment.delete(0, fragment.length);
|