@stll/folio-react 0.31.1 → 0.32.0

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.
@@ -53,6 +53,7 @@ import { closestHtmlElement, htmlQueryAll, queryHtmlElement } from "@stll/folio-
53
53
  import { onFontsLoaded } from "@stll/folio-core/utils/fontLoader";
54
54
  import { collectHeadings } from "@stll/folio-core/utils/headingCollector";
55
55
  import { DEFAULT_OUTLINE_DEPTH, filterHeadingsByDepth } from "@stll/folio-core/utils/outlineDepth";
56
+ import { resolveOutlineHeadings } from "@stll/folio-core/utils/outlineHeadings";
56
57
  import { readBlobText } from "@stll/folio-core/utils/textEncoding";
57
58
  import { formatPx, pixelsToTwips, pointsToHalfPoints, twipsToPixels as twipsToPixels$1 } from "@stll/folio-core/utils/units";
58
59
  import { HistoryManager, classifyHistoryShortcut } from "@stll/folio-core/managers/HistoryManager";
@@ -6354,7 +6355,6 @@ function createComment(text, authorName, parentId, id) {
6354
6355
  date: (/* @__PURE__ */ new Date()).toISOString(),
6355
6356
  content: [{
6356
6357
  type: "paragraph",
6357
- formatting: {},
6358
6358
  content: [{
6359
6359
  type: "run",
6360
6360
  formatting: {},
@@ -6935,95 +6935,6 @@ function openDialogState(mode) {
6935
6935
  };
6936
6936
  }
6937
6937
  //#endregion
6938
- //#region src/components/hooks/useActiveHeading.ts
6939
- /**
6940
- * The heading the reader is in: the last heading whose paragraph starts above
6941
- * the middle of the scroll viewport, tracked as the document scrolls. Shared
6942
- * by every place the outline is drawn (column, rail, drawer), so a drawer
6943
- * opens on the same heading the rail marks.
6944
- */
6945
- /** How long a jump holds the active heading before scrolling may move it. */
6946
- const MANUAL_ACTIVE_LOCK_MS = 900;
6947
- /** Outline item id for a heading: its ProseMirror position. */
6948
- const headingId = (heading) => String(heading.pmPos);
6949
- const useActiveHeading = (container, headings) => {
6950
- const $ = c(7);
6951
- const [activeId, setActiveId] = useState(null);
6952
- const manualLockUntil = useRef(0);
6953
- let t0;
6954
- let t1;
6955
- if ($[0] !== container || $[1] !== headings) {
6956
- t0 = () => {
6957
- if (!container || headings.length === 0) return;
6958
- const compute = () => {
6959
- if (Date.now() < manualLockUntil.current) return;
6960
- const anchors = findBodyPmAnchors(container);
6961
- if (anchors.length === 0) return;
6962
- const containerTop = container.getBoundingClientRect().top;
6963
- const threshold = container.scrollTop + container.clientHeight / 2;
6964
- const offsets = [];
6965
- for (const el of anchors) {
6966
- const pm = Number(el.dataset.pmStart);
6967
- if (!Number.isFinite(pm)) continue;
6968
- offsets.push({
6969
- pm,
6970
- top: el.getBoundingClientRect().top - containerTop + container.scrollTop
6971
- });
6972
- }
6973
- offsets.sort(_temp$11);
6974
- let next = null;
6975
- for (const heading of headings) {
6976
- const candidate = offsets.find((offset) => offset.pm >= heading.pmPos);
6977
- if (candidate && candidate.top <= threshold) next = headingId(heading);
6978
- }
6979
- setActiveId(next);
6980
- };
6981
- let raf = 0;
6982
- const onScroll = () => {
6983
- cancelAnimationFrame(raf);
6984
- raf = requestAnimationFrame(compute);
6985
- };
6986
- container.addEventListener("scroll", onScroll, { passive: true });
6987
- raf = requestAnimationFrame(compute);
6988
- return () => {
6989
- cancelAnimationFrame(raf);
6990
- container.removeEventListener("scroll", onScroll);
6991
- };
6992
- };
6993
- t1 = [container, headings];
6994
- $[0] = container;
6995
- $[1] = headings;
6996
- $[2] = t0;
6997
- $[3] = t1;
6998
- } else {
6999
- t0 = $[2];
7000
- t1 = $[3];
7001
- }
7002
- useEffect(t0, t1);
7003
- let t2;
7004
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
7005
- t2 = (id) => {
7006
- setActiveId(id);
7007
- manualLockUntil.current = Date.now() + MANUAL_ACTIVE_LOCK_MS;
7008
- };
7009
- $[4] = t2;
7010
- } else t2 = $[4];
7011
- const markJumped = t2;
7012
- let t3;
7013
- if ($[5] !== activeId) {
7014
- t3 = {
7015
- activeId,
7016
- markJumped
7017
- };
7018
- $[5] = activeId;
7019
- $[6] = t3;
7020
- } else t3 = $[6];
7021
- return t3;
7022
- };
7023
- function _temp$11(a, b) {
7024
- return a.pm - b.pm;
7025
- }
7026
- //#endregion
7027
6938
  //#region src/components/panelDrawer.tsx
7028
6939
  /**
7029
6940
  * The shared behaviour of a panel opened as a drawer over the page: a scrim
@@ -7125,7 +7036,7 @@ const SURFACE_WIDTH = {
7125
7036
  expanded: PANEL_METRICS.outlineColumnWidth
7126
7037
  };
7127
7038
  const DocumentOutline = (t0) => {
7128
- const $ = c(92);
7039
+ const $ = c(93);
7129
7040
  const { headings, available, outlineDepth, onOutlineDepthChange, scrollContainerRef, docSize, activeId, onJump, surface, expanded, onExpand, onClose, width: widthOverride } = t0;
7130
7041
  const t = useTranslations("folio");
7131
7042
  const OutlineRail = useFolioUI().OutlineRail;
@@ -7160,7 +7071,7 @@ const DocumentOutline = (t0) => {
7160
7071
  const controlMinimumStyle = t4;
7161
7072
  let t5;
7162
7073
  if ($[4] !== headings) {
7163
- t5 = headings.map(_temp$10);
7074
+ t5 = headings.map(_temp$11);
7164
7075
  $[4] = headings;
7165
7076
  $[5] = t5;
7166
7077
  } else t5 = $[5];
@@ -7168,43 +7079,46 @@ const DocumentOutline = (t0) => {
7168
7079
  let map;
7169
7080
  if ($[6] !== docSize || $[7] !== headings) {
7170
7081
  map = /* @__PURE__ */ new Map();
7171
- if (docSize > 0) for (const heading_0 of headings) map.set(headingId(heading_0), Math.min(99, Math.max(1, heading_0.pmPos / docSize * 100)));
7082
+ if (docSize > 0) for (const heading_0 of headings) map.set(heading_0.id, Math.min(99, Math.max(1, heading_0.pmPos / docSize * 100)));
7172
7083
  $[6] = docSize;
7173
7084
  $[7] = headings;
7174
7085
  $[8] = map;
7175
7086
  } else map = $[8];
7176
7087
  const pctById = map;
7177
7088
  let t6;
7178
- if ($[9] !== onClose || $[10] !== onJump || $[11] !== surface) {
7089
+ if ($[9] !== headings || $[10] !== onClose || $[11] !== onJump || $[12] !== surface) {
7179
7090
  t6 = (id) => {
7180
- onJump(id);
7091
+ const heading_1 = headings.find((candidate) => candidate.id === id);
7092
+ if (!heading_1) return;
7093
+ onJump(heading_1);
7181
7094
  if (surface === "expanded") onClose?.();
7182
7095
  };
7183
- $[9] = onClose;
7184
- $[10] = onJump;
7185
- $[11] = surface;
7186
- $[12] = t6;
7187
- } else t6 = $[12];
7096
+ $[9] = headings;
7097
+ $[10] = onClose;
7098
+ $[11] = onJump;
7099
+ $[12] = surface;
7100
+ $[13] = t6;
7101
+ } else t6 = $[13];
7188
7102
  const handleJump = t6;
7189
7103
  let t7;
7190
- if ($[13] !== pctById) {
7104
+ if ($[14] !== pctById) {
7191
7105
  t7 = (id_0) => pctById.get(id_0) ?? null;
7192
- $[13] = pctById;
7193
- $[14] = t7;
7194
- } else t7 = $[14];
7106
+ $[14] = pctById;
7107
+ $[15] = t7;
7108
+ } else t7 = $[15];
7195
7109
  const resolvePct = t7;
7196
7110
  if (!available) return null;
7197
7111
  let t8;
7198
- if ($[15] !== t) {
7112
+ if ($[16] !== t) {
7199
7113
  t8 = t("editor.showDocumentOutline");
7200
- $[15] = t;
7201
- $[16] = t8;
7202
- } else t8 = $[16];
7114
+ $[16] = t;
7115
+ $[17] = t8;
7116
+ } else t8 = $[17];
7203
7117
  const outlineLabel = t8;
7204
7118
  const width = widthOverride ?? SURFACE_WIDTH[surface];
7205
7119
  const t9 = surface === "rail" ? "rail" : "panel";
7206
7120
  let t10;
7207
- if ($[17] !== OutlineRail || $[18] !== activeId || $[19] !== handleJump || $[20] !== items || $[21] !== outlineLabel || $[22] !== resolvePct || $[23] !== scrollContainerRef || $[24] !== t9 || $[25] !== width) {
7121
+ if ($[18] !== OutlineRail || $[19] !== activeId || $[20] !== handleJump || $[21] !== items || $[22] !== outlineLabel || $[23] !== resolvePct || $[24] !== scrollContainerRef || $[25] !== t9 || $[26] !== width) {
7208
7122
  t10 = /* @__PURE__ */ jsx(OutlineRail, {
7209
7123
  activeId,
7210
7124
  ariaLabel: outlineLabel,
@@ -7216,36 +7130,36 @@ const DocumentOutline = (t0) => {
7216
7130
  scrollContainerRef,
7217
7131
  topOffset: 0
7218
7132
  });
7219
- $[17] = OutlineRail;
7220
- $[18] = activeId;
7221
- $[19] = handleJump;
7222
- $[20] = items;
7223
- $[21] = outlineLabel;
7224
- $[22] = resolvePct;
7225
- $[23] = scrollContainerRef;
7226
- $[24] = t9;
7227
- $[25] = width;
7228
- $[26] = t10;
7229
- } else t10 = $[26];
7133
+ $[18] = OutlineRail;
7134
+ $[19] = activeId;
7135
+ $[20] = handleJump;
7136
+ $[21] = items;
7137
+ $[22] = outlineLabel;
7138
+ $[23] = resolvePct;
7139
+ $[24] = scrollContainerRef;
7140
+ $[25] = t9;
7141
+ $[26] = width;
7142
+ $[27] = t10;
7143
+ } else t10 = $[27];
7230
7144
  const rail = t10;
7231
7145
  if (surface === "rail") {
7232
7146
  let t11;
7233
- if ($[27] !== width) {
7147
+ if ($[28] !== width) {
7234
7148
  t11 = { width };
7235
- $[27] = width;
7236
- $[28] = t11;
7237
- } else t11 = $[28];
7149
+ $[28] = width;
7150
+ $[29] = t11;
7151
+ } else t11 = $[29];
7238
7152
  const t12 = expanded ?? false;
7239
7153
  let t13;
7240
- if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
7154
+ if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
7241
7155
  t13 = /* @__PURE__ */ jsx(PanelLeftOpenIcon, {
7242
7156
  "aria-hidden": "true",
7243
7157
  size: 16
7244
7158
  });
7245
- $[29] = t13;
7246
- } else t13 = $[29];
7159
+ $[30] = t13;
7160
+ } else t13 = $[30];
7247
7161
  let t14;
7248
- if ($[30] !== onExpand || $[31] !== outlineLabel || $[32] !== t12) {
7162
+ if ($[31] !== onExpand || $[32] !== outlineLabel || $[33] !== t12) {
7249
7163
  t14 = /* @__PURE__ */ jsx("button", {
7250
7164
  ref: expandButtonRef,
7251
7165
  "aria-expanded": t12,
@@ -7258,13 +7172,13 @@ const DocumentOutline = (t0) => {
7258
7172
  type: "button",
7259
7173
  children: t13
7260
7174
  });
7261
- $[30] = onExpand;
7262
- $[31] = outlineLabel;
7263
- $[32] = t12;
7264
- $[33] = t14;
7265
- } else t14 = $[33];
7175
+ $[31] = onExpand;
7176
+ $[32] = outlineLabel;
7177
+ $[33] = t12;
7178
+ $[34] = t14;
7179
+ } else t14 = $[34];
7266
7180
  let t15;
7267
- if ($[34] !== outlineLabel || $[35] !== rail || $[36] !== t11 || $[37] !== t14) {
7181
+ if ($[35] !== outlineLabel || $[36] !== rail || $[37] !== t11 || $[38] !== t14) {
7268
7182
  t15 = /* @__PURE__ */ jsxs("nav", {
7269
7183
  "aria-label": outlineLabel,
7270
7184
  className: "folio-outline folio-outline--rail",
@@ -7273,38 +7187,38 @@ const DocumentOutline = (t0) => {
7273
7187
  style: t11,
7274
7188
  children: [t14, rail]
7275
7189
  });
7276
- $[34] = outlineLabel;
7277
- $[35] = rail;
7278
- $[36] = t11;
7279
- $[37] = t14;
7280
- $[38] = t15;
7281
- } else t15 = $[38];
7190
+ $[35] = outlineLabel;
7191
+ $[36] = rail;
7192
+ $[37] = t11;
7193
+ $[38] = t14;
7194
+ $[39] = t15;
7195
+ } else t15 = $[39];
7282
7196
  return t15;
7283
7197
  }
7284
7198
  const t11 = `folio-outline folio-outline--${surface === "expanded" ? "column" : surface}`;
7285
7199
  let t12;
7286
- if ($[39] !== width) {
7200
+ if ($[40] !== width) {
7287
7201
  t12 = { width };
7288
- $[39] = width;
7289
- $[40] = t12;
7290
- } else t12 = $[40];
7202
+ $[40] = width;
7203
+ $[41] = t12;
7204
+ } else t12 = $[41];
7291
7205
  let t13;
7292
- if ($[41] !== t) {
7206
+ if ($[42] !== t) {
7293
7207
  t13 = t("editor.outlineTitle");
7294
- $[41] = t;
7295
- $[42] = t13;
7296
- } else t13 = $[42];
7208
+ $[42] = t;
7209
+ $[43] = t13;
7210
+ } else t13 = $[43];
7297
7211
  let t14;
7298
- if ($[43] !== t13) {
7212
+ if ($[44] !== t13) {
7299
7213
  t14 = /* @__PURE__ */ jsx("span", {
7300
7214
  className: "folio-outline-title",
7301
7215
  children: t13
7302
7216
  });
7303
- $[43] = t13;
7304
- $[44] = t14;
7305
- } else t14 = $[44];
7217
+ $[44] = t13;
7218
+ $[45] = t14;
7219
+ } else t14 = $[45];
7306
7220
  let t15;
7307
- if ($[45] !== onClose || $[46] !== surface || $[47] !== t) {
7221
+ if ($[46] !== onClose || $[47] !== surface || $[48] !== t) {
7308
7222
  t15 = surface === "expanded" && onClose && /* @__PURE__ */ jsx("button", {
7309
7223
  "aria-label": t("common.closeDialog"),
7310
7224
  className: "folio-outline-icon-button",
@@ -7317,41 +7231,41 @@ const DocumentOutline = (t0) => {
7317
7231
  size: 16
7318
7232
  })
7319
7233
  });
7320
- $[45] = onClose;
7321
- $[46] = surface;
7322
- $[47] = t;
7323
- $[48] = t15;
7324
- } else t15 = $[48];
7234
+ $[46] = onClose;
7235
+ $[47] = surface;
7236
+ $[48] = t;
7237
+ $[49] = t15;
7238
+ } else t15 = $[49];
7325
7239
  let t16;
7326
- if ($[49] !== t14 || $[50] !== t15) {
7240
+ if ($[50] !== t14 || $[51] !== t15) {
7327
7241
  t16 = /* @__PURE__ */ jsxs("div", {
7328
7242
  className: "folio-outline-heading-row",
7329
7243
  children: [t14, t15]
7330
7244
  });
7331
- $[49] = t14;
7332
- $[50] = t15;
7333
- $[51] = t16;
7334
- } else t16 = $[51];
7245
+ $[50] = t14;
7246
+ $[51] = t15;
7247
+ $[52] = t16;
7248
+ } else t16 = $[52];
7335
7249
  let t17;
7336
- if ($[52] !== t) {
7250
+ if ($[53] !== t) {
7337
7251
  t17 = t("editor.outlineDepthLabel");
7338
- $[52] = t;
7339
- $[53] = t17;
7340
- } else t17 = $[53];
7252
+ $[53] = t;
7253
+ $[54] = t17;
7254
+ } else t17 = $[54];
7341
7255
  let t18;
7342
- if ($[54] !== t17) {
7256
+ if ($[55] !== t17) {
7343
7257
  t18 = /* @__PURE__ */ jsx("span", { children: t17 });
7344
- $[54] = t17;
7345
- $[55] = t18;
7346
- } else t18 = $[55];
7258
+ $[55] = t17;
7259
+ $[56] = t18;
7260
+ } else t18 = $[56];
7347
7261
  let t19;
7348
- if ($[56] !== t) {
7262
+ if ($[57] !== t) {
7349
7263
  t19 = t("editor.outlineDepthLabel");
7350
- $[56] = t;
7351
- $[57] = t19;
7352
- } else t19 = $[57];
7264
+ $[57] = t;
7265
+ $[58] = t19;
7266
+ } else t19 = $[58];
7353
7267
  let t20;
7354
- if ($[58] !== onOutlineDepthChange) {
7268
+ if ($[59] !== onOutlineDepthChange) {
7355
7269
  t20 = (event) => {
7356
7270
  const value = event.currentTarget.value;
7357
7271
  if (value === "all") {
@@ -7360,56 +7274,56 @@ const DocumentOutline = (t0) => {
7360
7274
  }
7361
7275
  onOutlineDepthChange(value === "3" ? 3 : 2);
7362
7276
  };
7363
- $[58] = onOutlineDepthChange;
7364
- $[59] = t20;
7365
- } else t20 = $[59];
7277
+ $[59] = onOutlineDepthChange;
7278
+ $[60] = t20;
7279
+ } else t20 = $[60];
7366
7280
  let t21;
7367
- if ($[60] !== t) {
7281
+ if ($[61] !== t) {
7368
7282
  t21 = t("editor.outlineDepthTwo");
7369
- $[60] = t;
7370
- $[61] = t21;
7371
- } else t21 = $[61];
7283
+ $[61] = t;
7284
+ $[62] = t21;
7285
+ } else t21 = $[62];
7372
7286
  let t22;
7373
- if ($[62] !== t21) {
7287
+ if ($[63] !== t21) {
7374
7288
  t22 = /* @__PURE__ */ jsx("option", {
7375
7289
  value: 2,
7376
7290
  children: t21
7377
7291
  });
7378
- $[62] = t21;
7379
- $[63] = t22;
7380
- } else t22 = $[63];
7292
+ $[63] = t21;
7293
+ $[64] = t22;
7294
+ } else t22 = $[64];
7381
7295
  let t23;
7382
- if ($[64] !== t) {
7296
+ if ($[65] !== t) {
7383
7297
  t23 = t("editor.outlineDepthThree");
7384
- $[64] = t;
7385
- $[65] = t23;
7386
- } else t23 = $[65];
7298
+ $[65] = t;
7299
+ $[66] = t23;
7300
+ } else t23 = $[66];
7387
7301
  let t24;
7388
- if ($[66] !== t23) {
7302
+ if ($[67] !== t23) {
7389
7303
  t24 = /* @__PURE__ */ jsx("option", {
7390
7304
  value: 3,
7391
7305
  children: t23
7392
7306
  });
7393
- $[66] = t23;
7394
- $[67] = t24;
7395
- } else t24 = $[67];
7307
+ $[67] = t23;
7308
+ $[68] = t24;
7309
+ } else t24 = $[68];
7396
7310
  let t25;
7397
- if ($[68] !== t) {
7311
+ if ($[69] !== t) {
7398
7312
  t25 = t("editor.outlineDepthAll");
7399
- $[68] = t;
7400
- $[69] = t25;
7401
- } else t25 = $[69];
7313
+ $[69] = t;
7314
+ $[70] = t25;
7315
+ } else t25 = $[70];
7402
7316
  let t26;
7403
- if ($[70] !== t25) {
7317
+ if ($[71] !== t25) {
7404
7318
  t26 = /* @__PURE__ */ jsx("option", {
7405
7319
  value: "all",
7406
7320
  children: t25
7407
7321
  });
7408
- $[70] = t25;
7409
- $[71] = t26;
7410
- } else t26 = $[71];
7322
+ $[71] = t25;
7323
+ $[72] = t26;
7324
+ } else t26 = $[72];
7411
7325
  let t27;
7412
- if ($[72] !== outlineDepth || $[73] !== t19 || $[74] !== t20 || $[75] !== t22 || $[76] !== t24 || $[77] !== t26) {
7326
+ if ($[73] !== outlineDepth || $[74] !== t19 || $[75] !== t20 || $[76] !== t22 || $[77] !== t24 || $[78] !== t26) {
7413
7327
  t27 = /* @__PURE__ */ jsxs("select", {
7414
7328
  "aria-label": t19,
7415
7329
  onChange: t20,
@@ -7420,36 +7334,36 @@ const DocumentOutline = (t0) => {
7420
7334
  t26
7421
7335
  ]
7422
7336
  });
7423
- $[72] = outlineDepth;
7424
- $[73] = t19;
7425
- $[74] = t20;
7426
- $[75] = t22;
7427
- $[76] = t24;
7428
- $[77] = t26;
7429
- $[78] = t27;
7430
- } else t27 = $[78];
7337
+ $[73] = outlineDepth;
7338
+ $[74] = t19;
7339
+ $[75] = t20;
7340
+ $[76] = t22;
7341
+ $[77] = t24;
7342
+ $[78] = t26;
7343
+ $[79] = t27;
7344
+ } else t27 = $[79];
7431
7345
  let t28;
7432
- if ($[79] !== t18 || $[80] !== t27) {
7346
+ if ($[80] !== t18 || $[81] !== t27) {
7433
7347
  t28 = /* @__PURE__ */ jsxs("label", {
7434
7348
  className: "folio-outline-depth-control",
7435
7349
  children: [t18, t27]
7436
7350
  });
7437
- $[79] = t18;
7438
- $[80] = t27;
7439
- $[81] = t28;
7440
- } else t28 = $[81];
7351
+ $[80] = t18;
7352
+ $[81] = t27;
7353
+ $[82] = t28;
7354
+ } else t28 = $[82];
7441
7355
  let t29;
7442
- if ($[82] !== t16 || $[83] !== t28) {
7356
+ if ($[83] !== t16 || $[84] !== t28) {
7443
7357
  t29 = /* @__PURE__ */ jsxs("div", {
7444
7358
  className: "folio-outline-header",
7445
7359
  children: [t16, t28]
7446
7360
  });
7447
- $[82] = t16;
7448
- $[83] = t28;
7449
- $[84] = t29;
7450
- } else t29 = $[84];
7361
+ $[83] = t16;
7362
+ $[84] = t28;
7363
+ $[85] = t29;
7364
+ } else t29 = $[85];
7451
7365
  let t30;
7452
- if ($[85] !== outlineLabel || $[86] !== rail || $[87] !== surface || $[88] !== t11 || $[89] !== t12 || $[90] !== t29) {
7366
+ if ($[86] !== outlineLabel || $[87] !== rail || $[88] !== surface || $[89] !== t11 || $[90] !== t12 || $[91] !== t29) {
7453
7367
  t30 = /* @__PURE__ */ jsxs("nav", {
7454
7368
  ref: navRef,
7455
7369
  "aria-label": outlineLabel,
@@ -7459,19 +7373,19 @@ const DocumentOutline = (t0) => {
7459
7373
  style: t12,
7460
7374
  children: [t29, rail]
7461
7375
  });
7462
- $[85] = outlineLabel;
7463
- $[86] = rail;
7464
- $[87] = surface;
7465
- $[88] = t11;
7466
- $[89] = t12;
7467
- $[90] = t29;
7468
- $[91] = t30;
7469
- } else t30 = $[91];
7376
+ $[86] = outlineLabel;
7377
+ $[87] = rail;
7378
+ $[88] = surface;
7379
+ $[89] = t11;
7380
+ $[90] = t12;
7381
+ $[91] = t29;
7382
+ $[92] = t30;
7383
+ } else t30 = $[92];
7470
7384
  return t30;
7471
7385
  };
7472
- function _temp$10(heading) {
7386
+ function _temp$11(heading) {
7473
7387
  const item = {
7474
- id: headingId(heading),
7388
+ id: heading.id,
7475
7389
  label: heading.text,
7476
7390
  level: heading.level
7477
7391
  };
@@ -7869,7 +7783,7 @@ function NotificationContainer(t0) {
7869
7783
  if ($[0] !== notifications || $[1] !== onDismiss) {
7870
7784
  t3 = Symbol.for("react.early_return_sentinel");
7871
7785
  bb0: {
7872
- const visibleNotifications = notifications.filter(_temp$9);
7786
+ const visibleNotifications = notifications.filter(_temp$10);
7873
7787
  if (visibleNotifications.length === 0) {
7874
7788
  t3 = null;
7875
7789
  break bb0;
@@ -7909,7 +7823,7 @@ function NotificationContainer(t0) {
7909
7823
  } else t4 = $[9];
7910
7824
  return t4;
7911
7825
  }
7912
- function _temp$9(n) {
7826
+ function _temp$10(n) {
7913
7827
  return !n.dismissed;
7914
7828
  }
7915
7829
  const SEVERITY_STYLES = {
@@ -8351,7 +8265,7 @@ function AlignmentButtons({ value = "left", onChange, disabled = false }) {
8351
8265
  function AlignmentOption(t0) {
8352
8266
  const $ = c(16);
8353
8267
  const { PopoverClose, option, selected, onChange } = t0;
8354
- const handleMouseDown = _temp$8;
8268
+ const handleMouseDown = _temp$9;
8355
8269
  let t1;
8356
8270
  if ($[0] !== onChange || $[1] !== option.value) {
8357
8271
  t1 = () => onChange?.(option.value);
@@ -8405,7 +8319,7 @@ function AlignmentOption(t0) {
8405
8319
  } else t8 = $[15];
8406
8320
  return t8;
8407
8321
  }
8408
- function _temp$8(event) {
8322
+ function _temp$9(event) {
8409
8323
  return event.preventDefault();
8410
8324
  }
8411
8325
  //#endregion
@@ -9596,6 +9510,93 @@ function FormattingBar(props) {
9596
9510
  });
9597
9511
  }
9598
9512
  //#endregion
9513
+ //#region src/components/hooks/useActiveHeading.ts
9514
+ /**
9515
+ * The heading the reader is in: the last heading whose paragraph starts above
9516
+ * the middle of the scroll viewport, tracked as the document scrolls. Shared
9517
+ * by every place the outline is drawn (column, rail, drawer), so a drawer
9518
+ * opens on the same heading the rail marks.
9519
+ */
9520
+ /** How long a jump holds the active heading before scrolling may move it. */
9521
+ const MANUAL_ACTIVE_LOCK_MS = 900;
9522
+ const useActiveHeading = (container, headings) => {
9523
+ const $ = c(7);
9524
+ const [activeId, setActiveId] = useState(null);
9525
+ const manualLockUntil = useRef(0);
9526
+ let t0;
9527
+ let t1;
9528
+ if ($[0] !== container || $[1] !== headings) {
9529
+ t0 = () => {
9530
+ if (!container || headings.length === 0) return;
9531
+ const compute = () => {
9532
+ if (Date.now() < manualLockUntil.current) return;
9533
+ const anchors = findBodyPmAnchors(container);
9534
+ if (anchors.length === 0) return;
9535
+ const containerTop = container.getBoundingClientRect().top;
9536
+ const threshold = container.scrollTop + container.clientHeight / 2;
9537
+ const offsets = [];
9538
+ for (const el of anchors) {
9539
+ const pm = Number(el.dataset.pmStart);
9540
+ if (!Number.isFinite(pm)) continue;
9541
+ offsets.push({
9542
+ pm,
9543
+ top: el.getBoundingClientRect().top - containerTop + container.scrollTop
9544
+ });
9545
+ }
9546
+ offsets.sort(_temp$8);
9547
+ let next = null;
9548
+ for (const heading of headings) {
9549
+ const candidate = offsets.find((offset) => offset.pm >= heading.pmPos);
9550
+ if (candidate && candidate.top <= threshold) next = heading.id;
9551
+ }
9552
+ setActiveId(next);
9553
+ };
9554
+ let raf = 0;
9555
+ const onScroll = () => {
9556
+ cancelAnimationFrame(raf);
9557
+ raf = requestAnimationFrame(compute);
9558
+ };
9559
+ container.addEventListener("scroll", onScroll, { passive: true });
9560
+ raf = requestAnimationFrame(compute);
9561
+ return () => {
9562
+ cancelAnimationFrame(raf);
9563
+ container.removeEventListener("scroll", onScroll);
9564
+ };
9565
+ };
9566
+ t1 = [container, headings];
9567
+ $[0] = container;
9568
+ $[1] = headings;
9569
+ $[2] = t0;
9570
+ $[3] = t1;
9571
+ } else {
9572
+ t0 = $[2];
9573
+ t1 = $[3];
9574
+ }
9575
+ useEffect(t0, t1);
9576
+ let t2;
9577
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
9578
+ t2 = (id) => {
9579
+ setActiveId(id);
9580
+ manualLockUntil.current = Date.now() + MANUAL_ACTIVE_LOCK_MS;
9581
+ };
9582
+ $[4] = t2;
9583
+ } else t2 = $[4];
9584
+ const markJumped = t2;
9585
+ let t3;
9586
+ if ($[5] !== activeId) {
9587
+ t3 = {
9588
+ activeId,
9589
+ markJumped
9590
+ };
9591
+ $[5] = activeId;
9592
+ $[6] = t3;
9593
+ } else t3 = $[6];
9594
+ return t3;
9595
+ };
9596
+ function _temp$8(a, b) {
9597
+ return a.pm - b.pm;
9598
+ }
9599
+ //#endregion
9599
9600
  //#region src/components/selectionDetection.ts
9600
9601
  /**
9601
9602
  * If the editor's current selection is a `NodeSelection` of an `image`
@@ -14092,7 +14093,7 @@ function _temp(id_4) {
14092
14093
  //#region src/components/DocxEditor.tsx
14093
14094
  /** No headings to track while the outline is not shown. */
14094
14095
  const NO_HEADINGS = [];
14095
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-jIMSYslR.js").then((m) => ({ default: m.CommentsSidebar })));
14096
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-C9bLPobu.js").then((m) => ({ default: m.CommentsSidebar })));
14096
14097
  const TextContextMenu = lazy(() => import("./TextContextMenu-DHe4vOW7.js").then((m) => ({ default: m.TextContextMenu })));
14097
14098
  const loadAttemptSelectiveSave = async () => {
14098
14099
  const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
@@ -14237,10 +14238,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14237
14238
  const [rulerVisible, setRulerVisible] = useState(showRulerProp);
14238
14239
  const toggleRuler = useCallback(() => setRulerVisible((visible) => !visible), []);
14239
14240
  const [showOutline, setShowOutline] = useState(showOutlineProp);
14240
- const showOutlineRef = useRef(false);
14241
- useLayoutEffect(() => {
14242
- showOutlineRef.current = showOutline;
14243
- });
14244
14241
  const [outlineHeadings, setHeadingInfos] = useState([]);
14245
14242
  const [, setTrackedChangeEntries] = useState([]);
14246
14243
  const trackedChangesRef = useRef([]);
@@ -14262,7 +14259,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14262
14259
  } : { type: "editing" });
14263
14260
  }, [editingMode, author]);
14264
14261
  const extractTrackedChangesTimerRef = useRef(null);
14265
- const collectHeadingsTimerRef = useRef(null);
14266
14262
  const extractTrackedChanges = useCallback(() => {
14267
14263
  const view = pagedEditorRef.current?.getView();
14268
14264
  if (!view) return;
@@ -14298,7 +14294,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14298
14294
  }, [setTrackedChanges]);
14299
14295
  useEffect(() => () => {
14300
14296
  if (extractTrackedChangesTimerRef.current) clearTimeout(extractTrackedChangesTimerRef.current);
14301
- if (collectHeadingsTimerRef.current) clearTimeout(collectHeadingsTimerRef.current);
14302
14297
  }, []);
14303
14298
  const [previousShowOutlineProp, setPreviousShowOutlineProp] = useState(showOutlineProp);
14304
14299
  if (previousShowOutlineProp !== showOutlineProp) {
@@ -14427,35 +14422,26 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14427
14422
  setBodyViewEpoch((epoch) => epoch + 1);
14428
14423
  }, [reportEditorViewReady]);
14429
14424
  useEffect(() => {
14430
- if (!showOutline || !history.state || bodyViewEpoch === 0) return;
14431
- const view_3 = pagedEditorRef.current?.getView();
14432
- if (!view_3) return;
14433
- const headings = collectHeadings(view_3.state.doc, getDocumentBuiltInStyles(view_3.state));
14434
- setHeadingInfos(headings);
14435
- let attempts = 0;
14436
- let timer = null;
14437
- const fill = () => {
14438
- attempts++;
14439
- const pagedRef = pagedEditorRef.current;
14440
- if (!pagedRef) return;
14441
- let unresolved = false;
14442
- for (const heading of headings) if (heading.pageNumber == null) {
14443
- const page = pagedRef.getPageNumberForPmPos(heading.pmPos);
14444
- if (page !== null) heading.pageNumber = page;
14445
- else unresolved = true;
14425
+ const pagedEditor = pagedEditorRef.current;
14426
+ if (!showOutline || bodyViewEpoch === 0 || !pagedEditor) return;
14427
+ let collectedDoc = null;
14428
+ let collected = [];
14429
+ const refresh = (layout) => {
14430
+ const view_3 = pagedEditor.getView();
14431
+ if (!view_3) return;
14432
+ if (view_3.state.doc !== collectedDoc) {
14433
+ collectedDoc = view_3.state.doc;
14434
+ collected = collectHeadings(view_3.state.doc, getDocumentBuiltInStyles(view_3.state));
14446
14435
  }
14447
- setHeadingInfos([...headings]);
14448
- if (unresolved && attempts < 10) timer = setTimeout(fill, 300);
14449
- };
14450
- timer = setTimeout(fill, 100);
14451
- return () => {
14452
- if (timer) clearTimeout(timer);
14436
+ setHeadingInfos((previous) => resolveOutlineHeadings({
14437
+ collected,
14438
+ layout,
14439
+ previous
14440
+ }));
14453
14441
  };
14454
- }, [
14455
- showOutline,
14456
- history.state,
14457
- bodyViewEpoch
14458
- ]);
14442
+ refresh(pagedEditor.getLayout());
14443
+ return pagedEditor.getEditor().on("layoutComplete", refresh);
14444
+ }, [showOutline, bodyViewEpoch]);
14459
14445
  const [editorController, setEditorController] = useState(null);
14460
14446
  const attachPagedEditor = useCallback((editor) => {
14461
14447
  assignRef(pagedEditorRef, editor);
@@ -14487,23 +14473,23 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14487
14473
  const [widestLaidOutPageWidth, setWidestLaidOutPageWidth] = useState(null);
14488
14474
  const hasDocument = history.state !== null;
14489
14475
  useEffect(() => {
14490
- const pagedEditor = pagedEditorRef.current;
14491
- if (!pagedEditor || !hasDocument || state.documentLoad.status !== "ready" && !preserveDocumentWhileLoading) {
14476
+ const pagedEditor_0 = pagedEditorRef.current;
14477
+ if (!pagedEditor_0 || !hasDocument || state.documentLoad.status !== "ready" && !preserveDocumentWhileLoading) {
14492
14478
  setWidestLaidOutPageWidth(null);
14493
14479
  return;
14494
14480
  }
14495
14481
  const updatePageWidth = () => {
14496
- const pages = pagedEditor.getLayout()?.pages;
14482
+ const pages = pagedEditor_0.getLayout()?.pages;
14497
14483
  if (!pages) {
14498
14484
  setWidestLaidOutPageWidth(null);
14499
14485
  return;
14500
14486
  }
14501
14487
  let width = 0;
14502
- for (const page_0 of pages) width = Math.max(width, page_0.size.w);
14488
+ for (const page of pages) width = Math.max(width, page.size.w);
14503
14489
  setWidestLaidOutPageWidth(width);
14504
14490
  };
14505
14491
  updatePageWidth();
14506
- return pagedEditor.getEditor().on("layoutComplete", updatePageWidth);
14492
+ return pagedEditor_0.getEditor().on("layoutComplete", updatePageWidth);
14507
14493
  }, [
14508
14494
  state.documentLoad.status,
14509
14495
  hasDocument,
@@ -14730,10 +14716,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14730
14716
  clearTimeout(extractTrackedChangesTimerRef.current);
14731
14717
  extractTrackedChangesTimerRef.current = null;
14732
14718
  }
14733
- if (collectHeadingsTimerRef.current) {
14734
- clearTimeout(collectHeadingsTimerRef.current);
14735
- collectHeadingsTimerRef.current = null;
14736
- }
14737
14719
  }, [
14738
14720
  setCommentsDirty,
14739
14721
  resetLoadedComments,
@@ -14757,8 +14739,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14757
14739
  });
14758
14740
  useEffect(() => {
14759
14741
  if (state.documentLoad.status === "ready" && history.state) {
14760
- const timer_0 = setTimeout(extractTrackedChanges, 200);
14761
- return () => clearTimeout(timer_0);
14742
+ const timer = setTimeout(extractTrackedChanges, 200);
14743
+ return () => clearTimeout(timer);
14762
14744
  }
14763
14745
  }, [
14764
14746
  state.documentLoad.status,
@@ -14818,18 +14800,6 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14818
14800
  };
14819
14801
  pushDocument(documentWithComments);
14820
14802
  onChange?.(canonical ? cloneDocumentWithParagraphPropertySources(documentWithComments) : documentWithComments);
14821
- if (showOutlineRef.current) {
14822
- if (collectHeadingsTimerRef.current) clearTimeout(collectHeadingsTimerRef.current);
14823
- collectHeadingsTimerRef.current = setTimeout(() => {
14824
- const view_5 = pagedEditorRef.current?.getView();
14825
- if (view_5) {
14826
- const headings_0 = collectHeadings(view_5.state.doc, getDocumentBuiltInStyles(view_5.state));
14827
- const pagedRef_0 = pagedEditorRef.current;
14828
- for (const heading_0 of headings_0) heading_0.pageNumber = pagedRef_0?.getPageNumberForPmPos(heading_0.pmPos) ?? null;
14829
- setHeadingInfos(headings_0);
14830
- }
14831
- }, 400);
14832
- }
14833
14803
  if (extractTrackedChangesTimerRef.current) clearTimeout(extractTrackedChangesTimerRef.current);
14834
14804
  extractTrackedChangesTimerRef.current = setTimeout(extractTrackedChanges, 300);
14835
14805
  requestAnimationFrame(refreshBodyHistoryAvailability);
@@ -14860,8 +14830,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14860
14830
  const flushBag = (bag) => {
14861
14831
  if (!bag) return;
14862
14832
  for (const [rId, hf] of bag) {
14863
- const view_6 = editor_0.getHfView(rId);
14864
- if (view_6) hf.content = proseDocToBlocks(view_6.state.doc, hf.content);
14833
+ const view_5 = editor_0.getHfView(rId);
14834
+ if (view_5) hf.content = proseDocToBlocks(view_5.state.doc, hf.content);
14865
14835
  }
14866
14836
  };
14867
14837
  flushBag(doc_0.package.headers);
@@ -14920,9 +14890,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14920
14890
  return;
14921
14891
  }
14922
14892
  if (result?.status !== "refused" || result.retry !== "afterComposition") return;
14923
- const view_7 = getCanonicalApi()?.getView();
14924
- if (!view_7) return;
14925
- return afterCanonicalCompositionSettles(view_7, () => setControlledCommentsRetry((attempt) => attempt + 1));
14893
+ const view_6 = getCanonicalApi()?.getView();
14894
+ if (!view_6) return;
14895
+ return afterCanonicalCompositionSettles(view_6, () => setControlledCommentsRetry((attempt) => attempt + 1));
14926
14896
  });
14927
14897
  useEffect(() => synchronizeControlledComments({
14928
14898
  commentsProp,
@@ -14999,41 +14969,41 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14999
14969
  if (bodyViewEpoch === 0) return;
15000
14970
  const editor_1 = pagedEditorRef.current?.getEditor();
15001
14971
  if (!editor_1) return;
15002
- let timer_1 = null;
14972
+ let timer_0 = null;
15003
14973
  const schedule = () => {
15004
- if (timer_1 !== null) clearTimeout(timer_1);
15005
- timer_1 = setTimeout(() => refreshFindRef.current(), 200);
14974
+ if (timer_0 !== null) clearTimeout(timer_0);
14975
+ timer_0 = setTimeout(() => refreshFindRef.current(), 200);
15006
14976
  };
15007
14977
  const unsubscribe = editor_1.on("docChange", schedule);
15008
14978
  const unsubscribeLayout = editor_1.on("layoutComplete", schedule);
15009
14979
  return () => {
15010
14980
  unsubscribe();
15011
14981
  unsubscribeLayout();
15012
- if (timer_1 !== null) clearTimeout(timer_1);
14982
+ if (timer_0 !== null) clearTimeout(timer_0);
15013
14983
  };
15014
14984
  }, [bodyViewEpoch]);
15015
14985
  useEffect(() => {
15016
14986
  const snapshot = comments;
15017
- const timer_2 = setTimeout(() => {
14987
+ const timer_1 = setTimeout(() => {
15018
14988
  if (commentsRef.current === snapshot) refreshFindRef.current();
15019
14989
  }, 200);
15020
- return () => clearTimeout(timer_2);
14990
+ return () => clearTimeout(timer_1);
15021
14991
  }, [comments, commentsRef]);
15022
14992
  useLayoutEffect(() => {
15023
14993
  resetFindResultRef.current = resetFindResult;
15024
14994
  }, [resetFindResult]);
15025
14995
  const handleSelectionChange = useCallback((selectionState) => {
15026
- const view_8 = getActiveEditorView();
15027
- if (view_8) {
15028
- const { from, to } = view_8.state.selection;
14996
+ const view_7 = getActiveEditorView();
14997
+ if (view_7) {
14998
+ const { from, to } = view_7.state.selection;
15029
14999
  lastSelectionRef.current = {
15030
15000
  from,
15031
15001
  to
15032
15002
  };
15033
15003
  }
15034
15004
  let pmTableCtx = null;
15035
- if (view_8) {
15036
- pmTableCtx = getTableContext(view_8.state);
15005
+ if (view_7) {
15006
+ pmTableCtx = getTableContext(view_7.state);
15037
15007
  if (!pmTableCtx.isInTable) pmTableCtx = null;
15038
15008
  }
15039
15009
  if (pmTableCtx?.cellBorderColor) {
@@ -15045,8 +15015,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15045
15015
  color: { rgb }
15046
15016
  };
15047
15017
  }
15048
- const pmImageCtx = view_8 ? detectImageContext(view_8.state) : null;
15049
- const trackedChange = view_8 ? detectActiveTrackedChange(view_8.state) : null;
15018
+ const pmImageCtx = view_7 ? detectImageContext(view_7.state) : null;
15019
+ const trackedChange = view_7 ? detectActiveTrackedChange(view_7.state) : null;
15050
15020
  if (!selectionState) {
15051
15021
  setFloatingCommentBtn(null);
15052
15022
  setState((prev_1) => {
@@ -15109,10 +15079,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15109
15079
  activeTrackedChange: activeTrackedChange_0
15110
15080
  };
15111
15081
  });
15112
- if (view_8 && selectionState.hasSelection && !isAddingComment && !readOnly) {
15082
+ if (view_7 && selectionState.hasSelection && !isAddingComment && !readOnly) {
15113
15083
  const container = scrollContainerRef.current;
15114
15084
  const parentEl = editorContentRef.current;
15115
- const { from: selFrom } = view_8.state.selection;
15085
+ const { from: selFrom } = view_7.state.selection;
15116
15086
  const top = findSelectionYPosition(container, parentEl, selFrom);
15117
15087
  if (top !== null && container && parentEl) {
15118
15088
  const pagesEl = container.querySelector(".paged-editor__pages");
@@ -15120,7 +15090,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15120
15090
  const parentRect = parentEl.getBoundingClientRect();
15121
15091
  const rawLeft = pageEl ? pageEl.getBoundingClientRect().right - parentRect.left + 12 : parentRect.width / 2 + 408;
15122
15092
  const left = Math.max(16, Math.min(rawLeft, parentRect.width - 16));
15123
- const { from: from_0, to: to_0 } = view_8.state.selection;
15093
+ const { from: from_0, to: to_0 } = view_7.state.selection;
15124
15094
  if (from_0 !== to_0) setFloatingCommentBtn({
15125
15095
  top,
15126
15096
  left,
@@ -15283,99 +15253,99 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15283
15253
  refuseCanonicalModelEdit
15284
15254
  ]);
15285
15255
  const handleTableAction = useCallback((action_0) => {
15286
- const view_9 = getActiveEditorView();
15287
- if (!view_9) return;
15256
+ const view_8 = getActiveEditorView();
15257
+ if (!view_8) return;
15288
15258
  switch (action_0) {
15289
15259
  case "addRowAbove":
15290
- addRowAbove(view_9.state, view_9.dispatch);
15260
+ addRowAbove(view_8.state, view_8.dispatch);
15291
15261
  break;
15292
15262
  case "addRowBelow":
15293
- addRowBelow(view_9.state, view_9.dispatch);
15263
+ addRowBelow(view_8.state, view_8.dispatch);
15294
15264
  break;
15295
15265
  case "addColumnLeft":
15296
- addColumnLeft(view_9.state, view_9.dispatch);
15266
+ addColumnLeft(view_8.state, view_8.dispatch);
15297
15267
  break;
15298
15268
  case "addColumnRight":
15299
- addColumnRight(view_9.state, view_9.dispatch);
15269
+ addColumnRight(view_8.state, view_8.dispatch);
15300
15270
  break;
15301
15271
  case "deleteRow":
15302
- deleteRow(view_9.state, view_9.dispatch);
15272
+ deleteRow(view_8.state, view_8.dispatch);
15303
15273
  break;
15304
15274
  case "deleteColumn":
15305
- deleteColumn(view_9.state, view_9.dispatch);
15275
+ deleteColumn(view_8.state, view_8.dispatch);
15306
15276
  break;
15307
15277
  case "deleteTable":
15308
- deleteTable(view_9.state, view_9.dispatch);
15278
+ deleteTable(view_8.state, view_8.dispatch);
15309
15279
  break;
15310
15280
  case "selectTable":
15311
- selectTable(view_9.state, view_9.dispatch);
15281
+ selectTable(view_8.state, view_8.dispatch);
15312
15282
  break;
15313
15283
  case "selectRow":
15314
- selectRow(view_9.state, view_9.dispatch);
15284
+ selectRow(view_8.state, view_8.dispatch);
15315
15285
  break;
15316
15286
  case "selectColumn":
15317
- selectColumn(view_9.state, view_9.dispatch);
15287
+ selectColumn(view_8.state, view_8.dispatch);
15318
15288
  break;
15319
15289
  case "mergeCells":
15320
- mergeCells(view_9.state, view_9.dispatch);
15290
+ mergeCells(view_8.state, view_8.dispatch);
15321
15291
  break;
15322
15292
  case "splitCell":
15323
- splitCell(view_9.state, view_9.dispatch);
15293
+ splitCell(view_8.state, view_8.dispatch);
15324
15294
  break;
15325
15295
  case "borderAll":
15326
- setAllTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
15296
+ setAllTableBorders(view_8.state, view_8.dispatch, borderSpecRef.current);
15327
15297
  break;
15328
15298
  case "borderOutside":
15329
- setOutsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
15299
+ setOutsideTableBorders(view_8.state, view_8.dispatch, borderSpecRef.current);
15330
15300
  break;
15331
15301
  case "borderInside":
15332
- setInsideTableBorders(view_9.state, view_9.dispatch, borderSpecRef.current);
15302
+ setInsideTableBorders(view_8.state, view_8.dispatch, borderSpecRef.current);
15333
15303
  break;
15334
15304
  case "borderNone":
15335
- removeTableBorders(view_9.state, view_9.dispatch);
15305
+ removeTableBorders(view_8.state, view_8.dispatch);
15336
15306
  break;
15337
15307
  case "borderTop":
15338
- setCellBorder("top", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15308
+ setCellBorder("top", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
15339
15309
  break;
15340
15310
  case "borderBottom":
15341
- setCellBorder("bottom", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15311
+ setCellBorder("bottom", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
15342
15312
  break;
15343
15313
  case "borderLeft":
15344
- setCellBorder("left", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15314
+ setCellBorder("left", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
15345
15315
  break;
15346
15316
  case "borderRight":
15347
- setCellBorder("right", borderSpecRef.current, true)(view_9.state, view_9.dispatch);
15317
+ setCellBorder("right", borderSpecRef.current, true)(view_8.state, view_8.dispatch);
15348
15318
  break;
15349
15319
  default: if (typeof action_0 === "object") {
15350
- if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_9.state, view_9.dispatch);
15320
+ if (action_0.type === "cellFillColor") setCellFillColor(action_0.color)(view_8.state, view_8.dispatch);
15351
15321
  else if (action_0.type === "borderColor") {
15352
15322
  const rgb_0 = action_0.color.replace(/^#/u, "");
15353
15323
  borderSpecRef.current = {
15354
15324
  ...borderSpecRef.current,
15355
15325
  color: { rgb: rgb_0 }
15356
15326
  };
15357
- setTableBorderColor(action_0.color)(view_9.state, view_9.dispatch);
15327
+ setTableBorderColor(action_0.color)(view_8.state, view_8.dispatch);
15358
15328
  } else if (action_0.type === "borderWidth") {
15359
15329
  borderSpecRef.current = {
15360
15330
  ...borderSpecRef.current,
15361
15331
  size: action_0.size
15362
15332
  };
15363
- setTableBorderWidth(action_0.size)(view_9.state, view_9.dispatch);
15333
+ setTableBorderWidth(action_0.size)(view_8.state, view_8.dispatch);
15364
15334
  } else if (action_0.type === "cellBorder") setCellBorder(action_0.side, {
15365
15335
  style: action_0.style,
15366
15336
  size: action_0.size,
15367
15337
  color: { rgb: action_0.color.replace(/^#/u, "") }
15368
- })(view_9.state, view_9.dispatch);
15369
- else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_9.state, view_9.dispatch);
15370
- else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_9.state, view_9.dispatch);
15371
- else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_9.state, view_9.dispatch);
15372
- else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_9.state, view_9.dispatch);
15373
- else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_9.state, view_9.dispatch);
15374
- else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_9.state, view_9.dispatch);
15375
- else if (action_0.type === "distributeColumns") distributeColumns()(view_9.state, view_9.dispatch);
15376
- else if (action_0.type === "autoFitContents") autoFitContents()(view_9.state, view_9.dispatch);
15338
+ })(view_8.state, view_8.dispatch);
15339
+ else if (action_0.type === "cellVerticalAlign") setCellVerticalAlign(action_0.align)(view_8.state, view_8.dispatch);
15340
+ else if (action_0.type === "cellMargins") setCellMargins(action_0.margins)(view_8.state, view_8.dispatch);
15341
+ else if (action_0.type === "cellTextDirection") setCellTextDirection(action_0.direction)(view_8.state, view_8.dispatch);
15342
+ else if (action_0.type === "toggleNoWrap") toggleNoWrap()(view_8.state, view_8.dispatch);
15343
+ else if (action_0.type === "rowHeight") setRowHeight(action_0.height, action_0.rule)(view_8.state, view_8.dispatch);
15344
+ else if (action_0.type === "toggleHeaderRow") toggleHeaderRow()(view_8.state, view_8.dispatch);
15345
+ else if (action_0.type === "distributeColumns") distributeColumns()(view_8.state, view_8.dispatch);
15346
+ else if (action_0.type === "autoFitContents") autoFitContents()(view_8.state, view_8.dispatch);
15377
15347
  else if (action_0.type === "openTableProperties") setTablePropsOpen(true);
15378
- else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_9.state, view_9.dispatch);
15348
+ else if (action_0.type === "tableProperties") setTableProperties(action_0.props)(view_8.state, view_8.dispatch);
15379
15349
  else {
15380
15350
  let preset = getBuiltinTableStyle(action_0.styleId);
15381
15351
  const currentDocForTable = historyStateRef.current;
@@ -15446,7 +15416,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15446
15416
  if (preset.tableBorders) styleArg.tableBorders = preset.tableBorders;
15447
15417
  if (preset.conditionals) styleArg.conditionals = preset.conditionals;
15448
15418
  if (preset.look) styleArg.look = preset.look;
15449
- applyTableStyle(styleArg)(view_9.state, view_9.dispatch);
15419
+ applyTableStyle(styleArg)(view_8.state, view_8.dispatch);
15450
15420
  }
15451
15421
  }
15452
15422
  } else tableSelection.handleAction(action_0);
@@ -15467,86 +15437,86 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15467
15437
  });
15468
15438
  }, [openContextMenu]);
15469
15439
  const handleFormat = useCallback((action_1) => {
15470
- const view_10 = getActiveEditorView();
15471
- if (!view_10) return;
15472
- view_10.focus();
15473
- const isBodyEditor = view_10 === pagedEditorRef.current?.getView();
15474
- const { from: from_1, to: to_1 } = view_10.state.selection;
15440
+ const view_9 = getActiveEditorView();
15441
+ if (!view_9) return;
15442
+ view_9.focus();
15443
+ const isBodyEditor = view_9 === pagedEditorRef.current?.getView();
15444
+ const { from: from_1, to: to_1 } = view_9.state.selection;
15475
15445
  const savedSelection = lastSelectionRef.current;
15476
15446
  if (isBodyEditor && savedSelection && (from_1 !== savedSelection.from || to_1 !== savedSelection.to)) try {
15477
- const tr = view_10.state.tr.setSelection(TextSelection.create(view_10.state.doc, savedSelection.from, savedSelection.to));
15478
- view_10.dispatch(tr);
15447
+ const tr = view_9.state.tr.setSelection(TextSelection.create(view_9.state.doc, savedSelection.from, savedSelection.to));
15448
+ view_9.dispatch(tr);
15479
15449
  } catch {}
15480
15450
  if (action_1 === "bold") {
15481
- executeEditorCommand(view_10, toggleBold);
15451
+ executeEditorCommand(view_9, toggleBold);
15482
15452
  return;
15483
15453
  }
15484
15454
  if (action_1 === "italic") {
15485
- executeEditorCommand(view_10, toggleItalic);
15455
+ executeEditorCommand(view_9, toggleItalic);
15486
15456
  return;
15487
15457
  }
15488
15458
  if (action_1 === "underline") {
15489
- executeEditorCommand(view_10, toggleUnderline);
15459
+ executeEditorCommand(view_9, toggleUnderline);
15490
15460
  return;
15491
15461
  }
15492
15462
  if (action_1 === "strikethrough") {
15493
- executeEditorCommand(view_10, toggleStrike);
15463
+ executeEditorCommand(view_9, toggleStrike);
15494
15464
  return;
15495
15465
  }
15496
15466
  if (action_1 === "superscript") {
15497
- executeEditorCommand(view_10, toggleSuperscript);
15467
+ executeEditorCommand(view_9, toggleSuperscript);
15498
15468
  return;
15499
15469
  }
15500
15470
  if (action_1 === "subscript") {
15501
- executeEditorCommand(view_10, toggleSubscript);
15471
+ executeEditorCommand(view_9, toggleSubscript);
15502
15472
  return;
15503
15473
  }
15504
15474
  if (action_1 === "bulletList") {
15505
- executeEditorCommand(view_10, toggleBulletList);
15475
+ executeEditorCommand(view_9, toggleBulletList);
15506
15476
  return;
15507
15477
  }
15508
15478
  if (action_1 === "numberedList") {
15509
- executeEditorCommand(view_10, toggleNumberedList);
15479
+ executeEditorCommand(view_9, toggleNumberedList);
15510
15480
  return;
15511
15481
  }
15512
15482
  if (action_1 === "indent") {
15513
- executeFirstEditorCommand(view_10, [increaseListLevel, increaseIndent()]);
15483
+ executeFirstEditorCommand(view_9, [increaseListLevel, increaseIndent()]);
15514
15484
  return;
15515
15485
  }
15516
15486
  if (action_1 === "outdent") {
15517
- executeFirstEditorCommand(view_10, [decreaseListLevel, decreaseIndent()]);
15487
+ executeFirstEditorCommand(view_9, [decreaseListLevel, decreaseIndent()]);
15518
15488
  return;
15519
15489
  }
15520
15490
  if (action_1 === "clearFormatting") {
15521
- executeEditorCommand(view_10, clearFormatting);
15491
+ executeEditorCommand(view_9, clearFormatting);
15522
15492
  return;
15523
15493
  }
15524
15494
  if (action_1 === "setRtl") {
15525
- executeEditorCommand(view_10, setRtl);
15495
+ executeEditorCommand(view_9, setRtl);
15526
15496
  return;
15527
15497
  }
15528
15498
  if (action_1 === "setLtr") {
15529
- executeEditorCommand(view_10, setLtr);
15499
+ executeEditorCommand(view_9, setLtr);
15530
15500
  return;
15531
15501
  }
15532
15502
  if (action_1 === "insertPageBreak") {
15533
- executeEditorCommand(view_10, insertPageBreak);
15503
+ executeEditorCommand(view_9, insertPageBreak);
15534
15504
  return;
15535
15505
  }
15536
15506
  if (typeof action_1 === "object") switch (action_1.type) {
15537
15507
  case "alignment":
15538
- executeEditorCommand(view_10, setAlignment(action_1.value));
15508
+ executeEditorCommand(view_9, setAlignment(action_1.value));
15539
15509
  break;
15540
15510
  case "toggleDirection":
15541
- executeEditorCommand(view_10, toggleBidi);
15511
+ executeEditorCommand(view_9, toggleBidi);
15542
15512
  break;
15543
15513
  case "textColor": {
15544
15514
  const colorVal_0 = action_1.value;
15545
- if (typeof colorVal_0 === "string") executeEditorCommand(view_10, setTextColor({ rgb: colorVal_0.replace("#", "") }));
15546
- else if (colorVal_0.auto) executeEditorCommand(view_10, clearTextColor);
15515
+ if (typeof colorVal_0 === "string") executeEditorCommand(view_9, setTextColor({ rgb: colorVal_0.replace("#", "") }));
15516
+ else if (colorVal_0.auto) executeEditorCommand(view_9, clearTextColor);
15547
15517
  else {
15548
15518
  const themeColor = typeof colorVal_0.themeColor === "string" ? colorVal_0.themeColor : void 0;
15549
- executeEditorCommand(view_10, setTextColor({
15519
+ executeEditorCommand(view_9, setTextColor({
15550
15520
  ...colorVal_0.rgb === void 0 ? {} : { rgb: colorVal_0.rgb },
15551
15521
  ...themeColor ? { themeColor } : {},
15552
15522
  ...colorVal_0.themeTint === void 0 ? {} : { themeTint: colorVal_0.themeTint },
@@ -15557,17 +15527,17 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15557
15527
  }
15558
15528
  case "highlightColor": {
15559
15529
  const highlightName = action_1.value ? mapHexToHighlightName(action_1.value) : "";
15560
- executeEditorCommand(view_10, setHighlight(highlightName || action_1.value));
15530
+ executeEditorCommand(view_9, setHighlight(highlightName || action_1.value));
15561
15531
  break;
15562
15532
  }
15563
15533
  case "fontSize":
15564
- executeEditorCommand(view_10, setFontSize(pointsToHalfPoints(action_1.value)));
15534
+ executeEditorCommand(view_9, setFontSize(pointsToHalfPoints(action_1.value)));
15565
15535
  break;
15566
15536
  case "fontFamily":
15567
- executeEditorCommand(view_10, setFontFamily(action_1.value));
15537
+ executeEditorCommand(view_9, setFontFamily(action_1.value));
15568
15538
  break;
15569
15539
  case "lineSpacing":
15570
- executeEditorCommand(view_10, setLineSpacing(action_1.value));
15540
+ executeEditorCommand(view_9, setLineSpacing(action_1.value));
15571
15541
  break;
15572
15542
  case "applyStyle": {
15573
15543
  const currentDoc_0 = historyStateRef.current;
@@ -15580,21 +15550,21 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15580
15550
  const styleName = styleResolver_0.getStyle(action_1.value)?.name;
15581
15551
  if (styleName) styleAttrs.styleName = styleName;
15582
15552
  styleAttrs.numbering = currentDoc_0?.package.numbering ? getCachedNumberingMap(currentDoc_0.package.numbering) : null;
15583
- executeEditorCommand(view_10, applyStyle(action_1.value, styleAttrs));
15584
- } else executeEditorCommand(view_10, applyStyle(action_1.value));
15553
+ executeEditorCommand(view_9, applyStyle(action_1.value, styleAttrs));
15554
+ } else executeEditorCommand(view_9, applyStyle(action_1.value));
15585
15555
  break;
15586
15556
  }
15587
15557
  }
15588
15558
  }, [getActiveEditorView, getCachedStyleResolver]);
15589
15559
  const captureFormatPainter = useCallback(() => {
15590
- const view_11 = getActiveEditorView();
15591
- capturedFormatMarksRef.current = view_11 ? captureFormatMarks(view_11.state) : null;
15560
+ const view_10 = getActiveEditorView();
15561
+ capturedFormatMarksRef.current = view_10 ? captureFormatMarks(view_10.state) : null;
15592
15562
  }, [getActiveEditorView]);
15593
15563
  const paintFormatToSelection = useCallback(() => {
15594
- const view_12 = getActiveEditorView();
15595
- if (!view_12) return false;
15596
- const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_12.state, view_12.dispatch);
15597
- if (applied) requestAnimationFrame(() => view_12.focus());
15564
+ const view_11 = getActiveEditorView();
15565
+ if (!view_11) return false;
15566
+ const applied = applyFormatMarks(capturedFormatMarksRef.current)(view_11.state, view_11.dispatch);
15567
+ if (applied) requestAnimationFrame(() => view_11.focus());
15598
15568
  return applied;
15599
15569
  }, [getActiveEditorView]);
15600
15570
  const handleFormatPainter = useCallback((sticky) => {
@@ -15773,15 +15743,15 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15773
15743
  ]);
15774
15744
  const { from: contextSelectionFrom, to: contextSelectionTo } = contextMenu.selectionRange;
15775
15745
  const handleContextMenuAction = useCallback(async (action_2) => {
15776
- const view_13 = getActiveEditorView();
15777
- if (!view_13) return;
15746
+ const view_12 = getActiveEditorView();
15747
+ if (!view_12) return;
15778
15748
  focusActiveEditor();
15779
15749
  if (readOnly && action_2 !== "copy" && action_2 !== "selectAll") return;
15780
15750
  if (action_2.startsWith("custom:")) {
15781
15751
  const { from: from_2, to: to_2 } = contextSelectionFrom !== contextSelectionTo ? {
15782
15752
  from: contextSelectionFrom,
15783
15753
  to: contextSelectionTo
15784
- } : view_13.state.selection;
15754
+ } : view_12.state.selection;
15785
15755
  onCustomContextAction?.(action_2.slice(7), {
15786
15756
  from: from_2,
15787
15757
  to: to_2
@@ -15791,16 +15761,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15791
15761
  switch (action_2) {
15792
15762
  case "cut": {
15793
15763
  if (readOnly) return;
15794
- const { from: from_7, to: to_7 } = view_13.state.selection;
15795
- const text_2 = view_13.state.doc.textBetween(from_7, to_7, "\n");
15764
+ const { from: from_7, to: to_7 } = view_12.state.selection;
15765
+ const text_2 = view_12.state.doc.textBetween(from_7, to_7, "\n");
15796
15766
  navigator.clipboard.writeText(text_2).catch(() => void 0);
15797
- if (!deleteSelectionAsSuggestion(view_13.state, view_13.dispatch)) view_13.dispatch(view_13.state.tr.deleteSelection());
15767
+ if (!deleteSelectionAsSuggestion(view_12.state, view_12.dispatch)) view_12.dispatch(view_12.state.tr.deleteSelection());
15798
15768
  onCut?.();
15799
15769
  break;
15800
15770
  }
15801
15771
  case "copy": {
15802
- const { from: cf, to: ct } = view_13.state.selection;
15803
- const copied = view_13.state.doc.textBetween(cf, ct, "\n");
15772
+ const { from: cf, to: ct } = view_12.state.selection;
15773
+ const copied = view_12.state.doc.textBetween(cf, ct, "\n");
15804
15774
  navigator.clipboard.writeText(copied).catch(() => void 0);
15805
15775
  onCopy?.();
15806
15776
  break;
@@ -15823,12 +15793,12 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15823
15793
  bubbles: true,
15824
15794
  cancelable: true
15825
15795
  });
15826
- view_13.dom.dispatchEvent(pasteEvent);
15796
+ view_12.dom.dispatchEvent(pasteEvent);
15827
15797
  } catch {
15828
15798
  try {
15829
15799
  const text_0 = await navigator.clipboard.readText();
15830
15800
  if (text_0) {
15831
- view_13.dispatch(view_13.state.tr.insertText(text_0));
15801
+ view_12.dispatch(view_12.state.tr.insertText(text_0));
15832
15802
  onPaste?.();
15833
15803
  }
15834
15804
  } catch {}
@@ -15837,9 +15807,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15837
15807
  case "pasteAsPlainText":
15838
15808
  try {
15839
15809
  const text = await navigator.clipboard.readText();
15840
- if (text && !view_13.isDestroyed) {
15841
- const slice = buildPlainTextSlice(text, view_13.state.schema);
15842
- view_13.dispatch(view_13.state.tr.replaceSelection(slice).scrollIntoView());
15810
+ if (text && !view_12.isDestroyed) {
15811
+ const slice = buildPlainTextSlice(text, view_12.state.schema);
15812
+ view_12.dispatch(view_12.state.tr.replaceSelection(slice).scrollIntoView());
15843
15813
  onPaste?.();
15844
15814
  }
15845
15815
  } catch {
@@ -15847,42 +15817,42 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15847
15817
  }
15848
15818
  break;
15849
15819
  case "delete": {
15850
- const { from: from_6, to: to_6 } = view_13.state.selection;
15851
- if (from_6 !== to_6) view_13.dispatch(view_13.state.tr.deleteRange(from_6, to_6));
15820
+ const { from: from_6, to: to_6 } = view_12.state.selection;
15821
+ if (from_6 !== to_6) view_12.dispatch(view_12.state.tr.deleteRange(from_6, to_6));
15852
15822
  break;
15853
15823
  }
15854
15824
  case "selectAll":
15855
- view_13.dispatch(view_13.state.tr.setSelection(TextSelection.create(view_13.state.doc, 0, view_13.state.doc.content.size)));
15825
+ view_12.dispatch(view_12.state.tr.setSelection(TextSelection.create(view_12.state.doc, 0, view_12.state.doc.content.size)));
15856
15826
  break;
15857
15827
  case "addRowAbove":
15858
- addRowAbove(view_13.state, view_13.dispatch);
15828
+ addRowAbove(view_12.state, view_12.dispatch);
15859
15829
  break;
15860
15830
  case "addRowBelow":
15861
- addRowBelow(view_13.state, view_13.dispatch);
15831
+ addRowBelow(view_12.state, view_12.dispatch);
15862
15832
  break;
15863
15833
  case "deleteRow":
15864
- deleteRow(view_13.state, view_13.dispatch);
15834
+ deleteRow(view_12.state, view_12.dispatch);
15865
15835
  break;
15866
15836
  case "addColumnLeft":
15867
- addColumnLeft(view_13.state, view_13.dispatch);
15837
+ addColumnLeft(view_12.state, view_12.dispatch);
15868
15838
  break;
15869
15839
  case "addColumnRight":
15870
- addColumnRight(view_13.state, view_13.dispatch);
15840
+ addColumnRight(view_12.state, view_12.dispatch);
15871
15841
  break;
15872
15842
  case "deleteColumn":
15873
- deleteColumn(view_13.state, view_13.dispatch);
15843
+ deleteColumn(view_12.state, view_12.dispatch);
15874
15844
  break;
15875
15845
  case "tableBordersAll":
15876
- setTableBorderPreset("all")(view_13.state, view_13.dispatch);
15846
+ setTableBorderPreset("all")(view_12.state, view_12.dispatch);
15877
15847
  break;
15878
15848
  case "tableBordersNone":
15879
- setTableBorderPreset("none")(view_13.state, view_13.dispatch);
15849
+ setTableBorderPreset("none")(view_12.state, view_12.dispatch);
15880
15850
  break;
15881
15851
  case "addComment": {
15882
15852
  const { from: from_5, to: to_5 } = contextSelectionFrom !== contextSelectionTo ? {
15883
15853
  from: contextSelectionFrom,
15884
15854
  to: contextSelectionTo
15885
- } : view_13.state.selection;
15855
+ } : view_12.state.selection;
15886
15856
  if (from_5 === to_5) break;
15887
15857
  const commentY = findSelectionYPosition(scrollContainerRef.current, editorContentRef.current, from_5) ?? getFallbackCommentYPosition(scrollContainerRef.current);
15888
15858
  setCommentSelectionRange({
@@ -15890,7 +15860,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15890
15860
  to: to_5
15891
15861
  });
15892
15862
  if (commentDraftMode === "prosemirror") {
15893
- if (!applyCommentMarkRange(view_13, {
15863
+ if (!applyCommentMarkRange(view_12, {
15894
15864
  from: from_5,
15895
15865
  to: to_5
15896
15866
  }, -1, { selectEnd: true })) break;
@@ -15902,30 +15872,30 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15902
15872
  break;
15903
15873
  }
15904
15874
  case "acceptChange": {
15905
- const { from: from_4, to: to_4 } = view_13.state.selection;
15906
- const range_0 = findChangeAtPosition(view_13.state, from_4, to_4);
15875
+ const { from: from_4, to: to_4 } = view_12.state.selection;
15876
+ const range_0 = findChangeAtPosition(view_12.state, from_4, to_4);
15907
15877
  if (resolveCanonicalReviewRange({
15908
15878
  editor: pagedEditorRef.current?.getEditor(),
15909
15879
  ...range_0,
15910
15880
  resolution: "accept"
15911
- }) === null) acceptChange(range_0.from, range_0.to)(view_13.state, view_13.dispatch);
15881
+ }) === null) acceptChange(range_0.from, range_0.to)(view_12.state, view_12.dispatch);
15912
15882
  break;
15913
15883
  }
15914
15884
  case "rejectChange": {
15915
- const { from: from_3, to: to_3 } = view_13.state.selection;
15916
- const range = findChangeAtPosition(view_13.state, from_3, to_3);
15885
+ const { from: from_3, to: to_3 } = view_12.state.selection;
15886
+ const range = findChangeAtPosition(view_12.state, from_3, to_3);
15917
15887
  if (resolveCanonicalReviewRange({
15918
15888
  editor: pagedEditorRef.current?.getEditor(),
15919
15889
  ...range,
15920
15890
  resolution: "reject"
15921
- }) === null) rejectChange(range.from, range.to)(view_13.state, view_13.dispatch);
15891
+ }) === null) rejectChange(range.from, range.to)(view_12.state, view_12.dispatch);
15922
15892
  break;
15923
15893
  }
15924
15894
  case "restartNumbering":
15925
- restartNumbering(view_13.state, view_13.dispatch);
15895
+ restartNumbering(view_12.state, view_12.dispatch);
15926
15896
  break;
15927
15897
  case "continueNumbering":
15928
- continueNumbering(view_13.state, view_13.dispatch);
15898
+ continueNumbering(view_12.state, view_12.dispatch);
15929
15899
  break;
15930
15900
  case "setNumberingValue": setNumberingValueDialogOpen(true);
15931
15901
  }
@@ -15982,25 +15952,25 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
15982
15952
  const handleTopMarginChange = useCallback((twips_1) => handlePageSetupApply({ marginTop: twips_1 }), [handlePageSetupApply]);
15983
15953
  const handleBottomMarginChange = useCallback((twips_2) => handlePageSetupApply({ marginBottom: twips_2 }), [handlePageSetupApply]);
15984
15954
  const handleIndentLeftChange = useCallback((twips_3) => {
15955
+ const view_13 = getActiveEditorView();
15956
+ if (!view_13) return;
15957
+ setIndentLeft(twips_3)(view_13.state, view_13.dispatch);
15958
+ }, [getActiveEditorView]);
15959
+ const handleIndentRightChange = useCallback((twips_4) => {
15985
15960
  const view_14 = getActiveEditorView();
15986
15961
  if (!view_14) return;
15987
- setIndentLeft(twips_3)(view_14.state, view_14.dispatch);
15962
+ setIndentRight(twips_4)(view_14.state, view_14.dispatch);
15988
15963
  }, [getActiveEditorView]);
15989
- const handleIndentRightChange = useCallback((twips_4) => {
15964
+ const handleFirstLineIndentChange = useCallback((twips_5) => {
15990
15965
  const view_15 = getActiveEditorView();
15991
15966
  if (!view_15) return;
15992
- setIndentRight(twips_4)(view_15.state, view_15.dispatch);
15967
+ if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_15.state, view_15.dispatch);
15968
+ else setIndentFirstLine(twips_5, false)(view_15.state, view_15.dispatch);
15993
15969
  }, [getActiveEditorView]);
15994
- const handleFirstLineIndentChange = useCallback((twips_5) => {
15970
+ const handleTabStopRemove = useCallback((positionTwips) => {
15995
15971
  const view_16 = getActiveEditorView();
15996
15972
  if (!view_16) return;
15997
- if (twips_5 < 0) setIndentFirstLine(-twips_5, true)(view_16.state, view_16.dispatch);
15998
- else setIndentFirstLine(twips_5, false)(view_16.state, view_16.dispatch);
15999
- }, [getActiveEditorView]);
16000
- const handleTabStopRemove = useCallback((positionTwips) => {
16001
- const view_17 = getActiveEditorView();
16002
- if (!view_17) return;
16003
- removeTabStop(positionTwips)(view_17.state, view_17.dispatch);
15973
+ removeTabStop(positionTwips)(view_16.state, view_16.dispatch);
16004
15974
  }, [getActiveEditorView]);
16005
15975
  const serializeCurrentDocx = useCallback(async (options) => {
16006
15976
  let tripwireResult = null;
@@ -16009,8 +15979,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16009
15979
  const editor_2 = pagedEditorRef.current?.getEditor();
16010
15980
  const snapshot_0 = editor_2?.captureCanonicalSave();
16011
15981
  if (snapshot_0 && editor_2) {
16012
- const view_18 = editor_2.getView();
16013
- const editorState = view_18?.state;
15982
+ const view_17 = editor_2.getView();
15983
+ const editorState = view_17?.state;
16014
15984
  const result_2 = await serializeCanonicalSave({
16015
15985
  snapshot: snapshot_0,
16016
15986
  options,
@@ -16022,12 +15992,12 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16022
15992
  message: `Canonical save used a fidelity fallback: ${diagnostic.type} (${diagnostic.part}).`
16023
15993
  }));
16024
15994
  tripwireResult = result_2.tripwireResult;
16025
- if (view_18 && pagedEditorRef.current?.getEditor() === editor_2 && editor_2.getView() === view_18 && view_18.state.doc === editorState?.doc && editor_2.isCanonicalSaveCurrent(snapshot_0.version)) view_18.dispatch(clearTrackedChanges(view_18.state));
15995
+ if (view_17 && pagedEditorRef.current?.getEditor() === editor_2 && editor_2.getView() === view_17 && view_17.state.doc === editorState?.doc && editor_2.isCanonicalSaveCurrent(snapshot_0.version)) view_17.dispatch(clearTrackedChanges(view_17.state));
16026
15996
  savedBuffer = result_2.buffer;
16027
15997
  } else {
16028
15998
  if (usesCanonicalSession(experimentalSession, CANONICAL_GAP.save)) return null;
16029
- const view_19 = pagedEditorRef.current?.getView();
16030
- const editorState_0 = view_19?.state;
15999
+ const view_18 = pagedEditorRef.current?.getView();
16000
+ const editorState_0 = view_18?.state;
16031
16001
  const baselineBuffer = originalBufferRef.current;
16032
16002
  const current = buildCurrentDocument();
16033
16003
  const doc_1 = current ? withoutUnreferencedNotes(current) : null;
@@ -16068,9 +16038,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16068
16038
  const { compareSelectiveVsFull } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
16069
16039
  tripwireResult = await compareSelectiveVsFull(selectiveBuffer, fullBuffer);
16070
16040
  } catch {}
16071
- if (view_19 && pagedEditorRef.current?.getView() === view_19 && view_19.state.doc === editorState_0?.doc) {
16041
+ if (view_18 && pagedEditorRef.current?.getView() === view_18 && view_18.state.doc === editorState_0?.doc) {
16072
16042
  originalBufferRef.current = buffer;
16073
- view_19.dispatch(clearTrackedChanges(view_19.state));
16043
+ view_18.dispatch(clearTrackedChanges(view_18.state));
16074
16044
  }
16075
16045
  savedBuffer = buffer;
16076
16046
  }
@@ -16126,9 +16096,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16126
16096
  getFindResult,
16127
16097
  clearFind: resetFindResult,
16128
16098
  hasPendingChanges: () => {
16129
- const view_20 = pagedEditorRef.current?.getView();
16130
- if (!view_20) return false;
16131
- return getCommentsDirty() || getChangedParagraphIds(view_20.state).size > 0 || hasStructuralChanges(view_20.state) || hasUntrackedChanges(view_20.state);
16099
+ const view_19 = pagedEditorRef.current?.getView();
16100
+ if (!view_19) return false;
16101
+ return getCommentsDirty() || getChangedParagraphIds(view_19.state).size > 0 || hasStructuralChanges(view_19.state) || hasUntrackedChanges(view_19.state);
16132
16102
  },
16133
16103
  getEditorRef: () => pagedEditorRef.current,
16134
16104
  getEditor: () => pagedEditorRef.current?.getEditor() ?? null,
@@ -16173,13 +16143,13 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16173
16143
  pagedEditorRef.current?.ensureView(options_3);
16174
16144
  },
16175
16145
  createAIEditSnapshot: () => {
16176
- const view_21 = pagedEditorRef.current?.getView();
16177
- return view_21 ? createFolioAIEditSnapshot(view_21.state.doc) : null;
16146
+ const view_20 = pagedEditorRef.current?.getView();
16147
+ return view_20 ? createFolioAIEditSnapshot(view_20.state.doc) : null;
16178
16148
  },
16179
16149
  applyDocumentOperations: ({ undefinedReferences, snapshot: snapshot_1, batch, author: operationAuthor = author }) => {
16180
16150
  assertSupportedFolioDocumentOperationVersion(batch.version);
16181
- const view_22 = pagedEditorRef.current?.getView();
16182
- if (!view_22) {
16151
+ const view_21 = pagedEditorRef.current?.getView();
16152
+ if (!view_21) {
16183
16153
  let status = "committed";
16184
16154
  if (batch.dryRun === true) status = "previewed";
16185
16155
  else if (batch.atomic === true) status = "rejected";
@@ -16205,17 +16175,17 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16205
16175
  });
16206
16176
  if (canonical_1) return canonical_1;
16207
16177
  const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
16208
- if (existingUndoEntry && (!view_22.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentsRef.current) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
16178
+ if (existingUndoEntry && (!view_21.state.doc.eq(existingUndoEntry.afterState.doc) || canonicalJson(commentsRef.current) !== existingUndoEntry.commentsAfterJson)) documentOperationUndoEntriesRef.current.length = 0;
16209
16179
  const commentsBefore = commentsRef.current;
16210
16180
  const createdComments = [];
16211
16181
  const operationView = {
16212
- state: view_22.state,
16182
+ state: view_21.state,
16213
16183
  dispatch: (transaction) => {
16214
- view_22.dispatch(closeHistory(transaction));
16215
- operationView.state = view_22.state;
16184
+ view_21.dispatch(closeHistory(transaction));
16185
+ operationView.state = view_21.state;
16216
16186
  }
16217
16187
  };
16218
- const activeSuggestionIds = new Set(getSuggestions(view_22.state).map((s_0) => s_0.suggestionId));
16188
+ const activeSuggestionIds = new Set(getSuggestions(view_21.state).map((s_0) => s_0.suggestionId));
16219
16189
  const result_3 = applyFolioDocumentOperations({
16220
16190
  undefinedReferences,
16221
16191
  view: operationView,
@@ -16245,7 +16215,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16245
16215
  if (batchComments.length > 0) replaceComments(commentsAfter);
16246
16216
  if (result_3.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
16247
16217
  undoHandle: result_3.undoHandle,
16248
- afterState: view_22.state,
16218
+ afterState: view_21.state,
16249
16219
  commentsBefore,
16250
16220
  commentsAfterJson: canonicalJson(commentsAfter)
16251
16221
  });
@@ -16267,18 +16237,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16267
16237
  reason: "notLatest"
16268
16238
  };
16269
16239
  const entry_3 = entries_0.at(-1);
16270
- const view_23 = pagedEditorRef.current?.getView();
16271
- if (!entry_3 || !view_23) return {
16240
+ const view_22 = pagedEditorRef.current?.getView();
16241
+ if (!entry_3 || !view_22) return {
16272
16242
  status: "rejected",
16273
16243
  undoHandle,
16274
16244
  reason: "unknownHandle"
16275
16245
  };
16276
- if (!view_23.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentsRef.current) !== entry_3.commentsAfterJson) return {
16246
+ if (!view_22.state.doc.eq(entry_3.afterState.doc) || canonicalJson(commentsRef.current) !== entry_3.commentsAfterJson) return {
16277
16247
  status: "rejected",
16278
16248
  undoHandle,
16279
16249
  reason: "documentChanged"
16280
16250
  };
16281
- if (!undo(view_23.state, view_23.dispatch)) return {
16251
+ if (!undo(view_22.state, view_22.dispatch)) return {
16282
16252
  status: "rejected",
16283
16253
  undoHandle,
16284
16254
  reason: "documentChanged"
@@ -16292,8 +16262,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16292
16262
  };
16293
16263
  },
16294
16264
  applyAIEditOperations: ({ undefinedReferences: undefinedReferences_0, snapshot: snapshot_2, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
16295
- const view_24 = pagedEditorRef.current?.getView();
16296
- if (!view_24) return {
16265
+ const view_23 = pagedEditorRef.current?.getView();
16266
+ if (!view_23) return {
16297
16267
  applied: [],
16298
16268
  skipped: operations.map((operation_0) => ({
16299
16269
  id: operation_0.id,
@@ -16312,10 +16282,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16312
16282
  });
16313
16283
  if (canonical_3) return canonical_3;
16314
16284
  const createdComments_0 = [];
16315
- const activeSuggestionIds_0 = new Set(getSuggestions(view_24.state).map((s_1) => s_1.suggestionId));
16285
+ const activeSuggestionIds_0 = new Set(getSuggestions(view_23.state).map((s_1) => s_1.suggestionId));
16316
16286
  const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
16317
16287
  undefinedReferences: undefinedReferences_0,
16318
- view: view_24,
16288
+ view: view_23,
16319
16289
  snapshot: snapshot_2,
16320
16290
  batch: {
16321
16291
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
@@ -16345,18 +16315,18 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16345
16315
  };
16346
16316
  },
16347
16317
  acceptAIEditOperation: (revisionId) => {
16348
- const view_25 = pagedEditorRef.current?.getView();
16349
- if (!view_25) return false;
16318
+ const view_24 = pagedEditorRef.current?.getView();
16319
+ if (!view_24) return false;
16350
16320
  const editor_5 = pagedEditorRef.current?.getEditor();
16351
16321
  if (editor_5?.getCanonicalDocument()) return editor_5.resolveCanonicalRevisions(typeof revisionId === "number" ? [revisionId] : revisionId, "accept");
16352
- return acceptAIEditRevision(revisionId)(view_25.state, view_25.dispatch);
16322
+ return acceptAIEditRevision(revisionId)(view_24.state, view_24.dispatch);
16353
16323
  },
16354
16324
  rejectAIEditOperation: (revisionId_0) => {
16355
- const view_26 = pagedEditorRef.current?.getView();
16356
- if (!view_26) return false;
16325
+ const view_25 = pagedEditorRef.current?.getView();
16326
+ if (!view_25) return false;
16357
16327
  const editor_6 = pagedEditorRef.current?.getEditor();
16358
16328
  if (editor_6?.getCanonicalDocument()) return editor_6.resolveCanonicalRevisions(typeof revisionId_0 === "number" ? [revisionId_0] : revisionId_0, "reject");
16359
- return rejectAIEditRevision(revisionId_0)(view_26.state, view_26.dispatch);
16329
+ return rejectAIEditRevision(revisionId_0)(view_25.state, view_25.dispatch);
16360
16330
  },
16361
16331
  undo: () => {
16362
16332
  if (!usesCanonicalSession(experimentalSession, CANONICAL_GAP.authorityRouting) && getActiveEditorStory().type === "headerFooter" && hfEditorRef.current) return hfEditorRef.current.undo();
@@ -16371,44 +16341,44 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16371
16341
  return redone;
16372
16342
  },
16373
16343
  scrollToAIEditOperation: (revisionId_1) => {
16374
- const view_27 = pagedEditorRef.current?.getView();
16375
- if (!view_27) return false;
16376
- const range_1 = findAIEditRevisionRange(view_27.state, revisionId_1);
16344
+ const view_26 = pagedEditorRef.current?.getView();
16345
+ if (!view_26) return false;
16346
+ const range_1 = findAIEditRevisionRange(view_26.state, revisionId_1);
16377
16347
  if (!range_1) return false;
16378
- const { from: from_8, to: to_8 } = clampRangeToDocSize(view_27.state.doc.content.size, range_1);
16379
- const $from = view_27.state.doc.resolve(from_8);
16380
- const $to = view_27.state.doc.resolve(to_8);
16381
- view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from, $to)));
16348
+ const { from: from_8, to: to_8 } = clampRangeToDocSize(view_26.state.doc.content.size, range_1);
16349
+ const $from = view_26.state.doc.resolve(from_8);
16350
+ const $to = view_26.state.doc.resolve(to_8);
16351
+ view_26.dispatch(view_26.state.tr.setSelection(TextSelection.between($from, $to)));
16382
16352
  requestAnimationFrame(() => {
16383
16353
  pagedEditorRef.current?.scrollToPosition(from_8);
16384
16354
  });
16385
16355
  return true;
16386
16356
  },
16387
16357
  scrollToBlock: (blockId, snapshot_3) => {
16388
- const view_28 = pagedEditorRef.current?.getView();
16389
- if (!view_28) return false;
16358
+ const view_27 = pagedEditorRef.current?.getView();
16359
+ if (!view_27) return false;
16390
16360
  const range_2 = resolveFolioAIBlockRange({
16391
16361
  blockId,
16392
- doc: view_28.state.doc,
16362
+ doc: view_27.state.doc,
16393
16363
  snapshot: snapshot_3
16394
16364
  });
16395
16365
  if (range_2 === null) return false;
16396
16366
  const { from: from_9, to: to_9 } = range_2;
16397
- const $from_0 = view_28.state.doc.resolve(from_9);
16398
- const $to_0 = view_28.state.doc.resolve(to_9);
16399
- view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
16367
+ const $from_0 = view_27.state.doc.resolve(from_9);
16368
+ const $to_0 = view_27.state.doc.resolve(to_9);
16369
+ view_27.dispatch(view_27.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
16400
16370
  requestAnimationFrame(() => {
16401
16371
  pagedEditorRef.current?.scrollToPosition(from_9);
16402
16372
  });
16403
16373
  return true;
16404
16374
  },
16405
16375
  highlightPassage: ({ blockId: blockId_0, text: text_5, snapshot: snapshot_4 }) => {
16406
- const view_29 = pagedEditorRef.current?.getView();
16407
- if (!view_29) return "none";
16376
+ const view_28 = pagedEditorRef.current?.getView();
16377
+ if (!view_28) return "none";
16408
16378
  const passageRange = resolvePassageRange({
16409
16379
  blockId: blockId_0,
16410
16380
  text: text_5,
16411
- doc: view_29.state.doc,
16381
+ doc: view_28.state.doc,
16412
16382
  snapshot: snapshot_4
16413
16383
  });
16414
16384
  if (passageRange !== null) {
@@ -16421,16 +16391,16 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16421
16391
  pagedEditorRef.current?.setPassageHighlight(null);
16422
16392
  const blockRange = resolveFolioAIBlockRange({
16423
16393
  blockId: blockId_0,
16424
- doc: view_29.state.doc,
16394
+ doc: view_28.state.doc,
16425
16395
  snapshot: snapshot_4
16426
16396
  });
16427
16397
  if (blockRange === null) return "none";
16428
16398
  const paraId_0 = getFolioParaIdFromBlockId(blockId_0);
16429
16399
  if (paraId_0 !== null && pagedEditorRef.current?.scrollToParaId(paraId_0, { highlight: {} })) return "block";
16430
16400
  const { from: from_10, to: to_10 } = blockRange;
16431
- const $from_1 = view_29.state.doc.resolve(from_10);
16432
- const $to_1 = view_29.state.doc.resolve(to_10);
16433
- view_29.dispatch(view_29.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
16401
+ const $from_1 = view_28.state.doc.resolve(from_10);
16402
+ const $to_1 = view_28.state.doc.resolve(to_10);
16403
+ view_28.dispatch(view_28.state.tr.setSelection(TextSelection.between($from_1, $to_1)));
16434
16404
  requestAnimationFrame(() => {
16435
16405
  pagedEditorRef.current?.scrollToPosition(from_10);
16436
16406
  });
@@ -16440,52 +16410,52 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16440
16410
  pagedEditorRef.current?.setPassageHighlight(null);
16441
16411
  },
16442
16412
  showInDocument: (target_1, snapshot_5) => {
16443
- const view_30 = pagedEditorRef.current?.getView();
16444
- if (!view_30) return false;
16413
+ const view_29 = pagedEditorRef.current?.getView();
16414
+ if (!view_29) return false;
16445
16415
  const range_3 = target_1.type === "textRange" ? resolveFolioAITextRange({
16446
16416
  range: target_1,
16447
- doc: view_30.state.doc,
16417
+ doc: view_29.state.doc,
16448
16418
  snapshot: snapshot_5
16449
16419
  }) : resolveFolioAIBlockRange({
16450
16420
  blockId: target_1.blockId,
16451
- doc: view_30.state.doc,
16421
+ doc: view_29.state.doc,
16452
16422
  snapshot: snapshot_5
16453
16423
  });
16454
16424
  if (range_3 === null) return false;
16455
16425
  const { from: from_11, to: to_11 } = range_3;
16456
- const $from_2 = view_30.state.doc.resolve(from_11);
16457
- const $to_2 = view_30.state.doc.resolve(to_11);
16458
- view_30.dispatch(view_30.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
16426
+ const $from_2 = view_29.state.doc.resolve(from_11);
16427
+ const $to_2 = view_29.state.doc.resolve(to_11);
16428
+ view_29.dispatch(view_29.state.tr.setSelection(TextSelection.between($from_2, $to_2)));
16459
16429
  requestAnimationFrame(() => {
16460
16430
  pagedEditorRef.current?.scrollToPosition(from_11);
16461
16431
  });
16462
16432
  return true;
16463
16433
  },
16464
16434
  getSuggestions: () => {
16465
- const view_31 = pagedEditorRef.current?.getView();
16466
- return view_31 ? getSuggestions(view_31.state) : [];
16435
+ const view_30 = pagedEditorRef.current?.getView();
16436
+ return view_30 ? getSuggestions(view_30.state) : [];
16467
16437
  },
16468
16438
  exportPendingSuggestions: () => {
16469
- const view_32 = pagedEditorRef.current?.getView();
16470
- const activeIds = new Set(view_32 ? getSuggestions(view_32.state).map((s_2) => s_2.suggestionId) : []);
16439
+ const view_31 = pagedEditorRef.current?.getView();
16440
+ const activeIds = new Set(view_31 ? getSuggestions(view_31.state).map((s_2) => s_2.suggestionId) : []);
16471
16441
  return pendingSuggestionRegistryRef.current.exportPendingSuggestions({
16472
16442
  activeSuggestionIds: activeIds,
16473
- snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_32 ? createPendingSuggestionSourceSnapshot(view_32.state, commentIds) : null
16443
+ snapshotForStory: (story_0, commentIds) => story_0.type === "main" && view_31 ? createPendingSuggestionSourceSnapshot(view_31.state, commentIds) : null
16474
16444
  });
16475
16445
  },
16476
16446
  loadPendingSuggestions: (records) => pendingSuggestionRegistryRef.current.loadPendingSuggestions({
16477
16447
  records,
16478
16448
  snapshotForStory: (story_1) => {
16479
- const view_33 = pagedEditorRef.current?.getView();
16480
- return story_1.type === "main" && view_33 ? createFolioAIEditSnapshot(view_33.state.doc) : null;
16449
+ const view_32 = pagedEditorRef.current?.getView();
16450
+ return story_1.type === "main" && view_32 ? createFolioAIEditSnapshot(view_32.state.doc) : null;
16481
16451
  },
16482
16452
  sourceSnapshotForStory: (story_2, commentIds_0) => {
16483
- const view_34 = pagedEditorRef.current?.getView();
16484
- return story_2.type === "main" && view_34 ? createPendingSuggestionSourceSnapshot(view_34.state, commentIds_0) : null;
16453
+ const view_33 = pagedEditorRef.current?.getView();
16454
+ return story_2.type === "main" && view_33 ? createPendingSuggestionSourceSnapshot(view_33.state, commentIds_0) : null;
16485
16455
  },
16486
16456
  apply: (record, snapshot_6) => {
16487
- const view_35 = pagedEditorRef.current?.getView();
16488
- if (!view_35) return {
16457
+ const view_34 = pagedEditorRef.current?.getView();
16458
+ if (!view_34) return {
16489
16459
  applied: [],
16490
16460
  skipped: []
16491
16461
  };
@@ -16503,7 +16473,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16503
16473
  const createdComments_1 = [];
16504
16474
  const result_4 = applyFolioDocumentOperations({
16505
16475
  undefinedReferences: "refuse",
16506
- view: view_35,
16476
+ view: view_34,
16507
16477
  snapshot: snapshot_6,
16508
16478
  batch: {
16509
16479
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
@@ -16525,75 +16495,75 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16525
16495
  };
16526
16496
  },
16527
16497
  activeSuggestionIds: () => {
16528
- const view_36 = pagedEditorRef.current?.getView();
16529
- return new Set(view_36 ? getSuggestions(view_36.state).map((s_3) => s_3.suggestionId) : []);
16498
+ const view_35 = pagedEditorRef.current?.getView();
16499
+ return new Set(view_35 ? getSuggestions(view_35.state).map((s_3) => s_3.suggestionId) : []);
16530
16500
  }
16531
16501
  }),
16532
16502
  acceptSuggestion: (suggestionId, options_4) => {
16533
- const view_37 = pagedEditorRef.current?.getView();
16534
- if (!view_37) return {
16503
+ const view_36 = pagedEditorRef.current?.getView();
16504
+ if (!view_36) return {
16535
16505
  accepted: false,
16536
16506
  appliedAs: null
16537
16507
  };
16538
- const appliedAs = getSuggestions(view_37.state).find((s_4) => s_4.suggestionId === suggestionId)?.appliedAs ?? null;
16539
- const accepted = acceptSuggestion(suggestionId, { author: options_4?.author ?? author })(view_37.state, view_37.dispatch);
16508
+ const appliedAs = getSuggestions(view_36.state).find((s_4) => s_4.suggestionId === suggestionId)?.appliedAs ?? null;
16509
+ const accepted = acceptSuggestion(suggestionId, { author: options_4?.author ?? author })(view_36.state, view_36.dispatch);
16540
16510
  return {
16541
16511
  accepted,
16542
16512
  appliedAs: accepted ? appliedAs : null
16543
16513
  };
16544
16514
  },
16545
16515
  rejectSuggestion: (suggestionId_0) => {
16546
- const view_38 = pagedEditorRef.current?.getView();
16547
- if (!view_38) return false;
16548
- return rejectSuggestion(suggestionId_0)(view_38.state, view_38.dispatch);
16516
+ const view_37 = pagedEditorRef.current?.getView();
16517
+ if (!view_37) return false;
16518
+ return rejectSuggestion(suggestionId_0)(view_37.state, view_37.dispatch);
16549
16519
  },
16550
16520
  scrollToSuggestion: (suggestionId_1) => {
16551
- const view_39 = pagedEditorRef.current?.getView();
16552
- if (!view_39) return false;
16553
- const range_4 = findSuggestionRange(view_39.state, suggestionId_1);
16521
+ const view_38 = pagedEditorRef.current?.getView();
16522
+ if (!view_38) return false;
16523
+ const range_4 = findSuggestionRange(view_38.state, suggestionId_1);
16554
16524
  if (!range_4) return false;
16555
- const { from: from_12, to: to_12 } = clampRangeToDocSize(view_39.state.doc.content.size, range_4);
16556
- const $from_3 = view_39.state.doc.resolve(from_12);
16557
- const $to_3 = view_39.state.doc.resolve(to_12);
16558
- view_39.dispatch(view_39.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
16525
+ const { from: from_12, to: to_12 } = clampRangeToDocSize(view_38.state.doc.content.size, range_4);
16526
+ const $from_3 = view_38.state.doc.resolve(from_12);
16527
+ const $to_3 = view_38.state.doc.resolve(to_12);
16528
+ view_38.dispatch(view_38.state.tr.setSelection(TextSelection.between($from_3, $to_3)));
16559
16529
  requestAnimationFrame(() => {
16560
16530
  pagedEditorRef.current?.scrollToPosition(from_12);
16561
16531
  });
16562
16532
  return true;
16563
16533
  },
16564
16534
  getTrackedChanges: () => {
16565
- const view_40 = pagedEditorRef.current?.getView();
16566
- return view_40 ? getTrackedChangesFromDoc(view_40.state.doc) : [];
16535
+ const view_39 = pagedEditorRef.current?.getView();
16536
+ return view_39 ? getTrackedChangesFromDoc(view_39.state.doc) : [];
16567
16537
  },
16568
16538
  getCommentAnchors: () => {
16569
- const view_41 = pagedEditorRef.current?.getView();
16570
- return view_41 ? getCommentAnchorsFromDoc(view_41.state.doc) : [];
16539
+ const view_40 = pagedEditorRef.current?.getView();
16540
+ return view_40 ? getCommentAnchorsFromDoc(view_40.state.doc) : [];
16571
16541
  },
16572
16542
  getSelectionText: () => {
16573
- const view_42 = pagedEditorRef.current?.getView();
16574
- return view_42 ? getSelectedText(view_42.state) : "";
16543
+ const view_41 = pagedEditorRef.current?.getView();
16544
+ return view_41 ? getSelectedText(view_41.state) : "";
16575
16545
  },
16576
- getPageText: (page_1) => {
16577
- const view_43 = pagedEditorRef.current?.getView();
16578
- if (!view_43) return null;
16579
- const layout = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
16546
+ getPageText: (page_0) => {
16547
+ const view_42 = pagedEditorRef.current?.getView();
16548
+ if (!view_42) return null;
16549
+ const layout_0 = pagedEditorRef.current?.getEditor()?.getLayout() ?? null;
16580
16550
  return getPageTextFromLayout({
16581
- layout,
16582
- doc: view_43.state.doc,
16583
- page: page_1,
16584
- projection: projectMarkupView(view_43.state, displayMode)
16551
+ layout: layout_0,
16552
+ doc: view_42.state.doc,
16553
+ page: page_0,
16554
+ projection: projectMarkupView(view_42.state, displayMode)
16585
16555
  });
16586
16556
  },
16587
16557
  getTargetPage: (target_2, snapshot_7) => {
16588
- const view_44 = pagedEditorRef.current?.getView();
16589
- if (!view_44) return null;
16558
+ const view_43 = pagedEditorRef.current?.getView();
16559
+ if (!view_43) return null;
16590
16560
  const range_5 = target_2.type === "textRange" ? resolveFolioAITextRange({
16591
16561
  range: target_2,
16592
- doc: view_44.state.doc,
16562
+ doc: view_43.state.doc,
16593
16563
  snapshot: snapshot_7
16594
16564
  }) : resolveFolioAIBlockRange({
16595
16565
  blockId: target_2.blockId,
16596
- doc: view_44.state.doc,
16566
+ doc: view_43.state.doc,
16597
16567
  snapshot: snapshot_7
16598
16568
  });
16599
16569
  if (range_5 === null) return null;
@@ -16604,49 +16574,49 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16604
16574
  getScrollRoot: () => pagedEditorRef.current?.getScrollRoot() ?? null,
16605
16575
  onLayoutChange: (listener) => pagedEditorRef.current?.onLayoutChange(listener) ?? (() => {}),
16606
16576
  getContentControls: (filter = {}) => {
16607
- const view_45 = pagedEditorRef.current?.getView();
16608
- if (!view_45) return [];
16609
- return findBlockSdtMatches(view_45.state.doc, filter).map((match_0) => ({
16577
+ const view_44 = pagedEditorRef.current?.getView();
16578
+ if (!view_44) return [];
16579
+ return findBlockSdtMatches(view_44.state.doc, filter).map((match_0) => ({
16610
16580
  properties: blockSdtAttrsToSdtProperties(match_0.node),
16611
16581
  path: match_0.path,
16612
16582
  pmPos: match_0.pos
16613
16583
  }));
16614
16584
  },
16615
16585
  scrollToContentControl: (filter_0) => {
16616
- const view_46 = pagedEditorRef.current?.getView();
16617
- if (!view_46) return false;
16618
- const match_1 = findBlockSdtMatch(view_46.state.doc, filter_0);
16586
+ const view_45 = pagedEditorRef.current?.getView();
16587
+ if (!view_45) return false;
16588
+ const match_1 = findBlockSdtMatch(view_45.state.doc, filter_0);
16619
16589
  if (!match_1) return false;
16620
16590
  const inside = match_1.pos + 1;
16621
- const $pos = view_46.state.doc.resolve(inside);
16622
- view_46.dispatch(view_46.state.tr.setSelection(TextSelection.near($pos)));
16591
+ const $pos = view_45.state.doc.resolve(inside);
16592
+ view_45.dispatch(view_45.state.tr.setSelection(TextSelection.near($pos)));
16623
16593
  requestAnimationFrame(() => {
16624
16594
  pagedEditorRef.current?.scrollToPosition(inside);
16625
16595
  });
16626
16596
  return true;
16627
16597
  },
16628
16598
  setContentControlContent: (filter_1, input, options_5 = {}) => {
16629
- const view_47 = pagedEditorRef.current?.getView();
16630
- if (!view_47) return false;
16631
- const tr_0 = typeof input === "string" ? setContentControlContentTr(view_47.state, filter_1, input, options_5) : setContentControlContentBlocksTr(view_47.state, filter_1, input, options_5);
16599
+ const view_46 = pagedEditorRef.current?.getView();
16600
+ if (!view_46) return false;
16601
+ const tr_0 = typeof input === "string" ? setContentControlContentTr(view_46.state, filter_1, input, options_5) : setContentControlContentBlocksTr(view_46.state, filter_1, input, options_5);
16632
16602
  if (!tr_0) return false;
16633
- view_47.dispatch(tr_0);
16603
+ view_46.dispatch(tr_0);
16634
16604
  return true;
16635
16605
  },
16636
16606
  setContentControlValue: (filter_2, input_0, options_6 = {}) => {
16637
- const view_48 = pagedEditorRef.current?.getView();
16638
- if (!view_48) return false;
16639
- const tr_1 = setContentControlValueTr(view_48.state, filter_2, input_0, options_6);
16607
+ const view_47 = pagedEditorRef.current?.getView();
16608
+ if (!view_47) return false;
16609
+ const tr_1 = setContentControlValueTr(view_47.state, filter_2, input_0, options_6);
16640
16610
  if (!tr_1) return false;
16641
- view_48.dispatch(tr_1);
16611
+ view_47.dispatch(tr_1);
16642
16612
  return true;
16643
16613
  },
16644
16614
  removeContentControl: (filter_3, options_7 = {}) => {
16645
- const view_49 = pagedEditorRef.current?.getView();
16646
- if (!view_49) return false;
16647
- const tr_2 = removeContentControlTr(view_49.state, filter_3, options_7);
16615
+ const view_48 = pagedEditorRef.current?.getView();
16616
+ if (!view_48) return false;
16617
+ const tr_2 = removeContentControlTr(view_48.state, filter_3, options_7);
16648
16618
  if (!tr_2) return false;
16649
- view_49.dispatch(tr_2);
16619
+ view_48.dispatch(tr_2);
16650
16620
  return true;
16651
16621
  }
16652
16622
  }), [
@@ -16739,47 +16709,47 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16739
16709
  if (isDisplayMode(value)) setDisplayMode(value);
16740
16710
  }, [setDisplayMode]);
16741
16711
  const handleAcceptActiveChange = useCallback(() => {
16742
- const view_50 = pagedEditorRef.current?.getView();
16743
- if (!view_50) return;
16744
- const { from: from_13, to: to_13 } = view_50.state.selection;
16745
- const range_6 = findChangeAtPosition(view_50.state, from_13, to_13);
16712
+ const view_49 = pagedEditorRef.current?.getView();
16713
+ if (!view_49) return;
16714
+ const { from: from_13, to: to_13 } = view_49.state.selection;
16715
+ const range_6 = findChangeAtPosition(view_49.state, from_13, to_13);
16746
16716
  if (resolveCanonicalReviewRange({
16747
16717
  editor: pagedEditorRef.current?.getEditor(),
16748
16718
  ...range_6,
16749
16719
  resolution: "accept"
16750
- }) === null) acceptChange(range_6.from, range_6.to)(view_50.state, view_50.dispatch);
16720
+ }) === null) acceptChange(range_6.from, range_6.to)(view_49.state, view_49.dispatch);
16751
16721
  }, []);
16752
16722
  const handleRejectActiveChange = useCallback(() => {
16753
- const view_51 = pagedEditorRef.current?.getView();
16754
- if (!view_51) return;
16755
- const { from: from_14, to: to_14 } = view_51.state.selection;
16756
- const range_7 = findChangeAtPosition(view_51.state, from_14, to_14);
16723
+ const view_50 = pagedEditorRef.current?.getView();
16724
+ if (!view_50) return;
16725
+ const { from: from_14, to: to_14 } = view_50.state.selection;
16726
+ const range_7 = findChangeAtPosition(view_50.state, from_14, to_14);
16757
16727
  if (resolveCanonicalReviewRange({
16758
16728
  editor: pagedEditorRef.current?.getEditor(),
16759
16729
  ...range_7,
16760
16730
  resolution: "reject"
16761
- }) === null) rejectChange(range_7.from, range_7.to)(view_51.state, view_51.dispatch);
16731
+ }) === null) rejectChange(range_7.from, range_7.to)(view_50.state, view_50.dispatch);
16762
16732
  }, []);
16763
16733
  const handlePreviousChange = useCallback(() => {
16764
- const view_52 = pagedEditorRef.current?.getView();
16765
- if (!view_52) return;
16766
- const { from: from_15 } = view_52.state.selection;
16767
- const change = findPreviousChange(view_52.state, from_15);
16734
+ const view_51 = pagedEditorRef.current?.getView();
16735
+ if (!view_51) return;
16736
+ const { from: from_15 } = view_51.state.selection;
16737
+ const change = findPreviousChange(view_51.state, from_15);
16768
16738
  if (!change) return;
16769
- view_52.dispatch(view_52.state.tr.setSelection(TextSelection.create(view_52.state.doc, change.from, change.to)));
16770
- view_52.focus();
16739
+ view_51.dispatch(view_51.state.tr.setSelection(TextSelection.create(view_51.state.doc, change.from, change.to)));
16740
+ view_51.focus();
16771
16741
  requestAnimationFrame(() => {
16772
16742
  pagedEditorRef.current?.scrollToPosition(change.from);
16773
16743
  });
16774
16744
  }, []);
16775
16745
  const handleNextChange = useCallback(() => {
16776
- const view_53 = pagedEditorRef.current?.getView();
16777
- if (!view_53) return;
16778
- const { to: to_15 } = view_53.state.selection;
16779
- const change_0 = findNextChange(view_53.state, to_15);
16746
+ const view_52 = pagedEditorRef.current?.getView();
16747
+ if (!view_52) return;
16748
+ const { to: to_15 } = view_52.state.selection;
16749
+ const change_0 = findNextChange(view_52.state, to_15);
16780
16750
  if (!change_0) return;
16781
- view_53.dispatch(view_53.state.tr.setSelection(TextSelection.create(view_53.state.doc, change_0.from, change_0.to)));
16782
- view_53.focus();
16751
+ view_52.dispatch(view_52.state.tr.setSelection(TextSelection.create(view_52.state.doc, change_0.from, change_0.to)));
16752
+ view_52.focus();
16783
16753
  requestAnimationFrame(() => {
16784
16754
  pagedEditorRef.current?.scrollToPosition(change_0.from);
16785
16755
  });
@@ -16949,11 +16919,11 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16949
16919
  requestAnimationFrame(syncCommentHighlightStyles);
16950
16920
  }, [onScrollTopChange, syncCommentHighlightStyles]);
16951
16921
  const handlePagedSelectionChange = useCallback((_from, _to) => {
16952
- const view_54 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
16953
- handleSelectionChange(view_54 ? extractSelectionState(view_54.state) : null);
16922
+ const view_53 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
16923
+ handleSelectionChange(view_53 ? extractSelectionState(view_53.state) : null);
16954
16924
  }, [getActiveEditorView, handleSelectionChange]);
16955
16925
  const handleTotalPagesChange = useCallback((totalPages) => {
16956
- setScrollPageInfo((previous) => updateScrollPageTotal(previous, totalPages));
16926
+ setScrollPageInfo((previous_0) => updateScrollPageTotal(previous_0, totalPages));
16957
16927
  }, [setScrollPageInfo]);
16958
16928
  const handleCommentClick = useCallback((id_0) => setActiveCommentId(id_0), [setActiveCommentId]);
16959
16929
  const handleCommentResolve = useCallback((id_1) => {
@@ -16962,7 +16932,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16962
16932
  id: id_1,
16963
16933
  status: "resolved"
16964
16934
  }) !== null) return;
16965
- updateComments((previous_0) => previous_0.map((comment_2) => comment_2.id === id_1 ? {
16935
+ updateComments((previous_1) => previous_1.map((comment_2) => comment_2.id === id_1 ? {
16966
16936
  ...comment_2,
16967
16937
  done: true
16968
16938
  } : comment_2));
@@ -16976,7 +16946,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16976
16946
  if (result_5.status === "applied" && activeCommentId === id_2) setActiveCommentId(null);
16977
16947
  return;
16978
16948
  }
16979
- updateComments((previous_1) => previous_1.filter((comment_3) => comment_3.id !== id_2 && comment_3.parentId !== id_2));
16949
+ updateComments((previous_2) => previous_2.filter((comment_3) => comment_3.id !== id_2 && comment_3.parentId !== id_2));
16980
16950
  if (activeCommentId === id_2) setActiveCommentId(null);
16981
16951
  }, [
16982
16952
  activeCommentId,
@@ -16994,7 +16964,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
16994
16964
  parentId: id_3
16995
16965
  }
16996
16966
  }) !== null) return;
16997
- updateComments((previous_2) => [...previous_2, createComment(text_6, author, id_3)]);
16967
+ updateComments((previous_3) => [...previous_3, createComment(text_6, author, id_3)]);
16998
16968
  }, [
16999
16969
  applyCanonicalComment,
17000
16970
  author,
@@ -17002,8 +16972,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17002
16972
  updateComments
17003
16973
  ]);
17004
16974
  const handleAddComment = useCallback((addText) => {
17005
- const view_55 = pagedEditorRef.current?.getView();
17006
- if (!view_55 || !commentSelectionRange) return false;
16975
+ const view_54 = pagedEditorRef.current?.getView();
16976
+ if (!view_54 || !commentSelectionRange) return false;
17007
16977
  const result_6 = applyCanonicalComment({
17008
16978
  type: "create",
17009
16979
  text: addText,
@@ -17030,7 +17000,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17030
17000
  return true;
17031
17001
  }
17032
17002
  const comment_4 = createComment(addText, author);
17033
- if (!applyCommentMarkRange(view_55, commentSelectionRange, comment_4.id, { replacePending: true })) return false;
17003
+ if (!applyCommentMarkRange(view_54, commentSelectionRange, comment_4.id, { replacePending: true })) return false;
17034
17004
  const commentAuthor_2 = getCommentAuthorKey(comment_4.author);
17035
17005
  setVisibleCommentAuthors((current_1) => {
17036
17006
  if (current_1 === null) return null;
@@ -17039,7 +17009,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17039
17009
  return next_2;
17040
17010
  });
17041
17011
  setActiveCommentId(comment_4.id);
17042
- updateComments((previous_3) => [...previous_3, comment_4]);
17012
+ updateComments((previous_4) => [...previous_4, comment_4]);
17043
17013
  pagedEditorRef.current?.relayout();
17044
17014
  requestAnimationFrame(() => {
17045
17015
  syncCommentHighlightStyles();
@@ -17073,7 +17043,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17073
17043
  revisionId: revisionId_2
17074
17044
  }
17075
17045
  }) !== null) return;
17076
- updateComments((previous_4) => [...previous_4, createComment(text_7, author, revisionId_2)]);
17046
+ updateComments((previous_5) => [...previous_5, createComment(text_7, author, revisionId_2)]);
17077
17047
  }, [
17078
17048
  applyCanonicalComment,
17079
17049
  author,
@@ -17081,8 +17051,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17081
17051
  updateComments
17082
17052
  ]);
17083
17053
  const handleCancelAddComment = useCallback(() => {
17084
- const view_56 = pagedEditorRef.current?.getView();
17085
- if (view_56 && commentSelectionRange && commentDraftMode === "prosemirror") removePendingCommentMarkRange(view_56, commentSelectionRange);
17054
+ const view_55 = pagedEditorRef.current?.getView();
17055
+ if (view_55 && commentSelectionRange && commentDraftMode === "prosemirror") removePendingCommentMarkRange(view_55, commentSelectionRange);
17086
17056
  setIsAddingComment(false);
17087
17057
  setCommentSelectionRange(null);
17088
17058
  setAddCommentYPosition(null);
@@ -17099,23 +17069,23 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17099
17069
  })?.revisionId ?? null;
17100
17070
  }, []);
17101
17071
  const handleSidebarAcceptChange = useCallback((from_17, to_17) => {
17102
- const view_57 = pagedEditorRef.current?.getView();
17103
- if (!view_57) return;
17072
+ const view_56 = pagedEditorRef.current?.getView();
17073
+ if (!view_56) return;
17104
17074
  const revisionId_3 = resolveSidebarChangeRevisionId(from_17, to_17);
17105
17075
  if (revisionId_3 === null) return;
17106
17076
  const editor_7 = pagedEditorRef.current?.getEditor();
17107
17077
  if (editor_7?.getCanonicalDocument()) editor_7.resolveCanonicalRevisions([revisionId_3], "accept");
17108
- else acceptAIEditRevision(revisionId_3)(view_57.state, view_57.dispatch);
17078
+ else acceptAIEditRevision(revisionId_3)(view_56.state, view_56.dispatch);
17109
17079
  extractTrackedChanges();
17110
17080
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
17111
17081
  const handleSidebarRejectChange = useCallback((from_18, to_18) => {
17112
- const view_58 = pagedEditorRef.current?.getView();
17113
- if (!view_58) return;
17082
+ const view_57 = pagedEditorRef.current?.getView();
17083
+ if (!view_57) return;
17114
17084
  const revisionId_4 = resolveSidebarChangeRevisionId(from_18, to_18);
17115
17085
  if (revisionId_4 === null) return;
17116
17086
  const editor_8 = pagedEditorRef.current?.getEditor();
17117
17087
  if (editor_8?.getCanonicalDocument()) editor_8.resolveCanonicalRevisions([revisionId_4], "reject");
17118
- else rejectAIEditRevision(revisionId_4)(view_58.state, view_58.dispatch);
17088
+ else rejectAIEditRevision(revisionId_4)(view_57.state, view_57.dispatch);
17119
17089
  extractTrackedChanges();
17120
17090
  }, [extractTrackedChanges, resolveSidebarChangeRevisionId]);
17121
17091
  const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
@@ -17234,9 +17204,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17234
17204
  }, []);
17235
17205
  const handleOutlineHeadingClick = useCallback((pmPos) => {
17236
17206
  pagedEditorRef.current?.scrollToPosition(pmPos);
17237
- let attempts_0 = 0;
17207
+ let attempts = 0;
17238
17208
  const flash = () => {
17239
- attempts_0++;
17209
+ attempts++;
17240
17210
  const container_0 = scrollContainerRef.current;
17241
17211
  if (!container_0) return;
17242
17212
  const element_1 = container_0.querySelector(`.layout-page-content [data-pm-start="${String(pmPos)}"]`);
@@ -17246,13 +17216,13 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17246
17216
  element_1.dataset["folioOutlineFlash"] = "";
17247
17217
  return;
17248
17218
  }
17249
- if (attempts_0 < 30) requestAnimationFrame(flash);
17219
+ if (attempts < 30) requestAnimationFrame(flash);
17250
17220
  };
17251
17221
  requestAnimationFrame(flash);
17252
17222
  }, []);
17253
- const handleOutlineJump = useCallback((id_5) => {
17223
+ const handleOutlineJump = useCallback(({ id: id_5, pmPos: pmPos_0 }) => {
17254
17224
  markHeadingJumped(id_5);
17255
- handleOutlineHeadingClick(Number(id_5));
17225
+ handleOutlineHeadingClick(pmPos_0);
17256
17226
  }, [handleOutlineHeadingClick, markHeadingJumped]);
17257
17227
  const handleTextContextAction = useCallback((action_3) => {
17258
17228
  handleContextMenuAction(action_3);
@@ -17265,8 +17235,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17265
17235
  }, [readOnly]);
17266
17236
  const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
17267
17237
  const applyTableProperties = useCallback((props_0) => {
17268
- const view_59 = getActiveEditorView();
17269
- if (view_59) setTableProperties(props_0)(view_59.state, view_59.dispatch);
17238
+ const view_58 = getActiveEditorView();
17239
+ if (view_58) setTableProperties(props_0)(view_58.state, view_58.dispatch);
17270
17240
  }, [getActiveEditorView]);
17271
17241
  const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
17272
17242
  const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
@@ -17274,8 +17244,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17274
17244
  const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
17275
17245
  const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
17276
17246
  const insertSymbol = useCallback((symbol) => {
17277
- const view_60 = getActiveEditorView();
17278
- if (view_60) view_60.dispatch(view_60.state.tr.insertText(symbol).scrollIntoView());
17247
+ const view_59 = getActiveEditorView();
17248
+ if (view_59) view_59.dispatch(view_59.state.tr.insertText(symbol).scrollIntoView());
17279
17249
  }, [getActiveEditorView]);
17280
17250
  const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
17281
17251
  const { close: closeFindDialog } = findReplace;
@@ -17366,8 +17336,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17366
17336
  ]);
17367
17337
  const closeNumberingValueDialog = useCallback(() => setNumberingValueDialogOpen(false), []);
17368
17338
  const applyNumberingValue = useCallback((value_0) => {
17369
- const view_61 = getActiveEditorView();
17370
- if (view_61) setNumberingValue(value_0)(view_61.state, view_61.dispatch);
17339
+ const view_60 = getActiveEditorView();
17340
+ if (view_60) setNumberingValue(value_0)(view_60.state, view_60.dispatch);
17371
17341
  }, [getActiveEditorView]);
17372
17342
  const numberingValueDialog = useMemo(() => ({
17373
17343
  isOpen: numberingValueDialogOpen,
@@ -17668,8 +17638,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17668
17638
  onMouseDown: (e_1) => {
17669
17639
  e_1.preventDefault();
17670
17640
  e_1.stopPropagation();
17671
- const view_62 = pagedEditorRef.current?.getView();
17672
- if (!view_62) {
17641
+ const view_61 = pagedEditorRef.current?.getView();
17642
+ if (!view_61) {
17673
17643
  setFloatingCommentBtn(null);
17674
17644
  return;
17675
17645
  }
@@ -17677,9 +17647,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17677
17647
  from: floatingCommentBtn.from,
17678
17648
  to: floatingCommentBtn.to
17679
17649
  };
17680
- const currentSelection = view_62.state.selection;
17650
+ const currentSelection = view_61.state.selection;
17681
17651
  const safeRange = resolveCommentCreationRange({
17682
- docSize: view_62.state.doc.content.size,
17652
+ docSize: view_61.state.doc.content.size,
17683
17653
  capturedRange,
17684
17654
  currentRange: {
17685
17655
  from: currentSelection.from,
@@ -17694,7 +17664,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
17694
17664
  }
17695
17665
  setCommentSelectionRange(safeRange);
17696
17666
  if (commentDraftMode === "prosemirror") {
17697
- if (!applyCommentMarkRange(view_62, safeRange, -1, { selectEnd: true })) {
17667
+ if (!applyCommentMarkRange(view_61, safeRange, -1, { selectEnd: true })) {
17698
17668
  setCommentSelectionRange(null);
17699
17669
  setFloatingCommentBtn(null);
17700
17670
  return;