@stll/folio-react 0.7.0 → 0.8.1

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.
@@ -1,9 +1,10 @@
1
- import { i as cn, n as FolioUIProvider, r as useFolioUI, t as DEFAULT_COMPONENTS } from "./folio-ui-C-85DSuK.js";
1
+ import { i as cn, n as FolioUIProvider, r as useFolioUI, t as DEFAULT_COMPONENTS } from "./folio-ui-BgDDRsUX.js";
2
2
  import { t as messages_exports } from "./messages.js";
3
3
  import { c } from "react-compiler-runtime";
4
4
  import * as React$1 from "react";
5
5
  import React, { Component, Suspense, cloneElement, createContext, forwardRef, isValidElement, lazy, memo, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
6
6
  import { AlertCircleIcon, AlertTriangleIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, AlignRightIcon, BaselineIcon, BoldIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ClipboardCopyIcon, EyeIcon, FileIcon, GlobeIcon, ImageIcon, IndentDecreaseIcon, IndentIncreaseIcon, InfoIcon, ItalicIcon, LinkIcon, ListIcon, ListOrderedIcon, MoreHorizontalIcon, OmegaIcon, PaintbrushIcon, PenLineIcon, PencilIcon, PilcrowIcon, Redo2Icon, RulerIcon, SeparatorHorizontalIcon, SquarePenIcon, StickyNoteIcon, TableIcon, TableOfContentsIcon, TypeIcon, UnderlineIcon, Undo2Icon, UnlinkIcon, XIcon } from "lucide-react";
7
+ import { closeHistory, redo, undo } from "prosemirror-history";
7
8
  import { IntlProvider, useTranslations } from "use-intl";
8
9
  import { FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, createFolioAIEditSnapshot, getCommentAnchorsFromDoc, getFolioDocumentOperationIssues, getTrackedChangesFromDoc } from "@stll/folio-core/ai-edits";
9
10
  import { normalizeBaseDirection } from "@stll/folio-core/docx/normalizeBaseDirection";
@@ -92,7 +93,6 @@ import { applyImagePosition, applyImageProperties, applyImageTransform, applyIma
92
93
  import { classifyEditorKeydown, deleteSelectedTable, isFocusInInputLike, isMacPlatform } from "@stll/folio-core/managers/editorShortcuts";
93
94
  import { getScrollTopForZoomAnchor, getViewportCenterZoomAnchorForZoomChange } from "@stll/folio-core/paged-layout/zoomScrollAnchor";
94
95
  import { ZOOM_MAX, ZOOM_MIN, ZOOM_STEP } from "@stll/folio-core/utils/zoom";
95
- import { redo, undo } from "prosemirror-history";
96
96
  import { createRoot } from "react-dom/client";
97
97
  //#region src/hooks/useHistory.ts
98
98
  /**
@@ -7716,13 +7716,13 @@ function _temp2$3(a, b) {
7716
7716
  }
7717
7717
  //#endregion
7718
7718
  //#region src/components/DocxEditorDialogs.tsx
7719
- const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-Bx7QaFQ_.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
7720
- const TablePropertiesDialog = lazy(() => import("./TablePropertiesDialog-PQxKKM0Y.js").then((n) => n.n).then((m) => ({ default: m.TablePropertiesDialog })));
7721
- const ImagePositionDialog = lazy(() => import("./ImagePositionDialog-D3MileYL.js").then((n) => n.n).then((m) => ({ default: m.ImagePositionDialog })));
7722
- const ImagePropertiesDialog = lazy(() => import("./ImagePropertiesDialog-CzK8HCaW.js").then((n) => n.n).then((m) => ({ default: m.ImagePropertiesDialog })));
7723
- const FootnotePropertiesDialog = lazy(() => import("./FootnotePropertiesDialog-2lmpg9m8.js").then((n) => n.n).then((m) => ({ default: m.FootnotePropertiesDialog })));
7724
- const PageSetupDialog = lazy(() => import("./PageSetupDialog-PSs9YdPb.js").then((n) => n.n).then((m) => ({ default: m.PageSetupDialog })));
7725
- const InsertSymbolDialog = lazy(() => import("./InsertSymbolDialog-Df9dyLvn.js").then((n) => n.n).then((m) => ({ default: m.InsertSymbolDialog })));
7719
+ const FindReplaceDialog = lazy(() => import("./FindReplaceDialog-CqKK82nE.js").then((n) => n.n).then((m) => ({ default: m.FindReplaceDialog })));
7720
+ const TablePropertiesDialog = lazy(() => import("./TablePropertiesDialog-B_AGrPR8.js").then((n) => n.n).then((m) => ({ default: m.TablePropertiesDialog })));
7721
+ const ImagePositionDialog = lazy(() => import("./ImagePositionDialog-DNodkoI2.js").then((n) => n.n).then((m) => ({ default: m.ImagePositionDialog })));
7722
+ const ImagePropertiesDialog = lazy(() => import("./ImagePropertiesDialog-CLsDIUWb.js").then((n) => n.n).then((m) => ({ default: m.ImagePropertiesDialog })));
7723
+ const FootnotePropertiesDialog = lazy(() => import("./FootnotePropertiesDialog-CixRdIiT.js").then((n) => n.n).then((m) => ({ default: m.FootnotePropertiesDialog })));
7724
+ const PageSetupDialog = lazy(() => import("./PageSetupDialog-COkgeOQn.js").then((n) => n.n).then((m) => ({ default: m.PageSetupDialog })));
7725
+ const InsertSymbolDialog = lazy(() => import("./InsertSymbolDialog-DCFLmfzn.js").then((n) => n.n).then((m) => ({ default: m.InsertSymbolDialog })));
7726
7726
  function DocxEditorDialogs(t0) {
7727
7727
  const $ = c(47);
7728
7728
  const { findReplace, tableProperties, imagePosition, imageProperties, pageSetup, footnoteProperties, insertSymbol } = t0;
@@ -7891,61 +7891,88 @@ function DefaultLoadingIndicator() {
7891
7891
  return t2;
7892
7892
  }
7893
7893
  function DefaultPlaceholder() {
7894
- const $ = c(1);
7894
+ const $ = c(5);
7895
+ const t = useTranslations("folio");
7895
7896
  let t0;
7896
7897
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
7897
- t0 = /* @__PURE__ */ jsxs("div", {
7898
+ t0 = /* @__PURE__ */ jsx(FileIcon, {
7899
+ size: 48,
7900
+ strokeWidth: 1.5
7901
+ });
7902
+ $[0] = t0;
7903
+ } else t0 = $[0];
7904
+ let t1;
7905
+ if ($[1] !== t) {
7906
+ t1 = t("noDocumentLoaded");
7907
+ $[1] = t;
7908
+ $[2] = t1;
7909
+ } else t1 = $[2];
7910
+ let t2;
7911
+ if ($[3] !== t1) {
7912
+ t2 = /* @__PURE__ */ jsxs("div", {
7898
7913
  className: "flex h-full flex-col items-center justify-center text-[var(--doc-text-subtle)]",
7899
- children: [/* @__PURE__ */ jsx(FileIcon, {
7900
- size: 48,
7901
- strokeWidth: 1.5
7902
- }), /* @__PURE__ */ jsx("span", {
7914
+ children: [t0, /* @__PURE__ */ jsx("span", {
7903
7915
  className: "mt-4 text-sm",
7904
- children: "No document loaded"
7916
+ children: t1
7905
7917
  })]
7906
7918
  });
7907
- $[0] = t0;
7908
- } else t0 = $[0];
7909
- return t0;
7919
+ $[3] = t1;
7920
+ $[4] = t2;
7921
+ } else t2 = $[4];
7922
+ return t2;
7910
7923
  }
7911
7924
  function ParseError(t0) {
7912
- const $ = c(4);
7925
+ const $ = c(10);
7913
7926
  const { message } = t0;
7927
+ const t = useTranslations("folio");
7914
7928
  let t1;
7915
- let t2;
7916
7929
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
7917
7930
  t1 = /* @__PURE__ */ jsx(AlertCircleIcon, {
7918
7931
  size: 48,
7919
7932
  strokeWidth: 1.5,
7920
7933
  className: "text-[var(--doc-error)]"
7921
7934
  });
7922
- t2 = /* @__PURE__ */ jsx("h3", {
7923
- className: "mt-4 text-base font-semibold text-[var(--doc-error)]",
7924
- children: "Failed to Load Document"
7925
- });
7926
7935
  $[0] = t1;
7927
- $[1] = t2;
7928
- } else {
7929
- t1 = $[0];
7930
- t2 = $[1];
7931
- }
7936
+ } else t1 = $[0];
7937
+ let t2;
7938
+ if ($[1] !== t) {
7939
+ t2 = t("loadDocumentFailedTitle");
7940
+ $[1] = t;
7941
+ $[2] = t2;
7942
+ } else t2 = $[2];
7932
7943
  let t3;
7933
- if ($[2] !== message) {
7934
- t3 = /* @__PURE__ */ jsxs("div", {
7944
+ if ($[3] !== t2) {
7945
+ t3 = /* @__PURE__ */ jsx("h3", {
7946
+ className: "mt-4 text-base font-semibold text-[var(--doc-error)]",
7947
+ children: t2
7948
+ });
7949
+ $[3] = t2;
7950
+ $[4] = t3;
7951
+ } else t3 = $[4];
7952
+ let t4;
7953
+ if ($[5] !== message) {
7954
+ t4 = /* @__PURE__ */ jsx("p", {
7955
+ className: "mt-2 max-w-[400px] text-sm text-[var(--doc-text-muted)]",
7956
+ children: message
7957
+ });
7958
+ $[5] = message;
7959
+ $[6] = t4;
7960
+ } else t4 = $[6];
7961
+ let t5;
7962
+ if ($[7] !== t3 || $[8] !== t4) {
7963
+ t5 = /* @__PURE__ */ jsxs("div", {
7935
7964
  className: "flex h-full flex-col items-center justify-center p-5 text-center",
7936
7965
  children: [
7937
7966
  t1,
7938
- t2,
7939
- /* @__PURE__ */ jsx("p", {
7940
- className: "mt-2 max-w-[400px] text-sm text-[var(--doc-text-muted)]",
7941
- children: message
7942
- })
7967
+ t3,
7968
+ t4
7943
7969
  ]
7944
7970
  });
7945
- $[2] = message;
7946
- $[3] = t3;
7947
- } else t3 = $[3];
7948
- return t3;
7971
+ $[7] = t3;
7972
+ $[8] = t4;
7973
+ $[9] = t5;
7974
+ } else t5 = $[9];
7975
+ return t5;
7949
7976
  }
7950
7977
  //#endregion
7951
7978
  //#region src/components/ErrorBoundary.tsx
@@ -11010,6 +11037,7 @@ const labelStyle = {
11010
11037
  letterSpacing: .3
11011
11038
  };
11012
11039
  const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({ position, targetElement, parentElement, getActiveView, onClose, onRemove }, ref) {
11040
+ const t = useTranslations("folio");
11013
11041
  const [showOptions, setShowOptions] = useState(false);
11014
11042
  const optionsRef = useRef(null);
11015
11043
  const [overlayPos, setOverlayPos] = useState(null);
@@ -11089,7 +11117,7 @@ const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({
11089
11117
  return redo(view.state, view.dispatch);
11090
11118
  }
11091
11119
  }));
11092
- const label = position === "header" ? "Header" : "Footer";
11120
+ const label = position === "header" ? t("headerFooter.header") : t("headerFooter.footer");
11093
11121
  if (!overlayPos) return null;
11094
11122
  return /* @__PURE__ */ jsxs("div", {
11095
11123
  role: "presentation",
@@ -11111,7 +11139,6 @@ const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({
11111
11139
  children: label
11112
11140
  }), /* @__PURE__ */ jsx(OptionsMenu, {
11113
11141
  position,
11114
- label,
11115
11142
  showOptions,
11116
11143
  setShowOptions,
11117
11144
  optionsRef,
@@ -11127,7 +11154,6 @@ const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({
11127
11154
  children: label
11128
11155
  }), /* @__PURE__ */ jsx(OptionsMenu, {
11129
11156
  position,
11130
- label,
11131
11157
  showOptions,
11132
11158
  setShowOptions,
11133
11159
  optionsRef,
@@ -11139,8 +11165,9 @@ const InlineHeaderFooterEditor = forwardRef(function InlineHeaderFooterEditor({
11139
11165
  });
11140
11166
  });
11141
11167
  function OptionsMenu(t0) {
11142
- const $ = c(17);
11143
- const { position, label, showOptions, setShowOptions, optionsRef, onRemove, onClose, getActiveView } = t0;
11168
+ const $ = c(22);
11169
+ const { position, showOptions, setShowOptions, optionsRef, onRemove, onClose, getActiveView } = t0;
11170
+ const t = useTranslations("folio");
11144
11171
  let t1;
11145
11172
  if ($[0] !== getActiveView) {
11146
11173
  t1 = (fieldType) => {
@@ -11169,22 +11196,35 @@ function OptionsMenu(t0) {
11169
11196
  } else t2 = $[2];
11170
11197
  let t3;
11171
11198
  if ($[3] !== setShowOptions) {
11172
- t3 = /* @__PURE__ */ jsx("button", {
11173
- type: "button",
11174
- className: "hf-options-button",
11175
- onClick: (e) => {
11176
- e.stopPropagation();
11177
- setShowOptions(_temp$1);
11178
- },
11179
- onMouseDown: _temp2$1,
11180
- children: "Options ▾"
11181
- });
11199
+ t3 = (e) => {
11200
+ e.stopPropagation();
11201
+ setShowOptions(_temp$1);
11202
+ };
11182
11203
  $[3] = setShowOptions;
11183
11204
  $[4] = t3;
11184
11205
  } else t3 = $[4];
11185
11206
  let t4;
11186
- if ($[5] !== insertField || $[6] !== label || $[7] !== onClose || $[8] !== onRemove || $[9] !== position || $[10] !== setShowOptions || $[11] !== showOptions) {
11187
- t4 = showOptions && /* @__PURE__ */ jsxs("div", {
11207
+ if ($[5] !== t) {
11208
+ t4 = t("headerFooter.options");
11209
+ $[5] = t;
11210
+ $[6] = t4;
11211
+ } else t4 = $[6];
11212
+ let t5;
11213
+ if ($[7] !== t3 || $[8] !== t4) {
11214
+ t5 = /* @__PURE__ */ jsxs("button", {
11215
+ type: "button",
11216
+ className: "hf-options-button",
11217
+ onClick: t3,
11218
+ onMouseDown: _temp2$1,
11219
+ children: [t4, " ▾"]
11220
+ });
11221
+ $[7] = t3;
11222
+ $[8] = t4;
11223
+ $[9] = t5;
11224
+ } else t5 = $[9];
11225
+ let t6;
11226
+ if ($[10] !== insertField || $[11] !== onClose || $[12] !== onRemove || $[13] !== position || $[14] !== setShowOptions || $[15] !== showOptions || $[16] !== t) {
11227
+ t6 = showOptions && /* @__PURE__ */ jsxs("div", {
11188
11228
  className: `hf-options-dropdown${position === "footer" ? " hf-options-dropdown--up" : ""}`,
11189
11229
  children: [
11190
11230
  /* @__PURE__ */ jsx("button", {
@@ -11194,7 +11234,7 @@ function OptionsMenu(t0) {
11194
11234
  setShowOptions(false);
11195
11235
  insertField("PAGE");
11196
11236
  },
11197
- children: "Insert current page number"
11237
+ children: t("headerFooter.insertPageNumber")
11198
11238
  }),
11199
11239
  /* @__PURE__ */ jsx("button", {
11200
11240
  type: "button",
@@ -11203,55 +11243,51 @@ function OptionsMenu(t0) {
11203
11243
  setShowOptions(false);
11204
11244
  insertField("NUMPAGES");
11205
11245
  },
11206
- children: "Insert total page count"
11246
+ children: t("headerFooter.insertPageCount")
11207
11247
  }),
11208
11248
  /* @__PURE__ */ jsx("div", { className: "hf-options-divider" }),
11209
- onRemove && /* @__PURE__ */ jsxs("button", {
11249
+ onRemove && /* @__PURE__ */ jsx("button", {
11210
11250
  type: "button",
11211
11251
  className: "hf-options-item",
11212
11252
  onClick: () => {
11213
11253
  setShowOptions(false);
11214
11254
  onRemove();
11215
11255
  },
11216
- children: ["Remove ", label.toLowerCase()]
11256
+ children: position === "header" ? t("headerFooter.removeHeader") : t("headerFooter.removeFooter")
11217
11257
  }),
11218
- /* @__PURE__ */ jsxs("button", {
11258
+ /* @__PURE__ */ jsx("button", {
11219
11259
  type: "button",
11220
11260
  className: "hf-options-item",
11221
11261
  onClick: () => {
11222
11262
  setShowOptions(false);
11223
11263
  onClose();
11224
11264
  },
11225
- children: [
11226
- "Close ",
11227
- label.toLowerCase(),
11228
- " editing"
11229
- ]
11265
+ children: position === "header" ? t("headerFooter.closeHeaderEditing") : t("headerFooter.closeFooterEditing")
11230
11266
  })
11231
11267
  ]
11232
11268
  });
11233
- $[5] = insertField;
11234
- $[6] = label;
11235
- $[7] = onClose;
11236
- $[8] = onRemove;
11237
- $[9] = position;
11238
- $[10] = setShowOptions;
11239
- $[11] = showOptions;
11240
- $[12] = t4;
11241
- } else t4 = $[12];
11242
- let t5;
11243
- if ($[13] !== optionsRef || $[14] !== t3 || $[15] !== t4) {
11244
- t5 = /* @__PURE__ */ jsxs("div", {
11269
+ $[10] = insertField;
11270
+ $[11] = onClose;
11271
+ $[12] = onRemove;
11272
+ $[13] = position;
11273
+ $[14] = setShowOptions;
11274
+ $[15] = showOptions;
11275
+ $[16] = t;
11276
+ $[17] = t6;
11277
+ } else t6 = $[17];
11278
+ let t7;
11279
+ if ($[18] !== optionsRef || $[19] !== t5 || $[20] !== t6) {
11280
+ t7 = /* @__PURE__ */ jsxs("div", {
11245
11281
  style: t2,
11246
11282
  ref: optionsRef,
11247
- children: [t3, t4]
11283
+ children: [t5, t6]
11248
11284
  });
11249
- $[13] = optionsRef;
11250
- $[14] = t3;
11251
- $[15] = t4;
11252
- $[16] = t5;
11253
- } else t5 = $[16];
11254
- return t5;
11285
+ $[18] = optionsRef;
11286
+ $[19] = t5;
11287
+ $[20] = t6;
11288
+ $[21] = t7;
11289
+ } else t7 = $[21];
11290
+ return t7;
11255
11291
  }
11256
11292
  function _temp2$1(e_0) {
11257
11293
  return e_0.stopPropagation();
@@ -11360,7 +11396,7 @@ function areSelectionFormattingEqual(a, b) {
11360
11396
  * Edit mode: text + URL inputs with Apply.
11361
11397
  */
11362
11398
  function HyperlinkPopup(t0) {
11363
- const $ = c(85);
11399
+ const $ = c(88);
11364
11400
  const { data, onNavigate, onCopy, onEdit, onRemove, onClose, readOnly } = t0;
11365
11401
  const t = useTranslations("folio");
11366
11402
  const [mode, setMode] = useState("view");
@@ -11610,81 +11646,88 @@ function HyperlinkPopup(t0) {
11610
11646
  } else t22 = $[42];
11611
11647
  const t23 = !t22;
11612
11648
  let t24;
11613
- if ($[43] !== handleApply || $[44] !== t23) {
11614
- t24 = /* @__PURE__ */ jsx("button", {
11649
+ if ($[43] !== t) {
11650
+ t24 = t("common.apply");
11651
+ $[43] = t;
11652
+ $[44] = t24;
11653
+ } else t24 = $[44];
11654
+ let t25;
11655
+ if ($[45] !== handleApply || $[46] !== t23 || $[47] !== t24) {
11656
+ t25 = /* @__PURE__ */ jsx("button", {
11615
11657
  className: "text-primary shrink-0 rounded px-3 py-1 text-sm font-semibold disabled:opacity-40",
11616
11658
  disabled: t23,
11617
11659
  onClick: handleApply,
11618
11660
  type: "button",
11619
- children: "Apply"
11661
+ children: t24
11620
11662
  });
11621
- $[43] = handleApply;
11622
- $[44] = t23;
11623
- $[45] = t24;
11624
- } else t24 = $[45];
11625
- let t25;
11626
- if ($[46] !== t21 || $[47] !== t24) {
11627
- t25 = /* @__PURE__ */ jsxs("div", {
11663
+ $[45] = handleApply;
11664
+ $[46] = t23;
11665
+ $[47] = t24;
11666
+ $[48] = t25;
11667
+ } else t25 = $[48];
11668
+ let t26;
11669
+ if ($[49] !== t21 || $[50] !== t25) {
11670
+ t26 = /* @__PURE__ */ jsxs("div", {
11628
11671
  className: "flex items-center gap-2",
11629
11672
  children: [
11630
11673
  t19,
11631
11674
  t21,
11632
- t24
11675
+ t25
11633
11676
  ]
11634
11677
  });
11635
- $[46] = t21;
11636
- $[47] = t24;
11637
- $[48] = t25;
11638
- } else t25 = $[48];
11639
- let t26;
11640
- if ($[49] !== t14 || $[50] !== t18 || $[51] !== t25) {
11641
- t26 = /* @__PURE__ */ jsxs("div", {
11678
+ $[49] = t21;
11679
+ $[50] = t25;
11680
+ $[51] = t26;
11681
+ } else t26 = $[51];
11682
+ let t27;
11683
+ if ($[52] !== t14 || $[53] !== t18 || $[54] !== t26) {
11684
+ t27 = /* @__PURE__ */ jsxs("div", {
11642
11685
  ref: popupRef,
11643
11686
  className: "fixed z-[10000] w-80 rounded-lg border border-[var(--doc-border)] bg-[var(--doc-page)] p-3 shadow-lg",
11644
11687
  onMouseDown: t13,
11645
11688
  role: "presentation",
11646
11689
  style: t14,
11647
- children: [t18, t25]
11690
+ children: [t18, t26]
11648
11691
  });
11649
- $[49] = t14;
11650
- $[50] = t18;
11651
- $[51] = t25;
11652
- $[52] = t26;
11653
- } else t26 = $[52];
11654
- return t26;
11692
+ $[52] = t14;
11693
+ $[53] = t18;
11694
+ $[54] = t26;
11695
+ $[55] = t27;
11696
+ } else t27 = $[55];
11697
+ return t27;
11655
11698
  }
11656
11699
  let t13;
11657
- if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
11700
+ if ($[56] === Symbol.for("react.memo_cache_sentinel")) {
11658
11701
  t13 = containedHandler(_temp2);
11659
- $[53] = t13;
11660
- } else t13 = $[53];
11702
+ $[56] = t13;
11703
+ } else t13 = $[56];
11661
11704
  let t14;
11662
- if ($[54] !== left || $[55] !== top) {
11705
+ if ($[57] !== left || $[58] !== top) {
11663
11706
  t14 = {
11664
11707
  top,
11665
11708
  left
11666
11709
  };
11667
- $[54] = left;
11668
- $[55] = top;
11669
- $[56] = t14;
11670
- } else t14 = $[56];
11710
+ $[57] = left;
11711
+ $[58] = top;
11712
+ $[59] = t14;
11713
+ } else t14 = $[59];
11671
11714
  let t15;
11672
- if ($[57] === Symbol.for("react.memo_cache_sentinel")) {
11715
+ if ($[60] === Symbol.for("react.memo_cache_sentinel")) {
11673
11716
  t15 = /* @__PURE__ */ jsx(GlobeIcon, { className: "text-muted-foreground size-4.5 shrink-0" });
11674
- $[57] = t15;
11675
- } else t15 = $[57];
11717
+ $[60] = t15;
11718
+ } else t15 = $[60];
11676
11719
  let t16;
11677
- if ($[58] !== data.href || $[59] !== onNavigate) {
11720
+ if ($[61] !== data.href || $[62] !== onNavigate) {
11678
11721
  t16 = (e_6) => {
11679
11722
  e_6.preventDefault();
11680
11723
  onNavigate(data.href);
11681
11724
  };
11682
- $[58] = data.href;
11683
- $[59] = onNavigate;
11684
- $[60] = t16;
11685
- } else t16 = $[60];
11725
+ $[61] = data.href;
11726
+ $[62] = onNavigate;
11727
+ $[63] = t16;
11728
+ } else t16 = $[63];
11686
11729
  let t17;
11687
- if ($[61] !== data.href || $[62] !== t16) {
11730
+ if ($[64] !== data.href || $[65] !== t16) {
11688
11731
  t17 = /* @__PURE__ */ jsx("a", {
11689
11732
  className: "text-primary truncate text-sm hover:underline",
11690
11733
  href: data.href,
@@ -11694,35 +11737,35 @@ function HyperlinkPopup(t0) {
11694
11737
  title: data.href,
11695
11738
  children: data.href
11696
11739
  });
11697
- $[61] = data.href;
11698
- $[62] = t16;
11699
- $[63] = t17;
11700
- } else t17 = $[63];
11740
+ $[64] = data.href;
11741
+ $[65] = t16;
11742
+ $[66] = t17;
11743
+ } else t17 = $[66];
11701
11744
  let t18;
11702
- if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
11745
+ if ($[67] === Symbol.for("react.memo_cache_sentinel")) {
11703
11746
  t18 = /* @__PURE__ */ jsx("span", { className: "bg-border h-5 w-px shrink-0" });
11704
- $[64] = t18;
11705
- } else t18 = $[64];
11747
+ $[67] = t18;
11748
+ } else t18 = $[67];
11706
11749
  let t19;
11707
- if ($[65] !== data.href || $[66] !== onCopy) {
11750
+ if ($[68] !== data.href || $[69] !== onCopy) {
11708
11751
  t19 = () => onCopy(data.href);
11709
- $[65] = data.href;
11710
- $[66] = onCopy;
11711
- $[67] = t19;
11712
- } else t19 = $[67];
11752
+ $[68] = data.href;
11753
+ $[69] = onCopy;
11754
+ $[70] = t19;
11755
+ } else t19 = $[70];
11713
11756
  let t20;
11714
- if ($[68] !== t) {
11757
+ if ($[71] !== t) {
11715
11758
  t20 = t("copyLink");
11716
- $[68] = t;
11717
- $[69] = t20;
11718
- } else t20 = $[69];
11759
+ $[71] = t;
11760
+ $[72] = t20;
11761
+ } else t20 = $[72];
11719
11762
  let t21;
11720
- if ($[70] === Symbol.for("react.memo_cache_sentinel")) {
11763
+ if ($[73] === Symbol.for("react.memo_cache_sentinel")) {
11721
11764
  t21 = /* @__PURE__ */ jsx(ClipboardCopyIcon, { size: 16 });
11722
- $[70] = t21;
11723
- } else t21 = $[70];
11765
+ $[73] = t21;
11766
+ } else t21 = $[73];
11724
11767
  let t22;
11725
- if ($[71] !== t19 || $[72] !== t20) {
11768
+ if ($[74] !== t19 || $[75] !== t20) {
11726
11769
  t22 = /* @__PURE__ */ jsx("button", {
11727
11770
  className: "flex size-7 items-center justify-center rounded text-[var(--doc-text-muted)] hover:bg-[var(--doc-bg-hover)] transition-colors",
11728
11771
  onClick: t19,
@@ -11730,12 +11773,12 @@ function HyperlinkPopup(t0) {
11730
11773
  type: "button",
11731
11774
  children: t21
11732
11775
  });
11733
- $[71] = t19;
11734
- $[72] = t20;
11735
- $[73] = t22;
11736
- } else t22 = $[73];
11776
+ $[74] = t19;
11777
+ $[75] = t20;
11778
+ $[76] = t22;
11779
+ } else t22 = $[76];
11737
11780
  let t23;
11738
- if ($[74] !== data.displayText || $[75] !== data.href || $[76] !== onRemove || $[77] !== readOnly || $[78] !== t) {
11781
+ if ($[77] !== data.displayText || $[78] !== data.href || $[79] !== onRemove || $[80] !== readOnly || $[81] !== t) {
11739
11782
  t23 = !readOnly && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
11740
11783
  className: "flex size-7 items-center justify-center rounded text-[var(--doc-text-muted)] hover:bg-[var(--doc-bg-hover)] transition-colors",
11741
11784
  onClick: () => {
@@ -11753,15 +11796,15 @@ function HyperlinkPopup(t0) {
11753
11796
  type: "button",
11754
11797
  children: /* @__PURE__ */ jsx(UnlinkIcon, { size: 16 })
11755
11798
  })] });
11756
- $[74] = data.displayText;
11757
- $[75] = data.href;
11758
- $[76] = onRemove;
11759
- $[77] = readOnly;
11760
- $[78] = t;
11761
- $[79] = t23;
11762
- } else t23 = $[79];
11799
+ $[77] = data.displayText;
11800
+ $[78] = data.href;
11801
+ $[79] = onRemove;
11802
+ $[80] = readOnly;
11803
+ $[81] = t;
11804
+ $[82] = t23;
11805
+ } else t23 = $[82];
11763
11806
  let t24;
11764
- if ($[80] !== t14 || $[81] !== t17 || $[82] !== t22 || $[83] !== t23) {
11807
+ if ($[83] !== t14 || $[84] !== t17 || $[85] !== t22 || $[86] !== t23) {
11765
11808
  t24 = /* @__PURE__ */ jsxs("div", {
11766
11809
  ref: popupRef,
11767
11810
  className: "fixed z-[10000] flex max-w-[400px] items-center gap-2 rounded-lg border border-[var(--doc-border)] bg-[var(--doc-page)] px-3 py-2 shadow-lg",
@@ -11776,12 +11819,12 @@ function HyperlinkPopup(t0) {
11776
11819
  t23
11777
11820
  ]
11778
11821
  });
11779
- $[80] = t14;
11780
- $[81] = t17;
11781
- $[82] = t22;
11782
- $[83] = t23;
11783
- $[84] = t24;
11784
- } else t24 = $[84];
11822
+ $[83] = t14;
11823
+ $[84] = t17;
11824
+ $[85] = t22;
11825
+ $[86] = t23;
11826
+ $[87] = t24;
11827
+ } else t24 = $[87];
11785
11828
  return t24;
11786
11829
  }
11787
11830
  function _temp2(e_5) {
@@ -12263,7 +12306,7 @@ function useFolioComments({ doc, autoOpenReviewSidebar, anchorPositions, editorC
12263
12306
  * - Error boundary
12264
12307
  * - Loading states
12265
12308
  */
12266
- const CommentsSidebar = lazy(() => import("./CommentsSidebar-B8X5a8JW.js").then((m) => ({ default: m.CommentsSidebar })));
12309
+ const CommentsSidebar = lazy(() => import("./CommentsSidebar-Byn5lyrt.js").then((m) => ({ default: m.CommentsSidebar })));
12267
12310
  const TextContextMenu = lazy(() => import("./TextContextMenu-Ci7-M4oU.js").then((m) => ({ default: m.TextContextMenu })));
12268
12311
  const loadAttemptSelectiveSave = async () => {
12269
12312
  const { attemptSelectiveSave } = await import("@stll/folio-core/docx/selectiveSave");
@@ -12281,6 +12324,7 @@ const DISPLAY_MODE_LABEL_KEYS = {
12281
12324
  original: "markupView.original"
12282
12325
  };
12283
12326
  const preventMouseDownDefault = (event) => event.preventDefault();
12327
+ let documentOperationUndoHandleCursor = Date.now();
12284
12328
  function isDisplayMode(value) {
12285
12329
  return typeof value === "string" && DISPLAY_MODES.some((mode) => mode === value);
12286
12330
  }
@@ -12544,6 +12588,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
12544
12588
  commentsProp,
12545
12589
  onCommentsChange
12546
12590
  });
12591
+ const documentOperationUndoEntriesRef = useRef([]);
12547
12592
  const styleResolverCacheRef = useRef(null);
12548
12593
  const getCachedStyleResolver = useCallback((styles) => {
12549
12594
  const cached = styleResolverCacheRef.current;
@@ -13835,12 +13880,23 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13835
13880
  applied: [],
13836
13881
  skipped,
13837
13882
  issues: getFolioDocumentOperationIssues(batch.operations, skipped),
13838
- receipts: []
13883
+ receipts: [],
13884
+ undoHandle: null
13839
13885
  };
13840
13886
  }
13887
+ const existingUndoEntry = documentOperationUndoEntriesRef.current.at(-1);
13888
+ if (existingUndoEntry && (!view_20.state.doc.eq(existingUndoEntry.afterState.doc) || commentsRef.current !== existingUndoEntry.commentsAfter)) documentOperationUndoEntriesRef.current.length = 0;
13889
+ const commentsBefore = commentsRef.current;
13841
13890
  const createdComments = [];
13891
+ const operationView = {
13892
+ state: view_20.state,
13893
+ dispatch: (transaction) => {
13894
+ view_20.dispatch(closeHistory(transaction));
13895
+ operationView.state = view_20.state;
13896
+ }
13897
+ };
13842
13898
  const result = applyFolioDocumentOperations({
13843
- view: view_20,
13899
+ view: operationView,
13844
13900
  snapshot,
13845
13901
  batch,
13846
13902
  author: operationAuthor,
@@ -13848,14 +13904,62 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13848
13904
  const comment = createComment(text_3, operationAuthor);
13849
13905
  createdComments.push(comment);
13850
13906
  return comment.id;
13851
- }
13907
+ },
13908
+ createUndoHandle: () => ({
13909
+ type: "documentOperationUndo",
13910
+ id: `react-${String(documentOperationUndoHandleCursor++)}`
13911
+ })
13852
13912
  });
13853
13913
  if (createdComments.length > 0) updateComments((currentComments_0) => [...currentComments_0, ...createdComments]);
13914
+ if (result.undoHandle !== null) documentOperationUndoEntriesRef.current.push({
13915
+ undoHandle: result.undoHandle,
13916
+ afterState: view_20.state,
13917
+ commentsBefore,
13918
+ commentsAfter: commentsRef.current
13919
+ });
13854
13920
  return result;
13855
13921
  },
13856
- applyAIEditOperations: ({ snapshot: snapshot_0, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
13922
+ undoDocumentOperations: (undoHandle) => {
13923
+ const entries = documentOperationUndoEntriesRef.current;
13924
+ const entryIndex = entries.findIndex((entry_2) => entry_2.undoHandle.type === undoHandle.type && entry_2.undoHandle.id === undoHandle.id);
13925
+ if (entryIndex === -1) return {
13926
+ status: "rejected",
13927
+ undoHandle,
13928
+ reason: "unknownHandle"
13929
+ };
13930
+ if (entryIndex !== entries.length - 1) return {
13931
+ status: "rejected",
13932
+ undoHandle,
13933
+ reason: "notLatest"
13934
+ };
13935
+ const entry_3 = entries.at(-1);
13857
13936
  const view_21 = pagedEditorRef.current?.getView();
13858
- if (!view_21) return {
13937
+ if (!entry_3 || !view_21) return {
13938
+ status: "rejected",
13939
+ undoHandle,
13940
+ reason: "unknownHandle"
13941
+ };
13942
+ if (!view_21.state.doc.eq(entry_3.afterState.doc) || commentsRef.current !== entry_3.commentsAfter) return {
13943
+ status: "rejected",
13944
+ undoHandle,
13945
+ reason: "documentChanged"
13946
+ };
13947
+ if (!(pagedEditorRef.current?.undo() ?? false)) return {
13948
+ status: "rejected",
13949
+ undoHandle,
13950
+ reason: "documentChanged"
13951
+ };
13952
+ replaceComments(entry_3.commentsBefore);
13953
+ entries.pop();
13954
+ requestAnimationFrame(refreshBodyHistoryAvailability);
13955
+ return {
13956
+ status: "undone",
13957
+ undoHandle
13958
+ };
13959
+ },
13960
+ applyAIEditOperations: ({ snapshot: snapshot_0, operations, mode = "tracked-changes", author: operationAuthor_0 = author }) => {
13961
+ const view_22 = pagedEditorRef.current?.getView();
13962
+ if (!view_22) return {
13859
13963
  applied: [],
13860
13964
  skipped: operations.map((operation_0) => ({
13861
13965
  id: operation_0.id,
@@ -13864,7 +13968,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13864
13968
  };
13865
13969
  const createdComments_0 = [];
13866
13970
  const { applied: applied_0, skipped: skipped_0 } = applyFolioDocumentOperations({
13867
- view: view_21,
13971
+ view: view_22,
13868
13972
  snapshot: snapshot_0,
13869
13973
  batch: {
13870
13974
  version: FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION,
@@ -13885,14 +13989,14 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13885
13989
  };
13886
13990
  },
13887
13991
  acceptAIEditOperation: (revisionId) => {
13888
- const view_22 = pagedEditorRef.current?.getView();
13889
- if (!view_22) return false;
13890
- return acceptAIEditRevision(revisionId)(view_22.state, view_22.dispatch);
13891
- },
13892
- rejectAIEditOperation: (revisionId_0) => {
13893
13992
  const view_23 = pagedEditorRef.current?.getView();
13894
13993
  if (!view_23) return false;
13895
- return rejectAIEditRevision(revisionId_0)(view_23.state, view_23.dispatch);
13994
+ return acceptAIEditRevision(revisionId)(view_23.state, view_23.dispatch);
13995
+ },
13996
+ rejectAIEditOperation: (revisionId_0) => {
13997
+ const view_24 = pagedEditorRef.current?.getView();
13998
+ if (!view_24) return false;
13999
+ return rejectAIEditRevision(revisionId_0)(view_24.state, view_24.dispatch);
13896
14000
  },
13897
14001
  undo: () => {
13898
14002
  if (hfEditPosition && hfEditorRef.current) return hfEditorRef.current.undo();
@@ -13907,98 +14011,98 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
13907
14011
  return redone;
13908
14012
  },
13909
14013
  scrollToAIEditOperation: (revisionId_1) => {
13910
- const view_24 = pagedEditorRef.current?.getView();
13911
- if (!view_24) return false;
13912
- const range_2 = findAIEditRevisionRange(view_24.state, revisionId_1);
14014
+ const view_25 = pagedEditorRef.current?.getView();
14015
+ if (!view_25) return false;
14016
+ const range_2 = findAIEditRevisionRange(view_25.state, revisionId_1);
13913
14017
  if (!range_2) return false;
13914
- const { from: from_8, to: to_8 } = clampRangeToDocSize(view_24.state.doc.content.size, range_2);
13915
- const $from = view_24.state.doc.resolve(from_8);
13916
- const $to = view_24.state.doc.resolve(to_8);
13917
- view_24.dispatch(view_24.state.tr.setSelection(TextSelection.between($from, $to)));
14018
+ const { from: from_8, to: to_8 } = clampRangeToDocSize(view_25.state.doc.content.size, range_2);
14019
+ const $from = view_25.state.doc.resolve(from_8);
14020
+ const $to = view_25.state.doc.resolve(to_8);
14021
+ view_25.dispatch(view_25.state.tr.setSelection(TextSelection.between($from, $to)));
13918
14022
  requestAnimationFrame(() => {
13919
14023
  pagedEditorRef.current?.scrollToPosition(from_8);
13920
14024
  });
13921
14025
  return true;
13922
14026
  },
13923
14027
  scrollToBlock: (blockId, snapshot_1) => {
13924
- const view_25 = pagedEditorRef.current?.getView();
13925
- if (!view_25) return false;
14028
+ const view_26 = pagedEditorRef.current?.getView();
14029
+ if (!view_26) return false;
13926
14030
  const range_3 = resolveFolioAIBlockRange({
13927
14031
  blockId,
13928
- doc: view_25.state.doc,
14032
+ doc: view_26.state.doc,
13929
14033
  snapshot: snapshot_1
13930
14034
  });
13931
14035
  if (range_3 === null) return false;
13932
14036
  const { from: from_9, to: to_9 } = range_3;
13933
- const $from_0 = view_25.state.doc.resolve(from_9);
13934
- const $to_0 = view_25.state.doc.resolve(to_9);
13935
- view_25.dispatch(view_25.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
14037
+ const $from_0 = view_26.state.doc.resolve(from_9);
14038
+ const $to_0 = view_26.state.doc.resolve(to_9);
14039
+ view_26.dispatch(view_26.state.tr.setSelection(TextSelection.between($from_0, $to_0)));
13936
14040
  requestAnimationFrame(() => {
13937
14041
  pagedEditorRef.current?.scrollToPosition(from_9);
13938
14042
  });
13939
14043
  return true;
13940
14044
  },
13941
14045
  getTrackedChanges: () => {
13942
- const view_26 = pagedEditorRef.current?.getView();
13943
- return view_26 ? getTrackedChangesFromDoc(view_26.state.doc) : [];
14046
+ const view_27 = pagedEditorRef.current?.getView();
14047
+ return view_27 ? getTrackedChangesFromDoc(view_27.state.doc) : [];
13944
14048
  },
13945
14049
  getCommentAnchors: () => {
13946
- const view_27 = pagedEditorRef.current?.getView();
13947
- return view_27 ? getCommentAnchorsFromDoc(view_27.state.doc) : [];
14050
+ const view_28 = pagedEditorRef.current?.getView();
14051
+ return view_28 ? getCommentAnchorsFromDoc(view_28.state.doc) : [];
13948
14052
  },
13949
14053
  getSelectionText: () => {
13950
- const view_28 = pagedEditorRef.current?.getView();
13951
- return view_28 ? getSelectedText(view_28.state) : "";
14054
+ const view_29 = pagedEditorRef.current?.getView();
14055
+ return view_29 ? getSelectedText(view_29.state) : "";
13952
14056
  },
13953
14057
  getPageText: (page_0) => {
13954
- const view_29 = pagedEditorRef.current?.getView();
13955
- if (!view_29) return null;
13956
- return getPageTextFromLayout(pagedEditorRef.current?.getEditor()?.getLayout() ?? null, view_29.state.doc, page_0);
14058
+ const view_30 = pagedEditorRef.current?.getView();
14059
+ if (!view_30) return null;
14060
+ return getPageTextFromLayout(pagedEditorRef.current?.getEditor()?.getLayout() ?? null, view_30.state.doc, page_0);
13957
14061
  },
13958
14062
  getContentControls: (filter = {}) => {
13959
- const view_30 = pagedEditorRef.current?.getView();
13960
- if (!view_30) return [];
13961
- return findBlockSdtMatches(view_30.state.doc, filter).map((match_0) => ({
14063
+ const view_31 = pagedEditorRef.current?.getView();
14064
+ if (!view_31) return [];
14065
+ return findBlockSdtMatches(view_31.state.doc, filter).map((match_0) => ({
13962
14066
  properties: blockSdtAttrsToSdtProperties(match_0.node),
13963
14067
  path: match_0.path,
13964
14068
  pmPos: match_0.pos
13965
14069
  }));
13966
14070
  },
13967
14071
  scrollToContentControl: (filter_0) => {
13968
- const view_31 = pagedEditorRef.current?.getView();
13969
- if (!view_31) return false;
13970
- const match_1 = findBlockSdtMatch(view_31.state.doc, filter_0);
14072
+ const view_32 = pagedEditorRef.current?.getView();
14073
+ if (!view_32) return false;
14074
+ const match_1 = findBlockSdtMatch(view_32.state.doc, filter_0);
13971
14075
  if (!match_1) return false;
13972
14076
  const inside = match_1.pos + 1;
13973
- const $pos = view_31.state.doc.resolve(inside);
13974
- view_31.dispatch(view_31.state.tr.setSelection(TextSelection.near($pos)));
14077
+ const $pos = view_32.state.doc.resolve(inside);
14078
+ view_32.dispatch(view_32.state.tr.setSelection(TextSelection.near($pos)));
13975
14079
  requestAnimationFrame(() => {
13976
14080
  pagedEditorRef.current?.scrollToPosition(inside);
13977
14081
  });
13978
14082
  return true;
13979
14083
  },
13980
14084
  setContentControlContent: (filter_1, input, options_2 = {}) => {
13981
- const view_32 = pagedEditorRef.current?.getView();
13982
- if (!view_32) return false;
13983
- const tr_0 = typeof input === "string" ? setContentControlContentTr(view_32.state, filter_1, input, options_2) : setContentControlContentBlocksTr(view_32.state, filter_1, input, options_2);
14085
+ const view_33 = pagedEditorRef.current?.getView();
14086
+ if (!view_33) return false;
14087
+ const tr_0 = typeof input === "string" ? setContentControlContentTr(view_33.state, filter_1, input, options_2) : setContentControlContentBlocksTr(view_33.state, filter_1, input, options_2);
13984
14088
  if (!tr_0) return false;
13985
- view_32.dispatch(tr_0);
14089
+ view_33.dispatch(tr_0);
13986
14090
  return true;
13987
14091
  },
13988
14092
  setContentControlValue: (filter_2, input_0, options_3 = {}) => {
13989
- const view_33 = pagedEditorRef.current?.getView();
13990
- if (!view_33) return false;
13991
- const tr_1 = setContentControlValueTr(view_33.state, filter_2, input_0, options_3);
14093
+ const view_34 = pagedEditorRef.current?.getView();
14094
+ if (!view_34) return false;
14095
+ const tr_1 = setContentControlValueTr(view_34.state, filter_2, input_0, options_3);
13992
14096
  if (!tr_1) return false;
13993
- view_33.dispatch(tr_1);
14097
+ view_34.dispatch(tr_1);
13994
14098
  return true;
13995
14099
  },
13996
14100
  removeContentControl: (filter_3, options_4 = {}) => {
13997
- const view_34 = pagedEditorRef.current?.getView();
13998
- if (!view_34) return false;
13999
- const tr_2 = removeContentControlTr(view_34.state, filter_3, options_4);
14101
+ const view_35 = pagedEditorRef.current?.getView();
14102
+ if (!view_35) return false;
14103
+ const tr_2 = removeContentControlTr(view_35.state, filter_3, options_4);
14000
14104
  if (!tr_2) return false;
14001
- view_34.dispatch(tr_2);
14105
+ view_35.dispatch(tr_2);
14002
14106
  return true;
14003
14107
  }
14004
14108
  }), [
@@ -14012,6 +14116,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14012
14116
  loadParsedDocument,
14013
14117
  loadBuffer,
14014
14118
  updateComments,
14119
+ replaceComments,
14120
+ commentsRef,
14015
14121
  commentsDirtyRef,
14016
14122
  hfEditPosition,
14017
14123
  refreshBodyHistoryAvailability
@@ -14067,39 +14173,39 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14067
14173
  if (isDisplayMode(value)) setDisplayMode(value);
14068
14174
  }, [setDisplayMode]);
14069
14175
  const handleAcceptActiveChange = useCallback(() => {
14070
- const view_35 = pagedEditorRef.current?.getView();
14071
- if (!view_35) return;
14072
- const { from: from_10, to: to_10 } = view_35.state.selection;
14073
- const range_4 = findChangeAtPosition(view_35.state, from_10, to_10);
14074
- acceptChange(range_4.from, range_4.to)(view_35.state, view_35.dispatch);
14075
- }, []);
14076
- const handleRejectActiveChange = useCallback(() => {
14077
14176
  const view_36 = pagedEditorRef.current?.getView();
14078
14177
  if (!view_36) return;
14079
- const { from: from_11, to: to_11 } = view_36.state.selection;
14080
- const range_5 = findChangeAtPosition(view_36.state, from_11, to_11);
14081
- rejectChange(range_5.from, range_5.to)(view_36.state, view_36.dispatch);
14178
+ const { from: from_10, to: to_10 } = view_36.state.selection;
14179
+ const range_4 = findChangeAtPosition(view_36.state, from_10, to_10);
14180
+ acceptChange(range_4.from, range_4.to)(view_36.state, view_36.dispatch);
14082
14181
  }, []);
14083
- const handlePreviousChange = useCallback(() => {
14182
+ const handleRejectActiveChange = useCallback(() => {
14084
14183
  const view_37 = pagedEditorRef.current?.getView();
14085
14184
  if (!view_37) return;
14086
- const { from: from_12 } = view_37.state.selection;
14087
- const change = findPreviousChange(view_37.state, from_12);
14185
+ const { from: from_11, to: to_11 } = view_37.state.selection;
14186
+ const range_5 = findChangeAtPosition(view_37.state, from_11, to_11);
14187
+ rejectChange(range_5.from, range_5.to)(view_37.state, view_37.dispatch);
14188
+ }, []);
14189
+ const handlePreviousChange = useCallback(() => {
14190
+ const view_38 = pagedEditorRef.current?.getView();
14191
+ if (!view_38) return;
14192
+ const { from: from_12 } = view_38.state.selection;
14193
+ const change = findPreviousChange(view_38.state, from_12);
14088
14194
  if (!change) return;
14089
- view_37.dispatch(view_37.state.tr.setSelection(TextSelection.create(view_37.state.doc, change.from, change.to)));
14090
- view_37.focus();
14195
+ view_38.dispatch(view_38.state.tr.setSelection(TextSelection.create(view_38.state.doc, change.from, change.to)));
14196
+ view_38.focus();
14091
14197
  requestAnimationFrame(() => {
14092
14198
  pagedEditorRef.current?.scrollToPosition(change.from);
14093
14199
  });
14094
14200
  }, []);
14095
14201
  const handleNextChange = useCallback(() => {
14096
- const view_38 = pagedEditorRef.current?.getView();
14097
- if (!view_38) return;
14098
- const { to: to_12 } = view_38.state.selection;
14099
- const change_0 = findNextChange(view_38.state, to_12);
14202
+ const view_39 = pagedEditorRef.current?.getView();
14203
+ if (!view_39) return;
14204
+ const { to: to_12 } = view_39.state.selection;
14205
+ const change_0 = findNextChange(view_39.state, to_12);
14100
14206
  if (!change_0) return;
14101
- view_38.dispatch(view_38.state.tr.setSelection(TextSelection.create(view_38.state.doc, change_0.from, change_0.to)));
14102
- view_38.focus();
14207
+ view_39.dispatch(view_39.state.tr.setSelection(TextSelection.create(view_39.state.doc, change_0.from, change_0.to)));
14208
+ view_39.focus();
14103
14209
  requestAnimationFrame(() => {
14104
14210
  pagedEditorRef.current?.scrollToPosition(change_0.from);
14105
14211
  });
@@ -14269,8 +14375,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14269
14375
  requestAnimationFrame(syncCommentHighlightStyles);
14270
14376
  }, [onScrollTopChange, syncCommentHighlightStyles]);
14271
14377
  const handlePagedSelectionChange = useCallback((_from, _to) => {
14272
- const view_39 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
14273
- handleSelectionChange(view_39 ? extractSelectionState(view_39.state) : null);
14378
+ const view_40 = getActiveEditorView() ?? pagedEditorRef.current?.getView() ?? null;
14379
+ handleSelectionChange(view_40 ? extractSelectionState(view_40.state) : null);
14274
14380
  }, [getActiveEditorView, handleSelectionChange]);
14275
14381
  const handleTotalPagesChange = useCallback((totalPages) => {
14276
14382
  setScrollPageInfo((previous) => updateScrollPageTotal(previous, totalPages));
@@ -14295,9 +14401,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14295
14401
  }, [author, updateComments]);
14296
14402
  const handleAddComment = useCallback((addText) => {
14297
14403
  const comment_3 = createComment(addText, author);
14298
- const view_40 = pagedEditorRef.current?.getView();
14299
- if (!view_40 || !commentSelectionRange) return false;
14300
- if (!applyCommentMarkRange(view_40, commentSelectionRange, comment_3.id, { replacePending: true })) return false;
14404
+ const view_41 = pagedEditorRef.current?.getView();
14405
+ if (!view_41 || !commentSelectionRange) return false;
14406
+ if (!applyCommentMarkRange(view_41, commentSelectionRange, comment_3.id, { replacePending: true })) return false;
14301
14407
  const commentAuthor_2 = getCommentAuthorKey(comment_3.author);
14302
14408
  setVisibleCommentAuthors((current) => {
14303
14409
  if (current === null) return null;
@@ -14331,8 +14437,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14331
14437
  updateComments((previous_4) => [...previous_4, createComment(text_6, author, revisionId_2)]);
14332
14438
  }, [author, updateComments]);
14333
14439
  const handleCancelAddComment = useCallback(() => {
14334
- const view_41 = pagedEditorRef.current?.getView();
14335
- if (view_41 && commentSelectionRange) removePendingCommentMarkRange(view_41, commentSelectionRange);
14440
+ const view_42 = pagedEditorRef.current?.getView();
14441
+ if (view_42 && commentSelectionRange) removePendingCommentMarkRange(view_42, commentSelectionRange);
14336
14442
  setIsAddingComment(false);
14337
14443
  setCommentSelectionRange(null);
14338
14444
  setAddCommentYPosition(null);
@@ -14343,15 +14449,15 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14343
14449
  setIsAddingComment
14344
14450
  ]);
14345
14451
  const handleSidebarAcceptChange = useCallback((from_13, to_13) => {
14346
- const view_42 = pagedEditorRef.current?.getView();
14347
- if (!view_42) return;
14348
- acceptChange(from_13, to_13)(view_42.state, view_42.dispatch);
14452
+ const view_43 = pagedEditorRef.current?.getView();
14453
+ if (!view_43) return;
14454
+ acceptChange(from_13, to_13)(view_43.state, view_43.dispatch);
14349
14455
  extractTrackedChanges();
14350
14456
  }, [extractTrackedChanges]);
14351
14457
  const handleSidebarRejectChange = useCallback((from_14, to_14) => {
14352
- const view_43 = pagedEditorRef.current?.getView();
14353
- if (!view_43) return;
14354
- rejectChange(from_14, to_14)(view_43.state, view_43.dispatch);
14458
+ const view_44 = pagedEditorRef.current?.getView();
14459
+ if (!view_44) return;
14460
+ rejectChange(from_14, to_14)(view_44.state, view_44.dispatch);
14355
14461
  extractTrackedChanges();
14356
14462
  }, [extractTrackedChanges]);
14357
14463
  const commentsPageWidth = history.state?.package.document.finalSectionProperties?.pageWidth;
@@ -14424,8 +14530,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14424
14530
  const getBodyEditorView = useCallback(() => pagedEditorRef.current?.getView() ?? null, []);
14425
14531
  const closeTableProperties = useCallback(() => setTablePropsOpen(false), []);
14426
14532
  const applyTableProperties = useCallback((props_0) => {
14427
- const view_44 = getActiveEditorView();
14428
- if (view_44) setTableProperties(props_0)(view_44.state, view_44.dispatch);
14533
+ const view_45 = getActiveEditorView();
14534
+ if (view_45) setTableProperties(props_0)(view_45.state, view_45.dispatch);
14429
14535
  }, [getActiveEditorView]);
14430
14536
  const closeImagePosition = useCallback(() => setImagePositionOpen(false), [setImagePositionOpen]);
14431
14537
  const closeImageProperties = useCallback(() => setImagePropsOpen(false), [setImagePropsOpen]);
@@ -14433,8 +14539,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14433
14539
  const closeFootnoteProperties = useCallback(() => setFootnotePropsOpen(false), []);
14434
14540
  const closeInsertSymbol = useCallback(() => setShowInsertSymbol(false), []);
14435
14541
  const insertSymbol = useCallback((symbol) => {
14436
- const view_45 = getActiveEditorView();
14437
- if (view_45) view_45.dispatch(view_45.state.tr.insertText(symbol).scrollIntoView());
14542
+ const view_46 = getActiveEditorView();
14543
+ if (view_46) view_46.dispatch(view_46.state.tr.insertText(symbol).scrollIntoView());
14438
14544
  }, [getActiveEditorView]);
14439
14545
  const imagePropertiesCurrentData = useMemo(() => buildImagePropertiesData(state.pmImageContext), [state.pmImageContext]);
14440
14546
  const currentFindResult = findResultRef.current;
@@ -14760,8 +14866,8 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14760
14866
  onMouseDown: (e_1) => {
14761
14867
  e_1.preventDefault();
14762
14868
  e_1.stopPropagation();
14763
- const view_46 = pagedEditorRef.current?.getView();
14764
- if (!view_46) {
14869
+ const view_47 = pagedEditorRef.current?.getView();
14870
+ if (!view_47) {
14765
14871
  setFloatingCommentBtn(null);
14766
14872
  return;
14767
14873
  }
@@ -14769,9 +14875,9 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14769
14875
  from: floatingCommentBtn.from,
14770
14876
  to: floatingCommentBtn.to
14771
14877
  };
14772
- const currentSelection = view_46.state.selection;
14878
+ const currentSelection = view_47.state.selection;
14773
14879
  const safeRange = resolveCommentCreationRange({
14774
- docSize: view_46.state.doc.content.size,
14880
+ docSize: view_47.state.doc.content.size,
14775
14881
  capturedRange,
14776
14882
  currentRange: {
14777
14883
  from: currentSelection.from,
@@ -14785,7 +14891,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14785
14891
  return;
14786
14892
  }
14787
14893
  setCommentSelectionRange(safeRange);
14788
- if (!applyCommentMarkRange(view_46, safeRange, -1, { selectEnd: true })) {
14894
+ if (!applyCommentMarkRange(view_47, safeRange, -1, { selectEnd: true })) {
14789
14895
  setCommentSelectionRange(null);
14790
14896
  setFloatingCommentBtn(null);
14791
14897
  return;
@@ -14858,7 +14964,7 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14858
14964
  })
14859
14965
  })]
14860
14966
  }),
14861
- scrollPageInfo.totalPages > 1 && /* @__PURE__ */ jsxs("div", {
14967
+ scrollPageInfo.totalPages > 1 && /* @__PURE__ */ jsx("div", {
14862
14968
  style: {
14863
14969
  position: "absolute",
14864
14970
  right: 24,
@@ -14879,11 +14985,10 @@ const DocxEditor = forwardRef(function DocxEditor({ documentBuffer, password, do
14879
14985
  },
14880
14986
  "aria-live": "polite",
14881
14987
  role: "status",
14882
- children: [
14883
- scrollPageInfo.currentPage,
14884
- " of ",
14885
- scrollPageInfo.totalPages
14886
- ]
14988
+ children: t("viewer.pageOfTotal", {
14989
+ current: String(scrollPageInfo.currentPage),
14990
+ total: String(scrollPageInfo.totalPages)
14991
+ })
14887
14992
  }),
14888
14993
  showOutline && outlineHeadings.length > 1 && /* @__PURE__ */ jsx(DocumentOutline, {
14889
14994
  headings: outlineHeadings,