@extend-ai/react-docx 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1503,7 +1503,7 @@ __export(index_exports, {
1503
1503
  });
1504
1504
  module.exports = __toCommonJS(index_exports);
1505
1505
  init_cjs_shims();
1506
- var React2 = __toESM(require("react"), 1);
1506
+ var React3 = __toESM(require("react"), 1);
1507
1507
  var import_react_dom2 = require("react-dom");
1508
1508
 
1509
1509
  // ../layout-engine/src/index.ts
@@ -1933,7 +1933,7 @@ async function importDocxBuffer(buffer, options = {}) {
1933
1933
 
1934
1934
  // src/editor.tsx
1935
1935
  init_cjs_shims();
1936
- var React = __toESM(require("react"), 1);
1936
+ var React2 = __toESM(require("react"), 1);
1937
1937
  var import_react_dom = require("react-dom");
1938
1938
 
1939
1939
  // src/pointer-drag.ts
@@ -2118,6 +2118,247 @@ function startObjectDrag(options) {
2118
2118
  return cancel;
2119
2119
  }
2120
2120
 
2121
+ // src/viewer-zoom.ts
2122
+ init_cjs_shims();
2123
+ var React = __toESM(require("react"), 1);
2124
+ var VIEWER_ZOOM_MIN = 50;
2125
+ var VIEWER_ZOOM_MAX = 200;
2126
+ function normalizeViewerZoomLevel(level) {
2127
+ if (typeof level !== "number") {
2128
+ return level;
2129
+ }
2130
+ if (!Number.isFinite(level)) {
2131
+ return 100;
2132
+ }
2133
+ return Math.max(VIEWER_ZOOM_MIN, Math.min(VIEWER_ZOOM_MAX, level));
2134
+ }
2135
+ function resolveViewerZoom(level, dimensions) {
2136
+ const normalizedLevel = normalizeViewerZoomLevel(level);
2137
+ if (typeof normalizedLevel === "number") {
2138
+ return normalizedLevel;
2139
+ }
2140
+ const safeContentWidth = Math.max(1, dimensions.contentWidth);
2141
+ const safeContentHeight = Math.max(1, dimensions.contentHeight);
2142
+ const fitWidth = Math.max(1, dimensions.viewportWidth) / safeContentWidth * 100;
2143
+ const fitHeight = Math.max(1, dimensions.viewportHeight) / safeContentHeight * 100;
2144
+ const resolved = normalizedLevel === "fit-page" ? Math.min(fitWidth, fitHeight) : normalizedLevel === "automatic" ? Math.min(fitWidth, 100) : fitWidth;
2145
+ return Math.max(
2146
+ VIEWER_ZOOM_MIN,
2147
+ Math.min(VIEWER_ZOOM_MAX, resolved)
2148
+ );
2149
+ }
2150
+ function isWindowScroller(element) {
2151
+ return element === document.documentElement || element === document.body || element === document.scrollingElement;
2152
+ }
2153
+ function nearestScrollableAncestor(element) {
2154
+ let current = element.parentElement;
2155
+ while (current) {
2156
+ const style = window.getComputedStyle(current);
2157
+ if (/(auto|scroll|overlay|hidden)/.test(`${style.overflow} ${style.overflowY}`)) {
2158
+ return current;
2159
+ }
2160
+ current = current.parentElement;
2161
+ }
2162
+ return document.scrollingElement ?? document.documentElement;
2163
+ }
2164
+ function elementPadding(element) {
2165
+ const style = window.getComputedStyle(element);
2166
+ const number = (value) => {
2167
+ const parsed = Number.parseFloat(value);
2168
+ return Number.isFinite(parsed) ? parsed : 0;
2169
+ };
2170
+ return {
2171
+ horizontal: number(style.paddingLeft) + number(style.paddingRight),
2172
+ vertical: number(style.paddingTop) + number(style.paddingBottom)
2173
+ };
2174
+ }
2175
+ function viewportRect(scroller) {
2176
+ if (isWindowScroller(scroller)) {
2177
+ return { top: 0, bottom: window.innerHeight };
2178
+ }
2179
+ const rect = scroller.getBoundingClientRect();
2180
+ return { top: rect.top, bottom: rect.bottom };
2181
+ }
2182
+ function captureAnchor(root, scroller, pageSelector) {
2183
+ const viewport = viewportRect(scroller);
2184
+ let best;
2185
+ root.querySelectorAll(pageSelector).forEach((element2) => {
2186
+ const rect2 = element2.getBoundingClientRect();
2187
+ const visible = Math.max(
2188
+ 0,
2189
+ Math.min(rect2.bottom, viewport.bottom) - Math.max(rect2.top, viewport.top)
2190
+ );
2191
+ if (!best || visible > best.visible) {
2192
+ best = { element: element2, visible };
2193
+ }
2194
+ });
2195
+ if (!best || best.visible <= 0) {
2196
+ return void 0;
2197
+ }
2198
+ const element = best.element;
2199
+ const rect = element.getBoundingClientRect();
2200
+ const pageIndex = element.dataset.docxPageIndex ?? element.dataset.pageIndex ?? element.dataset.page;
2201
+ if (!pageIndex || rect.height <= 0) {
2202
+ return void 0;
2203
+ }
2204
+ return {
2205
+ pageIndex,
2206
+ progress: Math.max(0, Math.min(1, (viewport.top - rect.top) / rect.height))
2207
+ };
2208
+ }
2209
+ function restoreAnchor(root, scroller, pageSelector, anchor) {
2210
+ const page = Array.from(root.querySelectorAll(pageSelector)).find(
2211
+ (element) => (element.dataset.docxPageIndex ?? element.dataset.pageIndex ?? element.dataset.page) === anchor.pageIndex
2212
+ );
2213
+ if (!page) {
2214
+ return;
2215
+ }
2216
+ const viewport = viewportRect(scroller);
2217
+ const rect = page.getBoundingClientRect();
2218
+ const desiredTop = viewport.top - anchor.progress * rect.height;
2219
+ const delta = rect.top - desiredTop;
2220
+ if (Math.abs(delta) < 0.5) {
2221
+ return;
2222
+ }
2223
+ if (isWindowScroller(scroller)) {
2224
+ window.scrollBy(0, delta);
2225
+ } else {
2226
+ scroller.scrollTop += delta;
2227
+ }
2228
+ }
2229
+ function useViewerZoom({
2230
+ zoom,
2231
+ defaultZoom = 100,
2232
+ onZoomChange,
2233
+ rootRef,
2234
+ contentWidth,
2235
+ contentHeight,
2236
+ pageSelector,
2237
+ onBridgeChange
2238
+ }) {
2239
+ const controlled = zoom !== void 0;
2240
+ const [uncontrolledLevel, setUncontrolledLevel] = React.useState(
2241
+ () => normalizeViewerZoomLevel(defaultZoom)
2242
+ );
2243
+ const level = normalizeViewerZoomLevel(controlled ? zoom : uncontrolledLevel);
2244
+ const levelRef = React.useRef(level);
2245
+ levelRef.current = level;
2246
+ const [resolvedZoom, setResolvedZoom] = React.useState(
2247
+ () => typeof level === "number" ? level : 100
2248
+ );
2249
+ const resolvedZoomRef = React.useRef(resolvedZoom);
2250
+ resolvedZoomRef.current = resolvedZoom;
2251
+ const onZoomChangeRef = React.useRef(onZoomChange);
2252
+ onZoomChangeRef.current = onZoomChange;
2253
+ const controlledRef = React.useRef(controlled);
2254
+ controlledRef.current = controlled;
2255
+ const dimensionsRef = React.useRef(
2256
+ void 0
2257
+ );
2258
+ const pendingAnchorRef = React.useRef(void 0);
2259
+ const scrollerRef = React.useRef(void 0);
2260
+ const lastEmittedRef = React.useRef(void 0);
2261
+ const emit = React.useCallback((state) => {
2262
+ const key = `${state.level}:${state.resolvedZoom.toFixed(4)}`;
2263
+ if (lastEmittedRef.current === key) {
2264
+ return;
2265
+ }
2266
+ lastEmittedRef.current = key;
2267
+ onZoomChangeRef.current?.(state);
2268
+ }, []);
2269
+ const setLevel = React.useCallback(
2270
+ (nextLevel) => {
2271
+ const normalized = normalizeViewerZoomLevel(nextLevel);
2272
+ const root = rootRef.current;
2273
+ const scroller = root ? nearestScrollableAncestor(root) : void 0;
2274
+ if (root && scroller) {
2275
+ pendingAnchorRef.current = captureAnchor(root, scroller, pageSelector);
2276
+ }
2277
+ const nextResolved = typeof normalized === "number" ? normalized : dimensionsRef.current ? resolveViewerZoom(normalized, dimensionsRef.current) : resolvedZoomRef.current;
2278
+ if (!controlledRef.current) {
2279
+ levelRef.current = normalized;
2280
+ resolvedZoomRef.current = nextResolved;
2281
+ setUncontrolledLevel(normalized);
2282
+ setResolvedZoom(nextResolved);
2283
+ }
2284
+ emit({ level: normalized, resolvedZoom: nextResolved });
2285
+ },
2286
+ [emit, pageSelector, rootRef]
2287
+ );
2288
+ const bridge = React.useMemo(
2289
+ () => ({
2290
+ setZoom: setLevel,
2291
+ getZoom: () => levelRef.current,
2292
+ getResolvedZoom: () => resolvedZoomRef.current
2293
+ }),
2294
+ [setLevel]
2295
+ );
2296
+ React.useLayoutEffect(() => {
2297
+ onBridgeChange?.(bridge);
2298
+ return () => onBridgeChange?.(void 0);
2299
+ }, [bridge, onBridgeChange]);
2300
+ React.useLayoutEffect(() => {
2301
+ const root = rootRef.current;
2302
+ if (!root || typeof window === "undefined") {
2303
+ return;
2304
+ }
2305
+ const scroller = nearestScrollableAncestor(root);
2306
+ scrollerRef.current = scroller;
2307
+ let frame = 0;
2308
+ const recalculate = () => {
2309
+ frame = 0;
2310
+ const scrollerPadding = elementPadding(scroller);
2311
+ const rootPadding = elementPadding(root);
2312
+ const viewportWidth = (isWindowScroller(scroller) ? window.innerWidth : scroller.clientWidth) - scrollerPadding.horizontal;
2313
+ const viewportHeight = (isWindowScroller(scroller) ? window.innerHeight : scroller.clientHeight) - scrollerPadding.vertical;
2314
+ const dimensions = {
2315
+ viewportWidth,
2316
+ viewportHeight,
2317
+ contentWidth: contentWidth + rootPadding.horizontal,
2318
+ contentHeight: contentHeight + rootPadding.vertical
2319
+ };
2320
+ dimensionsRef.current = dimensions;
2321
+ const nextResolved = resolveViewerZoom(levelRef.current, dimensions);
2322
+ if (Math.abs(nextResolved - resolvedZoomRef.current) < 0.01) {
2323
+ return;
2324
+ }
2325
+ pendingAnchorRef.current = captureAnchor(root, scroller, pageSelector);
2326
+ resolvedZoomRef.current = nextResolved;
2327
+ setResolvedZoom(nextResolved);
2328
+ emit({ level: levelRef.current, resolvedZoom: nextResolved });
2329
+ };
2330
+ const schedule = () => {
2331
+ if (frame) {
2332
+ cancelAnimationFrame(frame);
2333
+ }
2334
+ frame = requestAnimationFrame(recalculate);
2335
+ };
2336
+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(schedule) : void 0;
2337
+ observer?.observe(scroller);
2338
+ observer?.observe(root);
2339
+ window.addEventListener("resize", schedule);
2340
+ recalculate();
2341
+ return () => {
2342
+ if (frame) {
2343
+ cancelAnimationFrame(frame);
2344
+ }
2345
+ observer?.disconnect();
2346
+ window.removeEventListener("resize", schedule);
2347
+ };
2348
+ }, [contentHeight, contentWidth, emit, pageSelector, rootRef, level]);
2349
+ React.useLayoutEffect(() => {
2350
+ const root = rootRef.current;
2351
+ const scroller = scrollerRef.current;
2352
+ const anchor = pendingAnchorRef.current;
2353
+ if (!root || !scroller || !anchor) {
2354
+ return;
2355
+ }
2356
+ pendingAnchorRef.current = void 0;
2357
+ restoreAnchor(root, scroller, pageSelector, anchor);
2358
+ }, [pageSelector, resolvedZoom, rootRef]);
2359
+ return { level, resolvedZoom };
2360
+ }
2361
+
2121
2362
  // src/image-drop.ts
2122
2363
  init_cjs_shims();
2123
2364
  function copyModelForParagraphEdits(model, locations) {
@@ -8221,7 +8462,7 @@ function clampNumber(value, min, max) {
8221
8462
  function hasVerticalScrollOverflow(value) {
8222
8463
  return value === "auto" || value === "scroll" || value === "overlay" || value === "hidden";
8223
8464
  }
8224
- function nearestScrollableAncestor(element) {
8465
+ function nearestScrollableAncestor2(element) {
8225
8466
  let current = element;
8226
8467
  while (current) {
8227
8468
  const style = window.getComputedStyle(current);
@@ -9948,6 +10189,18 @@ function normalizeTextRange(range) {
9948
10189
  end: range.start
9949
10190
  };
9950
10191
  }
10192
+ var viewerZoomBridgeByController = /* @__PURE__ */ new WeakMap();
10193
+ function viewerZoomControllerKey(editor) {
10194
+ return editor.syncPaginationInfo;
10195
+ }
10196
+ function setViewerZoomBridge(editor, bridge) {
10197
+ const key = viewerZoomControllerKey(editor);
10198
+ if (bridge) {
10199
+ viewerZoomBridgeByController.set(key, bridge);
10200
+ } else {
10201
+ viewerZoomBridgeByController.delete(key);
10202
+ }
10203
+ }
9951
10204
  var defaultStarterModel = {
9952
10205
  nodes: [
9953
10206
  {
@@ -24316,14 +24569,14 @@ function updateSectionImageFloatingAtLocation(model, location, patch) {
24316
24569
  return changed ? next : model;
24317
24570
  }
24318
24571
  function useDocxEditor(options = {}) {
24319
- const [starterTemplate] = React.useState(
24572
+ const [starterTemplate] = React2.useState(
24320
24573
  () => cloneDocModelWithBlockIds(options.starterModel ?? defaultStarterModel)
24321
24574
  );
24322
- const starterTemplateRef = React.useRef(starterTemplate);
24323
- const [initialModel] = React.useState(
24575
+ const starterTemplateRef = React2.useRef(starterTemplate);
24576
+ const [initialModel] = React2.useState(
24324
24577
  () => cloneDocModelWithBlockIds(options.document?.model ?? starterTemplate)
24325
24578
  );
24326
- const [editorState, dispatchCanonicalEditorState] = React.useReducer(
24579
+ const [editorState, dispatchCanonicalEditorState] = React2.useReducer(
24327
24580
  reduceDocxEditorState,
24328
24581
  initialModel,
24329
24582
  (initialModel2) => ({
@@ -24341,8 +24594,8 @@ function useDocxEditor(options = {}) {
24341
24594
  })
24342
24595
  );
24343
24596
  const { model, selection, activeTextRange, pendingRunStyle, history } = editorState;
24344
- const canonicalEditorStateRef = React.useRef(editorState);
24345
- const applyCanonicalEditorStateAction = React.useCallback(
24597
+ const canonicalEditorStateRef = React2.useRef(editorState);
24598
+ const applyCanonicalEditorStateAction = React2.useCallback(
24346
24599
  (action) => {
24347
24600
  const previous = canonicalEditorStateRef.current;
24348
24601
  const next = reduceDocxEditorState(previous, action);
@@ -24354,7 +24607,7 @@ function useDocxEditor(options = {}) {
24354
24607
  },
24355
24608
  []
24356
24609
  );
24357
- const setModel = React.useCallback(
24610
+ const setModel = React2.useCallback(
24358
24611
  (value) => {
24359
24612
  const currentModel = canonicalEditorStateRef.current.model;
24360
24613
  const nextModel = typeof value === "function" ? value(currentModel) : value;
@@ -24366,7 +24619,7 @@ function useDocxEditor(options = {}) {
24366
24619
  },
24367
24620
  [applyCanonicalEditorStateAction]
24368
24621
  );
24369
- const setSelection = React.useCallback(
24622
+ const setSelection = React2.useCallback(
24370
24623
  (value) => {
24371
24624
  const currentSelection = canonicalEditorStateRef.current.selection;
24372
24625
  const nextSelection = typeof value === "function" ? value(currentSelection) : value;
@@ -24378,7 +24631,7 @@ function useDocxEditor(options = {}) {
24378
24631
  },
24379
24632
  [applyCanonicalEditorStateAction]
24380
24633
  );
24381
- const setActiveTextRangeState = React.useCallback(
24634
+ const setActiveTextRangeState = React2.useCallback(
24382
24635
  (value) => {
24383
24636
  const currentRange = canonicalEditorStateRef.current.activeTextRange;
24384
24637
  const nextRange = typeof value === "function" ? value(currentRange) : value;
@@ -24390,7 +24643,7 @@ function useDocxEditor(options = {}) {
24390
24643
  },
24391
24644
  [applyCanonicalEditorStateAction]
24392
24645
  );
24393
- const setPendingRunStyle = React.useCallback(
24646
+ const setPendingRunStyle = React2.useCallback(
24394
24647
  (value) => {
24395
24648
  const currentStyle = canonicalEditorStateRef.current.pendingRunStyle;
24396
24649
  const nextStyle = typeof value === "function" ? value(currentStyle) : value;
@@ -24402,7 +24655,7 @@ function useDocxEditor(options = {}) {
24402
24655
  },
24403
24656
  [applyCanonicalEditorStateAction]
24404
24657
  );
24405
- const setHistory = React.useCallback(
24658
+ const setHistory = React2.useCallback(
24406
24659
  (value) => {
24407
24660
  const currentHistory = canonicalEditorStateRef.current.history;
24408
24661
  const nextHistory = typeof value === "function" ? value(currentHistory) : value;
@@ -24413,61 +24666,65 @@ function useDocxEditor(options = {}) {
24413
24666
  },
24414
24667
  [applyCanonicalEditorStateAction]
24415
24668
  );
24416
- const [basePackage, setBasePackage] = React.useState(options.document?.package);
24417
- const [documentLoadNonce, setDocumentLoadNonce] = React.useState(0);
24418
- const documentLoadNonceRef = React.useRef(0);
24419
- const advanceDocumentLoadNonce = React.useCallback(() => {
24669
+ const [basePackage, setBasePackage] = React2.useState(options.document?.package);
24670
+ const [documentLoadNonce, setDocumentLoadNonce] = React2.useState(0);
24671
+ const documentLoadNonceRef = React2.useRef(0);
24672
+ const advanceDocumentLoadNonce = React2.useCallback(() => {
24420
24673
  documentLoadNonceRef.current += 1;
24421
24674
  setDocumentLoadNonce(documentLoadNonceRef.current);
24422
24675
  }, []);
24423
- const [fileName, setFileName] = React.useState(
24676
+ const [fileName, setFileName] = React2.useState(
24424
24677
  options.initialFileName ?? options.document?.fileName ?? "(new document)"
24425
24678
  );
24426
- const [selectedFormFieldLocation, setSelectedFormFieldLocation] = React.useState();
24427
- const [status, setStatus] = React.useState(
24679
+ const [selectedFormFieldLocation, setSelectedFormFieldLocation] = React2.useState();
24680
+ const [status, setStatus] = React2.useState(
24428
24681
  options.initialStatus ?? (options.document?.fileName ? `Loaded ${options.document.fileName}` : "Ready")
24429
24682
  );
24430
- const [importError, setImportError] = React.useState();
24431
- const [isImporting, setIsImporting] = React.useState(false);
24432
- const [documentTheme, setDocumentThemeState] = React.useState(options.initialDocumentTheme ?? "light");
24433
- const [showTrackedChanges, setShowTrackedChangesState] = React.useState(options.initialShowTrackedChanges ?? false);
24434
- const [showComments, setShowCommentsState] = React.useState(
24683
+ const [importError, setImportError] = React2.useState();
24684
+ const [isImporting, setIsImporting] = React2.useState(false);
24685
+ const [documentTheme, setDocumentThemeState] = React2.useState(options.initialDocumentTheme ?? "light");
24686
+ const [showTrackedChanges, setShowTrackedChangesState] = React2.useState(options.initialShowTrackedChanges ?? false);
24687
+ const [showComments, setShowCommentsState] = React2.useState(
24435
24688
  options.initialShowComments ?? false
24436
24689
  );
24437
- const [paginationInfo, setPaginationInfo] = React.useState({
24690
+ const [paginationInfo, setPaginationInfo] = React2.useState({
24438
24691
  currentPage: 1,
24439
24692
  totalPages: 1
24440
24693
  });
24441
- const activeImportAbortControllerRef = React.useRef(void 0);
24442
- const [historyRestoreRequest, setHistoryRestoreRequest] = React.useState();
24443
- const [selectionSessionKind, setSelectionSessionKind] = React.useState("idle");
24444
- const modelRef = React.useRef(model);
24445
- const selectionRef = React.useRef(selection);
24446
- const activeTextRangeRef = React.useRef(
24694
+ const fallbackZoomRef = React2.useRef({
24695
+ level: 100,
24696
+ resolvedZoom: 100
24697
+ });
24698
+ const activeImportAbortControllerRef = React2.useRef(void 0);
24699
+ const [historyRestoreRequest, setHistoryRestoreRequest] = React2.useState();
24700
+ const [selectionSessionKind, setSelectionSessionKind] = React2.useState("idle");
24701
+ const modelRef = React2.useRef(model);
24702
+ const selectionRef = React2.useRef(selection);
24703
+ const activeTextRangeRef = React2.useRef(
24447
24704
  activeTextRange
24448
24705
  );
24449
- const pendingRunStyleRef = React.useRef(
24706
+ const pendingRunStyleRef = React2.useRef(
24450
24707
  pendingRunStyle
24451
24708
  );
24452
- const suppressNextDomSelectionRestoreRef = React.useRef(false);
24453
- const textCommitBurstRef = React.useRef(
24709
+ const suppressNextDomSelectionRestoreRef = React2.useRef(false);
24710
+ const textCommitBurstRef = React2.useRef(
24454
24711
  void 0
24455
24712
  );
24456
- const domSelectionRestoreModelRef = React.useRef(model);
24457
- const selectionSessionRef = React.useRef("idle");
24458
- const selectionSessionTimeoutRef = React.useRef(null);
24459
- const lastInViewerActiveTextRangeRef = React.useRef(void 0);
24460
- const suppressSelectionResetRef = React.useRef(false);
24461
- const historyRestoreNonceRef = React.useRef(0);
24462
- const embeddedFontLoadNonceRef = React.useRef(0);
24463
- const loadedEmbeddedFontFacesRef = React.useRef([]);
24464
- React.useEffect(() => {
24713
+ const domSelectionRestoreModelRef = React2.useRef(model);
24714
+ const selectionSessionRef = React2.useRef("idle");
24715
+ const selectionSessionTimeoutRef = React2.useRef(null);
24716
+ const lastInViewerActiveTextRangeRef = React2.useRef(void 0);
24717
+ const suppressSelectionResetRef = React2.useRef(false);
24718
+ const historyRestoreNonceRef = React2.useRef(0);
24719
+ const embeddedFontLoadNonceRef = React2.useRef(0);
24720
+ const loadedEmbeddedFontFacesRef = React2.useRef([]);
24721
+ React2.useEffect(() => {
24465
24722
  canonicalEditorStateRef.current = editorState;
24466
24723
  }, [editorState]);
24467
- React.useEffect(() => {
24724
+ React2.useEffect(() => {
24468
24725
  modelRef.current = model;
24469
24726
  }, [model]);
24470
- React.useEffect(() => {
24727
+ React2.useEffect(() => {
24471
24728
  if (typeof process === "undefined" || process.env?.NODE_ENV === "production") {
24472
24729
  return;
24473
24730
  }
@@ -24480,10 +24737,10 @@ function useDocxEditor(options = {}) {
24480
24737
  );
24481
24738
  }
24482
24739
  }, [model]);
24483
- React.useEffect(() => {
24740
+ React2.useEffect(() => {
24484
24741
  selectionRef.current = selection;
24485
24742
  }, [selection]);
24486
- const selectedFormField = React.useMemo(() => {
24743
+ const selectedFormField = React2.useMemo(() => {
24487
24744
  if (!selectedFormFieldLocation) {
24488
24745
  return void 0;
24489
24746
  }
@@ -24505,22 +24762,22 @@ function useDocxEditor(options = {}) {
24505
24762
  field: child
24506
24763
  };
24507
24764
  }, [model, selectedFormFieldLocation]);
24508
- React.useEffect(() => {
24765
+ React2.useEffect(() => {
24509
24766
  activeTextRangeRef.current = activeTextRange;
24510
24767
  if (activeTextRange) {
24511
24768
  lastInViewerActiveTextRangeRef.current = cloneTextRange(activeTextRange);
24512
24769
  }
24513
24770
  }, [activeTextRange]);
24514
- React.useEffect(() => {
24771
+ React2.useEffect(() => {
24515
24772
  pendingRunStyleRef.current = pendingRunStyle;
24516
24773
  }, [pendingRunStyle]);
24517
- React.useEffect(() => {
24774
+ React2.useEffect(() => {
24518
24775
  setPaginationInfo({
24519
24776
  currentPage: 1,
24520
24777
  totalPages: 1
24521
24778
  });
24522
24779
  }, [documentLoadNonce]);
24523
- const clearSelectionSession = React.useCallback(
24780
+ const clearSelectionSession = React2.useCallback(
24524
24781
  (expectedKind) => {
24525
24782
  if (expectedKind && selectionSessionRef.current !== expectedKind) {
24526
24783
  return;
@@ -24536,7 +24793,7 @@ function useDocxEditor(options = {}) {
24536
24793
  },
24537
24794
  []
24538
24795
  );
24539
- const beginSelectionSession = React.useCallback(
24796
+ const beginSelectionSession = React2.useCallback(
24540
24797
  (kind, options2) => {
24541
24798
  if (selectionSessionTimeoutRef.current !== null && typeof window !== "undefined") {
24542
24799
  window.clearTimeout(selectionSessionTimeoutRef.current);
@@ -24559,7 +24816,7 @@ function useDocxEditor(options = {}) {
24559
24816
  },
24560
24817
  []
24561
24818
  );
24562
- React.useEffect(() => {
24819
+ React2.useEffect(() => {
24563
24820
  const normalizedCursorState = normalizeEditorCursorStateForModel(
24564
24821
  model,
24565
24822
  selection,
@@ -24610,7 +24867,7 @@ function useDocxEditor(options = {}) {
24610
24867
  activeTextRange: cloneTextRange(nextRange)
24611
24868
  });
24612
24869
  }, [model]);
24613
- React.useEffect(() => {
24870
+ React2.useEffect(() => {
24614
24871
  if (!selectedFormFieldLocation) {
24615
24872
  return;
24616
24873
  }
@@ -24623,14 +24880,14 @@ function useDocxEditor(options = {}) {
24623
24880
  setSelectedFormFieldLocation(void 0);
24624
24881
  }
24625
24882
  }, [model, selectedFormFieldLocation]);
24626
- const selectedParagraphLocation = React.useMemo(
24883
+ const selectedParagraphLocation = React2.useMemo(
24627
24884
  () => resolveSelectedParagraphLocation(selection, activeTextRange),
24628
24885
  [activeTextRange, selection]
24629
24886
  );
24630
- const selectedParagraph = React.useMemo(() => {
24887
+ const selectedParagraph = React2.useMemo(() => {
24631
24888
  return getParagraphAtLocation(model, selectedParagraphLocation).paragraph;
24632
24889
  }, [model, selectedParagraphLocation]);
24633
- const availableParagraphStyles = React.useMemo(() => {
24890
+ const availableParagraphStyles = React2.useMemo(() => {
24634
24891
  const embeddedStyles = model.metadata.paragraphStyles ?? [];
24635
24892
  if (embeddedStyles.length > 0) {
24636
24893
  return normalizeParagraphStyleDefinitionsForUi(embeddedStyles);
@@ -24639,11 +24896,11 @@ function useDocxEditor(options = {}) {
24639
24896
  defaultStarterModel.metadata.paragraphStyles
24640
24897
  );
24641
24898
  }, [model.metadata.paragraphStyles]);
24642
- const paragraphStyleById = React.useMemo(
24899
+ const paragraphStyleById = React2.useMemo(
24643
24900
  () => new Map(availableParagraphStyles.map((style) => [style.id, style])),
24644
24901
  [availableParagraphStyles]
24645
24902
  );
24646
- const selectedParagraphStyleId = React.useMemo(() => {
24903
+ const selectedParagraphStyleId = React2.useMemo(() => {
24647
24904
  if (!selectedParagraph) {
24648
24905
  return model.metadata.defaultParagraphStyleId ?? availableParagraphStyles.find((style) => style.isDefault)?.id;
24649
24906
  }
@@ -24663,7 +24920,7 @@ function useDocxEditor(options = {}) {
24663
24920
  availableParagraphStyles,
24664
24921
  paragraphStyleById
24665
24922
  ]);
24666
- const selectedLineSpacing = React.useMemo(() => {
24923
+ const selectedLineSpacing = React2.useMemo(() => {
24667
24924
  const lineTwipsRaw = selectedParagraph?.style?.spacing?.lineTwips;
24668
24925
  const lineTwips = Number.isFinite(lineTwipsRaw) ? Math.max(1, Math.round(lineTwipsRaw)) : void 0;
24669
24926
  const lineRule = selectedParagraph?.style?.spacing?.lineRule ?? "auto";
@@ -24678,7 +24935,7 @@ function useDocxEditor(options = {}) {
24678
24935
  };
24679
24936
  }, [selectedParagraph]);
24680
24937
  const selectedBorderContext = selectedParagraphLocation.kind === "table-cell" ? "table" : "paragraph";
24681
- const activeBorderPresets = React.useMemo(() => {
24938
+ const activeBorderPresets = React2.useMemo(() => {
24682
24939
  if (selectedParagraphLocation.kind === "table-cell") {
24683
24940
  const node = model.nodes[selectedParagraphLocation.tableIndex];
24684
24941
  if (!node || node.type !== "table") {
@@ -24689,10 +24946,10 @@ function useDocxEditor(options = {}) {
24689
24946
  }
24690
24947
  return paragraphBorderPresetState(selectedParagraph?.style?.borders);
24691
24948
  }, [model.nodes, selectedParagraph, selectedParagraphLocation]);
24692
- const selectedRunStyleFromSelection = React.useMemo(() => {
24949
+ const selectedRunStyleFromSelection = React2.useMemo(() => {
24693
24950
  return runStyleForEditorSelection(model, selection, activeTextRange);
24694
24951
  }, [activeTextRange, model, selection]);
24695
- const selectedRunStyle = React.useMemo(() => {
24952
+ const selectedRunStyle = React2.useMemo(() => {
24696
24953
  const hasExpandedRange = Boolean(
24697
24954
  activeTextRange && compareTextRangeBoundaries(activeTextRange.start, activeTextRange.end) < 0
24698
24955
  );
@@ -24704,7 +24961,7 @@ function useDocxEditor(options = {}) {
24704
24961
  ...pendingRunStyle
24705
24962
  };
24706
24963
  }, [activeTextRange, pendingRunStyle, selectedRunStyleFromSelection]);
24707
- const selectedLink = React.useMemo(() => {
24964
+ const selectedLink = React2.useMemo(() => {
24708
24965
  if (!selectedParagraph || !activeTextRange) {
24709
24966
  return void 0;
24710
24967
  }
@@ -24742,11 +24999,11 @@ function useDocxEditor(options = {}) {
24742
24999
  );
24743
25000
  }, [activeTextRange, selectedParagraph, selectedParagraphLocation]);
24744
25001
  const selectedListType = selectedParagraph ? paragraphListType(selectedParagraph, model.metadata.numberingDefinitions) : void 0;
24745
- const trackedChanges = React.useMemo(
25002
+ const trackedChanges = React2.useMemo(
24746
25003
  () => collectTrackedChangesFromModel(model, documentLoadNonce),
24747
25004
  [documentLoadNonce, model]
24748
25005
  );
24749
- const comments = React.useMemo(
25006
+ const comments = React2.useMemo(
24750
25007
  () => collectCommentsFromModel(model, documentLoadNonce),
24751
25008
  [documentLoadNonce, model]
24752
25009
  );
@@ -24754,38 +25011,38 @@ function useDocxEditor(options = {}) {
24754
25011
  const hasOrderedList = selectedListType === "ordered";
24755
25012
  const canUndo = history.past.length > 0;
24756
25013
  const canRedo = history.future.length > 0;
24757
- const pendingExportModelTransformerRef = React.useRef(void 0);
24758
- const setDocumentTheme = React.useCallback(
25014
+ const pendingExportModelTransformerRef = React2.useRef(void 0);
25015
+ const setDocumentTheme = React2.useCallback(
24759
25016
  (theme) => {
24760
25017
  setDocumentThemeState(theme);
24761
25018
  },
24762
25019
  []
24763
25020
  );
24764
- const setShowTrackedChanges = React.useCallback(
25021
+ const setShowTrackedChanges = React2.useCallback(
24765
25022
  (nextShowTrackedChanges) => {
24766
25023
  setShowTrackedChangesState(nextShowTrackedChanges);
24767
25024
  },
24768
25025
  []
24769
25026
  );
24770
- const toggleShowTrackedChanges = React.useCallback(() => {
25027
+ const toggleShowTrackedChanges = React2.useCallback(() => {
24771
25028
  setShowTrackedChangesState((current) => !current);
24772
25029
  }, []);
24773
- const setShowComments = React.useCallback(
25030
+ const setShowComments = React2.useCallback(
24774
25031
  (nextShowComments) => {
24775
25032
  setShowCommentsState(nextShowComments);
24776
25033
  },
24777
25034
  []
24778
25035
  );
24779
- const toggleShowComments = React.useCallback(() => {
25036
+ const toggleShowComments = React2.useCallback(() => {
24780
25037
  setShowCommentsState((current) => !current);
24781
25038
  }, []);
24782
- const registerPendingExportModelTransformer = React.useCallback(
25039
+ const registerPendingExportModelTransformer = React2.useCallback(
24783
25040
  (transformer) => {
24784
25041
  pendingExportModelTransformerRef.current = transformer;
24785
25042
  },
24786
25043
  []
24787
25044
  );
24788
- const unloadEmbeddedFonts = React.useCallback(() => {
25045
+ const unloadEmbeddedFonts = React2.useCallback(() => {
24789
25046
  if (typeof document !== "undefined" && "fonts" in document) {
24790
25047
  loadedEmbeddedFontFacesRef.current.forEach((fontFace) => {
24791
25048
  try {
@@ -24799,7 +25056,7 @@ function useDocxEditor(options = {}) {
24799
25056
  }
24800
25057
  loadedEmbeddedFontFacesRef.current = [];
24801
25058
  }, []);
24802
- const loadEmbeddedFontsFromPackage = React.useCallback(
25059
+ const loadEmbeddedFontsFromPackage = React2.useCallback(
24803
25060
  async (pkg) => {
24804
25061
  embeddedFontLoadNonceRef.current += 1;
24805
25062
  const requestNonce = embeddedFontLoadNonceRef.current;
@@ -24846,13 +25103,13 @@ function useDocxEditor(options = {}) {
24846
25103
  },
24847
25104
  [unloadEmbeddedFonts]
24848
25105
  );
24849
- React.useEffect(() => {
25106
+ React2.useEffect(() => {
24850
25107
  return () => {
24851
25108
  activeImportAbortControllerRef.current?.abort();
24852
25109
  unloadEmbeddedFonts();
24853
25110
  };
24854
25111
  }, [unloadEmbeddedFonts]);
24855
- React.useEffect(() => {
25112
+ React2.useEffect(() => {
24856
25113
  if (!options.document || options.loadEmbeddedFonts === false || options.document.embeddedFontsLoaded) {
24857
25114
  return;
24858
25115
  }
@@ -24862,7 +25119,7 @@ function useDocxEditor(options = {}) {
24862
25119
  options.document,
24863
25120
  options.loadEmbeddedFonts
24864
25121
  ]);
24865
- const dispatchEditorTransaction = React.useCallback(
25122
+ const dispatchEditorTransaction = React2.useCallback(
24866
25123
  (resolver) => {
24867
25124
  const currentState = canonicalEditorStateRef.current;
24868
25125
  const currentModel = currentState.model;
@@ -24956,14 +25213,14 @@ function useDocxEditor(options = {}) {
24956
25213
  },
24957
25214
  [applyCanonicalEditorStateAction]
24958
25215
  );
24959
- const annotationFailureStatus = React.useCallback(
25216
+ const annotationFailureStatus = React2.useCallback(
24960
25217
  (action, reason) => {
24961
25218
  const detail = reason === "stale" ? "the annotation no longer matches the document" : reason === "unsafe-xml" ? "the source markup is ambiguous" : "this annotation shape is not safely editable";
24962
25219
  return `${action} failed: ${detail}`;
24963
25220
  },
24964
25221
  []
24965
25222
  );
24966
- const runTrackedChangeCommand = React.useCallback(
25223
+ const runTrackedChangeCommand = React2.useCallback(
24967
25224
  (action, change) => {
24968
25225
  if (change.documentLoadNonce !== documentLoadNonceRef.current) {
24969
25226
  const failure = { ok: false, reason: "stale" };
@@ -25033,15 +25290,15 @@ function useDocxEditor(options = {}) {
25033
25290
  },
25034
25291
  [annotationFailureStatus, dispatchEditorTransaction]
25035
25292
  );
25036
- const acceptTrackedChange = React.useCallback(
25293
+ const acceptTrackedChange = React2.useCallback(
25037
25294
  (change) => runTrackedChangeCommand("accept", change),
25038
25295
  [runTrackedChangeCommand]
25039
25296
  );
25040
- const rejectTrackedChange = React.useCallback(
25297
+ const rejectTrackedChange = React2.useCallback(
25041
25298
  (change) => runTrackedChangeCommand("reject", change),
25042
25299
  [runTrackedChangeCommand]
25043
25300
  );
25044
- const createComment = React.useCallback(
25301
+ const createComment = React2.useCallback(
25045
25302
  (text, commentOptions = {}) => {
25046
25303
  let outcome = {
25047
25304
  ok: false,
@@ -25086,7 +25343,7 @@ function useDocxEditor(options = {}) {
25086
25343
  },
25087
25344
  [annotationFailureStatus, dispatchEditorTransaction]
25088
25345
  );
25089
- const setCommentResolved2 = React.useCallback(
25346
+ const setCommentResolved2 = React2.useCallback(
25090
25347
  (comment, resolved) => {
25091
25348
  if (comment.documentLoadNonce !== documentLoadNonceRef.current) {
25092
25349
  const failure = { ok: false, reason: "stale" };
@@ -25154,7 +25411,7 @@ function useDocxEditor(options = {}) {
25154
25411
  },
25155
25412
  [annotationFailureStatus, dispatchEditorTransaction]
25156
25413
  );
25157
- const applyModelChange = React.useCallback(
25414
+ const applyModelChange = React2.useCallback(
25158
25415
  (updater, successStatus) => {
25159
25416
  dispatchEditorTransaction((current) => {
25160
25417
  const nextModel = updater(current.model);
@@ -25170,7 +25427,7 @@ function useDocxEditor(options = {}) {
25170
25427
  },
25171
25428
  [dispatchEditorTransaction]
25172
25429
  );
25173
- const replaceDocumentWithImportError = React.useCallback(
25430
+ const replaceDocumentWithImportError = React2.useCallback(
25174
25431
  (fileName2, error) => {
25175
25432
  unloadEmbeddedFonts();
25176
25433
  setModel(createBlankDocumentModel());
@@ -25188,7 +25445,7 @@ function useDocxEditor(options = {}) {
25188
25445
  },
25189
25446
  [advanceDocumentLoadNonce, unloadEmbeddedFonts]
25190
25447
  );
25191
- const importDocxFile = React.useCallback(
25448
+ const importDocxFile = React2.useCallback(
25192
25449
  async (file) => {
25193
25450
  activeImportAbortControllerRef.current?.abort();
25194
25451
  activeImportAbortControllerRef.current = void 0;
@@ -25289,7 +25546,7 @@ function useDocxEditor(options = {}) {
25289
25546
  replaceDocumentWithImportError
25290
25547
  ]
25291
25548
  );
25292
- const newDocument = React.useCallback(() => {
25549
+ const newDocument = React2.useCallback(() => {
25293
25550
  activeImportAbortControllerRef.current?.abort();
25294
25551
  activeImportAbortControllerRef.current = void 0;
25295
25552
  unloadEmbeddedFonts();
@@ -25306,7 +25563,7 @@ function useDocxEditor(options = {}) {
25306
25563
  setImportError(void 0);
25307
25564
  setStatus("Created new document");
25308
25565
  }, [advanceDocumentLoadNonce, unloadEmbeddedFonts]);
25309
- const exportDocx = React.useCallback(async () => {
25566
+ const exportDocx = React2.useCallback(async () => {
25310
25567
  const sourceModel = modelRef.current;
25311
25568
  const transformedModel = pendingExportModelTransformerRef.current ? pendingExportModelTransformerRef.current(sourceModel) : sourceModel;
25312
25569
  if (transformedModel !== sourceModel) {
@@ -25329,7 +25586,7 @@ function useDocxEditor(options = {}) {
25329
25586
  }, 1e3);
25330
25587
  setStatus("Exported DOCX");
25331
25588
  }, [basePackage, fileName]);
25332
- const undo = React.useCallback(() => {
25589
+ const undo = React2.useCallback(() => {
25333
25590
  textCommitBurstRef.current = void 0;
25334
25591
  const { previous, next } = applyCanonicalEditorStateAction({
25335
25592
  type: "undo"
@@ -25353,7 +25610,7 @@ function useDocxEditor(options = {}) {
25353
25610
  });
25354
25611
  setStatus("Undo");
25355
25612
  }, [applyCanonicalEditorStateAction]);
25356
- const redo = React.useCallback(() => {
25613
+ const redo = React2.useCallback(() => {
25357
25614
  textCommitBurstRef.current = void 0;
25358
25615
  const { previous, next } = applyCanonicalEditorStateAction({
25359
25616
  type: "redo"
@@ -25377,7 +25634,7 @@ function useDocxEditor(options = {}) {
25377
25634
  });
25378
25635
  setStatus("Redo");
25379
25636
  }, [applyCanonicalEditorStateAction]);
25380
- React.useEffect(() => {
25637
+ React2.useEffect(() => {
25381
25638
  const onKeyDown = (event) => {
25382
25639
  if (event.defaultPrevented) {
25383
25640
  return;
@@ -25422,7 +25679,7 @@ function useDocxEditor(options = {}) {
25422
25679
  window.removeEventListener("keydown", onKeyDown);
25423
25680
  };
25424
25681
  }, [redo, undo]);
25425
- const applyToSelectedParagraphNode = React.useCallback(
25682
+ const applyToSelectedParagraphNode = React2.useCallback(
25426
25683
  (mutate) => {
25427
25684
  applyModelChange((current) => {
25428
25685
  const next = cloneDocModel(current);
@@ -25443,7 +25700,7 @@ function useDocxEditor(options = {}) {
25443
25700
  },
25444
25701
  [applyModelChange, selectedParagraphLocation]
25445
25702
  );
25446
- const restoreSelectionAfterToolbarCommand = React.useCallback(
25703
+ const restoreSelectionAfterToolbarCommand = React2.useCallback(
25447
25704
  (selectionSnapshot, textRangeSnapshot) => {
25448
25705
  dispatchEditorTransaction(() => ({
25449
25706
  selection: cloneEditorSelection(selectionSnapshot),
@@ -25453,7 +25710,7 @@ function useDocxEditor(options = {}) {
25453
25710
  },
25454
25711
  [dispatchEditorTransaction]
25455
25712
  );
25456
- const setActiveTextRange = React.useCallback(
25713
+ const setActiveTextRange = React2.useCallback(
25457
25714
  (range) => {
25458
25715
  const currentRange = cloneTextRange(activeTextRangeRef.current);
25459
25716
  if (!range) {
@@ -25462,7 +25719,7 @@ function useDocxEditor(options = {}) {
25462
25719
  return;
25463
25720
  }
25464
25721
  activeTextRangeRef.current = void 0;
25465
- React.startTransition(() => {
25722
+ React2.startTransition(() => {
25466
25723
  setActiveTextRangeState(void 0);
25467
25724
  });
25468
25725
  setPendingRunStyle(void 0);
@@ -25485,17 +25742,17 @@ function useDocxEditor(options = {}) {
25485
25742
  const nextRange = cloneTextRange(normalized);
25486
25743
  activeTextRangeRef.current = nextRange;
25487
25744
  lastInViewerActiveTextRangeRef.current = cloneTextRange(nextRange);
25488
- React.startTransition(() => {
25745
+ React2.startTransition(() => {
25489
25746
  setActiveTextRangeState(cloneTextRange(nextRange));
25490
25747
  });
25491
25748
  setPendingRunStyle(void 0);
25492
25749
  },
25493
25750
  []
25494
25751
  );
25495
- const suppressNextDomSelectionRestore = React.useCallback(() => {
25752
+ const suppressNextDomSelectionRestore = React2.useCallback(() => {
25496
25753
  suppressNextDomSelectionRestoreRef.current = true;
25497
25754
  }, []);
25498
- const applySelectedStyleChange = React.useCallback(
25755
+ const applySelectedStyleChange = React2.useCallback(
25499
25756
  (mutator) => {
25500
25757
  const currentState = canonicalEditorStateRef.current;
25501
25758
  const textRangeSnapshot = cloneTextRange(
@@ -25574,7 +25831,7 @@ function useDocxEditor(options = {}) {
25574
25831
  lastInViewerActiveTextRangeRef
25575
25832
  ]
25576
25833
  );
25577
- const setParagraphStyle = React.useCallback(
25834
+ const setParagraphStyle = React2.useCallback(
25578
25835
  (styleId) => {
25579
25836
  const fallbackStyleId = modelRef.current.metadata.defaultParagraphStyleId;
25580
25837
  const nextStyleId = styleId ?? fallbackStyleId;
@@ -25603,7 +25860,7 @@ function useDocxEditor(options = {}) {
25603
25860
  lastInViewerActiveTextRangeRef
25604
25861
  ]
25605
25862
  );
25606
- const setHeading = React.useCallback(
25863
+ const setHeading = React2.useCallback(
25607
25864
  (heading) => {
25608
25865
  const styleId = heading ? `Heading${heading}` : modelRef.current.metadata.defaultParagraphStyleId;
25609
25866
  const styleDefinition = styleId ? paragraphStyleById.get(styleId) : void 0;
@@ -25630,7 +25887,7 @@ function useDocxEditor(options = {}) {
25630
25887
  lastInViewerActiveTextRangeRef
25631
25888
  ]
25632
25889
  );
25633
- const setLineSpacing = React.useCallback(
25890
+ const setLineSpacing = React2.useCallback(
25634
25891
  (lineMultiple) => {
25635
25892
  if (!Number.isFinite(lineMultiple)) {
25636
25893
  return;
@@ -25678,7 +25935,7 @@ function useDocxEditor(options = {}) {
25678
25935
  lastInViewerActiveTextRangeRef
25679
25936
  ]
25680
25937
  );
25681
- const setFontFamily = React.useCallback(
25938
+ const setFontFamily = React2.useCallback(
25682
25939
  (fontFamily) => {
25683
25940
  applySelectedStyleChange(
25684
25941
  (style) => textStyleWithExplicitFontFamily(style, fontFamily)
@@ -25686,7 +25943,7 @@ function useDocxEditor(options = {}) {
25686
25943
  },
25687
25944
  [applySelectedStyleChange]
25688
25945
  );
25689
- const setFontSize = React.useCallback(
25946
+ const setFontSize = React2.useCallback(
25690
25947
  (fontSizePt) => {
25691
25948
  applySelectedStyleChange((style) => ({
25692
25949
  ...style ?? {},
@@ -25695,7 +25952,7 @@ function useDocxEditor(options = {}) {
25695
25952
  },
25696
25953
  [applySelectedStyleChange]
25697
25954
  );
25698
- const currentSelectedRunStyleSnapshot = React.useCallback(() => {
25955
+ const currentSelectedRunStyleSnapshot = React2.useCallback(() => {
25699
25956
  const currentState = canonicalEditorStateRef.current;
25700
25957
  const range = cloneTextRange(
25701
25958
  currentState.activeTextRange ?? lastInViewerActiveTextRangeRef.current
@@ -25717,21 +25974,21 @@ function useDocxEditor(options = {}) {
25717
25974
  ...currentPendingStyle
25718
25975
  };
25719
25976
  }, []);
25720
- const toggleBold = React.useCallback(() => {
25977
+ const toggleBold = React2.useCallback(() => {
25721
25978
  const nextBold = !Boolean(currentSelectedRunStyleSnapshot()?.bold);
25722
25979
  applySelectedStyleChange((style) => ({
25723
25980
  ...style ?? {},
25724
25981
  bold: nextBold
25725
25982
  }));
25726
25983
  }, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
25727
- const toggleItalic = React.useCallback(() => {
25984
+ const toggleItalic = React2.useCallback(() => {
25728
25985
  const nextItalic = !Boolean(currentSelectedRunStyleSnapshot()?.italic);
25729
25986
  applySelectedStyleChange((style) => ({
25730
25987
  ...style ?? {},
25731
25988
  italic: nextItalic
25732
25989
  }));
25733
25990
  }, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
25734
- const toggleUnderline = React.useCallback(() => {
25991
+ const toggleUnderline = React2.useCallback(() => {
25735
25992
  const nextUnderline = !Boolean(
25736
25993
  currentSelectedRunStyleSnapshot()?.underline
25737
25994
  );
@@ -25740,28 +25997,28 @@ function useDocxEditor(options = {}) {
25740
25997
  underline: nextUnderline
25741
25998
  }));
25742
25999
  }, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
25743
- const toggleStrike = React.useCallback(() => {
26000
+ const toggleStrike = React2.useCallback(() => {
25744
26001
  const nextStrike = !Boolean(currentSelectedRunStyleSnapshot()?.strike);
25745
26002
  applySelectedStyleChange((style) => ({
25746
26003
  ...style ?? {},
25747
26004
  strike: nextStrike
25748
26005
  }));
25749
26006
  }, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
25750
- const toggleSuperscript = React.useCallback(() => {
26007
+ const toggleSuperscript = React2.useCallback(() => {
25751
26008
  const nextVerticalAlign = selectedRunStyle?.verticalAlign === "superscript" ? void 0 : "superscript";
25752
26009
  applySelectedStyleChange((style) => ({
25753
26010
  ...style ?? {},
25754
26011
  verticalAlign: nextVerticalAlign
25755
26012
  }));
25756
26013
  }, [applySelectedStyleChange, selectedRunStyle?.verticalAlign]);
25757
- const toggleSubscript = React.useCallback(() => {
26014
+ const toggleSubscript = React2.useCallback(() => {
25758
26015
  const nextVerticalAlign = selectedRunStyle?.verticalAlign === "subscript" ? void 0 : "subscript";
25759
26016
  applySelectedStyleChange((style) => ({
25760
26017
  ...style ?? {},
25761
26018
  verticalAlign: nextVerticalAlign
25762
26019
  }));
25763
26020
  }, [applySelectedStyleChange, selectedRunStyle?.verticalAlign]);
25764
- const setHighlight = React.useCallback(
26021
+ const setHighlight = React2.useCallback(
25765
26022
  (highlight) => {
25766
26023
  applySelectedStyleChange((style) => ({
25767
26024
  ...style ?? {},
@@ -25770,7 +26027,7 @@ function useDocxEditor(options = {}) {
25770
26027
  },
25771
26028
  [applySelectedStyleChange]
25772
26029
  );
25773
- const setTextColor = React.useCallback(
26030
+ const setTextColor = React2.useCallback(
25774
26031
  (color) => {
25775
26032
  applySelectedStyleChange((style) => ({
25776
26033
  ...style ?? {},
@@ -25779,7 +26036,7 @@ function useDocxEditor(options = {}) {
25779
26036
  },
25780
26037
  [applySelectedStyleChange]
25781
26038
  );
25782
- const setLink = React.useCallback(
26039
+ const setLink = React2.useCallback(
25783
26040
  (link) => {
25784
26041
  const normalized = link?.trim();
25785
26042
  const nextLink = normalized && normalized.length > 0 ? normalized : void 0;
@@ -25861,7 +26118,7 @@ function useDocxEditor(options = {}) {
25861
26118
  },
25862
26119
  [activeTextRange, applyModelChange]
25863
26120
  );
25864
- const replaceExpandedSelection = React.useCallback(
26121
+ const replaceExpandedSelection = React2.useCallback(
25865
26122
  (text, range) => {
25866
26123
  const sourceRange = range ?? activeTextRangeRef.current;
25867
26124
  if (!sourceRange) {
@@ -26215,13 +26472,13 @@ function useDocxEditor(options = {}) {
26215
26472
  },
26216
26473
  [applyModelChange, pendingRunStyle]
26217
26474
  );
26218
- const deleteExpandedSelection = React.useCallback(
26475
+ const deleteExpandedSelection = React2.useCallback(
26219
26476
  (range) => {
26220
26477
  return replaceExpandedSelection("", range);
26221
26478
  },
26222
26479
  [replaceExpandedSelection]
26223
26480
  );
26224
- const updateFormField = React.useCallback(
26481
+ const updateFormField = React2.useCallback(
26225
26482
  (location, updater, successStatus) => {
26226
26483
  dispatchEditorTransaction((current) => {
26227
26484
  const next = cloneDocModel(current.model);
@@ -26251,7 +26508,7 @@ function useDocxEditor(options = {}) {
26251
26508
  },
26252
26509
  [dispatchEditorTransaction]
26253
26510
  );
26254
- const selectFormField = React.useCallback(
26511
+ const selectFormField = React2.useCallback(
26255
26512
  (location) => {
26256
26513
  if (!location) {
26257
26514
  setSelectedFormFieldLocation(void 0);
@@ -26276,7 +26533,7 @@ function useDocxEditor(options = {}) {
26276
26533
  },
26277
26534
  []
26278
26535
  );
26279
- const toggleFormCheckbox = React.useCallback(
26536
+ const toggleFormCheckbox = React2.useCallback(
26280
26537
  (location) => {
26281
26538
  updateFormField(
26282
26539
  location,
@@ -26294,7 +26551,7 @@ function useDocxEditor(options = {}) {
26294
26551
  },
26295
26552
  [updateFormField]
26296
26553
  );
26297
- const setFormFieldValue = React.useCallback(
26554
+ const setFormFieldValue = React2.useCallback(
26298
26555
  (location, value) => {
26299
26556
  updateFormField(
26300
26557
  location,
@@ -26316,7 +26573,7 @@ function useDocxEditor(options = {}) {
26316
26573
  },
26317
26574
  [updateFormField]
26318
26575
  );
26319
- const updateFormFieldWidget = React.useCallback(
26576
+ const updateFormFieldWidget = React2.useCallback(
26320
26577
  (location, patch) => {
26321
26578
  updateFormField(
26322
26579
  location,
@@ -26329,7 +26586,7 @@ function useDocxEditor(options = {}) {
26329
26586
  },
26330
26587
  [updateFormField]
26331
26588
  );
26332
- const applyBorderPreset = React.useCallback(
26589
+ const applyBorderPreset = React2.useCallback(
26333
26590
  (preset) => {
26334
26591
  const textRangeSnapshot = cloneTextRange(
26335
26592
  activeTextRangeRef.current ?? lastInViewerActiveTextRangeRef.current
@@ -26516,7 +26773,7 @@ function useDocxEditor(options = {}) {
26516
26773
  lastInViewerActiveTextRangeRef
26517
26774
  ]
26518
26775
  );
26519
- const setAlignment = React.useCallback(
26776
+ const setAlignment = React2.useCallback(
26520
26777
  (align) => {
26521
26778
  const textRangeSnapshot = cloneTextRange(
26522
26779
  activeTextRangeRef.current ?? lastInViewerActiveTextRangeRef.current
@@ -26575,7 +26832,7 @@ function useDocxEditor(options = {}) {
26575
26832
  lastInViewerActiveTextRangeRef
26576
26833
  ]
26577
26834
  );
26578
- const toggleList = React.useCallback(
26835
+ const toggleList = React2.useCallback(
26579
26836
  (listType) => {
26580
26837
  const textRangeSnapshot = cloneTextRange(
26581
26838
  activeTextRangeRef.current ?? lastInViewerActiveTextRangeRef.current
@@ -26718,7 +26975,7 @@ function useDocxEditor(options = {}) {
26718
26975
  lastInViewerActiveTextRangeRef
26719
26976
  ]
26720
26977
  );
26721
- const adjustSelectedListDepth = React.useCallback(
26978
+ const adjustSelectedListDepth = React2.useCallback(
26722
26979
  (levelDelta, draftText) => {
26723
26980
  const normalizedLevelDelta = Math.trunc(levelDelta);
26724
26981
  if (!normalizedLevelDelta) {
@@ -26835,7 +27092,7 @@ function useDocxEditor(options = {}) {
26835
27092
  },
26836
27093
  [applyModelChange, pendingRunStyle, selection]
26837
27094
  );
26838
- const insertListItemAfterSelection = React.useCallback(
27095
+ const insertListItemAfterSelection = React2.useCallback(
26839
27096
  (draftText, startOffset, endOffset, targetLocationOverride) => {
26840
27097
  const targetLocation = targetLocationOverride ?? resolveSelectedParagraphLocation(selection, activeTextRangeRef.current);
26841
27098
  if (targetLocation.kind !== "paragraph") {
@@ -26945,7 +27202,7 @@ function useDocxEditor(options = {}) {
26945
27202
  },
26946
27203
  [applyModelChange, pendingRunStyle, selection]
26947
27204
  );
26948
- const splitParagraphAtSelection = React.useCallback(
27205
+ const splitParagraphAtSelection = React2.useCallback(
26949
27206
  (draftText, startOffset, endOffset, targetLocationOverride) => {
26950
27207
  const targetLocation = targetLocationOverride ?? resolveSelectedParagraphLocation(selection, activeTextRangeRef.current);
26951
27208
  if (targetLocation.kind !== "paragraph") {
@@ -27036,7 +27293,7 @@ function useDocxEditor(options = {}) {
27036
27293
  },
27037
27294
  [applyModelChange, pendingRunStyle, selection]
27038
27295
  );
27039
- const insertTable = React.useCallback(() => {
27296
+ const insertTable = React2.useCallback(() => {
27040
27297
  applyModelChange((current) => {
27041
27298
  const next = cloneDocModel(current);
27042
27299
  const insertionIndex = selection.kind === "paragraph" ? selection.nodeIndex + 1 : selection.tableIndex + 1;
@@ -27119,7 +27376,7 @@ function useDocxEditor(options = {}) {
27119
27376
  return next;
27120
27377
  }, "Inserted table");
27121
27378
  }, [applyModelChange, selection]);
27122
- const insertImageFile = React.useCallback(
27379
+ const insertImageFile = React2.useCallback(
27123
27380
  async (file) => {
27124
27381
  if (!file.type.startsWith("image/")) {
27125
27382
  setStatus("Select an image file");
@@ -27169,7 +27426,7 @@ function useDocxEditor(options = {}) {
27169
27426
  },
27170
27427
  [applyModelChange, selection]
27171
27428
  );
27172
- const appendParagraph = React.useCallback(
27429
+ const appendParagraph = React2.useCallback(
27173
27430
  (text = "") => {
27174
27431
  let insertedIndex = 0;
27175
27432
  dispatchEditorTransaction((current) => {
@@ -27193,7 +27450,7 @@ function useDocxEditor(options = {}) {
27193
27450
  },
27194
27451
  [dispatchEditorTransaction]
27195
27452
  );
27196
- const resizeImage = React.useCallback(
27453
+ const resizeImage = React2.useCallback(
27197
27454
  (location, widthPx, heightPx) => {
27198
27455
  const safeWidth = Math.max(24, Math.round(widthPx));
27199
27456
  const safeHeight = Math.max(24, Math.round(heightPx));
@@ -27224,7 +27481,7 @@ function useDocxEditor(options = {}) {
27224
27481
  },
27225
27482
  [applyModelChange]
27226
27483
  );
27227
- const setSyntheticTextBoxText = React.useCallback(
27484
+ const setSyntheticTextBoxText = React2.useCallback(
27228
27485
  (location, text) => {
27229
27486
  applyModelChange((current) => {
27230
27487
  const next = cloneDocModel(current);
@@ -27263,7 +27520,7 @@ function useDocxEditor(options = {}) {
27263
27520
  },
27264
27521
  [applyModelChange]
27265
27522
  );
27266
- const setImageWrapMode = React.useCallback(
27523
+ const setImageWrapMode = React2.useCallback(
27267
27524
  (location, mode, seedFloating) => {
27268
27525
  applyModelChange((current) => {
27269
27526
  const next = cloneDocModel(current);
@@ -27298,7 +27555,7 @@ function useDocxEditor(options = {}) {
27298
27555
  },
27299
27556
  [applyModelChange]
27300
27557
  );
27301
- const moveFloatingImage = React.useCallback(
27558
+ const moveFloatingImage = React2.useCallback(
27302
27559
  (location, patch, options2) => {
27303
27560
  applyModelChange((current) => {
27304
27561
  const sourceLocation = imageLocationToParagraphLocation(location);
@@ -27355,7 +27612,7 @@ function useDocxEditor(options = {}) {
27355
27612
  },
27356
27613
  [applyModelChange]
27357
27614
  );
27358
- const moveSectionFloatingImage = React.useCallback(
27615
+ const moveSectionFloatingImage = React2.useCallback(
27359
27616
  (location, patch) => {
27360
27617
  applyModelChange((current) => {
27361
27618
  return updateSectionImageFloatingAtLocation(current, location, patch);
@@ -27363,7 +27620,7 @@ function useDocxEditor(options = {}) {
27363
27620
  },
27364
27621
  [applyModelChange]
27365
27622
  );
27366
- const moveParagraphDropCap = React.useCallback(
27623
+ const moveParagraphDropCap = React2.useCallback(
27367
27624
  (nodeIndex, patch) => {
27368
27625
  applyModelChange((current) => {
27369
27626
  const next = cloneDocModel(current);
@@ -27386,7 +27643,7 @@ function useDocxEditor(options = {}) {
27386
27643
  },
27387
27644
  [applyModelChange]
27388
27645
  );
27389
- const setParagraphDropCapFontSizePt = React.useCallback(
27646
+ const setParagraphDropCapFontSizePt = React2.useCallback(
27390
27647
  (nodeIndex, fontSizePt) => {
27391
27648
  applyModelChange((current) => {
27392
27649
  const next = cloneDocModel(current);
@@ -27425,7 +27682,7 @@ function useDocxEditor(options = {}) {
27425
27682
  },
27426
27683
  [applyModelChange]
27427
27684
  );
27428
- const setParagraphDropCapText = React.useCallback(
27685
+ const setParagraphDropCapText = React2.useCallback(
27429
27686
  (nodeIndex, text) => {
27430
27687
  applyModelChange((current) => {
27431
27688
  const next = cloneDocModel(current);
@@ -27461,7 +27718,7 @@ function useDocxEditor(options = {}) {
27461
27718
  },
27462
27719
  [applyModelChange]
27463
27720
  );
27464
- const moveImage = React.useCallback(
27721
+ const moveImage = React2.useCallback(
27465
27722
  (source, target) => {
27466
27723
  const sourceParagraphLocation = imageLocationToParagraphLocation(source);
27467
27724
  const targetParagraphLocation = target.kind === "paragraph" ? {
@@ -27533,7 +27790,7 @@ function useDocxEditor(options = {}) {
27533
27790
  },
27534
27791
  [applyModelChange]
27535
27792
  );
27536
- const selectParagraph = React.useCallback(
27793
+ const selectParagraph = React2.useCallback(
27537
27794
  (nodeIndex) => {
27538
27795
  dispatchEditorTransaction((current) => {
27539
27796
  const nextSelection = {
@@ -27553,7 +27810,7 @@ function useDocxEditor(options = {}) {
27553
27810
  },
27554
27811
  [dispatchEditorTransaction]
27555
27812
  );
27556
- const selectTableCell = React.useCallback(
27813
+ const selectTableCell = React2.useCallback(
27557
27814
  (tableIndex, rowIndex, cellIndex) => {
27558
27815
  dispatchEditorTransaction((current) => {
27559
27816
  const nextSelection = {
@@ -27575,7 +27832,7 @@ function useDocxEditor(options = {}) {
27575
27832
  },
27576
27833
  [dispatchEditorTransaction]
27577
27834
  );
27578
- const clearTableCellContents = React.useCallback(
27835
+ const clearTableCellContents = React2.useCallback(
27579
27836
  (tableIndex, cells) => {
27580
27837
  const dedupedCells = Array.from(
27581
27838
  new Map(
@@ -27634,7 +27891,7 @@ function useDocxEditor(options = {}) {
27634
27891
  },
27635
27892
  [applyModelChange, pendingRunStyle]
27636
27893
  );
27637
- const deleteTable = React.useCallback(
27894
+ const deleteTable = React2.useCallback(
27638
27895
  (tableIndex) => {
27639
27896
  const currentModel = modelRef.current;
27640
27897
  const target = currentModel.nodes[tableIndex];
@@ -27712,7 +27969,7 @@ function useDocxEditor(options = {}) {
27712
27969
  },
27713
27970
  [applyModelChange]
27714
27971
  );
27715
- const moveTable = React.useCallback(
27972
+ const moveTable = React2.useCallback(
27716
27973
  (tableIndex, targetNodeIndex) => {
27717
27974
  let nextSelection;
27718
27975
  applyModelChange((current) => {
@@ -27770,7 +28027,7 @@ function useDocxEditor(options = {}) {
27770
28027
  },
27771
28028
  [applyModelChange]
27772
28029
  );
27773
- const setTableFloating = React.useCallback(
28030
+ const setTableFloating = React2.useCallback(
27774
28031
  (tableIndex, patch, options2) => {
27775
28032
  applyModelChange((current) => {
27776
28033
  const tableNode = current.nodes[tableIndex];
@@ -27834,7 +28091,7 @@ function useDocxEditor(options = {}) {
27834
28091
  },
27835
28092
  [applyModelChange]
27836
28093
  );
27837
- const moveEmbeddedTableToBody = React.useCallback(
28094
+ const moveEmbeddedTableToBody = React2.useCallback(
27838
28095
  (tableRuntimeKey, targetNodeIndex) => {
27839
28096
  const runtimeLocation = parseEmbeddedTableRuntimeKey(tableRuntimeKey);
27840
28097
  if (!runtimeLocation) {
@@ -27920,7 +28177,7 @@ function useDocxEditor(options = {}) {
27920
28177
  },
27921
28178
  [applyModelChange]
27922
28179
  );
27923
- const insertTableRow = React.useCallback(
28180
+ const insertTableRow = React2.useCallback(
27924
28181
  (tableIndex, rowIndex, direction) => {
27925
28182
  let nextSelection;
27926
28183
  const currentSelection = selectionRef.current;
@@ -27975,7 +28232,7 @@ function useDocxEditor(options = {}) {
27975
28232
  },
27976
28233
  [applyModelChange]
27977
28234
  );
27978
- const insertTableColumn = React.useCallback(
28235
+ const insertTableColumn = React2.useCallback(
27979
28236
  (tableIndex, cellIndex, direction, rowIndex) => {
27980
28237
  let nextSelection;
27981
28238
  applyModelChange(
@@ -28057,7 +28314,7 @@ function useDocxEditor(options = {}) {
28057
28314
  },
28058
28315
  [applyModelChange]
28059
28316
  );
28060
- const deleteTableRow = React.useCallback(
28317
+ const deleteTableRow = React2.useCallback(
28061
28318
  (tableIndex, rowIndex) => {
28062
28319
  const tableNode = modelRef.current.nodes[tableIndex];
28063
28320
  if (!tableNode || tableNode.type !== "table") {
@@ -28120,7 +28377,7 @@ function useDocxEditor(options = {}) {
28120
28377
  },
28121
28378
  [applyModelChange, deleteTable]
28122
28379
  );
28123
- const deleteTableColumn = React.useCallback(
28380
+ const deleteTableColumn = React2.useCallback(
28124
28381
  (tableIndex, cellIndex, rowIndex) => {
28125
28382
  const tableNode = modelRef.current.nodes[tableIndex];
28126
28383
  if (!tableNode || tableNode.type !== "table") {
@@ -28206,7 +28463,7 @@ function useDocxEditor(options = {}) {
28206
28463
  },
28207
28464
  [applyModelChange, deleteTable]
28208
28465
  );
28209
- const commitParagraphText = React.useCallback(
28466
+ const commitParagraphText = React2.useCallback(
28210
28467
  (nodeIndex, text) => {
28211
28468
  applyModelChange((current) => {
28212
28469
  const activeRange = activeTextRangeRef.current ? normalizeTextRange(activeTextRangeRef.current) : void 0;
@@ -28224,7 +28481,7 @@ function useDocxEditor(options = {}) {
28224
28481
  },
28225
28482
  [applyModelChange]
28226
28483
  );
28227
- const commitTableCellText = React.useCallback(
28484
+ const commitTableCellText = React2.useCallback(
28228
28485
  (tableIndex, rowIndex, cellIndex, text) => {
28229
28486
  applyModelChange((current) => {
28230
28487
  const activeRange = activeTextRangeRef.current ? normalizeTextRange(activeTextRangeRef.current) : void 0;
@@ -28255,7 +28512,7 @@ function useDocxEditor(options = {}) {
28255
28512
  },
28256
28513
  [applyModelChange]
28257
28514
  );
28258
- const commitTableCellParagraphTextRecursive = React.useCallback(
28515
+ const commitTableCellParagraphTextRecursive = React2.useCallback(
28259
28516
  (tableIndex, rowIndex, cellIndex, paragraphIndex, text) => {
28260
28517
  applyModelChange((current) => {
28261
28518
  const activeRange = activeTextRangeRef.current ? normalizeTextRange(activeTextRangeRef.current) : void 0;
@@ -28287,7 +28544,7 @@ function useDocxEditor(options = {}) {
28287
28544
  },
28288
28545
  [applyModelChange]
28289
28546
  );
28290
- const commitParagraphTextAtRange = React.useCallback(
28547
+ const commitParagraphTextAtRange = React2.useCallback(
28291
28548
  (location, text, caret, options2) => {
28292
28549
  const now2 = Date.now();
28293
28550
  return dispatchEditorTransaction((current) => {
@@ -28330,7 +28587,7 @@ function useDocxEditor(options = {}) {
28330
28587
  },
28331
28588
  [dispatchEditorTransaction]
28332
28589
  );
28333
- const commitTableCellTextAtRange = React.useCallback(
28590
+ const commitTableCellTextAtRange = React2.useCallback(
28334
28591
  (tableIndex, rowIndex, cellIndex, text, caret) => {
28335
28592
  textCommitBurstRef.current = void 0;
28336
28593
  return dispatchEditorTransaction((current) => {
@@ -28383,7 +28640,7 @@ function useDocxEditor(options = {}) {
28383
28640
  },
28384
28641
  [dispatchEditorTransaction]
28385
28642
  );
28386
- const commitSectionParagraphText = React.useCallback(
28643
+ const commitSectionParagraphText = React2.useCallback(
28387
28644
  (location, text) => {
28388
28645
  applyModelChange(
28389
28646
  (current) => updateSectionParagraphTextAtLocation(current, location, text, {
@@ -28394,7 +28651,7 @@ function useDocxEditor(options = {}) {
28394
28651
  },
28395
28652
  [applyModelChange]
28396
28653
  );
28397
- const syncPaginationInfo = React.useCallback(
28654
+ const syncPaginationInfo = React2.useCallback(
28398
28655
  (nextPaginationInfo) => {
28399
28656
  setPaginationInfo((current) => {
28400
28657
  const nextTotalPages = Math.max(
@@ -28417,6 +28674,29 @@ function useDocxEditor(options = {}) {
28417
28674
  },
28418
28675
  []
28419
28676
  );
28677
+ const setZoom = React2.useCallback(
28678
+ (level) => {
28679
+ const bridge = viewerZoomBridgeByController.get(
28680
+ syncPaginationInfo
28681
+ );
28682
+ if (bridge) {
28683
+ bridge.setZoom(level);
28684
+ return;
28685
+ }
28686
+ const normalized = normalizeViewerZoomLevel(level);
28687
+ fallbackZoomRef.current = {
28688
+ level: normalized,
28689
+ resolvedZoom: typeof normalized === "number" ? normalized : fallbackZoomRef.current.resolvedZoom
28690
+ };
28691
+ },
28692
+ [syncPaginationInfo]
28693
+ );
28694
+ const getZoom = React2.useCallback(() => {
28695
+ return viewerZoomBridgeByController.get(syncPaginationInfo)?.getZoom() ?? fallbackZoomRef.current.level;
28696
+ }, [syncPaginationInfo]);
28697
+ const getResolvedZoom = React2.useCallback(() => {
28698
+ return viewerZoomBridgeByController.get(syncPaginationInfo)?.getResolvedZoom() ?? fallbackZoomRef.current.resolvedZoom;
28699
+ }, [syncPaginationInfo]);
28420
28700
  return {
28421
28701
  model,
28422
28702
  documentLoadNonce,
@@ -28458,6 +28738,9 @@ function useDocxEditor(options = {}) {
28458
28738
  setShowTrackedChanges,
28459
28739
  setShowComments,
28460
28740
  syncPaginationInfo,
28741
+ setZoom,
28742
+ getZoom,
28743
+ getResolvedZoom,
28461
28744
  toggleShowTrackedChanges,
28462
28745
  toggleShowComments,
28463
28746
  acceptTrackedChange,
@@ -29265,27 +29548,27 @@ function resolveDocxPageThumbnailResolution(options) {
29265
29548
  }
29266
29549
  function useDocxPageThumbnails(editor, options = {}) {
29267
29550
  const pageSurfaceRegistryOwner = docxViewerPageSurfaceRegistryOwner(editor);
29268
- const pageSurfaceRegistryEditor = React.useMemo(
29551
+ const pageSurfaceRegistryEditor = React2.useMemo(
29269
29552
  () => ({ syncPaginationInfo: editor.syncPaginationInfo }),
29270
29553
  [pageSurfaceRegistryOwner]
29271
29554
  );
29272
- const [pageSurfaceEpoch, setPageSurfaceEpoch] = React.useState(0);
29273
- const [pageThumbnailStates, setPageThumbnailStates] = React.useState(() => /* @__PURE__ */ new Map());
29274
- const attachedCanvasByPageRef = React.useRef(
29555
+ const [pageSurfaceEpoch, setPageSurfaceEpoch] = React2.useState(0);
29556
+ const [pageThumbnailStates, setPageThumbnailStates] = React2.useState(() => /* @__PURE__ */ new Map());
29557
+ const attachedCanvasByPageRef = React2.useRef(
29275
29558
  /* @__PURE__ */ new Map()
29276
29559
  );
29277
- const canvasRefCallbacksRef = React.useRef(/* @__PURE__ */ new Map());
29278
- const renderToCanvasCallbacksRef = React.useRef(/* @__PURE__ */ new Map());
29279
- const fallbackLayout = React.useMemo(
29560
+ const canvasRefCallbacksRef = React2.useRef(/* @__PURE__ */ new Map());
29561
+ const renderToCanvasCallbacksRef = React2.useRef(/* @__PURE__ */ new Map());
29562
+ const fallbackLayout = React2.useMemo(
29280
29563
  () => resolveDocumentLayout(editor.model),
29281
29564
  [editor.model]
29282
29565
  );
29283
- const pageSurfaceRegistry = React.useMemo(
29566
+ const pageSurfaceRegistry = React2.useMemo(
29284
29567
  () => ensureDocxViewerPageSurfaceRegistry(pageSurfaceRegistryEditor),
29285
29568
  [pageSurfaceRegistryEditor]
29286
29569
  );
29287
29570
  const hasRequestedThumbnails = options.pageIndexes?.length !== 0;
29288
- React.useEffect(
29571
+ React2.useEffect(
29289
29572
  () => {
29290
29573
  if (!hasRequestedThumbnails) return;
29291
29574
  setPageSurfaceEpoch((current) => current + 1);
@@ -29295,11 +29578,11 @@ function useDocxPageThumbnails(editor, options = {}) {
29295
29578
  },
29296
29579
  [hasRequestedThumbnails, pageSurfaceRegistryEditor]
29297
29580
  );
29298
- const mountedPageElements = React.useMemo(
29581
+ const mountedPageElements = React2.useMemo(
29299
29582
  () => new Map(pageSurfaceRegistry.pageElements),
29300
29583
  [pageSurfaceEpoch, pageSurfaceRegistry.pageElements]
29301
29584
  );
29302
- const updatePageThumbnailState = React.useCallback(
29585
+ const updatePageThumbnailState = React2.useCallback(
29303
29586
  (pageIndex, status, error) => {
29304
29587
  setPageThumbnailStates((current) => {
29305
29588
  const next = new Map(current);
@@ -29313,20 +29596,20 @@ function useDocxPageThumbnails(editor, options = {}) {
29313
29596
  },
29314
29597
  []
29315
29598
  );
29316
- const thumbnailSurfaceCacheRef = React.useRef(void 0);
29317
- const thumbnailRasterQueueRef = React.useRef(void 0);
29318
- const detachedThumbnailSurfaceRendererRef = React.useRef(void 0);
29319
- const lastPaintedThumbnailKeyByCanvasRef = React.useRef(
29599
+ const thumbnailSurfaceCacheRef = React2.useRef(void 0);
29600
+ const thumbnailRasterQueueRef = React2.useRef(void 0);
29601
+ const detachedThumbnailSurfaceRendererRef = React2.useRef(void 0);
29602
+ const lastPaintedThumbnailKeyByCanvasRef = React2.useRef(
29320
29603
  /* @__PURE__ */ new WeakMap()
29321
29604
  );
29322
- const thumbnailQueueKeyByCanvasRef = React.useRef(
29605
+ const thumbnailQueueKeyByCanvasRef = React2.useRef(
29323
29606
  /* @__PURE__ */ new WeakMap()
29324
29607
  );
29325
- const nextThumbnailCanvasQueueIdRef = React.useRef(0);
29326
- const queuedPrefetchThumbnailKeysRef = React.useRef(/* @__PURE__ */ new Set());
29608
+ const nextThumbnailCanvasQueueIdRef = React2.useRef(0);
29609
+ const queuedPrefetchThumbnailKeysRef = React2.useRef(/* @__PURE__ */ new Set());
29327
29610
  const thumbnailMinRasterIntervalMs = normalizeDocxThumbnailMinRasterIntervalMs(options.minRasterIntervalMs);
29328
29611
  const defaultThumbnailScheduling = options.scheduling ?? "idle";
29329
- const ensureThumbnailSurfaceCache = React.useCallback(() => {
29612
+ const ensureThumbnailSurfaceCache = React2.useCallback(() => {
29330
29613
  if (!thumbnailSurfaceCacheRef.current) {
29331
29614
  thumbnailSurfaceCacheRef.current = new DocxThumbnailSurfaceCache(
29332
29615
  DOCX_THUMBNAIL_SURFACE_CACHE_MAX_ENTRIES
@@ -29334,7 +29617,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29334
29617
  }
29335
29618
  return thumbnailSurfaceCacheRef.current;
29336
29619
  }, []);
29337
- const ensureThumbnailRasterQueue = React.useCallback(() => {
29620
+ const ensureThumbnailRasterQueue = React2.useCallback(() => {
29338
29621
  if (!thumbnailRasterQueueRef.current) {
29339
29622
  thumbnailRasterQueueRef.current = new SerialIdleTaskQueue({
29340
29623
  minTaskIntervalMs: thumbnailMinRasterIntervalMs
@@ -29342,7 +29625,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29342
29625
  }
29343
29626
  return thumbnailRasterQueueRef.current;
29344
29627
  }, [thumbnailMinRasterIntervalMs]);
29345
- const thumbnailQueueKeyForCanvas = React.useCallback(
29628
+ const thumbnailQueueKeyForCanvas = React2.useCallback(
29346
29629
  (canvas) => {
29347
29630
  const existing = thumbnailQueueKeyByCanvasRef.current.get(canvas);
29348
29631
  if (existing) {
@@ -29357,12 +29640,12 @@ function useDocxPageThumbnails(editor, options = {}) {
29357
29640
  },
29358
29641
  []
29359
29642
  );
29360
- React.useEffect(() => {
29643
+ React2.useEffect(() => {
29361
29644
  thumbnailRasterQueueRef.current?.clear();
29362
29645
  thumbnailRasterQueueRef.current = void 0;
29363
29646
  queuedPrefetchThumbnailKeysRef.current.clear();
29364
29647
  }, [thumbnailMinRasterIntervalMs]);
29365
- React.useEffect(() => {
29648
+ React2.useEffect(() => {
29366
29649
  thumbnailSurfaceCacheRef.current?.clear();
29367
29650
  thumbnailRasterQueueRef.current?.clear();
29368
29651
  detachedThumbnailSurfaceRendererRef.current?.clear();
@@ -29372,7 +29655,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29372
29655
  nextThumbnailCanvasQueueIdRef.current = 0;
29373
29656
  queuedPrefetchThumbnailKeysRef.current.clear();
29374
29657
  }, [editor.documentLoadNonce, pageSurfaceRegistryOwner]);
29375
- React.useEffect(() => {
29658
+ React2.useEffect(() => {
29376
29659
  detachedThumbnailSurfaceRendererRef.current?.clear();
29377
29660
  detachedThumbnailSurfaceRendererRef.current = void 0;
29378
29661
  }, [
@@ -29381,14 +29664,14 @@ function useDocxPageThumbnails(editor, options = {}) {
29381
29664
  editor.showComments,
29382
29665
  editor.showTrackedChanges
29383
29666
  ]);
29384
- React.useEffect(
29667
+ React2.useEffect(
29385
29668
  () => () => {
29386
29669
  detachedThumbnailSurfaceRendererRef.current?.clear();
29387
29670
  detachedThumbnailSurfaceRendererRef.current = void 0;
29388
29671
  },
29389
29672
  []
29390
29673
  );
29391
- const thumbnailResolutionOptionsKey = React.useMemo(() => {
29674
+ const thumbnailResolutionOptionsKey = React2.useMemo(() => {
29392
29675
  const bounds = options.resolution;
29393
29676
  const boundsKey = typeof bounds === "number" ? `n${bounds}` : bounds ? `b${bounds.maxWidth ?? ""}x${bounds.maxHeight ?? ""}` : "";
29394
29677
  return `${boundsKey}|${options.maxWidthPx ?? ""}|${options.maxHeightPx ?? ""}|${options.pixelRatio ?? ""}`;
@@ -29398,7 +29681,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29398
29681
  options.pixelRatio,
29399
29682
  options.resolution
29400
29683
  ]);
29401
- const thumbnailSkipKeyForPage = React.useCallback(
29684
+ const thumbnailSkipKeyForPage = React2.useCallback(
29402
29685
  (pageIndex) => {
29403
29686
  const contentKey = pageSurfaceRegistry.pageContentKeys.get(pageIndex);
29404
29687
  return contentKey === void 0 ? void 0 : `${contentKey}|${editor.documentTheme}|${thumbnailResolutionOptionsKey}`;
@@ -29406,18 +29689,18 @@ function useDocxPageThumbnails(editor, options = {}) {
29406
29689
  [editor.documentTheme, pageSurfaceRegistry, thumbnailResolutionOptionsKey]
29407
29690
  );
29408
29691
  const totalThumbnailPages = Math.max(1, editor.totalPages);
29409
- const hardThumbnailPageIndexes = React.useMemo(
29692
+ const hardThumbnailPageIndexes = React2.useMemo(
29410
29693
  () => options.pageIndexes === void 0 ? void 0 : normalizeDocxThumbnailPageIndexes(
29411
29694
  options.pageIndexes,
29412
29695
  totalThumbnailPages
29413
29696
  ),
29414
29697
  [options.pageIndexes, totalThumbnailPages]
29415
29698
  );
29416
- const hardThumbnailPageIndexSet = React.useMemo(
29699
+ const hardThumbnailPageIndexSet = React2.useMemo(
29417
29700
  () => hardThumbnailPageIndexes ? new Set(hardThumbnailPageIndexes) : void 0,
29418
29701
  [hardThumbnailPageIndexes]
29419
29702
  );
29420
- const visibleThumbnailPageIndexes = React.useMemo(() => {
29703
+ const visibleThumbnailPageIndexes = React2.useMemo(() => {
29421
29704
  const normalized = normalizeDocxThumbnailPageIndexes(
29422
29705
  options.renderWindow?.visiblePageIndexes,
29423
29706
  totalThumbnailPages
@@ -29430,7 +29713,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29430
29713
  options.renderWindow?.visiblePageIndexes,
29431
29714
  totalThumbnailPages
29432
29715
  ]);
29433
- const prefetchThumbnailPageIndexes = React.useMemo(() => {
29716
+ const prefetchThumbnailPageIndexes = React2.useMemo(() => {
29434
29717
  const normalized = normalizeDocxThumbnailPageIndexes(
29435
29718
  options.renderWindow?.prefetchPageIndexes,
29436
29719
  totalThumbnailPages
@@ -29449,15 +29732,15 @@ function useDocxPageThumbnails(editor, options = {}) {
29449
29732
  const prefetchThumbnailPageIndexesKey = docxThumbnailPageIndexesKey(
29450
29733
  prefetchThumbnailPageIndexes
29451
29734
  );
29452
- const visibleThumbnailPageIndexSet = React.useMemo(
29735
+ const visibleThumbnailPageIndexSet = React2.useMemo(
29453
29736
  () => new Set(visibleThumbnailPageIndexes),
29454
29737
  [visibleThumbnailPageIndexesKey]
29455
29738
  );
29456
- const thumbnailRenderPriorityForPage = React.useCallback(
29739
+ const thumbnailRenderPriorityForPage = React2.useCallback(
29457
29740
  (pageIndex, fallbackPriority = DOCX_THUMBNAIL_RENDER_PRIORITY_ATTACHED) => visibleThumbnailPageIndexSet.has(pageIndex) ? DOCX_THUMBNAIL_RENDER_PRIORITY_VISIBLE : fallbackPriority,
29458
29741
  [visibleThumbnailPageIndexSet]
29459
29742
  );
29460
- const renderPageThumbnailSurface = React.useCallback(
29743
+ const renderPageThumbnailSurface = React2.useCallback(
29461
29744
  async (pageIndex, renderOptions) => {
29462
29745
  const force = renderOptions?.force === true;
29463
29746
  const runSkipKey = thumbnailSkipKeyForPage(pageIndex);
@@ -29549,7 +29832,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29549
29832
  editor
29550
29833
  ]
29551
29834
  );
29552
- const renderPageThumbnailToCanvas = React.useCallback(
29835
+ const renderPageThumbnailToCanvas = React2.useCallback(
29553
29836
  async (pageIndex, canvas, renderOptions) => {
29554
29837
  if (options.disabled) {
29555
29838
  return;
@@ -29626,7 +29909,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29626
29909
  updatePageThumbnailState
29627
29910
  ]
29628
29911
  );
29629
- const prefetchPageThumbnailSurface = React.useCallback(
29912
+ const prefetchPageThumbnailSurface = React2.useCallback(
29630
29913
  async (pageIndex) => {
29631
29914
  if (options.disabled) {
29632
29915
  return;
@@ -29647,7 +29930,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29647
29930
  },
29648
29931
  [ensureThumbnailRasterQueue, options.disabled, renderPageThumbnailSurface]
29649
29932
  );
29650
- const requestAttachedThumbnailRenders = React.useCallback(
29933
+ const requestAttachedThumbnailRenders = React2.useCallback(
29651
29934
  async (renderOptions) => {
29652
29935
  const attachedPageIndexes = [
29653
29936
  ...attachedCanvasByPageRef.current.keys()
@@ -29666,7 +29949,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29666
29949
  },
29667
29950
  [renderPageThumbnailToCanvas, thumbnailRenderPriorityForPage]
29668
29951
  );
29669
- const requestPrefetchThumbnailRenders = React.useCallback(async () => {
29952
+ const requestPrefetchThumbnailRenders = React2.useCallback(async () => {
29670
29953
  if (options.disabled) {
29671
29954
  queuedPrefetchThumbnailKeysRef.current.forEach((queueKey) => {
29672
29955
  thumbnailRasterQueueRef.current?.cancel(queueKey);
@@ -29694,7 +29977,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29694
29977
  prefetchPageThumbnailSurface,
29695
29978
  prefetchThumbnailPageIndexes
29696
29979
  ]);
29697
- React.useEffect(() => {
29980
+ React2.useEffect(() => {
29698
29981
  void requestPrefetchThumbnailRenders();
29699
29982
  }, [
29700
29983
  editor.documentLoadNonce,
@@ -29708,21 +29991,21 @@ function useDocxPageThumbnails(editor, options = {}) {
29708
29991
  prefetchThumbnailPageIndexesKey,
29709
29992
  requestPrefetchThumbnailRenders
29710
29993
  ]);
29711
- const rerenderAttachedThumbnails = React.useCallback(
29994
+ const rerenderAttachedThumbnails = React2.useCallback(
29712
29995
  async () => requestAttachedThumbnailRenders({ force: true }),
29713
29996
  [requestAttachedThumbnailRenders]
29714
29997
  );
29715
- const renderPageThumbnailToCanvasRef = React.useRef(
29998
+ const renderPageThumbnailToCanvasRef = React2.useRef(
29716
29999
  renderPageThumbnailToCanvas
29717
30000
  );
29718
- React.useEffect(() => {
30001
+ React2.useEffect(() => {
29719
30002
  renderPageThumbnailToCanvasRef.current = renderPageThumbnailToCanvas;
29720
30003
  }, [renderPageThumbnailToCanvas]);
29721
- React.useEffect(() => {
30004
+ React2.useEffect(() => {
29722
30005
  canvasRefCallbacksRef.current.clear();
29723
30006
  renderToCanvasCallbacksRef.current.clear();
29724
30007
  }, [pageSurfaceRegistryOwner]);
29725
- React.useEffect(() => {
30008
+ React2.useEffect(() => {
29726
30009
  void requestAttachedThumbnailRenders();
29727
30010
  }, [
29728
30011
  editor.documentLoadNonce,
@@ -29736,7 +30019,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29736
30019
  options.pixelRatio,
29737
30020
  requestAttachedThumbnailRenders
29738
30021
  ]);
29739
- const thumbnailGeometryItems = React.useMemo(() => {
30022
+ const thumbnailGeometryItems = React2.useMemo(() => {
29740
30023
  const totalPages = Math.max(1, editor.totalPages);
29741
30024
  const geometryPageIndexes = hardThumbnailPageIndexes ?? Array.from({ length: totalPages }, (_, pageIndex) => pageIndex);
29742
30025
  return geometryPageIndexes.map((pageIndex) => {
@@ -29827,7 +30110,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29827
30110
  pageSurfaceRegistry,
29828
30111
  thumbnailQueueKeyForCanvas
29829
30112
  ]);
29830
- const thumbnails = React.useMemo(
30113
+ const thumbnails = React2.useMemo(
29831
30114
  () => thumbnailGeometryItems.map((geometryItem) => {
29832
30115
  const { hasElement, ...item } = geometryItem;
29833
30116
  const state = pageThumbnailStates.get(item.pageIndex);
@@ -29839,7 +30122,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29839
30122
  }),
29840
30123
  [thumbnailGeometryItems, pageThumbnailStates]
29841
30124
  );
29842
- const paintThumbnail = React.useCallback(
30125
+ const paintThumbnail = React2.useCallback(
29843
30126
  (pageIndex, canvas) => {
29844
30127
  if (!canvas || options.disabled) {
29845
30128
  return false;
@@ -29854,7 +30137,7 @@ function useDocxPageThumbnails(editor, options = {}) {
29854
30137
  },
29855
30138
  [options.disabled, thumbnails]
29856
30139
  );
29857
- return React.useMemo(
30140
+ return React2.useMemo(
29858
30141
  () => ({
29859
30142
  paintThumbnail,
29860
30143
  thumbnails,
@@ -29865,16 +30148,16 @@ function useDocxPageThumbnails(editor, options = {}) {
29865
30148
  }
29866
30149
  var useDocxViewerThumbnails = useDocxPageThumbnails;
29867
30150
  function useDocxDocumentTheme(editor) {
29868
- const setDocumentTheme = React.useCallback(
30151
+ const setDocumentTheme = React2.useCallback(
29869
30152
  (theme) => {
29870
30153
  editor.setDocumentTheme(theme);
29871
30154
  },
29872
30155
  [editor.setDocumentTheme]
29873
30156
  );
29874
- const toggleDocumentTheme = React.useCallback(() => {
30157
+ const toggleDocumentTheme = React2.useCallback(() => {
29875
30158
  editor.setDocumentTheme(editor.documentTheme === "dark" ? "light" : "dark");
29876
30159
  }, [editor.documentTheme, editor.setDocumentTheme]);
29877
- return React.useMemo(
30160
+ return React2.useMemo(
29878
30161
  () => ({
29879
30162
  documentTheme: editor.documentTheme,
29880
30163
  isDarkDocument: editor.documentTheme === "dark",
@@ -29885,13 +30168,13 @@ function useDocxDocumentTheme(editor) {
29885
30168
  );
29886
30169
  }
29887
30170
  function useDocxParagraphStyles(editor) {
29888
- const setParagraphStyle = React.useCallback(
30171
+ const setParagraphStyle = React2.useCallback(
29889
30172
  (styleId) => {
29890
30173
  editor.setParagraphStyle(styleId);
29891
30174
  },
29892
30175
  [editor.setParagraphStyle]
29893
30176
  );
29894
- return React.useMemo(
30177
+ return React2.useMemo(
29895
30178
  () => ({
29896
30179
  paragraphStyles: editor.availableParagraphStyles,
29897
30180
  selectedParagraphStyleId: editor.selectedParagraphStyleId,
@@ -29906,13 +30189,13 @@ function useDocxParagraphStyles(editor) {
29906
30189
  }
29907
30190
  function useDocxImageWrapMenu(menu) {
29908
30191
  const wrapState = menu.context.kind === "image" ? menu.context.image?.wrap ?? resolveDocxImageWrapState(menu.context.image?.floating) : void 0;
29909
- const setMode = React.useCallback(
30192
+ const setMode = React2.useCallback(
29910
30193
  (mode) => {
29911
30194
  menu.runAction(imageWrapModeActionId(mode));
29912
30195
  },
29913
30196
  [menu]
29914
30197
  );
29915
- const setMoveWithText = React.useCallback(
30198
+ const setMoveWithText = React2.useCallback(
29916
30199
  (moveWithText) => {
29917
30200
  menu.runAction(
29918
30201
  moveWithText ? "image-move-with-text" : "image-fix-position-on-page"
@@ -29920,7 +30203,7 @@ function useDocxImageWrapMenu(menu) {
29920
30203
  },
29921
30204
  [menu]
29922
30205
  );
29923
- return React.useMemo(() => {
30206
+ return React2.useMemo(() => {
29924
30207
  if (!wrapState) {
29925
30208
  return void 0;
29926
30209
  }
@@ -29968,13 +30251,13 @@ function useDocxImageWrapMenu(menu) {
29968
30251
  }, [menu, setMode, setMoveWithText, wrapState]);
29969
30252
  }
29970
30253
  function useDocxLineSpacing(editor) {
29971
- const setLineSpacing = React.useCallback(
30254
+ const setLineSpacing = React2.useCallback(
29972
30255
  (lineMultiple) => {
29973
30256
  editor.setLineSpacing(lineMultiple);
29974
30257
  },
29975
30258
  [editor.setLineSpacing]
29976
30259
  );
29977
- return React.useMemo(
30260
+ return React2.useMemo(
29978
30261
  () => ({
29979
30262
  lineSpacing: editor.selectedLineSpacing,
29980
30263
  setLineSpacing
@@ -29983,13 +30266,13 @@ function useDocxLineSpacing(editor) {
29983
30266
  );
29984
30267
  }
29985
30268
  function useDocxBorders(editor) {
29986
- const applyBorderPreset = React.useCallback(
30269
+ const applyBorderPreset = React2.useCallback(
29987
30270
  (preset) => {
29988
30271
  editor.applyBorderPreset(preset);
29989
30272
  },
29990
30273
  [editor.applyBorderPreset]
29991
30274
  );
29992
- return React.useMemo(
30275
+ return React2.useMemo(
29993
30276
  () => ({
29994
30277
  borderContext: editor.selectedBorderContext,
29995
30278
  activeBorderPresets: editor.activeBorderPresets,
@@ -30003,11 +30286,11 @@ function useDocxBorders(editor) {
30003
30286
  );
30004
30287
  }
30005
30288
  function useDocxFormFields(editor) {
30006
- const formFields = React.useMemo(
30289
+ const formFields = React2.useMemo(
30007
30290
  () => collectFormFieldsFromModel(editor.model),
30008
30291
  [editor.model]
30009
30292
  );
30010
- const updateSelectedFormFieldWidget = React.useCallback(
30293
+ const updateSelectedFormFieldWidget = React2.useCallback(
30011
30294
  (patch) => {
30012
30295
  if (!editor.selectedFormField) {
30013
30296
  return;
@@ -30016,7 +30299,7 @@ function useDocxFormFields(editor) {
30016
30299
  },
30017
30300
  [editor.selectedFormField, editor.updateFormFieldWidget]
30018
30301
  );
30019
- return React.useMemo(
30302
+ return React2.useMemo(
30020
30303
  () => ({
30021
30304
  formFields,
30022
30305
  selectedFormField: editor.selectedFormField,
@@ -30038,7 +30321,7 @@ function useDocxFormFields(editor) {
30038
30321
  );
30039
30322
  }
30040
30323
  function useDocxTrackChanges(editor) {
30041
- const changesByLocation = React.useMemo(() => {
30324
+ const changesByLocation = React2.useMemo(() => {
30042
30325
  const grouped = /* @__PURE__ */ new Map();
30043
30326
  editor.trackedChanges.forEach((change) => {
30044
30327
  const key = paragraphLocationKey(change.location);
@@ -30048,13 +30331,13 @@ function useDocxTrackChanges(editor) {
30048
30331
  });
30049
30332
  return grouped;
30050
30333
  }, [editor.trackedChanges]);
30051
- const getChangesForLocation = React.useCallback(
30334
+ const getChangesForLocation = React2.useCallback(
30052
30335
  (location) => {
30053
30336
  return changesByLocation.get(paragraphLocationKey(location)) ?? [];
30054
30337
  },
30055
30338
  [changesByLocation]
30056
30339
  );
30057
- return React.useMemo(
30340
+ return React2.useMemo(
30058
30341
  () => ({
30059
30342
  trackedChanges: editor.trackedChanges,
30060
30343
  showTrackedChanges: editor.showTrackedChanges,
@@ -30078,7 +30361,7 @@ function useDocxTrackChanges(editor) {
30078
30361
  );
30079
30362
  }
30080
30363
  function useDocxComments(editor) {
30081
- const commentsByLocation = React.useMemo(() => {
30364
+ const commentsByLocation = React2.useMemo(() => {
30082
30365
  const grouped = /* @__PURE__ */ new Map();
30083
30366
  editor.comments.forEach((comment) => {
30084
30367
  const key = paragraphLocationKey(comment.location);
@@ -30088,13 +30371,13 @@ function useDocxComments(editor) {
30088
30371
  });
30089
30372
  return grouped;
30090
30373
  }, [editor.comments]);
30091
- const getCommentsForLocation = React.useCallback(
30374
+ const getCommentsForLocation = React2.useCallback(
30092
30375
  (location) => {
30093
30376
  return commentsByLocation.get(paragraphLocationKey(location)) ?? [];
30094
30377
  },
30095
30378
  [commentsByLocation]
30096
30379
  );
30097
- return React.useMemo(
30380
+ return React2.useMemo(
30098
30381
  () => ({
30099
30382
  comments: editor.comments,
30100
30383
  showComments: editor.showComments,
@@ -30119,7 +30402,7 @@ function useDocxComments(editor) {
30119
30402
  }
30120
30403
  function useDocxPageLayout(editor) {
30121
30404
  const primarySectionPropertiesXml = editor.model.metadata.sections?.[0]?.sectionPropertiesXml ?? editor.model.metadata.sectionPropertiesXml;
30122
- const layout = React.useMemo(() => {
30405
+ const layout = React2.useMemo(() => {
30123
30406
  const sectionLayout = parseSectionLayout(primarySectionPropertiesXml);
30124
30407
  const sectionColumns = parseSectionColumns(primarySectionPropertiesXml);
30125
30408
  const pageNumberStart = parseSectionPageNumberStart(
@@ -30152,7 +30435,7 @@ function useDocxPageLayout(editor) {
30152
30435
  }
30153
30436
  };
30154
30437
  }, [primarySectionPropertiesXml]);
30155
- return React.useMemo(
30438
+ return React2.useMemo(
30156
30439
  () => ({
30157
30440
  layout
30158
30441
  }),
@@ -30160,7 +30443,7 @@ function useDocxPageLayout(editor) {
30160
30443
  );
30161
30444
  }
30162
30445
  function useDocxPagination(editor) {
30163
- return React.useMemo(
30446
+ return React2.useMemo(
30164
30447
  () => ({
30165
30448
  pagination: {
30166
30449
  currentPage: editor.currentPage,
@@ -30978,6 +31261,9 @@ function DocxEditorViewer({
30978
31261
  editor,
30979
31262
  className,
30980
31263
  style,
31264
+ zoom,
31265
+ defaultZoom,
31266
+ onZoomChange,
30981
31267
  pageBackgroundColor,
30982
31268
  pageGapBackgroundColor,
30983
31269
  deferInitialPaginationPaint = false,
@@ -30997,7 +31283,7 @@ function DocxEditorViewer({
30997
31283
  onFormFieldDoubleClick,
30998
31284
  mode = "edit"
30999
31285
  }) {
31000
- const fontMetricsRevision = React.useSyncExternalStore(
31286
+ const fontMetricsRevision = React2.useSyncExternalStore(
31001
31287
  subscribeFontMetrics,
31002
31288
  getFontMetricsRevision,
31003
31289
  getServerFontMetricsRevision
@@ -31013,17 +31299,17 @@ function DocxEditorViewer({
31013
31299
  const documentContentTheme = isNightReaderMode ? "light" : editor.documentTheme;
31014
31300
  const documentContentFilter = isNightReaderMode ? NIGHT_READER_INVERSION_FILTER : void 0;
31015
31301
  const canReplaceDocumentByDrop = mode !== "read-only";
31016
- const formFieldLocationKey = React.useCallback(
31302
+ const formFieldLocationKey = React2.useCallback(
31017
31303
  (location) => {
31018
31304
  return location.kind === "paragraph" ? `p:${location.nodeIndex}:${location.childIndex}` : `t:${location.tableIndex}:${location.rowIndex}:${location.cellIndex}:${location.paragraphIndex}:${location.childIndex}`;
31019
31305
  },
31020
31306
  []
31021
31307
  );
31022
- const tocLinkColorByLevel = React.useMemo(
31308
+ const tocLinkColorByLevel = React2.useMemo(
31023
31309
  () => collectHeadingTextColorByLevel(editor.model),
31024
31310
  [editor.model]
31025
31311
  );
31026
- const paragraphRunRenderOptions = React.useMemo(
31312
+ const paragraphRunRenderOptions = React2.useMemo(
31027
31313
  () => ({
31028
31314
  showTrackedChanges: trackedChangesEnabled,
31029
31315
  showCommentHighlights: commentsEnabled,
@@ -31039,29 +31325,29 @@ function DocxEditorViewer({
31039
31325
  trackedChangesEnabled
31040
31326
  ]
31041
31327
  );
31042
- const viewerRootRef = React.useRef(null);
31043
- const tableCellDraftsRef = React.useRef(/* @__PURE__ */ new Map());
31044
- const plainParagraphHtmlCacheRef = React.useRef(
31328
+ const viewerRootRef = React2.useRef(null);
31329
+ const tableCellDraftsRef = React2.useRef(/* @__PURE__ */ new Map());
31330
+ const plainParagraphHtmlCacheRef = React2.useRef(
31045
31331
  /* @__PURE__ */ new WeakMap()
31046
31332
  );
31047
- const editableParagraphHtmlPropsRef = React.useRef(/* @__PURE__ */ new Map());
31048
- const editableTableCellHtmlPropsRef = React.useRef(/* @__PURE__ */ new Map());
31049
- const tableCellParagraphDraftsRef = React.useRef(
31333
+ const editableParagraphHtmlPropsRef = React2.useRef(/* @__PURE__ */ new Map());
31334
+ const editableTableCellHtmlPropsRef = React2.useRef(/* @__PURE__ */ new Map());
31335
+ const tableCellParagraphDraftsRef = React2.useRef(
31050
31336
  /* @__PURE__ */ new Map()
31051
31337
  );
31052
- const contextMenuClipboardTextRef = React.useRef("");
31053
- const sectionParagraphDraftsRef = React.useRef(
31338
+ const contextMenuClipboardTextRef = React2.useRef("");
31339
+ const sectionParagraphDraftsRef = React2.useRef(
31054
31340
  /* @__PURE__ */ new Map()
31055
31341
  );
31056
- const pendingParagraphSegmentFocusRef = React.useRef(void 0);
31057
- const paragraphElementsRef = React.useRef(
31342
+ const pendingParagraphSegmentFocusRef = React2.useRef(void 0);
31343
+ const paragraphElementsRef = React2.useRef(
31058
31344
  /* @__PURE__ */ new Map()
31059
31345
  );
31060
31346
  const [
31061
31347
  measuredParagraphOuterHeightsPxByBlockId,
31062
31348
  setMeasuredParagraphOuterHeightsPxByBlockId
31063
- ] = React.useState(() => /* @__PURE__ */ new Map());
31064
- const measuredParagraphOuterHeightsPxByNodeIndex = React.useMemo(() => {
31349
+ ] = React2.useState(() => /* @__PURE__ */ new Map());
31350
+ const measuredParagraphOuterHeightsPxByNodeIndex = React2.useMemo(() => {
31065
31351
  const byNodeIndex = /* @__PURE__ */ new Map();
31066
31352
  if (measuredParagraphOuterHeightsPxByBlockId.size === 0) {
31067
31353
  return byNodeIndex;
@@ -31079,70 +31365,70 @@ function DocxEditorViewer({
31079
31365
  });
31080
31366
  return byNodeIndex;
31081
31367
  }, [editor.model.nodes, measuredParagraphOuterHeightsPxByBlockId]);
31082
- const tableCellEditorElementsRef = React.useRef(
31368
+ const tableCellEditorElementsRef = React2.useRef(
31083
31369
  /* @__PURE__ */ new Map()
31084
31370
  );
31085
- const tableCellParagraphElementsRef = React.useRef(/* @__PURE__ */ new Map());
31086
- const sectionParagraphElementsRef = React.useRef(
31371
+ const tableCellParagraphElementsRef = React2.useRef(/* @__PURE__ */ new Map());
31372
+ const sectionParagraphElementsRef = React2.useRef(
31087
31373
  /* @__PURE__ */ new Map()
31088
31374
  );
31089
- const tableElementsRef = React.useRef(/* @__PURE__ */ new Map());
31090
- const pageHeaderElementsRef = React.useRef(
31375
+ const tableElementsRef = React2.useRef(/* @__PURE__ */ new Map());
31376
+ const pageHeaderElementsRef = React2.useRef(
31091
31377
  /* @__PURE__ */ new Map()
31092
31378
  );
31093
- const pageBodyElementsRef = React.useRef(
31379
+ const pageBodyElementsRef = React2.useRef(
31094
31380
  /* @__PURE__ */ new Map()
31095
31381
  );
31096
- const pageFooterElementsRef = React.useRef(
31382
+ const pageFooterElementsRef = React2.useRef(
31097
31383
  /* @__PURE__ */ new Map()
31098
31384
  );
31099
- const pageElementsRef = React.useRef(/* @__PURE__ */ new Map());
31100
- const pageSurfaceRefCallbacksRef = React.useRef(/* @__PURE__ */ new Map());
31101
- const trackedChangeCardElementsRef = React.useRef(/* @__PURE__ */ new Map());
31102
- const initialPaginationStableSignatureRef = React.useRef(
31385
+ const pageElementsRef = React2.useRef(/* @__PURE__ */ new Map());
31386
+ const pageSurfaceRefCallbacksRef = React2.useRef(/* @__PURE__ */ new Map());
31387
+ const trackedChangeCardElementsRef = React2.useRef(/* @__PURE__ */ new Map());
31388
+ const initialPaginationStableSignatureRef = React2.useRef(
31103
31389
  void 0
31104
31390
  );
31105
- const initialPaginationRevealFrameRef = React.useRef(null);
31106
- const pendingHeaderFooterDeactivateFrameRef = React.useRef(
31391
+ const initialPaginationRevealFrameRef = React2.useRef(null);
31392
+ const pendingHeaderFooterDeactivateFrameRef = React2.useRef(
31107
31393
  null
31108
31394
  );
31109
- const appliedHistoryRestoreNonceRef = React.useRef(0);
31110
- const pendingTableCellFocusRef = React.useRef(void 0);
31111
- const pendingSectionParagraphFocusRef = React.useRef(void 0);
31112
- const draggedImageRef = React.useRef(null);
31113
- const previousBodyNodeCountRef = React.useRef(
31395
+ const appliedHistoryRestoreNonceRef = React2.useRef(0);
31396
+ const pendingTableCellFocusRef = React2.useRef(void 0);
31397
+ const pendingSectionParagraphFocusRef = React2.useRef(void 0);
31398
+ const draggedImageRef = React2.useRef(null);
31399
+ const previousBodyNodeCountRef = React2.useRef(
31114
31400
  editor.model.nodes.length
31115
31401
  );
31116
- const fileDragDepthRef = React.useRef(0);
31117
- const tableDraftLayoutRefreshRafRef = React.useRef(null);
31118
- const activeRangeFlushFrameRef = React.useRef(null);
31119
- const pendingEditableCaretRef = React.useRef(null);
31120
- const commandSelectionGuardRef = React.useRef(void 0);
31121
- const editingIntentContinuationRef = React.useRef(void 0);
31122
- const compositionActiveRef = React.useRef(false);
31123
- const pointerSelectionDragRef = React.useRef({ down: false, moved: false });
31124
- const deferredCollapsedSelectionSyncTimeoutRef = React.useRef(
31402
+ const fileDragDepthRef = React2.useRef(0);
31403
+ const tableDraftLayoutRefreshRafRef = React2.useRef(null);
31404
+ const activeRangeFlushFrameRef = React2.useRef(null);
31405
+ const pendingEditableCaretRef = React2.useRef(null);
31406
+ const commandSelectionGuardRef = React2.useRef(void 0);
31407
+ const editingIntentContinuationRef = React2.useRef(void 0);
31408
+ const compositionActiveRef = React2.useRef(false);
31409
+ const pointerSelectionDragRef = React2.useRef({ down: false, moved: false });
31410
+ const deferredCollapsedSelectionSyncTimeoutRef = React2.useRef(
31125
31411
  null
31126
31412
  );
31127
- const pendingSelectionIntentFrameRef = React.useRef(null);
31128
- const selectionIntentNonceRef = React.useRef(0);
31129
- const lastFormFieldClickRef = React.useRef(void 0);
31130
- const [isDragOverCanvas, setIsDragOverCanvas] = React.useState(false);
31131
- const [isDraggingImage, setIsDraggingImage] = React.useState(false);
31132
- const [activeDropTarget, setActiveDropTarget] = React.useState();
31133
- const [selectedImage, setSelectedImage] = React.useState();
31134
- const [selectedSectionImageKey, setSelectedSectionImageKey] = React.useState();
31135
- const [selectedDropCapNodeIndex, setSelectedDropCapNodeIndex] = React.useState();
31136
- const [hoveredDropCapNodeIndex, setHoveredDropCapNodeIndex] = React.useState();
31137
- const [activeWrappedParagraphSession, setActiveWrappedParagraphSession] = React.useState();
31138
- const activeWrappedParagraphSessionRef = React.useRef(void 0);
31139
- const [resizePreview, setResizePreview] = React.useState();
31140
- const [floatingMovePreview, setFloatingMovePreview] = React.useState();
31141
- const [dropCapMovePreview, setDropCapMovePreview] = React.useState();
31142
- const [dropCapResizePreview, setDropCapResizePreview] = React.useState();
31143
- const [tableColumnWidths, setTableColumnWidths] = React.useState({});
31144
- const [embeddedTableColumnWidths, setEmbeddedTableColumnWidths] = React.useState({});
31145
- const handleRepeatedFormFieldClick = React.useCallback(
31413
+ const pendingSelectionIntentFrameRef = React2.useRef(null);
31414
+ const selectionIntentNonceRef = React2.useRef(0);
31415
+ const lastFormFieldClickRef = React2.useRef(void 0);
31416
+ const [isDragOverCanvas, setIsDragOverCanvas] = React2.useState(false);
31417
+ const [isDraggingImage, setIsDraggingImage] = React2.useState(false);
31418
+ const [activeDropTarget, setActiveDropTarget] = React2.useState();
31419
+ const [selectedImage, setSelectedImage] = React2.useState();
31420
+ const [selectedSectionImageKey, setSelectedSectionImageKey] = React2.useState();
31421
+ const [selectedDropCapNodeIndex, setSelectedDropCapNodeIndex] = React2.useState();
31422
+ const [hoveredDropCapNodeIndex, setHoveredDropCapNodeIndex] = React2.useState();
31423
+ const [activeWrappedParagraphSession, setActiveWrappedParagraphSession] = React2.useState();
31424
+ const activeWrappedParagraphSessionRef = React2.useRef(void 0);
31425
+ const [resizePreview, setResizePreview] = React2.useState();
31426
+ const [floatingMovePreview, setFloatingMovePreview] = React2.useState();
31427
+ const [dropCapMovePreview, setDropCapMovePreview] = React2.useState();
31428
+ const [dropCapResizePreview, setDropCapResizePreview] = React2.useState();
31429
+ const [tableColumnWidths, setTableColumnWidths] = React2.useState({});
31430
+ const [embeddedTableColumnWidths, setEmbeddedTableColumnWidths] = React2.useState({});
31431
+ const handleRepeatedFormFieldClick = React2.useCallback(
31146
31432
  (location) => {
31147
31433
  const now2 = typeof performance !== "undefined" ? performance.now() : Date.now();
31148
31434
  const key = formFieldLocationKey(location);
@@ -31158,16 +31444,16 @@ function DocxEditorViewer({
31158
31444
  },
31159
31445
  [editor.selectFormField, formFieldLocationKey, onFormFieldDoubleClick]
31160
31446
  );
31161
- const [activeColumnResize, setActiveColumnResize] = React.useState();
31162
- const [activeEmbeddedColumnResize, setActiveEmbeddedColumnResize] = React.useState();
31163
- const [tableRowHeights, setTableRowHeights] = React.useState({});
31164
- const [embeddedTableRowHeights, setEmbeddedTableRowHeights] = React.useState({});
31165
- const [tableMeasuredRowHeights, setTableMeasuredRowHeights] = React.useState({});
31447
+ const [activeColumnResize, setActiveColumnResize] = React2.useState();
31448
+ const [activeEmbeddedColumnResize, setActiveEmbeddedColumnResize] = React2.useState();
31449
+ const [tableRowHeights, setTableRowHeights] = React2.useState({});
31450
+ const [embeddedTableRowHeights, setEmbeddedTableRowHeights] = React2.useState({});
31451
+ const [tableMeasuredRowHeights, setTableMeasuredRowHeights] = React2.useState({});
31166
31452
  const [
31167
31453
  measuredPageContentHeightByIndex,
31168
31454
  setMeasuredPageContentHeightByIndex
31169
- ] = React.useState([]);
31170
- const pageSurfaceRefForIndex = React.useCallback(
31455
+ ] = React2.useState([]);
31456
+ const pageSurfaceRefForIndex = React2.useCallback(
31171
31457
  (pageIndex) => {
31172
31458
  const normalizedPageIndex = Math.max(0, Math.round(pageIndex));
31173
31459
  const cached = pageSurfaceRefCallbacksRef.current.get(normalizedPageIndex);
@@ -31197,54 +31483,54 @@ function DocxEditorViewer({
31197
31483
  },
31198
31484
  [pageSurfaceRegistryOwner]
31199
31485
  );
31200
- React.useEffect(() => {
31486
+ React2.useEffect(() => {
31201
31487
  pageSurfaceRefCallbacksRef.current.clear();
31202
31488
  }, [pageSurfaceRegistryOwner]);
31203
31489
  const [
31204
31490
  measuredPageContentIdentityKeysByIndex,
31205
31491
  setMeasuredPageContentIdentityKeysByIndex
31206
- ] = React.useState([]);
31492
+ ] = React2.useState([]);
31207
31493
  const [
31208
31494
  measuredPageContentValidationByIndex,
31209
31495
  setMeasuredPageContentValidationByIndex
31210
- ] = React.useState([]);
31211
- const [hasMeasuredBodyFooterOverlap, setHasMeasuredBodyFooterOverlap] = React.useState(false);
31212
- const measuredBodyFooterOverlapCandidateRef = React.useRef({
31496
+ ] = React2.useState([]);
31497
+ const [hasMeasuredBodyFooterOverlap, setHasMeasuredBodyFooterOverlap] = React2.useState(false);
31498
+ const measuredBodyFooterOverlapCandidateRef = React2.useRef({
31213
31499
  signature: void 0,
31214
31500
  consecutivePasses: 0
31215
31501
  });
31216
- const [, setRenderableImageSourceRevision] = React.useState(0);
31217
- const [activeEditableParagraphSegment, setActiveEditableParagraphSegment] = React.useState(void 0);
31218
- const wrappedParagraphTextareaRef = React.useRef(
31502
+ const [, setRenderableImageSourceRevision] = React2.useState(0);
31503
+ const [activeEditableParagraphSegment, setActiveEditableParagraphSegment] = React2.useState(void 0);
31504
+ const wrappedParagraphTextareaRef = React2.useRef(
31219
31505
  null
31220
31506
  );
31221
- const wrappedParagraphPendingSelectionRef = React.useRef(void 0);
31222
- const wrappedParagraphSelectionDragRef = React.useRef(void 0);
31223
- const wrappedParagraphSurfaceRegistryRef = React.useRef(/* @__PURE__ */ new Map());
31224
- const [isInitialPaginationSettled, setIsInitialPaginationSettled] = React.useState(!deferInitialPaginationPaint);
31507
+ const wrappedParagraphPendingSelectionRef = React2.useRef(void 0);
31508
+ const wrappedParagraphSelectionDragRef = React2.useRef(void 0);
31509
+ const wrappedParagraphSurfaceRegistryRef = React2.useRef(/* @__PURE__ */ new Map());
31510
+ const [isInitialPaginationSettled, setIsInitialPaginationSettled] = React2.useState(!deferInitialPaginationPaint);
31225
31511
  const [
31226
31512
  initialPaginationBackgroundRefinementUnlocked,
31227
31513
  setInitialPaginationBackgroundRefinementUnlocked
31228
- ] = React.useState(!deferInitialPaginationPaint);
31229
- const [postImportPaginationUnlocked, setPostImportPaginationUnlocked] = React.useState(false);
31514
+ ] = React2.useState(!deferInitialPaginationPaint);
31515
+ const [postImportPaginationUnlocked, setPostImportPaginationUnlocked] = React2.useState(false);
31230
31516
  const [
31231
31517
  initialPaginationReservedLayoutState,
31232
31518
  setInitialPaginationReservedLayoutState
31233
- ] = React.useState({
31519
+ ] = React2.useState({
31234
31520
  pageCount: 0,
31235
31521
  totalHeightPx: 0
31236
31522
  });
31237
- const [disableMeasuredImportPagination, setDisableMeasuredImportPagination] = React.useState(false);
31238
- const initialPaginationPageCountOscillationRef = React.useRef({
31523
+ const [disableMeasuredImportPagination, setDisableMeasuredImportPagination] = React2.useState(false);
31524
+ const initialPaginationPageCountOscillationRef = React2.useRef({
31239
31525
  changeCount: 0,
31240
31526
  distinctPageCounts: /* @__PURE__ */ new Set()
31241
31527
  });
31242
- React.useEffect(() => {
31528
+ React2.useEffect(() => {
31243
31529
  return subscribeRenderableImageSourceUpdates(() => {
31244
31530
  setRenderableImageSourceRevision((value) => value + 1);
31245
31531
  });
31246
31532
  }, []);
31247
- React.useEffect(() => {
31533
+ React2.useEffect(() => {
31248
31534
  if (typeof document === "undefined") {
31249
31535
  return;
31250
31536
  }
@@ -31264,7 +31550,7 @@ function DocxEditorViewer({
31264
31550
  document.head.appendChild(styleElement);
31265
31551
  }
31266
31552
  }, []);
31267
- React.useEffect(() => {
31553
+ React2.useEffect(() => {
31268
31554
  setMeasuredPageContentHeightByIndex([]);
31269
31555
  setMeasuredPageContentIdentityKeysByIndex([]);
31270
31556
  setMeasuredPageContentValidationByIndex([]);
@@ -31309,7 +31595,7 @@ function DocxEditorViewer({
31309
31595
  distinctPageCounts: /* @__PURE__ */ new Set()
31310
31596
  };
31311
31597
  }, [editor.documentLoadNonce]);
31312
- React.useEffect(() => {
31598
+ React2.useEffect(() => {
31313
31599
  initialPaginationStableSignatureRef.current = void 0;
31314
31600
  if (initialPaginationRevealFrameRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
31315
31601
  window.cancelAnimationFrame(initialPaginationRevealFrameRef.current);
@@ -31320,47 +31606,47 @@ function DocxEditorViewer({
31320
31606
  !deferInitialPaginationPaint
31321
31607
  );
31322
31608
  }, [deferInitialPaginationPaint, editor.documentLoadNonce]);
31323
- const [activeRowResize, setActiveRowResize] = React.useState();
31324
- const [activeEmbeddedRowResize, setActiveEmbeddedRowResize] = React.useState();
31325
- const [activeTableResize, setActiveTableResize] = React.useState();
31326
- const [activeEmbeddedTableResize, setActiveEmbeddedTableResize] = React.useState();
31327
- const [hoveredTableResizeHandle, setHoveredTableResizeHandle] = React.useState();
31328
- const [hoveredTableHandleTableIndex, setHoveredTableHandleTableIndex] = React.useState();
31609
+ const [activeRowResize, setActiveRowResize] = React2.useState();
31610
+ const [activeEmbeddedRowResize, setActiveEmbeddedRowResize] = React2.useState();
31611
+ const [activeTableResize, setActiveTableResize] = React2.useState();
31612
+ const [activeEmbeddedTableResize, setActiveEmbeddedTableResize] = React2.useState();
31613
+ const [hoveredTableResizeHandle, setHoveredTableResizeHandle] = React2.useState();
31614
+ const [hoveredTableHandleTableIndex, setHoveredTableHandleTableIndex] = React2.useState();
31329
31615
  const [
31330
31616
  hoveredEmbeddedTableResizeHandle,
31331
31617
  setHoveredEmbeddedTableResizeHandle
31332
- ] = React.useState();
31333
- const [hoveredEmbeddedTableKey, setHoveredEmbeddedTableKey] = React.useState();
31334
- const [focusedEmbeddedTableKey, setFocusedEmbeddedTableKey] = React.useState();
31335
- const tableSelectionDragRef = React.useRef(void 0);
31336
- const tableCellSelectionDragRef = React.useRef(void 0);
31337
- const tableMoveDragRef = React.useRef(void 0);
31338
- const suppressNextTableCellClickRef = React.useRef(false);
31339
- const [tableCellSelectionRange, setTableCellSelectionRange] = React.useState();
31340
- const [tableMoveDropPreview, setTableMoveDropPreview] = React.useState();
31341
- const [objectWrapDragPreview, setObjectWrapDragPreview] = React.useState();
31342
- const objectDragCleanupRef = React.useRef(void 0);
31343
- React.useEffect(() => () => objectDragCleanupRef.current?.(), [editor.documentLoadNonce, editor.model, isReadOnly]);
31344
- const [tableContextMenuState, setTableContextMenuState] = React.useState();
31345
- const [contextMenuState, setContextMenuState] = React.useState();
31346
- const [activeHeaderFooterEdit, setActiveHeaderFooterEdit] = React.useState();
31347
- const [tableDraftLayoutEpoch, bumpTableDraftLayoutEpoch] = React.useReducer(
31618
+ ] = React2.useState();
31619
+ const [hoveredEmbeddedTableKey, setHoveredEmbeddedTableKey] = React2.useState();
31620
+ const [focusedEmbeddedTableKey, setFocusedEmbeddedTableKey] = React2.useState();
31621
+ const tableSelectionDragRef = React2.useRef(void 0);
31622
+ const tableCellSelectionDragRef = React2.useRef(void 0);
31623
+ const tableMoveDragRef = React2.useRef(void 0);
31624
+ const suppressNextTableCellClickRef = React2.useRef(false);
31625
+ const [tableCellSelectionRange, setTableCellSelectionRange] = React2.useState();
31626
+ const [tableMoveDropPreview, setTableMoveDropPreview] = React2.useState();
31627
+ const [objectWrapDragPreview, setObjectWrapDragPreview] = React2.useState();
31628
+ const objectDragCleanupRef = React2.useRef(void 0);
31629
+ React2.useEffect(() => () => objectDragCleanupRef.current?.(), [editor.documentLoadNonce, editor.model, isReadOnly]);
31630
+ const [tableContextMenuState, setTableContextMenuState] = React2.useState();
31631
+ const [contextMenuState, setContextMenuState] = React2.useState();
31632
+ const [activeHeaderFooterEdit, setActiveHeaderFooterEdit] = React2.useState();
31633
+ const [tableDraftLayoutEpoch, bumpTableDraftLayoutEpoch] = React2.useReducer(
31348
31634
  (value) => value + 1,
31349
31635
  0
31350
31636
  );
31351
- const [paragraphStructureEpoch, bumpParagraphStructureEpoch] = React.useReducer((value) => value + 1, 0);
31352
- const [paginationMeasurementEpoch, bumpPaginationMeasurementEpoch] = React.useReducer((value) => value + 1, 0);
31353
- const [measuredWrapBands, setMeasuredWrapBands] = React.useState(() => /* @__PURE__ */ new Map());
31354
- const wrapBandReconcileModelRef = React.useRef(void 0);
31355
- const wrapBandReconcilePassCountRef = React.useRef(0);
31356
- const paginationMeasurementSuspendUntilRef = React.useRef(0);
31357
- const paginationMeasurementResumeTimeoutRef = React.useRef(
31637
+ const [paragraphStructureEpoch, bumpParagraphStructureEpoch] = React2.useReducer((value) => value + 1, 0);
31638
+ const [paginationMeasurementEpoch, bumpPaginationMeasurementEpoch] = React2.useReducer((value) => value + 1, 0);
31639
+ const [measuredWrapBands, setMeasuredWrapBands] = React2.useState(() => /* @__PURE__ */ new Map());
31640
+ const wrapBandReconcileModelRef = React2.useRef(void 0);
31641
+ const wrapBandReconcilePassCountRef = React2.useRef(0);
31642
+ const paginationMeasurementSuspendUntilRef = React2.useRef(0);
31643
+ const paginationMeasurementResumeTimeoutRef = React2.useRef(
31358
31644
  null
31359
31645
  );
31360
- React.useLayoutEffect(() => {
31646
+ React2.useLayoutEffect(() => {
31361
31647
  setMeasuredParagraphOuterHeightsPxByBlockId(/* @__PURE__ */ new Map());
31362
31648
  }, [editor.documentLoadNonce]);
31363
- React.useEffect(() => {
31649
+ React2.useEffect(() => {
31364
31650
  setMeasuredParagraphOuterHeightsPxByBlockId((current) => {
31365
31651
  if (current.size === 0) {
31366
31652
  return current;
@@ -31380,7 +31666,7 @@ function DocxEditorViewer({
31380
31666
  return next ?? current;
31381
31667
  });
31382
31668
  }, [editor.model.nodes]);
31383
- const schedulePaginationMeasurementResume = React.useCallback(
31669
+ const schedulePaginationMeasurementResume = React2.useCallback(
31384
31670
  (delayMs) => {
31385
31671
  if (typeof window === "undefined") {
31386
31672
  return;
@@ -31401,7 +31687,7 @@ function DocxEditorViewer({
31401
31687
  },
31402
31688
  []
31403
31689
  );
31404
- const requestTableDraftLayoutRefresh = React.useCallback(() => {
31690
+ const requestTableDraftLayoutRefresh = React2.useCallback(() => {
31405
31691
  if (typeof window === "undefined" || typeof window.requestAnimationFrame !== "function") {
31406
31692
  bumpTableDraftLayoutEpoch();
31407
31693
  return;
@@ -31414,7 +31700,7 @@ function DocxEditorViewer({
31414
31700
  bumpTableDraftLayoutEpoch();
31415
31701
  });
31416
31702
  }, []);
31417
- React.useEffect(() => {
31703
+ React2.useEffect(() => {
31418
31704
  return () => {
31419
31705
  if (tableDraftLayoutRefreshRafRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
31420
31706
  window.cancelAnimationFrame(tableDraftLayoutRefreshRafRef.current);
@@ -31448,7 +31734,7 @@ function DocxEditorViewer({
31448
31734
  pendingSelectionIntentFrameRef.current = null;
31449
31735
  };
31450
31736
  }, []);
31451
- React.useEffect(() => {
31737
+ React2.useEffect(() => {
31452
31738
  if (!isReadOnly) {
31453
31739
  return;
31454
31740
  }
@@ -31482,7 +31768,7 @@ function DocxEditorViewer({
31482
31768
  sectionParagraphDraftsRef.current.clear();
31483
31769
  pendingSectionParagraphFocusRef.current = void 0;
31484
31770
  }, [isReadOnly]);
31485
- const beginSelectionIntent = React.useCallback(() => {
31771
+ const beginSelectionIntent = React2.useCallback(() => {
31486
31772
  if (pendingSelectionIntentFrameRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
31487
31773
  window.cancelAnimationFrame(pendingSelectionIntentFrameRef.current);
31488
31774
  }
@@ -31491,13 +31777,13 @@ function DocxEditorViewer({
31491
31777
  selectionIntentNonceRef.current = nextNonce;
31492
31778
  return nextNonce;
31493
31779
  }, []);
31494
- const isSelectionIntentCurrent = React.useCallback(
31780
+ const isSelectionIntentCurrent = React2.useCallback(
31495
31781
  (nonce) => {
31496
31782
  return selectionIntentNonceRef.current === nonce;
31497
31783
  },
31498
31784
  []
31499
31785
  );
31500
- const scheduleSelectionIntentFrame = React.useCallback(
31786
+ const scheduleSelectionIntentFrame = React2.useCallback(
31501
31787
  (nonce, callback) => {
31502
31788
  if (pendingSelectionIntentFrameRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
31503
31789
  window.cancelAnimationFrame(pendingSelectionIntentFrameRef.current);
@@ -31521,10 +31807,10 @@ function DocxEditorViewer({
31521
31807
  },
31522
31808
  []
31523
31809
  );
31524
- const cancelPendingSelectionIntent = React.useCallback(() => {
31810
+ const cancelPendingSelectionIntent = React2.useCallback(() => {
31525
31811
  beginSelectionIntent();
31526
31812
  }, [beginSelectionIntent]);
31527
- React.useEffect(() => {
31813
+ React2.useEffect(() => {
31528
31814
  const previousNodeCount = previousBodyNodeCountRef.current;
31529
31815
  const nextNodeCount = editor.model.nodes.length;
31530
31816
  const structureChanged = previousNodeCount !== nextNodeCount;
@@ -31573,20 +31859,20 @@ function DocxEditorViewer({
31573
31859
  });
31574
31860
  previousBodyNodeCountRef.current = nextNodeCount;
31575
31861
  }, [editor.model.nodes]);
31576
- const documentSections = React.useMemo(
31862
+ const documentSections = React2.useMemo(
31577
31863
  () => resolveDocumentSectionsFromMetadata(editor.model.metadata),
31578
31864
  [editor.model.metadata]
31579
31865
  );
31580
31866
  const primarySectionPropertiesXml = documentSections[0]?.sectionPropertiesXml ?? editor.model.metadata.sectionPropertiesXml;
31581
- const documentLayout = React.useMemo(
31867
+ const documentLayout = React2.useMemo(
31582
31868
  () => parseSectionLayout(primarySectionPropertiesXml),
31583
31869
  [primarySectionPropertiesXml]
31584
31870
  );
31585
- const paginationSectionMetrics = React.useMemo(
31871
+ const paginationSectionMetrics = React2.useMemo(
31586
31872
  () => buildPaginationSectionMetrics(documentSections, documentLayout),
31587
31873
  [documentLayout, documentSections]
31588
31874
  );
31589
- const paginationMeasurementContextSignature = React.useMemo(
31875
+ const paginationMeasurementContextSignature = React2.useMemo(
31590
31876
  () => [
31591
31877
  Math.round(documentLayout.pageWidthPx),
31592
31878
  Math.round(documentLayout.pageHeightPx),
@@ -31605,7 +31891,7 @@ function DocxEditorViewer({
31605
31891
  trackedChangesEnabled
31606
31892
  ]
31607
31893
  );
31608
- React.useEffect(() => {
31894
+ React2.useEffect(() => {
31609
31895
  setMeasuredPageContentHeightByIndex((current) => current.length ? [] : current);
31610
31896
  setMeasuredPageContentIdentityKeysByIndex(
31611
31897
  (current) => current.length ? [] : current
@@ -31615,7 +31901,7 @@ function DocxEditorViewer({
31615
31901
  );
31616
31902
  setHasMeasuredBodyFooterOverlap(false);
31617
31903
  }, [fontMetricsRevision]);
31618
- React.useEffect(() => {
31904
+ React2.useEffect(() => {
31619
31905
  setMeasuredParagraphOuterHeightsPxByBlockId(
31620
31906
  (current) => current.size === 0 ? current : /* @__PURE__ */ new Map()
31621
31907
  );
@@ -31627,7 +31913,7 @@ function DocxEditorViewer({
31627
31913
  docGridLinePitchPxByNodeIndex,
31628
31914
  pageContentWidthPxByNodeIndex,
31629
31915
  pageContentHeightPxByNodeIndex
31630
- } = React.useMemo(() => {
31916
+ } = React2.useMemo(() => {
31631
31917
  const pitchByNodeIndex = /* @__PURE__ */ new Map();
31632
31918
  const widthByNodeIndex = /* @__PURE__ */ new Map();
31633
31919
  const heightByNodeIndex = /* @__PURE__ */ new Map();
@@ -31674,17 +31960,17 @@ function DocxEditorViewer({
31674
31960
  pageContentHeightPxByNodeIndex: heightByNodeIndex
31675
31961
  };
31676
31962
  }, [editor.model.nodes.length, paginationSectionMetrics]);
31677
- const sectionColumnsBySectionIndex = React.useMemo(
31963
+ const sectionColumnsBySectionIndex = React2.useMemo(
31678
31964
  () => documentSections.map(
31679
31965
  (section) => parseSectionColumns(section.sectionPropertiesXml)
31680
31966
  ),
31681
31967
  [documentSections]
31682
31968
  );
31683
- const paragraphNumberingLabels = React.useMemo(
31969
+ const paragraphNumberingLabels = React2.useMemo(
31684
31970
  () => buildParagraphNumberingLabels(editor.model),
31685
31971
  [editor.model]
31686
31972
  );
31687
- const noteMarkerIndexes = React.useMemo(
31973
+ const noteMarkerIndexes = React2.useMemo(
31688
31974
  () => ({
31689
31975
  footnote: new Map(
31690
31976
  editor.model.metadata.footnotes?.map((note, index) => [
@@ -31701,7 +31987,7 @@ function DocxEditorViewer({
31701
31987
  }),
31702
31988
  [editor.model.metadata.footnotes, editor.model.metadata.endnotes]
31703
31989
  );
31704
- const bookmarkTargetNodeIndexByName = React.useMemo(() => {
31990
+ const bookmarkTargetNodeIndexByName = React2.useMemo(() => {
31705
31991
  const targets = /* @__PURE__ */ new Map();
31706
31992
  editor.model.nodes.forEach((node, nodeIndex) => {
31707
31993
  if (node.type === "paragraph") {
@@ -31726,7 +32012,7 @@ function DocxEditorViewer({
31726
32012
  });
31727
32013
  return targets;
31728
32014
  }, [editor.model.nodes]);
31729
- const tableMeasuredRowHeightsForPagination = React.useMemo(() => {
32015
+ const tableMeasuredRowHeightsForPagination = React2.useMemo(() => {
31730
32016
  const allowMeasuredImportPagination = !editor.canUndo && !editor.canRedo && !disableMeasuredImportPagination;
31731
32017
  const activeDraftKeys = [
31732
32018
  ...tableCellDraftsRef.current.keys(),
@@ -31757,10 +32043,10 @@ function DocxEditorViewer({
31757
32043
  tableDraftLayoutEpoch,
31758
32044
  tableMeasuredRowHeights
31759
32045
  ]);
31760
- const textEditPaginationMemo = React.useRef(null);
32046
+ const textEditPaginationMemo = React2.useRef(null);
31761
32047
  if (!textEditPaginationMemo.current)
31762
32048
  textEditPaginationMemo.current = createTextEditPaginationMemo();
31763
- const pageSegmentationPlan = React.useMemo(() => {
32049
+ const pageSegmentationPlan = React2.useMemo(() => {
31764
32050
  const pageContentHeightPx = Math.max(
31765
32051
  120,
31766
32052
  documentLayout.pageHeightPx - documentLayout.marginsPx.top - documentLayout.marginsPx.bottom
@@ -32161,13 +32447,13 @@ function DocxEditorViewer({
32161
32447
  const useMeasuredPageContentHeightsForRender = pageSegmentationPlan.useMeasuredPageContentHeightsForRender;
32162
32448
  const renderMeasuredPageContentHeightsPxByPageIndex = pageSegmentationPlan.renderMeasuredPageContentHeightsPxByPageIndex;
32163
32449
  const renderPageContentHeightScale = pageSegmentationPlan.renderPageContentHeightScale;
32164
- const pageNodeSegmentIdentityKeysByPage = React.useMemo(
32450
+ const pageNodeSegmentIdentityKeysByPage = React2.useMemo(
32165
32451
  () => pageNodeSegmentsByPage.map(
32166
32452
  (pageSegments) => documentPageNodeSegmentsIdentityKey(pageSegments)
32167
32453
  ),
32168
32454
  [pageNodeSegmentsByPage]
32169
32455
  );
32170
- const pageIndexByNodeIndex = React.useMemo(() => {
32456
+ const pageIndexByNodeIndex = React2.useMemo(() => {
32171
32457
  const indexByNode = /* @__PURE__ */ new Map();
32172
32458
  pageNodeSegmentsByPage.forEach((segments, pageIndex) => {
32173
32459
  segments.forEach((segment) => {
@@ -32178,14 +32464,14 @@ function DocxEditorViewer({
32178
32464
  });
32179
32465
  return indexByNode;
32180
32466
  }, [pageNodeSegmentsByPage]);
32181
- const storedDocumentPageCount = React.useMemo(() => {
32467
+ const storedDocumentPageCount = React2.useMemo(() => {
32182
32468
  const value = editor.model.metadata.documentPageCount;
32183
32469
  if (!Number.isFinite(value) || value <= 0) {
32184
32470
  return void 0;
32185
32471
  }
32186
32472
  return Math.max(1, Math.round(value));
32187
32473
  }, [editor.model.metadata.documentPageCount]);
32188
- const pageSectionInfoByIndex = React.useMemo(() => {
32474
+ const pageSectionInfoByIndex = React2.useMemo(() => {
32189
32475
  if (pageNodeSegmentsByPage.length === 0) {
32190
32476
  return [];
32191
32477
  }
@@ -32322,7 +32608,7 @@ function DocxEditorViewer({
32322
32608
  pageNodeSegmentsByPage,
32323
32609
  primarySectionPropertiesXml
32324
32610
  ]);
32325
- const pageThumbnailContentKeysByPage = React.useMemo(() => {
32611
+ const pageThumbnailContentKeysByPage = React2.useMemo(() => {
32326
32612
  const metadataSignature = docModelThumbnailMetadataSignature(
32327
32613
  editor.model.metadata
32328
32614
  );
@@ -32352,7 +32638,7 @@ function DocxEditorViewer({
32352
32638
  pageSectionInfoByIndex,
32353
32639
  trackedChangesEnabled
32354
32640
  ]);
32355
- const pageThumbnailSurfaceSizesByPage = React.useMemo(
32641
+ const pageThumbnailSurfaceSizesByPage = React2.useMemo(
32356
32642
  () => pageNodeSegmentsByPage.map((_, pageIndex) => {
32357
32643
  const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
32358
32644
  return {
@@ -32362,7 +32648,7 @@ function DocxEditorViewer({
32362
32648
  }),
32363
32649
  [documentLayout, pageNodeSegmentsByPage, pageSectionInfoByIndex]
32364
32650
  );
32365
- const pageThumbnailSnapshotEntriesByPage = React.useMemo(
32651
+ const pageThumbnailSnapshotEntriesByPage = React2.useMemo(
32366
32652
  () => buildDocxPageThumbnailRenderSnapshotEntries({
32367
32653
  model: editor.model,
32368
32654
  pageNodeSegmentsByPage,
@@ -32384,7 +32670,7 @@ function DocxEditorViewer({
32384
32670
  pageThumbnailContentKeysByPage
32385
32671
  ]
32386
32672
  );
32387
- React.useEffect(() => {
32673
+ React2.useEffect(() => {
32388
32674
  syncDocxViewerPageSurfaceContentKeys(
32389
32675
  editor,
32390
32676
  pageThumbnailContentKeysByPage,
@@ -32397,7 +32683,7 @@ function DocxEditorViewer({
32397
32683
  pageThumbnailSnapshotEntriesByPage,
32398
32684
  pageThumbnailSurfaceSizesByPage
32399
32685
  ]);
32400
- const resolveStyleRefFieldValueForPage = React.useMemo(() => {
32686
+ const resolveStyleRefFieldValueForPage = React2.useMemo(() => {
32401
32687
  const valueCache = /* @__PURE__ */ new Map();
32402
32688
  const nodes = editor.model.nodes;
32403
32689
  const resolveFromParagraph = (paragraph, target, normalizedTarget) => {
@@ -32462,14 +32748,43 @@ function DocxEditorViewer({
32462
32748
  };
32463
32749
  }, [editor.model.nodes, pageNodeSegmentsByPage]);
32464
32750
  const pageCount = pageNodeSegmentsByPage.length;
32465
- const requestedPageIndexes = React.useMemo(
32751
+ const viewerZoomContentSize = React2.useMemo(() => {
32752
+ let width = documentLayout.pageWidthPx;
32753
+ let height = documentLayout.pageHeightPx;
32754
+ pageSectionInfoByIndex.forEach(({ layout }) => {
32755
+ width = Math.max(width, layout.pageWidthPx);
32756
+ height = Math.max(height, layout.pageHeightPx);
32757
+ });
32758
+ if (showTrackedChangeGutter) {
32759
+ width += TRACKED_CHANGE_GUTTER_WIDTH_PX;
32760
+ }
32761
+ return { width, height };
32762
+ }, [documentLayout, pageSectionInfoByIndex, showTrackedChangeGutter]);
32763
+ const onViewerZoomBridgeChange = React2.useCallback(
32764
+ (bridge) => {
32765
+ setViewerZoomBridge(editor, bridge);
32766
+ },
32767
+ [editor.syncPaginationInfo]
32768
+ );
32769
+ const viewerZoom = useViewerZoom({
32770
+ zoom,
32771
+ defaultZoom: defaultZoom ?? editor.getZoom(),
32772
+ onZoomChange,
32773
+ rootRef: viewerRootRef,
32774
+ contentWidth: viewerZoomContentSize.width,
32775
+ contentHeight: viewerZoomContentSize.height,
32776
+ pageSelector: '[data-docx-page-wrapper="true"]',
32777
+ onBridgeChange: onViewerZoomBridgeChange
32778
+ });
32779
+ const builtInViewerZoomScale = viewerZoom.resolvedZoom / 100;
32780
+ const requestedPageIndexes = React2.useMemo(
32466
32781
  () => normalizeDocxThumbnailPageIndexes(pageIndexes, pageCount).sort(
32467
32782
  (left, right) => left - right
32468
32783
  ),
32469
32784
  [pageCount, pageIndexes]
32470
32785
  );
32471
32786
  const hasRequestedPageIndexes = pageIndexes !== void 0;
32472
- const hasLargeTableLayoutSurface = React.useMemo(() => {
32787
+ const hasLargeTableLayoutSurface = React2.useMemo(() => {
32473
32788
  let tableParagraphCount = 0;
32474
32789
  let tableCellCount = 0;
32475
32790
  let largestRowParagraphCount = 0;
@@ -32496,7 +32811,7 @@ function DocxEditorViewer({
32496
32811
  return tableParagraphCount >= 1e3 || tableCellCount >= 240 || largestRowParagraphCount >= 100;
32497
32812
  }, [editor.model.nodes]);
32498
32813
  const hideDocumentUntilPaginationSettled = deferInitialPaginationPaint && !isInitialPaginationSettled;
32499
- const estimateDocumentStackHeightPx = React.useCallback(
32814
+ const estimateDocumentStackHeightPx = React2.useCallback(
32500
32815
  (count) => {
32501
32816
  const safeCount = Math.max(0, Math.round(count));
32502
32817
  if (safeCount <= 0) {
@@ -32512,7 +32827,7 @@ function DocxEditorViewer({
32512
32827
  },
32513
32828
  [documentLayout, pageSectionInfoByIndex]
32514
32829
  );
32515
- React.useEffect(() => {
32830
+ React2.useEffect(() => {
32516
32831
  if (!hideDocumentUntilPaginationSettled) {
32517
32832
  setInitialPaginationReservedLayoutState((current) => {
32518
32833
  if (current.pageCount === 0 && current.totalHeightPx === 0) {
@@ -32564,10 +32879,10 @@ function DocxEditorViewer({
32564
32879
  )
32565
32880
  ) : 0;
32566
32881
  const hasExternalVisiblePageRange = hasRequestedPageIndexes || Number.isFinite(Number(visiblePageRange?.startPageIndex)) || Number.isFinite(Number(visiblePageRange?.endPageIndex));
32567
- const [deferInternalPageVirtualization, setDeferInternalPageVirtualization] = React.useState(false);
32568
- const [internalVirtualScrollElement, setInternalVirtualScrollElement] = React.useState(null);
32569
- const [virtualizerMeasurementScale, setVirtualizerMeasurementScale] = React.useState(1);
32570
- const [observedVisiblePageRange, setObservedVisiblePageRange] = React.useState(void 0);
32882
+ const [deferInternalPageVirtualization, setDeferInternalPageVirtualization] = React2.useState(false);
32883
+ const [internalVirtualScrollElement, setInternalVirtualScrollElement] = React2.useState(null);
32884
+ const [virtualizerMeasurementScale, setVirtualizerMeasurementScale] = React2.useState(1);
32885
+ const [observedVisiblePageRange, setObservedVisiblePageRange] = React2.useState(void 0);
32571
32886
  const pageVirtualizationSettleDelayMs = Math.max(
32572
32887
  0,
32573
32888
  Math.round(
@@ -32585,16 +32900,16 @@ function DocxEditorViewer({
32585
32900
  const internalPageVirtualizationRequested = pageVirtualization?.enabled !== false && !hasExternalVisiblePageRange && !hideDocumentUntilPaginationSettled && isInitialPaginationSettled && !deferInternalPageVirtualization && !webdriverActive && pageCount > 1;
32586
32901
  const explicitPageVirtualizationScrollElement = pageVirtualization?.scrollElement ?? null;
32587
32902
  const explicitPageVirtualizationZoomScale = normalizePageVirtualizationZoomScale(pageVirtualization?.zoomScale);
32588
- const resolveViewerMeasurementZoomScale = React.useCallback(
32903
+ const resolveViewerMeasurementZoomScale = React2.useCallback(
32589
32904
  (rootElement, fallback = 1) => {
32590
32905
  if (explicitPageVirtualizationZoomScale !== void 0) {
32591
- return explicitPageVirtualizationZoomScale;
32906
+ return explicitPageVirtualizationZoomScale * builtInViewerZoomScale;
32592
32907
  }
32593
- return rootElement ? resolveEffectiveZoomScale(rootElement) : fallback;
32908
+ return rootElement ? resolveEffectiveZoomScale(rootElement) : fallback * builtInViewerZoomScale;
32594
32909
  },
32595
- [explicitPageVirtualizationZoomScale]
32910
+ [builtInViewerZoomScale, explicitPageVirtualizationZoomScale]
32596
32911
  );
32597
- React.useEffect(() => {
32912
+ React2.useEffect(() => {
32598
32913
  if (floatingMovePreview || objectWrapDragPreview || resizePreview || tableMoveDragRef.current) {
32599
32914
  return;
32600
32915
  }
@@ -32726,10 +33041,10 @@ function DocxEditorViewer({
32726
33041
  }
32727
33042
  setMeasuredWrapBands(next);
32728
33043
  });
32729
- React.useEffect(() => {
33044
+ React2.useEffect(() => {
32730
33045
  setDeferInternalPageVirtualization(!hasLargeTableLayoutSurface);
32731
33046
  }, [editor.documentLoadNonce, hasLargeTableLayoutSurface]);
32732
- React.useEffect(() => {
33047
+ React2.useEffect(() => {
32733
33048
  if (typeof window === "undefined" || webdriverActive || pageCount <= 1) {
32734
33049
  setDeferInternalPageVirtualization(true);
32735
33050
  return;
@@ -32751,12 +33066,12 @@ function DocxEditorViewer({
32751
33066
  pageVirtualizationSettleDelayMs,
32752
33067
  webdriverActive
32753
33068
  ]);
32754
- React.useLayoutEffect(() => {
33069
+ React2.useLayoutEffect(() => {
32755
33070
  if (typeof window === "undefined") {
32756
33071
  return;
32757
33072
  }
32758
33073
  setInternalVirtualScrollElement(
32759
- explicitPageVirtualizationScrollElement instanceof HTMLElement ? explicitPageVirtualizationScrollElement : nearestScrollableAncestor(viewerRootRef.current)
33074
+ explicitPageVirtualizationScrollElement instanceof HTMLElement ? explicitPageVirtualizationScrollElement : nearestScrollableAncestor2(viewerRootRef.current)
32760
33075
  );
32761
33076
  }, [
32762
33077
  editor.documentLoadNonce,
@@ -32764,8 +33079,8 @@ function DocxEditorViewer({
32764
33079
  pageCount,
32765
33080
  trackedChangesEnabled
32766
33081
  ]);
32767
- const [zoomProbeNonce, setZoomProbeNonce] = React.useState(0);
32768
- React.useEffect(() => {
33082
+ const [zoomProbeNonce, setZoomProbeNonce] = React2.useState(0);
33083
+ React2.useEffect(() => {
32769
33084
  if (typeof window === "undefined") {
32770
33085
  return;
32771
33086
  }
@@ -32784,7 +33099,7 @@ function DocxEditorViewer({
32784
33099
  window.removeEventListener("resize", bumpZoomProbe);
32785
33100
  };
32786
33101
  }, [editor.documentLoadNonce]);
32787
- React.useLayoutEffect(() => {
33102
+ React2.useLayoutEffect(() => {
32788
33103
  if (typeof window === "undefined") {
32789
33104
  return;
32790
33105
  }
@@ -32813,7 +33128,7 @@ function DocxEditorViewer({
32813
33128
  const internalVirtualScrollUsesWindow = typeof document !== "undefined" && internalVirtualScrollElement !== null && (internalVirtualScrollElement === document.scrollingElement || internalVirtualScrollElement === document.documentElement || internalVirtualScrollElement === document.body);
32814
33129
  const internalElementPageVirtualizationEnabled = internalPageVirtualizationEnabled && !internalVirtualScrollUsesWindow;
32815
33130
  const internalWindowPageVirtualizationEnabled = internalPageVirtualizationEnabled && internalVirtualScrollUsesWindow;
32816
- const estimateVirtualPageSize = React.useCallback(
33131
+ const estimateVirtualPageSize = React2.useCallback(
32817
33132
  (pageIndex) => {
32818
33133
  const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
32819
33134
  return Math.max(
@@ -32825,7 +33140,7 @@ function DocxEditorViewer({
32825
33140
  },
32826
33141
  [documentLayout, pageSectionInfoByIndex, virtualizerMeasurementScale]
32827
33142
  );
32828
- const suspendPaginationMeasurementForScroll = React.useCallback(() => {
33143
+ const suspendPaginationMeasurementForScroll = React2.useCallback(() => {
32829
33144
  paginationMeasurementSuspendUntilRef.current = Date.now() + PAGE_SCROLL_MEASUREMENT_SUSPEND_MS;
32830
33145
  }, []);
32831
33146
  const internalElementPageVirtualizer = (0, import_react_virtual.useVirtualizer)({
@@ -32846,7 +33161,7 @@ function DocxEditorViewer({
32846
33161
  (layout.pageHeightPx + DOC_PAGE_BREAK_GAP) * virtualizerMeasurementScale
32847
33162
  )
32848
33163
  ).join("|");
32849
- React.useLayoutEffect(() => {
33164
+ React2.useLayoutEffect(() => {
32850
33165
  internalElementPageVirtualizer.measure();
32851
33166
  internalWindowPageVirtualizer.measure();
32852
33167
  }, [
@@ -32857,7 +33172,7 @@ function DocxEditorViewer({
32857
33172
  internalWindowPageVirtualizer
32858
33173
  ]);
32859
33174
  const internalVirtualItems = internalPageVirtualizer.getVirtualItems();
32860
- const internalMostVisiblePageIndex = React.useMemo(() => {
33175
+ const internalMostVisiblePageIndex = React2.useMemo(() => {
32861
33176
  if (!internalPageVirtualizationEnabled || internalVirtualItems.length === 0) {
32862
33177
  return void 0;
32863
33178
  }
@@ -32881,7 +33196,7 @@ function DocxEditorViewer({
32881
33196
  internalVirtualItems,
32882
33197
  pageCount
32883
33198
  ]);
32884
- const internalVisiblePageRange = React.useMemo(() => {
33199
+ const internalVisiblePageRange = React2.useMemo(() => {
32885
33200
  if (!internalPageVirtualizationEnabled) {
32886
33201
  return void 0;
32887
33202
  }
@@ -32914,7 +33229,7 @@ function DocxEditorViewer({
32914
33229
  endPageIndex
32915
33230
  };
32916
33231
  }, [internalPageVirtualizationEnabled, internalVirtualItems, pageCount]);
32917
- const internalRenderVisiblePageRange = React.useMemo(() => {
33232
+ const internalRenderVisiblePageRange = React2.useMemo(() => {
32918
33233
  if (!internalVisiblePageRange) {
32919
33234
  return void 0;
32920
33235
  }
@@ -32946,7 +33261,7 @@ function DocxEditorViewer({
32946
33261
  pageVirtualization?.overscan
32947
33262
  ]);
32948
33263
  const shouldObserveVisiblePageRange = hasLargeTableLayoutSurface || internalVirtualItems.length === 0;
32949
- React.useLayoutEffect(() => {
33264
+ React2.useLayoutEffect(() => {
32950
33265
  if (!internalPageVirtualizationEnabled || !internalVirtualScrollElement || !shouldObserveVisiblePageRange || typeof window === "undefined") {
32951
33266
  setObservedVisiblePageRange(
32952
33267
  (current) => current === void 0 ? current : void 0
@@ -32962,14 +33277,14 @@ function DocxEditorViewer({
32962
33277
  }
32963
33278
  let frameId = null;
32964
33279
  const commitObservedVisiblePageRange = (updater) => {
32965
- React.startTransition(() => {
33280
+ React2.startTransition(() => {
32966
33281
  setObservedVisiblePageRange(updater);
32967
33282
  });
32968
33283
  };
32969
33284
  const syncVisiblePageRange = () => {
32970
33285
  frameId = null;
32971
33286
  suspendPaginationMeasurementForScroll();
32972
- const viewportRect = internalVirtualScrollUsesWindow ? {
33287
+ const viewportRect2 = internalVirtualScrollUsesWindow ? {
32973
33288
  top: 0,
32974
33289
  bottom: window.innerHeight
32975
33290
  } : internalVirtualScrollElement.getBoundingClientRect();
@@ -32985,10 +33300,10 @@ function DocxEditorViewer({
32985
33300
  continue;
32986
33301
  }
32987
33302
  const pageRect = pageWrapper.getBoundingClientRect();
32988
- if (pageRect.bottom <= viewportRect.top) {
33303
+ if (pageRect.bottom <= viewportRect2.top) {
32989
33304
  continue;
32990
33305
  }
32991
- if (pageRect.top >= viewportRect.bottom) {
33306
+ if (pageRect.top >= viewportRect2.bottom) {
32992
33307
  if (firstVisiblePageIndex !== void 0) {
32993
33308
  break;
32994
33309
  }
@@ -33078,7 +33393,7 @@ function DocxEditorViewer({
33078
33393
  shouldObserveVisiblePageRange,
33079
33394
  suspendPaginationMeasurementForScroll
33080
33395
  ]);
33081
- React.useEffect(() => {
33396
+ React2.useEffect(() => {
33082
33397
  if (!internalPageVirtualizationEnabled || !internalVirtualScrollElement || typeof window === "undefined") {
33083
33398
  return;
33084
33399
  }
@@ -33096,7 +33411,7 @@ function DocxEditorViewer({
33096
33411
  internalVirtualScrollUsesWindow,
33097
33412
  suspendPaginationMeasurementForScroll
33098
33413
  ]);
33099
- const internalEffectiveRenderVisiblePageRange = React.useMemo(() => {
33414
+ const internalEffectiveRenderVisiblePageRange = React2.useMemo(() => {
33100
33415
  if (!internalRenderVisiblePageRange) {
33101
33416
  return observedVisiblePageRange;
33102
33417
  }
@@ -33129,7 +33444,7 @@ function DocxEditorViewer({
33129
33444
  Math.max(0, pageVirtualizationOverscan)
33130
33445
  )
33131
33446
  } : void 0);
33132
- const normalizedVisiblePageRange = React.useMemo(() => {
33447
+ const normalizedVisiblePageRange = React2.useMemo(() => {
33133
33448
  if (pageCount <= 0) {
33134
33449
  return {
33135
33450
  startPageIndex: 0,
@@ -33161,7 +33476,7 @@ function DocxEditorViewer({
33161
33476
  const measureAllPagesBeforeInitialReveal = hideDocumentUntilPaginationSettled && pageCount > 0 && initialPremeasureStartPageIndex === 0 && initialPremeasureEndPageIndex >= pageCount - 1;
33162
33477
  const visiblePageStartIndex = hasRequestedPageIndexes ? requestedPageIndexes[0] ?? 0 : measureAllPagesBeforeInitialReveal ? 0 : hideDocumentUntilPaginationSettled ? initialPremeasureStartPageIndex : normalizedVisiblePageRange.startPageIndex;
33163
33478
  const visiblePageEndIndex = hasRequestedPageIndexes ? requestedPageIndexes[requestedPageIndexes.length - 1] ?? -1 : measureAllPagesBeforeInitialReveal ? pageCount - 1 : hideDocumentUntilPaginationSettled ? initialPremeasureEndPageIndex : normalizedVisiblePageRange.endPageIndex;
33164
- const visiblePageIndexes = React.useMemo(() => {
33479
+ const visiblePageIndexes = React2.useMemo(() => {
33165
33480
  if (hasRequestedPageIndexes) {
33166
33481
  return requestedPageIndexes;
33167
33482
  }
@@ -33180,7 +33495,7 @@ function DocxEditorViewer({
33180
33495
  visiblePageEndIndex,
33181
33496
  visiblePageStartIndex
33182
33497
  ]);
33183
- const pageStackVirtualSpacers = React.useMemo(() => {
33498
+ const pageStackVirtualSpacers = React2.useMemo(() => {
33184
33499
  const pageWrapperWidthPxForIndex = (pageIndex) => {
33185
33500
  const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
33186
33501
  return showTrackedChangeGutter ? pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX : pageLayout.pageWidthPx;
@@ -33214,7 +33529,7 @@ function DocxEditorViewer({
33214
33529
  visiblePageEndIndex,
33215
33530
  visiblePageStartIndex
33216
33531
  ]);
33217
- React.useLayoutEffect(() => {
33532
+ React2.useLayoutEffect(() => {
33218
33533
  if (typeof window === "undefined") {
33219
33534
  return;
33220
33535
  }
@@ -33264,7 +33579,7 @@ function DocxEditorViewer({
33264
33579
  visiblePageEndIndex,
33265
33580
  visiblePageStartIndex
33266
33581
  ]);
33267
- const visibleTableRowIndexesByNodeIndex = React.useMemo(() => {
33582
+ const visibleTableRowIndexesByNodeIndex = React2.useMemo(() => {
33268
33583
  const rowsByNodeIndex = /* @__PURE__ */ new Map();
33269
33584
  const addRowIndex = (nodeIndex, rowIndex) => {
33270
33585
  const tableNode = editor.model.nodes[nodeIndex];
@@ -33302,7 +33617,7 @@ function DocxEditorViewer({
33302
33617
  return rowsByNodeIndex;
33303
33618
  }, [editor.model.nodes, pageNodeSegmentsByPage, visiblePageIndexes]);
33304
33619
  const paginationMeasurementEnabled = hideDocumentUntilPaginationSettled || postImportPaginationUnlocked;
33305
- const visiblePagesHavePendingPaginationMeasurements = React.useMemo(() => {
33620
+ const visiblePagesHavePendingPaginationMeasurements = React2.useMemo(() => {
33306
33621
  if (pageCount === 0) {
33307
33622
  return false;
33308
33623
  }
@@ -33340,13 +33655,13 @@ function DocxEditorViewer({
33340
33655
  ]);
33341
33656
  const allowPostImportPaginationMeasurement = !hasLargeTableLayoutSurface || !internalPageVirtualizationEnabled;
33342
33657
  const visiblePagesNeedMeasurementUnlock = !hideDocumentUntilPaginationSettled && allowPostImportPaginationMeasurement && visiblePagesHavePendingPaginationMeasurements;
33343
- React.useEffect(() => {
33658
+ React2.useEffect(() => {
33344
33659
  if (!visiblePagesNeedMeasurementUnlock) {
33345
33660
  return;
33346
33661
  }
33347
33662
  setPostImportPaginationUnlocked(true);
33348
33663
  }, [visiblePagesNeedMeasurementUnlock]);
33349
- React.useEffect(() => {
33664
+ React2.useEffect(() => {
33350
33665
  if (hideDocumentUntilPaginationSettled || !postImportPaginationUnlocked || visiblePagesNeedMeasurementUnlock) {
33351
33666
  return;
33352
33667
  }
@@ -33372,13 +33687,13 @@ function DocxEditorViewer({
33372
33687
  postImportPaginationUnlocked,
33373
33688
  visiblePagesNeedMeasurementUnlock
33374
33689
  ]);
33375
- React.useEffect(() => {
33690
+ React2.useEffect(() => {
33376
33691
  if (!onPageCountChange) {
33377
33692
  return;
33378
33693
  }
33379
33694
  onPageCountChange(stableReportedPageCount);
33380
33695
  }, [onPageCountChange, stableReportedPageCount]);
33381
- React.useEffect(() => {
33696
+ React2.useEffect(() => {
33382
33697
  const nextCurrentPage = clampNumber(
33383
33698
  (internalMostVisiblePageIndex ?? visiblePageStartIndex) + 1,
33384
33699
  1,
@@ -33394,7 +33709,7 @@ function DocxEditorViewer({
33394
33709
  stableReportedPageCount,
33395
33710
  visiblePageStartIndex
33396
33711
  ]);
33397
- const trackedChangesByPage = React.useMemo(() => {
33712
+ const trackedChangesByPage = React2.useMemo(() => {
33398
33713
  const pageBuckets = pageNodeSegmentsByPage.map(
33399
33714
  () => []
33400
33715
  );
@@ -33450,13 +33765,13 @@ function DocxEditorViewer({
33450
33765
  pageNodeSegmentsByPage,
33451
33766
  trackedChangesEnabled
33452
33767
  ]);
33453
- const [trackedChangeAnchorByPage, setTrackedChangeAnchorByPage] = React.useState([]);
33454
- const [headerBodyClearanceByPage, setHeaderBodyClearanceByPage] = React.useState({});
33455
- React.useEffect(() => {
33768
+ const [trackedChangeAnchorByPage, setTrackedChangeAnchorByPage] = React2.useState([]);
33769
+ const [headerBodyClearanceByPage, setHeaderBodyClearanceByPage] = React2.useState({});
33770
+ React2.useEffect(() => {
33456
33771
  setHeaderBodyClearanceByPage({});
33457
33772
  }, [editor.documentLoadNonce]);
33458
- const [trackedChangeCardHeightsByPage, setTrackedChangeCardHeightsByPage] = React.useState([]);
33459
- React.useLayoutEffect(() => {
33773
+ const [trackedChangeCardHeightsByPage, setTrackedChangeCardHeightsByPage] = React2.useState([]);
33774
+ React2.useLayoutEffect(() => {
33460
33775
  if (!showTrackedChangeGutter || trackedChangesByPage.length === 0) {
33461
33776
  setTrackedChangeAnchorByPage(
33462
33777
  (current) => current.length === 0 ? current : []
@@ -33509,7 +33824,7 @@ function DocxEditorViewer({
33509
33824
  visiblePageEndIndex,
33510
33825
  visiblePageStartIndex
33511
33826
  ]);
33512
- React.useLayoutEffect(() => {
33827
+ React2.useLayoutEffect(() => {
33513
33828
  if (!showTrackedChangeGutter || trackedChangesByPage.length === 0) {
33514
33829
  setTrackedChangeCardHeightsByPage(
33515
33830
  (current) => current.length === 0 ? current : []
@@ -33572,7 +33887,7 @@ function DocxEditorViewer({
33572
33887
  visiblePageEndIndex,
33573
33888
  visiblePageStartIndex
33574
33889
  ]);
33575
- const positionedTrackedChangesByPage = React.useMemo(() => {
33890
+ const positionedTrackedChangesByPage = React2.useMemo(() => {
33576
33891
  return trackedChangesByPage.map((changes, pageIndex) => {
33577
33892
  const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
33578
33893
  const anchorsByChangeId = trackedChangeAnchorByPage[pageIndex] ?? /* @__PURE__ */ new Map();
@@ -33592,7 +33907,7 @@ function DocxEditorViewer({
33592
33907
  trackedChangeCardHeightsByPage,
33593
33908
  trackedChangesByPage
33594
33909
  ]);
33595
- const totalPagesForFieldResolution = React.useMemo(() => {
33910
+ const totalPagesForFieldResolution = React2.useMemo(() => {
33596
33911
  if (editor.canUndo || editor.canRedo) {
33597
33912
  return pageCount;
33598
33913
  }
@@ -33607,7 +33922,7 @@ function DocxEditorViewer({
33607
33922
  editor.model.metadata.documentPageCount,
33608
33923
  pageCount
33609
33924
  ]);
33610
- const isPageVisible = React.useCallback(
33925
+ const isPageVisible = React2.useCallback(
33611
33926
  (pageIndex) => {
33612
33927
  return hasRequestedPageIndexes ? requestedPageIndexes.includes(pageIndex) : pageIndex >= visiblePageStartIndex && pageIndex <= visiblePageEndIndex;
33613
33928
  },
@@ -33618,7 +33933,7 @@ function DocxEditorViewer({
33618
33933
  visiblePageStartIndex
33619
33934
  ]
33620
33935
  );
33621
- const requestPageReveal = React.useCallback(
33936
+ const requestPageReveal = React2.useCallback(
33622
33937
  (targetPageIndex) => {
33623
33938
  if (onRequestPageReveal) {
33624
33939
  onRequestPageReveal(targetPageIndex);
@@ -33644,7 +33959,7 @@ function DocxEditorViewer({
33644
33959
  pageCount
33645
33960
  ]
33646
33961
  );
33647
- const scrollToBookmark = React.useCallback(
33962
+ const scrollToBookmark = React2.useCallback(
33648
33963
  (bookmarkName) => {
33649
33964
  const normalized = bookmarkName.trim();
33650
33965
  if (!normalized) {
@@ -33708,7 +34023,7 @@ function DocxEditorViewer({
33708
34023
  visiblePageStartIndex
33709
34024
  ]
33710
34025
  );
33711
- const pageHeaderAndFooterNodes = React.useMemo(
34026
+ const pageHeaderAndFooterNodes = React2.useMemo(
33712
34027
  () => pageNodeSegmentsByPage.map((_, pageIndex) => {
33713
34028
  const sectionInfo = pageSectionInfoByIndex[pageIndex];
33714
34029
  const sectionHeaderSections = sectionInfo?.section.headerSections ?? editor.model.metadata.headerSections;
@@ -33751,7 +34066,7 @@ function DocxEditorViewer({
33751
34066
  editor.model.metadata.sectionPropertiesXml
33752
34067
  ]
33753
34068
  );
33754
- const headerBodyClearanceFloorByPage = React.useMemo(() => {
34069
+ const headerBodyClearanceFloorByPage = React2.useMemo(() => {
33755
34070
  const next = {};
33756
34071
  for (let pageIndex = 0; pageIndex < pageNodeSegmentsByPage.length; pageIndex += 1) {
33757
34072
  const headerNodes = pageHeaderAndFooterNodes[pageIndex]?.headerNodes ?? [];
@@ -33781,7 +34096,7 @@ function DocxEditorViewer({
33781
34096
  pageNodeSegmentsByPage.length,
33782
34097
  pageSectionInfoByIndex
33783
34098
  ]);
33784
- React.useLayoutEffect(() => {
34099
+ React2.useLayoutEffect(() => {
33785
34100
  if (!paginationMeasurementEnabled) {
33786
34101
  return;
33787
34102
  }
@@ -33883,7 +34198,7 @@ function DocxEditorViewer({
33883
34198
  visiblePageEndIndex,
33884
34199
  visiblePageStartIndex
33885
34200
  ]);
33886
- React.useEffect(() => {
34201
+ React2.useEffect(() => {
33887
34202
  if (disableMeasuredImportPagination) {
33888
34203
  setMeasuredPageContentHeightByIndex(
33889
34204
  (current) => current.length === 0 ? current : []
@@ -34172,7 +34487,7 @@ function DocxEditorViewer({
34172
34487
  visiblePageEndIndex,
34173
34488
  visiblePageStartIndex
34174
34489
  ]);
34175
- React.useEffect(() => {
34490
+ React2.useEffect(() => {
34176
34491
  if (!deferInitialPaginationPaint || isInitialPaginationSettled || disableMeasuredImportPagination) {
34177
34492
  return;
34178
34493
  }
@@ -34200,7 +34515,7 @@ function DocxEditorViewer({
34200
34515
  isInitialPaginationSettled,
34201
34516
  pageCount
34202
34517
  ]);
34203
- React.useEffect(() => {
34518
+ React2.useEffect(() => {
34204
34519
  if (!deferInitialPaginationPaint || !isInitialPaginationSettled || initialPaginationBackgroundRefinementUnlocked) {
34205
34520
  return;
34206
34521
  }
@@ -34209,7 +34524,7 @@ function DocxEditorViewer({
34209
34524
  return;
34210
34525
  }
34211
34526
  const timeoutId = window.setTimeout(() => {
34212
- React.startTransition(() => {
34527
+ React2.startTransition(() => {
34213
34528
  setInitialPaginationBackgroundRefinementUnlocked(true);
34214
34529
  });
34215
34530
  }, INITIAL_PAGINATION_BACKGROUND_REFINEMENT_DELAY_MS);
@@ -34221,7 +34536,7 @@ function DocxEditorViewer({
34221
34536
  initialPaginationBackgroundRefinementUnlocked,
34222
34537
  isInitialPaginationSettled
34223
34538
  ]);
34224
- React.useEffect(() => {
34539
+ React2.useEffect(() => {
34225
34540
  if (!deferInitialPaginationPaint || isInitialPaginationSettled) {
34226
34541
  return;
34227
34542
  }
@@ -34337,7 +34652,7 @@ function DocxEditorViewer({
34337
34652
  visiblePageEndIndex,
34338
34653
  visiblePageStartIndex
34339
34654
  ]);
34340
- const setSingleTableCellSelection = React.useCallback(
34655
+ const setSingleTableCellSelection = React2.useCallback(
34341
34656
  (tableIndex, rowIndex, cellIndex) => {
34342
34657
  const nextRange = {
34343
34658
  tableIndex,
@@ -34355,10 +34670,10 @@ function DocxEditorViewer({
34355
34670
  },
34356
34671
  []
34357
34672
  );
34358
- const clearTableCellSelection = React.useCallback(() => {
34673
+ const clearTableCellSelection = React2.useCallback(() => {
34359
34674
  setTableCellSelectionRange((current) => current ? void 0 : current);
34360
34675
  }, []);
34361
- const isPointWithinTableHandleHoverZone = React.useCallback(
34676
+ const isPointWithinTableHandleHoverZone = React2.useCallback(
34362
34677
  (tableIndex, x, y) => {
34363
34678
  const tableElement = tableElementsRef.current.get(tableIndex);
34364
34679
  if (!tableElement || !tableElement.isConnected) {
@@ -34372,7 +34687,7 @@ function DocxEditorViewer({
34372
34687
  },
34373
34688
  []
34374
34689
  );
34375
- const resolveHoveredTableHandleIndexFromPoint = React.useCallback(
34690
+ const resolveHoveredTableHandleIndexFromPoint = React2.useCallback(
34376
34691
  (x, y) => {
34377
34692
  let nextHoveredTableIndex;
34378
34693
  let bestDistance = Number.POSITIVE_INFINITY;
@@ -34399,7 +34714,7 @@ function DocxEditorViewer({
34399
34714
  },
34400
34715
  []
34401
34716
  );
34402
- const onViewerPointerMove = React.useCallback(
34717
+ const onViewerPointerMove = React2.useCallback(
34403
34718
  (event) => {
34404
34719
  if (isReadOnly) {
34405
34720
  return;
@@ -34417,7 +34732,7 @@ function DocxEditorViewer({
34417
34732
  },
34418
34733
  [isReadOnly, resolveHoveredTableHandleIndexFromPoint]
34419
34734
  );
34420
- const onViewerPointerLeave = React.useCallback(() => {
34735
+ const onViewerPointerLeave = React2.useCallback(() => {
34421
34736
  if (isReadOnly) {
34422
34737
  return;
34423
34738
  }
@@ -34426,7 +34741,7 @@ function DocxEditorViewer({
34426
34741
  }
34427
34742
  setHoveredTableHandleTableIndex(void 0);
34428
34743
  }, [isReadOnly]);
34429
- const selectWholeTable = React.useCallback(
34744
+ const selectWholeTable = React2.useCallback(
34430
34745
  (tableIndex) => {
34431
34746
  const tableNode = editor.model.nodes[tableIndex];
34432
34747
  if (!tableNode || tableNode.type !== "table") {
@@ -34452,7 +34767,7 @@ function DocxEditorViewer({
34452
34767
  },
34453
34768
  [editor]
34454
34769
  );
34455
- const resolveTableMoveDropTarget = React.useCallback(
34770
+ const resolveTableMoveDropTarget = React2.useCallback(
34456
34771
  (tableIndex, point) => {
34457
34772
  const rootElement = viewerRootRef.current;
34458
34773
  if (!rootElement) {
@@ -34513,9 +34828,9 @@ function DocxEditorViewer({
34513
34828
  },
34514
34829
  [editor.model.nodes.length]
34515
34830
  );
34516
- const objectWrapDragSignatureRef = React.useRef("");
34517
- const objectWrapDragLatestRef = React.useRef(void 0);
34518
- const updateObjectWrapDragPreview = React.useCallback(
34831
+ const objectWrapDragSignatureRef = React2.useRef("");
34832
+ const objectWrapDragLatestRef = React2.useRef(void 0);
34833
+ const updateObjectWrapDragPreview = React2.useCallback(
34519
34834
  (frame, source, distances) => {
34520
34835
  const bandsByPage = /* @__PURE__ */ new Map();
34521
34836
  let pageIndex = -1;
@@ -34604,7 +34919,7 @@ function DocxEditorViewer({
34604
34919
  },
34605
34920
  [resolveViewerMeasurementZoomScale]
34606
34921
  );
34607
- const clearObjectDragPreview = React.useCallback(
34922
+ const clearObjectDragPreview = React2.useCallback(
34608
34923
  (preserveMeasurements = false) => {
34609
34924
  if (preserveMeasurements && objectWrapDragLatestRef.current) {
34610
34925
  const next = new Map(measuredWrapBands);
@@ -34624,7 +34939,7 @@ function DocxEditorViewer({
34624
34939
  },
34625
34940
  [measuredWrapBands]
34626
34941
  );
34627
- const beginTableMoveDrag = React.useCallback(
34942
+ const beginTableMoveDrag = React2.useCallback(
34628
34943
  (event, tableIndex) => {
34629
34944
  if (isReadOnly || event.button !== 0) return;
34630
34945
  const element = tableElementsRef.current.get(tableIndex);
@@ -34642,12 +34957,12 @@ function DocxEditorViewer({
34642
34957
  startY: event.clientY,
34643
34958
  hasMoved: false
34644
34959
  };
34645
- const zoom = resolveViewerMeasurementZoomScale(element, 1);
34960
+ const zoom2 = resolveViewerMeasurementZoomScale(element, 1);
34646
34961
  const floating = table.style?.floating;
34647
34962
  objectDragCleanupRef.current = startObjectDrag({
34648
34963
  event,
34649
34964
  element,
34650
- zoom,
34965
+ zoom: zoom2,
34651
34966
  resolveElement: () => tableElementsRef.current.get(tableIndex),
34652
34967
  onFrame: (frame) => {
34653
34968
  if (tableMoveDragRef.current)
@@ -34682,7 +34997,7 @@ function DocxEditorViewer({
34682
34997
  const anchorLayout = anchorParagraph?.type === "paragraph" && anchorSource && anchorRect ? layoutParagraphPretextSource(
34683
34998
  anchorParagraph,
34684
34999
  anchorSource,
34685
- anchorRect.width / zoom,
35000
+ anchorRect.width / zoom2,
34686
35001
  Number(anchor?.host.dataset.docxParagraphLineHeight) || estimateParagraphLineHeightPx(anchorParagraph),
34687
35002
  []
34688
35003
  ) : void 0;
@@ -34693,9 +35008,9 @@ function DocxEditorViewer({
34693
35008
  tableIndex,
34694
35009
  {
34695
35010
  xTwips: pixelsToTwips(
34696
- (frame.left - (bodyRect?.left ?? anchorRect.left)) / zoom
35011
+ (frame.left - (bodyRect?.left ?? anchorRect.left)) / zoom2
34697
35012
  ),
34698
- yTwips: pixelsToTwips((frame.top - anchorRect.top) / zoom),
35013
+ yTwips: pixelsToTwips((frame.top - anchorRect.top) / zoom2),
34699
35014
  horizontalAnchor: "margin",
34700
35015
  verticalAnchor: "text",
34701
35016
  horizontalAlign: void 0,
@@ -34719,13 +35034,13 @@ function DocxEditorViewer({
34719
35034
  clearObjectDragPreview
34720
35035
  ]
34721
35036
  );
34722
- const closeTableContextMenu = React.useCallback(() => {
35037
+ const closeTableContextMenu = React2.useCallback(() => {
34723
35038
  setTableContextMenuState(void 0);
34724
35039
  }, []);
34725
- const closeContextMenu = React.useCallback(() => {
35040
+ const closeContextMenu = React2.useCallback(() => {
34726
35041
  setContextMenuState(void 0);
34727
35042
  }, []);
34728
- const openContextMenu = React.useCallback(
35043
+ const openContextMenu = React2.useCallback(
34729
35044
  (context, point) => {
34730
35045
  setTableContextMenuState(void 0);
34731
35046
  setContextMenuState({
@@ -34736,7 +35051,7 @@ function DocxEditorViewer({
34736
35051
  },
34737
35052
  []
34738
35053
  );
34739
- const openTableContextMenu = React.useCallback(
35054
+ const openTableContextMenu = React2.useCallback(
34740
35055
  (context, point) => {
34741
35056
  setContextMenuState(void 0);
34742
35057
  setTableContextMenuState({
@@ -34747,7 +35062,7 @@ function DocxEditorViewer({
34747
35062
  },
34748
35063
  []
34749
35064
  );
34750
- const runTableContextMenuAction = React.useCallback(
35065
+ const runTableContextMenuAction = React2.useCallback(
34751
35066
  (actionId, providedContext) => {
34752
35067
  const context = providedContext ?? tableContextMenuState;
34753
35068
  if (!context) {
@@ -34796,11 +35111,11 @@ function DocxEditorViewer({
34796
35111
  },
34797
35112
  [closeTableContextMenu, editor, tableContextMenuState]
34798
35113
  );
34799
- const tableContextMenuActions = React.useMemo(
35114
+ const tableContextMenuActions = React2.useMemo(
34800
35115
  () => [...DEFAULT_TABLE_CONTEXT_MENU_ACTIONS],
34801
35116
  []
34802
35117
  );
34803
- const resolveTableContextMenuLocation = React.useCallback(
35118
+ const resolveTableContextMenuLocation = React2.useCallback(
34804
35119
  (tableIndex, fallbackRowIndex = 0, fallbackCellIndex = 0) => {
34805
35120
  const tableNode = editor.model.nodes[tableIndex];
34806
35121
  if (!tableNode || tableNode.type !== "table") {
@@ -34830,7 +35145,7 @@ function DocxEditorViewer({
34830
35145
  },
34831
35146
  [editor.model.nodes, editor.selection]
34832
35147
  );
34833
- React.useEffect(() => {
35148
+ React2.useEffect(() => {
34834
35149
  if (!tableContextMenuState && !contextMenuState) {
34835
35150
  return;
34836
35151
  }
@@ -34859,7 +35174,7 @@ function DocxEditorViewer({
34859
35174
  window.removeEventListener("keydown", onKeyDown, true);
34860
35175
  };
34861
35176
  }, [contextMenuState, tableContextMenuState]);
34862
- React.useEffect(() => {
35177
+ React2.useEffect(() => {
34863
35178
  if (!tableCellSelectionRange) {
34864
35179
  return;
34865
35180
  }
@@ -34868,7 +35183,7 @@ function DocxEditorViewer({
34868
35183
  setTableCellSelectionRange(void 0);
34869
35184
  }
34870
35185
  }, [editor.model.nodes, tableCellSelectionRange]);
34871
- React.useEffect(() => {
35186
+ React2.useEffect(() => {
34872
35187
  if (!tableContextMenuState) {
34873
35188
  return;
34874
35189
  }
@@ -34877,7 +35192,7 @@ function DocxEditorViewer({
34877
35192
  setTableContextMenuState(void 0);
34878
35193
  }
34879
35194
  }, [editor.model.nodes, tableContextMenuState]);
34880
- React.useEffect(() => {
35195
+ React2.useEffect(() => {
34881
35196
  if (!contextMenuState || contextMenuState.kind !== "image") {
34882
35197
  return;
34883
35198
  }
@@ -34895,7 +35210,7 @@ function DocxEditorViewer({
34895
35210
  setContextMenuState(void 0);
34896
35211
  }
34897
35212
  }, [contextMenuState, editor.model]);
34898
- const placeCaretInsideElement = React.useCallback(
35213
+ const placeCaretInsideElement = React2.useCallback(
34899
35214
  (element, point) => {
34900
35215
  const selection = window.getSelection();
34901
35216
  if (!selection) {
@@ -35072,7 +35387,7 @@ function DocxEditorViewer({
35072
35387
  },
35073
35388
  []
35074
35389
  );
35075
- React.useEffect(() => {
35390
+ React2.useEffect(() => {
35076
35391
  const pendingFocus = pendingSectionParagraphFocusRef.current;
35077
35392
  if (!pendingFocus) {
35078
35393
  return;
@@ -35093,7 +35408,7 @@ function DocxEditorViewer({
35093
35408
  pendingSectionParagraphFocusRef.current = void 0;
35094
35409
  });
35095
35410
  }, [activeHeaderFooterEdit, placeCaretInsideElement]);
35096
- const setSelectionWithinElementByTextOffsets = React.useCallback(
35411
+ const setSelectionWithinElementByTextOffsets = React2.useCallback(
35097
35412
  (element, startOffset, endOffset) => {
35098
35413
  const selection = window.getSelection();
35099
35414
  if (!selection) {
@@ -35148,7 +35463,7 @@ function DocxEditorViewer({
35148
35463
  },
35149
35464
  [placeCaretInsideElement]
35150
35465
  );
35151
- const paragraphTextLengthFromElement = React.useCallback(
35466
+ const paragraphTextLengthFromElement = React2.useCallback(
35152
35467
  (element) => {
35153
35468
  const range = document.createRange();
35154
35469
  range.selectNodeContents(element);
@@ -35156,7 +35471,7 @@ function DocxEditorViewer({
35156
35471
  },
35157
35472
  []
35158
35473
  );
35159
- const activateEditableParagraphSegment = React.useCallback(
35474
+ const activateEditableParagraphSegment = React2.useCallback(
35160
35475
  (nodeIndex, paragraphLineRange, point) => {
35161
35476
  if (!paragraphSegmentHasPartialLineRange(paragraphLineRange)) {
35162
35477
  pendingParagraphSegmentFocusRef.current = void 0;
@@ -35181,7 +35496,7 @@ function DocxEditorViewer({
35181
35496
  },
35182
35497
  []
35183
35498
  );
35184
- const resolveParagraphHostElement = React.useCallback(
35499
+ const resolveParagraphHostElement = React2.useCallback(
35185
35500
  (location) => {
35186
35501
  if (location.kind === "paragraph") {
35187
35502
  const wrappedSurface = wrappedParagraphSurfaceRegistryRef.current.get(
@@ -35218,7 +35533,7 @@ function DocxEditorViewer({
35218
35533
  },
35219
35534
  [paragraphElementsRef]
35220
35535
  );
35221
- const resolveDomPositionFromTextOffset = React.useCallback(
35536
+ const resolveDomPositionFromTextOffset = React2.useCallback(
35222
35537
  (element, targetOffset) => {
35223
35538
  const safeOffset = Math.max(0, Math.round(targetOffset));
35224
35539
  const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
@@ -35248,7 +35563,7 @@ function DocxEditorViewer({
35248
35563
  },
35249
35564
  []
35250
35565
  );
35251
- const resolveParagraphHostElementForOffset = React.useCallback(
35566
+ const resolveParagraphHostElementForOffset = React2.useCallback(
35252
35567
  (paragraphIndex, offset) => {
35253
35568
  const rootElement = viewerRootRef.current;
35254
35569
  const trackedElement = paragraphElementsRef.current.get(paragraphIndex);
@@ -35286,7 +35601,7 @@ function DocxEditorViewer({
35286
35601
  },
35287
35602
  [resolveDomPositionFromTextOffset]
35288
35603
  );
35289
- const resolveDomPositionFromBoundary = React.useCallback(
35604
+ const resolveDomPositionFromBoundary = React2.useCallback(
35290
35605
  (boundary) => {
35291
35606
  const location = boundary.location;
35292
35607
  const hostElement = resolveParagraphHostElement(location);
@@ -35305,7 +35620,7 @@ function DocxEditorViewer({
35305
35620
  paragraphTextLengthFromElement
35306
35621
  ]
35307
35622
  );
35308
- const setSelectionFromDocxBoundaries = React.useCallback(
35623
+ const setSelectionFromDocxBoundaries = React2.useCallback(
35309
35624
  (rawStartBoundary, rawEndBoundary) => {
35310
35625
  const selection = window.getSelection();
35311
35626
  if (!selection) {
@@ -35401,7 +35716,7 @@ function DocxEditorViewer({
35401
35716
  placeCaretInsideElement
35402
35717
  ]
35403
35718
  );
35404
- const syncSelectionFromDocxRange = React.useCallback(
35719
+ const syncSelectionFromDocxRange = React2.useCallback(
35405
35720
  (range) => {
35406
35721
  const selectionIntentNonce = beginSelectionIntent();
35407
35722
  editor.beginSelectionSession("command", { settleAfterMs: 140 });
@@ -35491,7 +35806,7 @@ function DocxEditorViewer({
35491
35806
  setSelectionFromDocxBoundaries
35492
35807
  ]
35493
35808
  );
35494
- const resolveWrappedParagraphBoundaryFromPoint = React.useCallback(
35809
+ const resolveWrappedParagraphBoundaryFromPoint = React2.useCallback(
35495
35810
  (point) => {
35496
35811
  const elementAtPoint = document.elementFromPoint(point.x, point.y);
35497
35812
  if (!(elementAtPoint instanceof Element)) {
@@ -35530,7 +35845,7 @@ function DocxEditorViewer({
35530
35845
  },
35531
35846
  []
35532
35847
  );
35533
- const selectAllDocumentText = React.useCallback(() => {
35848
+ const selectAllDocumentText = React2.useCallback(() => {
35534
35849
  const rootElement = viewerRootRef.current;
35535
35850
  if (!rootElement) {
35536
35851
  return;
@@ -35565,7 +35880,7 @@ function DocxEditorViewer({
35565
35880
  paragraphTextLengthFromElement,
35566
35881
  setSelectionFromDocxBoundaries
35567
35882
  ]);
35568
- const resolveParagraphBoundaryFromSelectionPoint = React.useCallback(
35883
+ const resolveParagraphBoundaryFromSelectionPoint = React2.useCallback(
35569
35884
  (container, offset) => {
35570
35885
  if (!container) {
35571
35886
  return void 0;
@@ -35636,7 +35951,7 @@ function DocxEditorViewer({
35636
35951
  },
35637
35952
  []
35638
35953
  );
35639
- const resolveBoundaryFromPoint = React.useCallback(
35954
+ const resolveBoundaryFromPoint = React2.useCallback(
35640
35955
  (point, fallbackBias) => {
35641
35956
  const wrappedParagraphBoundary = resolveWrappedParagraphBoundaryFromPoint(point);
35642
35957
  if (wrappedParagraphBoundary) {
@@ -35845,7 +36160,7 @@ function DocxEditorViewer({
35845
36160
  resolveWrappedParagraphBoundaryFromPoint
35846
36161
  ]
35847
36162
  );
35848
- const resolveActiveRangeFromDomSelection = React.useCallback(() => {
36163
+ const resolveActiveRangeFromDomSelection = React2.useCallback(() => {
35849
36164
  const rootElement = viewerRootRef.current;
35850
36165
  const selection = window.getSelection();
35851
36166
  if (!rootElement || !selection || selection.rangeCount === 0) {
@@ -35871,7 +36186,7 @@ function DocxEditorViewer({
35871
36186
  end: endBoundary
35872
36187
  });
35873
36188
  }, [resolveParagraphBoundaryFromSelectionPoint]);
35874
- const setActiveRangeFromSelection = React.useCallback(() => {
36189
+ const setActiveRangeFromSelection = React2.useCallback(() => {
35875
36190
  const session = editor.selectionSessionKind;
35876
36191
  const rootElement = viewerRootRef.current;
35877
36192
  const activeElement = document.activeElement;
@@ -35928,7 +36243,7 @@ function DocxEditorViewer({
35928
36243
  resolveParagraphHostElement,
35929
36244
  setSelectionFromDocxBoundaries
35930
36245
  ]);
35931
- const flushActiveRangeFromSelection = React.useCallback(() => {
36246
+ const flushActiveRangeFromSelection = React2.useCallback(() => {
35932
36247
  if (deferredCollapsedSelectionSyncTimeoutRef.current !== null) {
35933
36248
  window.clearTimeout(deferredCollapsedSelectionSyncTimeoutRef.current);
35934
36249
  deferredCollapsedSelectionSyncTimeoutRef.current = null;
@@ -35941,7 +36256,7 @@ function DocxEditorViewer({
35941
36256
  setActiveRangeFromSelection();
35942
36257
  });
35943
36258
  }, [setActiveRangeFromSelection]);
35944
- React.useLayoutEffect(() => {
36259
+ React2.useLayoutEffect(() => {
35945
36260
  if (isReadOnly) {
35946
36261
  return;
35947
36262
  }
@@ -36025,7 +36340,7 @@ function DocxEditorViewer({
36025
36340
  }
36026
36341
  setSelectionFromDocxBoundaries(normalized.start, normalized.end);
36027
36342
  });
36028
- const selectionIsExpandedWithinElement = React.useCallback(
36343
+ const selectionIsExpandedWithinElement = React2.useCallback(
36029
36344
  (element) => {
36030
36345
  const selection = window.getSelection();
36031
36346
  if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
@@ -36036,7 +36351,7 @@ function DocxEditorViewer({
36036
36351
  },
36037
36352
  []
36038
36353
  );
36039
- const ensureCaretPlacementInsideElement = React.useCallback(
36354
+ const ensureCaretPlacementInsideElement = React2.useCallback(
36040
36355
  (element, point, selectionIntentNonce) => {
36041
36356
  const selection = window.getSelection();
36042
36357
  const selectedRange = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : void 0;
@@ -36089,7 +36404,7 @@ function DocxEditorViewer({
36089
36404
  scheduleSelectionIntentFrame
36090
36405
  ]
36091
36406
  );
36092
- const schedulePointerSelectionReconcile = React.useCallback(
36407
+ const schedulePointerSelectionReconcile = React2.useCallback(
36093
36408
  (element, point, syncSelection) => {
36094
36409
  const selectionIntentNonce = beginSelectionIntent();
36095
36410
  editor.beginSelectionSession("pointer", { settleAfterMs: 320 });
@@ -36156,11 +36471,11 @@ function DocxEditorViewer({
36156
36471
  scheduleSelectionIntentFrame
36157
36472
  ]
36158
36473
  );
36159
- const cancelPendingPointerSelectionReconcile = React.useCallback(() => {
36474
+ const cancelPendingPointerSelectionReconcile = React2.useCallback(() => {
36160
36475
  cancelPendingSelectionIntent();
36161
36476
  editor.clearSelectionSession("pointer");
36162
36477
  }, [cancelPendingSelectionIntent, editor]);
36163
- const clearObjectSelectionForParagraphEntry = React.useCallback(
36478
+ const clearObjectSelectionForParagraphEntry = React2.useCallback(
36164
36479
  (nodeIndex) => {
36165
36480
  clearTableCellSelection();
36166
36481
  setSelectedImage(void 0);
@@ -36174,7 +36489,7 @@ function DocxEditorViewer({
36174
36489
  },
36175
36490
  [clearTableCellSelection, editor]
36176
36491
  );
36177
- const syncWrappedParagraphRange = React.useCallback(
36492
+ const syncWrappedParagraphRange = React2.useCallback(
36178
36493
  (location, startOffset, endOffset, options) => {
36179
36494
  const paragraph = getParagraphAtLocation(
36180
36495
  editor.model,
@@ -36234,7 +36549,7 @@ function DocxEditorViewer({
36234
36549
  },
36235
36550
  [editor]
36236
36551
  );
36237
- const focusWrappedParagraphTextarea = React.useCallback(() => {
36552
+ const focusWrappedParagraphTextarea = React2.useCallback(() => {
36238
36553
  scheduleDomWrite(() => {
36239
36554
  const textarea = wrappedParagraphTextareaRef.current;
36240
36555
  if (!textarea || !textarea.isConnected) {
@@ -36268,7 +36583,7 @@ function DocxEditorViewer({
36268
36583
  }
36269
36584
  });
36270
36585
  }, [activeWrappedParagraphSession]);
36271
- const commitWrappedParagraphTextAtLocation = React.useCallback(
36586
+ const commitWrappedParagraphTextAtLocation = React2.useCallback(
36272
36587
  (location, text) => {
36273
36588
  editor.suppressNextDomSelectionRestore();
36274
36589
  if (location.kind === "paragraph") {
@@ -36285,7 +36600,7 @@ function DocxEditorViewer({
36285
36600
  },
36286
36601
  [editor]
36287
36602
  );
36288
- const focusDropCapWrappedParagraph = React.useCallback(
36603
+ const focusDropCapWrappedParagraph = React2.useCallback(
36289
36604
  (nodeIndex, point) => {
36290
36605
  clearObjectSelectionForParagraphEntry(nodeIndex);
36291
36606
  editor.selectParagraph(nodeIndex);
@@ -36309,7 +36624,7 @@ function DocxEditorViewer({
36309
36624
  placeCaretInsideElement
36310
36625
  ]
36311
36626
  );
36312
- const activateDropCapEditor = React.useCallback(
36627
+ const activateDropCapEditor = React2.useCallback(
36313
36628
  (nodeIndex) => {
36314
36629
  if (isReadOnly) {
36315
36630
  return;
@@ -36322,7 +36637,7 @@ function DocxEditorViewer({
36322
36637
  },
36323
36638
  [clearTableCellSelection, isReadOnly]
36324
36639
  );
36325
- const scheduleDeferredCollapsedSelectionSync = React.useCallback(() => {
36640
+ const scheduleDeferredCollapsedSelectionSync = React2.useCallback(() => {
36326
36641
  if (deferredCollapsedSelectionSyncTimeoutRef.current !== null) {
36327
36642
  window.clearTimeout(deferredCollapsedSelectionSyncTimeoutRef.current);
36328
36643
  }
@@ -36331,7 +36646,7 @@ function DocxEditorViewer({
36331
36646
  flushActiveRangeFromSelection();
36332
36647
  }, 80);
36333
36648
  }, [flushActiveRangeFromSelection]);
36334
- React.useLayoutEffect(() => {
36649
+ React2.useLayoutEffect(() => {
36335
36650
  const request = editor.historyRestoreRequest;
36336
36651
  if (!request?.textInput || !request.activeTextRange || request.nonce === appliedHistoryRestoreNonceRef.current || compositionActiveRef.current) {
36337
36652
  return;
@@ -36379,7 +36694,7 @@ function DocxEditorViewer({
36379
36694
  resolveDomPositionFromBoundary,
36380
36695
  resolveParagraphHostElement
36381
36696
  ]);
36382
- React.useEffect(() => {
36697
+ React2.useEffect(() => {
36383
36698
  const restoreRequest = editor.historyRestoreRequest;
36384
36699
  if (!restoreRequest) {
36385
36700
  return;
@@ -36511,7 +36826,7 @@ function DocxEditorViewer({
36511
36826
  scheduleSelectionIntentFrame,
36512
36827
  setSelectionFromDocxBoundaries
36513
36828
  ]);
36514
- React.useEffect(() => {
36829
+ React2.useEffect(() => {
36515
36830
  const handleSelectionChange = () => {
36516
36831
  const selection = window.getSelection();
36517
36832
  if (!selection) {
@@ -36577,7 +36892,7 @@ function DocxEditorViewer({
36577
36892
  document.removeEventListener("selectionchange", handleSelectionChange);
36578
36893
  };
36579
36894
  }, [flushActiveRangeFromSelection, scheduleDeferredCollapsedSelectionSync]);
36580
- React.useEffect(() => {
36895
+ React2.useEffect(() => {
36581
36896
  const onPointerDown = (event) => {
36582
36897
  commandSelectionGuardRef.current = void 0;
36583
36898
  const rootElement = viewerRootRef.current;
@@ -36612,7 +36927,7 @@ function DocxEditorViewer({
36612
36927
  editor,
36613
36928
  resolveActiveRangeFromDomSelection
36614
36929
  ]);
36615
- const beginCrossNodeSelectionDrag = React.useCallback(
36930
+ const beginCrossNodeSelectionDrag = React2.useCallback(
36616
36931
  (startBoundary, pointerId, startX, startY) => {
36617
36932
  tableSelectionDragRef.current = {
36618
36933
  pointerId,
@@ -36700,14 +37015,14 @@ function DocxEditorViewer({
36700
37015
  },
36701
37016
  [resolveBoundaryFromPoint, setSelectionFromDocxBoundaries]
36702
37017
  );
36703
- const resolveTableCellLocationFromPoint = React.useCallback(
37018
+ const resolveTableCellLocationFromPoint = React2.useCallback(
36704
37019
  (point) => {
36705
37020
  const element = document.elementFromPoint(point.x, point.y);
36706
37021
  return parseTableCellLocationFromElement(element);
36707
37022
  },
36708
37023
  []
36709
37024
  );
36710
- const beginTableCellSelectionDrag = React.useCallback(
37025
+ const beginTableCellSelectionDrag = React2.useCallback(
36711
37026
  (pointerId, anchorCell, startX, startY, startBoundary) => {
36712
37027
  tableCellSelectionDragRef.current = {
36713
37028
  pointerId,
@@ -36823,7 +37138,7 @@ function DocxEditorViewer({
36823
37138
  setSelectionFromDocxBoundaries
36824
37139
  ]
36825
37140
  );
36826
- const onViewerPointerDown = React.useCallback(
37141
+ const onViewerPointerDown = React2.useCallback(
36827
37142
  (event) => {
36828
37143
  if (tableContextMenuState || contextMenuState) {
36829
37144
  const target2 = event.target;
@@ -36884,7 +37199,7 @@ function DocxEditorViewer({
36884
37199
  tableContextMenuState
36885
37200
  ]
36886
37201
  );
36887
- const onViewerFormFieldDoubleClick = React.useCallback(
37202
+ const onViewerFormFieldDoubleClick = React2.useCallback(
36888
37203
  (event) => {
36889
37204
  if (isReadOnly || !(event.target instanceof Element)) {
36890
37205
  return;
@@ -36911,7 +37226,7 @@ function DocxEditorViewer({
36911
37226
  },
36912
37227
  [editor.model, editor.selectFormField, isReadOnly, onFormFieldDoubleClick]
36913
37228
  );
36914
- const onViewerContextMenu = React.useCallback(
37229
+ const onViewerContextMenu = React2.useCallback(
36915
37230
  (event) => {
36916
37231
  if (isReadOnly || event.defaultPrevented) {
36917
37232
  return;
@@ -36986,7 +37301,7 @@ function DocxEditorViewer({
36986
37301
  setSelectionFromDocxBoundaries
36987
37302
  ]
36988
37303
  );
36989
- const handleDeleteAcrossTableCellSelection = React.useCallback(
37304
+ const handleDeleteAcrossTableCellSelection = React2.useCallback(
36990
37305
  (event) => {
36991
37306
  if (isReadOnly) {
36992
37307
  return false;
@@ -37062,7 +37377,7 @@ function DocxEditorViewer({
37062
37377
  tableCellSelectionRange
37063
37378
  ]
37064
37379
  );
37065
- const onViewerKeyDown = React.useCallback(
37380
+ const onViewerKeyDown = React2.useCallback(
37066
37381
  (event) => {
37067
37382
  commandSelectionGuardRef.current = void 0;
37068
37383
  if (!isReadOnly && handleDeleteAcrossTableCellSelection(event)) {
@@ -37151,7 +37466,7 @@ function DocxEditorViewer({
37151
37466
  syncSelectionFromDocxRange
37152
37467
  ]
37153
37468
  );
37154
- const onViewerKeyUp = React.useCallback(
37469
+ const onViewerKeyUp = React2.useCallback(
37155
37470
  (event) => {
37156
37471
  if (!shouldSyncActiveRangeOnKeyUp(event)) {
37157
37472
  return;
@@ -37160,7 +37475,7 @@ function DocxEditorViewer({
37160
37475
  },
37161
37476
  [flushActiveRangeFromSelection]
37162
37477
  );
37163
- const handleDeleteAcrossSelection = React.useCallback(
37478
+ const handleDeleteAcrossSelection = React2.useCallback(
37164
37479
  (event) => {
37165
37480
  if (isReadOnly) {
37166
37481
  return false;
@@ -37230,7 +37545,7 @@ function DocxEditorViewer({
37230
37545
  syncSelectionFromDocxRange
37231
37546
  ]
37232
37547
  );
37233
- const replaceExpandedSelectionWithText = React.useCallback(
37548
+ const replaceExpandedSelectionWithText = React2.useCallback(
37234
37549
  (rawText) => {
37235
37550
  if (isReadOnly) {
37236
37551
  return false;
@@ -37287,7 +37602,7 @@ function DocxEditorViewer({
37287
37602
  syncSelectionFromDocxRange
37288
37603
  ]
37289
37604
  );
37290
- const resolveContextMenuActions = React.useCallback(
37605
+ const resolveContextMenuActions = React2.useCallback(
37291
37606
  (context) => {
37292
37607
  if (context.kind === "table") {
37293
37608
  return tableContextMenuActions.map((action) => ({
@@ -37392,7 +37707,7 @@ function DocxEditorViewer({
37392
37707
  },
37393
37708
  [tableContextMenuActions]
37394
37709
  );
37395
- const runContextMenuAction = React.useCallback(
37710
+ const runContextMenuAction = React2.useCallback(
37396
37711
  (actionId, providedContext) => {
37397
37712
  const isTableAction = (value) => value === "insert-row-above" || value === "insert-row-below" || value === "insert-column-left" || value === "insert-column-right" || value === "delete-row" || value === "delete-column" || value === "delete-table";
37398
37713
  if (isTableAction(actionId)) {
@@ -37863,7 +38178,7 @@ function DocxEditorViewer({
37863
38178
  syncSelectionFromDocxRange
37864
38179
  ]
37865
38180
  );
37866
- React.useEffect(() => {
38181
+ React2.useEffect(() => {
37867
38182
  const onWindowKeyDown = (event) => {
37868
38183
  if (isReadOnly || event.defaultPrevented) {
37869
38184
  return;
@@ -37937,7 +38252,7 @@ function DocxEditorViewer({
37937
38252
  resolveParagraphBoundaryFromSelectionPoint,
37938
38253
  syncSelectionFromDocxRange
37939
38254
  ]);
37940
- React.useEffect(() => {
38255
+ React2.useEffect(() => {
37941
38256
  if (!selectedImage) {
37942
38257
  return;
37943
38258
  }
@@ -37951,10 +38266,10 @@ function DocxEditorViewer({
37951
38266
  setResizePreview(void 0);
37952
38267
  }
37953
38268
  }, [editor.model, selectedImage]);
37954
- React.useEffect(() => {
38269
+ React2.useEffect(() => {
37955
38270
  activeWrappedParagraphSessionRef.current = activeWrappedParagraphSession;
37956
38271
  }, [activeWrappedParagraphSession]);
37957
- React.useEffect(() => {
38272
+ React2.useEffect(() => {
37958
38273
  if (!selectedImage && !selectedSectionImageKey) {
37959
38274
  return;
37960
38275
  }
@@ -37963,7 +38278,7 @@ function DocxEditorViewer({
37963
38278
  setDropCapMovePreview(void 0);
37964
38279
  setActiveWrappedParagraphSession(void 0);
37965
38280
  }, [selectedImage, selectedSectionImageKey]);
37966
- React.useEffect(() => {
38281
+ React2.useEffect(() => {
37967
38282
  if (selectedDropCapNodeIndex === void 0) {
37968
38283
  return;
37969
38284
  }
@@ -37974,7 +38289,7 @@ function DocxEditorViewer({
37974
38289
  setDropCapMovePreview(void 0);
37975
38290
  }
37976
38291
  }, [editor.model, selectedDropCapNodeIndex]);
37977
- React.useEffect(() => {
38292
+ React2.useEffect(() => {
37978
38293
  if (!activeWrappedParagraphSession) {
37979
38294
  return;
37980
38295
  }
@@ -38004,13 +38319,13 @@ function DocxEditorViewer({
38004
38319
  );
38005
38320
  }
38006
38321
  }, [activeWrappedParagraphSession, editor.model]);
38007
- React.useEffect(() => {
38322
+ React2.useEffect(() => {
38008
38323
  if (!activeWrappedParagraphSession) {
38009
38324
  return;
38010
38325
  }
38011
38326
  focusWrappedParagraphTextarea();
38012
38327
  }, [activeWrappedParagraphSession, focusWrappedParagraphTextarea]);
38013
- React.useEffect(() => {
38328
+ React2.useEffect(() => {
38014
38329
  const textarea = wrappedParagraphTextareaRef.current;
38015
38330
  const session = activeWrappedParagraphSession;
38016
38331
  if (!textarea || !session) {
@@ -38031,7 +38346,7 @@ function DocxEditorViewer({
38031
38346
  } catch {
38032
38347
  }
38033
38348
  }, [activeWrappedParagraphSession]);
38034
- const focusParagraphAtOffset = React.useCallback(
38349
+ const focusParagraphAtOffset = React2.useCallback(
38035
38350
  (paragraphIndex, offset) => {
38036
38351
  const focusAttempt = (attempt) => {
38037
38352
  const element = resolveParagraphHostElementForOffset(
@@ -38076,7 +38391,7 @@ function DocxEditorViewer({
38076
38391
  setSelectionWithinElementByTextOffsets
38077
38392
  ]
38078
38393
  );
38079
- const focusTableCellParagraphAtOffset = React.useCallback(
38394
+ const focusTableCellParagraphAtOffset = React2.useCallback(
38080
38395
  (cellDraftKey, paragraphIndex, offset) => {
38081
38396
  window.requestAnimationFrame(() => {
38082
38397
  const cellElement = tableCellEditorElementsRef.current.get(cellDraftKey);
@@ -38107,7 +38422,7 @@ function DocxEditorViewer({
38107
38422
  },
38108
38423
  [setSelectionWithinElementByTextOffsets]
38109
38424
  );
38110
- const focusParagraphLocationAtOffset = React.useCallback(
38425
+ const focusParagraphLocationAtOffset = React2.useCallback(
38111
38426
  (location, offset) => {
38112
38427
  if (location.kind === "paragraph") {
38113
38428
  focusParagraphAtOffset(location.nodeIndex, offset);
@@ -38122,7 +38437,7 @@ function DocxEditorViewer({
38122
38437
  },
38123
38438
  [focusParagraphAtOffset, focusTableCellParagraphAtOffset]
38124
38439
  );
38125
- const focusParagraphLocationAtClientPoint = React.useCallback(
38440
+ const focusParagraphLocationAtClientPoint = React2.useCallback(
38126
38441
  (location, preferredPoint, fallbackOffset) => {
38127
38442
  const targetElement = resolveParagraphHostElement(location);
38128
38443
  if (!targetElement) {
@@ -38168,7 +38483,7 @@ function DocxEditorViewer({
38168
38483
  setSelectionFromDocxBoundaries
38169
38484
  ]
38170
38485
  );
38171
- const focusParagraphAtEnd = React.useCallback(
38486
+ const focusParagraphAtEnd = React2.useCallback(
38172
38487
  (paragraphIndex) => {
38173
38488
  window.requestAnimationFrame(() => {
38174
38489
  const element = paragraphElementsRef.current.get(paragraphIndex);
@@ -38189,7 +38504,7 @@ function DocxEditorViewer({
38189
38504
  },
38190
38505
  []
38191
38506
  );
38192
- const selectionOffsetsWithinElement = React.useCallback(
38507
+ const selectionOffsetsWithinElement = React2.useCallback(
38193
38508
  (element) => {
38194
38509
  const selection = window.getSelection();
38195
38510
  if (!selection || selection.rangeCount === 0) {
@@ -38228,7 +38543,7 @@ function DocxEditorViewer({
38228
38543
  },
38229
38544
  []
38230
38545
  );
38231
- const collapsedCaretClientPointWithinElement = React.useCallback(
38546
+ const collapsedCaretClientPointWithinElement = React2.useCallback(
38232
38547
  (element) => {
38233
38548
  const selection = window.getSelection();
38234
38549
  if (!selection || selection.rangeCount === 0 || !selection.isCollapsed) {
@@ -38255,7 +38570,7 @@ function DocxEditorViewer({
38255
38570
  },
38256
38571
  []
38257
38572
  );
38258
- const activeTableCellParagraphContext = React.useCallback(
38573
+ const activeTableCellParagraphContext = React2.useCallback(
38259
38574
  (cellElement) => {
38260
38575
  const selection = window.getSelection();
38261
38576
  if (!selection) {
@@ -38292,7 +38607,7 @@ function DocxEditorViewer({
38292
38607
  },
38293
38608
  []
38294
38609
  );
38295
- const updateActiveTextRangeFromTableCell = React.useCallback(
38610
+ const updateActiveTextRangeFromTableCell = React2.useCallback(
38296
38611
  (cellElement, tableIndex, rowIndex, cellIndex) => {
38297
38612
  const selection = window.getSelection();
38298
38613
  if (!selection || selection.rangeCount === 0) {
@@ -38331,7 +38646,7 @@ function DocxEditorViewer({
38331
38646
  resolveParagraphBoundaryFromSelectionPoint
38332
38647
  ]
38333
38648
  );
38334
- const updateActiveTextRangeFromElement = React.useCallback(
38649
+ const updateActiveTextRangeFromElement = React2.useCallback(
38335
38650
  (element, location) => {
38336
38651
  const selection = window.getSelection();
38337
38652
  if (!selection || selection.rangeCount === 0) {
@@ -38363,7 +38678,7 @@ function DocxEditorViewer({
38363
38678
  },
38364
38679
  [clearTableCellSelection, editor, selectionOffsetsWithinElement]
38365
38680
  );
38366
- const commitTableCellDraftFromElement = React.useCallback(
38681
+ const commitTableCellDraftFromElement = React2.useCallback(
38367
38682
  (tableIndex, rowIndex, cellIndex, cellParagraphs, draftKey, element) => {
38368
38683
  const nextText = editableTextFromTableCellElement(element);
38369
38684
  const nextHtml = element.innerHTML;
@@ -38377,7 +38692,7 @@ function DocxEditorViewer({
38377
38692
  },
38378
38693
  [editor]
38379
38694
  );
38380
- const registerTableCellParagraphElement = React.useCallback(
38695
+ const registerTableCellParagraphElement = React2.useCallback(
38381
38696
  (draftKey, element) => {
38382
38697
  if (element) {
38383
38698
  tableCellParagraphElementsRef.current.set(draftKey, element);
@@ -38387,27 +38702,27 @@ function DocxEditorViewer({
38387
38702
  },
38388
38703
  []
38389
38704
  );
38390
- const readTableCellParagraphDraft = React.useCallback(
38705
+ const readTableCellParagraphDraft = React2.useCallback(
38391
38706
  (draftKey) => {
38392
38707
  return tableCellParagraphDraftsRef.current.get(draftKey);
38393
38708
  },
38394
38709
  []
38395
38710
  );
38396
- const writeTableCellParagraphDraft = React.useCallback(
38711
+ const writeTableCellParagraphDraft = React2.useCallback(
38397
38712
  (draftKey, html) => {
38398
38713
  tableCellParagraphDraftsRef.current.set(draftKey, html);
38399
38714
  requestTableDraftLayoutRefresh();
38400
38715
  },
38401
38716
  [requestTableDraftLayoutRefresh]
38402
38717
  );
38403
- const clearTableCellParagraphDraft = React.useCallback(
38718
+ const clearTableCellParagraphDraft = React2.useCallback(
38404
38719
  (draftKey) => {
38405
38720
  tableCellParagraphDraftsRef.current.delete(draftKey);
38406
38721
  requestTableDraftLayoutRefresh();
38407
38722
  },
38408
38723
  [requestTableDraftLayoutRefresh]
38409
38724
  );
38410
- const commitTableCellParagraphDraft = React.useCallback(
38725
+ const commitTableCellParagraphDraft = React2.useCallback(
38411
38726
  (tableIndex, rowIndex, cellIndex, paragraphIndex, text) => {
38412
38727
  const draftKey = tableCellParagraphDraftKey(
38413
38728
  tableIndex,
@@ -38439,7 +38754,7 @@ function DocxEditorViewer({
38439
38754
  },
38440
38755
  [editor]
38441
38756
  );
38442
- const registerSectionParagraphElement = React.useCallback(
38757
+ const registerSectionParagraphElement = React2.useCallback(
38443
38758
  (draftKey, element) => {
38444
38759
  if (element) {
38445
38760
  sectionParagraphElementsRef.current.set(draftKey, element);
@@ -38449,25 +38764,25 @@ function DocxEditorViewer({
38449
38764
  },
38450
38765
  []
38451
38766
  );
38452
- const readSectionParagraphDraft = React.useCallback(
38767
+ const readSectionParagraphDraft = React2.useCallback(
38453
38768
  (draftKey) => {
38454
38769
  return sectionParagraphDraftsRef.current.get(draftKey);
38455
38770
  },
38456
38771
  []
38457
38772
  );
38458
- const writeSectionParagraphDraft = React.useCallback(
38773
+ const writeSectionParagraphDraft = React2.useCallback(
38459
38774
  (draftKey, html) => {
38460
38775
  sectionParagraphDraftsRef.current.set(draftKey, html);
38461
38776
  },
38462
38777
  []
38463
38778
  );
38464
- const clearSectionParagraphDraft = React.useCallback(
38779
+ const clearSectionParagraphDraft = React2.useCallback(
38465
38780
  (draftKey) => {
38466
38781
  sectionParagraphDraftsRef.current.delete(draftKey);
38467
38782
  },
38468
38783
  []
38469
38784
  );
38470
- const commitSectionParagraphDraft = React.useCallback(
38785
+ const commitSectionParagraphDraft = React2.useCallback(
38471
38786
  (location, text) => {
38472
38787
  const draftKey = sectionParagraphLocationKey(location);
38473
38788
  const currentSectionLists = location.region === "header" ? [
@@ -38497,7 +38812,7 @@ function DocxEditorViewer({
38497
38812
  },
38498
38813
  [editor]
38499
38814
  );
38500
- const updateSectionParagraphDraftFromTarget = React.useCallback(
38815
+ const updateSectionParagraphDraftFromTarget = React2.useCallback(
38501
38816
  (target) => {
38502
38817
  if (!(target instanceof Element)) {
38503
38818
  return;
@@ -38518,7 +38833,7 @@ function DocxEditorViewer({
38518
38833
  },
38519
38834
  []
38520
38835
  );
38521
- const commitSectionRegionDraftsFromContainer = React.useCallback(
38836
+ const commitSectionRegionDraftsFromContainer = React2.useCallback(
38522
38837
  (container, region, partName) => {
38523
38838
  const paragraphHosts = Array.from(
38524
38839
  container.querySelectorAll(
@@ -38577,7 +38892,7 @@ function DocxEditorViewer({
38577
38892
  closeActiveHeaderFooterEdit(activeEdit);
38578
38893
  });
38579
38894
  }
38580
- React.useEffect(() => {
38895
+ React2.useEffect(() => {
38581
38896
  const flushPendingDraftsForExport = (currentModel) => {
38582
38897
  if (tableCellDraftsRef.current.size === 0 && tableCellParagraphDraftsRef.current.size === 0 && sectionParagraphDraftsRef.current.size === 0) {
38583
38898
  return currentModel;
@@ -38699,7 +39014,7 @@ function DocxEditorViewer({
38699
39014
  editor.registerPendingExportModelTransformer(void 0);
38700
39015
  };
38701
39016
  }, [editor, editor.pendingRunStyle]);
38702
- const handleEditorHistoryShortcut = React.useCallback(
39017
+ const handleEditorHistoryShortcut = React2.useCallback(
38703
39018
  (event, commitDraft) => {
38704
39019
  if (event.defaultPrevented || !(event.metaKey || event.ctrlKey) || event.altKey) {
38705
39020
  return false;
@@ -38724,7 +39039,7 @@ function DocxEditorViewer({
38724
39039
  },
38725
39040
  [editor]
38726
39041
  );
38727
- const handleEditableHostBeforeInput = React.useCallback(
39042
+ const handleEditableHostBeforeInput = React2.useCallback(
38728
39043
  (event) => {
38729
39044
  if (isReadOnly) {
38730
39045
  return;
@@ -39129,7 +39444,7 @@ function DocxEditorViewer({
39129
39444
  syncSelectionFromDocxRange
39130
39445
  ]
39131
39446
  );
39132
- React.useEffect(() => {
39447
+ React2.useEffect(() => {
39133
39448
  const rootElement = viewerRootRef.current;
39134
39449
  if (!rootElement) {
39135
39450
  return;
@@ -39142,7 +39457,7 @@ function DocxEditorViewer({
39142
39457
  rootElement.removeEventListener("beforeinput", handleBeforeInput);
39143
39458
  };
39144
39459
  }, [handleEditableHostBeforeInput]);
39145
- const resolveTableColumnWidths = React.useCallback(
39460
+ const resolveTableColumnWidths = React2.useCallback(
39146
39461
  (tableIndex, table, tableWidthPx) => {
39147
39462
  const columnCount = tableColumnCount(table);
39148
39463
  const storedWidths = tableColumnWidths[tableIndex];
@@ -39173,7 +39488,7 @@ function DocxEditorViewer({
39173
39488
  },
39174
39489
  [tableColumnWidths]
39175
39490
  );
39176
- const resolveTableRowHeights = React.useCallback(
39491
+ const resolveTableRowHeights = React2.useCallback(
39177
39492
  (tableIndex, table) => {
39178
39493
  const storedHeights = tableRowHeights[tableIndex];
39179
39494
  return table.rows.map((row, rowIndex) => {
@@ -39193,7 +39508,7 @@ function DocxEditorViewer({
39193
39508
  },
39194
39509
  [tableRowHeights]
39195
39510
  );
39196
- const resolveEmbeddedTableColumnWidths = React.useCallback(
39511
+ const resolveEmbeddedTableColumnWidths = React2.useCallback(
39197
39512
  (tableKey, table, tableWidthPx) => {
39198
39513
  const columnCount = tableColumnCount(table);
39199
39514
  const storedWidths = embeddedTableColumnWidths[tableKey];
@@ -39224,7 +39539,7 @@ function DocxEditorViewer({
39224
39539
  },
39225
39540
  [embeddedTableColumnWidths]
39226
39541
  );
39227
- const resolveEmbeddedTableRowHeights = React.useCallback(
39542
+ const resolveEmbeddedTableRowHeights = React2.useCallback(
39228
39543
  (tableKey, table) => {
39229
39544
  const storedHeights = embeddedTableRowHeights[tableKey];
39230
39545
  return table.rows.map((row, rowIndex) => {
@@ -39244,7 +39559,7 @@ function DocxEditorViewer({
39244
39559
  },
39245
39560
  [embeddedTableRowHeights]
39246
39561
  );
39247
- React.useLayoutEffect(() => {
39562
+ React2.useLayoutEffect(() => {
39248
39563
  if (disableMeasuredImportPagination) {
39249
39564
  setTableMeasuredRowHeights(
39250
39565
  (current) => Object.keys(current).length === 0 ? current : {}
@@ -39422,7 +39737,7 @@ function DocxEditorViewer({
39422
39737
  virtualizerMeasurementScale,
39423
39738
  visibleTableRowIndexesByNodeIndex
39424
39739
  ]);
39425
- const normalizeResizableHeights = React.useCallback(
39740
+ const normalizeResizableHeights = React2.useCallback(
39426
39741
  (rowHeights) => {
39427
39742
  return rowHeights.map((height) => {
39428
39743
  if (typeof height !== "number" || !Number.isFinite(height) || height <= 0) {
@@ -39433,7 +39748,7 @@ function DocxEditorViewer({
39433
39748
  },
39434
39749
  []
39435
39750
  );
39436
- const distributeHeightByTotal = React.useCallback(
39751
+ const distributeHeightByTotal = React2.useCallback(
39437
39752
  (rowHeights, totalHeightPx) => {
39438
39753
  const safeCount = rowHeights.length;
39439
39754
  if (safeCount === 0) {
@@ -39482,7 +39797,7 @@ function DocxEditorViewer({
39482
39797
  },
39483
39798
  []
39484
39799
  );
39485
- const beginTableColumnResize = React.useCallback(
39800
+ const beginTableColumnResize = React2.useCallback(
39486
39801
  (event, tableIndex, boundaryColumnIndex, tableWidthPx, columnWidths) => {
39487
39802
  if (isReadOnly) {
39488
39803
  return;
@@ -39572,7 +39887,7 @@ function DocxEditorViewer({
39572
39887
  },
39573
39888
  [isReadOnly]
39574
39889
  );
39575
- const beginTableRowResize = React.useCallback(
39890
+ const beginTableRowResize = React2.useCallback(
39576
39891
  (event, tableIndex, boundaryRowIndex, rowHeights) => {
39577
39892
  if (isReadOnly) {
39578
39893
  return;
@@ -39653,7 +39968,7 @@ function DocxEditorViewer({
39653
39968
  },
39654
39969
  [isReadOnly]
39655
39970
  );
39656
- const beginEmbeddedTableColumnResize = React.useCallback(
39971
+ const beginEmbeddedTableColumnResize = React2.useCallback(
39657
39972
  (event, tableKey, boundaryColumnIndex, tableWidthPx, columnWidths) => {
39658
39973
  if (isReadOnly) {
39659
39974
  return;
@@ -39746,7 +40061,7 @@ function DocxEditorViewer({
39746
40061
  },
39747
40062
  [isReadOnly]
39748
40063
  );
39749
- const beginEmbeddedTableRowResize = React.useCallback(
40064
+ const beginEmbeddedTableRowResize = React2.useCallback(
39750
40065
  (event, tableKey, boundaryRowIndex, rowHeights) => {
39751
40066
  if (isReadOnly) {
39752
40067
  return;
@@ -39827,7 +40142,7 @@ function DocxEditorViewer({
39827
40142
  },
39828
40143
  [isReadOnly]
39829
40144
  );
39830
- const beginImageResize = React.useCallback(
40145
+ const beginImageResize = React2.useCallback(
39831
40146
  (event, location, startWidthPx, startHeightPx, xDirection, yDirection) => {
39832
40147
  if (isReadOnly) {
39833
40148
  return;
@@ -39881,7 +40196,7 @@ function DocxEditorViewer({
39881
40196
  },
39882
40197
  [editor, isReadOnly]
39883
40198
  );
39884
- const beginFloatingImageMove = React.useCallback(
40199
+ const beginFloatingImageMove = React2.useCallback(
39885
40200
  (event, location, image, isWrappedFloatingImage, isAbsoluteFloatingImage) => {
39886
40201
  if (isReadOnly || event.button !== 0 || event.target.closest(
39887
40202
  "[data-image-resize-handle='true']"
@@ -39893,7 +40208,7 @@ function DocxEditorViewer({
39893
40208
  setSelectedImage(location);
39894
40209
  const element = event.currentTarget;
39895
40210
  const imageKey = imageLocationKey(location);
39896
- const zoom = resolveViewerMeasurementZoomScale(element, 1);
40211
+ const zoom2 = resolveViewerMeasurementZoomScale(element, 1);
39897
40212
  const isInline = !isWrappedFloatingImage && !isAbsoluteFloatingImage;
39898
40213
  const floating = image.floating;
39899
40214
  let caret;
@@ -39973,7 +40288,7 @@ function DocxEditorViewer({
39973
40288
  objectDragCleanupRef.current = startObjectDrag({
39974
40289
  event,
39975
40290
  element,
39976
- zoom,
40291
+ zoom: zoom2,
39977
40292
  resolveElement: () => viewerRootRef.current?.querySelector(
39978
40293
  `[data-docx-image-location="${imageKey}"]`
39979
40294
  ) ?? void 0,
@@ -40033,7 +40348,7 @@ function DocxEditorViewer({
40033
40348
  const anchorLayout = anchorParagraph?.type === "paragraph" && anchorSource ? layoutParagraphPretextSource(
40034
40349
  anchorParagraph,
40035
40350
  anchorSource,
40036
- hostRect.width / zoom,
40351
+ hostRect.width / zoom2,
40037
40352
  Number(host?.dataset.docxParagraphLineHeight) || estimateParagraphLineHeightPx(anchorParagraph),
40038
40353
  []
40039
40354
  ) : void 0;
@@ -40051,9 +40366,9 @@ function DocxEditorViewer({
40051
40366
  {
40052
40367
  ...resolveWrappedFloatingImageDropPatch(
40053
40368
  image,
40054
- hostRect.width / zoom,
40055
- (frame.left - hostRect.left) / zoom,
40056
- (frame.top - hostRect.top) / zoom
40369
+ hostRect.width / zoom2,
40370
+ (frame.left - hostRect.left) / zoom2,
40371
+ (frame.top - hostRect.top) / zoom2
40057
40372
  ),
40058
40373
  horizontalAlign: void 0,
40059
40374
  verticalAlign: void 0,
@@ -40074,12 +40389,12 @@ function DocxEditorViewer({
40074
40389
  documentLayout,
40075
40390
  {
40076
40391
  wrapperRect: {
40077
- left: frame.left / zoom,
40078
- top: frame.top / zoom,
40079
- width: frame.width / zoom,
40080
- height: frame.height / zoom
40392
+ left: frame.left / zoom2,
40393
+ top: frame.top / zoom2,
40394
+ width: frame.width / zoom2,
40395
+ height: frame.height / zoom2
40081
40396
  },
40082
- pageSurfaceRect: surfaceRect ? normalizeFloatingDropRectForZoom(surfaceRect, zoom) : void 0,
40397
+ pageSurfaceRect: surfaceRect ? normalizeFloatingDropRectForZoom(surfaceRect, zoom2) : void 0,
40083
40398
  deltaX: 0,
40084
40399
  deltaY: 0
40085
40400
  }
@@ -40107,7 +40422,7 @@ function DocxEditorViewer({
40107
40422
  clearObjectDragPreview
40108
40423
  ]
40109
40424
  );
40110
- const beginDropCapMove = React.useCallback(
40425
+ const beginDropCapMove = React2.useCallback(
40111
40426
  (event, nodeIndex, dropCap) => {
40112
40427
  if (isReadOnly) {
40113
40428
  return;
@@ -40154,7 +40469,7 @@ function DocxEditorViewer({
40154
40469
  },
40155
40470
  [editor, isReadOnly]
40156
40471
  );
40157
- const beginDropCapResize = React.useCallback(
40472
+ const beginDropCapResize = React2.useCallback(
40158
40473
  (event, nodeIndex, currentFontSizePx, currentWidthPx, currentHeightPx) => {
40159
40474
  if (isReadOnly || event.button !== 0) {
40160
40475
  return;
@@ -40205,7 +40520,7 @@ function DocxEditorViewer({
40205
40520
  },
40206
40521
  [editor, isReadOnly]
40207
40522
  );
40208
- const beginSectionFloatingImageMove = React.useCallback(
40523
+ const beginSectionFloatingImageMove = React2.useCallback(
40209
40524
  (event, location, image, isWrappedFloatingImage, isAbsoluteFloatingImage) => {
40210
40525
  if (isReadOnly) {
40211
40526
  return;
@@ -40367,7 +40682,7 @@ function DocxEditorViewer({
40367
40682
  resolveViewerMeasurementZoomScale
40368
40683
  ]
40369
40684
  );
40370
- const onSectionImageClick = React.useCallback(
40685
+ const onSectionImageClick = React2.useCallback(
40371
40686
  (location) => {
40372
40687
  if (isReadOnly) {
40373
40688
  return;
@@ -40380,7 +40695,7 @@ function DocxEditorViewer({
40380
40695
  },
40381
40696
  [activeHeaderFooterEdit, isReadOnly]
40382
40697
  );
40383
- const onImageDragStart = React.useCallback(
40698
+ const onImageDragStart = React2.useCallback(
40384
40699
  (event, location) => {
40385
40700
  if (isReadOnly) {
40386
40701
  event.preventDefault();
@@ -40395,12 +40710,12 @@ function DocxEditorViewer({
40395
40710
  },
40396
40711
  [isReadOnly]
40397
40712
  );
40398
- const onImageDragEnd = React.useCallback(() => {
40713
+ const onImageDragEnd = React2.useCallback(() => {
40399
40714
  draggedImageRef.current = null;
40400
40715
  setIsDraggingImage(false);
40401
40716
  setActiveDropTarget(void 0);
40402
40717
  }, []);
40403
- const beginTableCornerResize = React.useCallback(
40718
+ const beginTableCornerResize = React2.useCallback(
40404
40719
  (event, tableIndex, tableWidthPx, columnWidths, rowHeights, maxTableWidthPx) => {
40405
40720
  if (isReadOnly) {
40406
40721
  return;
@@ -40503,7 +40818,7 @@ function DocxEditorViewer({
40503
40818
  },
40504
40819
  [isReadOnly]
40505
40820
  );
40506
- const beginEmbeddedTableCornerResize = React.useCallback(
40821
+ const beginEmbeddedTableCornerResize = React2.useCallback(
40507
40822
  (event, tableKey, tableWidthPx, columnWidths, rowHeights, maxTableWidthPx) => {
40508
40823
  if (isReadOnly) {
40509
40824
  return;
@@ -40606,7 +40921,7 @@ function DocxEditorViewer({
40606
40921
  },
40607
40922
  [distributeHeightByTotal, isReadOnly, normalizeResizableHeights]
40608
40923
  );
40609
- const beginEmbeddedTableMove = React.useCallback(
40924
+ const beginEmbeddedTableMove = React2.useCallback(
40610
40925
  (event, tableKey) => {
40611
40926
  if (isReadOnly) {
40612
40927
  return;
@@ -40692,7 +41007,7 @@ function DocxEditorViewer({
40692
41007
  },
40693
41008
  [editor, isReadOnly, resolveTableMoveDropTarget]
40694
41009
  );
40695
- const embeddedTableResizeController = React.useMemo(
41010
+ const embeddedTableResizeController = React2.useMemo(
40696
41011
  () => ({
40697
41012
  isReadOnly,
40698
41013
  hoveredTableKey: hoveredEmbeddedTableKey,
@@ -40754,7 +41069,7 @@ function DocxEditorViewer({
40754
41069
  resolveEmbeddedTableRowHeights
40755
41070
  ]
40756
41071
  );
40757
- const onDropImageAtTarget = React.useCallback(
41072
+ const onDropImageAtTarget = React2.useCallback(
40758
41073
  (target) => {
40759
41074
  if (isReadOnly) {
40760
41075
  return;
@@ -40786,7 +41101,7 @@ function DocxEditorViewer({
40786
41101
  },
40787
41102
  [editor, isReadOnly]
40788
41103
  );
40789
- const renderImageDropZone = React.useCallback(
41104
+ const renderImageDropZone = React2.useCallback(
40790
41105
  (target, key) => {
40791
41106
  if (isReadOnly || !isDraggingImage) {
40792
41107
  return null;
@@ -41553,7 +41868,7 @@ function DocxEditorViewer({
41553
41868
  }
41554
41869
  );
41555
41870
  };
41556
- const renderInteractiveParagraphRuns = React.useCallback(
41871
+ const renderInteractiveParagraphRuns = React2.useCallback(
41557
41872
  (paragraph, keyPrefix, location, options) => {
41558
41873
  const lineRange = options?.paragraphLineRange;
41559
41874
  const sliceTop = (lineRange?.startLineIndex ?? 0) * (lineRange?.lineHeightPx ?? 0);
@@ -43756,13 +44071,13 @@ function DocxEditorViewer({
43756
44071
  trackedChangesEnabled
43757
44072
  ]
43758
44073
  );
43759
- const hasFilePayload = React.useCallback(
44074
+ const hasFilePayload = React2.useCallback(
43760
44075
  (dataTransfer) => {
43761
44076
  return Array.from(dataTransfer?.types ?? []).includes("Files");
43762
44077
  },
43763
44078
  []
43764
44079
  );
43765
- const extractDroppedDocxFile = React.useCallback(
44080
+ const extractDroppedDocxFile = React2.useCallback(
43766
44081
  (dataTransfer) => {
43767
44082
  return Array.from(dataTransfer?.files ?? []).find(
43768
44083
  (candidate) => /\.docx?$/i.test(candidate.name)
@@ -43770,7 +44085,7 @@ function DocxEditorViewer({
43770
44085
  },
43771
44086
  []
43772
44087
  );
43773
- const onCanvasDragOver = React.useCallback(
44088
+ const onCanvasDragOver = React2.useCallback(
43774
44089
  (event) => {
43775
44090
  if (isDraggingImage) {
43776
44091
  event.preventDefault();
@@ -43792,7 +44107,7 @@ function DocxEditorViewer({
43792
44107
  },
43793
44108
  [canReplaceDocumentByDrop, hasFilePayload, isDraggingImage]
43794
44109
  );
43795
- const onCanvasDragLeave = React.useCallback(
44110
+ const onCanvasDragLeave = React2.useCallback(
43796
44111
  (event) => {
43797
44112
  if (event.currentTarget.contains(event.relatedTarget)) {
43798
44113
  return;
@@ -43801,7 +44116,7 @@ function DocxEditorViewer({
43801
44116
  },
43802
44117
  []
43803
44118
  );
43804
- const onCanvasDrop = React.useCallback(
44119
+ const onCanvasDrop = React2.useCallback(
43805
44120
  async (event) => {
43806
44121
  setIsDragOverCanvas(false);
43807
44122
  if (isDraggingImage) {
@@ -43821,7 +44136,7 @@ function DocxEditorViewer({
43821
44136
  },
43822
44137
  [canReplaceDocumentByDrop, editor, extractDroppedDocxFile, isDraggingImage]
43823
44138
  );
43824
- React.useEffect(() => {
44139
+ React2.useEffect(() => {
43825
44140
  if (!canReplaceDocumentByDrop) {
43826
44141
  fileDragDepthRef.current = 0;
43827
44142
  setIsDragOverCanvas(false);
@@ -43894,7 +44209,7 @@ function DocxEditorViewer({
43894
44209
  120,
43895
44210
  documentLayout.pageWidthPx - documentLayout.marginsPx.left - documentLayout.marginsPx.right
43896
44211
  );
43897
- const documentInheritedFontFamily = React.useMemo(
44212
+ const documentInheritedFontFamily = React2.useMemo(
43898
44213
  () => resolveDocumentInheritedFontFamily(editor.model),
43899
44214
  [editor.model]
43900
44215
  );
@@ -43906,19 +44221,19 @@ function DocxEditorViewer({
43906
44221
  boxSizing: "border-box",
43907
44222
  overflow: floatingMovePreview || dropCapMovePreview ? "visible" : "clip"
43908
44223
  };
43909
- const tableCellParagraphSliceLayoutCacheRef = React.useRef(
44224
+ const tableCellParagraphSliceLayoutCacheRef = React2.useRef(
43910
44225
  /* @__PURE__ */ new Map()
43911
44226
  );
43912
- const tableCellParagraphFlowLayoutCacheRef = React.useRef(
44227
+ const tableCellParagraphFlowLayoutCacheRef = React2.useRef(
43913
44228
  /* @__PURE__ */ new Map()
43914
44229
  );
43915
- const tableCellParagraphSlicePlanCacheRef = React.useRef(
44230
+ const tableCellParagraphSlicePlanCacheRef = React2.useRef(
43916
44231
  /* @__PURE__ */ new Map()
43917
44232
  );
43918
- const tableCellParagraphSliceSignatureCacheRef = React.useRef(
44233
+ const tableCellParagraphSliceSignatureCacheRef = React2.useRef(
43919
44234
  /* @__PURE__ */ new WeakMap()
43920
44235
  );
43921
- React.useEffect(() => {
44236
+ React2.useEffect(() => {
43922
44237
  tableCellParagraphSliceLayoutCacheRef.current.clear();
43923
44238
  tableCellParagraphFlowLayoutCacheRef.current.clear();
43924
44239
  tableCellParagraphSlicePlanCacheRef.current.clear();
@@ -47344,11 +47659,11 @@ ${currentText.slice(end)}`;
47344
47659
  }
47345
47660
  return renderedTableBlock;
47346
47661
  };
47347
- const objectDragPageRenderCacheRef = React.useRef(
47662
+ const objectDragPageRenderCacheRef = React2.useRef(
47348
47663
  /* @__PURE__ */ new Map()
47349
47664
  );
47350
47665
  if (!objectWrapDragPreview) objectDragPageRenderCacheRef.current.clear();
47351
- const renderNodeSegments = React.useCallback(
47666
+ const renderNodeSegments = React2.useCallback(
47352
47667
  (nodeSegments, options) => {
47353
47668
  const dragSourceIndex = objectWrapDragPreview?.tableIndex ?? (objectWrapDragPreview?.imageKey?.startsWith("p:") ? Number(objectWrapDragPreview.imageKey.split(":")[1]) : -1);
47354
47669
  const dragPagePreview = objectWrapDragPreview?.bandsByPage.has(
@@ -47403,7 +47718,7 @@ ${currentText.slice(end)}`;
47403
47718
  Math.round(segment2.tableRowSlice.sliceHeightPx)
47404
47719
  )}` : ""}` : segment2.paragraphLineRange ? `lines-${segment2.paragraphLineRange.startLineIndex}-${segment2.paragraphLineRange.endLineIndex}` : "all";
47405
47720
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47406
- React.Fragment,
47721
+ React2.Fragment,
47407
47722
  {
47408
47723
  children: renderDocumentNode(
47409
47724
  groupNode,
@@ -47453,7 +47768,7 @@ ${currentText.slice(end)}`;
47453
47768
  const leftSegment = leftSegments[rowIndex];
47454
47769
  const rightSegment = rightSegments[rowIndex];
47455
47770
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
47456
- React.Fragment,
47771
+ React2.Fragment,
47457
47772
  {
47458
47773
  children: [
47459
47774
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: letterheadColumnStackStyle(), children: leftSegment ? renderLetterheadSegment(
@@ -48095,23 +48410,23 @@ ${currentText.slice(end)}`;
48095
48410
  );
48096
48411
  const footnotes = editor.model.metadata.footnotes ?? [];
48097
48412
  const endnotes = editor.model.metadata.endnotes ?? [];
48098
- const footnoteDisplayIndexById = React.useMemo(
48413
+ const footnoteDisplayIndexById = React2.useMemo(
48099
48414
  () => new Map(footnotes.map((note, index) => [note.id, index + 1])),
48100
48415
  [footnotes]
48101
48416
  );
48102
- const endnoteDisplayIndexById = React.useMemo(
48417
+ const endnoteDisplayIndexById = React2.useMemo(
48103
48418
  () => new Map(endnotes.map((note, index) => [note.id, index + 1])),
48104
48419
  [endnotes]
48105
48420
  );
48106
- const footnotesById = React.useMemo(
48421
+ const footnotesById = React2.useMemo(
48107
48422
  () => new Map(footnotes.map((note) => [note.id, note])),
48108
48423
  [footnotes]
48109
48424
  );
48110
- const endnotesById = React.useMemo(
48425
+ const endnotesById = React2.useMemo(
48111
48426
  () => new Map(endnotes.map((note) => [note.id, note])),
48112
48427
  [endnotes]
48113
48428
  );
48114
- const pageFootnotesByIndex = React.useMemo(() => {
48429
+ const pageFootnotesByIndex = React2.useMemo(() => {
48115
48430
  if (footnotes.length === 0) {
48116
48431
  return pageNodeSegmentsByPage.map(() => []);
48117
48432
  }
@@ -48144,7 +48459,7 @@ ${currentText.slice(end)}`;
48144
48459
  footnotesById,
48145
48460
  pageNodeSegmentsByPage
48146
48461
  ]);
48147
- const referencedEndnotes = React.useMemo(() => {
48462
+ const referencedEndnotes = React2.useMemo(() => {
48148
48463
  if (endnotes.length === 0) {
48149
48464
  return endnotes;
48150
48465
  }
@@ -48162,7 +48477,7 @@ ${currentText.slice(end)}`;
48162
48477
  const referenced = referencedIds.map((referenceId) => endnotesById.get(referenceId)).filter((note) => Boolean(note));
48163
48478
  return referenced.length > 0 ? referenced : endnotes;
48164
48479
  }, [editor.model.nodes, endnotes, endnotesById]);
48165
- const placedFootnoteIds = React.useMemo(() => {
48480
+ const placedFootnoteIds = React2.useMemo(() => {
48166
48481
  const ids = /* @__PURE__ */ new Set();
48167
48482
  pageFootnotesByIndex.forEach((notesForPage) => {
48168
48483
  notesForPage.forEach((note) => {
@@ -48171,11 +48486,11 @@ ${currentText.slice(end)}`;
48171
48486
  });
48172
48487
  return ids;
48173
48488
  }, [pageFootnotesByIndex]);
48174
- const remainingFootnotes = React.useMemo(
48489
+ const remainingFootnotes = React2.useMemo(
48175
48490
  () => footnotes.filter((note) => !placedFootnoteIds.has(note.id)),
48176
48491
  [footnotes, placedFootnoteIds]
48177
48492
  );
48178
- const renderDocumentNote = React.useCallback(
48493
+ const renderDocumentNote = React2.useCallback(
48179
48494
  (note, noteKind, keyPrefix, pageNumberValue, runRenderOptions) => {
48180
48495
  const noteNodes = note.nodes?.filter(
48181
48496
  (node) => node.type === "paragraph"
@@ -48239,7 +48554,7 @@ ${currentText.slice(end)}`;
48239
48554
  totalPagesForFieldResolution
48240
48555
  ]
48241
48556
  );
48242
- const headerFooterEditHandlers = React.useMemo(
48557
+ const headerFooterEditHandlers = React2.useMemo(
48243
48558
  () => ({
48244
48559
  registerElement: registerSectionParagraphElement,
48245
48560
  readDraftHtml: readSectionParagraphDraft,
@@ -48255,7 +48570,7 @@ ${currentText.slice(end)}`;
48255
48570
  writeSectionParagraphDraft
48256
48571
  ]
48257
48572
  );
48258
- const activateHeaderFooterEdit = React.useCallback(
48573
+ const activateHeaderFooterEdit = React2.useCallback(
48259
48574
  (region, partName, pageIndex, options) => {
48260
48575
  if (isReadOnly || !partName) {
48261
48576
  return;
@@ -48282,6 +48597,8 @@ ${currentText.slice(end)}`;
48282
48597
  "div",
48283
48598
  {
48284
48599
  "data-testid": "docx-editor-viewer",
48600
+ "data-docx-zoom-level": viewerZoom.level,
48601
+ "data-docx-resolved-zoom": viewerZoom.resolvedZoom,
48285
48602
  ref: viewerRootRef,
48286
48603
  className,
48287
48604
  style: {
@@ -48290,7 +48607,8 @@ ${currentText.slice(end)}`;
48290
48607
  gap: DOC_PAGE_BREAK_GAP,
48291
48608
  minHeight: hideDocumentUntilPaginationSettled && stableHiddenDocumentHeightPx > 0 ? stableHiddenDocumentHeightPx : void 0,
48292
48609
  backgroundColor: pageGapBackgroundColor ?? "transparent",
48293
- ...style
48610
+ ...style,
48611
+ zoom: builtInViewerZoomScale
48294
48612
  },
48295
48613
  onDragOver: onCanvasDragOver,
48296
48614
  onDragLeave: onCanvasDragLeave,
@@ -48911,7 +49229,7 @@ ${currentText.slice(end)}`;
48911
49229
  const explicitColumnBreakParagraphSegments = columnNode.type === "paragraph" && !columnSegment.tableRowRange && !columnSegment.tableRowSlice && !columnSegment.paragraphLineRange && !explicitColumnWidthsPx && (sectionColumns?.count ?? 0) > 1 ? splitParagraphAtExplicitColumnBreaks(columnNode) : void 0;
48912
49230
  if (explicitColumnBreakParagraphSegments && explicitColumnBreakParagraphSegments.length > 1) {
48913
49231
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48914
- React.Fragment,
49232
+ React2.Fragment,
48915
49233
  {
48916
49234
  children: explicitColumnBreakParagraphSegments.map(
48917
49235
  (segmentParagraph, segmentIndex) => {
@@ -48982,7 +49300,7 @@ ${currentText.slice(end)}`;
48982
49300
  };
48983
49301
  if (!sectionColumns || sectionColumns.count <= 1 || requiresPlainFlowRender) {
48984
49302
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48985
- React.Fragment,
49303
+ React2.Fragment,
48986
49304
  {
48987
49305
  children: renderNodeSegments(group.segments, {
48988
49306
  pageIndex,
@@ -49042,7 +49360,7 @@ ${currentText.slice(end)}`;
49042
49360
  return null;
49043
49361
  }
49044
49362
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49045
- React.Fragment,
49363
+ React2.Fragment,
49046
49364
  {
49047
49365
  children: renderDocumentNode(
49048
49366
  overlayNode,
@@ -49370,7 +49688,7 @@ ${currentText.slice(end)}`;
49370
49688
  )
49371
49689
  )}` : ""}` : overlaySegment.paragraphLineRange ? `lines-${overlaySegment.paragraphLineRange.startLineIndex}-${overlaySegment.paragraphLineRange.endLineIndex}` : "all";
49372
49690
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49373
- React.Fragment,
49691
+ React2.Fragment,
49374
49692
  {
49375
49693
  children: renderDocumentNode(
49376
49694
  overlayNode,
@@ -52150,10 +52468,10 @@ function headingFontSize(level) {
52150
52468
  }
52151
52469
  }
52152
52470
  function useDocxModel(file) {
52153
- const [state, setState] = React2.useState({
52471
+ const [state, setState] = React3.useState({
52154
52472
  isLoading: Boolean(file)
52155
52473
  });
52156
- React2.useEffect(() => {
52474
+ React3.useEffect(() => {
52157
52475
  if (!file) {
52158
52476
  setState({ isLoading: false });
52159
52477
  return;
@@ -52381,7 +52699,7 @@ var containerStyle = {
52381
52699
  };
52382
52700
  function renderBlock(block) {
52383
52701
  if (block.kind === "table") {
52384
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(React2.Fragment, { children: renderTable(block) }, block.id);
52702
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(React3.Fragment, { children: renderTable(block) }, block.id);
52385
52703
  }
52386
52704
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
52387
52705
  "p",
@@ -52405,6 +52723,9 @@ function ReactDocxViewer({
52405
52723
  loadEmbeddedFonts = true,
52406
52724
  pageIndexes,
52407
52725
  className,
52726
+ zoom,
52727
+ defaultZoom,
52728
+ onZoomChange,
52408
52729
  layoutOptions,
52409
52730
  emptyState
52410
52731
  }) {
@@ -52414,12 +52735,12 @@ function ReactDocxViewer({
52414
52735
  error
52415
52736
  } = useDocxModel(model || document2 ? void 0 : file);
52416
52737
  const resolvedModel = model ?? document2?.model ?? parsedModel;
52417
- React2.useEffect(() => {
52738
+ React3.useEffect(() => {
52418
52739
  if (document2 && loadEmbeddedFonts && !document2.embeddedFontsLoaded) {
52419
52740
  void document2.loadEmbeddedFonts();
52420
52741
  }
52421
52742
  }, [document2, loadEmbeddedFonts]);
52422
- const modelWithSections = React2.useMemo(() => {
52743
+ const modelWithSections = React3.useMemo(() => {
52423
52744
  if (!resolvedModel) {
52424
52745
  return void 0;
52425
52746
  }
@@ -52433,7 +52754,7 @@ function ReactDocxViewer({
52433
52754
  nodes: [...headerNodes, ...resolvedModel.nodes, ...footerNodes]
52434
52755
  };
52435
52756
  }, [resolvedModel]);
52436
- const resolvedLayoutOptions = React2.useMemo(() => {
52757
+ const resolvedLayoutOptions = React3.useMemo(() => {
52437
52758
  if (!resolvedModel) {
52438
52759
  return layoutOptions;
52439
52760
  }
@@ -52444,18 +52765,28 @@ function ReactDocxViewer({
52444
52765
  pageHeight: layoutOptions?.pageHeight ?? documentLayout.pageHeightPx
52445
52766
  };
52446
52767
  }, [layoutOptions, resolvedModel]);
52447
- const pages = React2.useMemo(() => {
52768
+ const pages = React3.useMemo(() => {
52448
52769
  if (!modelWithSections) {
52449
52770
  return [];
52450
52771
  }
52451
52772
  return layoutDocument(modelWithSections, resolvedLayoutOptions);
52452
52773
  }, [modelWithSections, resolvedLayoutOptions]);
52453
- const requestedPageIndexSet = React2.useMemo(
52774
+ const requestedPageIndexSet = React3.useMemo(
52454
52775
  () => pageIndexes === void 0 ? void 0 : new Set(
52455
52776
  pageIndexes.filter((pageIndex) => Number.isFinite(pageIndex)).map((pageIndex) => Math.trunc(pageIndex))
52456
52777
  ),
52457
52778
  [pageIndexes]
52458
52779
  );
52780
+ const viewerRootRef = React3.useRef(null);
52781
+ const viewerZoom = useViewerZoom({
52782
+ zoom,
52783
+ defaultZoom,
52784
+ onZoomChange,
52785
+ rootRef: viewerRootRef,
52786
+ contentWidth: resolvedLayoutOptions?.pageWidth ?? DEFAULT_DOCUMENT_LAYOUT.pageWidthPx,
52787
+ contentHeight: resolvedLayoutOptions?.pageHeight ?? DEFAULT_DOCUMENT_LAYOUT.pageHeightPx,
52788
+ pageSelector: "[data-page-index]"
52789
+ });
52459
52790
  if (isLoading) {
52460
52791
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className, children: "Loading DOCX..." });
52461
52792
  }
@@ -52474,9 +52805,12 @@ function ReactDocxViewer({
52474
52805
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
52475
52806
  "div",
52476
52807
  {
52808
+ ref: viewerRootRef,
52477
52809
  className,
52478
52810
  "data-testid": "react-docx-viewer",
52479
- style: containerStyle,
52811
+ "data-docx-zoom-level": viewerZoom.level,
52812
+ "data-docx-resolved-zoom": viewerZoom.resolvedZoom,
52813
+ style: { ...containerStyle, zoom: viewerZoom.resolvedZoom / 100 },
52480
52814
  children: pages.map(
52481
52815
  (page, pageIndex) => requestedPageIndexSet && !requestedPageIndexSet.has(pageIndex) ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
52482
52816
  "section",