@arbidocs/blocks 0.4.33 → 0.4.38
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/dist/agents/index.cjs +224 -224
- package/dist/agents/index.js +5 -5
- package/dist/chat/index.cjs +123 -123
- package/dist/chat/index.js +2 -2
- package/dist/{chunk-MZL67U2E.cjs → chunk-2EI7NCUA.cjs} +8 -3
- package/dist/chunk-2EI7NCUA.cjs.map +1 -0
- package/dist/{chunk-PXFJDX2C.js → chunk-4WWM3GQ5.js} +4 -3
- package/dist/chunk-4WWM3GQ5.js.map +1 -0
- package/dist/{chunk-6DNYPLCD.cjs → chunk-7RGLTF76.cjs} +4 -3
- package/dist/chunk-7RGLTF76.cjs.map +1 -0
- package/dist/{chunk-4AWS54US.js → chunk-CKB64Z4R.js} +4 -3
- package/dist/chunk-CKB64Z4R.js.map +1 -0
- package/dist/{chunk-6RXUMBTK.js → chunk-EA6YX3GR.js} +6 -6
- package/dist/{chunk-6RXUMBTK.js.map → chunk-EA6YX3GR.js.map} +1 -1
- package/dist/{chunk-AZ75JUIH.cjs → chunk-EEGPWOOG.cjs} +5 -5
- package/dist/{chunk-AZ75JUIH.cjs.map → chunk-EEGPWOOG.cjs.map} +1 -1
- package/dist/{chunk-6YVI74BC.js → chunk-JH25QIZW.js} +439 -12
- package/dist/chunk-JH25QIZW.js.map +1 -0
- package/dist/{chunk-DLVX6R6B.cjs → chunk-KMYLQIOH.cjs} +3 -3
- package/dist/{chunk-DLVX6R6B.cjs.map → chunk-KMYLQIOH.cjs.map} +1 -1
- package/dist/{chunk-V6U5KVAR.js → chunk-LQITIYBN.js} +3 -3
- package/dist/{chunk-V6U5KVAR.js.map → chunk-LQITIYBN.js.map} +1 -1
- package/dist/{chunk-VMCOH3AY.cjs → chunk-NUF2WGGF.cjs} +527 -96
- package/dist/chunk-NUF2WGGF.cjs.map +1 -0
- package/dist/{chunk-M2YGPC5N.cjs → chunk-SKFSJHVU.cjs} +4 -4
- package/dist/{chunk-M2YGPC5N.cjs.map → chunk-SKFSJHVU.cjs.map} +1 -1
- package/dist/{chunk-24KQJYSB.js → chunk-SWON6O45.js} +3 -3
- package/dist/{chunk-24KQJYSB.js.map → chunk-SWON6O45.js.map} +1 -1
- package/dist/{chunk-SEQWI6E4.cjs → chunk-XDTYENKC.cjs} +21 -21
- package/dist/{chunk-SEQWI6E4.cjs.map → chunk-XDTYENKC.cjs.map} +1 -1
- package/dist/{chunk-2QTT2RZE.cjs → chunk-YJQVLVBJ.cjs} +4 -3
- package/dist/chunk-YJQVLVBJ.cjs.map +1 -0
- package/dist/{chunk-C7FGONCM.js → chunk-YU2KUMGE.js} +8 -3
- package/dist/chunk-YU2KUMGE.js.map +1 -0
- package/dist/{chunk-XWEJ5LV2.js → chunk-ZXYHBQFW.js} +3 -3
- package/dist/{chunk-XWEJ5LV2.js.map → chunk-ZXYHBQFW.js.map} +1 -1
- package/dist/connect/docx.cjs +4 -4
- package/dist/connect/docx.js +1 -1
- package/dist/connect/index.cjs +12 -12
- package/dist/connect/index.js +3 -3
- package/dist/docx/NativeDocxEditor.d.ts +2 -2
- package/dist/docx/index.cjs +33 -30
- package/dist/docx/index.cjs.map +1 -1
- package/dist/docx/index.d.ts +2 -2
- package/dist/docx/index.js +3 -4
- package/dist/docx/index.js.map +1 -1
- package/dist/docx/review/DocxEditorReview.d.ts +16 -0
- package/dist/docx/review/index.d.ts +3 -0
- package/dist/docx/review/reviewModule.d.ts +6 -0
- package/dist/docx/review/useReview.d.ts +29 -0
- package/dist/facts/index.cjs +8 -8
- package/dist/facts/index.js +4 -4
- package/dist/files/ExplorerSurface.d.ts +6 -2
- package/dist/files/index.cjs +27 -14
- package/dist/files/index.cjs.map +1 -1
- package/dist/files/index.js +26 -13
- package/dist/files/index.js.map +1 -1
- package/dist/index.cjs +683 -683
- package/dist/index.js +13 -13
- package/dist/settings/TriStateFilterMenu.d.ts +3 -1
- package/dist/settings/index.cjs +9 -9
- package/dist/settings/index.js +2 -2
- package/dist/shell/FilterInput.d.ts +3 -1
- package/dist/shell/TabHeader.d.ts +2 -0
- package/dist/shell/index.cjs +7 -7
- package/dist/shell/index.js +2 -2
- package/dist/studio/index.cjs +3 -3
- package/dist/studio/index.js +2 -2
- package/package.json +9 -13
- package/src/docx/styles.css +488 -43
- package/dist/chunk-2QTT2RZE.cjs.map +0 -1
- package/dist/chunk-4AWS54US.js.map +0 -1
- package/dist/chunk-6DNYPLCD.cjs.map +0 -1
- package/dist/chunk-6YVI74BC.js.map +0 -1
- package/dist/chunk-C7FGONCM.js.map +0 -1
- package/dist/chunk-MZL67U2E.cjs.map +0 -1
- package/dist/chunk-PXFJDX2C.js.map +0 -1
- package/dist/chunk-VMCOH3AY.cjs.map +0 -1
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
var chunk7UTB4PHM_cjs = require('./chunk-7UTB4PHM.cjs');
|
|
5
5
|
var fflate = require('fflate');
|
|
6
|
-
var
|
|
6
|
+
var store = require('@docx-editor.dev/core/store');
|
|
7
|
+
var React3 = require('react');
|
|
8
|
+
var react = require('@docx-editor.dev/react');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
10
|
var reactDom = require('react-dom');
|
|
8
|
-
var react = require('@docx-editor.dev/pro/react');
|
|
9
11
|
var ui = require('@arbidocs/react/ui');
|
|
10
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
11
12
|
var server = require('react-dom/server');
|
|
12
13
|
var Y = require('yjs');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var collaboration = require('@docx-editor.dev/pro/collaboration');
|
|
16
|
-
var hocuspocus = require('@docx-editor.dev/pro/collaboration/hocuspocus');
|
|
14
|
+
var coedit = require('@arbidocs/coedit');
|
|
15
|
+
var hocuspocus = require('@arbidocs/coedit/hocuspocus');
|
|
17
16
|
var lucideReact = require('lucide-react');
|
|
18
17
|
|
|
19
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -36,7 +35,7 @@ function _interopNamespace(e) {
|
|
|
36
35
|
return Object.freeze(n);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
var
|
|
38
|
+
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
40
39
|
var Y__namespace = /*#__PURE__*/_interopNamespace(Y);
|
|
41
40
|
|
|
42
41
|
function normalizeDocxExport(data) {
|
|
@@ -103,6 +102,435 @@ function normalizeDocxExport(data) {
|
|
|
103
102
|
if (!changed) return data;
|
|
104
103
|
return fflate.zipSync(files).slice().buffer;
|
|
105
104
|
}
|
|
105
|
+
function findNode(node, id) {
|
|
106
|
+
if (node.id === id) return node;
|
|
107
|
+
for (const child of node.children ?? []) {
|
|
108
|
+
const found = findNode(child, id);
|
|
109
|
+
if (found) return found;
|
|
110
|
+
}
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
function revisionItemsOfParagraph(part, paragraphId) {
|
|
114
|
+
const paragraph = findNode(part.root, paragraphId);
|
|
115
|
+
if (!paragraph) return [];
|
|
116
|
+
return store.revisionItemsOf({ ...part, root: paragraph });
|
|
117
|
+
}
|
|
118
|
+
function reviewModule() {
|
|
119
|
+
return {
|
|
120
|
+
id: "review",
|
|
121
|
+
review: {
|
|
122
|
+
displayModes: ["all-markup", "simple-markup", "proposed", "original"],
|
|
123
|
+
collectReviewItems: store.collectReviewItems,
|
|
124
|
+
revisionItemsOfParagraph
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
var NONE = [];
|
|
129
|
+
var ok = (result) => result?.ok === true;
|
|
130
|
+
function useReview() {
|
|
131
|
+
const editor = react.useDocxEditor();
|
|
132
|
+
const version = react.useEditorSnapshot(editor);
|
|
133
|
+
const revision = editor?.getReviewRevision() ?? 0;
|
|
134
|
+
const items = React3.useMemo(() => editor ? editor.getReviewItems() : NONE, [editor, revision]);
|
|
135
|
+
const paneOpen = editor?.isReviewPaneOpen() ?? false;
|
|
136
|
+
const activeKey = items.find((item) => item.isActive)?.key ?? null;
|
|
137
|
+
return React3.useMemo(
|
|
138
|
+
() => ({
|
|
139
|
+
ready: editor !== null,
|
|
140
|
+
items,
|
|
141
|
+
activeKey,
|
|
142
|
+
paneOpen,
|
|
143
|
+
setPaneOpen: (open) => {
|
|
144
|
+
if (editor && editor.isReviewPaneOpen() !== open) editor.exec({ type: "toggleReviewPane" });
|
|
145
|
+
},
|
|
146
|
+
setActive: (key, options) => ok(editor?.setActiveReviewItem(key, options)),
|
|
147
|
+
reply: (entry, text) => ok(editor?.replyToReviewItem(entry.key, text)),
|
|
148
|
+
accept: (entry) => ok(editor?.acceptReviewItem(entry.key)),
|
|
149
|
+
reject: (entry) => ok(editor?.rejectReviewItem(entry.key)),
|
|
150
|
+
resolve: (entry, resolved) => ok(editor?.setCommentResolved(entry.key, resolved)),
|
|
151
|
+
remove: (entry) => ok(editor?.deleteReviewItem(entry.key)),
|
|
152
|
+
addComment: (text) => ok(editor?.addComment(text)),
|
|
153
|
+
navigate: (direction) => ok(editor?.exec({ type: "navigateReviewChange", direction })),
|
|
154
|
+
resolveAll: (action) => ok(editor?.exec({ type: "resolveAllReviewChanges", action }))
|
|
155
|
+
}),
|
|
156
|
+
[editor, items, activeKey, paneOpen, version]
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
var ReviewItemContext = React3.createContext(null);
|
|
160
|
+
function useReviewItem() {
|
|
161
|
+
return React3.useContext(ReviewItemContext);
|
|
162
|
+
}
|
|
163
|
+
var CARD_GAP = 8;
|
|
164
|
+
var REVISION_LABELS = {
|
|
165
|
+
insert: "Inserted",
|
|
166
|
+
delete: "Deleted",
|
|
167
|
+
replace: "Replaced",
|
|
168
|
+
moveFrom: "Moved from here",
|
|
169
|
+
moveTo: "Moved to here",
|
|
170
|
+
format: "Formatted",
|
|
171
|
+
paragraphMark: "Paragraph break",
|
|
172
|
+
structural: "Table change"
|
|
173
|
+
};
|
|
174
|
+
function isTopLevel(entry) {
|
|
175
|
+
if (entry.kind === "comment") return !entry.parentId && !entry.parentRevisionId;
|
|
176
|
+
if (entry.kind === "custom") return entry.item.carded;
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
function formatDate(value) {
|
|
180
|
+
if (!value) return "";
|
|
181
|
+
const date = new Date(value);
|
|
182
|
+
return Number.isNaN(date.getTime()) ? "" : date.toLocaleString();
|
|
183
|
+
}
|
|
184
|
+
function Avatar({ entry }) {
|
|
185
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-review-avatar", "aria-hidden": "true", children: entry.initials });
|
|
186
|
+
}
|
|
187
|
+
function Message({ entry }) {
|
|
188
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-message", children: [
|
|
189
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-byline", children: [
|
|
190
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { entry }),
|
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-review-author", children: entry.author || "Reviewer" }),
|
|
192
|
+
/* @__PURE__ */ jsxRuntime.jsx("time", { className: "native-docx-review-date", children: formatDate(entry.date) })
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "native-docx-review-text", "data-testid": "review-text", children: entry.text })
|
|
195
|
+
] });
|
|
196
|
+
}
|
|
197
|
+
function ReplyForm({
|
|
198
|
+
entry,
|
|
199
|
+
review
|
|
200
|
+
}) {
|
|
201
|
+
const [text, setText] = React3.useState("");
|
|
202
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
203
|
+
"form",
|
|
204
|
+
{
|
|
205
|
+
className: "native-docx-review-reply",
|
|
206
|
+
onSubmit: (event) => {
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
const value = text.trim();
|
|
209
|
+
if (value && review.reply(entry, value)) setText("");
|
|
210
|
+
},
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
213
|
+
"input",
|
|
214
|
+
{
|
|
215
|
+
"data-testid": "review-reply-input",
|
|
216
|
+
"aria-label": "Reply",
|
|
217
|
+
placeholder: "Reply",
|
|
218
|
+
value: text,
|
|
219
|
+
onChange: (event) => setText(event.target.value),
|
|
220
|
+
onKeyDown: (event) => {
|
|
221
|
+
if (event.key === "Escape") {
|
|
222
|
+
event.stopPropagation();
|
|
223
|
+
review.setActive(null);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: !text.trim(), children: "Reply" }),
|
|
229
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
230
|
+
"button",
|
|
231
|
+
{
|
|
232
|
+
type: "button",
|
|
233
|
+
"data-testid": "review-reply-cancel",
|
|
234
|
+
onClick: () => review.setActive(null),
|
|
235
|
+
children: "Cancel"
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
function Card({
|
|
243
|
+
entry,
|
|
244
|
+
replies,
|
|
245
|
+
review,
|
|
246
|
+
extra,
|
|
247
|
+
cardRef,
|
|
248
|
+
top
|
|
249
|
+
}) {
|
|
250
|
+
const resolved = entry.kind === "comment" && entry.resolved;
|
|
251
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReviewItemContext.Provider, { value: entry, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
252
|
+
"article",
|
|
253
|
+
{
|
|
254
|
+
ref: cardRef,
|
|
255
|
+
className: "native-docx-review-card",
|
|
256
|
+
tabIndex: 0,
|
|
257
|
+
"aria-label": `${entry.kind === "revision" ? "Change" : "Comment"} by ${entry.author || "reviewer"}`,
|
|
258
|
+
onKeyDown: (event) => {
|
|
259
|
+
if (event.target !== event.currentTarget) return;
|
|
260
|
+
if ((event.key === "Enter" || event.key === " ") && entry.activatable) {
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
review.setActive(entry.key);
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
"data-testid": "review-card",
|
|
266
|
+
"data-kind": entry.kind,
|
|
267
|
+
"data-active": entry.isActive || void 0,
|
|
268
|
+
"data-resolved": resolved || void 0,
|
|
269
|
+
style: { top },
|
|
270
|
+
onClick: () => {
|
|
271
|
+
if (entry.activatable && !entry.isActive) review.setActive(entry.key);
|
|
272
|
+
},
|
|
273
|
+
children: [
|
|
274
|
+
entry.kind === "revision" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-review-kind", children: REVISION_LABELS[entry.revisionKind] ?? "Change" }),
|
|
275
|
+
/* @__PURE__ */ jsxRuntime.jsx(Message, { entry }),
|
|
276
|
+
replies.map((reply) => /* @__PURE__ */ jsxRuntime.jsx(Message, { entry: reply }, reply.key)),
|
|
277
|
+
extra,
|
|
278
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-actions", children: [
|
|
279
|
+
entry.kind === "revision" && !entry.readOnly && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
280
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
281
|
+
"button",
|
|
282
|
+
{
|
|
283
|
+
type: "button",
|
|
284
|
+
"data-testid": "review-accept",
|
|
285
|
+
onClick: () => review.accept(entry),
|
|
286
|
+
children: "Accept"
|
|
287
|
+
}
|
|
288
|
+
),
|
|
289
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
290
|
+
"button",
|
|
291
|
+
{
|
|
292
|
+
type: "button",
|
|
293
|
+
"data-testid": "review-reject",
|
|
294
|
+
onClick: () => review.reject(entry),
|
|
295
|
+
children: "Reject"
|
|
296
|
+
}
|
|
297
|
+
)
|
|
298
|
+
] }),
|
|
299
|
+
entry.kind === "comment" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
300
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
301
|
+
"button",
|
|
302
|
+
{
|
|
303
|
+
type: "button",
|
|
304
|
+
"data-testid": "review-resolve",
|
|
305
|
+
onClick: () => review.resolve(entry, !entry.resolved),
|
|
306
|
+
children: entry.resolved ? "Reopen" : "Resolve"
|
|
307
|
+
}
|
|
308
|
+
),
|
|
309
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
310
|
+
"button",
|
|
311
|
+
{
|
|
312
|
+
type: "button",
|
|
313
|
+
"data-testid": "review-delete",
|
|
314
|
+
onClick: () => review.remove(entry),
|
|
315
|
+
children: "Delete"
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
] })
|
|
319
|
+
] }),
|
|
320
|
+
entry.isActive && entry.kind !== "custom" && /* @__PURE__ */ jsxRuntime.jsx(ReplyForm, { entry, review })
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
) });
|
|
324
|
+
}
|
|
325
|
+
function Draft({
|
|
326
|
+
top,
|
|
327
|
+
onSubmit,
|
|
328
|
+
onCancel,
|
|
329
|
+
formRef
|
|
330
|
+
}) {
|
|
331
|
+
const [text, setText] = React3.useState("");
|
|
332
|
+
const input = React3.useRef(null);
|
|
333
|
+
React3.useEffect(() => input.current?.focus(), []);
|
|
334
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
335
|
+
"form",
|
|
336
|
+
{
|
|
337
|
+
ref: formRef,
|
|
338
|
+
className: "native-docx-review-card native-docx-review-draft",
|
|
339
|
+
"data-testid": "review-draft",
|
|
340
|
+
style: { top },
|
|
341
|
+
onSubmit: (event) => {
|
|
342
|
+
event.preventDefault();
|
|
343
|
+
if (text.trim()) onSubmit(text.trim());
|
|
344
|
+
},
|
|
345
|
+
children: [
|
|
346
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
347
|
+
"input",
|
|
348
|
+
{
|
|
349
|
+
ref: input,
|
|
350
|
+
"data-testid": "review-draft-input",
|
|
351
|
+
"aria-label": "Comment",
|
|
352
|
+
placeholder: "Add a comment",
|
|
353
|
+
value: text,
|
|
354
|
+
onChange: (event) => setText(event.target.value),
|
|
355
|
+
onKeyDown: (event) => {
|
|
356
|
+
if (event.key === "Escape") onCancel();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
),
|
|
360
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-actions", children: [
|
|
361
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: !text.trim(), children: "Comment" }),
|
|
362
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "data-testid": "review-draft-cancel", onClick: onCancel, children: "Cancel" })
|
|
363
|
+
] })
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
function DocxEditorReviewRail({
|
|
369
|
+
children
|
|
370
|
+
}) {
|
|
371
|
+
const editor = react.useDocxEditor();
|
|
372
|
+
const registry = React3.useContext(react.ReviewRailContext);
|
|
373
|
+
const review = useReview();
|
|
374
|
+
const [draft, setDraft] = React3.useState(null);
|
|
375
|
+
const [tops, setTops] = React3.useState({});
|
|
376
|
+
const [showResolved, setShowResolved] = React3.useState(true);
|
|
377
|
+
const elements = React3.useRef(/* @__PURE__ */ new Map());
|
|
378
|
+
const openDraft = React3.useCallback(() => {
|
|
379
|
+
const placement = editor?.getSelectionPlacement();
|
|
380
|
+
if (!placement) return;
|
|
381
|
+
review.setPaneOpen(true);
|
|
382
|
+
setDraft({ anchorY: placement.anchorY });
|
|
383
|
+
}, [editor, review.setPaneOpen]);
|
|
384
|
+
React3.useEffect(() => registry?.register(), [registry]);
|
|
385
|
+
React3.useEffect(() => registry?.registerCommentDraft(openDraft), [registry, openDraft]);
|
|
386
|
+
const scale = editor?.getRenderScale() ?? 1;
|
|
387
|
+
const top = review.items.filter(isTopLevel).filter((entry) => entry.anchorY !== null).filter((entry) => showResolved || entry.kind !== "comment" || !entry.resolved);
|
|
388
|
+
const hasChanges = review.items.some((entry) => entry.kind === "revision");
|
|
389
|
+
const hasResolved = review.items.some((entry) => entry.kind === "comment" && entry.resolved);
|
|
390
|
+
const repliesOf = React3.useCallback(
|
|
391
|
+
(entry) => review.items.filter(
|
|
392
|
+
(other) => other.kind === "comment" && (other.parentId === entry.id || other.parentRevisionId === entry.id)
|
|
393
|
+
),
|
|
394
|
+
[review.items]
|
|
395
|
+
);
|
|
396
|
+
React3.useLayoutEffect(() => {
|
|
397
|
+
if (!review.paneOpen) return;
|
|
398
|
+
const next = {};
|
|
399
|
+
let floor = 0;
|
|
400
|
+
const rows = top.map((entry) => ({
|
|
401
|
+
key: entry.key,
|
|
402
|
+
y: (entry.anchorY ?? 0) * scale
|
|
403
|
+
}));
|
|
404
|
+
if (draft) rows.push({ key: "__draft", y: draft.anchorY * scale });
|
|
405
|
+
rows.sort((a, b) => a.y - b.y);
|
|
406
|
+
for (const row of rows) {
|
|
407
|
+
const y = Math.max(row.y, floor);
|
|
408
|
+
next[row.key] = y;
|
|
409
|
+
const height = elements.current.get(row.key)?.offsetHeight ?? 96;
|
|
410
|
+
floor = y + height + CARD_GAP;
|
|
411
|
+
}
|
|
412
|
+
setTops((previous) => {
|
|
413
|
+
const same = Object.keys(next).length === Object.keys(previous).length && Object.entries(next).every(([key, value]) => previous[key] === value);
|
|
414
|
+
return same ? previous : next;
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
if (!review.ready) return null;
|
|
418
|
+
const selection = editor?.getSelectionPlacement();
|
|
419
|
+
const addComment = selection && /* @__PURE__ */ jsxRuntime.jsx(
|
|
420
|
+
"button",
|
|
421
|
+
{
|
|
422
|
+
type: "button",
|
|
423
|
+
className: "native-docx-review-add",
|
|
424
|
+
"data-testid": "review-add-comment",
|
|
425
|
+
"aria-label": "Add comment",
|
|
426
|
+
style: { top: selection.anchorY * scale },
|
|
427
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
428
|
+
onClick: openDraft,
|
|
429
|
+
children: "+"
|
|
430
|
+
}
|
|
431
|
+
);
|
|
432
|
+
if (!review.paneOpen) {
|
|
433
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-markers", "data-testid": "review-markers", children: [
|
|
434
|
+
addComment,
|
|
435
|
+
top.map((entry) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
436
|
+
"button",
|
|
437
|
+
{
|
|
438
|
+
type: "button",
|
|
439
|
+
className: "native-docx-review-marker",
|
|
440
|
+
"data-testid": "review-marker",
|
|
441
|
+
"data-kind": entry.kind,
|
|
442
|
+
"aria-label": `${entry.author}: ${entry.text.slice(0, 60)}`,
|
|
443
|
+
style: { top: (entry.anchorY ?? 0) * scale },
|
|
444
|
+
onClick: () => {
|
|
445
|
+
review.setPaneOpen(true);
|
|
446
|
+
review.setActive(entry.key);
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
entry.key
|
|
450
|
+
))
|
|
451
|
+
] });
|
|
452
|
+
}
|
|
453
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: "native-docx-review-pane", "data-testid": "review-pane", "aria-label": "Review", children: [
|
|
454
|
+
addComment,
|
|
455
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-review-toolbar", "data-testid": "review-toolbar", children: [
|
|
456
|
+
hasChanges && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
457
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
458
|
+
"button",
|
|
459
|
+
{
|
|
460
|
+
type: "button",
|
|
461
|
+
"data-testid": "review-previous",
|
|
462
|
+
onClick: () => review.navigate("previous"),
|
|
463
|
+
children: "Previous change"
|
|
464
|
+
}
|
|
465
|
+
),
|
|
466
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "data-testid": "review-next", onClick: () => review.navigate("next"), children: "Next change" }),
|
|
467
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
468
|
+
"button",
|
|
469
|
+
{
|
|
470
|
+
type: "button",
|
|
471
|
+
"data-testid": "review-accept-all",
|
|
472
|
+
onClick: () => review.resolveAll("accept"),
|
|
473
|
+
children: "Accept all"
|
|
474
|
+
}
|
|
475
|
+
),
|
|
476
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
477
|
+
"button",
|
|
478
|
+
{
|
|
479
|
+
type: "button",
|
|
480
|
+
"data-testid": "review-reject-all",
|
|
481
|
+
onClick: () => review.resolveAll("reject"),
|
|
482
|
+
children: "Reject all"
|
|
483
|
+
}
|
|
484
|
+
)
|
|
485
|
+
] }),
|
|
486
|
+
hasResolved && /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
487
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
488
|
+
"input",
|
|
489
|
+
{
|
|
490
|
+
type: "checkbox",
|
|
491
|
+
"data-testid": "review-show-resolved",
|
|
492
|
+
checked: showResolved,
|
|
493
|
+
onChange: (event) => setShowResolved(event.target.checked)
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
"Show resolved"
|
|
497
|
+
] })
|
|
498
|
+
] }),
|
|
499
|
+
draft && /* @__PURE__ */ jsxRuntime.jsx(
|
|
500
|
+
Draft,
|
|
501
|
+
{
|
|
502
|
+
top: tops.__draft ?? draft.anchorY * scale,
|
|
503
|
+
formRef: (element) => {
|
|
504
|
+
if (element) elements.current.set("__draft", element);
|
|
505
|
+
},
|
|
506
|
+
onCancel: () => setDraft(null),
|
|
507
|
+
onSubmit: (text) => {
|
|
508
|
+
if (review.addComment(text)) setDraft(null);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
),
|
|
512
|
+
top.map((entry) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
513
|
+
Card,
|
|
514
|
+
{
|
|
515
|
+
entry,
|
|
516
|
+
replies: repliesOf(entry),
|
|
517
|
+
review,
|
|
518
|
+
extra: children?.(entry),
|
|
519
|
+
top: tops[entry.key] ?? (entry.anchorY ?? 0) * scale,
|
|
520
|
+
cardRef: (element) => {
|
|
521
|
+
if (element) elements.current.set(entry.key, element);
|
|
522
|
+
else elements.current.delete(entry.key);
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
entry.key
|
|
526
|
+
)),
|
|
527
|
+
top.length === 0 && !draft && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "native-docx-review-empty", "data-testid": "review-empty", children: "No comments or changes." })
|
|
528
|
+
] });
|
|
529
|
+
}
|
|
530
|
+
function ReviewCardSlot({ children }) {
|
|
531
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-review-extra", children });
|
|
532
|
+
}
|
|
533
|
+
var DocxEditorReview = Object.assign(DocxEditorReviewRail, { Card: ReviewCardSlot });
|
|
106
534
|
|
|
107
535
|
// src/docx/mentions.ts
|
|
108
536
|
function mentionCandidates(mentions) {
|
|
@@ -118,12 +546,12 @@ function mentionCandidates(mentions) {
|
|
|
118
546
|
function mentionedDocxRecipients(text, mentions) {
|
|
119
547
|
return chunk7UTB4PHM_cjs.extractMentions(text, mentionCandidates(mentions)).map((person) => person.id);
|
|
120
548
|
}
|
|
121
|
-
var ActivityContext =
|
|
549
|
+
var ActivityContext = React3.createContext({});
|
|
122
550
|
function DocxCommentActivity() {
|
|
123
|
-
const item =
|
|
124
|
-
const review =
|
|
125
|
-
const activity =
|
|
126
|
-
const [reading, setReading] =
|
|
551
|
+
const item = useReviewItem();
|
|
552
|
+
const review = useReview();
|
|
553
|
+
const activity = React3.useContext(ActivityContext);
|
|
554
|
+
const [reading, setReading] = React3.useState(false);
|
|
127
555
|
if (!item || item.kind !== "comment") return null;
|
|
128
556
|
const commentId = item.parentId || item.item.id;
|
|
129
557
|
const thread = review.items.filter(
|
|
@@ -205,11 +633,11 @@ function DocxMentions({
|
|
|
205
633
|
getAgentStatus,
|
|
206
634
|
notify
|
|
207
635
|
}) {
|
|
208
|
-
const review =
|
|
209
|
-
const [activity, setActivity] =
|
|
210
|
-
const root =
|
|
211
|
-
const [composers, setComposers] =
|
|
212
|
-
|
|
636
|
+
const review = useReview();
|
|
637
|
+
const [activity, setActivity] = React3.useState({});
|
|
638
|
+
const root = React3.useRef(null);
|
|
639
|
+
const [composers, setComposers] = React3.useState([]);
|
|
640
|
+
React3.useEffect(() => {
|
|
213
641
|
const element = root.current;
|
|
214
642
|
if (!element || !requestAgent) return;
|
|
215
643
|
const discover = () => {
|
|
@@ -235,15 +663,15 @@ function DocxMentions({
|
|
|
235
663
|
field.setSelectionRange(value.length, value.length);
|
|
236
664
|
setSuggestions(null);
|
|
237
665
|
};
|
|
238
|
-
const alive =
|
|
239
|
-
|
|
666
|
+
const alive = React3.useRef(true);
|
|
667
|
+
React3.useEffect(() => {
|
|
240
668
|
alive.current = true;
|
|
241
669
|
return () => {
|
|
242
670
|
alive.current = false;
|
|
243
671
|
};
|
|
244
672
|
}, []);
|
|
245
|
-
const activated =
|
|
246
|
-
|
|
673
|
+
const activated = React3.useRef(void 0);
|
|
674
|
+
React3.useEffect(() => {
|
|
247
675
|
if (!initialCommentId || activated.current === initialCommentId || !review.ready) return;
|
|
248
676
|
const target = review.items.find(
|
|
249
677
|
(item) => item.kind === "comment" && item.item.id === initialCommentId
|
|
@@ -252,16 +680,16 @@ function DocxMentions({
|
|
|
252
680
|
review.setPaneOpen(true);
|
|
253
681
|
if (review.setActive(target.key)) activated.current = initialCommentId;
|
|
254
682
|
}, [initialCommentId, review]);
|
|
255
|
-
const input =
|
|
256
|
-
const replyTarget =
|
|
257
|
-
const pending =
|
|
258
|
-
const [suggestions, setSuggestions] =
|
|
259
|
-
const [selected, setSelected] =
|
|
683
|
+
const input = React3.useRef(null);
|
|
684
|
+
const replyTarget = React3.useRef(null);
|
|
685
|
+
const pending = React3.useRef(null);
|
|
686
|
+
const [suggestions, setSuggestions] = React3.useState(null);
|
|
687
|
+
const [selected, setSelected] = React3.useState(0);
|
|
260
688
|
const candidates = chunk7UTB4PHM_cjs.filterMentionCandidates(
|
|
261
689
|
mentionCandidates(mentions),
|
|
262
690
|
suggestions?.query || ""
|
|
263
691
|
).slice(0, 8);
|
|
264
|
-
|
|
692
|
+
React3.useEffect(() => {
|
|
265
693
|
const submission = pending.current;
|
|
266
694
|
if (!submission || !requestAgent) return;
|
|
267
695
|
const created = review.items.find(
|
|
@@ -610,7 +1038,7 @@ function covered(room, vector, receipt) {
|
|
|
610
1038
|
}
|
|
611
1039
|
return true;
|
|
612
1040
|
}
|
|
613
|
-
var EditorBoundary = class extends
|
|
1041
|
+
var EditorBoundary = class extends React3__default.default.Component {
|
|
614
1042
|
state = {};
|
|
615
1043
|
static getDerivedStateFromError(error) {
|
|
616
1044
|
return { error };
|
|
@@ -623,8 +1051,8 @@ var EditorBoundary = class extends React2__default.default.Component {
|
|
|
623
1051
|
}
|
|
624
1052
|
};
|
|
625
1053
|
function DocxParticipants({ session }) {
|
|
626
|
-
const [people, setPeople] =
|
|
627
|
-
|
|
1054
|
+
const [people, setPeople] = React3.useState([]);
|
|
1055
|
+
React3.useEffect(() => {
|
|
628
1056
|
if (!session) return;
|
|
629
1057
|
setPeople(session.participants());
|
|
630
1058
|
return session.subscribeParticipants(setPeople);
|
|
@@ -636,9 +1064,9 @@ function RibbonMenu({
|
|
|
636
1064
|
icon,
|
|
637
1065
|
children
|
|
638
1066
|
}) {
|
|
639
|
-
const [open, setOpen] =
|
|
640
|
-
const element =
|
|
641
|
-
|
|
1067
|
+
const [open, setOpen] = React3.useState(false);
|
|
1068
|
+
const element = React3.useRef(null);
|
|
1069
|
+
React3.useEffect(() => {
|
|
642
1070
|
if (!open) return;
|
|
643
1071
|
const dismiss = (event) => {
|
|
644
1072
|
if (!element.current?.contains(event.target)) setOpen(false);
|
|
@@ -683,48 +1111,48 @@ function RibbonMenu({
|
|
|
683
1111
|
] });
|
|
684
1112
|
}
|
|
685
1113
|
function DocxRibbon({ onSave }) {
|
|
686
|
-
const [tab, setTab] =
|
|
687
|
-
const t = react
|
|
1114
|
+
const [tab, setTab] = React3.useState("Home");
|
|
1115
|
+
const t = react.useChromeTranslate();
|
|
688
1116
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-ribbon", children: [
|
|
689
1117
|
/* @__PURE__ */ jsxRuntime.jsxs("select", { "aria-label": "Ribbon tab", value: tab, onChange: (event) => setTab(event.target.value), children: [
|
|
690
1118
|
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "Home" }),
|
|
691
1119
|
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "Insert" }),
|
|
692
1120
|
/* @__PURE__ */ jsxRuntime.jsx("option", { children: "Review" })
|
|
693
1121
|
] }),
|
|
694
|
-
/* @__PURE__ */ jsxRuntime.jsxs(react
|
|
695
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
696
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1122
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Toolbar, { t, preset: false, onSave, children: [
|
|
1123
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Undo, {}),
|
|
1124
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Redo, {}),
|
|
697
1125
|
tab === "Home" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
698
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
699
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
700
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Bold, {}),
|
|
1127
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Italic, {}),
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Underline, {}),
|
|
701
1129
|
/* @__PURE__ */ jsxRuntime.jsxs(RibbonMenu, { label: "Font", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Type, { size: 16 }), children: [
|
|
702
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
703
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
704
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
705
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1130
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.FontFamily, {}),
|
|
1131
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.FontSize, {}),
|
|
1132
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.FontColor, {}),
|
|
1133
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Highlight, {})
|
|
706
1134
|
] }),
|
|
707
1135
|
/* @__PURE__ */ jsxRuntime.jsxs(RibbonMenu, { label: "More formatting", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Ellipsis, { size: 16 }), children: [
|
|
708
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
709
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
710
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
711
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
712
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
713
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
714
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
715
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
716
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1136
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.StylePicker, {}),
|
|
1137
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Alignment, {}),
|
|
1138
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.BulletList, {}),
|
|
1139
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.NumberedList, {}),
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.LineSpacing, {}),
|
|
1141
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Indent, {}),
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Outdent, {}),
|
|
1143
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Strike, {}),
|
|
1144
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.ClearFormatting, {})
|
|
717
1145
|
] })
|
|
718
1146
|
] }),
|
|
719
1147
|
tab === "Insert" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
720
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
721
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
722
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1148
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.TableInsert, {}),
|
|
1149
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.ImageInsert, {}),
|
|
1150
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Link, {})
|
|
723
1151
|
] }),
|
|
724
1152
|
tab === "Review" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
725
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
726
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
727
|
-
/* @__PURE__ */ jsxRuntime.jsx(RibbonMenu, { label: "Review options", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Ellipsis, { size: 16 }), children: /* @__PURE__ */ jsxRuntime.jsx(react
|
|
1153
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.EditingMode, {}),
|
|
1154
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Comments, {}),
|
|
1155
|
+
/* @__PURE__ */ jsxRuntime.jsx(RibbonMenu, { label: "Review options", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Ellipsis, { size: 16 }), children: /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Toolbar.Reviewers, {}) })
|
|
728
1156
|
] })
|
|
729
1157
|
] })
|
|
730
1158
|
] });
|
|
@@ -740,18 +1168,18 @@ function NativeDocxEditor({
|
|
|
740
1168
|
stream,
|
|
741
1169
|
adapter
|
|
742
1170
|
}) {
|
|
743
|
-
const [ready, setReady] =
|
|
744
|
-
const [status, setStatus] =
|
|
745
|
-
const revision =
|
|
746
|
-
const stageRef =
|
|
747
|
-
const ref =
|
|
1171
|
+
const [ready, setReady] = React3.useState(), [error, setError] = React3.useState(""), [retry, setRetry] = React3.useState(0);
|
|
1172
|
+
const [status, setStatus] = React3.useState("Connecting\u2026"), [dirty, setDirty] = React3.useState(false), [saving, setSaving] = React3.useState(false), [offline, setOffline] = React3.useState(false);
|
|
1173
|
+
const revision = React3.useRef(0);
|
|
1174
|
+
const stageRef = React3.useRef(null), fitCleanup = React3.useRef(void 0);
|
|
1175
|
+
const ref = React3.useRef(null), dirtyRef = React3.useRef(false), draftTimer = React3.useRef(void 0);
|
|
748
1176
|
const isDraft = draftContent !== void 0;
|
|
749
|
-
const streamRef =
|
|
1177
|
+
const streamRef = React3.useRef(stream);
|
|
750
1178
|
streamRef.current = stream;
|
|
751
|
-
const streamWriter =
|
|
752
|
-
const streamFinished =
|
|
753
|
-
const streamTimer =
|
|
754
|
-
const [streamAttempt, setStreamAttempt] =
|
|
1179
|
+
const streamWriter = React3.useRef(null);
|
|
1180
|
+
const streamFinished = React3.useRef(false);
|
|
1181
|
+
const streamTimer = React3.useRef(void 0);
|
|
1182
|
+
const [streamAttempt, setStreamAttempt] = React3.useState(0);
|
|
755
1183
|
function updateStream() {
|
|
756
1184
|
const current = streamRef.current;
|
|
757
1185
|
if (!current || !streamWriter.current || streamFinished.current) return;
|
|
@@ -775,7 +1203,7 @@ function NativeDocxEditor({
|
|
|
775
1203
|
);
|
|
776
1204
|
}
|
|
777
1205
|
}
|
|
778
|
-
|
|
1206
|
+
React3.useEffect(() => {
|
|
779
1207
|
if (!streamRef.current) return;
|
|
780
1208
|
if (!streamRef.current.busy) {
|
|
781
1209
|
clearTimeout(streamTimer.current);
|
|
@@ -788,8 +1216,8 @@ function NativeDocxEditor({
|
|
|
788
1216
|
}, 120);
|
|
789
1217
|
}
|
|
790
1218
|
}, [stream?.content, stream?.busy, stream?.error, streamAttempt]);
|
|
791
|
-
|
|
792
|
-
|
|
1219
|
+
React3.useEffect(() => () => clearTimeout(streamTimer.current), []);
|
|
1220
|
+
React3.useEffect(() => {
|
|
793
1221
|
let cancelled = false;
|
|
794
1222
|
let room;
|
|
795
1223
|
const cleanups = [];
|
|
@@ -810,7 +1238,7 @@ function NativeDocxEditor({
|
|
|
810
1238
|
setReady({
|
|
811
1239
|
document: new Uint8Array(data),
|
|
812
1240
|
fonts,
|
|
813
|
-
modules: [
|
|
1241
|
+
modules: [reviewModule()],
|
|
814
1242
|
canEdit: !snapshot,
|
|
815
1243
|
author: adapter.author || "You",
|
|
816
1244
|
filename: title
|
|
@@ -827,7 +1255,6 @@ function NativeDocxEditor({
|
|
|
827
1255
|
url: ws.toString(),
|
|
828
1256
|
roomId: session.room_id,
|
|
829
1257
|
identity: session.identity,
|
|
830
|
-
bootstrap: { kind: "join" },
|
|
831
1258
|
offlineEditing: true,
|
|
832
1259
|
token: async () => {
|
|
833
1260
|
const next = initial ? session : await adapter.open(documentId);
|
|
@@ -836,7 +1263,7 @@ function NativeDocxEditor({
|
|
|
836
1263
|
setReady((previous) => previous ? { ...previous, canEdit: next.can_edit } : previous);
|
|
837
1264
|
return JSON.stringify({
|
|
838
1265
|
capability: next.token,
|
|
839
|
-
versions:
|
|
1266
|
+
versions: coedit.DOCUMENT_COLLABORATION_VERSIONS
|
|
840
1267
|
});
|
|
841
1268
|
}
|
|
842
1269
|
});
|
|
@@ -894,7 +1321,7 @@ function NativeDocxEditor({
|
|
|
894
1321
|
setReady({
|
|
895
1322
|
document: current.document,
|
|
896
1323
|
fonts,
|
|
897
|
-
modules: [
|
|
1324
|
+
modules: [reviewModule(), coedit.collaborationModule({ session: current.session })],
|
|
898
1325
|
room: current,
|
|
899
1326
|
canEdit: session.can_edit,
|
|
900
1327
|
author: session.identity.name,
|
|
@@ -913,7 +1340,7 @@ function NativeDocxEditor({
|
|
|
913
1340
|
room?.destroy();
|
|
914
1341
|
};
|
|
915
1342
|
}, [documentId, isDraft, snapshot, retry]);
|
|
916
|
-
|
|
1343
|
+
React3.useEffect(() => {
|
|
917
1344
|
adapter.onDirtyChange?.(dirty);
|
|
918
1345
|
const beforeUnload = (e) => {
|
|
919
1346
|
if (dirtyRef.current) e.preventDefault();
|
|
@@ -938,7 +1365,7 @@ function NativeDocxEditor({
|
|
|
938
1365
|
a.click();
|
|
939
1366
|
setTimeout(() => URL.revokeObjectURL(url), 5e3);
|
|
940
1367
|
}
|
|
941
|
-
|
|
1368
|
+
React3.useLayoutEffect(() => {
|
|
942
1369
|
const editor = ref.current;
|
|
943
1370
|
return () => {
|
|
944
1371
|
if (isDraft && editor && dirtyRef.current)
|
|
@@ -1075,7 +1502,7 @@ function NativeDocxEditor({
|
|
|
1075
1502
|
] }),
|
|
1076
1503
|
!ready && !error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-error", role: "status", children: "Opening Word document\u2026" }),
|
|
1077
1504
|
ready && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "native-docx-body docx-editor", children: /* @__PURE__ */ jsxRuntime.jsx(EditorBoundary, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1078
|
-
react
|
|
1505
|
+
react.DocxEditor.Root,
|
|
1079
1506
|
{
|
|
1080
1507
|
document: ready.document,
|
|
1081
1508
|
modules: ready.modules,
|
|
@@ -1091,7 +1518,7 @@ function NativeDocxEditor({
|
|
|
1091
1518
|
onFontError: (e) => setError(e.message),
|
|
1092
1519
|
children: [
|
|
1093
1520
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1094
|
-
react
|
|
1521
|
+
react.DocxEditor.RevisionMarkup,
|
|
1095
1522
|
{
|
|
1096
1523
|
insertions: { mark: "underline", color: "blue" },
|
|
1097
1524
|
deletions: { mark: "strikethrough", color: "red" },
|
|
@@ -1111,8 +1538,8 @@ function NativeDocxEditor({
|
|
|
1111
1538
|
event.preventDefault();
|
|
1112
1539
|
},
|
|
1113
1540
|
children: [
|
|
1114
|
-
/* @__PURE__ */ jsxRuntime.jsxs(react
|
|
1115
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1541
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.DocxEditor.Viewport, { className: "native-docx-viewport", children: [
|
|
1542
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Content, {}),
|
|
1116
1543
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1117
1544
|
DocxMentions,
|
|
1118
1545
|
{
|
|
@@ -1121,16 +1548,16 @@ function NativeDocxEditor({
|
|
|
1121
1548
|
notify: adapter.notify,
|
|
1122
1549
|
getAgentStatus: adapter.getAgentStatus,
|
|
1123
1550
|
requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
|
|
1124
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1551
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}) }) })
|
|
1125
1552
|
}
|
|
1126
1553
|
),
|
|
1127
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1128
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1129
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1130
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1131
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1554
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
|
|
1555
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.NotesChrome, {}),
|
|
1556
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.Equation, {}),
|
|
1557
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HyperLink, {}),
|
|
1558
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.ContextMenu, {})
|
|
1132
1559
|
] }),
|
|
1133
|
-
/* @__PURE__ */ jsxRuntime.jsx(react
|
|
1560
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.PageNumber, {})
|
|
1134
1561
|
]
|
|
1135
1562
|
}
|
|
1136
1563
|
)
|
|
@@ -1168,7 +1595,7 @@ async function loadFonts(baseUrl) {
|
|
|
1168
1595
|
`${baseUrl.replace(/\/$/, "")}/${family.replace(" ", "")}-${face.suffix}.ttf`
|
|
1169
1596
|
);
|
|
1170
1597
|
if (!r.ok) throw new Error(`Could not load the document font ${family}.`);
|
|
1171
|
-
const result = react
|
|
1598
|
+
const result = react.createFontSource(new Uint8Array(await r.arrayBuffer()), {
|
|
1172
1599
|
family,
|
|
1173
1600
|
weight: face.weight,
|
|
1174
1601
|
style: face.style
|
|
@@ -1214,8 +1641,8 @@ function StreamedWordArtifact({
|
|
|
1214
1641
|
sourceDocumentId,
|
|
1215
1642
|
onSaved
|
|
1216
1643
|
}) {
|
|
1217
|
-
const [documentId, setDocumentId] =
|
|
1218
|
-
const saving =
|
|
1644
|
+
const [documentId, setDocumentId] = React3.useState();
|
|
1645
|
+
const saving = React3.useRef(null);
|
|
1219
1646
|
async function persist(bytes) {
|
|
1220
1647
|
if (saving.current) return saving.current;
|
|
1221
1648
|
saving.current = (async () => {
|
|
@@ -1257,6 +1684,7 @@ function StreamedWordArtifact({
|
|
|
1257
1684
|
}
|
|
1258
1685
|
|
|
1259
1686
|
exports.DocxCommentActivity = DocxCommentActivity;
|
|
1687
|
+
exports.DocxEditorReview = DocxEditorReview;
|
|
1260
1688
|
exports.DocxMentions = DocxMentions;
|
|
1261
1689
|
exports.DocxParticipants = DocxParticipants;
|
|
1262
1690
|
exports.DocxRibbon = DocxRibbon;
|
|
@@ -1264,5 +1692,8 @@ exports.NativeDocxEditor = NativeDocxEditor;
|
|
|
1264
1692
|
exports.StreamedWordArtifact = StreamedWordArtifact;
|
|
1265
1693
|
exports.loadDocxFonts = loadDocxFonts;
|
|
1266
1694
|
exports.normalizeDocxExport = normalizeDocxExport;
|
|
1267
|
-
|
|
1268
|
-
|
|
1695
|
+
exports.reviewModule = reviewModule;
|
|
1696
|
+
exports.useReview = useReview;
|
|
1697
|
+
exports.useReviewItem = useReviewItem;
|
|
1698
|
+
//# sourceMappingURL=chunk-NUF2WGGF.cjs.map
|
|
1699
|
+
//# sourceMappingURL=chunk-NUF2WGGF.cjs.map
|