wordinweb 0.2.2 → 0.2.3
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/{chunk-JGXXZTQE.js → chunk-OIN65MGS.js} +91 -70
- package/dist/chunk-OIN65MGS.js.map +1 -0
- package/dist/collab.d.ts +35 -19
- package/dist/collab.js +231 -50
- package/dist/collab.js.map +1 -1
- package/dist/{index-C2J9egkh.d.ts → index-CGp6gVjn.d.ts} +29 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-JGXXZTQE.js.map +0 -1
|
@@ -3930,7 +3930,7 @@ function parseParaChildren(parent, ctx, out, field, bookmarks) {
|
|
|
3930
3930
|
const style = (r) => {
|
|
3931
3931
|
r.props = {
|
|
3932
3932
|
...r.props,
|
|
3933
|
-
color: isInsert ? "#
|
|
3933
|
+
color: isInsert ? "#188038" : "#D93025",
|
|
3934
3934
|
...isInsert ? { underline: "single" } : { strike: true }
|
|
3935
3935
|
};
|
|
3936
3936
|
};
|
|
@@ -24176,6 +24176,26 @@ function insertSuggestedText(doc, t, offset, text, meta) {
|
|
|
24176
24176
|
if (offset < t.text.length) afterChildren.push(textLike(t, t.name, t.text.slice(offset)));
|
|
24177
24177
|
afterChildren.push(...following);
|
|
24178
24178
|
if (afterChildren.length > 0) replacement.push(runLike(rEl, rPr, afterChildren));
|
|
24179
|
+
if (localName(parent.name) === "ins") {
|
|
24180
|
+
const grand = doc.findParentOf(parent);
|
|
24181
|
+
if (!grand) return null;
|
|
24182
|
+
const parentIdx = grand.children.indexOf(parent);
|
|
24183
|
+
if (parentIdx === -1) return null;
|
|
24184
|
+
const insIdx = replacement.indexOf(ins);
|
|
24185
|
+
const before = [...parent.children.slice(0, idx), ...replacement.slice(0, insIdx)];
|
|
24186
|
+
const after = [...replacement.slice(insIdx + 1), ...parent.children.slice(idx + 1)];
|
|
24187
|
+
const outerParts = [];
|
|
24188
|
+
if (before.length > 0) outerParts.push({ ...cloneXml(parent), children: before });
|
|
24189
|
+
outerParts.push(ins);
|
|
24190
|
+
if (after.length > 0) {
|
|
24191
|
+
const afterOuter = { ...cloneXml(parent), children: after };
|
|
24192
|
+
const idKey = Object.keys(afterOuter.attrs).find((key) => localName(key) === "id");
|
|
24193
|
+
if (before.length > 0 && idKey) afterOuter.attrs[idKey] = String(meta.nextId());
|
|
24194
|
+
outerParts.push(afterOuter);
|
|
24195
|
+
}
|
|
24196
|
+
grand.children.splice(parentIdx, 1, ...outerParts);
|
|
24197
|
+
return { t: newT, offset: text.length };
|
|
24198
|
+
}
|
|
24179
24199
|
parent.children.splice(idx, 1, ...replacement);
|
|
24180
24200
|
return { t: newT, offset: text.length };
|
|
24181
24201
|
}
|
|
@@ -25409,7 +25429,7 @@ var _DocxEditor = class _DocxEditor {
|
|
|
25409
25429
|
this.caret = caret;
|
|
25410
25430
|
this.positionCaret();
|
|
25411
25431
|
this.focusText();
|
|
25412
|
-
const ref =
|
|
25432
|
+
const ref = this.revisionAtCaret();
|
|
25413
25433
|
if (ref) this.showSuggestionPopover(ref, e.clientX, e.clientY);
|
|
25414
25434
|
} else {
|
|
25415
25435
|
this.hideCaret();
|
|
@@ -28616,7 +28636,7 @@ var _DocxEditor = class _DocxEditor {
|
|
|
28616
28636
|
showSuggestionPopover(ref, clientX, clientY) {
|
|
28617
28637
|
this.dismissSuggestionPopover();
|
|
28618
28638
|
const isIns = ref.kind === "insertion" || ref.kind === "markInsertion";
|
|
28619
|
-
const ink = isIns ? "#
|
|
28639
|
+
const ink = isIns ? "#188038" : "#D93025";
|
|
28620
28640
|
const attrEndingWith = (suffix) => {
|
|
28621
28641
|
const key = Object.keys(ref.el.attrs).find((k) => k.toLowerCase().endsWith(suffix));
|
|
28622
28642
|
return key ? ref.el.attrs[key] : void 0;
|
|
@@ -28671,17 +28691,9 @@ var _DocxEditor = class _DocxEditor {
|
|
|
28671
28691
|
});
|
|
28672
28692
|
btnRow.appendChild(b);
|
|
28673
28693
|
};
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
note.style.cssText = "font-size:11.5px;color:#5f6368;line-height:1.35;";
|
|
28678
|
-
note.textContent = "Accept and reject are not available in a shared session yet.";
|
|
28679
|
-
box.appendChild(note);
|
|
28680
|
-
} else {
|
|
28681
|
-
box.appendChild(btnRow);
|
|
28682
|
-
mkBtn("\u2713 Accept", "Accept this suggestion", true, () => this.acceptRevisionRef(ref));
|
|
28683
|
-
mkBtn("\u2717 Reject", "Reject this suggestion", false, () => this.rejectRevisionRef(ref));
|
|
28684
|
-
}
|
|
28694
|
+
box.appendChild(btnRow);
|
|
28695
|
+
mkBtn("\u2713 Accept", "Accept this suggestion", true, () => this.acceptRevisionRef(ref));
|
|
28696
|
+
mkBtn("\u2717 Reject", "Reject this suggestion", false, () => this.rejectRevisionRef(ref));
|
|
28685
28697
|
document.body.appendChild(box);
|
|
28686
28698
|
this.suggestionPopover = box;
|
|
28687
28699
|
}
|
|
@@ -29625,27 +29637,16 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29625
29637
|
}
|
|
29626
29638
|
return null;
|
|
29627
29639
|
}
|
|
29628
|
-
/** True in a live session, where accept/reject would fork the room.
|
|
29629
|
-
*
|
|
29630
|
-
* Collab gate (narrow): the four accept/reject entry points below mutate
|
|
29631
|
-
* host.doc DIRECTLY (no emission), so in a live session they would resolve
|
|
29632
|
-
* the suggestion locally with no peer ever seeing it — refused per the
|
|
29633
|
-
* standing audit rule (no mutation branch without an emission). The
|
|
29634
|
-
* acceptRevision/rejectRevision/acceptAllRevisions INTENTS exist and apply
|
|
29635
|
-
* fine (collab/src/apply.ts), but they address a revision by its index in
|
|
29636
|
-
* collectRevisions order, which the editor has no path to produce here.
|
|
29637
|
-
* Wiring that is known follow-on work. Local mode is unaffected. */
|
|
29638
|
-
reviewBlockedByCollab() {
|
|
29639
|
-
return !!this.host.onIntent;
|
|
29640
|
-
}
|
|
29641
29640
|
/** Accept (keep insertion / drop deletion) the given revision, or the one at
|
|
29642
29641
|
* the caret. Re-renders and returns whether anything changed. */
|
|
29643
29642
|
acceptRevisionRef(ref) {
|
|
29644
|
-
if (this.reviewBlockedByCollab()) return false;
|
|
29645
29643
|
const target = ref ?? this.revisionAtCaret();
|
|
29646
29644
|
if (!target) return false;
|
|
29645
|
+
const index = this.host.onIntent ? collectRevisions(this.host.doc).findIndex((item) => item.el === target.el && item.kind === target.kind) : -1;
|
|
29646
|
+
if (this.host.onIntent && index < 0) return false;
|
|
29647
29647
|
this.host.history?.checkpoint();
|
|
29648
29648
|
if (!acceptRevision(this.host.doc, target)) return false;
|
|
29649
|
+
if (this.host.onIntent) this.host.onIntent({ kind: "acceptRevision", index });
|
|
29649
29650
|
this.dismissSuggestionPopover();
|
|
29650
29651
|
this.host.rerender();
|
|
29651
29652
|
this.positionCaret();
|
|
@@ -29655,11 +29656,13 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29655
29656
|
/** Reject (drop insertion / restore deletion) the given revision, or the one
|
|
29656
29657
|
* at the caret. */
|
|
29657
29658
|
rejectRevisionRef(ref) {
|
|
29658
|
-
if (this.reviewBlockedByCollab()) return false;
|
|
29659
29659
|
const target = ref ?? this.revisionAtCaret();
|
|
29660
29660
|
if (!target) return false;
|
|
29661
|
+
const index = this.host.onIntent ? collectRevisions(this.host.doc).findIndex((item) => item.el === target.el && item.kind === target.kind) : -1;
|
|
29662
|
+
if (this.host.onIntent && index < 0) return false;
|
|
29661
29663
|
this.host.history?.checkpoint();
|
|
29662
29664
|
if (!rejectRevision(this.host.doc, target)) return false;
|
|
29665
|
+
if (this.host.onIntent) this.host.onIntent({ kind: "rejectRevision", index });
|
|
29663
29666
|
this.dismissSuggestionPopover();
|
|
29664
29667
|
this.host.rerender();
|
|
29665
29668
|
this.positionCaret();
|
|
@@ -29672,10 +29675,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29672
29675
|
}
|
|
29673
29676
|
/** Accept every tracked change (one undo step). Returns how many applied. */
|
|
29674
29677
|
acceptAllRevisions() {
|
|
29675
|
-
if (this.reviewBlockedByCollab()) return 0;
|
|
29676
29678
|
this.host.history?.checkpoint();
|
|
29677
29679
|
const n = acceptAllRevisions(this.host.doc);
|
|
29678
29680
|
if (n === 0) return 0;
|
|
29681
|
+
this.host.onIntent?.({ kind: "acceptAllRevisions" });
|
|
29679
29682
|
this.dismissSuggestionPopover();
|
|
29680
29683
|
this.host.rerender();
|
|
29681
29684
|
this.positionCaret();
|
|
@@ -29684,10 +29687,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29684
29687
|
}
|
|
29685
29688
|
/** Reject every tracked change (one undo step). Returns how many applied. */
|
|
29686
29689
|
rejectAllRevisions() {
|
|
29687
|
-
if (this.reviewBlockedByCollab()) return 0;
|
|
29688
29690
|
this.host.history?.checkpoint();
|
|
29689
29691
|
const n = rejectAllRevisions(this.host.doc);
|
|
29690
29692
|
if (n === 0) return 0;
|
|
29693
|
+
this.host.onIntent?.({ kind: "rejectAllRevisions" });
|
|
29691
29694
|
this.dismissSuggestionPopover();
|
|
29692
29695
|
this.host.rerender();
|
|
29693
29696
|
this.positionCaret();
|
|
@@ -30172,14 +30175,21 @@ var _DocxEditor = class _DocxEditor {
|
|
|
30172
30175
|
return;
|
|
30173
30176
|
}
|
|
30174
30177
|
const splitPos = this.host.onIntent ? this.encodeCaretForIntent() : null;
|
|
30175
|
-
const
|
|
30178
|
+
const splitMeta = this.suggesting && this.host.onIntent ? this.frozenRevMeta() : void 0;
|
|
30179
|
+
const split = this.splitParagraphCore(splitMeta);
|
|
30176
30180
|
if (split && splitPos && this.host.doc.stableIds && this.host.onIntent) {
|
|
30177
30181
|
const ids = this.host.doc.stableIds;
|
|
30178
30182
|
const alloc = this.host.allocIds?.(2) ?? [];
|
|
30179
30183
|
const newBlockId = ids.assign(split.after, alloc[0]);
|
|
30180
30184
|
const newRunEl = split.after.children.find((c) => localName(c.name) === "r");
|
|
30181
30185
|
const newRunId = newRunEl ? ids.assign(newRunEl, alloc[1]) : newBlockId;
|
|
30182
|
-
this.host.onIntent({
|
|
30186
|
+
this.host.onIntent({
|
|
30187
|
+
kind: "splitParagraph",
|
|
30188
|
+
at: splitPos,
|
|
30189
|
+
newBlockId,
|
|
30190
|
+
newRunId,
|
|
30191
|
+
suggest: splitMeta ? { author: splitMeta.author, date: splitMeta.date } : void 0
|
|
30192
|
+
});
|
|
30183
30193
|
}
|
|
30184
30194
|
const reparsed = split ? this.host.doc.reparseDirectBodyParagraphSplit(split.before, split.after) : null;
|
|
30185
30195
|
if (reparsed && split && this.caret) {
|
|
@@ -30244,9 +30254,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
30244
30254
|
}
|
|
30245
30255
|
/** Split the paragraph at the caret without history or commit — shared by
|
|
30246
30256
|
* Enter and multi-line paste. */
|
|
30247
|
-
splitParagraphCore() {
|
|
30257
|
+
splitParagraphCore(meta) {
|
|
30248
30258
|
if (!this.caret) return null;
|
|
30249
|
-
const
|
|
30259
|
+
const ctx = meta ? { suggesting: true, revMeta: () => meta } : this.mutationCtx();
|
|
30260
|
+
const result = applySplitParagraph(this.host.doc, this.caret, ctx);
|
|
30250
30261
|
if (!result) return null;
|
|
30251
30262
|
this.caret = result.caret;
|
|
30252
30263
|
return { before: result.before, after: result.after };
|
|
@@ -35975,7 +35986,7 @@ function DocxToolbar({
|
|
|
35975
35986
|
result === "too-large" ? (() => {
|
|
35976
35987
|
const max = api?.imageMaxBytes() ?? null;
|
|
35977
35988
|
return max === null ? "That image is too large for this document." : `Images must be under ${formatBytes(max)}.`;
|
|
35978
|
-
})() : result === "unsupported-format" ? "Images in a shared document must be PNG, JPEG, GIF, BMP or WebP." : result === "no-relay" ? "This shared document has no image relay, so images can\u2019t be added to it." : result === "upload-failed" ? "Upload failed
|
|
35989
|
+
})() : result === "unsupported-format" ? "Images in a shared document must be PNG, JPEG, GIF, BMP or WebP." : result === "no-relay" ? "This shared document has no image relay, so images can\u2019t be added to it." : result === "upload-failed" ? "Upload failed. The image may be too large, or the connection dropped. Try a smaller image." : result === "no-caret" ? "Click in the document before inserting an image." : "That file could not be read as an image."
|
|
35979
35990
|
);
|
|
35980
35991
|
};
|
|
35981
35992
|
const rootRef = useRef2(null);
|
|
@@ -36851,6 +36862,8 @@ function DocxView({
|
|
|
36851
36862
|
const redrawPresenceRef = useRef3(null);
|
|
36852
36863
|
const presenceRef = useRef3(void 0);
|
|
36853
36864
|
presenceRef.current = collab?.presence;
|
|
36865
|
+
const collabRef = useRef3(collab);
|
|
36866
|
+
collabRef.current = collab;
|
|
36854
36867
|
useEffect3(() => {
|
|
36855
36868
|
redrawPresenceRef.current?.();
|
|
36856
36869
|
}, [collab?.presence]);
|
|
@@ -37017,14 +37030,15 @@ function DocxView({
|
|
|
37017
37030
|
};
|
|
37018
37031
|
const emitBlockIntents = (targets, make) => {
|
|
37019
37032
|
const d = docCacheRef.current?.doc;
|
|
37020
|
-
|
|
37033
|
+
const current = collabRef.current;
|
|
37034
|
+
if (!current || !d?.stableIds) return;
|
|
37021
37035
|
const seen = /* @__PURE__ */ new Set();
|
|
37022
37036
|
for (const t of targets) {
|
|
37023
37037
|
const p = paragraphOf(d, t);
|
|
37024
37038
|
const blockId = p ? d.stableIds.idOf(p) : void 0;
|
|
37025
37039
|
if (blockId !== void 0 && !seen.has(blockId)) {
|
|
37026
37040
|
seen.add(blockId);
|
|
37027
|
-
|
|
37041
|
+
current.submit(make(blockId));
|
|
37028
37042
|
}
|
|
37029
37043
|
}
|
|
37030
37044
|
};
|
|
@@ -37034,7 +37048,7 @@ function DocxView({
|
|
|
37034
37048
|
const presence = presenceRef.current;
|
|
37035
37049
|
if (!handle2 || !d || !presence) return;
|
|
37036
37050
|
drawPresenceSelections(handle2.root, computePresenceSelections(handle2, d, presence));
|
|
37037
|
-
drawPresenceCarets(handle2.root, computePresenceCarets(handle2, d, presence),
|
|
37051
|
+
drawPresenceCarets(handle2.root, computePresenceCarets(handle2, d, presence), collabRef.current?.participantNames);
|
|
37038
37052
|
};
|
|
37039
37053
|
redrawPresenceRef.current = drawCollabPresence;
|
|
37040
37054
|
const rerender = (doc, dirtyBlock, scope = "local", dirtySource) => {
|
|
@@ -37170,7 +37184,8 @@ function DocxView({
|
|
|
37170
37184
|
};
|
|
37171
37185
|
const flushPresence = () => {
|
|
37172
37186
|
presenceQueued = false;
|
|
37173
|
-
|
|
37187
|
+
const current = collabRef.current;
|
|
37188
|
+
if (!current?.setPresence) return;
|
|
37174
37189
|
const ranges = selectionRanges();
|
|
37175
37190
|
const last = ranges?.[ranges.length - 1];
|
|
37176
37191
|
const anchor = presenceCaret ?? (last ? { blockId: last.blockId, runId: last.runId, offset: last.end } : null);
|
|
@@ -37178,7 +37193,7 @@ function DocxView({
|
|
|
37178
37193
|
const key = pos ? JSON.stringify(pos) : "null";
|
|
37179
37194
|
if (key === presenceKey) return;
|
|
37180
37195
|
presenceKey = key;
|
|
37181
|
-
|
|
37196
|
+
current.setPresence(pos);
|
|
37182
37197
|
};
|
|
37183
37198
|
const queuePresence = () => {
|
|
37184
37199
|
if (presenceQueued) return;
|
|
@@ -37217,11 +37232,11 @@ function DocxView({
|
|
|
37217
37232
|
onStyleShortcut: (styleId) => applyStyleShortcut?.(styleId),
|
|
37218
37233
|
// Collaboration: forward each local edit as an intent. The editor
|
|
37219
37234
|
// emits only when doc.stableIds is populated, so enable it here.
|
|
37220
|
-
onIntent: collab ? (intent) =>
|
|
37235
|
+
onIntent: collab ? (intent) => collabRef.current?.submit(intent) : void 0,
|
|
37221
37236
|
// Cmd+Z in a room reverses the last SEQUENCED action over the wire;
|
|
37222
37237
|
// without this hook the editor declines rather than replaying local
|
|
37223
37238
|
// history (which would fork the room silently).
|
|
37224
|
-
onCollabUndo: collab?.undoLast,
|
|
37239
|
+
onCollabUndo: collab?.undoLast ? () => collabRef.current?.undoLast?.() : void 0,
|
|
37225
37240
|
// Presence: broadcast the local caret so remote participants can
|
|
37226
37241
|
// draw this user's cursor (the anchor mirrors the intent addressing).
|
|
37227
37242
|
// The caret is recorded here and sent by flushPresence together with
|
|
@@ -37232,7 +37247,7 @@ function DocxView({
|
|
|
37232
37247
|
} : void 0,
|
|
37233
37248
|
// Disjoint carried-id blocks for the editor's node-creating intents
|
|
37234
37249
|
// (paragraph split); see EditorHost.allocIds.
|
|
37235
|
-
allocIds: collab?.allocIds,
|
|
37250
|
+
allocIds: collab?.allocIds ? (n) => collabRef.current?.allocIds?.(n) ?? [] : void 0,
|
|
37236
37251
|
onTextCommand: (command) => {
|
|
37237
37252
|
const current = apiRef.current;
|
|
37238
37253
|
if (!current) return;
|
|
@@ -37337,27 +37352,30 @@ function DocxView({
|
|
|
37337
37352
|
};
|
|
37338
37353
|
const collabAnchor = (t, offset) => doc.stableIds ? doc.stableIds.encodeCaret(t, offset, (el16) => doc.findParentOf(el16) ?? null) : null;
|
|
37339
37354
|
const collabOp = (make, at) => {
|
|
37340
|
-
|
|
37355
|
+
const current = collabRef.current;
|
|
37356
|
+
if (!current?.submitOp || !doc.stableIds) return false;
|
|
37341
37357
|
const target = at !== void 0 ? at : insertionTarget();
|
|
37342
37358
|
if (!target) return true;
|
|
37343
37359
|
const anchor = collabAnchor(target.t, target.offset);
|
|
37344
37360
|
if (!anchor) return true;
|
|
37345
|
-
const intent = make(anchor, (n) =>
|
|
37361
|
+
const intent = make(anchor, (n) => current.allocIds?.(n) ?? []);
|
|
37346
37362
|
if (!intent) return true;
|
|
37347
37363
|
history.checkpoint();
|
|
37348
|
-
|
|
37364
|
+
current.submitOp(intent);
|
|
37349
37365
|
return true;
|
|
37350
37366
|
};
|
|
37351
37367
|
const collabDocOp = (make) => {
|
|
37352
|
-
|
|
37353
|
-
|
|
37368
|
+
const current = collabRef.current;
|
|
37369
|
+
if (!current?.submitOp || !doc.stableIds) return false;
|
|
37370
|
+
const intent = make((n) => current.allocIds?.(n) ?? []);
|
|
37354
37371
|
if (!intent) return true;
|
|
37355
37372
|
history.checkpoint();
|
|
37356
|
-
|
|
37373
|
+
current.submitOp(intent);
|
|
37357
37374
|
return true;
|
|
37358
37375
|
};
|
|
37359
37376
|
const collabBlockOp = (targets, make) => {
|
|
37360
|
-
|
|
37377
|
+
const current = collabRef.current;
|
|
37378
|
+
if (!current?.submitOp || !doc.stableIds) return false;
|
|
37361
37379
|
const submitted = /* @__PURE__ */ new Set();
|
|
37362
37380
|
let any = false;
|
|
37363
37381
|
for (const t of targets) {
|
|
@@ -37368,18 +37386,19 @@ function DocxView({
|
|
|
37368
37386
|
if (!intent) continue;
|
|
37369
37387
|
if (!any) history.checkpoint();
|
|
37370
37388
|
any = true;
|
|
37371
|
-
|
|
37389
|
+
current.submitOp(intent);
|
|
37372
37390
|
}
|
|
37373
37391
|
return true;
|
|
37374
37392
|
};
|
|
37375
|
-
const captureFormatIds = (segs) =>
|
|
37393
|
+
const captureFormatIds = (segs) => collabRef.current && doc.stableIds ? segs.map((seg) => ({
|
|
37376
37394
|
runId: seg.run.src ? doc.stableIds.idOf(seg.run.src) : void 0,
|
|
37377
37395
|
blockId: seg.run.srcParent ? doc.stableIds.idOf(seg.run.srcParent) : void 0,
|
|
37378
37396
|
runLen: seg.run.src ? runWireLength(seg.run.src) : 0,
|
|
37379
37397
|
cumStart: seg.run.src && seg.t ? wireOffsetOf(seg.run.src, seg.t, seg.start) ?? seg.start : seg.start
|
|
37380
37398
|
})) : [];
|
|
37381
37399
|
const emitFormatIntents = (segs, preIds, formatted, patch) => {
|
|
37382
|
-
|
|
37400
|
+
const current = collabRef.current;
|
|
37401
|
+
if (!current || !doc.stableIds) return;
|
|
37383
37402
|
const spanByRun = /* @__PURE__ */ new Map();
|
|
37384
37403
|
segs.forEach((seg, i) => {
|
|
37385
37404
|
const pre = preIds[i];
|
|
@@ -37402,18 +37421,18 @@ function DocxView({
|
|
|
37402
37421
|
const cumEnd = cumStart + (seg.end - seg.start);
|
|
37403
37422
|
const whole = !seg.t || span.lo <= 0 && span.hi >= runLen || (segCountByRun.get(runId) ?? 1) > 1;
|
|
37404
37423
|
if (whole) {
|
|
37405
|
-
|
|
37424
|
+
current.submit({ kind: "formatRun", blockId, runId, patch });
|
|
37406
37425
|
return;
|
|
37407
37426
|
}
|
|
37408
37427
|
const before = cumStart > 0;
|
|
37409
37428
|
const after = cumEnd < runLen;
|
|
37410
|
-
const alloc =
|
|
37429
|
+
const alloc = current.allocIds?.((before ? 1 : 0) + 1 + (after ? 1 : 0)) ?? [];
|
|
37411
37430
|
let k = 0;
|
|
37412
37431
|
const beforeId = before ? alloc[k++] : void 0;
|
|
37413
37432
|
const middleId = alloc[k++];
|
|
37414
37433
|
const afterId = after ? alloc[k++] : void 0;
|
|
37415
37434
|
if (middleId === void 0) return;
|
|
37416
|
-
|
|
37435
|
+
current.submit({ kind: "formatRange", blockId, runId, start: cumStart, end: cumEnd, patch, beforeId, middleId, afterId });
|
|
37417
37436
|
const middleT = formatted[i]?.t;
|
|
37418
37437
|
const middleRun = middleT ? doc.findParentOf(middleT) : null;
|
|
37419
37438
|
const parent = middleRun ? doc.findParentOf(middleRun) : null;
|
|
@@ -37567,7 +37586,7 @@ function DocxView({
|
|
|
37567
37586
|
return true;
|
|
37568
37587
|
},
|
|
37569
37588
|
updateSelectedChart: (data) => {
|
|
37570
|
-
if (
|
|
37589
|
+
if (collabRef.current?.submitOp) return false;
|
|
37571
37590
|
const source2 = editor?.getSelectedDrawingSource();
|
|
37572
37591
|
if (!source2) return false;
|
|
37573
37592
|
history.checkpoint();
|
|
@@ -37587,7 +37606,7 @@ function DocxView({
|
|
|
37587
37606
|
return true;
|
|
37588
37607
|
},
|
|
37589
37608
|
updateSelectedSmartArt: (data) => {
|
|
37590
|
-
if (
|
|
37609
|
+
if (collabRef.current?.submitOp) return false;
|
|
37591
37610
|
const source2 = editor?.getSelectedDrawingSource();
|
|
37592
37611
|
if (!source2) return false;
|
|
37593
37612
|
history.checkpoint();
|
|
@@ -37598,7 +37617,7 @@ function DocxView({
|
|
|
37598
37617
|
},
|
|
37599
37618
|
getSelectedSmartArt: () => editor?.getSelectedSmartArtData() ?? null,
|
|
37600
37619
|
insertModel3D: async (file, poster) => {
|
|
37601
|
-
if (
|
|
37620
|
+
if (collabRef.current?.submitOp) return false;
|
|
37602
37621
|
const target = insertionTarget();
|
|
37603
37622
|
if (!target) return false;
|
|
37604
37623
|
const preview = poster ?? await objectPoster("3D model", "Double-click in Word to explore", "\u25C7");
|
|
@@ -37610,7 +37629,7 @@ function DocxView({
|
|
|
37610
37629
|
return true;
|
|
37611
37630
|
},
|
|
37612
37631
|
insertOnlineVideo: async (url) => {
|
|
37613
|
-
if (
|
|
37632
|
+
if (collabRef.current?.submitOp) return false;
|
|
37614
37633
|
const target = insertionTarget();
|
|
37615
37634
|
if (!target) return false;
|
|
37616
37635
|
const preview = await objectPoster("Online video", url, "\u25B6");
|
|
@@ -37621,7 +37640,7 @@ function DocxView({
|
|
|
37621
37640
|
return true;
|
|
37622
37641
|
},
|
|
37623
37642
|
insertEmbeddedObject: async (file, filename) => {
|
|
37624
|
-
if (
|
|
37643
|
+
if (collabRef.current?.submitOp) return false;
|
|
37625
37644
|
const target = insertionTarget();
|
|
37626
37645
|
if (!target) return false;
|
|
37627
37646
|
const name = filename ?? (file instanceof File ? file.name : "embedded-file.bin");
|
|
@@ -37642,7 +37661,7 @@ function DocxView({
|
|
|
37642
37661
|
getSelectedSmartArtTextFormat: () => editor?.getSelectedSmartArtTextFormat() ?? null,
|
|
37643
37662
|
setSelectedSmartArtTextFormat: (patch) => editor?.setSelectedSmartArtTextFormat(patch) ?? false,
|
|
37644
37663
|
addComment: (text) => {
|
|
37645
|
-
if (
|
|
37664
|
+
if (collabRef.current?.submitOp) return false;
|
|
37646
37665
|
const segs = editor?.getSelectionSegments() ?? [];
|
|
37647
37666
|
const segments = segs.length > 0 ? segs : handle ? selectionToSegments(handle.bindings) : [];
|
|
37648
37667
|
if (segments.length === 0) return false;
|
|
@@ -37684,12 +37703,12 @@ function DocxView({
|
|
|
37684
37703
|
const caret = editor?.getCaretTarget();
|
|
37685
37704
|
return caret ? cellShadingAt(doc, caret.t) : void 0;
|
|
37686
37705
|
},
|
|
37687
|
-
imageAccept: () =>
|
|
37688
|
-
imageMaxBytes: () =>
|
|
37706
|
+
imageAccept: () => collabRef.current?.submitOp && doc.stableIds ? COLLAB_IMAGE_ACCEPT : LOCAL_IMAGE_ACCEPT,
|
|
37707
|
+
imageMaxBytes: () => collabRef.current?.submitOp && doc.stableIds ? collabRef.current.mediaMaxBlobBytes ?? null : null,
|
|
37689
37708
|
insertImage: async (file) => {
|
|
37690
37709
|
const caret = insertionTarget() ?? documentStart();
|
|
37691
37710
|
if (!caret) return "no-caret";
|
|
37692
|
-
const maxBytes =
|
|
37711
|
+
const maxBytes = collabRef.current?.submitOp && doc.stableIds ? collabRef.current.mediaMaxBlobBytes ?? null : null;
|
|
37693
37712
|
if (typeof maxBytes === "number" && file.size > maxBytes) return "too-large";
|
|
37694
37713
|
const bytes2 = new Uint8Array(await file.arrayBuffer());
|
|
37695
37714
|
const isSvg = file.type === "image/svg+xml";
|
|
@@ -37702,11 +37721,12 @@ function DocxView({
|
|
|
37702
37721
|
const maxW = sp ? sp.pageWidth - sp.marginLeft - sp.marginRight : 624;
|
|
37703
37722
|
const scale = Math.min(1, maxW / naturalWidth);
|
|
37704
37723
|
const ext = file.type === "image/svg+xml" ? "svg" : (file.type.split("/")[1] ?? "png").replace("jpeg", "jpg");
|
|
37705
|
-
|
|
37724
|
+
const current = collabRef.current;
|
|
37725
|
+
if (current?.submitOp && doc.stableIds) {
|
|
37706
37726
|
bmp?.close();
|
|
37707
|
-
if (!
|
|
37727
|
+
if (!current.uploadMedia) return "no-relay";
|
|
37708
37728
|
if (!COLLAB_IMAGE_EXTS.includes(ext)) return "unsupported-format";
|
|
37709
|
-
const media = await
|
|
37729
|
+
const media = await current.uploadMedia(bytes2);
|
|
37710
37730
|
if (!media) return "upload-failed";
|
|
37711
37731
|
const w = naturalWidth * scale;
|
|
37712
37732
|
const h2 = naturalHeight * scale;
|
|
@@ -38287,6 +38307,7 @@ export {
|
|
|
38287
38307
|
acceptRevision,
|
|
38288
38308
|
rejectRevision,
|
|
38289
38309
|
acceptAllRevisions,
|
|
38310
|
+
rejectAllRevisions,
|
|
38290
38311
|
applyInsertText,
|
|
38291
38312
|
applyDeleteRange,
|
|
38292
38313
|
applySplitParagraph,
|
|
@@ -38321,4 +38342,4 @@ export {
|
|
|
38321
38342
|
cfb/cfb.js:
|
|
38322
38343
|
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
|
38323
38344
|
*/
|
|
38324
|
-
//# sourceMappingURL=chunk-
|
|
38345
|
+
//# sourceMappingURL=chunk-OIN65MGS.js.map
|