wordinweb 0.2.1 → 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-XGTWJMDG.js → chunk-OIN65MGS.js} +271 -134
- 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-XGTWJMDG.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
|
};
|
|
@@ -20533,8 +20533,14 @@ function setPageLayout(doc, patch, target) {
|
|
|
20533
20533
|
return key ? elm.attrs[key] : void 0;
|
|
20534
20534
|
};
|
|
20535
20535
|
if (patch.size) {
|
|
20536
|
-
|
|
20537
|
-
|
|
20536
|
+
let width = Math.round(patch.size.width * TWIPS_PER_INCH);
|
|
20537
|
+
let height = Math.round(patch.size.height * TWIPS_PER_INCH);
|
|
20538
|
+
const currentWidth = parseInt(getAttr(pgSz, "w") ?? "12240", 10);
|
|
20539
|
+
const currentHeight = parseInt(getAttr(pgSz, "h") ?? "15840", 10);
|
|
20540
|
+
const isLandscape = getAttr(pgSz, "orient") === "landscape" || currentWidth > currentHeight;
|
|
20541
|
+
if (isLandscape !== width > height) [width, height] = [height, width];
|
|
20542
|
+
setAttr(pgSz, "w", String(width));
|
|
20543
|
+
setAttr(pgSz, "h", String(height));
|
|
20538
20544
|
}
|
|
20539
20545
|
if (patch.orientation) {
|
|
20540
20546
|
const cw = parseInt(getAttr(pgSz, "w") ?? "12240", 10);
|
|
@@ -24170,6 +24176,26 @@ function insertSuggestedText(doc, t, offset, text, meta) {
|
|
|
24170
24176
|
if (offset < t.text.length) afterChildren.push(textLike(t, t.name, t.text.slice(offset)));
|
|
24171
24177
|
afterChildren.push(...following);
|
|
24172
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
|
+
}
|
|
24173
24199
|
parent.children.splice(idx, 1, ...replacement);
|
|
24174
24200
|
return { t: newT, offset: text.length };
|
|
24175
24201
|
}
|
|
@@ -25403,7 +25429,7 @@ var _DocxEditor = class _DocxEditor {
|
|
|
25403
25429
|
this.caret = caret;
|
|
25404
25430
|
this.positionCaret();
|
|
25405
25431
|
this.focusText();
|
|
25406
|
-
const ref =
|
|
25432
|
+
const ref = this.revisionAtCaret();
|
|
25407
25433
|
if (ref) this.showSuggestionPopover(ref, e.clientX, e.clientY);
|
|
25408
25434
|
} else {
|
|
25409
25435
|
this.hideCaret();
|
|
@@ -28610,7 +28636,7 @@ var _DocxEditor = class _DocxEditor {
|
|
|
28610
28636
|
showSuggestionPopover(ref, clientX, clientY) {
|
|
28611
28637
|
this.dismissSuggestionPopover();
|
|
28612
28638
|
const isIns = ref.kind === "insertion" || ref.kind === "markInsertion";
|
|
28613
|
-
const ink = isIns ? "#
|
|
28639
|
+
const ink = isIns ? "#188038" : "#D93025";
|
|
28614
28640
|
const attrEndingWith = (suffix) => {
|
|
28615
28641
|
const key = Object.keys(ref.el.attrs).find((k) => k.toLowerCase().endsWith(suffix));
|
|
28616
28642
|
return key ? ref.el.attrs[key] : void 0;
|
|
@@ -28665,17 +28691,9 @@ var _DocxEditor = class _DocxEditor {
|
|
|
28665
28691
|
});
|
|
28666
28692
|
btnRow.appendChild(b);
|
|
28667
28693
|
};
|
|
28668
|
-
|
|
28669
|
-
|
|
28670
|
-
|
|
28671
|
-
note.style.cssText = "font-size:11.5px;color:#5f6368;line-height:1.35;";
|
|
28672
|
-
note.textContent = "Accept and reject are not available in a shared session yet.";
|
|
28673
|
-
box.appendChild(note);
|
|
28674
|
-
} else {
|
|
28675
|
-
box.appendChild(btnRow);
|
|
28676
|
-
mkBtn("\u2713 Accept", "Accept this suggestion", true, () => this.acceptRevisionRef(ref));
|
|
28677
|
-
mkBtn("\u2717 Reject", "Reject this suggestion", false, () => this.rejectRevisionRef(ref));
|
|
28678
|
-
}
|
|
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));
|
|
28679
28697
|
document.body.appendChild(box);
|
|
28680
28698
|
this.suggestionPopover = box;
|
|
28681
28699
|
}
|
|
@@ -29619,27 +29637,16 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29619
29637
|
}
|
|
29620
29638
|
return null;
|
|
29621
29639
|
}
|
|
29622
|
-
/** True in a live session, where accept/reject would fork the room.
|
|
29623
|
-
*
|
|
29624
|
-
* Collab gate (narrow): the four accept/reject entry points below mutate
|
|
29625
|
-
* host.doc DIRECTLY (no emission), so in a live session they would resolve
|
|
29626
|
-
* the suggestion locally with no peer ever seeing it — refused per the
|
|
29627
|
-
* standing audit rule (no mutation branch without an emission). The
|
|
29628
|
-
* acceptRevision/rejectRevision/acceptAllRevisions INTENTS exist and apply
|
|
29629
|
-
* fine (collab/src/apply.ts), but they address a revision by its index in
|
|
29630
|
-
* collectRevisions order, which the editor has no path to produce here.
|
|
29631
|
-
* Wiring that is known follow-on work. Local mode is unaffected. */
|
|
29632
|
-
reviewBlockedByCollab() {
|
|
29633
|
-
return !!this.host.onIntent;
|
|
29634
|
-
}
|
|
29635
29640
|
/** Accept (keep insertion / drop deletion) the given revision, or the one at
|
|
29636
29641
|
* the caret. Re-renders and returns whether anything changed. */
|
|
29637
29642
|
acceptRevisionRef(ref) {
|
|
29638
|
-
if (this.reviewBlockedByCollab()) return false;
|
|
29639
29643
|
const target = ref ?? this.revisionAtCaret();
|
|
29640
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;
|
|
29641
29647
|
this.host.history?.checkpoint();
|
|
29642
29648
|
if (!acceptRevision(this.host.doc, target)) return false;
|
|
29649
|
+
if (this.host.onIntent) this.host.onIntent({ kind: "acceptRevision", index });
|
|
29643
29650
|
this.dismissSuggestionPopover();
|
|
29644
29651
|
this.host.rerender();
|
|
29645
29652
|
this.positionCaret();
|
|
@@ -29649,11 +29656,13 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29649
29656
|
/** Reject (drop insertion / restore deletion) the given revision, or the one
|
|
29650
29657
|
* at the caret. */
|
|
29651
29658
|
rejectRevisionRef(ref) {
|
|
29652
|
-
if (this.reviewBlockedByCollab()) return false;
|
|
29653
29659
|
const target = ref ?? this.revisionAtCaret();
|
|
29654
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;
|
|
29655
29663
|
this.host.history?.checkpoint();
|
|
29656
29664
|
if (!rejectRevision(this.host.doc, target)) return false;
|
|
29665
|
+
if (this.host.onIntent) this.host.onIntent({ kind: "rejectRevision", index });
|
|
29657
29666
|
this.dismissSuggestionPopover();
|
|
29658
29667
|
this.host.rerender();
|
|
29659
29668
|
this.positionCaret();
|
|
@@ -29666,10 +29675,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29666
29675
|
}
|
|
29667
29676
|
/** Accept every tracked change (one undo step). Returns how many applied. */
|
|
29668
29677
|
acceptAllRevisions() {
|
|
29669
|
-
if (this.reviewBlockedByCollab()) return 0;
|
|
29670
29678
|
this.host.history?.checkpoint();
|
|
29671
29679
|
const n = acceptAllRevisions(this.host.doc);
|
|
29672
29680
|
if (n === 0) return 0;
|
|
29681
|
+
this.host.onIntent?.({ kind: "acceptAllRevisions" });
|
|
29673
29682
|
this.dismissSuggestionPopover();
|
|
29674
29683
|
this.host.rerender();
|
|
29675
29684
|
this.positionCaret();
|
|
@@ -29678,10 +29687,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
29678
29687
|
}
|
|
29679
29688
|
/** Reject every tracked change (one undo step). Returns how many applied. */
|
|
29680
29689
|
rejectAllRevisions() {
|
|
29681
|
-
if (this.reviewBlockedByCollab()) return 0;
|
|
29682
29690
|
this.host.history?.checkpoint();
|
|
29683
29691
|
const n = rejectAllRevisions(this.host.doc);
|
|
29684
29692
|
if (n === 0) return 0;
|
|
29693
|
+
this.host.onIntent?.({ kind: "rejectAllRevisions" });
|
|
29685
29694
|
this.dismissSuggestionPopover();
|
|
29686
29695
|
this.host.rerender();
|
|
29687
29696
|
this.positionCaret();
|
|
@@ -30166,14 +30175,21 @@ var _DocxEditor = class _DocxEditor {
|
|
|
30166
30175
|
return;
|
|
30167
30176
|
}
|
|
30168
30177
|
const splitPos = this.host.onIntent ? this.encodeCaretForIntent() : null;
|
|
30169
|
-
const
|
|
30178
|
+
const splitMeta = this.suggesting && this.host.onIntent ? this.frozenRevMeta() : void 0;
|
|
30179
|
+
const split = this.splitParagraphCore(splitMeta);
|
|
30170
30180
|
if (split && splitPos && this.host.doc.stableIds && this.host.onIntent) {
|
|
30171
30181
|
const ids = this.host.doc.stableIds;
|
|
30172
30182
|
const alloc = this.host.allocIds?.(2) ?? [];
|
|
30173
30183
|
const newBlockId = ids.assign(split.after, alloc[0]);
|
|
30174
30184
|
const newRunEl = split.after.children.find((c) => localName(c.name) === "r");
|
|
30175
30185
|
const newRunId = newRunEl ? ids.assign(newRunEl, alloc[1]) : newBlockId;
|
|
30176
|
-
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
|
+
});
|
|
30177
30193
|
}
|
|
30178
30194
|
const reparsed = split ? this.host.doc.reparseDirectBodyParagraphSplit(split.before, split.after) : null;
|
|
30179
30195
|
if (reparsed && split && this.caret) {
|
|
@@ -30238,9 +30254,10 @@ var _DocxEditor = class _DocxEditor {
|
|
|
30238
30254
|
}
|
|
30239
30255
|
/** Split the paragraph at the caret without history or commit — shared by
|
|
30240
30256
|
* Enter and multi-line paste. */
|
|
30241
|
-
splitParagraphCore() {
|
|
30257
|
+
splitParagraphCore(meta) {
|
|
30242
30258
|
if (!this.caret) return null;
|
|
30243
|
-
const
|
|
30259
|
+
const ctx = meta ? { suggesting: true, revMeta: () => meta } : this.mutationCtx();
|
|
30260
|
+
const result = applySplitParagraph(this.host.doc, this.caret, ctx);
|
|
30244
30261
|
if (!result) return null;
|
|
30245
30262
|
this.caret = result.caret;
|
|
30246
30263
|
return { before: result.before, after: result.after };
|
|
@@ -34206,6 +34223,7 @@ function WordArtMenu({ api }) {
|
|
|
34206
34223
|
}
|
|
34207
34224
|
function ChartMenu({ api, label = "Chart" }) {
|
|
34208
34225
|
const [open, setOpen] = useState2(false);
|
|
34226
|
+
const [editing, setEditing] = useState2(false);
|
|
34209
34227
|
const [type, setType] = useState2("column");
|
|
34210
34228
|
const [title, setTitle] = useState2("");
|
|
34211
34229
|
const [categories, setCategories] = useState2(["", ""]);
|
|
@@ -34222,16 +34240,35 @@ function ChartMenu({ api, label = "Chart" }) {
|
|
|
34222
34240
|
}, [open]);
|
|
34223
34241
|
const submit = () => {
|
|
34224
34242
|
const categoryValues = categories.map((value) => value.trim());
|
|
34225
|
-
const rawSeries = series.map((entry) => ({
|
|
34243
|
+
const rawSeries = (type === "pie" ? series.slice(0, 1) : series).map((entry) => ({
|
|
34226
34244
|
name: entry.name.trim(),
|
|
34227
34245
|
values: entry.values.map((value) => value.trim())
|
|
34228
34246
|
}));
|
|
34229
|
-
if (categoryValues.some((value) => !value)
|
|
34230
|
-
setError(
|
|
34247
|
+
if (categoryValues.some((value) => !value)) {
|
|
34248
|
+
setError(type === "pie" ? "Enter a label for every slice." : "Enter a name for every category.");
|
|
34231
34249
|
return;
|
|
34232
34250
|
}
|
|
34233
|
-
|
|
34234
|
-
|
|
34251
|
+
if (type !== "pie" && rawSeries.some((entry) => !entry.name)) {
|
|
34252
|
+
setError("Enter a name for every series.");
|
|
34253
|
+
return;
|
|
34254
|
+
}
|
|
34255
|
+
if (rawSeries.some((entry) => entry.values.some((value) => value === "" || !Number.isFinite(Number(value))))) {
|
|
34256
|
+
setError("Enter a number in every value field.");
|
|
34257
|
+
return;
|
|
34258
|
+
}
|
|
34259
|
+
if (type === "pie" && rawSeries.some((entry) => entry.values.some((value) => Number(value) < 0))) {
|
|
34260
|
+
setError("Pie chart values must be zero or greater.");
|
|
34261
|
+
return;
|
|
34262
|
+
}
|
|
34263
|
+
if (type === "pie" && rawSeries.every((entry) => entry.values.every((value) => Number(value) === 0))) {
|
|
34264
|
+
setError("Enter at least one pie chart value greater than zero.");
|
|
34265
|
+
return;
|
|
34266
|
+
}
|
|
34267
|
+
const seriesValues = rawSeries.map((entry) => ({
|
|
34268
|
+
name: type === "pie" ? entry.name || "Values" : entry.name,
|
|
34269
|
+
values: entry.values.map(Number)
|
|
34270
|
+
}));
|
|
34271
|
+
const data = { type, title: title.trim(), categories: categoryValues, series: seriesValues };
|
|
34235
34272
|
if (api?.updateSelectedChart(data) || api?.insertChart(data)) {
|
|
34236
34273
|
setError("");
|
|
34237
34274
|
setOpen(false);
|
|
@@ -34246,97 +34283,187 @@ function ChartMenu({ api, label = "Chart" }) {
|
|
|
34246
34283
|
setCategories(categories.filter((_, itemIndex) => itemIndex !== index));
|
|
34247
34284
|
setSeries(series.map((entry) => ({ ...entry, values: entry.values.filter((_, itemIndex) => itemIndex !== index) })));
|
|
34248
34285
|
};
|
|
34286
|
+
const changeType = (next) => {
|
|
34287
|
+
setType(next);
|
|
34288
|
+
if (next === "pie") {
|
|
34289
|
+
setSeries((current) => [
|
|
34290
|
+
current[0] ?? { name: "Values", values: categories.map(() => "") }
|
|
34291
|
+
]);
|
|
34292
|
+
}
|
|
34293
|
+
setError("");
|
|
34294
|
+
};
|
|
34249
34295
|
const anchor = open ? rootRef.current?.getBoundingClientRect() : null;
|
|
34250
34296
|
const viewportWidth = typeof window === "undefined" ? 456 : window.innerWidth;
|
|
34251
34297
|
const popoverWidth = Math.min(440, viewportWidth - 16);
|
|
34252
34298
|
const popoverLeft = Math.max(8, Math.min(anchor?.left ?? 8, viewportWidth - popoverWidth - 8));
|
|
34253
34299
|
const fieldStyle = { width: "100%", boxSizing: "border-box", border: `1px solid ${T.border}`, borderRadius: 6, padding: "6px 8px", font: "13px system-ui, sans-serif", color: T.fg, background: T.popoverBg };
|
|
34300
|
+
const fieldLabelStyle = { display: "grid", gap: 3, color: T.muted, font: "11px system-ui, sans-serif" };
|
|
34301
|
+
const tableHeaderStyle = { padding: "0 3px 4px", textAlign: "left", verticalAlign: "bottom", color: T.muted, font: "600 11px system-ui, sans-serif" };
|
|
34302
|
+
const tableCellStyle = { padding: 3, verticalAlign: "bottom" };
|
|
34254
34303
|
const toggle = () => {
|
|
34255
34304
|
if (open) {
|
|
34256
34305
|
setOpen(false);
|
|
34257
34306
|
return;
|
|
34258
34307
|
}
|
|
34259
34308
|
const selected = api?.getSelectedChart();
|
|
34309
|
+
const nextCategories = selected?.categories.length ? [...selected.categories] : ["", ""];
|
|
34310
|
+
const nextSeries = selected?.series.length ? selected.series.map((entry) => ({
|
|
34311
|
+
name: entry.name,
|
|
34312
|
+
values: nextCategories.map((_, index) => String(entry.values[index] ?? ""))
|
|
34313
|
+
})) : [{ name: "", values: nextCategories.map(() => "") }];
|
|
34314
|
+
setEditing(!!selected);
|
|
34260
34315
|
setType(selected?.type ?? "column");
|
|
34261
34316
|
setTitle(selected?.title ?? "");
|
|
34262
|
-
setCategories(
|
|
34263
|
-
setSeries(selected ?
|
|
34317
|
+
setCategories(nextCategories);
|
|
34318
|
+
setSeries(selected?.type === "pie" ? nextSeries.slice(0, 1) : nextSeries);
|
|
34264
34319
|
setError("");
|
|
34265
34320
|
setOpen(true);
|
|
34266
34321
|
};
|
|
34322
|
+
const chartTypes = [
|
|
34323
|
+
{ value: "column", label: "Column" },
|
|
34324
|
+
{ value: "bar", label: "Bar" },
|
|
34325
|
+
{ value: "line", label: "Line" },
|
|
34326
|
+
{ value: "pie", label: "Pie" }
|
|
34327
|
+
];
|
|
34267
34328
|
return /* @__PURE__ */ jsxs2("span", { ref: rootRef, style: { position: "relative", display: "inline-block" }, children: [
|
|
34268
34329
|
/* @__PURE__ */ jsx2("button", { title: "Insert or edit chart", style: btnStyle(open), onMouseDown: (event) => event.preventDefault(), onClick: toggle, children: label }),
|
|
34269
34330
|
open && /* @__PURE__ */ jsxs2("div", { style: { position: "fixed", top: anchor?.bottom ?? 28, left: popoverLeft, zIndex: 100, width: popoverWidth, maxHeight: "calc(100vh - 48px)", overflow: "auto", boxSizing: "border-box", padding: 10, display: "grid", gap: 8, background: T.popoverBg, border: `1px solid ${T.border}`, borderRadius: 8, boxShadow: T.popoverShadow }, children: [
|
|
34270
|
-
/* @__PURE__ */ jsx2(
|
|
34271
|
-
|
|
34272
|
-
{
|
|
34273
|
-
|
|
34274
|
-
|
|
34275
|
-
|
|
34276
|
-
|
|
34277
|
-
|
|
34278
|
-
|
|
34279
|
-
|
|
34280
|
-
|
|
34281
|
-
|
|
34282
|
-
|
|
34283
|
-
|
|
34284
|
-
|
|
34285
|
-
|
|
34286
|
-
|
|
34287
|
-
|
|
34331
|
+
/* @__PURE__ */ jsx2("strong", { style: { color: T.fg, font: "600 13px system-ui, sans-serif" }, children: editing ? "Edit chart" : "Insert chart" }),
|
|
34332
|
+
/* @__PURE__ */ jsxs2("fieldset", { style: { minWidth: 0, margin: 0, padding: 0, border: 0 }, children: [
|
|
34333
|
+
/* @__PURE__ */ jsx2("legend", { style: { marginBottom: 4, color: T.muted, font: "11px system-ui, sans-serif" }, children: "Chart type" }),
|
|
34334
|
+
/* @__PURE__ */ jsx2("div", { role: "radiogroup", "aria-label": "Chart type", style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 5 }, children: chartTypes.map((chartType) => {
|
|
34335
|
+
const selected = chartType.value === type;
|
|
34336
|
+
return /* @__PURE__ */ jsx2(
|
|
34337
|
+
"button",
|
|
34338
|
+
{
|
|
34339
|
+
type: "button",
|
|
34340
|
+
role: "radio",
|
|
34341
|
+
"aria-checked": selected,
|
|
34342
|
+
onClick: () => changeType(chartType.value),
|
|
34343
|
+
style: {
|
|
34344
|
+
minHeight: 34,
|
|
34345
|
+
border: `1px solid ${selected ? T.accent : T.border}`,
|
|
34346
|
+
borderRadius: 6,
|
|
34347
|
+
background: selected ? T.tabActiveBg : T.popoverBg,
|
|
34348
|
+
color: selected ? T.accent : T.fg,
|
|
34349
|
+
cursor: "pointer",
|
|
34350
|
+
font: "600 12px system-ui, sans-serif"
|
|
34351
|
+
},
|
|
34352
|
+
children: chartType.label
|
|
34353
|
+
},
|
|
34354
|
+
chartType.value
|
|
34355
|
+
);
|
|
34356
|
+
}) })
|
|
34357
|
+
] }),
|
|
34358
|
+
/* @__PURE__ */ jsxs2("label", { style: fieldLabelStyle, children: [
|
|
34359
|
+
/* @__PURE__ */ jsx2("span", { children: "Chart title (optional)" }),
|
|
34360
|
+
/* @__PURE__ */ jsx2("input", { "aria-label": "Chart title", value: title, onChange: (event) => setTitle(event.target.value), style: fieldStyle })
|
|
34361
|
+
] }),
|
|
34288
34362
|
/* @__PURE__ */ jsxs2("div", { role: "group", "aria-label": "Chart data", style: { display: "grid", gap: 7 }, children: [
|
|
34289
|
-
/* @__PURE__ */ jsx2("strong", { style: { color: T.fg, font: "600 11.5px system-ui, sans-serif" }, children: "
|
|
34290
|
-
/* @__PURE__ */ jsx2("div", { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs2("
|
|
34291
|
-
/* @__PURE__ */ jsx2("
|
|
34292
|
-
|
|
34293
|
-
/* @__PURE__ */ jsx2(
|
|
34294
|
-
|
|
34295
|
-
|
|
34296
|
-
|
|
34297
|
-
|
|
34298
|
-
|
|
34299
|
-
|
|
34300
|
-
|
|
34301
|
-
}
|
|
34302
|
-
|
|
34303
|
-
|
|
34304
|
-
|
|
34305
|
-
|
|
34306
|
-
|
|
34307
|
-
|
|
34363
|
+
/* @__PURE__ */ jsx2("strong", { style: { color: T.fg, font: "600 11.5px system-ui, sans-serif" }, children: type === "pie" ? "Slices" : "Chart data" }),
|
|
34364
|
+
/* @__PURE__ */ jsx2("div", { style: { overflowX: "auto" }, children: type === "pie" ? /* @__PURE__ */ jsxs2("table", { "aria-label": "Pie chart data", style: { width: "100%", borderCollapse: "collapse" }, children: [
|
|
34365
|
+
/* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsxs2("tr", { children: [
|
|
34366
|
+
/* @__PURE__ */ jsx2("th", { scope: "col", style: tableHeaderStyle, children: "Slice label" }),
|
|
34367
|
+
/* @__PURE__ */ jsx2("th", { scope: "col", style: tableHeaderStyle, children: "Value" }),
|
|
34368
|
+
/* @__PURE__ */ jsx2("th", { scope: "col", "aria-label": "Actions" })
|
|
34369
|
+
] }) }),
|
|
34370
|
+
/* @__PURE__ */ jsx2("tbody", { children: categories.map((category, index) => /* @__PURE__ */ jsxs2("tr", { children: [
|
|
34371
|
+
/* @__PURE__ */ jsx2("th", { scope: "row", style: { ...tableCellStyle, width: "52%", fontWeight: 400 }, children: /* @__PURE__ */ jsxs2("label", { style: fieldLabelStyle, children: [
|
|
34372
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
34373
|
+
"Slice ",
|
|
34374
|
+
index + 1
|
|
34375
|
+
] }),
|
|
34376
|
+
/* @__PURE__ */ jsx2(
|
|
34377
|
+
"input",
|
|
34378
|
+
{
|
|
34379
|
+
"aria-label": `Chart slice ${index + 1} label`,
|
|
34380
|
+
value: category,
|
|
34381
|
+
onChange: (event) => setCategories(categories.map((value, itemIndex) => itemIndex === index ? event.target.value : value)),
|
|
34382
|
+
style: fieldStyle
|
|
34383
|
+
}
|
|
34384
|
+
)
|
|
34385
|
+
] }) }),
|
|
34386
|
+
/* @__PURE__ */ jsx2("td", { style: tableCellStyle, children: /* @__PURE__ */ jsx2(
|
|
34308
34387
|
"input",
|
|
34309
34388
|
{
|
|
34310
|
-
"aria-label": `Chart
|
|
34311
|
-
|
|
34312
|
-
|
|
34313
|
-
|
|
34389
|
+
"aria-label": `Chart slice ${index + 1} value`,
|
|
34390
|
+
type: "number",
|
|
34391
|
+
min: "0",
|
|
34392
|
+
step: "any",
|
|
34393
|
+
value: series[0]?.values[index] ?? "",
|
|
34394
|
+
onChange: (event) => setSeries([{
|
|
34395
|
+
...series[0] ?? { name: "Values", values: categories.map(() => "") },
|
|
34396
|
+
values: categories.map((_, itemIndex) => itemIndex === index ? event.target.value : series[0]?.values[itemIndex] ?? "")
|
|
34397
|
+
}]),
|
|
34314
34398
|
style: fieldStyle
|
|
34315
34399
|
}
|
|
34316
|
-
),
|
|
34317
|
-
|
|
34400
|
+
) }),
|
|
34401
|
+
/* @__PURE__ */ jsx2("td", { style: tableCellStyle, children: categories.length > 1 && /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": `Remove chart slice ${index + 1}`, onClick: () => removeCategory(index), style: { ...pillBtn, padding: "0 7px" }, children: "Remove" }) })
|
|
34402
|
+
] }, index)) })
|
|
34403
|
+
] }) : /* @__PURE__ */ jsxs2("table", { "aria-label": `${type} chart data`, style: { minWidth: series.length > 2 ? 430 : void 0, width: "100%", borderCollapse: "collapse" }, children: [
|
|
34404
|
+
/* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsxs2("tr", { children: [
|
|
34405
|
+
/* @__PURE__ */ jsx2("th", { scope: "col", style: tableHeaderStyle, children: "Category" }),
|
|
34406
|
+
series.map((entry, seriesIndex) => /* @__PURE__ */ jsxs2("th", { scope: "col", style: tableHeaderStyle, children: [
|
|
34407
|
+
/* @__PURE__ */ jsxs2("label", { style: fieldLabelStyle, children: [
|
|
34408
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
34409
|
+
"Series ",
|
|
34410
|
+
seriesIndex + 1,
|
|
34411
|
+
" name"
|
|
34412
|
+
] }),
|
|
34413
|
+
/* @__PURE__ */ jsx2(
|
|
34414
|
+
"input",
|
|
34415
|
+
{
|
|
34416
|
+
"aria-label": `Chart series ${seriesIndex + 1} name`,
|
|
34417
|
+
value: entry.name,
|
|
34418
|
+
onChange: (event) => setSeries(series.map((value, itemIndex) => itemIndex === seriesIndex ? { ...value, name: event.target.value } : value)),
|
|
34419
|
+
style: fieldStyle
|
|
34420
|
+
}
|
|
34421
|
+
)
|
|
34422
|
+
] }),
|
|
34423
|
+
series.length > 1 && /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": `Remove chart series ${seriesIndex + 1}`, onClick: () => setSeries(series.filter((_, itemIndex) => itemIndex !== seriesIndex)), style: { ...pillBtn, marginTop: 3, padding: "0 7px" }, children: "Remove" })
|
|
34424
|
+
] }, seriesIndex)),
|
|
34425
|
+
/* @__PURE__ */ jsx2("th", { scope: "col", "aria-label": "Actions" })
|
|
34426
|
+
] }) }),
|
|
34427
|
+
/* @__PURE__ */ jsx2("tbody", { children: categories.map((category, categoryIndex) => /* @__PURE__ */ jsxs2("tr", { children: [
|
|
34428
|
+
/* @__PURE__ */ jsx2("th", { scope: "row", style: { ...tableCellStyle, minWidth: 120, fontWeight: 400 }, children: /* @__PURE__ */ jsxs2("label", { style: fieldLabelStyle, children: [
|
|
34429
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
34430
|
+
"Category ",
|
|
34431
|
+
categoryIndex + 1
|
|
34432
|
+
] }),
|
|
34433
|
+
/* @__PURE__ */ jsx2(
|
|
34434
|
+
"input",
|
|
34435
|
+
{
|
|
34436
|
+
"aria-label": `Chart category ${categoryIndex + 1}`,
|
|
34437
|
+
value: category,
|
|
34438
|
+
onChange: (event) => setCategories(categories.map((value, itemIndex) => itemIndex === categoryIndex ? event.target.value : value)),
|
|
34439
|
+
style: fieldStyle
|
|
34440
|
+
}
|
|
34441
|
+
)
|
|
34442
|
+
] }) }),
|
|
34443
|
+
series.map((entry, seriesIndex) => /* @__PURE__ */ jsx2("td", { style: { ...tableCellStyle, minWidth: 82 }, children: /* @__PURE__ */ jsx2(
|
|
34318
34444
|
"input",
|
|
34319
34445
|
{
|
|
34320
|
-
"aria-label": `Chart series ${seriesIndex + 1} value ${
|
|
34446
|
+
"aria-label": `Chart series ${seriesIndex + 1} value ${categoryIndex + 1}`,
|
|
34321
34447
|
type: "number",
|
|
34322
34448
|
step: "any",
|
|
34323
|
-
value,
|
|
34324
|
-
|
|
34325
|
-
|
|
34449
|
+
value: entry.values[categoryIndex] ?? "",
|
|
34450
|
+
onChange: (event) => setSeries(series.map((seriesValue, itemIndex) => itemIndex === seriesIndex ? {
|
|
34451
|
+
...seriesValue,
|
|
34452
|
+
values: categories.map((_, itemValueIndex) => itemValueIndex === categoryIndex ? event.target.value : seriesValue.values[itemValueIndex] ?? "")
|
|
34453
|
+
} : seriesValue)),
|
|
34326
34454
|
style: fieldStyle
|
|
34327
|
-
}
|
|
34328
|
-
|
|
34329
|
-
)),
|
|
34330
|
-
|
|
34331
|
-
] }, seriesIndex))
|
|
34455
|
+
}
|
|
34456
|
+
) }, seriesIndex)),
|
|
34457
|
+
/* @__PURE__ */ jsx2("td", { style: tableCellStyle, children: categories.length > 1 && /* @__PURE__ */ jsx2("button", { type: "button", "aria-label": `Remove chart category ${categoryIndex + 1}`, onClick: () => removeCategory(categoryIndex), style: { ...pillBtn, padding: "0 7px" }, children: "Remove" }) })
|
|
34458
|
+
] }, categoryIndex)) })
|
|
34332
34459
|
] }) }),
|
|
34333
34460
|
/* @__PURE__ */ jsxs2("div", { style: { display: "flex", gap: 6 }, children: [
|
|
34334
|
-
/* @__PURE__ */ jsx2("button", { type: "button", onClick: () => setSeries([...series, { name: "", values: categories.map(() => "") }]), style: { ...pillBtn, background: T.popoverBg, color: T.fg }, children: "Add series" }),
|
|
34335
|
-
/* @__PURE__ */ jsx2("button", { type: "button", onClick: addCategory, style: { ...pillBtn, background: T.popoverBg, color: T.fg }, children: "Add category" })
|
|
34461
|
+
type !== "pie" && /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => setSeries([...series, { name: "", values: categories.map(() => "") }]), style: { ...pillBtn, background: T.popoverBg, color: T.fg }, children: "Add series" }),
|
|
34462
|
+
/* @__PURE__ */ jsx2("button", { type: "button", onClick: addCategory, style: { ...pillBtn, background: T.popoverBg, color: T.fg }, children: type === "pie" ? "Add slice" : "Add category" })
|
|
34336
34463
|
] })
|
|
34337
34464
|
] }),
|
|
34338
34465
|
error && /* @__PURE__ */ jsx2("div", { role: "alert", style: { color: "#c5221f", font: "11.5px system-ui, sans-serif" }, children: error }),
|
|
34339
|
-
/* @__PURE__ */ jsx2("button", { onClick: submit, style: { border: 0, borderRadius: 6, padding: "7px 10px", background: T.accent, color: T.accentFg, cursor: "pointer", font: "600 12px system-ui, sans-serif" }, children: "
|
|
34466
|
+
/* @__PURE__ */ jsx2("button", { onClick: submit, style: { border: 0, borderRadius: 6, padding: "7px 10px", background: T.accent, color: T.accentFg, cursor: "pointer", font: "600 12px system-ui, sans-serif" }, children: editing ? "Update chart" : "Insert chart" })
|
|
34340
34467
|
] })
|
|
34341
34468
|
] });
|
|
34342
34469
|
}
|
|
@@ -35859,7 +35986,7 @@ function DocxToolbar({
|
|
|
35859
35986
|
result === "too-large" ? (() => {
|
|
35860
35987
|
const max = api?.imageMaxBytes() ?? null;
|
|
35861
35988
|
return max === null ? "That image is too large for this document." : `Images must be under ${formatBytes(max)}.`;
|
|
35862
|
-
})() : 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."
|
|
35863
35990
|
);
|
|
35864
35991
|
};
|
|
35865
35992
|
const rootRef = useRef2(null);
|
|
@@ -36735,6 +36862,8 @@ function DocxView({
|
|
|
36735
36862
|
const redrawPresenceRef = useRef3(null);
|
|
36736
36863
|
const presenceRef = useRef3(void 0);
|
|
36737
36864
|
presenceRef.current = collab?.presence;
|
|
36865
|
+
const collabRef = useRef3(collab);
|
|
36866
|
+
collabRef.current = collab;
|
|
36738
36867
|
useEffect3(() => {
|
|
36739
36868
|
redrawPresenceRef.current?.();
|
|
36740
36869
|
}, [collab?.presence]);
|
|
@@ -36901,14 +37030,15 @@ function DocxView({
|
|
|
36901
37030
|
};
|
|
36902
37031
|
const emitBlockIntents = (targets, make) => {
|
|
36903
37032
|
const d = docCacheRef.current?.doc;
|
|
36904
|
-
|
|
37033
|
+
const current = collabRef.current;
|
|
37034
|
+
if (!current || !d?.stableIds) return;
|
|
36905
37035
|
const seen = /* @__PURE__ */ new Set();
|
|
36906
37036
|
for (const t of targets) {
|
|
36907
37037
|
const p = paragraphOf(d, t);
|
|
36908
37038
|
const blockId = p ? d.stableIds.idOf(p) : void 0;
|
|
36909
37039
|
if (blockId !== void 0 && !seen.has(blockId)) {
|
|
36910
37040
|
seen.add(blockId);
|
|
36911
|
-
|
|
37041
|
+
current.submit(make(blockId));
|
|
36912
37042
|
}
|
|
36913
37043
|
}
|
|
36914
37044
|
};
|
|
@@ -36918,7 +37048,7 @@ function DocxView({
|
|
|
36918
37048
|
const presence = presenceRef.current;
|
|
36919
37049
|
if (!handle2 || !d || !presence) return;
|
|
36920
37050
|
drawPresenceSelections(handle2.root, computePresenceSelections(handle2, d, presence));
|
|
36921
|
-
drawPresenceCarets(handle2.root, computePresenceCarets(handle2, d, presence),
|
|
37051
|
+
drawPresenceCarets(handle2.root, computePresenceCarets(handle2, d, presence), collabRef.current?.participantNames);
|
|
36922
37052
|
};
|
|
36923
37053
|
redrawPresenceRef.current = drawCollabPresence;
|
|
36924
37054
|
const rerender = (doc, dirtyBlock, scope = "local", dirtySource) => {
|
|
@@ -37054,7 +37184,8 @@ function DocxView({
|
|
|
37054
37184
|
};
|
|
37055
37185
|
const flushPresence = () => {
|
|
37056
37186
|
presenceQueued = false;
|
|
37057
|
-
|
|
37187
|
+
const current = collabRef.current;
|
|
37188
|
+
if (!current?.setPresence) return;
|
|
37058
37189
|
const ranges = selectionRanges();
|
|
37059
37190
|
const last = ranges?.[ranges.length - 1];
|
|
37060
37191
|
const anchor = presenceCaret ?? (last ? { blockId: last.blockId, runId: last.runId, offset: last.end } : null);
|
|
@@ -37062,7 +37193,7 @@ function DocxView({
|
|
|
37062
37193
|
const key = pos ? JSON.stringify(pos) : "null";
|
|
37063
37194
|
if (key === presenceKey) return;
|
|
37064
37195
|
presenceKey = key;
|
|
37065
|
-
|
|
37196
|
+
current.setPresence(pos);
|
|
37066
37197
|
};
|
|
37067
37198
|
const queuePresence = () => {
|
|
37068
37199
|
if (presenceQueued) return;
|
|
@@ -37101,11 +37232,11 @@ function DocxView({
|
|
|
37101
37232
|
onStyleShortcut: (styleId) => applyStyleShortcut?.(styleId),
|
|
37102
37233
|
// Collaboration: forward each local edit as an intent. The editor
|
|
37103
37234
|
// emits only when doc.stableIds is populated, so enable it here.
|
|
37104
|
-
onIntent: collab ? (intent) =>
|
|
37235
|
+
onIntent: collab ? (intent) => collabRef.current?.submit(intent) : void 0,
|
|
37105
37236
|
// Cmd+Z in a room reverses the last SEQUENCED action over the wire;
|
|
37106
37237
|
// without this hook the editor declines rather than replaying local
|
|
37107
37238
|
// history (which would fork the room silently).
|
|
37108
|
-
onCollabUndo: collab?.undoLast,
|
|
37239
|
+
onCollabUndo: collab?.undoLast ? () => collabRef.current?.undoLast?.() : void 0,
|
|
37109
37240
|
// Presence: broadcast the local caret so remote participants can
|
|
37110
37241
|
// draw this user's cursor (the anchor mirrors the intent addressing).
|
|
37111
37242
|
// The caret is recorded here and sent by flushPresence together with
|
|
@@ -37116,7 +37247,7 @@ function DocxView({
|
|
|
37116
37247
|
} : void 0,
|
|
37117
37248
|
// Disjoint carried-id blocks for the editor's node-creating intents
|
|
37118
37249
|
// (paragraph split); see EditorHost.allocIds.
|
|
37119
|
-
allocIds: collab?.allocIds,
|
|
37250
|
+
allocIds: collab?.allocIds ? (n) => collabRef.current?.allocIds?.(n) ?? [] : void 0,
|
|
37120
37251
|
onTextCommand: (command) => {
|
|
37121
37252
|
const current = apiRef.current;
|
|
37122
37253
|
if (!current) return;
|
|
@@ -37221,27 +37352,30 @@ function DocxView({
|
|
|
37221
37352
|
};
|
|
37222
37353
|
const collabAnchor = (t, offset) => doc.stableIds ? doc.stableIds.encodeCaret(t, offset, (el16) => doc.findParentOf(el16) ?? null) : null;
|
|
37223
37354
|
const collabOp = (make, at) => {
|
|
37224
|
-
|
|
37355
|
+
const current = collabRef.current;
|
|
37356
|
+
if (!current?.submitOp || !doc.stableIds) return false;
|
|
37225
37357
|
const target = at !== void 0 ? at : insertionTarget();
|
|
37226
37358
|
if (!target) return true;
|
|
37227
37359
|
const anchor = collabAnchor(target.t, target.offset);
|
|
37228
37360
|
if (!anchor) return true;
|
|
37229
|
-
const intent = make(anchor, (n) =>
|
|
37361
|
+
const intent = make(anchor, (n) => current.allocIds?.(n) ?? []);
|
|
37230
37362
|
if (!intent) return true;
|
|
37231
37363
|
history.checkpoint();
|
|
37232
|
-
|
|
37364
|
+
current.submitOp(intent);
|
|
37233
37365
|
return true;
|
|
37234
37366
|
};
|
|
37235
37367
|
const collabDocOp = (make) => {
|
|
37236
|
-
|
|
37237
|
-
|
|
37368
|
+
const current = collabRef.current;
|
|
37369
|
+
if (!current?.submitOp || !doc.stableIds) return false;
|
|
37370
|
+
const intent = make((n) => current.allocIds?.(n) ?? []);
|
|
37238
37371
|
if (!intent) return true;
|
|
37239
37372
|
history.checkpoint();
|
|
37240
|
-
|
|
37373
|
+
current.submitOp(intent);
|
|
37241
37374
|
return true;
|
|
37242
37375
|
};
|
|
37243
37376
|
const collabBlockOp = (targets, make) => {
|
|
37244
|
-
|
|
37377
|
+
const current = collabRef.current;
|
|
37378
|
+
if (!current?.submitOp || !doc.stableIds) return false;
|
|
37245
37379
|
const submitted = /* @__PURE__ */ new Set();
|
|
37246
37380
|
let any = false;
|
|
37247
37381
|
for (const t of targets) {
|
|
@@ -37252,18 +37386,19 @@ function DocxView({
|
|
|
37252
37386
|
if (!intent) continue;
|
|
37253
37387
|
if (!any) history.checkpoint();
|
|
37254
37388
|
any = true;
|
|
37255
|
-
|
|
37389
|
+
current.submitOp(intent);
|
|
37256
37390
|
}
|
|
37257
37391
|
return true;
|
|
37258
37392
|
};
|
|
37259
|
-
const captureFormatIds = (segs) =>
|
|
37393
|
+
const captureFormatIds = (segs) => collabRef.current && doc.stableIds ? segs.map((seg) => ({
|
|
37260
37394
|
runId: seg.run.src ? doc.stableIds.idOf(seg.run.src) : void 0,
|
|
37261
37395
|
blockId: seg.run.srcParent ? doc.stableIds.idOf(seg.run.srcParent) : void 0,
|
|
37262
37396
|
runLen: seg.run.src ? runWireLength(seg.run.src) : 0,
|
|
37263
37397
|
cumStart: seg.run.src && seg.t ? wireOffsetOf(seg.run.src, seg.t, seg.start) ?? seg.start : seg.start
|
|
37264
37398
|
})) : [];
|
|
37265
37399
|
const emitFormatIntents = (segs, preIds, formatted, patch) => {
|
|
37266
|
-
|
|
37400
|
+
const current = collabRef.current;
|
|
37401
|
+
if (!current || !doc.stableIds) return;
|
|
37267
37402
|
const spanByRun = /* @__PURE__ */ new Map();
|
|
37268
37403
|
segs.forEach((seg, i) => {
|
|
37269
37404
|
const pre = preIds[i];
|
|
@@ -37286,18 +37421,18 @@ function DocxView({
|
|
|
37286
37421
|
const cumEnd = cumStart + (seg.end - seg.start);
|
|
37287
37422
|
const whole = !seg.t || span.lo <= 0 && span.hi >= runLen || (segCountByRun.get(runId) ?? 1) > 1;
|
|
37288
37423
|
if (whole) {
|
|
37289
|
-
|
|
37424
|
+
current.submit({ kind: "formatRun", blockId, runId, patch });
|
|
37290
37425
|
return;
|
|
37291
37426
|
}
|
|
37292
37427
|
const before = cumStart > 0;
|
|
37293
37428
|
const after = cumEnd < runLen;
|
|
37294
|
-
const alloc =
|
|
37429
|
+
const alloc = current.allocIds?.((before ? 1 : 0) + 1 + (after ? 1 : 0)) ?? [];
|
|
37295
37430
|
let k = 0;
|
|
37296
37431
|
const beforeId = before ? alloc[k++] : void 0;
|
|
37297
37432
|
const middleId = alloc[k++];
|
|
37298
37433
|
const afterId = after ? alloc[k++] : void 0;
|
|
37299
37434
|
if (middleId === void 0) return;
|
|
37300
|
-
|
|
37435
|
+
current.submit({ kind: "formatRange", blockId, runId, start: cumStart, end: cumEnd, patch, beforeId, middleId, afterId });
|
|
37301
37436
|
const middleT = formatted[i]?.t;
|
|
37302
37437
|
const middleRun = middleT ? doc.findParentOf(middleT) : null;
|
|
37303
37438
|
const parent = middleRun ? doc.findParentOf(middleRun) : null;
|
|
@@ -37451,7 +37586,7 @@ function DocxView({
|
|
|
37451
37586
|
return true;
|
|
37452
37587
|
},
|
|
37453
37588
|
updateSelectedChart: (data) => {
|
|
37454
|
-
if (
|
|
37589
|
+
if (collabRef.current?.submitOp) return false;
|
|
37455
37590
|
const source2 = editor?.getSelectedDrawingSource();
|
|
37456
37591
|
if (!source2) return false;
|
|
37457
37592
|
history.checkpoint();
|
|
@@ -37471,7 +37606,7 @@ function DocxView({
|
|
|
37471
37606
|
return true;
|
|
37472
37607
|
},
|
|
37473
37608
|
updateSelectedSmartArt: (data) => {
|
|
37474
|
-
if (
|
|
37609
|
+
if (collabRef.current?.submitOp) return false;
|
|
37475
37610
|
const source2 = editor?.getSelectedDrawingSource();
|
|
37476
37611
|
if (!source2) return false;
|
|
37477
37612
|
history.checkpoint();
|
|
@@ -37482,7 +37617,7 @@ function DocxView({
|
|
|
37482
37617
|
},
|
|
37483
37618
|
getSelectedSmartArt: () => editor?.getSelectedSmartArtData() ?? null,
|
|
37484
37619
|
insertModel3D: async (file, poster) => {
|
|
37485
|
-
if (
|
|
37620
|
+
if (collabRef.current?.submitOp) return false;
|
|
37486
37621
|
const target = insertionTarget();
|
|
37487
37622
|
if (!target) return false;
|
|
37488
37623
|
const preview = poster ?? await objectPoster("3D model", "Double-click in Word to explore", "\u25C7");
|
|
@@ -37494,7 +37629,7 @@ function DocxView({
|
|
|
37494
37629
|
return true;
|
|
37495
37630
|
},
|
|
37496
37631
|
insertOnlineVideo: async (url) => {
|
|
37497
|
-
if (
|
|
37632
|
+
if (collabRef.current?.submitOp) return false;
|
|
37498
37633
|
const target = insertionTarget();
|
|
37499
37634
|
if (!target) return false;
|
|
37500
37635
|
const preview = await objectPoster("Online video", url, "\u25B6");
|
|
@@ -37505,7 +37640,7 @@ function DocxView({
|
|
|
37505
37640
|
return true;
|
|
37506
37641
|
},
|
|
37507
37642
|
insertEmbeddedObject: async (file, filename) => {
|
|
37508
|
-
if (
|
|
37643
|
+
if (collabRef.current?.submitOp) return false;
|
|
37509
37644
|
const target = insertionTarget();
|
|
37510
37645
|
if (!target) return false;
|
|
37511
37646
|
const name = filename ?? (file instanceof File ? file.name : "embedded-file.bin");
|
|
@@ -37526,7 +37661,7 @@ function DocxView({
|
|
|
37526
37661
|
getSelectedSmartArtTextFormat: () => editor?.getSelectedSmartArtTextFormat() ?? null,
|
|
37527
37662
|
setSelectedSmartArtTextFormat: (patch) => editor?.setSelectedSmartArtTextFormat(patch) ?? false,
|
|
37528
37663
|
addComment: (text) => {
|
|
37529
|
-
if (
|
|
37664
|
+
if (collabRef.current?.submitOp) return false;
|
|
37530
37665
|
const segs = editor?.getSelectionSegments() ?? [];
|
|
37531
37666
|
const segments = segs.length > 0 ? segs : handle ? selectionToSegments(handle.bindings) : [];
|
|
37532
37667
|
if (segments.length === 0) return false;
|
|
@@ -37568,12 +37703,12 @@ function DocxView({
|
|
|
37568
37703
|
const caret = editor?.getCaretTarget();
|
|
37569
37704
|
return caret ? cellShadingAt(doc, caret.t) : void 0;
|
|
37570
37705
|
},
|
|
37571
|
-
imageAccept: () =>
|
|
37572
|
-
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,
|
|
37573
37708
|
insertImage: async (file) => {
|
|
37574
37709
|
const caret = insertionTarget() ?? documentStart();
|
|
37575
37710
|
if (!caret) return "no-caret";
|
|
37576
|
-
const maxBytes =
|
|
37711
|
+
const maxBytes = collabRef.current?.submitOp && doc.stableIds ? collabRef.current.mediaMaxBlobBytes ?? null : null;
|
|
37577
37712
|
if (typeof maxBytes === "number" && file.size > maxBytes) return "too-large";
|
|
37578
37713
|
const bytes2 = new Uint8Array(await file.arrayBuffer());
|
|
37579
37714
|
const isSvg = file.type === "image/svg+xml";
|
|
@@ -37586,11 +37721,12 @@ function DocxView({
|
|
|
37586
37721
|
const maxW = sp ? sp.pageWidth - sp.marginLeft - sp.marginRight : 624;
|
|
37587
37722
|
const scale = Math.min(1, maxW / naturalWidth);
|
|
37588
37723
|
const ext = file.type === "image/svg+xml" ? "svg" : (file.type.split("/")[1] ?? "png").replace("jpeg", "jpg");
|
|
37589
|
-
|
|
37724
|
+
const current = collabRef.current;
|
|
37725
|
+
if (current?.submitOp && doc.stableIds) {
|
|
37590
37726
|
bmp?.close();
|
|
37591
|
-
if (!
|
|
37727
|
+
if (!current.uploadMedia) return "no-relay";
|
|
37592
37728
|
if (!COLLAB_IMAGE_EXTS.includes(ext)) return "unsupported-format";
|
|
37593
|
-
const media = await
|
|
37729
|
+
const media = await current.uploadMedia(bytes2);
|
|
37594
37730
|
if (!media) return "upload-failed";
|
|
37595
37731
|
const w = naturalWidth * scale;
|
|
37596
37732
|
const h2 = naturalHeight * scale;
|
|
@@ -38171,6 +38307,7 @@ export {
|
|
|
38171
38307
|
acceptRevision,
|
|
38172
38308
|
rejectRevision,
|
|
38173
38309
|
acceptAllRevisions,
|
|
38310
|
+
rejectAllRevisions,
|
|
38174
38311
|
applyInsertText,
|
|
38175
38312
|
applyDeleteRange,
|
|
38176
38313
|
applySplitParagraph,
|
|
@@ -38205,4 +38342,4 @@ export {
|
|
|
38205
38342
|
cfb/cfb.js:
|
|
38206
38343
|
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
|
38207
38344
|
*/
|
|
38208
|
-
//# sourceMappingURL=chunk-
|
|
38345
|
+
//# sourceMappingURL=chunk-OIN65MGS.js.map
|