@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/README.md +19 -0
- package/dist/index.cjs +970 -636
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +969 -636
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "./chunk-AKDFE4ZH.js";
|
|
27
27
|
|
|
28
28
|
// src/index.tsx
|
|
29
|
-
import * as
|
|
29
|
+
import * as React3 from "react";
|
|
30
30
|
import { flushSync as flushSync2 } from "react-dom";
|
|
31
31
|
|
|
32
32
|
// ../layout-engine/src/index.ts
|
|
@@ -449,7 +449,7 @@ async function importDocxBuffer(buffer, options = {}) {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
// src/editor.tsx
|
|
452
|
-
import * as
|
|
452
|
+
import * as React2 from "react";
|
|
453
453
|
import { flushSync } from "react-dom";
|
|
454
454
|
|
|
455
455
|
// src/pointer-drag.ts
|
|
@@ -633,6 +633,246 @@ function startObjectDrag(options) {
|
|
|
633
633
|
return cancel;
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
+
// src/viewer-zoom.ts
|
|
637
|
+
import * as React from "react";
|
|
638
|
+
var VIEWER_ZOOM_MIN = 50;
|
|
639
|
+
var VIEWER_ZOOM_MAX = 200;
|
|
640
|
+
function normalizeViewerZoomLevel(level) {
|
|
641
|
+
if (typeof level !== "number") {
|
|
642
|
+
return level;
|
|
643
|
+
}
|
|
644
|
+
if (!Number.isFinite(level)) {
|
|
645
|
+
return 100;
|
|
646
|
+
}
|
|
647
|
+
return Math.max(VIEWER_ZOOM_MIN, Math.min(VIEWER_ZOOM_MAX, level));
|
|
648
|
+
}
|
|
649
|
+
function resolveViewerZoom(level, dimensions) {
|
|
650
|
+
const normalizedLevel = normalizeViewerZoomLevel(level);
|
|
651
|
+
if (typeof normalizedLevel === "number") {
|
|
652
|
+
return normalizedLevel;
|
|
653
|
+
}
|
|
654
|
+
const safeContentWidth = Math.max(1, dimensions.contentWidth);
|
|
655
|
+
const safeContentHeight = Math.max(1, dimensions.contentHeight);
|
|
656
|
+
const fitWidth = Math.max(1, dimensions.viewportWidth) / safeContentWidth * 100;
|
|
657
|
+
const fitHeight = Math.max(1, dimensions.viewportHeight) / safeContentHeight * 100;
|
|
658
|
+
const resolved = normalizedLevel === "fit-page" ? Math.min(fitWidth, fitHeight) : normalizedLevel === "automatic" ? Math.min(fitWidth, 100) : fitWidth;
|
|
659
|
+
return Math.max(
|
|
660
|
+
VIEWER_ZOOM_MIN,
|
|
661
|
+
Math.min(VIEWER_ZOOM_MAX, resolved)
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
function isWindowScroller(element) {
|
|
665
|
+
return element === document.documentElement || element === document.body || element === document.scrollingElement;
|
|
666
|
+
}
|
|
667
|
+
function nearestScrollableAncestor(element) {
|
|
668
|
+
let current = element.parentElement;
|
|
669
|
+
while (current) {
|
|
670
|
+
const style = window.getComputedStyle(current);
|
|
671
|
+
if (/(auto|scroll|overlay|hidden)/.test(`${style.overflow} ${style.overflowY}`)) {
|
|
672
|
+
return current;
|
|
673
|
+
}
|
|
674
|
+
current = current.parentElement;
|
|
675
|
+
}
|
|
676
|
+
return document.scrollingElement ?? document.documentElement;
|
|
677
|
+
}
|
|
678
|
+
function elementPadding(element) {
|
|
679
|
+
const style = window.getComputedStyle(element);
|
|
680
|
+
const number = (value) => {
|
|
681
|
+
const parsed = Number.parseFloat(value);
|
|
682
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
683
|
+
};
|
|
684
|
+
return {
|
|
685
|
+
horizontal: number(style.paddingLeft) + number(style.paddingRight),
|
|
686
|
+
vertical: number(style.paddingTop) + number(style.paddingBottom)
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function viewportRect(scroller) {
|
|
690
|
+
if (isWindowScroller(scroller)) {
|
|
691
|
+
return { top: 0, bottom: window.innerHeight };
|
|
692
|
+
}
|
|
693
|
+
const rect = scroller.getBoundingClientRect();
|
|
694
|
+
return { top: rect.top, bottom: rect.bottom };
|
|
695
|
+
}
|
|
696
|
+
function captureAnchor(root, scroller, pageSelector) {
|
|
697
|
+
const viewport = viewportRect(scroller);
|
|
698
|
+
let best;
|
|
699
|
+
root.querySelectorAll(pageSelector).forEach((element2) => {
|
|
700
|
+
const rect2 = element2.getBoundingClientRect();
|
|
701
|
+
const visible = Math.max(
|
|
702
|
+
0,
|
|
703
|
+
Math.min(rect2.bottom, viewport.bottom) - Math.max(rect2.top, viewport.top)
|
|
704
|
+
);
|
|
705
|
+
if (!best || visible > best.visible) {
|
|
706
|
+
best = { element: element2, visible };
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
if (!best || best.visible <= 0) {
|
|
710
|
+
return void 0;
|
|
711
|
+
}
|
|
712
|
+
const element = best.element;
|
|
713
|
+
const rect = element.getBoundingClientRect();
|
|
714
|
+
const pageIndex = element.dataset.docxPageIndex ?? element.dataset.pageIndex ?? element.dataset.page;
|
|
715
|
+
if (!pageIndex || rect.height <= 0) {
|
|
716
|
+
return void 0;
|
|
717
|
+
}
|
|
718
|
+
return {
|
|
719
|
+
pageIndex,
|
|
720
|
+
progress: Math.max(0, Math.min(1, (viewport.top - rect.top) / rect.height))
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
function restoreAnchor(root, scroller, pageSelector, anchor) {
|
|
724
|
+
const page = Array.from(root.querySelectorAll(pageSelector)).find(
|
|
725
|
+
(element) => (element.dataset.docxPageIndex ?? element.dataset.pageIndex ?? element.dataset.page) === anchor.pageIndex
|
|
726
|
+
);
|
|
727
|
+
if (!page) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const viewport = viewportRect(scroller);
|
|
731
|
+
const rect = page.getBoundingClientRect();
|
|
732
|
+
const desiredTop = viewport.top - anchor.progress * rect.height;
|
|
733
|
+
const delta = rect.top - desiredTop;
|
|
734
|
+
if (Math.abs(delta) < 0.5) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (isWindowScroller(scroller)) {
|
|
738
|
+
window.scrollBy(0, delta);
|
|
739
|
+
} else {
|
|
740
|
+
scroller.scrollTop += delta;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
function useViewerZoom({
|
|
744
|
+
zoom,
|
|
745
|
+
defaultZoom = 100,
|
|
746
|
+
onZoomChange,
|
|
747
|
+
rootRef,
|
|
748
|
+
contentWidth,
|
|
749
|
+
contentHeight,
|
|
750
|
+
pageSelector,
|
|
751
|
+
onBridgeChange
|
|
752
|
+
}) {
|
|
753
|
+
const controlled = zoom !== void 0;
|
|
754
|
+
const [uncontrolledLevel, setUncontrolledLevel] = React.useState(
|
|
755
|
+
() => normalizeViewerZoomLevel(defaultZoom)
|
|
756
|
+
);
|
|
757
|
+
const level = normalizeViewerZoomLevel(controlled ? zoom : uncontrolledLevel);
|
|
758
|
+
const levelRef = React.useRef(level);
|
|
759
|
+
levelRef.current = level;
|
|
760
|
+
const [resolvedZoom, setResolvedZoom] = React.useState(
|
|
761
|
+
() => typeof level === "number" ? level : 100
|
|
762
|
+
);
|
|
763
|
+
const resolvedZoomRef = React.useRef(resolvedZoom);
|
|
764
|
+
resolvedZoomRef.current = resolvedZoom;
|
|
765
|
+
const onZoomChangeRef = React.useRef(onZoomChange);
|
|
766
|
+
onZoomChangeRef.current = onZoomChange;
|
|
767
|
+
const controlledRef = React.useRef(controlled);
|
|
768
|
+
controlledRef.current = controlled;
|
|
769
|
+
const dimensionsRef = React.useRef(
|
|
770
|
+
void 0
|
|
771
|
+
);
|
|
772
|
+
const pendingAnchorRef = React.useRef(void 0);
|
|
773
|
+
const scrollerRef = React.useRef(void 0);
|
|
774
|
+
const lastEmittedRef = React.useRef(void 0);
|
|
775
|
+
const emit = React.useCallback((state) => {
|
|
776
|
+
const key = `${state.level}:${state.resolvedZoom.toFixed(4)}`;
|
|
777
|
+
if (lastEmittedRef.current === key) {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
lastEmittedRef.current = key;
|
|
781
|
+
onZoomChangeRef.current?.(state);
|
|
782
|
+
}, []);
|
|
783
|
+
const setLevel = React.useCallback(
|
|
784
|
+
(nextLevel) => {
|
|
785
|
+
const normalized = normalizeViewerZoomLevel(nextLevel);
|
|
786
|
+
const root = rootRef.current;
|
|
787
|
+
const scroller = root ? nearestScrollableAncestor(root) : void 0;
|
|
788
|
+
if (root && scroller) {
|
|
789
|
+
pendingAnchorRef.current = captureAnchor(root, scroller, pageSelector);
|
|
790
|
+
}
|
|
791
|
+
const nextResolved = typeof normalized === "number" ? normalized : dimensionsRef.current ? resolveViewerZoom(normalized, dimensionsRef.current) : resolvedZoomRef.current;
|
|
792
|
+
if (!controlledRef.current) {
|
|
793
|
+
levelRef.current = normalized;
|
|
794
|
+
resolvedZoomRef.current = nextResolved;
|
|
795
|
+
setUncontrolledLevel(normalized);
|
|
796
|
+
setResolvedZoom(nextResolved);
|
|
797
|
+
}
|
|
798
|
+
emit({ level: normalized, resolvedZoom: nextResolved });
|
|
799
|
+
},
|
|
800
|
+
[emit, pageSelector, rootRef]
|
|
801
|
+
);
|
|
802
|
+
const bridge = React.useMemo(
|
|
803
|
+
() => ({
|
|
804
|
+
setZoom: setLevel,
|
|
805
|
+
getZoom: () => levelRef.current,
|
|
806
|
+
getResolvedZoom: () => resolvedZoomRef.current
|
|
807
|
+
}),
|
|
808
|
+
[setLevel]
|
|
809
|
+
);
|
|
810
|
+
React.useLayoutEffect(() => {
|
|
811
|
+
onBridgeChange?.(bridge);
|
|
812
|
+
return () => onBridgeChange?.(void 0);
|
|
813
|
+
}, [bridge, onBridgeChange]);
|
|
814
|
+
React.useLayoutEffect(() => {
|
|
815
|
+
const root = rootRef.current;
|
|
816
|
+
if (!root || typeof window === "undefined") {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const scroller = nearestScrollableAncestor(root);
|
|
820
|
+
scrollerRef.current = scroller;
|
|
821
|
+
let frame = 0;
|
|
822
|
+
const recalculate = () => {
|
|
823
|
+
frame = 0;
|
|
824
|
+
const scrollerPadding = elementPadding(scroller);
|
|
825
|
+
const rootPadding = elementPadding(root);
|
|
826
|
+
const viewportWidth = (isWindowScroller(scroller) ? window.innerWidth : scroller.clientWidth) - scrollerPadding.horizontal;
|
|
827
|
+
const viewportHeight = (isWindowScroller(scroller) ? window.innerHeight : scroller.clientHeight) - scrollerPadding.vertical;
|
|
828
|
+
const dimensions = {
|
|
829
|
+
viewportWidth,
|
|
830
|
+
viewportHeight,
|
|
831
|
+
contentWidth: contentWidth + rootPadding.horizontal,
|
|
832
|
+
contentHeight: contentHeight + rootPadding.vertical
|
|
833
|
+
};
|
|
834
|
+
dimensionsRef.current = dimensions;
|
|
835
|
+
const nextResolved = resolveViewerZoom(levelRef.current, dimensions);
|
|
836
|
+
if (Math.abs(nextResolved - resolvedZoomRef.current) < 0.01) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
pendingAnchorRef.current = captureAnchor(root, scroller, pageSelector);
|
|
840
|
+
resolvedZoomRef.current = nextResolved;
|
|
841
|
+
setResolvedZoom(nextResolved);
|
|
842
|
+
emit({ level: levelRef.current, resolvedZoom: nextResolved });
|
|
843
|
+
};
|
|
844
|
+
const schedule = () => {
|
|
845
|
+
if (frame) {
|
|
846
|
+
cancelAnimationFrame(frame);
|
|
847
|
+
}
|
|
848
|
+
frame = requestAnimationFrame(recalculate);
|
|
849
|
+
};
|
|
850
|
+
const observer = typeof ResizeObserver === "function" ? new ResizeObserver(schedule) : void 0;
|
|
851
|
+
observer?.observe(scroller);
|
|
852
|
+
observer?.observe(root);
|
|
853
|
+
window.addEventListener("resize", schedule);
|
|
854
|
+
recalculate();
|
|
855
|
+
return () => {
|
|
856
|
+
if (frame) {
|
|
857
|
+
cancelAnimationFrame(frame);
|
|
858
|
+
}
|
|
859
|
+
observer?.disconnect();
|
|
860
|
+
window.removeEventListener("resize", schedule);
|
|
861
|
+
};
|
|
862
|
+
}, [contentHeight, contentWidth, emit, pageSelector, rootRef, level]);
|
|
863
|
+
React.useLayoutEffect(() => {
|
|
864
|
+
const root = rootRef.current;
|
|
865
|
+
const scroller = scrollerRef.current;
|
|
866
|
+
const anchor = pendingAnchorRef.current;
|
|
867
|
+
if (!root || !scroller || !anchor) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
pendingAnchorRef.current = void 0;
|
|
871
|
+
restoreAnchor(root, scroller, pageSelector, anchor);
|
|
872
|
+
}, [pageSelector, resolvedZoom, rootRef]);
|
|
873
|
+
return { level, resolvedZoom };
|
|
874
|
+
}
|
|
875
|
+
|
|
636
876
|
// src/image-drop.ts
|
|
637
877
|
function copyModelForParagraphEdits(model, locations) {
|
|
638
878
|
const copies = /* @__PURE__ */ new Map();
|
|
@@ -6717,7 +6957,7 @@ function clampNumber(value, min, max) {
|
|
|
6717
6957
|
function hasVerticalScrollOverflow(value) {
|
|
6718
6958
|
return value === "auto" || value === "scroll" || value === "overlay" || value === "hidden";
|
|
6719
6959
|
}
|
|
6720
|
-
function
|
|
6960
|
+
function nearestScrollableAncestor2(element) {
|
|
6721
6961
|
let current = element;
|
|
6722
6962
|
while (current) {
|
|
6723
6963
|
const style = window.getComputedStyle(current);
|
|
@@ -8444,6 +8684,18 @@ function normalizeTextRange(range) {
|
|
|
8444
8684
|
end: range.start
|
|
8445
8685
|
};
|
|
8446
8686
|
}
|
|
8687
|
+
var viewerZoomBridgeByController = /* @__PURE__ */ new WeakMap();
|
|
8688
|
+
function viewerZoomControllerKey(editor) {
|
|
8689
|
+
return editor.syncPaginationInfo;
|
|
8690
|
+
}
|
|
8691
|
+
function setViewerZoomBridge(editor, bridge) {
|
|
8692
|
+
const key = viewerZoomControllerKey(editor);
|
|
8693
|
+
if (bridge) {
|
|
8694
|
+
viewerZoomBridgeByController.set(key, bridge);
|
|
8695
|
+
} else {
|
|
8696
|
+
viewerZoomBridgeByController.delete(key);
|
|
8697
|
+
}
|
|
8698
|
+
}
|
|
8447
8699
|
var defaultStarterModel = {
|
|
8448
8700
|
nodes: [
|
|
8449
8701
|
{
|
|
@@ -22812,14 +23064,14 @@ function updateSectionImageFloatingAtLocation(model, location, patch) {
|
|
|
22812
23064
|
return changed ? next : model;
|
|
22813
23065
|
}
|
|
22814
23066
|
function useDocxEditor(options = {}) {
|
|
22815
|
-
const [starterTemplate] =
|
|
23067
|
+
const [starterTemplate] = React2.useState(
|
|
22816
23068
|
() => cloneDocModelWithBlockIds(options.starterModel ?? defaultStarterModel)
|
|
22817
23069
|
);
|
|
22818
|
-
const starterTemplateRef =
|
|
22819
|
-
const [initialModel] =
|
|
23070
|
+
const starterTemplateRef = React2.useRef(starterTemplate);
|
|
23071
|
+
const [initialModel] = React2.useState(
|
|
22820
23072
|
() => cloneDocModelWithBlockIds(options.document?.model ?? starterTemplate)
|
|
22821
23073
|
);
|
|
22822
|
-
const [editorState, dispatchCanonicalEditorState] =
|
|
23074
|
+
const [editorState, dispatchCanonicalEditorState] = React2.useReducer(
|
|
22823
23075
|
reduceDocxEditorState,
|
|
22824
23076
|
initialModel,
|
|
22825
23077
|
(initialModel2) => ({
|
|
@@ -22837,8 +23089,8 @@ function useDocxEditor(options = {}) {
|
|
|
22837
23089
|
})
|
|
22838
23090
|
);
|
|
22839
23091
|
const { model, selection, activeTextRange, pendingRunStyle, history } = editorState;
|
|
22840
|
-
const canonicalEditorStateRef =
|
|
22841
|
-
const applyCanonicalEditorStateAction =
|
|
23092
|
+
const canonicalEditorStateRef = React2.useRef(editorState);
|
|
23093
|
+
const applyCanonicalEditorStateAction = React2.useCallback(
|
|
22842
23094
|
(action) => {
|
|
22843
23095
|
const previous = canonicalEditorStateRef.current;
|
|
22844
23096
|
const next = reduceDocxEditorState(previous, action);
|
|
@@ -22850,7 +23102,7 @@ function useDocxEditor(options = {}) {
|
|
|
22850
23102
|
},
|
|
22851
23103
|
[]
|
|
22852
23104
|
);
|
|
22853
|
-
const setModel =
|
|
23105
|
+
const setModel = React2.useCallback(
|
|
22854
23106
|
(value) => {
|
|
22855
23107
|
const currentModel = canonicalEditorStateRef.current.model;
|
|
22856
23108
|
const nextModel = typeof value === "function" ? value(currentModel) : value;
|
|
@@ -22862,7 +23114,7 @@ function useDocxEditor(options = {}) {
|
|
|
22862
23114
|
},
|
|
22863
23115
|
[applyCanonicalEditorStateAction]
|
|
22864
23116
|
);
|
|
22865
|
-
const setSelection =
|
|
23117
|
+
const setSelection = React2.useCallback(
|
|
22866
23118
|
(value) => {
|
|
22867
23119
|
const currentSelection = canonicalEditorStateRef.current.selection;
|
|
22868
23120
|
const nextSelection = typeof value === "function" ? value(currentSelection) : value;
|
|
@@ -22874,7 +23126,7 @@ function useDocxEditor(options = {}) {
|
|
|
22874
23126
|
},
|
|
22875
23127
|
[applyCanonicalEditorStateAction]
|
|
22876
23128
|
);
|
|
22877
|
-
const setActiveTextRangeState =
|
|
23129
|
+
const setActiveTextRangeState = React2.useCallback(
|
|
22878
23130
|
(value) => {
|
|
22879
23131
|
const currentRange = canonicalEditorStateRef.current.activeTextRange;
|
|
22880
23132
|
const nextRange = typeof value === "function" ? value(currentRange) : value;
|
|
@@ -22886,7 +23138,7 @@ function useDocxEditor(options = {}) {
|
|
|
22886
23138
|
},
|
|
22887
23139
|
[applyCanonicalEditorStateAction]
|
|
22888
23140
|
);
|
|
22889
|
-
const setPendingRunStyle =
|
|
23141
|
+
const setPendingRunStyle = React2.useCallback(
|
|
22890
23142
|
(value) => {
|
|
22891
23143
|
const currentStyle = canonicalEditorStateRef.current.pendingRunStyle;
|
|
22892
23144
|
const nextStyle = typeof value === "function" ? value(currentStyle) : value;
|
|
@@ -22898,7 +23150,7 @@ function useDocxEditor(options = {}) {
|
|
|
22898
23150
|
},
|
|
22899
23151
|
[applyCanonicalEditorStateAction]
|
|
22900
23152
|
);
|
|
22901
|
-
const setHistory =
|
|
23153
|
+
const setHistory = React2.useCallback(
|
|
22902
23154
|
(value) => {
|
|
22903
23155
|
const currentHistory = canonicalEditorStateRef.current.history;
|
|
22904
23156
|
const nextHistory = typeof value === "function" ? value(currentHistory) : value;
|
|
@@ -22909,61 +23161,65 @@ function useDocxEditor(options = {}) {
|
|
|
22909
23161
|
},
|
|
22910
23162
|
[applyCanonicalEditorStateAction]
|
|
22911
23163
|
);
|
|
22912
|
-
const [basePackage, setBasePackage] =
|
|
22913
|
-
const [documentLoadNonce, setDocumentLoadNonce] =
|
|
22914
|
-
const documentLoadNonceRef =
|
|
22915
|
-
const advanceDocumentLoadNonce =
|
|
23164
|
+
const [basePackage, setBasePackage] = React2.useState(options.document?.package);
|
|
23165
|
+
const [documentLoadNonce, setDocumentLoadNonce] = React2.useState(0);
|
|
23166
|
+
const documentLoadNonceRef = React2.useRef(0);
|
|
23167
|
+
const advanceDocumentLoadNonce = React2.useCallback(() => {
|
|
22916
23168
|
documentLoadNonceRef.current += 1;
|
|
22917
23169
|
setDocumentLoadNonce(documentLoadNonceRef.current);
|
|
22918
23170
|
}, []);
|
|
22919
|
-
const [fileName, setFileName] =
|
|
23171
|
+
const [fileName, setFileName] = React2.useState(
|
|
22920
23172
|
options.initialFileName ?? options.document?.fileName ?? "(new document)"
|
|
22921
23173
|
);
|
|
22922
|
-
const [selectedFormFieldLocation, setSelectedFormFieldLocation] =
|
|
22923
|
-
const [status, setStatus] =
|
|
23174
|
+
const [selectedFormFieldLocation, setSelectedFormFieldLocation] = React2.useState();
|
|
23175
|
+
const [status, setStatus] = React2.useState(
|
|
22924
23176
|
options.initialStatus ?? (options.document?.fileName ? `Loaded ${options.document.fileName}` : "Ready")
|
|
22925
23177
|
);
|
|
22926
|
-
const [importError, setImportError] =
|
|
22927
|
-
const [isImporting, setIsImporting] =
|
|
22928
|
-
const [documentTheme, setDocumentThemeState] =
|
|
22929
|
-
const [showTrackedChanges, setShowTrackedChangesState] =
|
|
22930
|
-
const [showComments, setShowCommentsState] =
|
|
23178
|
+
const [importError, setImportError] = React2.useState();
|
|
23179
|
+
const [isImporting, setIsImporting] = React2.useState(false);
|
|
23180
|
+
const [documentTheme, setDocumentThemeState] = React2.useState(options.initialDocumentTheme ?? "light");
|
|
23181
|
+
const [showTrackedChanges, setShowTrackedChangesState] = React2.useState(options.initialShowTrackedChanges ?? false);
|
|
23182
|
+
const [showComments, setShowCommentsState] = React2.useState(
|
|
22931
23183
|
options.initialShowComments ?? false
|
|
22932
23184
|
);
|
|
22933
|
-
const [paginationInfo, setPaginationInfo] =
|
|
23185
|
+
const [paginationInfo, setPaginationInfo] = React2.useState({
|
|
22934
23186
|
currentPage: 1,
|
|
22935
23187
|
totalPages: 1
|
|
22936
23188
|
});
|
|
22937
|
-
const
|
|
22938
|
-
|
|
22939
|
-
|
|
22940
|
-
|
|
22941
|
-
const
|
|
22942
|
-
const
|
|
23189
|
+
const fallbackZoomRef = React2.useRef({
|
|
23190
|
+
level: 100,
|
|
23191
|
+
resolvedZoom: 100
|
|
23192
|
+
});
|
|
23193
|
+
const activeImportAbortControllerRef = React2.useRef(void 0);
|
|
23194
|
+
const [historyRestoreRequest, setHistoryRestoreRequest] = React2.useState();
|
|
23195
|
+
const [selectionSessionKind, setSelectionSessionKind] = React2.useState("idle");
|
|
23196
|
+
const modelRef = React2.useRef(model);
|
|
23197
|
+
const selectionRef = React2.useRef(selection);
|
|
23198
|
+
const activeTextRangeRef = React2.useRef(
|
|
22943
23199
|
activeTextRange
|
|
22944
23200
|
);
|
|
22945
|
-
const pendingRunStyleRef =
|
|
23201
|
+
const pendingRunStyleRef = React2.useRef(
|
|
22946
23202
|
pendingRunStyle
|
|
22947
23203
|
);
|
|
22948
|
-
const suppressNextDomSelectionRestoreRef =
|
|
22949
|
-
const textCommitBurstRef =
|
|
23204
|
+
const suppressNextDomSelectionRestoreRef = React2.useRef(false);
|
|
23205
|
+
const textCommitBurstRef = React2.useRef(
|
|
22950
23206
|
void 0
|
|
22951
23207
|
);
|
|
22952
|
-
const domSelectionRestoreModelRef =
|
|
22953
|
-
const selectionSessionRef =
|
|
22954
|
-
const selectionSessionTimeoutRef =
|
|
22955
|
-
const lastInViewerActiveTextRangeRef =
|
|
22956
|
-
const suppressSelectionResetRef =
|
|
22957
|
-
const historyRestoreNonceRef =
|
|
22958
|
-
const embeddedFontLoadNonceRef =
|
|
22959
|
-
const loadedEmbeddedFontFacesRef =
|
|
22960
|
-
|
|
23208
|
+
const domSelectionRestoreModelRef = React2.useRef(model);
|
|
23209
|
+
const selectionSessionRef = React2.useRef("idle");
|
|
23210
|
+
const selectionSessionTimeoutRef = React2.useRef(null);
|
|
23211
|
+
const lastInViewerActiveTextRangeRef = React2.useRef(void 0);
|
|
23212
|
+
const suppressSelectionResetRef = React2.useRef(false);
|
|
23213
|
+
const historyRestoreNonceRef = React2.useRef(0);
|
|
23214
|
+
const embeddedFontLoadNonceRef = React2.useRef(0);
|
|
23215
|
+
const loadedEmbeddedFontFacesRef = React2.useRef([]);
|
|
23216
|
+
React2.useEffect(() => {
|
|
22961
23217
|
canonicalEditorStateRef.current = editorState;
|
|
22962
23218
|
}, [editorState]);
|
|
22963
|
-
|
|
23219
|
+
React2.useEffect(() => {
|
|
22964
23220
|
modelRef.current = model;
|
|
22965
23221
|
}, [model]);
|
|
22966
|
-
|
|
23222
|
+
React2.useEffect(() => {
|
|
22967
23223
|
if (typeof process === "undefined" || process.env?.NODE_ENV === "production") {
|
|
22968
23224
|
return;
|
|
22969
23225
|
}
|
|
@@ -22976,10 +23232,10 @@ function useDocxEditor(options = {}) {
|
|
|
22976
23232
|
);
|
|
22977
23233
|
}
|
|
22978
23234
|
}, [model]);
|
|
22979
|
-
|
|
23235
|
+
React2.useEffect(() => {
|
|
22980
23236
|
selectionRef.current = selection;
|
|
22981
23237
|
}, [selection]);
|
|
22982
|
-
const selectedFormField =
|
|
23238
|
+
const selectedFormField = React2.useMemo(() => {
|
|
22983
23239
|
if (!selectedFormFieldLocation) {
|
|
22984
23240
|
return void 0;
|
|
22985
23241
|
}
|
|
@@ -23001,22 +23257,22 @@ function useDocxEditor(options = {}) {
|
|
|
23001
23257
|
field: child
|
|
23002
23258
|
};
|
|
23003
23259
|
}, [model, selectedFormFieldLocation]);
|
|
23004
|
-
|
|
23260
|
+
React2.useEffect(() => {
|
|
23005
23261
|
activeTextRangeRef.current = activeTextRange;
|
|
23006
23262
|
if (activeTextRange) {
|
|
23007
23263
|
lastInViewerActiveTextRangeRef.current = cloneTextRange(activeTextRange);
|
|
23008
23264
|
}
|
|
23009
23265
|
}, [activeTextRange]);
|
|
23010
|
-
|
|
23266
|
+
React2.useEffect(() => {
|
|
23011
23267
|
pendingRunStyleRef.current = pendingRunStyle;
|
|
23012
23268
|
}, [pendingRunStyle]);
|
|
23013
|
-
|
|
23269
|
+
React2.useEffect(() => {
|
|
23014
23270
|
setPaginationInfo({
|
|
23015
23271
|
currentPage: 1,
|
|
23016
23272
|
totalPages: 1
|
|
23017
23273
|
});
|
|
23018
23274
|
}, [documentLoadNonce]);
|
|
23019
|
-
const clearSelectionSession =
|
|
23275
|
+
const clearSelectionSession = React2.useCallback(
|
|
23020
23276
|
(expectedKind) => {
|
|
23021
23277
|
if (expectedKind && selectionSessionRef.current !== expectedKind) {
|
|
23022
23278
|
return;
|
|
@@ -23032,7 +23288,7 @@ function useDocxEditor(options = {}) {
|
|
|
23032
23288
|
},
|
|
23033
23289
|
[]
|
|
23034
23290
|
);
|
|
23035
|
-
const beginSelectionSession =
|
|
23291
|
+
const beginSelectionSession = React2.useCallback(
|
|
23036
23292
|
(kind, options2) => {
|
|
23037
23293
|
if (selectionSessionTimeoutRef.current !== null && typeof window !== "undefined") {
|
|
23038
23294
|
window.clearTimeout(selectionSessionTimeoutRef.current);
|
|
@@ -23055,7 +23311,7 @@ function useDocxEditor(options = {}) {
|
|
|
23055
23311
|
},
|
|
23056
23312
|
[]
|
|
23057
23313
|
);
|
|
23058
|
-
|
|
23314
|
+
React2.useEffect(() => {
|
|
23059
23315
|
const normalizedCursorState = normalizeEditorCursorStateForModel(
|
|
23060
23316
|
model,
|
|
23061
23317
|
selection,
|
|
@@ -23106,7 +23362,7 @@ function useDocxEditor(options = {}) {
|
|
|
23106
23362
|
activeTextRange: cloneTextRange(nextRange)
|
|
23107
23363
|
});
|
|
23108
23364
|
}, [model]);
|
|
23109
|
-
|
|
23365
|
+
React2.useEffect(() => {
|
|
23110
23366
|
if (!selectedFormFieldLocation) {
|
|
23111
23367
|
return;
|
|
23112
23368
|
}
|
|
@@ -23119,14 +23375,14 @@ function useDocxEditor(options = {}) {
|
|
|
23119
23375
|
setSelectedFormFieldLocation(void 0);
|
|
23120
23376
|
}
|
|
23121
23377
|
}, [model, selectedFormFieldLocation]);
|
|
23122
|
-
const selectedParagraphLocation =
|
|
23378
|
+
const selectedParagraphLocation = React2.useMemo(
|
|
23123
23379
|
() => resolveSelectedParagraphLocation(selection, activeTextRange),
|
|
23124
23380
|
[activeTextRange, selection]
|
|
23125
23381
|
);
|
|
23126
|
-
const selectedParagraph =
|
|
23382
|
+
const selectedParagraph = React2.useMemo(() => {
|
|
23127
23383
|
return getParagraphAtLocation(model, selectedParagraphLocation).paragraph;
|
|
23128
23384
|
}, [model, selectedParagraphLocation]);
|
|
23129
|
-
const availableParagraphStyles =
|
|
23385
|
+
const availableParagraphStyles = React2.useMemo(() => {
|
|
23130
23386
|
const embeddedStyles = model.metadata.paragraphStyles ?? [];
|
|
23131
23387
|
if (embeddedStyles.length > 0) {
|
|
23132
23388
|
return normalizeParagraphStyleDefinitionsForUi(embeddedStyles);
|
|
@@ -23135,11 +23391,11 @@ function useDocxEditor(options = {}) {
|
|
|
23135
23391
|
defaultStarterModel.metadata.paragraphStyles
|
|
23136
23392
|
);
|
|
23137
23393
|
}, [model.metadata.paragraphStyles]);
|
|
23138
|
-
const paragraphStyleById =
|
|
23394
|
+
const paragraphStyleById = React2.useMemo(
|
|
23139
23395
|
() => new Map(availableParagraphStyles.map((style) => [style.id, style])),
|
|
23140
23396
|
[availableParagraphStyles]
|
|
23141
23397
|
);
|
|
23142
|
-
const selectedParagraphStyleId =
|
|
23398
|
+
const selectedParagraphStyleId = React2.useMemo(() => {
|
|
23143
23399
|
if (!selectedParagraph) {
|
|
23144
23400
|
return model.metadata.defaultParagraphStyleId ?? availableParagraphStyles.find((style) => style.isDefault)?.id;
|
|
23145
23401
|
}
|
|
@@ -23159,7 +23415,7 @@ function useDocxEditor(options = {}) {
|
|
|
23159
23415
|
availableParagraphStyles,
|
|
23160
23416
|
paragraphStyleById
|
|
23161
23417
|
]);
|
|
23162
|
-
const selectedLineSpacing =
|
|
23418
|
+
const selectedLineSpacing = React2.useMemo(() => {
|
|
23163
23419
|
const lineTwipsRaw = selectedParagraph?.style?.spacing?.lineTwips;
|
|
23164
23420
|
const lineTwips = Number.isFinite(lineTwipsRaw) ? Math.max(1, Math.round(lineTwipsRaw)) : void 0;
|
|
23165
23421
|
const lineRule = selectedParagraph?.style?.spacing?.lineRule ?? "auto";
|
|
@@ -23174,7 +23430,7 @@ function useDocxEditor(options = {}) {
|
|
|
23174
23430
|
};
|
|
23175
23431
|
}, [selectedParagraph]);
|
|
23176
23432
|
const selectedBorderContext = selectedParagraphLocation.kind === "table-cell" ? "table" : "paragraph";
|
|
23177
|
-
const activeBorderPresets =
|
|
23433
|
+
const activeBorderPresets = React2.useMemo(() => {
|
|
23178
23434
|
if (selectedParagraphLocation.kind === "table-cell") {
|
|
23179
23435
|
const node = model.nodes[selectedParagraphLocation.tableIndex];
|
|
23180
23436
|
if (!node || node.type !== "table") {
|
|
@@ -23185,10 +23441,10 @@ function useDocxEditor(options = {}) {
|
|
|
23185
23441
|
}
|
|
23186
23442
|
return paragraphBorderPresetState(selectedParagraph?.style?.borders);
|
|
23187
23443
|
}, [model.nodes, selectedParagraph, selectedParagraphLocation]);
|
|
23188
|
-
const selectedRunStyleFromSelection =
|
|
23444
|
+
const selectedRunStyleFromSelection = React2.useMemo(() => {
|
|
23189
23445
|
return runStyleForEditorSelection(model, selection, activeTextRange);
|
|
23190
23446
|
}, [activeTextRange, model, selection]);
|
|
23191
|
-
const selectedRunStyle =
|
|
23447
|
+
const selectedRunStyle = React2.useMemo(() => {
|
|
23192
23448
|
const hasExpandedRange = Boolean(
|
|
23193
23449
|
activeTextRange && compareTextRangeBoundaries(activeTextRange.start, activeTextRange.end) < 0
|
|
23194
23450
|
);
|
|
@@ -23200,7 +23456,7 @@ function useDocxEditor(options = {}) {
|
|
|
23200
23456
|
...pendingRunStyle
|
|
23201
23457
|
};
|
|
23202
23458
|
}, [activeTextRange, pendingRunStyle, selectedRunStyleFromSelection]);
|
|
23203
|
-
const selectedLink =
|
|
23459
|
+
const selectedLink = React2.useMemo(() => {
|
|
23204
23460
|
if (!selectedParagraph || !activeTextRange) {
|
|
23205
23461
|
return void 0;
|
|
23206
23462
|
}
|
|
@@ -23238,11 +23494,11 @@ function useDocxEditor(options = {}) {
|
|
|
23238
23494
|
);
|
|
23239
23495
|
}, [activeTextRange, selectedParagraph, selectedParagraphLocation]);
|
|
23240
23496
|
const selectedListType = selectedParagraph ? paragraphListType(selectedParagraph, model.metadata.numberingDefinitions) : void 0;
|
|
23241
|
-
const trackedChanges =
|
|
23497
|
+
const trackedChanges = React2.useMemo(
|
|
23242
23498
|
() => collectTrackedChangesFromModel(model, documentLoadNonce),
|
|
23243
23499
|
[documentLoadNonce, model]
|
|
23244
23500
|
);
|
|
23245
|
-
const comments =
|
|
23501
|
+
const comments = React2.useMemo(
|
|
23246
23502
|
() => collectCommentsFromModel(model, documentLoadNonce),
|
|
23247
23503
|
[documentLoadNonce, model]
|
|
23248
23504
|
);
|
|
@@ -23250,38 +23506,38 @@ function useDocxEditor(options = {}) {
|
|
|
23250
23506
|
const hasOrderedList = selectedListType === "ordered";
|
|
23251
23507
|
const canUndo = history.past.length > 0;
|
|
23252
23508
|
const canRedo = history.future.length > 0;
|
|
23253
|
-
const pendingExportModelTransformerRef =
|
|
23254
|
-
const setDocumentTheme =
|
|
23509
|
+
const pendingExportModelTransformerRef = React2.useRef(void 0);
|
|
23510
|
+
const setDocumentTheme = React2.useCallback(
|
|
23255
23511
|
(theme) => {
|
|
23256
23512
|
setDocumentThemeState(theme);
|
|
23257
23513
|
},
|
|
23258
23514
|
[]
|
|
23259
23515
|
);
|
|
23260
|
-
const setShowTrackedChanges =
|
|
23516
|
+
const setShowTrackedChanges = React2.useCallback(
|
|
23261
23517
|
(nextShowTrackedChanges) => {
|
|
23262
23518
|
setShowTrackedChangesState(nextShowTrackedChanges);
|
|
23263
23519
|
},
|
|
23264
23520
|
[]
|
|
23265
23521
|
);
|
|
23266
|
-
const toggleShowTrackedChanges =
|
|
23522
|
+
const toggleShowTrackedChanges = React2.useCallback(() => {
|
|
23267
23523
|
setShowTrackedChangesState((current) => !current);
|
|
23268
23524
|
}, []);
|
|
23269
|
-
const setShowComments =
|
|
23525
|
+
const setShowComments = React2.useCallback(
|
|
23270
23526
|
(nextShowComments) => {
|
|
23271
23527
|
setShowCommentsState(nextShowComments);
|
|
23272
23528
|
},
|
|
23273
23529
|
[]
|
|
23274
23530
|
);
|
|
23275
|
-
const toggleShowComments =
|
|
23531
|
+
const toggleShowComments = React2.useCallback(() => {
|
|
23276
23532
|
setShowCommentsState((current) => !current);
|
|
23277
23533
|
}, []);
|
|
23278
|
-
const registerPendingExportModelTransformer =
|
|
23534
|
+
const registerPendingExportModelTransformer = React2.useCallback(
|
|
23279
23535
|
(transformer) => {
|
|
23280
23536
|
pendingExportModelTransformerRef.current = transformer;
|
|
23281
23537
|
},
|
|
23282
23538
|
[]
|
|
23283
23539
|
);
|
|
23284
|
-
const unloadEmbeddedFonts =
|
|
23540
|
+
const unloadEmbeddedFonts = React2.useCallback(() => {
|
|
23285
23541
|
if (typeof document !== "undefined" && "fonts" in document) {
|
|
23286
23542
|
loadedEmbeddedFontFacesRef.current.forEach((fontFace) => {
|
|
23287
23543
|
try {
|
|
@@ -23295,7 +23551,7 @@ function useDocxEditor(options = {}) {
|
|
|
23295
23551
|
}
|
|
23296
23552
|
loadedEmbeddedFontFacesRef.current = [];
|
|
23297
23553
|
}, []);
|
|
23298
|
-
const loadEmbeddedFontsFromPackage =
|
|
23554
|
+
const loadEmbeddedFontsFromPackage = React2.useCallback(
|
|
23299
23555
|
async (pkg) => {
|
|
23300
23556
|
embeddedFontLoadNonceRef.current += 1;
|
|
23301
23557
|
const requestNonce = embeddedFontLoadNonceRef.current;
|
|
@@ -23342,13 +23598,13 @@ function useDocxEditor(options = {}) {
|
|
|
23342
23598
|
},
|
|
23343
23599
|
[unloadEmbeddedFonts]
|
|
23344
23600
|
);
|
|
23345
|
-
|
|
23601
|
+
React2.useEffect(() => {
|
|
23346
23602
|
return () => {
|
|
23347
23603
|
activeImportAbortControllerRef.current?.abort();
|
|
23348
23604
|
unloadEmbeddedFonts();
|
|
23349
23605
|
};
|
|
23350
23606
|
}, [unloadEmbeddedFonts]);
|
|
23351
|
-
|
|
23607
|
+
React2.useEffect(() => {
|
|
23352
23608
|
if (!options.document || options.loadEmbeddedFonts === false || options.document.embeddedFontsLoaded) {
|
|
23353
23609
|
return;
|
|
23354
23610
|
}
|
|
@@ -23358,7 +23614,7 @@ function useDocxEditor(options = {}) {
|
|
|
23358
23614
|
options.document,
|
|
23359
23615
|
options.loadEmbeddedFonts
|
|
23360
23616
|
]);
|
|
23361
|
-
const dispatchEditorTransaction =
|
|
23617
|
+
const dispatchEditorTransaction = React2.useCallback(
|
|
23362
23618
|
(resolver) => {
|
|
23363
23619
|
const currentState = canonicalEditorStateRef.current;
|
|
23364
23620
|
const currentModel = currentState.model;
|
|
@@ -23452,14 +23708,14 @@ function useDocxEditor(options = {}) {
|
|
|
23452
23708
|
},
|
|
23453
23709
|
[applyCanonicalEditorStateAction]
|
|
23454
23710
|
);
|
|
23455
|
-
const annotationFailureStatus =
|
|
23711
|
+
const annotationFailureStatus = React2.useCallback(
|
|
23456
23712
|
(action, reason) => {
|
|
23457
23713
|
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";
|
|
23458
23714
|
return `${action} failed: ${detail}`;
|
|
23459
23715
|
},
|
|
23460
23716
|
[]
|
|
23461
23717
|
);
|
|
23462
|
-
const runTrackedChangeCommand =
|
|
23718
|
+
const runTrackedChangeCommand = React2.useCallback(
|
|
23463
23719
|
(action, change) => {
|
|
23464
23720
|
if (change.documentLoadNonce !== documentLoadNonceRef.current) {
|
|
23465
23721
|
const failure = { ok: false, reason: "stale" };
|
|
@@ -23529,15 +23785,15 @@ function useDocxEditor(options = {}) {
|
|
|
23529
23785
|
},
|
|
23530
23786
|
[annotationFailureStatus, dispatchEditorTransaction]
|
|
23531
23787
|
);
|
|
23532
|
-
const acceptTrackedChange =
|
|
23788
|
+
const acceptTrackedChange = React2.useCallback(
|
|
23533
23789
|
(change) => runTrackedChangeCommand("accept", change),
|
|
23534
23790
|
[runTrackedChangeCommand]
|
|
23535
23791
|
);
|
|
23536
|
-
const rejectTrackedChange =
|
|
23792
|
+
const rejectTrackedChange = React2.useCallback(
|
|
23537
23793
|
(change) => runTrackedChangeCommand("reject", change),
|
|
23538
23794
|
[runTrackedChangeCommand]
|
|
23539
23795
|
);
|
|
23540
|
-
const createComment =
|
|
23796
|
+
const createComment = React2.useCallback(
|
|
23541
23797
|
(text, commentOptions = {}) => {
|
|
23542
23798
|
let outcome = {
|
|
23543
23799
|
ok: false,
|
|
@@ -23582,7 +23838,7 @@ function useDocxEditor(options = {}) {
|
|
|
23582
23838
|
},
|
|
23583
23839
|
[annotationFailureStatus, dispatchEditorTransaction]
|
|
23584
23840
|
);
|
|
23585
|
-
const setCommentResolved2 =
|
|
23841
|
+
const setCommentResolved2 = React2.useCallback(
|
|
23586
23842
|
(comment, resolved) => {
|
|
23587
23843
|
if (comment.documentLoadNonce !== documentLoadNonceRef.current) {
|
|
23588
23844
|
const failure = { ok: false, reason: "stale" };
|
|
@@ -23650,7 +23906,7 @@ function useDocxEditor(options = {}) {
|
|
|
23650
23906
|
},
|
|
23651
23907
|
[annotationFailureStatus, dispatchEditorTransaction]
|
|
23652
23908
|
);
|
|
23653
|
-
const applyModelChange =
|
|
23909
|
+
const applyModelChange = React2.useCallback(
|
|
23654
23910
|
(updater, successStatus) => {
|
|
23655
23911
|
dispatchEditorTransaction((current) => {
|
|
23656
23912
|
const nextModel = updater(current.model);
|
|
@@ -23666,7 +23922,7 @@ function useDocxEditor(options = {}) {
|
|
|
23666
23922
|
},
|
|
23667
23923
|
[dispatchEditorTransaction]
|
|
23668
23924
|
);
|
|
23669
|
-
const replaceDocumentWithImportError =
|
|
23925
|
+
const replaceDocumentWithImportError = React2.useCallback(
|
|
23670
23926
|
(fileName2, error) => {
|
|
23671
23927
|
unloadEmbeddedFonts();
|
|
23672
23928
|
setModel(createBlankDocumentModel());
|
|
@@ -23684,7 +23940,7 @@ function useDocxEditor(options = {}) {
|
|
|
23684
23940
|
},
|
|
23685
23941
|
[advanceDocumentLoadNonce, unloadEmbeddedFonts]
|
|
23686
23942
|
);
|
|
23687
|
-
const importDocxFile =
|
|
23943
|
+
const importDocxFile = React2.useCallback(
|
|
23688
23944
|
async (file) => {
|
|
23689
23945
|
activeImportAbortControllerRef.current?.abort();
|
|
23690
23946
|
activeImportAbortControllerRef.current = void 0;
|
|
@@ -23785,7 +24041,7 @@ function useDocxEditor(options = {}) {
|
|
|
23785
24041
|
replaceDocumentWithImportError
|
|
23786
24042
|
]
|
|
23787
24043
|
);
|
|
23788
|
-
const newDocument =
|
|
24044
|
+
const newDocument = React2.useCallback(() => {
|
|
23789
24045
|
activeImportAbortControllerRef.current?.abort();
|
|
23790
24046
|
activeImportAbortControllerRef.current = void 0;
|
|
23791
24047
|
unloadEmbeddedFonts();
|
|
@@ -23802,7 +24058,7 @@ function useDocxEditor(options = {}) {
|
|
|
23802
24058
|
setImportError(void 0);
|
|
23803
24059
|
setStatus("Created new document");
|
|
23804
24060
|
}, [advanceDocumentLoadNonce, unloadEmbeddedFonts]);
|
|
23805
|
-
const exportDocx =
|
|
24061
|
+
const exportDocx = React2.useCallback(async () => {
|
|
23806
24062
|
const sourceModel = modelRef.current;
|
|
23807
24063
|
const transformedModel = pendingExportModelTransformerRef.current ? pendingExportModelTransformerRef.current(sourceModel) : sourceModel;
|
|
23808
24064
|
if (transformedModel !== sourceModel) {
|
|
@@ -23825,7 +24081,7 @@ function useDocxEditor(options = {}) {
|
|
|
23825
24081
|
}, 1e3);
|
|
23826
24082
|
setStatus("Exported DOCX");
|
|
23827
24083
|
}, [basePackage, fileName]);
|
|
23828
|
-
const undo =
|
|
24084
|
+
const undo = React2.useCallback(() => {
|
|
23829
24085
|
textCommitBurstRef.current = void 0;
|
|
23830
24086
|
const { previous, next } = applyCanonicalEditorStateAction({
|
|
23831
24087
|
type: "undo"
|
|
@@ -23849,7 +24105,7 @@ function useDocxEditor(options = {}) {
|
|
|
23849
24105
|
});
|
|
23850
24106
|
setStatus("Undo");
|
|
23851
24107
|
}, [applyCanonicalEditorStateAction]);
|
|
23852
|
-
const redo =
|
|
24108
|
+
const redo = React2.useCallback(() => {
|
|
23853
24109
|
textCommitBurstRef.current = void 0;
|
|
23854
24110
|
const { previous, next } = applyCanonicalEditorStateAction({
|
|
23855
24111
|
type: "redo"
|
|
@@ -23873,7 +24129,7 @@ function useDocxEditor(options = {}) {
|
|
|
23873
24129
|
});
|
|
23874
24130
|
setStatus("Redo");
|
|
23875
24131
|
}, [applyCanonicalEditorStateAction]);
|
|
23876
|
-
|
|
24132
|
+
React2.useEffect(() => {
|
|
23877
24133
|
const onKeyDown = (event) => {
|
|
23878
24134
|
if (event.defaultPrevented) {
|
|
23879
24135
|
return;
|
|
@@ -23918,7 +24174,7 @@ function useDocxEditor(options = {}) {
|
|
|
23918
24174
|
window.removeEventListener("keydown", onKeyDown);
|
|
23919
24175
|
};
|
|
23920
24176
|
}, [redo, undo]);
|
|
23921
|
-
const applyToSelectedParagraphNode =
|
|
24177
|
+
const applyToSelectedParagraphNode = React2.useCallback(
|
|
23922
24178
|
(mutate) => {
|
|
23923
24179
|
applyModelChange((current) => {
|
|
23924
24180
|
const next = cloneDocModel(current);
|
|
@@ -23939,7 +24195,7 @@ function useDocxEditor(options = {}) {
|
|
|
23939
24195
|
},
|
|
23940
24196
|
[applyModelChange, selectedParagraphLocation]
|
|
23941
24197
|
);
|
|
23942
|
-
const restoreSelectionAfterToolbarCommand =
|
|
24198
|
+
const restoreSelectionAfterToolbarCommand = React2.useCallback(
|
|
23943
24199
|
(selectionSnapshot, textRangeSnapshot) => {
|
|
23944
24200
|
dispatchEditorTransaction(() => ({
|
|
23945
24201
|
selection: cloneEditorSelection(selectionSnapshot),
|
|
@@ -23949,7 +24205,7 @@ function useDocxEditor(options = {}) {
|
|
|
23949
24205
|
},
|
|
23950
24206
|
[dispatchEditorTransaction]
|
|
23951
24207
|
);
|
|
23952
|
-
const setActiveTextRange =
|
|
24208
|
+
const setActiveTextRange = React2.useCallback(
|
|
23953
24209
|
(range) => {
|
|
23954
24210
|
const currentRange = cloneTextRange(activeTextRangeRef.current);
|
|
23955
24211
|
if (!range) {
|
|
@@ -23958,7 +24214,7 @@ function useDocxEditor(options = {}) {
|
|
|
23958
24214
|
return;
|
|
23959
24215
|
}
|
|
23960
24216
|
activeTextRangeRef.current = void 0;
|
|
23961
|
-
|
|
24217
|
+
React2.startTransition(() => {
|
|
23962
24218
|
setActiveTextRangeState(void 0);
|
|
23963
24219
|
});
|
|
23964
24220
|
setPendingRunStyle(void 0);
|
|
@@ -23981,17 +24237,17 @@ function useDocxEditor(options = {}) {
|
|
|
23981
24237
|
const nextRange = cloneTextRange(normalized);
|
|
23982
24238
|
activeTextRangeRef.current = nextRange;
|
|
23983
24239
|
lastInViewerActiveTextRangeRef.current = cloneTextRange(nextRange);
|
|
23984
|
-
|
|
24240
|
+
React2.startTransition(() => {
|
|
23985
24241
|
setActiveTextRangeState(cloneTextRange(nextRange));
|
|
23986
24242
|
});
|
|
23987
24243
|
setPendingRunStyle(void 0);
|
|
23988
24244
|
},
|
|
23989
24245
|
[]
|
|
23990
24246
|
);
|
|
23991
|
-
const suppressNextDomSelectionRestore =
|
|
24247
|
+
const suppressNextDomSelectionRestore = React2.useCallback(() => {
|
|
23992
24248
|
suppressNextDomSelectionRestoreRef.current = true;
|
|
23993
24249
|
}, []);
|
|
23994
|
-
const applySelectedStyleChange =
|
|
24250
|
+
const applySelectedStyleChange = React2.useCallback(
|
|
23995
24251
|
(mutator) => {
|
|
23996
24252
|
const currentState = canonicalEditorStateRef.current;
|
|
23997
24253
|
const textRangeSnapshot = cloneTextRange(
|
|
@@ -24070,7 +24326,7 @@ function useDocxEditor(options = {}) {
|
|
|
24070
24326
|
lastInViewerActiveTextRangeRef
|
|
24071
24327
|
]
|
|
24072
24328
|
);
|
|
24073
|
-
const setParagraphStyle =
|
|
24329
|
+
const setParagraphStyle = React2.useCallback(
|
|
24074
24330
|
(styleId) => {
|
|
24075
24331
|
const fallbackStyleId = modelRef.current.metadata.defaultParagraphStyleId;
|
|
24076
24332
|
const nextStyleId = styleId ?? fallbackStyleId;
|
|
@@ -24099,7 +24355,7 @@ function useDocxEditor(options = {}) {
|
|
|
24099
24355
|
lastInViewerActiveTextRangeRef
|
|
24100
24356
|
]
|
|
24101
24357
|
);
|
|
24102
|
-
const setHeading =
|
|
24358
|
+
const setHeading = React2.useCallback(
|
|
24103
24359
|
(heading) => {
|
|
24104
24360
|
const styleId = heading ? `Heading${heading}` : modelRef.current.metadata.defaultParagraphStyleId;
|
|
24105
24361
|
const styleDefinition = styleId ? paragraphStyleById.get(styleId) : void 0;
|
|
@@ -24126,7 +24382,7 @@ function useDocxEditor(options = {}) {
|
|
|
24126
24382
|
lastInViewerActiveTextRangeRef
|
|
24127
24383
|
]
|
|
24128
24384
|
);
|
|
24129
|
-
const setLineSpacing =
|
|
24385
|
+
const setLineSpacing = React2.useCallback(
|
|
24130
24386
|
(lineMultiple) => {
|
|
24131
24387
|
if (!Number.isFinite(lineMultiple)) {
|
|
24132
24388
|
return;
|
|
@@ -24174,7 +24430,7 @@ function useDocxEditor(options = {}) {
|
|
|
24174
24430
|
lastInViewerActiveTextRangeRef
|
|
24175
24431
|
]
|
|
24176
24432
|
);
|
|
24177
|
-
const setFontFamily =
|
|
24433
|
+
const setFontFamily = React2.useCallback(
|
|
24178
24434
|
(fontFamily) => {
|
|
24179
24435
|
applySelectedStyleChange(
|
|
24180
24436
|
(style) => textStyleWithExplicitFontFamily(style, fontFamily)
|
|
@@ -24182,7 +24438,7 @@ function useDocxEditor(options = {}) {
|
|
|
24182
24438
|
},
|
|
24183
24439
|
[applySelectedStyleChange]
|
|
24184
24440
|
);
|
|
24185
|
-
const setFontSize =
|
|
24441
|
+
const setFontSize = React2.useCallback(
|
|
24186
24442
|
(fontSizePt) => {
|
|
24187
24443
|
applySelectedStyleChange((style) => ({
|
|
24188
24444
|
...style ?? {},
|
|
@@ -24191,7 +24447,7 @@ function useDocxEditor(options = {}) {
|
|
|
24191
24447
|
},
|
|
24192
24448
|
[applySelectedStyleChange]
|
|
24193
24449
|
);
|
|
24194
|
-
const currentSelectedRunStyleSnapshot =
|
|
24450
|
+
const currentSelectedRunStyleSnapshot = React2.useCallback(() => {
|
|
24195
24451
|
const currentState = canonicalEditorStateRef.current;
|
|
24196
24452
|
const range = cloneTextRange(
|
|
24197
24453
|
currentState.activeTextRange ?? lastInViewerActiveTextRangeRef.current
|
|
@@ -24213,21 +24469,21 @@ function useDocxEditor(options = {}) {
|
|
|
24213
24469
|
...currentPendingStyle
|
|
24214
24470
|
};
|
|
24215
24471
|
}, []);
|
|
24216
|
-
const toggleBold =
|
|
24472
|
+
const toggleBold = React2.useCallback(() => {
|
|
24217
24473
|
const nextBold = !Boolean(currentSelectedRunStyleSnapshot()?.bold);
|
|
24218
24474
|
applySelectedStyleChange((style) => ({
|
|
24219
24475
|
...style ?? {},
|
|
24220
24476
|
bold: nextBold
|
|
24221
24477
|
}));
|
|
24222
24478
|
}, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
|
|
24223
|
-
const toggleItalic =
|
|
24479
|
+
const toggleItalic = React2.useCallback(() => {
|
|
24224
24480
|
const nextItalic = !Boolean(currentSelectedRunStyleSnapshot()?.italic);
|
|
24225
24481
|
applySelectedStyleChange((style) => ({
|
|
24226
24482
|
...style ?? {},
|
|
24227
24483
|
italic: nextItalic
|
|
24228
24484
|
}));
|
|
24229
24485
|
}, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
|
|
24230
|
-
const toggleUnderline =
|
|
24486
|
+
const toggleUnderline = React2.useCallback(() => {
|
|
24231
24487
|
const nextUnderline = !Boolean(
|
|
24232
24488
|
currentSelectedRunStyleSnapshot()?.underline
|
|
24233
24489
|
);
|
|
@@ -24236,28 +24492,28 @@ function useDocxEditor(options = {}) {
|
|
|
24236
24492
|
underline: nextUnderline
|
|
24237
24493
|
}));
|
|
24238
24494
|
}, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
|
|
24239
|
-
const toggleStrike =
|
|
24495
|
+
const toggleStrike = React2.useCallback(() => {
|
|
24240
24496
|
const nextStrike = !Boolean(currentSelectedRunStyleSnapshot()?.strike);
|
|
24241
24497
|
applySelectedStyleChange((style) => ({
|
|
24242
24498
|
...style ?? {},
|
|
24243
24499
|
strike: nextStrike
|
|
24244
24500
|
}));
|
|
24245
24501
|
}, [applySelectedStyleChange, currentSelectedRunStyleSnapshot]);
|
|
24246
|
-
const toggleSuperscript =
|
|
24502
|
+
const toggleSuperscript = React2.useCallback(() => {
|
|
24247
24503
|
const nextVerticalAlign = selectedRunStyle?.verticalAlign === "superscript" ? void 0 : "superscript";
|
|
24248
24504
|
applySelectedStyleChange((style) => ({
|
|
24249
24505
|
...style ?? {},
|
|
24250
24506
|
verticalAlign: nextVerticalAlign
|
|
24251
24507
|
}));
|
|
24252
24508
|
}, [applySelectedStyleChange, selectedRunStyle?.verticalAlign]);
|
|
24253
|
-
const toggleSubscript =
|
|
24509
|
+
const toggleSubscript = React2.useCallback(() => {
|
|
24254
24510
|
const nextVerticalAlign = selectedRunStyle?.verticalAlign === "subscript" ? void 0 : "subscript";
|
|
24255
24511
|
applySelectedStyleChange((style) => ({
|
|
24256
24512
|
...style ?? {},
|
|
24257
24513
|
verticalAlign: nextVerticalAlign
|
|
24258
24514
|
}));
|
|
24259
24515
|
}, [applySelectedStyleChange, selectedRunStyle?.verticalAlign]);
|
|
24260
|
-
const setHighlight =
|
|
24516
|
+
const setHighlight = React2.useCallback(
|
|
24261
24517
|
(highlight) => {
|
|
24262
24518
|
applySelectedStyleChange((style) => ({
|
|
24263
24519
|
...style ?? {},
|
|
@@ -24266,7 +24522,7 @@ function useDocxEditor(options = {}) {
|
|
|
24266
24522
|
},
|
|
24267
24523
|
[applySelectedStyleChange]
|
|
24268
24524
|
);
|
|
24269
|
-
const setTextColor =
|
|
24525
|
+
const setTextColor = React2.useCallback(
|
|
24270
24526
|
(color) => {
|
|
24271
24527
|
applySelectedStyleChange((style) => ({
|
|
24272
24528
|
...style ?? {},
|
|
@@ -24275,7 +24531,7 @@ function useDocxEditor(options = {}) {
|
|
|
24275
24531
|
},
|
|
24276
24532
|
[applySelectedStyleChange]
|
|
24277
24533
|
);
|
|
24278
|
-
const setLink =
|
|
24534
|
+
const setLink = React2.useCallback(
|
|
24279
24535
|
(link) => {
|
|
24280
24536
|
const normalized = link?.trim();
|
|
24281
24537
|
const nextLink = normalized && normalized.length > 0 ? normalized : void 0;
|
|
@@ -24357,7 +24613,7 @@ function useDocxEditor(options = {}) {
|
|
|
24357
24613
|
},
|
|
24358
24614
|
[activeTextRange, applyModelChange]
|
|
24359
24615
|
);
|
|
24360
|
-
const replaceExpandedSelection =
|
|
24616
|
+
const replaceExpandedSelection = React2.useCallback(
|
|
24361
24617
|
(text, range) => {
|
|
24362
24618
|
const sourceRange = range ?? activeTextRangeRef.current;
|
|
24363
24619
|
if (!sourceRange) {
|
|
@@ -24711,13 +24967,13 @@ function useDocxEditor(options = {}) {
|
|
|
24711
24967
|
},
|
|
24712
24968
|
[applyModelChange, pendingRunStyle]
|
|
24713
24969
|
);
|
|
24714
|
-
const deleteExpandedSelection =
|
|
24970
|
+
const deleteExpandedSelection = React2.useCallback(
|
|
24715
24971
|
(range) => {
|
|
24716
24972
|
return replaceExpandedSelection("", range);
|
|
24717
24973
|
},
|
|
24718
24974
|
[replaceExpandedSelection]
|
|
24719
24975
|
);
|
|
24720
|
-
const updateFormField =
|
|
24976
|
+
const updateFormField = React2.useCallback(
|
|
24721
24977
|
(location, updater, successStatus) => {
|
|
24722
24978
|
dispatchEditorTransaction((current) => {
|
|
24723
24979
|
const next = cloneDocModel(current.model);
|
|
@@ -24747,7 +25003,7 @@ function useDocxEditor(options = {}) {
|
|
|
24747
25003
|
},
|
|
24748
25004
|
[dispatchEditorTransaction]
|
|
24749
25005
|
);
|
|
24750
|
-
const selectFormField =
|
|
25006
|
+
const selectFormField = React2.useCallback(
|
|
24751
25007
|
(location) => {
|
|
24752
25008
|
if (!location) {
|
|
24753
25009
|
setSelectedFormFieldLocation(void 0);
|
|
@@ -24772,7 +25028,7 @@ function useDocxEditor(options = {}) {
|
|
|
24772
25028
|
},
|
|
24773
25029
|
[]
|
|
24774
25030
|
);
|
|
24775
|
-
const toggleFormCheckbox =
|
|
25031
|
+
const toggleFormCheckbox = React2.useCallback(
|
|
24776
25032
|
(location) => {
|
|
24777
25033
|
updateFormField(
|
|
24778
25034
|
location,
|
|
@@ -24790,7 +25046,7 @@ function useDocxEditor(options = {}) {
|
|
|
24790
25046
|
},
|
|
24791
25047
|
[updateFormField]
|
|
24792
25048
|
);
|
|
24793
|
-
const setFormFieldValue =
|
|
25049
|
+
const setFormFieldValue = React2.useCallback(
|
|
24794
25050
|
(location, value) => {
|
|
24795
25051
|
updateFormField(
|
|
24796
25052
|
location,
|
|
@@ -24812,7 +25068,7 @@ function useDocxEditor(options = {}) {
|
|
|
24812
25068
|
},
|
|
24813
25069
|
[updateFormField]
|
|
24814
25070
|
);
|
|
24815
|
-
const updateFormFieldWidget =
|
|
25071
|
+
const updateFormFieldWidget = React2.useCallback(
|
|
24816
25072
|
(location, patch) => {
|
|
24817
25073
|
updateFormField(
|
|
24818
25074
|
location,
|
|
@@ -24825,7 +25081,7 @@ function useDocxEditor(options = {}) {
|
|
|
24825
25081
|
},
|
|
24826
25082
|
[updateFormField]
|
|
24827
25083
|
);
|
|
24828
|
-
const applyBorderPreset =
|
|
25084
|
+
const applyBorderPreset = React2.useCallback(
|
|
24829
25085
|
(preset) => {
|
|
24830
25086
|
const textRangeSnapshot = cloneTextRange(
|
|
24831
25087
|
activeTextRangeRef.current ?? lastInViewerActiveTextRangeRef.current
|
|
@@ -25012,7 +25268,7 @@ function useDocxEditor(options = {}) {
|
|
|
25012
25268
|
lastInViewerActiveTextRangeRef
|
|
25013
25269
|
]
|
|
25014
25270
|
);
|
|
25015
|
-
const setAlignment =
|
|
25271
|
+
const setAlignment = React2.useCallback(
|
|
25016
25272
|
(align) => {
|
|
25017
25273
|
const textRangeSnapshot = cloneTextRange(
|
|
25018
25274
|
activeTextRangeRef.current ?? lastInViewerActiveTextRangeRef.current
|
|
@@ -25071,7 +25327,7 @@ function useDocxEditor(options = {}) {
|
|
|
25071
25327
|
lastInViewerActiveTextRangeRef
|
|
25072
25328
|
]
|
|
25073
25329
|
);
|
|
25074
|
-
const toggleList =
|
|
25330
|
+
const toggleList = React2.useCallback(
|
|
25075
25331
|
(listType) => {
|
|
25076
25332
|
const textRangeSnapshot = cloneTextRange(
|
|
25077
25333
|
activeTextRangeRef.current ?? lastInViewerActiveTextRangeRef.current
|
|
@@ -25214,7 +25470,7 @@ function useDocxEditor(options = {}) {
|
|
|
25214
25470
|
lastInViewerActiveTextRangeRef
|
|
25215
25471
|
]
|
|
25216
25472
|
);
|
|
25217
|
-
const adjustSelectedListDepth =
|
|
25473
|
+
const adjustSelectedListDepth = React2.useCallback(
|
|
25218
25474
|
(levelDelta, draftText) => {
|
|
25219
25475
|
const normalizedLevelDelta = Math.trunc(levelDelta);
|
|
25220
25476
|
if (!normalizedLevelDelta) {
|
|
@@ -25331,7 +25587,7 @@ function useDocxEditor(options = {}) {
|
|
|
25331
25587
|
},
|
|
25332
25588
|
[applyModelChange, pendingRunStyle, selection]
|
|
25333
25589
|
);
|
|
25334
|
-
const insertListItemAfterSelection =
|
|
25590
|
+
const insertListItemAfterSelection = React2.useCallback(
|
|
25335
25591
|
(draftText, startOffset, endOffset, targetLocationOverride) => {
|
|
25336
25592
|
const targetLocation = targetLocationOverride ?? resolveSelectedParagraphLocation(selection, activeTextRangeRef.current);
|
|
25337
25593
|
if (targetLocation.kind !== "paragraph") {
|
|
@@ -25441,7 +25697,7 @@ function useDocxEditor(options = {}) {
|
|
|
25441
25697
|
},
|
|
25442
25698
|
[applyModelChange, pendingRunStyle, selection]
|
|
25443
25699
|
);
|
|
25444
|
-
const splitParagraphAtSelection =
|
|
25700
|
+
const splitParagraphAtSelection = React2.useCallback(
|
|
25445
25701
|
(draftText, startOffset, endOffset, targetLocationOverride) => {
|
|
25446
25702
|
const targetLocation = targetLocationOverride ?? resolveSelectedParagraphLocation(selection, activeTextRangeRef.current);
|
|
25447
25703
|
if (targetLocation.kind !== "paragraph") {
|
|
@@ -25532,7 +25788,7 @@ function useDocxEditor(options = {}) {
|
|
|
25532
25788
|
},
|
|
25533
25789
|
[applyModelChange, pendingRunStyle, selection]
|
|
25534
25790
|
);
|
|
25535
|
-
const insertTable =
|
|
25791
|
+
const insertTable = React2.useCallback(() => {
|
|
25536
25792
|
applyModelChange((current) => {
|
|
25537
25793
|
const next = cloneDocModel(current);
|
|
25538
25794
|
const insertionIndex = selection.kind === "paragraph" ? selection.nodeIndex + 1 : selection.tableIndex + 1;
|
|
@@ -25615,7 +25871,7 @@ function useDocxEditor(options = {}) {
|
|
|
25615
25871
|
return next;
|
|
25616
25872
|
}, "Inserted table");
|
|
25617
25873
|
}, [applyModelChange, selection]);
|
|
25618
|
-
const insertImageFile =
|
|
25874
|
+
const insertImageFile = React2.useCallback(
|
|
25619
25875
|
async (file) => {
|
|
25620
25876
|
if (!file.type.startsWith("image/")) {
|
|
25621
25877
|
setStatus("Select an image file");
|
|
@@ -25665,7 +25921,7 @@ function useDocxEditor(options = {}) {
|
|
|
25665
25921
|
},
|
|
25666
25922
|
[applyModelChange, selection]
|
|
25667
25923
|
);
|
|
25668
|
-
const appendParagraph =
|
|
25924
|
+
const appendParagraph = React2.useCallback(
|
|
25669
25925
|
(text = "") => {
|
|
25670
25926
|
let insertedIndex = 0;
|
|
25671
25927
|
dispatchEditorTransaction((current) => {
|
|
@@ -25689,7 +25945,7 @@ function useDocxEditor(options = {}) {
|
|
|
25689
25945
|
},
|
|
25690
25946
|
[dispatchEditorTransaction]
|
|
25691
25947
|
);
|
|
25692
|
-
const resizeImage =
|
|
25948
|
+
const resizeImage = React2.useCallback(
|
|
25693
25949
|
(location, widthPx, heightPx) => {
|
|
25694
25950
|
const safeWidth = Math.max(24, Math.round(widthPx));
|
|
25695
25951
|
const safeHeight = Math.max(24, Math.round(heightPx));
|
|
@@ -25720,7 +25976,7 @@ function useDocxEditor(options = {}) {
|
|
|
25720
25976
|
},
|
|
25721
25977
|
[applyModelChange]
|
|
25722
25978
|
);
|
|
25723
|
-
const setSyntheticTextBoxText =
|
|
25979
|
+
const setSyntheticTextBoxText = React2.useCallback(
|
|
25724
25980
|
(location, text) => {
|
|
25725
25981
|
applyModelChange((current) => {
|
|
25726
25982
|
const next = cloneDocModel(current);
|
|
@@ -25759,7 +26015,7 @@ function useDocxEditor(options = {}) {
|
|
|
25759
26015
|
},
|
|
25760
26016
|
[applyModelChange]
|
|
25761
26017
|
);
|
|
25762
|
-
const setImageWrapMode =
|
|
26018
|
+
const setImageWrapMode = React2.useCallback(
|
|
25763
26019
|
(location, mode, seedFloating) => {
|
|
25764
26020
|
applyModelChange((current) => {
|
|
25765
26021
|
const next = cloneDocModel(current);
|
|
@@ -25794,7 +26050,7 @@ function useDocxEditor(options = {}) {
|
|
|
25794
26050
|
},
|
|
25795
26051
|
[applyModelChange]
|
|
25796
26052
|
);
|
|
25797
|
-
const moveFloatingImage =
|
|
26053
|
+
const moveFloatingImage = React2.useCallback(
|
|
25798
26054
|
(location, patch, options2) => {
|
|
25799
26055
|
applyModelChange((current) => {
|
|
25800
26056
|
const sourceLocation = imageLocationToParagraphLocation(location);
|
|
@@ -25851,7 +26107,7 @@ function useDocxEditor(options = {}) {
|
|
|
25851
26107
|
},
|
|
25852
26108
|
[applyModelChange]
|
|
25853
26109
|
);
|
|
25854
|
-
const moveSectionFloatingImage =
|
|
26110
|
+
const moveSectionFloatingImage = React2.useCallback(
|
|
25855
26111
|
(location, patch) => {
|
|
25856
26112
|
applyModelChange((current) => {
|
|
25857
26113
|
return updateSectionImageFloatingAtLocation(current, location, patch);
|
|
@@ -25859,7 +26115,7 @@ function useDocxEditor(options = {}) {
|
|
|
25859
26115
|
},
|
|
25860
26116
|
[applyModelChange]
|
|
25861
26117
|
);
|
|
25862
|
-
const moveParagraphDropCap =
|
|
26118
|
+
const moveParagraphDropCap = React2.useCallback(
|
|
25863
26119
|
(nodeIndex, patch) => {
|
|
25864
26120
|
applyModelChange((current) => {
|
|
25865
26121
|
const next = cloneDocModel(current);
|
|
@@ -25882,7 +26138,7 @@ function useDocxEditor(options = {}) {
|
|
|
25882
26138
|
},
|
|
25883
26139
|
[applyModelChange]
|
|
25884
26140
|
);
|
|
25885
|
-
const setParagraphDropCapFontSizePt =
|
|
26141
|
+
const setParagraphDropCapFontSizePt = React2.useCallback(
|
|
25886
26142
|
(nodeIndex, fontSizePt) => {
|
|
25887
26143
|
applyModelChange((current) => {
|
|
25888
26144
|
const next = cloneDocModel(current);
|
|
@@ -25921,7 +26177,7 @@ function useDocxEditor(options = {}) {
|
|
|
25921
26177
|
},
|
|
25922
26178
|
[applyModelChange]
|
|
25923
26179
|
);
|
|
25924
|
-
const setParagraphDropCapText =
|
|
26180
|
+
const setParagraphDropCapText = React2.useCallback(
|
|
25925
26181
|
(nodeIndex, text) => {
|
|
25926
26182
|
applyModelChange((current) => {
|
|
25927
26183
|
const next = cloneDocModel(current);
|
|
@@ -25957,7 +26213,7 @@ function useDocxEditor(options = {}) {
|
|
|
25957
26213
|
},
|
|
25958
26214
|
[applyModelChange]
|
|
25959
26215
|
);
|
|
25960
|
-
const moveImage =
|
|
26216
|
+
const moveImage = React2.useCallback(
|
|
25961
26217
|
(source, target) => {
|
|
25962
26218
|
const sourceParagraphLocation = imageLocationToParagraphLocation(source);
|
|
25963
26219
|
const targetParagraphLocation = target.kind === "paragraph" ? {
|
|
@@ -26029,7 +26285,7 @@ function useDocxEditor(options = {}) {
|
|
|
26029
26285
|
},
|
|
26030
26286
|
[applyModelChange]
|
|
26031
26287
|
);
|
|
26032
|
-
const selectParagraph =
|
|
26288
|
+
const selectParagraph = React2.useCallback(
|
|
26033
26289
|
(nodeIndex) => {
|
|
26034
26290
|
dispatchEditorTransaction((current) => {
|
|
26035
26291
|
const nextSelection = {
|
|
@@ -26049,7 +26305,7 @@ function useDocxEditor(options = {}) {
|
|
|
26049
26305
|
},
|
|
26050
26306
|
[dispatchEditorTransaction]
|
|
26051
26307
|
);
|
|
26052
|
-
const selectTableCell =
|
|
26308
|
+
const selectTableCell = React2.useCallback(
|
|
26053
26309
|
(tableIndex, rowIndex, cellIndex) => {
|
|
26054
26310
|
dispatchEditorTransaction((current) => {
|
|
26055
26311
|
const nextSelection = {
|
|
@@ -26071,7 +26327,7 @@ function useDocxEditor(options = {}) {
|
|
|
26071
26327
|
},
|
|
26072
26328
|
[dispatchEditorTransaction]
|
|
26073
26329
|
);
|
|
26074
|
-
const clearTableCellContents =
|
|
26330
|
+
const clearTableCellContents = React2.useCallback(
|
|
26075
26331
|
(tableIndex, cells) => {
|
|
26076
26332
|
const dedupedCells = Array.from(
|
|
26077
26333
|
new Map(
|
|
@@ -26130,7 +26386,7 @@ function useDocxEditor(options = {}) {
|
|
|
26130
26386
|
},
|
|
26131
26387
|
[applyModelChange, pendingRunStyle]
|
|
26132
26388
|
);
|
|
26133
|
-
const deleteTable =
|
|
26389
|
+
const deleteTable = React2.useCallback(
|
|
26134
26390
|
(tableIndex) => {
|
|
26135
26391
|
const currentModel = modelRef.current;
|
|
26136
26392
|
const target = currentModel.nodes[tableIndex];
|
|
@@ -26208,7 +26464,7 @@ function useDocxEditor(options = {}) {
|
|
|
26208
26464
|
},
|
|
26209
26465
|
[applyModelChange]
|
|
26210
26466
|
);
|
|
26211
|
-
const moveTable =
|
|
26467
|
+
const moveTable = React2.useCallback(
|
|
26212
26468
|
(tableIndex, targetNodeIndex) => {
|
|
26213
26469
|
let nextSelection;
|
|
26214
26470
|
applyModelChange((current) => {
|
|
@@ -26266,7 +26522,7 @@ function useDocxEditor(options = {}) {
|
|
|
26266
26522
|
},
|
|
26267
26523
|
[applyModelChange]
|
|
26268
26524
|
);
|
|
26269
|
-
const setTableFloating =
|
|
26525
|
+
const setTableFloating = React2.useCallback(
|
|
26270
26526
|
(tableIndex, patch, options2) => {
|
|
26271
26527
|
applyModelChange((current) => {
|
|
26272
26528
|
const tableNode = current.nodes[tableIndex];
|
|
@@ -26330,7 +26586,7 @@ function useDocxEditor(options = {}) {
|
|
|
26330
26586
|
},
|
|
26331
26587
|
[applyModelChange]
|
|
26332
26588
|
);
|
|
26333
|
-
const moveEmbeddedTableToBody =
|
|
26589
|
+
const moveEmbeddedTableToBody = React2.useCallback(
|
|
26334
26590
|
(tableRuntimeKey, targetNodeIndex) => {
|
|
26335
26591
|
const runtimeLocation = parseEmbeddedTableRuntimeKey(tableRuntimeKey);
|
|
26336
26592
|
if (!runtimeLocation) {
|
|
@@ -26416,7 +26672,7 @@ function useDocxEditor(options = {}) {
|
|
|
26416
26672
|
},
|
|
26417
26673
|
[applyModelChange]
|
|
26418
26674
|
);
|
|
26419
|
-
const insertTableRow =
|
|
26675
|
+
const insertTableRow = React2.useCallback(
|
|
26420
26676
|
(tableIndex, rowIndex, direction) => {
|
|
26421
26677
|
let nextSelection;
|
|
26422
26678
|
const currentSelection = selectionRef.current;
|
|
@@ -26471,7 +26727,7 @@ function useDocxEditor(options = {}) {
|
|
|
26471
26727
|
},
|
|
26472
26728
|
[applyModelChange]
|
|
26473
26729
|
);
|
|
26474
|
-
const insertTableColumn =
|
|
26730
|
+
const insertTableColumn = React2.useCallback(
|
|
26475
26731
|
(tableIndex, cellIndex, direction, rowIndex) => {
|
|
26476
26732
|
let nextSelection;
|
|
26477
26733
|
applyModelChange(
|
|
@@ -26553,7 +26809,7 @@ function useDocxEditor(options = {}) {
|
|
|
26553
26809
|
},
|
|
26554
26810
|
[applyModelChange]
|
|
26555
26811
|
);
|
|
26556
|
-
const deleteTableRow =
|
|
26812
|
+
const deleteTableRow = React2.useCallback(
|
|
26557
26813
|
(tableIndex, rowIndex) => {
|
|
26558
26814
|
const tableNode = modelRef.current.nodes[tableIndex];
|
|
26559
26815
|
if (!tableNode || tableNode.type !== "table") {
|
|
@@ -26616,7 +26872,7 @@ function useDocxEditor(options = {}) {
|
|
|
26616
26872
|
},
|
|
26617
26873
|
[applyModelChange, deleteTable]
|
|
26618
26874
|
);
|
|
26619
|
-
const deleteTableColumn =
|
|
26875
|
+
const deleteTableColumn = React2.useCallback(
|
|
26620
26876
|
(tableIndex, cellIndex, rowIndex) => {
|
|
26621
26877
|
const tableNode = modelRef.current.nodes[tableIndex];
|
|
26622
26878
|
if (!tableNode || tableNode.type !== "table") {
|
|
@@ -26702,7 +26958,7 @@ function useDocxEditor(options = {}) {
|
|
|
26702
26958
|
},
|
|
26703
26959
|
[applyModelChange, deleteTable]
|
|
26704
26960
|
);
|
|
26705
|
-
const commitParagraphText =
|
|
26961
|
+
const commitParagraphText = React2.useCallback(
|
|
26706
26962
|
(nodeIndex, text) => {
|
|
26707
26963
|
applyModelChange((current) => {
|
|
26708
26964
|
const activeRange = activeTextRangeRef.current ? normalizeTextRange(activeTextRangeRef.current) : void 0;
|
|
@@ -26720,7 +26976,7 @@ function useDocxEditor(options = {}) {
|
|
|
26720
26976
|
},
|
|
26721
26977
|
[applyModelChange]
|
|
26722
26978
|
);
|
|
26723
|
-
const commitTableCellText =
|
|
26979
|
+
const commitTableCellText = React2.useCallback(
|
|
26724
26980
|
(tableIndex, rowIndex, cellIndex, text) => {
|
|
26725
26981
|
applyModelChange((current) => {
|
|
26726
26982
|
const activeRange = activeTextRangeRef.current ? normalizeTextRange(activeTextRangeRef.current) : void 0;
|
|
@@ -26751,7 +27007,7 @@ function useDocxEditor(options = {}) {
|
|
|
26751
27007
|
},
|
|
26752
27008
|
[applyModelChange]
|
|
26753
27009
|
);
|
|
26754
|
-
const commitTableCellParagraphTextRecursive =
|
|
27010
|
+
const commitTableCellParagraphTextRecursive = React2.useCallback(
|
|
26755
27011
|
(tableIndex, rowIndex, cellIndex, paragraphIndex, text) => {
|
|
26756
27012
|
applyModelChange((current) => {
|
|
26757
27013
|
const activeRange = activeTextRangeRef.current ? normalizeTextRange(activeTextRangeRef.current) : void 0;
|
|
@@ -26783,7 +27039,7 @@ function useDocxEditor(options = {}) {
|
|
|
26783
27039
|
},
|
|
26784
27040
|
[applyModelChange]
|
|
26785
27041
|
);
|
|
26786
|
-
const commitParagraphTextAtRange =
|
|
27042
|
+
const commitParagraphTextAtRange = React2.useCallback(
|
|
26787
27043
|
(location, text, caret, options2) => {
|
|
26788
27044
|
const now2 = Date.now();
|
|
26789
27045
|
return dispatchEditorTransaction((current) => {
|
|
@@ -26826,7 +27082,7 @@ function useDocxEditor(options = {}) {
|
|
|
26826
27082
|
},
|
|
26827
27083
|
[dispatchEditorTransaction]
|
|
26828
27084
|
);
|
|
26829
|
-
const commitTableCellTextAtRange =
|
|
27085
|
+
const commitTableCellTextAtRange = React2.useCallback(
|
|
26830
27086
|
(tableIndex, rowIndex, cellIndex, text, caret) => {
|
|
26831
27087
|
textCommitBurstRef.current = void 0;
|
|
26832
27088
|
return dispatchEditorTransaction((current) => {
|
|
@@ -26879,7 +27135,7 @@ function useDocxEditor(options = {}) {
|
|
|
26879
27135
|
},
|
|
26880
27136
|
[dispatchEditorTransaction]
|
|
26881
27137
|
);
|
|
26882
|
-
const commitSectionParagraphText =
|
|
27138
|
+
const commitSectionParagraphText = React2.useCallback(
|
|
26883
27139
|
(location, text) => {
|
|
26884
27140
|
applyModelChange(
|
|
26885
27141
|
(current) => updateSectionParagraphTextAtLocation(current, location, text, {
|
|
@@ -26890,7 +27146,7 @@ function useDocxEditor(options = {}) {
|
|
|
26890
27146
|
},
|
|
26891
27147
|
[applyModelChange]
|
|
26892
27148
|
);
|
|
26893
|
-
const syncPaginationInfo =
|
|
27149
|
+
const syncPaginationInfo = React2.useCallback(
|
|
26894
27150
|
(nextPaginationInfo) => {
|
|
26895
27151
|
setPaginationInfo((current) => {
|
|
26896
27152
|
const nextTotalPages = Math.max(
|
|
@@ -26913,6 +27169,29 @@ function useDocxEditor(options = {}) {
|
|
|
26913
27169
|
},
|
|
26914
27170
|
[]
|
|
26915
27171
|
);
|
|
27172
|
+
const setZoom = React2.useCallback(
|
|
27173
|
+
(level) => {
|
|
27174
|
+
const bridge = viewerZoomBridgeByController.get(
|
|
27175
|
+
syncPaginationInfo
|
|
27176
|
+
);
|
|
27177
|
+
if (bridge) {
|
|
27178
|
+
bridge.setZoom(level);
|
|
27179
|
+
return;
|
|
27180
|
+
}
|
|
27181
|
+
const normalized = normalizeViewerZoomLevel(level);
|
|
27182
|
+
fallbackZoomRef.current = {
|
|
27183
|
+
level: normalized,
|
|
27184
|
+
resolvedZoom: typeof normalized === "number" ? normalized : fallbackZoomRef.current.resolvedZoom
|
|
27185
|
+
};
|
|
27186
|
+
},
|
|
27187
|
+
[syncPaginationInfo]
|
|
27188
|
+
);
|
|
27189
|
+
const getZoom = React2.useCallback(() => {
|
|
27190
|
+
return viewerZoomBridgeByController.get(syncPaginationInfo)?.getZoom() ?? fallbackZoomRef.current.level;
|
|
27191
|
+
}, [syncPaginationInfo]);
|
|
27192
|
+
const getResolvedZoom = React2.useCallback(() => {
|
|
27193
|
+
return viewerZoomBridgeByController.get(syncPaginationInfo)?.getResolvedZoom() ?? fallbackZoomRef.current.resolvedZoom;
|
|
27194
|
+
}, [syncPaginationInfo]);
|
|
26916
27195
|
return {
|
|
26917
27196
|
model,
|
|
26918
27197
|
documentLoadNonce,
|
|
@@ -26954,6 +27233,9 @@ function useDocxEditor(options = {}) {
|
|
|
26954
27233
|
setShowTrackedChanges,
|
|
26955
27234
|
setShowComments,
|
|
26956
27235
|
syncPaginationInfo,
|
|
27236
|
+
setZoom,
|
|
27237
|
+
getZoom,
|
|
27238
|
+
getResolvedZoom,
|
|
26957
27239
|
toggleShowTrackedChanges,
|
|
26958
27240
|
toggleShowComments,
|
|
26959
27241
|
acceptTrackedChange,
|
|
@@ -27761,27 +28043,27 @@ function resolveDocxPageThumbnailResolution(options) {
|
|
|
27761
28043
|
}
|
|
27762
28044
|
function useDocxPageThumbnails(editor, options = {}) {
|
|
27763
28045
|
const pageSurfaceRegistryOwner = docxViewerPageSurfaceRegistryOwner(editor);
|
|
27764
|
-
const pageSurfaceRegistryEditor =
|
|
28046
|
+
const pageSurfaceRegistryEditor = React2.useMemo(
|
|
27765
28047
|
() => ({ syncPaginationInfo: editor.syncPaginationInfo }),
|
|
27766
28048
|
[pageSurfaceRegistryOwner]
|
|
27767
28049
|
);
|
|
27768
|
-
const [pageSurfaceEpoch, setPageSurfaceEpoch] =
|
|
27769
|
-
const [pageThumbnailStates, setPageThumbnailStates] =
|
|
27770
|
-
const attachedCanvasByPageRef =
|
|
28050
|
+
const [pageSurfaceEpoch, setPageSurfaceEpoch] = React2.useState(0);
|
|
28051
|
+
const [pageThumbnailStates, setPageThumbnailStates] = React2.useState(() => /* @__PURE__ */ new Map());
|
|
28052
|
+
const attachedCanvasByPageRef = React2.useRef(
|
|
27771
28053
|
/* @__PURE__ */ new Map()
|
|
27772
28054
|
);
|
|
27773
|
-
const canvasRefCallbacksRef =
|
|
27774
|
-
const renderToCanvasCallbacksRef =
|
|
27775
|
-
const fallbackLayout =
|
|
28055
|
+
const canvasRefCallbacksRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
28056
|
+
const renderToCanvasCallbacksRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
28057
|
+
const fallbackLayout = React2.useMemo(
|
|
27776
28058
|
() => resolveDocumentLayout(editor.model),
|
|
27777
28059
|
[editor.model]
|
|
27778
28060
|
);
|
|
27779
|
-
const pageSurfaceRegistry =
|
|
28061
|
+
const pageSurfaceRegistry = React2.useMemo(
|
|
27780
28062
|
() => ensureDocxViewerPageSurfaceRegistry(pageSurfaceRegistryEditor),
|
|
27781
28063
|
[pageSurfaceRegistryEditor]
|
|
27782
28064
|
);
|
|
27783
28065
|
const hasRequestedThumbnails = options.pageIndexes?.length !== 0;
|
|
27784
|
-
|
|
28066
|
+
React2.useEffect(
|
|
27785
28067
|
() => {
|
|
27786
28068
|
if (!hasRequestedThumbnails) return;
|
|
27787
28069
|
setPageSurfaceEpoch((current) => current + 1);
|
|
@@ -27791,11 +28073,11 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27791
28073
|
},
|
|
27792
28074
|
[hasRequestedThumbnails, pageSurfaceRegistryEditor]
|
|
27793
28075
|
);
|
|
27794
|
-
const mountedPageElements =
|
|
28076
|
+
const mountedPageElements = React2.useMemo(
|
|
27795
28077
|
() => new Map(pageSurfaceRegistry.pageElements),
|
|
27796
28078
|
[pageSurfaceEpoch, pageSurfaceRegistry.pageElements]
|
|
27797
28079
|
);
|
|
27798
|
-
const updatePageThumbnailState =
|
|
28080
|
+
const updatePageThumbnailState = React2.useCallback(
|
|
27799
28081
|
(pageIndex, status, error) => {
|
|
27800
28082
|
setPageThumbnailStates((current) => {
|
|
27801
28083
|
const next = new Map(current);
|
|
@@ -27809,20 +28091,20 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27809
28091
|
},
|
|
27810
28092
|
[]
|
|
27811
28093
|
);
|
|
27812
|
-
const thumbnailSurfaceCacheRef =
|
|
27813
|
-
const thumbnailRasterQueueRef =
|
|
27814
|
-
const detachedThumbnailSurfaceRendererRef =
|
|
27815
|
-
const lastPaintedThumbnailKeyByCanvasRef =
|
|
28094
|
+
const thumbnailSurfaceCacheRef = React2.useRef(void 0);
|
|
28095
|
+
const thumbnailRasterQueueRef = React2.useRef(void 0);
|
|
28096
|
+
const detachedThumbnailSurfaceRendererRef = React2.useRef(void 0);
|
|
28097
|
+
const lastPaintedThumbnailKeyByCanvasRef = React2.useRef(
|
|
27816
28098
|
/* @__PURE__ */ new WeakMap()
|
|
27817
28099
|
);
|
|
27818
|
-
const thumbnailQueueKeyByCanvasRef =
|
|
28100
|
+
const thumbnailQueueKeyByCanvasRef = React2.useRef(
|
|
27819
28101
|
/* @__PURE__ */ new WeakMap()
|
|
27820
28102
|
);
|
|
27821
|
-
const nextThumbnailCanvasQueueIdRef =
|
|
27822
|
-
const queuedPrefetchThumbnailKeysRef =
|
|
28103
|
+
const nextThumbnailCanvasQueueIdRef = React2.useRef(0);
|
|
28104
|
+
const queuedPrefetchThumbnailKeysRef = React2.useRef(/* @__PURE__ */ new Set());
|
|
27823
28105
|
const thumbnailMinRasterIntervalMs = normalizeDocxThumbnailMinRasterIntervalMs(options.minRasterIntervalMs);
|
|
27824
28106
|
const defaultThumbnailScheduling = options.scheduling ?? "idle";
|
|
27825
|
-
const ensureThumbnailSurfaceCache =
|
|
28107
|
+
const ensureThumbnailSurfaceCache = React2.useCallback(() => {
|
|
27826
28108
|
if (!thumbnailSurfaceCacheRef.current) {
|
|
27827
28109
|
thumbnailSurfaceCacheRef.current = new DocxThumbnailSurfaceCache(
|
|
27828
28110
|
DOCX_THUMBNAIL_SURFACE_CACHE_MAX_ENTRIES
|
|
@@ -27830,7 +28112,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27830
28112
|
}
|
|
27831
28113
|
return thumbnailSurfaceCacheRef.current;
|
|
27832
28114
|
}, []);
|
|
27833
|
-
const ensureThumbnailRasterQueue =
|
|
28115
|
+
const ensureThumbnailRasterQueue = React2.useCallback(() => {
|
|
27834
28116
|
if (!thumbnailRasterQueueRef.current) {
|
|
27835
28117
|
thumbnailRasterQueueRef.current = new SerialIdleTaskQueue({
|
|
27836
28118
|
minTaskIntervalMs: thumbnailMinRasterIntervalMs
|
|
@@ -27838,7 +28120,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27838
28120
|
}
|
|
27839
28121
|
return thumbnailRasterQueueRef.current;
|
|
27840
28122
|
}, [thumbnailMinRasterIntervalMs]);
|
|
27841
|
-
const thumbnailQueueKeyForCanvas =
|
|
28123
|
+
const thumbnailQueueKeyForCanvas = React2.useCallback(
|
|
27842
28124
|
(canvas) => {
|
|
27843
28125
|
const existing = thumbnailQueueKeyByCanvasRef.current.get(canvas);
|
|
27844
28126
|
if (existing) {
|
|
@@ -27853,12 +28135,12 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27853
28135
|
},
|
|
27854
28136
|
[]
|
|
27855
28137
|
);
|
|
27856
|
-
|
|
28138
|
+
React2.useEffect(() => {
|
|
27857
28139
|
thumbnailRasterQueueRef.current?.clear();
|
|
27858
28140
|
thumbnailRasterQueueRef.current = void 0;
|
|
27859
28141
|
queuedPrefetchThumbnailKeysRef.current.clear();
|
|
27860
28142
|
}, [thumbnailMinRasterIntervalMs]);
|
|
27861
|
-
|
|
28143
|
+
React2.useEffect(() => {
|
|
27862
28144
|
thumbnailSurfaceCacheRef.current?.clear();
|
|
27863
28145
|
thumbnailRasterQueueRef.current?.clear();
|
|
27864
28146
|
detachedThumbnailSurfaceRendererRef.current?.clear();
|
|
@@ -27868,7 +28150,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27868
28150
|
nextThumbnailCanvasQueueIdRef.current = 0;
|
|
27869
28151
|
queuedPrefetchThumbnailKeysRef.current.clear();
|
|
27870
28152
|
}, [editor.documentLoadNonce, pageSurfaceRegistryOwner]);
|
|
27871
|
-
|
|
28153
|
+
React2.useEffect(() => {
|
|
27872
28154
|
detachedThumbnailSurfaceRendererRef.current?.clear();
|
|
27873
28155
|
detachedThumbnailSurfaceRendererRef.current = void 0;
|
|
27874
28156
|
}, [
|
|
@@ -27877,14 +28159,14 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27877
28159
|
editor.showComments,
|
|
27878
28160
|
editor.showTrackedChanges
|
|
27879
28161
|
]);
|
|
27880
|
-
|
|
28162
|
+
React2.useEffect(
|
|
27881
28163
|
() => () => {
|
|
27882
28164
|
detachedThumbnailSurfaceRendererRef.current?.clear();
|
|
27883
28165
|
detachedThumbnailSurfaceRendererRef.current = void 0;
|
|
27884
28166
|
},
|
|
27885
28167
|
[]
|
|
27886
28168
|
);
|
|
27887
|
-
const thumbnailResolutionOptionsKey =
|
|
28169
|
+
const thumbnailResolutionOptionsKey = React2.useMemo(() => {
|
|
27888
28170
|
const bounds = options.resolution;
|
|
27889
28171
|
const boundsKey = typeof bounds === "number" ? `n${bounds}` : bounds ? `b${bounds.maxWidth ?? ""}x${bounds.maxHeight ?? ""}` : "";
|
|
27890
28172
|
return `${boundsKey}|${options.maxWidthPx ?? ""}|${options.maxHeightPx ?? ""}|${options.pixelRatio ?? ""}`;
|
|
@@ -27894,7 +28176,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27894
28176
|
options.pixelRatio,
|
|
27895
28177
|
options.resolution
|
|
27896
28178
|
]);
|
|
27897
|
-
const thumbnailSkipKeyForPage =
|
|
28179
|
+
const thumbnailSkipKeyForPage = React2.useCallback(
|
|
27898
28180
|
(pageIndex) => {
|
|
27899
28181
|
const contentKey = pageSurfaceRegistry.pageContentKeys.get(pageIndex);
|
|
27900
28182
|
return contentKey === void 0 ? void 0 : `${contentKey}|${editor.documentTheme}|${thumbnailResolutionOptionsKey}`;
|
|
@@ -27902,18 +28184,18 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27902
28184
|
[editor.documentTheme, pageSurfaceRegistry, thumbnailResolutionOptionsKey]
|
|
27903
28185
|
);
|
|
27904
28186
|
const totalThumbnailPages = Math.max(1, editor.totalPages);
|
|
27905
|
-
const hardThumbnailPageIndexes =
|
|
28187
|
+
const hardThumbnailPageIndexes = React2.useMemo(
|
|
27906
28188
|
() => options.pageIndexes === void 0 ? void 0 : normalizeDocxThumbnailPageIndexes(
|
|
27907
28189
|
options.pageIndexes,
|
|
27908
28190
|
totalThumbnailPages
|
|
27909
28191
|
),
|
|
27910
28192
|
[options.pageIndexes, totalThumbnailPages]
|
|
27911
28193
|
);
|
|
27912
|
-
const hardThumbnailPageIndexSet =
|
|
28194
|
+
const hardThumbnailPageIndexSet = React2.useMemo(
|
|
27913
28195
|
() => hardThumbnailPageIndexes ? new Set(hardThumbnailPageIndexes) : void 0,
|
|
27914
28196
|
[hardThumbnailPageIndexes]
|
|
27915
28197
|
);
|
|
27916
|
-
const visibleThumbnailPageIndexes =
|
|
28198
|
+
const visibleThumbnailPageIndexes = React2.useMemo(() => {
|
|
27917
28199
|
const normalized = normalizeDocxThumbnailPageIndexes(
|
|
27918
28200
|
options.renderWindow?.visiblePageIndexes,
|
|
27919
28201
|
totalThumbnailPages
|
|
@@ -27926,7 +28208,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27926
28208
|
options.renderWindow?.visiblePageIndexes,
|
|
27927
28209
|
totalThumbnailPages
|
|
27928
28210
|
]);
|
|
27929
|
-
const prefetchThumbnailPageIndexes =
|
|
28211
|
+
const prefetchThumbnailPageIndexes = React2.useMemo(() => {
|
|
27930
28212
|
const normalized = normalizeDocxThumbnailPageIndexes(
|
|
27931
28213
|
options.renderWindow?.prefetchPageIndexes,
|
|
27932
28214
|
totalThumbnailPages
|
|
@@ -27945,15 +28227,15 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
27945
28227
|
const prefetchThumbnailPageIndexesKey = docxThumbnailPageIndexesKey(
|
|
27946
28228
|
prefetchThumbnailPageIndexes
|
|
27947
28229
|
);
|
|
27948
|
-
const visibleThumbnailPageIndexSet =
|
|
28230
|
+
const visibleThumbnailPageIndexSet = React2.useMemo(
|
|
27949
28231
|
() => new Set(visibleThumbnailPageIndexes),
|
|
27950
28232
|
[visibleThumbnailPageIndexesKey]
|
|
27951
28233
|
);
|
|
27952
|
-
const thumbnailRenderPriorityForPage =
|
|
28234
|
+
const thumbnailRenderPriorityForPage = React2.useCallback(
|
|
27953
28235
|
(pageIndex, fallbackPriority = DOCX_THUMBNAIL_RENDER_PRIORITY_ATTACHED) => visibleThumbnailPageIndexSet.has(pageIndex) ? DOCX_THUMBNAIL_RENDER_PRIORITY_VISIBLE : fallbackPriority,
|
|
27954
28236
|
[visibleThumbnailPageIndexSet]
|
|
27955
28237
|
);
|
|
27956
|
-
const renderPageThumbnailSurface =
|
|
28238
|
+
const renderPageThumbnailSurface = React2.useCallback(
|
|
27957
28239
|
async (pageIndex, renderOptions) => {
|
|
27958
28240
|
const force = renderOptions?.force === true;
|
|
27959
28241
|
const runSkipKey = thumbnailSkipKeyForPage(pageIndex);
|
|
@@ -28045,7 +28327,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28045
28327
|
editor
|
|
28046
28328
|
]
|
|
28047
28329
|
);
|
|
28048
|
-
const renderPageThumbnailToCanvas =
|
|
28330
|
+
const renderPageThumbnailToCanvas = React2.useCallback(
|
|
28049
28331
|
async (pageIndex, canvas, renderOptions) => {
|
|
28050
28332
|
if (options.disabled) {
|
|
28051
28333
|
return;
|
|
@@ -28122,7 +28404,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28122
28404
|
updatePageThumbnailState
|
|
28123
28405
|
]
|
|
28124
28406
|
);
|
|
28125
|
-
const prefetchPageThumbnailSurface =
|
|
28407
|
+
const prefetchPageThumbnailSurface = React2.useCallback(
|
|
28126
28408
|
async (pageIndex) => {
|
|
28127
28409
|
if (options.disabled) {
|
|
28128
28410
|
return;
|
|
@@ -28143,7 +28425,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28143
28425
|
},
|
|
28144
28426
|
[ensureThumbnailRasterQueue, options.disabled, renderPageThumbnailSurface]
|
|
28145
28427
|
);
|
|
28146
|
-
const requestAttachedThumbnailRenders =
|
|
28428
|
+
const requestAttachedThumbnailRenders = React2.useCallback(
|
|
28147
28429
|
async (renderOptions) => {
|
|
28148
28430
|
const attachedPageIndexes = [
|
|
28149
28431
|
...attachedCanvasByPageRef.current.keys()
|
|
@@ -28162,7 +28444,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28162
28444
|
},
|
|
28163
28445
|
[renderPageThumbnailToCanvas, thumbnailRenderPriorityForPage]
|
|
28164
28446
|
);
|
|
28165
|
-
const requestPrefetchThumbnailRenders =
|
|
28447
|
+
const requestPrefetchThumbnailRenders = React2.useCallback(async () => {
|
|
28166
28448
|
if (options.disabled) {
|
|
28167
28449
|
queuedPrefetchThumbnailKeysRef.current.forEach((queueKey) => {
|
|
28168
28450
|
thumbnailRasterQueueRef.current?.cancel(queueKey);
|
|
@@ -28190,7 +28472,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28190
28472
|
prefetchPageThumbnailSurface,
|
|
28191
28473
|
prefetchThumbnailPageIndexes
|
|
28192
28474
|
]);
|
|
28193
|
-
|
|
28475
|
+
React2.useEffect(() => {
|
|
28194
28476
|
void requestPrefetchThumbnailRenders();
|
|
28195
28477
|
}, [
|
|
28196
28478
|
editor.documentLoadNonce,
|
|
@@ -28204,21 +28486,21 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28204
28486
|
prefetchThumbnailPageIndexesKey,
|
|
28205
28487
|
requestPrefetchThumbnailRenders
|
|
28206
28488
|
]);
|
|
28207
|
-
const rerenderAttachedThumbnails =
|
|
28489
|
+
const rerenderAttachedThumbnails = React2.useCallback(
|
|
28208
28490
|
async () => requestAttachedThumbnailRenders({ force: true }),
|
|
28209
28491
|
[requestAttachedThumbnailRenders]
|
|
28210
28492
|
);
|
|
28211
|
-
const renderPageThumbnailToCanvasRef =
|
|
28493
|
+
const renderPageThumbnailToCanvasRef = React2.useRef(
|
|
28212
28494
|
renderPageThumbnailToCanvas
|
|
28213
28495
|
);
|
|
28214
|
-
|
|
28496
|
+
React2.useEffect(() => {
|
|
28215
28497
|
renderPageThumbnailToCanvasRef.current = renderPageThumbnailToCanvas;
|
|
28216
28498
|
}, [renderPageThumbnailToCanvas]);
|
|
28217
|
-
|
|
28499
|
+
React2.useEffect(() => {
|
|
28218
28500
|
canvasRefCallbacksRef.current.clear();
|
|
28219
28501
|
renderToCanvasCallbacksRef.current.clear();
|
|
28220
28502
|
}, [pageSurfaceRegistryOwner]);
|
|
28221
|
-
|
|
28503
|
+
React2.useEffect(() => {
|
|
28222
28504
|
void requestAttachedThumbnailRenders();
|
|
28223
28505
|
}, [
|
|
28224
28506
|
editor.documentLoadNonce,
|
|
@@ -28232,7 +28514,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28232
28514
|
options.pixelRatio,
|
|
28233
28515
|
requestAttachedThumbnailRenders
|
|
28234
28516
|
]);
|
|
28235
|
-
const thumbnailGeometryItems =
|
|
28517
|
+
const thumbnailGeometryItems = React2.useMemo(() => {
|
|
28236
28518
|
const totalPages = Math.max(1, editor.totalPages);
|
|
28237
28519
|
const geometryPageIndexes = hardThumbnailPageIndexes ?? Array.from({ length: totalPages }, (_, pageIndex) => pageIndex);
|
|
28238
28520
|
return geometryPageIndexes.map((pageIndex) => {
|
|
@@ -28323,7 +28605,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28323
28605
|
pageSurfaceRegistry,
|
|
28324
28606
|
thumbnailQueueKeyForCanvas
|
|
28325
28607
|
]);
|
|
28326
|
-
const thumbnails =
|
|
28608
|
+
const thumbnails = React2.useMemo(
|
|
28327
28609
|
() => thumbnailGeometryItems.map((geometryItem) => {
|
|
28328
28610
|
const { hasElement, ...item } = geometryItem;
|
|
28329
28611
|
const state = pageThumbnailStates.get(item.pageIndex);
|
|
@@ -28335,7 +28617,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28335
28617
|
}),
|
|
28336
28618
|
[thumbnailGeometryItems, pageThumbnailStates]
|
|
28337
28619
|
);
|
|
28338
|
-
const paintThumbnail =
|
|
28620
|
+
const paintThumbnail = React2.useCallback(
|
|
28339
28621
|
(pageIndex, canvas) => {
|
|
28340
28622
|
if (!canvas || options.disabled) {
|
|
28341
28623
|
return false;
|
|
@@ -28350,7 +28632,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28350
28632
|
},
|
|
28351
28633
|
[options.disabled, thumbnails]
|
|
28352
28634
|
);
|
|
28353
|
-
return
|
|
28635
|
+
return React2.useMemo(
|
|
28354
28636
|
() => ({
|
|
28355
28637
|
paintThumbnail,
|
|
28356
28638
|
thumbnails,
|
|
@@ -28361,16 +28643,16 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
28361
28643
|
}
|
|
28362
28644
|
var useDocxViewerThumbnails = useDocxPageThumbnails;
|
|
28363
28645
|
function useDocxDocumentTheme(editor) {
|
|
28364
|
-
const setDocumentTheme =
|
|
28646
|
+
const setDocumentTheme = React2.useCallback(
|
|
28365
28647
|
(theme) => {
|
|
28366
28648
|
editor.setDocumentTheme(theme);
|
|
28367
28649
|
},
|
|
28368
28650
|
[editor.setDocumentTheme]
|
|
28369
28651
|
);
|
|
28370
|
-
const toggleDocumentTheme =
|
|
28652
|
+
const toggleDocumentTheme = React2.useCallback(() => {
|
|
28371
28653
|
editor.setDocumentTheme(editor.documentTheme === "dark" ? "light" : "dark");
|
|
28372
28654
|
}, [editor.documentTheme, editor.setDocumentTheme]);
|
|
28373
|
-
return
|
|
28655
|
+
return React2.useMemo(
|
|
28374
28656
|
() => ({
|
|
28375
28657
|
documentTheme: editor.documentTheme,
|
|
28376
28658
|
isDarkDocument: editor.documentTheme === "dark",
|
|
@@ -28381,13 +28663,13 @@ function useDocxDocumentTheme(editor) {
|
|
|
28381
28663
|
);
|
|
28382
28664
|
}
|
|
28383
28665
|
function useDocxParagraphStyles(editor) {
|
|
28384
|
-
const setParagraphStyle =
|
|
28666
|
+
const setParagraphStyle = React2.useCallback(
|
|
28385
28667
|
(styleId) => {
|
|
28386
28668
|
editor.setParagraphStyle(styleId);
|
|
28387
28669
|
},
|
|
28388
28670
|
[editor.setParagraphStyle]
|
|
28389
28671
|
);
|
|
28390
|
-
return
|
|
28672
|
+
return React2.useMemo(
|
|
28391
28673
|
() => ({
|
|
28392
28674
|
paragraphStyles: editor.availableParagraphStyles,
|
|
28393
28675
|
selectedParagraphStyleId: editor.selectedParagraphStyleId,
|
|
@@ -28402,13 +28684,13 @@ function useDocxParagraphStyles(editor) {
|
|
|
28402
28684
|
}
|
|
28403
28685
|
function useDocxImageWrapMenu(menu) {
|
|
28404
28686
|
const wrapState = menu.context.kind === "image" ? menu.context.image?.wrap ?? resolveDocxImageWrapState(menu.context.image?.floating) : void 0;
|
|
28405
|
-
const setMode =
|
|
28687
|
+
const setMode = React2.useCallback(
|
|
28406
28688
|
(mode) => {
|
|
28407
28689
|
menu.runAction(imageWrapModeActionId(mode));
|
|
28408
28690
|
},
|
|
28409
28691
|
[menu]
|
|
28410
28692
|
);
|
|
28411
|
-
const setMoveWithText =
|
|
28693
|
+
const setMoveWithText = React2.useCallback(
|
|
28412
28694
|
(moveWithText) => {
|
|
28413
28695
|
menu.runAction(
|
|
28414
28696
|
moveWithText ? "image-move-with-text" : "image-fix-position-on-page"
|
|
@@ -28416,7 +28698,7 @@ function useDocxImageWrapMenu(menu) {
|
|
|
28416
28698
|
},
|
|
28417
28699
|
[menu]
|
|
28418
28700
|
);
|
|
28419
|
-
return
|
|
28701
|
+
return React2.useMemo(() => {
|
|
28420
28702
|
if (!wrapState) {
|
|
28421
28703
|
return void 0;
|
|
28422
28704
|
}
|
|
@@ -28464,13 +28746,13 @@ function useDocxImageWrapMenu(menu) {
|
|
|
28464
28746
|
}, [menu, setMode, setMoveWithText, wrapState]);
|
|
28465
28747
|
}
|
|
28466
28748
|
function useDocxLineSpacing(editor) {
|
|
28467
|
-
const setLineSpacing =
|
|
28749
|
+
const setLineSpacing = React2.useCallback(
|
|
28468
28750
|
(lineMultiple) => {
|
|
28469
28751
|
editor.setLineSpacing(lineMultiple);
|
|
28470
28752
|
},
|
|
28471
28753
|
[editor.setLineSpacing]
|
|
28472
28754
|
);
|
|
28473
|
-
return
|
|
28755
|
+
return React2.useMemo(
|
|
28474
28756
|
() => ({
|
|
28475
28757
|
lineSpacing: editor.selectedLineSpacing,
|
|
28476
28758
|
setLineSpacing
|
|
@@ -28479,13 +28761,13 @@ function useDocxLineSpacing(editor) {
|
|
|
28479
28761
|
);
|
|
28480
28762
|
}
|
|
28481
28763
|
function useDocxBorders(editor) {
|
|
28482
|
-
const applyBorderPreset =
|
|
28764
|
+
const applyBorderPreset = React2.useCallback(
|
|
28483
28765
|
(preset) => {
|
|
28484
28766
|
editor.applyBorderPreset(preset);
|
|
28485
28767
|
},
|
|
28486
28768
|
[editor.applyBorderPreset]
|
|
28487
28769
|
);
|
|
28488
|
-
return
|
|
28770
|
+
return React2.useMemo(
|
|
28489
28771
|
() => ({
|
|
28490
28772
|
borderContext: editor.selectedBorderContext,
|
|
28491
28773
|
activeBorderPresets: editor.activeBorderPresets,
|
|
@@ -28499,11 +28781,11 @@ function useDocxBorders(editor) {
|
|
|
28499
28781
|
);
|
|
28500
28782
|
}
|
|
28501
28783
|
function useDocxFormFields(editor) {
|
|
28502
|
-
const formFields =
|
|
28784
|
+
const formFields = React2.useMemo(
|
|
28503
28785
|
() => collectFormFieldsFromModel(editor.model),
|
|
28504
28786
|
[editor.model]
|
|
28505
28787
|
);
|
|
28506
|
-
const updateSelectedFormFieldWidget =
|
|
28788
|
+
const updateSelectedFormFieldWidget = React2.useCallback(
|
|
28507
28789
|
(patch) => {
|
|
28508
28790
|
if (!editor.selectedFormField) {
|
|
28509
28791
|
return;
|
|
@@ -28512,7 +28794,7 @@ function useDocxFormFields(editor) {
|
|
|
28512
28794
|
},
|
|
28513
28795
|
[editor.selectedFormField, editor.updateFormFieldWidget]
|
|
28514
28796
|
);
|
|
28515
|
-
return
|
|
28797
|
+
return React2.useMemo(
|
|
28516
28798
|
() => ({
|
|
28517
28799
|
formFields,
|
|
28518
28800
|
selectedFormField: editor.selectedFormField,
|
|
@@ -28534,7 +28816,7 @@ function useDocxFormFields(editor) {
|
|
|
28534
28816
|
);
|
|
28535
28817
|
}
|
|
28536
28818
|
function useDocxTrackChanges(editor) {
|
|
28537
|
-
const changesByLocation =
|
|
28819
|
+
const changesByLocation = React2.useMemo(() => {
|
|
28538
28820
|
const grouped = /* @__PURE__ */ new Map();
|
|
28539
28821
|
editor.trackedChanges.forEach((change) => {
|
|
28540
28822
|
const key = paragraphLocationKey(change.location);
|
|
@@ -28544,13 +28826,13 @@ function useDocxTrackChanges(editor) {
|
|
|
28544
28826
|
});
|
|
28545
28827
|
return grouped;
|
|
28546
28828
|
}, [editor.trackedChanges]);
|
|
28547
|
-
const getChangesForLocation =
|
|
28829
|
+
const getChangesForLocation = React2.useCallback(
|
|
28548
28830
|
(location) => {
|
|
28549
28831
|
return changesByLocation.get(paragraphLocationKey(location)) ?? [];
|
|
28550
28832
|
},
|
|
28551
28833
|
[changesByLocation]
|
|
28552
28834
|
);
|
|
28553
|
-
return
|
|
28835
|
+
return React2.useMemo(
|
|
28554
28836
|
() => ({
|
|
28555
28837
|
trackedChanges: editor.trackedChanges,
|
|
28556
28838
|
showTrackedChanges: editor.showTrackedChanges,
|
|
@@ -28574,7 +28856,7 @@ function useDocxTrackChanges(editor) {
|
|
|
28574
28856
|
);
|
|
28575
28857
|
}
|
|
28576
28858
|
function useDocxComments(editor) {
|
|
28577
|
-
const commentsByLocation =
|
|
28859
|
+
const commentsByLocation = React2.useMemo(() => {
|
|
28578
28860
|
const grouped = /* @__PURE__ */ new Map();
|
|
28579
28861
|
editor.comments.forEach((comment) => {
|
|
28580
28862
|
const key = paragraphLocationKey(comment.location);
|
|
@@ -28584,13 +28866,13 @@ function useDocxComments(editor) {
|
|
|
28584
28866
|
});
|
|
28585
28867
|
return grouped;
|
|
28586
28868
|
}, [editor.comments]);
|
|
28587
|
-
const getCommentsForLocation =
|
|
28869
|
+
const getCommentsForLocation = React2.useCallback(
|
|
28588
28870
|
(location) => {
|
|
28589
28871
|
return commentsByLocation.get(paragraphLocationKey(location)) ?? [];
|
|
28590
28872
|
},
|
|
28591
28873
|
[commentsByLocation]
|
|
28592
28874
|
);
|
|
28593
|
-
return
|
|
28875
|
+
return React2.useMemo(
|
|
28594
28876
|
() => ({
|
|
28595
28877
|
comments: editor.comments,
|
|
28596
28878
|
showComments: editor.showComments,
|
|
@@ -28615,7 +28897,7 @@ function useDocxComments(editor) {
|
|
|
28615
28897
|
}
|
|
28616
28898
|
function useDocxPageLayout(editor) {
|
|
28617
28899
|
const primarySectionPropertiesXml = editor.model.metadata.sections?.[0]?.sectionPropertiesXml ?? editor.model.metadata.sectionPropertiesXml;
|
|
28618
|
-
const layout =
|
|
28900
|
+
const layout = React2.useMemo(() => {
|
|
28619
28901
|
const sectionLayout = parseSectionLayout(primarySectionPropertiesXml);
|
|
28620
28902
|
const sectionColumns = parseSectionColumns(primarySectionPropertiesXml);
|
|
28621
28903
|
const pageNumberStart = parseSectionPageNumberStart(
|
|
@@ -28648,7 +28930,7 @@ function useDocxPageLayout(editor) {
|
|
|
28648
28930
|
}
|
|
28649
28931
|
};
|
|
28650
28932
|
}, [primarySectionPropertiesXml]);
|
|
28651
|
-
return
|
|
28933
|
+
return React2.useMemo(
|
|
28652
28934
|
() => ({
|
|
28653
28935
|
layout
|
|
28654
28936
|
}),
|
|
@@ -28656,7 +28938,7 @@ function useDocxPageLayout(editor) {
|
|
|
28656
28938
|
);
|
|
28657
28939
|
}
|
|
28658
28940
|
function useDocxPagination(editor) {
|
|
28659
|
-
return
|
|
28941
|
+
return React2.useMemo(
|
|
28660
28942
|
() => ({
|
|
28661
28943
|
pagination: {
|
|
28662
28944
|
currentPage: editor.currentPage,
|
|
@@ -29474,6 +29756,9 @@ function DocxEditorViewer({
|
|
|
29474
29756
|
editor,
|
|
29475
29757
|
className,
|
|
29476
29758
|
style,
|
|
29759
|
+
zoom,
|
|
29760
|
+
defaultZoom,
|
|
29761
|
+
onZoomChange,
|
|
29477
29762
|
pageBackgroundColor,
|
|
29478
29763
|
pageGapBackgroundColor,
|
|
29479
29764
|
deferInitialPaginationPaint = false,
|
|
@@ -29493,7 +29778,7 @@ function DocxEditorViewer({
|
|
|
29493
29778
|
onFormFieldDoubleClick,
|
|
29494
29779
|
mode = "edit"
|
|
29495
29780
|
}) {
|
|
29496
|
-
const fontMetricsRevision =
|
|
29781
|
+
const fontMetricsRevision = React2.useSyncExternalStore(
|
|
29497
29782
|
subscribeFontMetrics,
|
|
29498
29783
|
getFontMetricsRevision,
|
|
29499
29784
|
getServerFontMetricsRevision
|
|
@@ -29509,17 +29794,17 @@ function DocxEditorViewer({
|
|
|
29509
29794
|
const documentContentTheme = isNightReaderMode ? "light" : editor.documentTheme;
|
|
29510
29795
|
const documentContentFilter = isNightReaderMode ? NIGHT_READER_INVERSION_FILTER : void 0;
|
|
29511
29796
|
const canReplaceDocumentByDrop = mode !== "read-only";
|
|
29512
|
-
const formFieldLocationKey =
|
|
29797
|
+
const formFieldLocationKey = React2.useCallback(
|
|
29513
29798
|
(location) => {
|
|
29514
29799
|
return location.kind === "paragraph" ? `p:${location.nodeIndex}:${location.childIndex}` : `t:${location.tableIndex}:${location.rowIndex}:${location.cellIndex}:${location.paragraphIndex}:${location.childIndex}`;
|
|
29515
29800
|
},
|
|
29516
29801
|
[]
|
|
29517
29802
|
);
|
|
29518
|
-
const tocLinkColorByLevel =
|
|
29803
|
+
const tocLinkColorByLevel = React2.useMemo(
|
|
29519
29804
|
() => collectHeadingTextColorByLevel(editor.model),
|
|
29520
29805
|
[editor.model]
|
|
29521
29806
|
);
|
|
29522
|
-
const paragraphRunRenderOptions =
|
|
29807
|
+
const paragraphRunRenderOptions = React2.useMemo(
|
|
29523
29808
|
() => ({
|
|
29524
29809
|
showTrackedChanges: trackedChangesEnabled,
|
|
29525
29810
|
showCommentHighlights: commentsEnabled,
|
|
@@ -29535,29 +29820,29 @@ function DocxEditorViewer({
|
|
|
29535
29820
|
trackedChangesEnabled
|
|
29536
29821
|
]
|
|
29537
29822
|
);
|
|
29538
|
-
const viewerRootRef =
|
|
29539
|
-
const tableCellDraftsRef =
|
|
29540
|
-
const plainParagraphHtmlCacheRef =
|
|
29823
|
+
const viewerRootRef = React2.useRef(null);
|
|
29824
|
+
const tableCellDraftsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29825
|
+
const plainParagraphHtmlCacheRef = React2.useRef(
|
|
29541
29826
|
/* @__PURE__ */ new WeakMap()
|
|
29542
29827
|
);
|
|
29543
|
-
const editableParagraphHtmlPropsRef =
|
|
29544
|
-
const editableTableCellHtmlPropsRef =
|
|
29545
|
-
const tableCellParagraphDraftsRef =
|
|
29828
|
+
const editableParagraphHtmlPropsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29829
|
+
const editableTableCellHtmlPropsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29830
|
+
const tableCellParagraphDraftsRef = React2.useRef(
|
|
29546
29831
|
/* @__PURE__ */ new Map()
|
|
29547
29832
|
);
|
|
29548
|
-
const contextMenuClipboardTextRef =
|
|
29549
|
-
const sectionParagraphDraftsRef =
|
|
29833
|
+
const contextMenuClipboardTextRef = React2.useRef("");
|
|
29834
|
+
const sectionParagraphDraftsRef = React2.useRef(
|
|
29550
29835
|
/* @__PURE__ */ new Map()
|
|
29551
29836
|
);
|
|
29552
|
-
const pendingParagraphSegmentFocusRef =
|
|
29553
|
-
const paragraphElementsRef =
|
|
29837
|
+
const pendingParagraphSegmentFocusRef = React2.useRef(void 0);
|
|
29838
|
+
const paragraphElementsRef = React2.useRef(
|
|
29554
29839
|
/* @__PURE__ */ new Map()
|
|
29555
29840
|
);
|
|
29556
29841
|
const [
|
|
29557
29842
|
measuredParagraphOuterHeightsPxByBlockId,
|
|
29558
29843
|
setMeasuredParagraphOuterHeightsPxByBlockId
|
|
29559
|
-
] =
|
|
29560
|
-
const measuredParagraphOuterHeightsPxByNodeIndex =
|
|
29844
|
+
] = React2.useState(() => /* @__PURE__ */ new Map());
|
|
29845
|
+
const measuredParagraphOuterHeightsPxByNodeIndex = React2.useMemo(() => {
|
|
29561
29846
|
const byNodeIndex = /* @__PURE__ */ new Map();
|
|
29562
29847
|
if (measuredParagraphOuterHeightsPxByBlockId.size === 0) {
|
|
29563
29848
|
return byNodeIndex;
|
|
@@ -29575,70 +29860,70 @@ function DocxEditorViewer({
|
|
|
29575
29860
|
});
|
|
29576
29861
|
return byNodeIndex;
|
|
29577
29862
|
}, [editor.model.nodes, measuredParagraphOuterHeightsPxByBlockId]);
|
|
29578
|
-
const tableCellEditorElementsRef =
|
|
29863
|
+
const tableCellEditorElementsRef = React2.useRef(
|
|
29579
29864
|
/* @__PURE__ */ new Map()
|
|
29580
29865
|
);
|
|
29581
|
-
const tableCellParagraphElementsRef =
|
|
29582
|
-
const sectionParagraphElementsRef =
|
|
29866
|
+
const tableCellParagraphElementsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29867
|
+
const sectionParagraphElementsRef = React2.useRef(
|
|
29583
29868
|
/* @__PURE__ */ new Map()
|
|
29584
29869
|
);
|
|
29585
|
-
const tableElementsRef =
|
|
29586
|
-
const pageHeaderElementsRef =
|
|
29870
|
+
const tableElementsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29871
|
+
const pageHeaderElementsRef = React2.useRef(
|
|
29587
29872
|
/* @__PURE__ */ new Map()
|
|
29588
29873
|
);
|
|
29589
|
-
const pageBodyElementsRef =
|
|
29874
|
+
const pageBodyElementsRef = React2.useRef(
|
|
29590
29875
|
/* @__PURE__ */ new Map()
|
|
29591
29876
|
);
|
|
29592
|
-
const pageFooterElementsRef =
|
|
29877
|
+
const pageFooterElementsRef = React2.useRef(
|
|
29593
29878
|
/* @__PURE__ */ new Map()
|
|
29594
29879
|
);
|
|
29595
|
-
const pageElementsRef =
|
|
29596
|
-
const pageSurfaceRefCallbacksRef =
|
|
29597
|
-
const trackedChangeCardElementsRef =
|
|
29598
|
-
const initialPaginationStableSignatureRef =
|
|
29880
|
+
const pageElementsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29881
|
+
const pageSurfaceRefCallbacksRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29882
|
+
const trackedChangeCardElementsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
29883
|
+
const initialPaginationStableSignatureRef = React2.useRef(
|
|
29599
29884
|
void 0
|
|
29600
29885
|
);
|
|
29601
|
-
const initialPaginationRevealFrameRef =
|
|
29602
|
-
const pendingHeaderFooterDeactivateFrameRef =
|
|
29886
|
+
const initialPaginationRevealFrameRef = React2.useRef(null);
|
|
29887
|
+
const pendingHeaderFooterDeactivateFrameRef = React2.useRef(
|
|
29603
29888
|
null
|
|
29604
29889
|
);
|
|
29605
|
-
const appliedHistoryRestoreNonceRef =
|
|
29606
|
-
const pendingTableCellFocusRef =
|
|
29607
|
-
const pendingSectionParagraphFocusRef =
|
|
29608
|
-
const draggedImageRef =
|
|
29609
|
-
const previousBodyNodeCountRef =
|
|
29890
|
+
const appliedHistoryRestoreNonceRef = React2.useRef(0);
|
|
29891
|
+
const pendingTableCellFocusRef = React2.useRef(void 0);
|
|
29892
|
+
const pendingSectionParagraphFocusRef = React2.useRef(void 0);
|
|
29893
|
+
const draggedImageRef = React2.useRef(null);
|
|
29894
|
+
const previousBodyNodeCountRef = React2.useRef(
|
|
29610
29895
|
editor.model.nodes.length
|
|
29611
29896
|
);
|
|
29612
|
-
const fileDragDepthRef =
|
|
29613
|
-
const tableDraftLayoutRefreshRafRef =
|
|
29614
|
-
const activeRangeFlushFrameRef =
|
|
29615
|
-
const pendingEditableCaretRef =
|
|
29616
|
-
const commandSelectionGuardRef =
|
|
29617
|
-
const editingIntentContinuationRef =
|
|
29618
|
-
const compositionActiveRef =
|
|
29619
|
-
const pointerSelectionDragRef =
|
|
29620
|
-
const deferredCollapsedSelectionSyncTimeoutRef =
|
|
29897
|
+
const fileDragDepthRef = React2.useRef(0);
|
|
29898
|
+
const tableDraftLayoutRefreshRafRef = React2.useRef(null);
|
|
29899
|
+
const activeRangeFlushFrameRef = React2.useRef(null);
|
|
29900
|
+
const pendingEditableCaretRef = React2.useRef(null);
|
|
29901
|
+
const commandSelectionGuardRef = React2.useRef(void 0);
|
|
29902
|
+
const editingIntentContinuationRef = React2.useRef(void 0);
|
|
29903
|
+
const compositionActiveRef = React2.useRef(false);
|
|
29904
|
+
const pointerSelectionDragRef = React2.useRef({ down: false, moved: false });
|
|
29905
|
+
const deferredCollapsedSelectionSyncTimeoutRef = React2.useRef(
|
|
29621
29906
|
null
|
|
29622
29907
|
);
|
|
29623
|
-
const pendingSelectionIntentFrameRef =
|
|
29624
|
-
const selectionIntentNonceRef =
|
|
29625
|
-
const lastFormFieldClickRef =
|
|
29626
|
-
const [isDragOverCanvas, setIsDragOverCanvas] =
|
|
29627
|
-
const [isDraggingImage, setIsDraggingImage] =
|
|
29628
|
-
const [activeDropTarget, setActiveDropTarget] =
|
|
29629
|
-
const [selectedImage, setSelectedImage] =
|
|
29630
|
-
const [selectedSectionImageKey, setSelectedSectionImageKey] =
|
|
29631
|
-
const [selectedDropCapNodeIndex, setSelectedDropCapNodeIndex] =
|
|
29632
|
-
const [hoveredDropCapNodeIndex, setHoveredDropCapNodeIndex] =
|
|
29633
|
-
const [activeWrappedParagraphSession, setActiveWrappedParagraphSession] =
|
|
29634
|
-
const activeWrappedParagraphSessionRef =
|
|
29635
|
-
const [resizePreview, setResizePreview] =
|
|
29636
|
-
const [floatingMovePreview, setFloatingMovePreview] =
|
|
29637
|
-
const [dropCapMovePreview, setDropCapMovePreview] =
|
|
29638
|
-
const [dropCapResizePreview, setDropCapResizePreview] =
|
|
29639
|
-
const [tableColumnWidths, setTableColumnWidths] =
|
|
29640
|
-
const [embeddedTableColumnWidths, setEmbeddedTableColumnWidths] =
|
|
29641
|
-
const handleRepeatedFormFieldClick =
|
|
29908
|
+
const pendingSelectionIntentFrameRef = React2.useRef(null);
|
|
29909
|
+
const selectionIntentNonceRef = React2.useRef(0);
|
|
29910
|
+
const lastFormFieldClickRef = React2.useRef(void 0);
|
|
29911
|
+
const [isDragOverCanvas, setIsDragOverCanvas] = React2.useState(false);
|
|
29912
|
+
const [isDraggingImage, setIsDraggingImage] = React2.useState(false);
|
|
29913
|
+
const [activeDropTarget, setActiveDropTarget] = React2.useState();
|
|
29914
|
+
const [selectedImage, setSelectedImage] = React2.useState();
|
|
29915
|
+
const [selectedSectionImageKey, setSelectedSectionImageKey] = React2.useState();
|
|
29916
|
+
const [selectedDropCapNodeIndex, setSelectedDropCapNodeIndex] = React2.useState();
|
|
29917
|
+
const [hoveredDropCapNodeIndex, setHoveredDropCapNodeIndex] = React2.useState();
|
|
29918
|
+
const [activeWrappedParagraphSession, setActiveWrappedParagraphSession] = React2.useState();
|
|
29919
|
+
const activeWrappedParagraphSessionRef = React2.useRef(void 0);
|
|
29920
|
+
const [resizePreview, setResizePreview] = React2.useState();
|
|
29921
|
+
const [floatingMovePreview, setFloatingMovePreview] = React2.useState();
|
|
29922
|
+
const [dropCapMovePreview, setDropCapMovePreview] = React2.useState();
|
|
29923
|
+
const [dropCapResizePreview, setDropCapResizePreview] = React2.useState();
|
|
29924
|
+
const [tableColumnWidths, setTableColumnWidths] = React2.useState({});
|
|
29925
|
+
const [embeddedTableColumnWidths, setEmbeddedTableColumnWidths] = React2.useState({});
|
|
29926
|
+
const handleRepeatedFormFieldClick = React2.useCallback(
|
|
29642
29927
|
(location) => {
|
|
29643
29928
|
const now2 = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
29644
29929
|
const key = formFieldLocationKey(location);
|
|
@@ -29654,16 +29939,16 @@ function DocxEditorViewer({
|
|
|
29654
29939
|
},
|
|
29655
29940
|
[editor.selectFormField, formFieldLocationKey, onFormFieldDoubleClick]
|
|
29656
29941
|
);
|
|
29657
|
-
const [activeColumnResize, setActiveColumnResize] =
|
|
29658
|
-
const [activeEmbeddedColumnResize, setActiveEmbeddedColumnResize] =
|
|
29659
|
-
const [tableRowHeights, setTableRowHeights] =
|
|
29660
|
-
const [embeddedTableRowHeights, setEmbeddedTableRowHeights] =
|
|
29661
|
-
const [tableMeasuredRowHeights, setTableMeasuredRowHeights] =
|
|
29942
|
+
const [activeColumnResize, setActiveColumnResize] = React2.useState();
|
|
29943
|
+
const [activeEmbeddedColumnResize, setActiveEmbeddedColumnResize] = React2.useState();
|
|
29944
|
+
const [tableRowHeights, setTableRowHeights] = React2.useState({});
|
|
29945
|
+
const [embeddedTableRowHeights, setEmbeddedTableRowHeights] = React2.useState({});
|
|
29946
|
+
const [tableMeasuredRowHeights, setTableMeasuredRowHeights] = React2.useState({});
|
|
29662
29947
|
const [
|
|
29663
29948
|
measuredPageContentHeightByIndex,
|
|
29664
29949
|
setMeasuredPageContentHeightByIndex
|
|
29665
|
-
] =
|
|
29666
|
-
const pageSurfaceRefForIndex =
|
|
29950
|
+
] = React2.useState([]);
|
|
29951
|
+
const pageSurfaceRefForIndex = React2.useCallback(
|
|
29667
29952
|
(pageIndex) => {
|
|
29668
29953
|
const normalizedPageIndex = Math.max(0, Math.round(pageIndex));
|
|
29669
29954
|
const cached = pageSurfaceRefCallbacksRef.current.get(normalizedPageIndex);
|
|
@@ -29693,54 +29978,54 @@ function DocxEditorViewer({
|
|
|
29693
29978
|
},
|
|
29694
29979
|
[pageSurfaceRegistryOwner]
|
|
29695
29980
|
);
|
|
29696
|
-
|
|
29981
|
+
React2.useEffect(() => {
|
|
29697
29982
|
pageSurfaceRefCallbacksRef.current.clear();
|
|
29698
29983
|
}, [pageSurfaceRegistryOwner]);
|
|
29699
29984
|
const [
|
|
29700
29985
|
measuredPageContentIdentityKeysByIndex,
|
|
29701
29986
|
setMeasuredPageContentIdentityKeysByIndex
|
|
29702
|
-
] =
|
|
29987
|
+
] = React2.useState([]);
|
|
29703
29988
|
const [
|
|
29704
29989
|
measuredPageContentValidationByIndex,
|
|
29705
29990
|
setMeasuredPageContentValidationByIndex
|
|
29706
|
-
] =
|
|
29707
|
-
const [hasMeasuredBodyFooterOverlap, setHasMeasuredBodyFooterOverlap] =
|
|
29708
|
-
const measuredBodyFooterOverlapCandidateRef =
|
|
29991
|
+
] = React2.useState([]);
|
|
29992
|
+
const [hasMeasuredBodyFooterOverlap, setHasMeasuredBodyFooterOverlap] = React2.useState(false);
|
|
29993
|
+
const measuredBodyFooterOverlapCandidateRef = React2.useRef({
|
|
29709
29994
|
signature: void 0,
|
|
29710
29995
|
consecutivePasses: 0
|
|
29711
29996
|
});
|
|
29712
|
-
const [, setRenderableImageSourceRevision] =
|
|
29713
|
-
const [activeEditableParagraphSegment, setActiveEditableParagraphSegment] =
|
|
29714
|
-
const wrappedParagraphTextareaRef =
|
|
29997
|
+
const [, setRenderableImageSourceRevision] = React2.useState(0);
|
|
29998
|
+
const [activeEditableParagraphSegment, setActiveEditableParagraphSegment] = React2.useState(void 0);
|
|
29999
|
+
const wrappedParagraphTextareaRef = React2.useRef(
|
|
29715
30000
|
null
|
|
29716
30001
|
);
|
|
29717
|
-
const wrappedParagraphPendingSelectionRef =
|
|
29718
|
-
const wrappedParagraphSelectionDragRef =
|
|
29719
|
-
const wrappedParagraphSurfaceRegistryRef =
|
|
29720
|
-
const [isInitialPaginationSettled, setIsInitialPaginationSettled] =
|
|
30002
|
+
const wrappedParagraphPendingSelectionRef = React2.useRef(void 0);
|
|
30003
|
+
const wrappedParagraphSelectionDragRef = React2.useRef(void 0);
|
|
30004
|
+
const wrappedParagraphSurfaceRegistryRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
30005
|
+
const [isInitialPaginationSettled, setIsInitialPaginationSettled] = React2.useState(!deferInitialPaginationPaint);
|
|
29721
30006
|
const [
|
|
29722
30007
|
initialPaginationBackgroundRefinementUnlocked,
|
|
29723
30008
|
setInitialPaginationBackgroundRefinementUnlocked
|
|
29724
|
-
] =
|
|
29725
|
-
const [postImportPaginationUnlocked, setPostImportPaginationUnlocked] =
|
|
30009
|
+
] = React2.useState(!deferInitialPaginationPaint);
|
|
30010
|
+
const [postImportPaginationUnlocked, setPostImportPaginationUnlocked] = React2.useState(false);
|
|
29726
30011
|
const [
|
|
29727
30012
|
initialPaginationReservedLayoutState,
|
|
29728
30013
|
setInitialPaginationReservedLayoutState
|
|
29729
|
-
] =
|
|
30014
|
+
] = React2.useState({
|
|
29730
30015
|
pageCount: 0,
|
|
29731
30016
|
totalHeightPx: 0
|
|
29732
30017
|
});
|
|
29733
|
-
const [disableMeasuredImportPagination, setDisableMeasuredImportPagination] =
|
|
29734
|
-
const initialPaginationPageCountOscillationRef =
|
|
30018
|
+
const [disableMeasuredImportPagination, setDisableMeasuredImportPagination] = React2.useState(false);
|
|
30019
|
+
const initialPaginationPageCountOscillationRef = React2.useRef({
|
|
29735
30020
|
changeCount: 0,
|
|
29736
30021
|
distinctPageCounts: /* @__PURE__ */ new Set()
|
|
29737
30022
|
});
|
|
29738
|
-
|
|
30023
|
+
React2.useEffect(() => {
|
|
29739
30024
|
return subscribeRenderableImageSourceUpdates(() => {
|
|
29740
30025
|
setRenderableImageSourceRevision((value) => value + 1);
|
|
29741
30026
|
});
|
|
29742
30027
|
}, []);
|
|
29743
|
-
|
|
30028
|
+
React2.useEffect(() => {
|
|
29744
30029
|
if (typeof document === "undefined") {
|
|
29745
30030
|
return;
|
|
29746
30031
|
}
|
|
@@ -29760,7 +30045,7 @@ function DocxEditorViewer({
|
|
|
29760
30045
|
document.head.appendChild(styleElement);
|
|
29761
30046
|
}
|
|
29762
30047
|
}, []);
|
|
29763
|
-
|
|
30048
|
+
React2.useEffect(() => {
|
|
29764
30049
|
setMeasuredPageContentHeightByIndex([]);
|
|
29765
30050
|
setMeasuredPageContentIdentityKeysByIndex([]);
|
|
29766
30051
|
setMeasuredPageContentValidationByIndex([]);
|
|
@@ -29805,7 +30090,7 @@ function DocxEditorViewer({
|
|
|
29805
30090
|
distinctPageCounts: /* @__PURE__ */ new Set()
|
|
29806
30091
|
};
|
|
29807
30092
|
}, [editor.documentLoadNonce]);
|
|
29808
|
-
|
|
30093
|
+
React2.useEffect(() => {
|
|
29809
30094
|
initialPaginationStableSignatureRef.current = void 0;
|
|
29810
30095
|
if (initialPaginationRevealFrameRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
|
|
29811
30096
|
window.cancelAnimationFrame(initialPaginationRevealFrameRef.current);
|
|
@@ -29816,47 +30101,47 @@ function DocxEditorViewer({
|
|
|
29816
30101
|
!deferInitialPaginationPaint
|
|
29817
30102
|
);
|
|
29818
30103
|
}, [deferInitialPaginationPaint, editor.documentLoadNonce]);
|
|
29819
|
-
const [activeRowResize, setActiveRowResize] =
|
|
29820
|
-
const [activeEmbeddedRowResize, setActiveEmbeddedRowResize] =
|
|
29821
|
-
const [activeTableResize, setActiveTableResize] =
|
|
29822
|
-
const [activeEmbeddedTableResize, setActiveEmbeddedTableResize] =
|
|
29823
|
-
const [hoveredTableResizeHandle, setHoveredTableResizeHandle] =
|
|
29824
|
-
const [hoveredTableHandleTableIndex, setHoveredTableHandleTableIndex] =
|
|
30104
|
+
const [activeRowResize, setActiveRowResize] = React2.useState();
|
|
30105
|
+
const [activeEmbeddedRowResize, setActiveEmbeddedRowResize] = React2.useState();
|
|
30106
|
+
const [activeTableResize, setActiveTableResize] = React2.useState();
|
|
30107
|
+
const [activeEmbeddedTableResize, setActiveEmbeddedTableResize] = React2.useState();
|
|
30108
|
+
const [hoveredTableResizeHandle, setHoveredTableResizeHandle] = React2.useState();
|
|
30109
|
+
const [hoveredTableHandleTableIndex, setHoveredTableHandleTableIndex] = React2.useState();
|
|
29825
30110
|
const [
|
|
29826
30111
|
hoveredEmbeddedTableResizeHandle,
|
|
29827
30112
|
setHoveredEmbeddedTableResizeHandle
|
|
29828
|
-
] =
|
|
29829
|
-
const [hoveredEmbeddedTableKey, setHoveredEmbeddedTableKey] =
|
|
29830
|
-
const [focusedEmbeddedTableKey, setFocusedEmbeddedTableKey] =
|
|
29831
|
-
const tableSelectionDragRef =
|
|
29832
|
-
const tableCellSelectionDragRef =
|
|
29833
|
-
const tableMoveDragRef =
|
|
29834
|
-
const suppressNextTableCellClickRef =
|
|
29835
|
-
const [tableCellSelectionRange, setTableCellSelectionRange] =
|
|
29836
|
-
const [tableMoveDropPreview, setTableMoveDropPreview] =
|
|
29837
|
-
const [objectWrapDragPreview, setObjectWrapDragPreview] =
|
|
29838
|
-
const objectDragCleanupRef =
|
|
29839
|
-
|
|
29840
|
-
const [tableContextMenuState, setTableContextMenuState] =
|
|
29841
|
-
const [contextMenuState, setContextMenuState] =
|
|
29842
|
-
const [activeHeaderFooterEdit, setActiveHeaderFooterEdit] =
|
|
29843
|
-
const [tableDraftLayoutEpoch, bumpTableDraftLayoutEpoch] =
|
|
30113
|
+
] = React2.useState();
|
|
30114
|
+
const [hoveredEmbeddedTableKey, setHoveredEmbeddedTableKey] = React2.useState();
|
|
30115
|
+
const [focusedEmbeddedTableKey, setFocusedEmbeddedTableKey] = React2.useState();
|
|
30116
|
+
const tableSelectionDragRef = React2.useRef(void 0);
|
|
30117
|
+
const tableCellSelectionDragRef = React2.useRef(void 0);
|
|
30118
|
+
const tableMoveDragRef = React2.useRef(void 0);
|
|
30119
|
+
const suppressNextTableCellClickRef = React2.useRef(false);
|
|
30120
|
+
const [tableCellSelectionRange, setTableCellSelectionRange] = React2.useState();
|
|
30121
|
+
const [tableMoveDropPreview, setTableMoveDropPreview] = React2.useState();
|
|
30122
|
+
const [objectWrapDragPreview, setObjectWrapDragPreview] = React2.useState();
|
|
30123
|
+
const objectDragCleanupRef = React2.useRef(void 0);
|
|
30124
|
+
React2.useEffect(() => () => objectDragCleanupRef.current?.(), [editor.documentLoadNonce, editor.model, isReadOnly]);
|
|
30125
|
+
const [tableContextMenuState, setTableContextMenuState] = React2.useState();
|
|
30126
|
+
const [contextMenuState, setContextMenuState] = React2.useState();
|
|
30127
|
+
const [activeHeaderFooterEdit, setActiveHeaderFooterEdit] = React2.useState();
|
|
30128
|
+
const [tableDraftLayoutEpoch, bumpTableDraftLayoutEpoch] = React2.useReducer(
|
|
29844
30129
|
(value) => value + 1,
|
|
29845
30130
|
0
|
|
29846
30131
|
);
|
|
29847
|
-
const [paragraphStructureEpoch, bumpParagraphStructureEpoch] =
|
|
29848
|
-
const [paginationMeasurementEpoch, bumpPaginationMeasurementEpoch] =
|
|
29849
|
-
const [measuredWrapBands, setMeasuredWrapBands] =
|
|
29850
|
-
const wrapBandReconcileModelRef =
|
|
29851
|
-
const wrapBandReconcilePassCountRef =
|
|
29852
|
-
const paginationMeasurementSuspendUntilRef =
|
|
29853
|
-
const paginationMeasurementResumeTimeoutRef =
|
|
30132
|
+
const [paragraphStructureEpoch, bumpParagraphStructureEpoch] = React2.useReducer((value) => value + 1, 0);
|
|
30133
|
+
const [paginationMeasurementEpoch, bumpPaginationMeasurementEpoch] = React2.useReducer((value) => value + 1, 0);
|
|
30134
|
+
const [measuredWrapBands, setMeasuredWrapBands] = React2.useState(() => /* @__PURE__ */ new Map());
|
|
30135
|
+
const wrapBandReconcileModelRef = React2.useRef(void 0);
|
|
30136
|
+
const wrapBandReconcilePassCountRef = React2.useRef(0);
|
|
30137
|
+
const paginationMeasurementSuspendUntilRef = React2.useRef(0);
|
|
30138
|
+
const paginationMeasurementResumeTimeoutRef = React2.useRef(
|
|
29854
30139
|
null
|
|
29855
30140
|
);
|
|
29856
|
-
|
|
30141
|
+
React2.useLayoutEffect(() => {
|
|
29857
30142
|
setMeasuredParagraphOuterHeightsPxByBlockId(/* @__PURE__ */ new Map());
|
|
29858
30143
|
}, [editor.documentLoadNonce]);
|
|
29859
|
-
|
|
30144
|
+
React2.useEffect(() => {
|
|
29860
30145
|
setMeasuredParagraphOuterHeightsPxByBlockId((current) => {
|
|
29861
30146
|
if (current.size === 0) {
|
|
29862
30147
|
return current;
|
|
@@ -29876,7 +30161,7 @@ function DocxEditorViewer({
|
|
|
29876
30161
|
return next ?? current;
|
|
29877
30162
|
});
|
|
29878
30163
|
}, [editor.model.nodes]);
|
|
29879
|
-
const schedulePaginationMeasurementResume =
|
|
30164
|
+
const schedulePaginationMeasurementResume = React2.useCallback(
|
|
29880
30165
|
(delayMs) => {
|
|
29881
30166
|
if (typeof window === "undefined") {
|
|
29882
30167
|
return;
|
|
@@ -29897,7 +30182,7 @@ function DocxEditorViewer({
|
|
|
29897
30182
|
},
|
|
29898
30183
|
[]
|
|
29899
30184
|
);
|
|
29900
|
-
const requestTableDraftLayoutRefresh =
|
|
30185
|
+
const requestTableDraftLayoutRefresh = React2.useCallback(() => {
|
|
29901
30186
|
if (typeof window === "undefined" || typeof window.requestAnimationFrame !== "function") {
|
|
29902
30187
|
bumpTableDraftLayoutEpoch();
|
|
29903
30188
|
return;
|
|
@@ -29910,7 +30195,7 @@ function DocxEditorViewer({
|
|
|
29910
30195
|
bumpTableDraftLayoutEpoch();
|
|
29911
30196
|
});
|
|
29912
30197
|
}, []);
|
|
29913
|
-
|
|
30198
|
+
React2.useEffect(() => {
|
|
29914
30199
|
return () => {
|
|
29915
30200
|
if (tableDraftLayoutRefreshRafRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
|
|
29916
30201
|
window.cancelAnimationFrame(tableDraftLayoutRefreshRafRef.current);
|
|
@@ -29944,7 +30229,7 @@ function DocxEditorViewer({
|
|
|
29944
30229
|
pendingSelectionIntentFrameRef.current = null;
|
|
29945
30230
|
};
|
|
29946
30231
|
}, []);
|
|
29947
|
-
|
|
30232
|
+
React2.useEffect(() => {
|
|
29948
30233
|
if (!isReadOnly) {
|
|
29949
30234
|
return;
|
|
29950
30235
|
}
|
|
@@ -29978,7 +30263,7 @@ function DocxEditorViewer({
|
|
|
29978
30263
|
sectionParagraphDraftsRef.current.clear();
|
|
29979
30264
|
pendingSectionParagraphFocusRef.current = void 0;
|
|
29980
30265
|
}, [isReadOnly]);
|
|
29981
|
-
const beginSelectionIntent =
|
|
30266
|
+
const beginSelectionIntent = React2.useCallback(() => {
|
|
29982
30267
|
if (pendingSelectionIntentFrameRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
|
|
29983
30268
|
window.cancelAnimationFrame(pendingSelectionIntentFrameRef.current);
|
|
29984
30269
|
}
|
|
@@ -29987,13 +30272,13 @@ function DocxEditorViewer({
|
|
|
29987
30272
|
selectionIntentNonceRef.current = nextNonce;
|
|
29988
30273
|
return nextNonce;
|
|
29989
30274
|
}, []);
|
|
29990
|
-
const isSelectionIntentCurrent =
|
|
30275
|
+
const isSelectionIntentCurrent = React2.useCallback(
|
|
29991
30276
|
(nonce) => {
|
|
29992
30277
|
return selectionIntentNonceRef.current === nonce;
|
|
29993
30278
|
},
|
|
29994
30279
|
[]
|
|
29995
30280
|
);
|
|
29996
|
-
const scheduleSelectionIntentFrame =
|
|
30281
|
+
const scheduleSelectionIntentFrame = React2.useCallback(
|
|
29997
30282
|
(nonce, callback) => {
|
|
29998
30283
|
if (pendingSelectionIntentFrameRef.current !== null && typeof window !== "undefined" && typeof window.cancelAnimationFrame === "function") {
|
|
29999
30284
|
window.cancelAnimationFrame(pendingSelectionIntentFrameRef.current);
|
|
@@ -30017,10 +30302,10 @@ function DocxEditorViewer({
|
|
|
30017
30302
|
},
|
|
30018
30303
|
[]
|
|
30019
30304
|
);
|
|
30020
|
-
const cancelPendingSelectionIntent =
|
|
30305
|
+
const cancelPendingSelectionIntent = React2.useCallback(() => {
|
|
30021
30306
|
beginSelectionIntent();
|
|
30022
30307
|
}, [beginSelectionIntent]);
|
|
30023
|
-
|
|
30308
|
+
React2.useEffect(() => {
|
|
30024
30309
|
const previousNodeCount = previousBodyNodeCountRef.current;
|
|
30025
30310
|
const nextNodeCount = editor.model.nodes.length;
|
|
30026
30311
|
const structureChanged = previousNodeCount !== nextNodeCount;
|
|
@@ -30069,20 +30354,20 @@ function DocxEditorViewer({
|
|
|
30069
30354
|
});
|
|
30070
30355
|
previousBodyNodeCountRef.current = nextNodeCount;
|
|
30071
30356
|
}, [editor.model.nodes]);
|
|
30072
|
-
const documentSections =
|
|
30357
|
+
const documentSections = React2.useMemo(
|
|
30073
30358
|
() => resolveDocumentSectionsFromMetadata(editor.model.metadata),
|
|
30074
30359
|
[editor.model.metadata]
|
|
30075
30360
|
);
|
|
30076
30361
|
const primarySectionPropertiesXml = documentSections[0]?.sectionPropertiesXml ?? editor.model.metadata.sectionPropertiesXml;
|
|
30077
|
-
const documentLayout =
|
|
30362
|
+
const documentLayout = React2.useMemo(
|
|
30078
30363
|
() => parseSectionLayout(primarySectionPropertiesXml),
|
|
30079
30364
|
[primarySectionPropertiesXml]
|
|
30080
30365
|
);
|
|
30081
|
-
const paginationSectionMetrics =
|
|
30366
|
+
const paginationSectionMetrics = React2.useMemo(
|
|
30082
30367
|
() => buildPaginationSectionMetrics(documentSections, documentLayout),
|
|
30083
30368
|
[documentLayout, documentSections]
|
|
30084
30369
|
);
|
|
30085
|
-
const paginationMeasurementContextSignature =
|
|
30370
|
+
const paginationMeasurementContextSignature = React2.useMemo(
|
|
30086
30371
|
() => [
|
|
30087
30372
|
Math.round(documentLayout.pageWidthPx),
|
|
30088
30373
|
Math.round(documentLayout.pageHeightPx),
|
|
@@ -30101,7 +30386,7 @@ function DocxEditorViewer({
|
|
|
30101
30386
|
trackedChangesEnabled
|
|
30102
30387
|
]
|
|
30103
30388
|
);
|
|
30104
|
-
|
|
30389
|
+
React2.useEffect(() => {
|
|
30105
30390
|
setMeasuredPageContentHeightByIndex((current) => current.length ? [] : current);
|
|
30106
30391
|
setMeasuredPageContentIdentityKeysByIndex(
|
|
30107
30392
|
(current) => current.length ? [] : current
|
|
@@ -30111,7 +30396,7 @@ function DocxEditorViewer({
|
|
|
30111
30396
|
);
|
|
30112
30397
|
setHasMeasuredBodyFooterOverlap(false);
|
|
30113
30398
|
}, [fontMetricsRevision]);
|
|
30114
|
-
|
|
30399
|
+
React2.useEffect(() => {
|
|
30115
30400
|
setMeasuredParagraphOuterHeightsPxByBlockId(
|
|
30116
30401
|
(current) => current.size === 0 ? current : /* @__PURE__ */ new Map()
|
|
30117
30402
|
);
|
|
@@ -30123,7 +30408,7 @@ function DocxEditorViewer({
|
|
|
30123
30408
|
docGridLinePitchPxByNodeIndex,
|
|
30124
30409
|
pageContentWidthPxByNodeIndex,
|
|
30125
30410
|
pageContentHeightPxByNodeIndex
|
|
30126
|
-
} =
|
|
30411
|
+
} = React2.useMemo(() => {
|
|
30127
30412
|
const pitchByNodeIndex = /* @__PURE__ */ new Map();
|
|
30128
30413
|
const widthByNodeIndex = /* @__PURE__ */ new Map();
|
|
30129
30414
|
const heightByNodeIndex = /* @__PURE__ */ new Map();
|
|
@@ -30170,17 +30455,17 @@ function DocxEditorViewer({
|
|
|
30170
30455
|
pageContentHeightPxByNodeIndex: heightByNodeIndex
|
|
30171
30456
|
};
|
|
30172
30457
|
}, [editor.model.nodes.length, paginationSectionMetrics]);
|
|
30173
|
-
const sectionColumnsBySectionIndex =
|
|
30458
|
+
const sectionColumnsBySectionIndex = React2.useMemo(
|
|
30174
30459
|
() => documentSections.map(
|
|
30175
30460
|
(section) => parseSectionColumns(section.sectionPropertiesXml)
|
|
30176
30461
|
),
|
|
30177
30462
|
[documentSections]
|
|
30178
30463
|
);
|
|
30179
|
-
const paragraphNumberingLabels =
|
|
30464
|
+
const paragraphNumberingLabels = React2.useMemo(
|
|
30180
30465
|
() => buildParagraphNumberingLabels(editor.model),
|
|
30181
30466
|
[editor.model]
|
|
30182
30467
|
);
|
|
30183
|
-
const noteMarkerIndexes =
|
|
30468
|
+
const noteMarkerIndexes = React2.useMemo(
|
|
30184
30469
|
() => ({
|
|
30185
30470
|
footnote: new Map(
|
|
30186
30471
|
editor.model.metadata.footnotes?.map((note, index) => [
|
|
@@ -30197,7 +30482,7 @@ function DocxEditorViewer({
|
|
|
30197
30482
|
}),
|
|
30198
30483
|
[editor.model.metadata.footnotes, editor.model.metadata.endnotes]
|
|
30199
30484
|
);
|
|
30200
|
-
const bookmarkTargetNodeIndexByName =
|
|
30485
|
+
const bookmarkTargetNodeIndexByName = React2.useMemo(() => {
|
|
30201
30486
|
const targets = /* @__PURE__ */ new Map();
|
|
30202
30487
|
editor.model.nodes.forEach((node, nodeIndex) => {
|
|
30203
30488
|
if (node.type === "paragraph") {
|
|
@@ -30222,7 +30507,7 @@ function DocxEditorViewer({
|
|
|
30222
30507
|
});
|
|
30223
30508
|
return targets;
|
|
30224
30509
|
}, [editor.model.nodes]);
|
|
30225
|
-
const tableMeasuredRowHeightsForPagination =
|
|
30510
|
+
const tableMeasuredRowHeightsForPagination = React2.useMemo(() => {
|
|
30226
30511
|
const allowMeasuredImportPagination = !editor.canUndo && !editor.canRedo && !disableMeasuredImportPagination;
|
|
30227
30512
|
const activeDraftKeys = [
|
|
30228
30513
|
...tableCellDraftsRef.current.keys(),
|
|
@@ -30253,10 +30538,10 @@ function DocxEditorViewer({
|
|
|
30253
30538
|
tableDraftLayoutEpoch,
|
|
30254
30539
|
tableMeasuredRowHeights
|
|
30255
30540
|
]);
|
|
30256
|
-
const textEditPaginationMemo =
|
|
30541
|
+
const textEditPaginationMemo = React2.useRef(null);
|
|
30257
30542
|
if (!textEditPaginationMemo.current)
|
|
30258
30543
|
textEditPaginationMemo.current = createTextEditPaginationMemo();
|
|
30259
|
-
const pageSegmentationPlan =
|
|
30544
|
+
const pageSegmentationPlan = React2.useMemo(() => {
|
|
30260
30545
|
const pageContentHeightPx = Math.max(
|
|
30261
30546
|
120,
|
|
30262
30547
|
documentLayout.pageHeightPx - documentLayout.marginsPx.top - documentLayout.marginsPx.bottom
|
|
@@ -30657,13 +30942,13 @@ function DocxEditorViewer({
|
|
|
30657
30942
|
const useMeasuredPageContentHeightsForRender = pageSegmentationPlan.useMeasuredPageContentHeightsForRender;
|
|
30658
30943
|
const renderMeasuredPageContentHeightsPxByPageIndex = pageSegmentationPlan.renderMeasuredPageContentHeightsPxByPageIndex;
|
|
30659
30944
|
const renderPageContentHeightScale = pageSegmentationPlan.renderPageContentHeightScale;
|
|
30660
|
-
const pageNodeSegmentIdentityKeysByPage =
|
|
30945
|
+
const pageNodeSegmentIdentityKeysByPage = React2.useMemo(
|
|
30661
30946
|
() => pageNodeSegmentsByPage.map(
|
|
30662
30947
|
(pageSegments) => documentPageNodeSegmentsIdentityKey(pageSegments)
|
|
30663
30948
|
),
|
|
30664
30949
|
[pageNodeSegmentsByPage]
|
|
30665
30950
|
);
|
|
30666
|
-
const pageIndexByNodeIndex =
|
|
30951
|
+
const pageIndexByNodeIndex = React2.useMemo(() => {
|
|
30667
30952
|
const indexByNode = /* @__PURE__ */ new Map();
|
|
30668
30953
|
pageNodeSegmentsByPage.forEach((segments, pageIndex) => {
|
|
30669
30954
|
segments.forEach((segment) => {
|
|
@@ -30674,14 +30959,14 @@ function DocxEditorViewer({
|
|
|
30674
30959
|
});
|
|
30675
30960
|
return indexByNode;
|
|
30676
30961
|
}, [pageNodeSegmentsByPage]);
|
|
30677
|
-
const storedDocumentPageCount =
|
|
30962
|
+
const storedDocumentPageCount = React2.useMemo(() => {
|
|
30678
30963
|
const value = editor.model.metadata.documentPageCount;
|
|
30679
30964
|
if (!Number.isFinite(value) || value <= 0) {
|
|
30680
30965
|
return void 0;
|
|
30681
30966
|
}
|
|
30682
30967
|
return Math.max(1, Math.round(value));
|
|
30683
30968
|
}, [editor.model.metadata.documentPageCount]);
|
|
30684
|
-
const pageSectionInfoByIndex =
|
|
30969
|
+
const pageSectionInfoByIndex = React2.useMemo(() => {
|
|
30685
30970
|
if (pageNodeSegmentsByPage.length === 0) {
|
|
30686
30971
|
return [];
|
|
30687
30972
|
}
|
|
@@ -30818,7 +31103,7 @@ function DocxEditorViewer({
|
|
|
30818
31103
|
pageNodeSegmentsByPage,
|
|
30819
31104
|
primarySectionPropertiesXml
|
|
30820
31105
|
]);
|
|
30821
|
-
const pageThumbnailContentKeysByPage =
|
|
31106
|
+
const pageThumbnailContentKeysByPage = React2.useMemo(() => {
|
|
30822
31107
|
const metadataSignature = docModelThumbnailMetadataSignature(
|
|
30823
31108
|
editor.model.metadata
|
|
30824
31109
|
);
|
|
@@ -30848,7 +31133,7 @@ function DocxEditorViewer({
|
|
|
30848
31133
|
pageSectionInfoByIndex,
|
|
30849
31134
|
trackedChangesEnabled
|
|
30850
31135
|
]);
|
|
30851
|
-
const pageThumbnailSurfaceSizesByPage =
|
|
31136
|
+
const pageThumbnailSurfaceSizesByPage = React2.useMemo(
|
|
30852
31137
|
() => pageNodeSegmentsByPage.map((_, pageIndex) => {
|
|
30853
31138
|
const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
|
|
30854
31139
|
return {
|
|
@@ -30858,7 +31143,7 @@ function DocxEditorViewer({
|
|
|
30858
31143
|
}),
|
|
30859
31144
|
[documentLayout, pageNodeSegmentsByPage, pageSectionInfoByIndex]
|
|
30860
31145
|
);
|
|
30861
|
-
const pageThumbnailSnapshotEntriesByPage =
|
|
31146
|
+
const pageThumbnailSnapshotEntriesByPage = React2.useMemo(
|
|
30862
31147
|
() => buildDocxPageThumbnailRenderSnapshotEntries({
|
|
30863
31148
|
model: editor.model,
|
|
30864
31149
|
pageNodeSegmentsByPage,
|
|
@@ -30880,7 +31165,7 @@ function DocxEditorViewer({
|
|
|
30880
31165
|
pageThumbnailContentKeysByPage
|
|
30881
31166
|
]
|
|
30882
31167
|
);
|
|
30883
|
-
|
|
31168
|
+
React2.useEffect(() => {
|
|
30884
31169
|
syncDocxViewerPageSurfaceContentKeys(
|
|
30885
31170
|
editor,
|
|
30886
31171
|
pageThumbnailContentKeysByPage,
|
|
@@ -30893,7 +31178,7 @@ function DocxEditorViewer({
|
|
|
30893
31178
|
pageThumbnailSnapshotEntriesByPage,
|
|
30894
31179
|
pageThumbnailSurfaceSizesByPage
|
|
30895
31180
|
]);
|
|
30896
|
-
const resolveStyleRefFieldValueForPage =
|
|
31181
|
+
const resolveStyleRefFieldValueForPage = React2.useMemo(() => {
|
|
30897
31182
|
const valueCache = /* @__PURE__ */ new Map();
|
|
30898
31183
|
const nodes = editor.model.nodes;
|
|
30899
31184
|
const resolveFromParagraph = (paragraph, target, normalizedTarget) => {
|
|
@@ -30958,14 +31243,43 @@ function DocxEditorViewer({
|
|
|
30958
31243
|
};
|
|
30959
31244
|
}, [editor.model.nodes, pageNodeSegmentsByPage]);
|
|
30960
31245
|
const pageCount = pageNodeSegmentsByPage.length;
|
|
30961
|
-
const
|
|
31246
|
+
const viewerZoomContentSize = React2.useMemo(() => {
|
|
31247
|
+
let width = documentLayout.pageWidthPx;
|
|
31248
|
+
let height = documentLayout.pageHeightPx;
|
|
31249
|
+
pageSectionInfoByIndex.forEach(({ layout }) => {
|
|
31250
|
+
width = Math.max(width, layout.pageWidthPx);
|
|
31251
|
+
height = Math.max(height, layout.pageHeightPx);
|
|
31252
|
+
});
|
|
31253
|
+
if (showTrackedChangeGutter) {
|
|
31254
|
+
width += TRACKED_CHANGE_GUTTER_WIDTH_PX;
|
|
31255
|
+
}
|
|
31256
|
+
return { width, height };
|
|
31257
|
+
}, [documentLayout, pageSectionInfoByIndex, showTrackedChangeGutter]);
|
|
31258
|
+
const onViewerZoomBridgeChange = React2.useCallback(
|
|
31259
|
+
(bridge) => {
|
|
31260
|
+
setViewerZoomBridge(editor, bridge);
|
|
31261
|
+
},
|
|
31262
|
+
[editor.syncPaginationInfo]
|
|
31263
|
+
);
|
|
31264
|
+
const viewerZoom = useViewerZoom({
|
|
31265
|
+
zoom,
|
|
31266
|
+
defaultZoom: defaultZoom ?? editor.getZoom(),
|
|
31267
|
+
onZoomChange,
|
|
31268
|
+
rootRef: viewerRootRef,
|
|
31269
|
+
contentWidth: viewerZoomContentSize.width,
|
|
31270
|
+
contentHeight: viewerZoomContentSize.height,
|
|
31271
|
+
pageSelector: '[data-docx-page-wrapper="true"]',
|
|
31272
|
+
onBridgeChange: onViewerZoomBridgeChange
|
|
31273
|
+
});
|
|
31274
|
+
const builtInViewerZoomScale = viewerZoom.resolvedZoom / 100;
|
|
31275
|
+
const requestedPageIndexes = React2.useMemo(
|
|
30962
31276
|
() => normalizeDocxThumbnailPageIndexes(pageIndexes, pageCount).sort(
|
|
30963
31277
|
(left, right) => left - right
|
|
30964
31278
|
),
|
|
30965
31279
|
[pageCount, pageIndexes]
|
|
30966
31280
|
);
|
|
30967
31281
|
const hasRequestedPageIndexes = pageIndexes !== void 0;
|
|
30968
|
-
const hasLargeTableLayoutSurface =
|
|
31282
|
+
const hasLargeTableLayoutSurface = React2.useMemo(() => {
|
|
30969
31283
|
let tableParagraphCount = 0;
|
|
30970
31284
|
let tableCellCount = 0;
|
|
30971
31285
|
let largestRowParagraphCount = 0;
|
|
@@ -30992,7 +31306,7 @@ function DocxEditorViewer({
|
|
|
30992
31306
|
return tableParagraphCount >= 1e3 || tableCellCount >= 240 || largestRowParagraphCount >= 100;
|
|
30993
31307
|
}, [editor.model.nodes]);
|
|
30994
31308
|
const hideDocumentUntilPaginationSettled = deferInitialPaginationPaint && !isInitialPaginationSettled;
|
|
30995
|
-
const estimateDocumentStackHeightPx =
|
|
31309
|
+
const estimateDocumentStackHeightPx = React2.useCallback(
|
|
30996
31310
|
(count) => {
|
|
30997
31311
|
const safeCount = Math.max(0, Math.round(count));
|
|
30998
31312
|
if (safeCount <= 0) {
|
|
@@ -31008,7 +31322,7 @@ function DocxEditorViewer({
|
|
|
31008
31322
|
},
|
|
31009
31323
|
[documentLayout, pageSectionInfoByIndex]
|
|
31010
31324
|
);
|
|
31011
|
-
|
|
31325
|
+
React2.useEffect(() => {
|
|
31012
31326
|
if (!hideDocumentUntilPaginationSettled) {
|
|
31013
31327
|
setInitialPaginationReservedLayoutState((current) => {
|
|
31014
31328
|
if (current.pageCount === 0 && current.totalHeightPx === 0) {
|
|
@@ -31060,10 +31374,10 @@ function DocxEditorViewer({
|
|
|
31060
31374
|
)
|
|
31061
31375
|
) : 0;
|
|
31062
31376
|
const hasExternalVisiblePageRange = hasRequestedPageIndexes || Number.isFinite(Number(visiblePageRange?.startPageIndex)) || Number.isFinite(Number(visiblePageRange?.endPageIndex));
|
|
31063
|
-
const [deferInternalPageVirtualization, setDeferInternalPageVirtualization] =
|
|
31064
|
-
const [internalVirtualScrollElement, setInternalVirtualScrollElement] =
|
|
31065
|
-
const [virtualizerMeasurementScale, setVirtualizerMeasurementScale] =
|
|
31066
|
-
const [observedVisiblePageRange, setObservedVisiblePageRange] =
|
|
31377
|
+
const [deferInternalPageVirtualization, setDeferInternalPageVirtualization] = React2.useState(false);
|
|
31378
|
+
const [internalVirtualScrollElement, setInternalVirtualScrollElement] = React2.useState(null);
|
|
31379
|
+
const [virtualizerMeasurementScale, setVirtualizerMeasurementScale] = React2.useState(1);
|
|
31380
|
+
const [observedVisiblePageRange, setObservedVisiblePageRange] = React2.useState(void 0);
|
|
31067
31381
|
const pageVirtualizationSettleDelayMs = Math.max(
|
|
31068
31382
|
0,
|
|
31069
31383
|
Math.round(
|
|
@@ -31081,16 +31395,16 @@ function DocxEditorViewer({
|
|
|
31081
31395
|
const internalPageVirtualizationRequested = pageVirtualization?.enabled !== false && !hasExternalVisiblePageRange && !hideDocumentUntilPaginationSettled && isInitialPaginationSettled && !deferInternalPageVirtualization && !webdriverActive && pageCount > 1;
|
|
31082
31396
|
const explicitPageVirtualizationScrollElement = pageVirtualization?.scrollElement ?? null;
|
|
31083
31397
|
const explicitPageVirtualizationZoomScale = normalizePageVirtualizationZoomScale(pageVirtualization?.zoomScale);
|
|
31084
|
-
const resolveViewerMeasurementZoomScale =
|
|
31398
|
+
const resolveViewerMeasurementZoomScale = React2.useCallback(
|
|
31085
31399
|
(rootElement, fallback = 1) => {
|
|
31086
31400
|
if (explicitPageVirtualizationZoomScale !== void 0) {
|
|
31087
|
-
return explicitPageVirtualizationZoomScale;
|
|
31401
|
+
return explicitPageVirtualizationZoomScale * builtInViewerZoomScale;
|
|
31088
31402
|
}
|
|
31089
|
-
return rootElement ? resolveEffectiveZoomScale(rootElement) : fallback;
|
|
31403
|
+
return rootElement ? resolveEffectiveZoomScale(rootElement) : fallback * builtInViewerZoomScale;
|
|
31090
31404
|
},
|
|
31091
|
-
[explicitPageVirtualizationZoomScale]
|
|
31405
|
+
[builtInViewerZoomScale, explicitPageVirtualizationZoomScale]
|
|
31092
31406
|
);
|
|
31093
|
-
|
|
31407
|
+
React2.useEffect(() => {
|
|
31094
31408
|
if (floatingMovePreview || objectWrapDragPreview || resizePreview || tableMoveDragRef.current) {
|
|
31095
31409
|
return;
|
|
31096
31410
|
}
|
|
@@ -31222,10 +31536,10 @@ function DocxEditorViewer({
|
|
|
31222
31536
|
}
|
|
31223
31537
|
setMeasuredWrapBands(next);
|
|
31224
31538
|
});
|
|
31225
|
-
|
|
31539
|
+
React2.useEffect(() => {
|
|
31226
31540
|
setDeferInternalPageVirtualization(!hasLargeTableLayoutSurface);
|
|
31227
31541
|
}, [editor.documentLoadNonce, hasLargeTableLayoutSurface]);
|
|
31228
|
-
|
|
31542
|
+
React2.useEffect(() => {
|
|
31229
31543
|
if (typeof window === "undefined" || webdriverActive || pageCount <= 1) {
|
|
31230
31544
|
setDeferInternalPageVirtualization(true);
|
|
31231
31545
|
return;
|
|
@@ -31247,12 +31561,12 @@ function DocxEditorViewer({
|
|
|
31247
31561
|
pageVirtualizationSettleDelayMs,
|
|
31248
31562
|
webdriverActive
|
|
31249
31563
|
]);
|
|
31250
|
-
|
|
31564
|
+
React2.useLayoutEffect(() => {
|
|
31251
31565
|
if (typeof window === "undefined") {
|
|
31252
31566
|
return;
|
|
31253
31567
|
}
|
|
31254
31568
|
setInternalVirtualScrollElement(
|
|
31255
|
-
explicitPageVirtualizationScrollElement instanceof HTMLElement ? explicitPageVirtualizationScrollElement :
|
|
31569
|
+
explicitPageVirtualizationScrollElement instanceof HTMLElement ? explicitPageVirtualizationScrollElement : nearestScrollableAncestor2(viewerRootRef.current)
|
|
31256
31570
|
);
|
|
31257
31571
|
}, [
|
|
31258
31572
|
editor.documentLoadNonce,
|
|
@@ -31260,8 +31574,8 @@ function DocxEditorViewer({
|
|
|
31260
31574
|
pageCount,
|
|
31261
31575
|
trackedChangesEnabled
|
|
31262
31576
|
]);
|
|
31263
|
-
const [zoomProbeNonce, setZoomProbeNonce] =
|
|
31264
|
-
|
|
31577
|
+
const [zoomProbeNonce, setZoomProbeNonce] = React2.useState(0);
|
|
31578
|
+
React2.useEffect(() => {
|
|
31265
31579
|
if (typeof window === "undefined") {
|
|
31266
31580
|
return;
|
|
31267
31581
|
}
|
|
@@ -31280,7 +31594,7 @@ function DocxEditorViewer({
|
|
|
31280
31594
|
window.removeEventListener("resize", bumpZoomProbe);
|
|
31281
31595
|
};
|
|
31282
31596
|
}, [editor.documentLoadNonce]);
|
|
31283
|
-
|
|
31597
|
+
React2.useLayoutEffect(() => {
|
|
31284
31598
|
if (typeof window === "undefined") {
|
|
31285
31599
|
return;
|
|
31286
31600
|
}
|
|
@@ -31309,7 +31623,7 @@ function DocxEditorViewer({
|
|
|
31309
31623
|
const internalVirtualScrollUsesWindow = typeof document !== "undefined" && internalVirtualScrollElement !== null && (internalVirtualScrollElement === document.scrollingElement || internalVirtualScrollElement === document.documentElement || internalVirtualScrollElement === document.body);
|
|
31310
31624
|
const internalElementPageVirtualizationEnabled = internalPageVirtualizationEnabled && !internalVirtualScrollUsesWindow;
|
|
31311
31625
|
const internalWindowPageVirtualizationEnabled = internalPageVirtualizationEnabled && internalVirtualScrollUsesWindow;
|
|
31312
|
-
const estimateVirtualPageSize =
|
|
31626
|
+
const estimateVirtualPageSize = React2.useCallback(
|
|
31313
31627
|
(pageIndex) => {
|
|
31314
31628
|
const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
|
|
31315
31629
|
return Math.max(
|
|
@@ -31321,7 +31635,7 @@ function DocxEditorViewer({
|
|
|
31321
31635
|
},
|
|
31322
31636
|
[documentLayout, pageSectionInfoByIndex, virtualizerMeasurementScale]
|
|
31323
31637
|
);
|
|
31324
|
-
const suspendPaginationMeasurementForScroll =
|
|
31638
|
+
const suspendPaginationMeasurementForScroll = React2.useCallback(() => {
|
|
31325
31639
|
paginationMeasurementSuspendUntilRef.current = Date.now() + PAGE_SCROLL_MEASUREMENT_SUSPEND_MS;
|
|
31326
31640
|
}, []);
|
|
31327
31641
|
const internalElementPageVirtualizer = useVirtualizer({
|
|
@@ -31342,7 +31656,7 @@ function DocxEditorViewer({
|
|
|
31342
31656
|
(layout.pageHeightPx + DOC_PAGE_BREAK_GAP) * virtualizerMeasurementScale
|
|
31343
31657
|
)
|
|
31344
31658
|
).join("|");
|
|
31345
|
-
|
|
31659
|
+
React2.useLayoutEffect(() => {
|
|
31346
31660
|
internalElementPageVirtualizer.measure();
|
|
31347
31661
|
internalWindowPageVirtualizer.measure();
|
|
31348
31662
|
}, [
|
|
@@ -31353,7 +31667,7 @@ function DocxEditorViewer({
|
|
|
31353
31667
|
internalWindowPageVirtualizer
|
|
31354
31668
|
]);
|
|
31355
31669
|
const internalVirtualItems = internalPageVirtualizer.getVirtualItems();
|
|
31356
|
-
const internalMostVisiblePageIndex =
|
|
31670
|
+
const internalMostVisiblePageIndex = React2.useMemo(() => {
|
|
31357
31671
|
if (!internalPageVirtualizationEnabled || internalVirtualItems.length === 0) {
|
|
31358
31672
|
return void 0;
|
|
31359
31673
|
}
|
|
@@ -31377,7 +31691,7 @@ function DocxEditorViewer({
|
|
|
31377
31691
|
internalVirtualItems,
|
|
31378
31692
|
pageCount
|
|
31379
31693
|
]);
|
|
31380
|
-
const internalVisiblePageRange =
|
|
31694
|
+
const internalVisiblePageRange = React2.useMemo(() => {
|
|
31381
31695
|
if (!internalPageVirtualizationEnabled) {
|
|
31382
31696
|
return void 0;
|
|
31383
31697
|
}
|
|
@@ -31410,7 +31724,7 @@ function DocxEditorViewer({
|
|
|
31410
31724
|
endPageIndex
|
|
31411
31725
|
};
|
|
31412
31726
|
}, [internalPageVirtualizationEnabled, internalVirtualItems, pageCount]);
|
|
31413
|
-
const internalRenderVisiblePageRange =
|
|
31727
|
+
const internalRenderVisiblePageRange = React2.useMemo(() => {
|
|
31414
31728
|
if (!internalVisiblePageRange) {
|
|
31415
31729
|
return void 0;
|
|
31416
31730
|
}
|
|
@@ -31442,7 +31756,7 @@ function DocxEditorViewer({
|
|
|
31442
31756
|
pageVirtualization?.overscan
|
|
31443
31757
|
]);
|
|
31444
31758
|
const shouldObserveVisiblePageRange = hasLargeTableLayoutSurface || internalVirtualItems.length === 0;
|
|
31445
|
-
|
|
31759
|
+
React2.useLayoutEffect(() => {
|
|
31446
31760
|
if (!internalPageVirtualizationEnabled || !internalVirtualScrollElement || !shouldObserveVisiblePageRange || typeof window === "undefined") {
|
|
31447
31761
|
setObservedVisiblePageRange(
|
|
31448
31762
|
(current) => current === void 0 ? current : void 0
|
|
@@ -31458,14 +31772,14 @@ function DocxEditorViewer({
|
|
|
31458
31772
|
}
|
|
31459
31773
|
let frameId = null;
|
|
31460
31774
|
const commitObservedVisiblePageRange = (updater) => {
|
|
31461
|
-
|
|
31775
|
+
React2.startTransition(() => {
|
|
31462
31776
|
setObservedVisiblePageRange(updater);
|
|
31463
31777
|
});
|
|
31464
31778
|
};
|
|
31465
31779
|
const syncVisiblePageRange = () => {
|
|
31466
31780
|
frameId = null;
|
|
31467
31781
|
suspendPaginationMeasurementForScroll();
|
|
31468
|
-
const
|
|
31782
|
+
const viewportRect2 = internalVirtualScrollUsesWindow ? {
|
|
31469
31783
|
top: 0,
|
|
31470
31784
|
bottom: window.innerHeight
|
|
31471
31785
|
} : internalVirtualScrollElement.getBoundingClientRect();
|
|
@@ -31481,10 +31795,10 @@ function DocxEditorViewer({
|
|
|
31481
31795
|
continue;
|
|
31482
31796
|
}
|
|
31483
31797
|
const pageRect = pageWrapper.getBoundingClientRect();
|
|
31484
|
-
if (pageRect.bottom <=
|
|
31798
|
+
if (pageRect.bottom <= viewportRect2.top) {
|
|
31485
31799
|
continue;
|
|
31486
31800
|
}
|
|
31487
|
-
if (pageRect.top >=
|
|
31801
|
+
if (pageRect.top >= viewportRect2.bottom) {
|
|
31488
31802
|
if (firstVisiblePageIndex !== void 0) {
|
|
31489
31803
|
break;
|
|
31490
31804
|
}
|
|
@@ -31574,7 +31888,7 @@ function DocxEditorViewer({
|
|
|
31574
31888
|
shouldObserveVisiblePageRange,
|
|
31575
31889
|
suspendPaginationMeasurementForScroll
|
|
31576
31890
|
]);
|
|
31577
|
-
|
|
31891
|
+
React2.useEffect(() => {
|
|
31578
31892
|
if (!internalPageVirtualizationEnabled || !internalVirtualScrollElement || typeof window === "undefined") {
|
|
31579
31893
|
return;
|
|
31580
31894
|
}
|
|
@@ -31592,7 +31906,7 @@ function DocxEditorViewer({
|
|
|
31592
31906
|
internalVirtualScrollUsesWindow,
|
|
31593
31907
|
suspendPaginationMeasurementForScroll
|
|
31594
31908
|
]);
|
|
31595
|
-
const internalEffectiveRenderVisiblePageRange =
|
|
31909
|
+
const internalEffectiveRenderVisiblePageRange = React2.useMemo(() => {
|
|
31596
31910
|
if (!internalRenderVisiblePageRange) {
|
|
31597
31911
|
return observedVisiblePageRange;
|
|
31598
31912
|
}
|
|
@@ -31625,7 +31939,7 @@ function DocxEditorViewer({
|
|
|
31625
31939
|
Math.max(0, pageVirtualizationOverscan)
|
|
31626
31940
|
)
|
|
31627
31941
|
} : void 0);
|
|
31628
|
-
const normalizedVisiblePageRange =
|
|
31942
|
+
const normalizedVisiblePageRange = React2.useMemo(() => {
|
|
31629
31943
|
if (pageCount <= 0) {
|
|
31630
31944
|
return {
|
|
31631
31945
|
startPageIndex: 0,
|
|
@@ -31657,7 +31971,7 @@ function DocxEditorViewer({
|
|
|
31657
31971
|
const measureAllPagesBeforeInitialReveal = hideDocumentUntilPaginationSettled && pageCount > 0 && initialPremeasureStartPageIndex === 0 && initialPremeasureEndPageIndex >= pageCount - 1;
|
|
31658
31972
|
const visiblePageStartIndex = hasRequestedPageIndexes ? requestedPageIndexes[0] ?? 0 : measureAllPagesBeforeInitialReveal ? 0 : hideDocumentUntilPaginationSettled ? initialPremeasureStartPageIndex : normalizedVisiblePageRange.startPageIndex;
|
|
31659
31973
|
const visiblePageEndIndex = hasRequestedPageIndexes ? requestedPageIndexes[requestedPageIndexes.length - 1] ?? -1 : measureAllPagesBeforeInitialReveal ? pageCount - 1 : hideDocumentUntilPaginationSettled ? initialPremeasureEndPageIndex : normalizedVisiblePageRange.endPageIndex;
|
|
31660
|
-
const visiblePageIndexes =
|
|
31974
|
+
const visiblePageIndexes = React2.useMemo(() => {
|
|
31661
31975
|
if (hasRequestedPageIndexes) {
|
|
31662
31976
|
return requestedPageIndexes;
|
|
31663
31977
|
}
|
|
@@ -31676,7 +31990,7 @@ function DocxEditorViewer({
|
|
|
31676
31990
|
visiblePageEndIndex,
|
|
31677
31991
|
visiblePageStartIndex
|
|
31678
31992
|
]);
|
|
31679
|
-
const pageStackVirtualSpacers =
|
|
31993
|
+
const pageStackVirtualSpacers = React2.useMemo(() => {
|
|
31680
31994
|
const pageWrapperWidthPxForIndex = (pageIndex) => {
|
|
31681
31995
|
const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
|
|
31682
31996
|
return showTrackedChangeGutter ? pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX : pageLayout.pageWidthPx;
|
|
@@ -31710,7 +32024,7 @@ function DocxEditorViewer({
|
|
|
31710
32024
|
visiblePageEndIndex,
|
|
31711
32025
|
visiblePageStartIndex
|
|
31712
32026
|
]);
|
|
31713
|
-
|
|
32027
|
+
React2.useLayoutEffect(() => {
|
|
31714
32028
|
if (typeof window === "undefined") {
|
|
31715
32029
|
return;
|
|
31716
32030
|
}
|
|
@@ -31760,7 +32074,7 @@ function DocxEditorViewer({
|
|
|
31760
32074
|
visiblePageEndIndex,
|
|
31761
32075
|
visiblePageStartIndex
|
|
31762
32076
|
]);
|
|
31763
|
-
const visibleTableRowIndexesByNodeIndex =
|
|
32077
|
+
const visibleTableRowIndexesByNodeIndex = React2.useMemo(() => {
|
|
31764
32078
|
const rowsByNodeIndex = /* @__PURE__ */ new Map();
|
|
31765
32079
|
const addRowIndex = (nodeIndex, rowIndex) => {
|
|
31766
32080
|
const tableNode = editor.model.nodes[nodeIndex];
|
|
@@ -31798,7 +32112,7 @@ function DocxEditorViewer({
|
|
|
31798
32112
|
return rowsByNodeIndex;
|
|
31799
32113
|
}, [editor.model.nodes, pageNodeSegmentsByPage, visiblePageIndexes]);
|
|
31800
32114
|
const paginationMeasurementEnabled = hideDocumentUntilPaginationSettled || postImportPaginationUnlocked;
|
|
31801
|
-
const visiblePagesHavePendingPaginationMeasurements =
|
|
32115
|
+
const visiblePagesHavePendingPaginationMeasurements = React2.useMemo(() => {
|
|
31802
32116
|
if (pageCount === 0) {
|
|
31803
32117
|
return false;
|
|
31804
32118
|
}
|
|
@@ -31836,13 +32150,13 @@ function DocxEditorViewer({
|
|
|
31836
32150
|
]);
|
|
31837
32151
|
const allowPostImportPaginationMeasurement = !hasLargeTableLayoutSurface || !internalPageVirtualizationEnabled;
|
|
31838
32152
|
const visiblePagesNeedMeasurementUnlock = !hideDocumentUntilPaginationSettled && allowPostImportPaginationMeasurement && visiblePagesHavePendingPaginationMeasurements;
|
|
31839
|
-
|
|
32153
|
+
React2.useEffect(() => {
|
|
31840
32154
|
if (!visiblePagesNeedMeasurementUnlock) {
|
|
31841
32155
|
return;
|
|
31842
32156
|
}
|
|
31843
32157
|
setPostImportPaginationUnlocked(true);
|
|
31844
32158
|
}, [visiblePagesNeedMeasurementUnlock]);
|
|
31845
|
-
|
|
32159
|
+
React2.useEffect(() => {
|
|
31846
32160
|
if (hideDocumentUntilPaginationSettled || !postImportPaginationUnlocked || visiblePagesNeedMeasurementUnlock) {
|
|
31847
32161
|
return;
|
|
31848
32162
|
}
|
|
@@ -31868,13 +32182,13 @@ function DocxEditorViewer({
|
|
|
31868
32182
|
postImportPaginationUnlocked,
|
|
31869
32183
|
visiblePagesNeedMeasurementUnlock
|
|
31870
32184
|
]);
|
|
31871
|
-
|
|
32185
|
+
React2.useEffect(() => {
|
|
31872
32186
|
if (!onPageCountChange) {
|
|
31873
32187
|
return;
|
|
31874
32188
|
}
|
|
31875
32189
|
onPageCountChange(stableReportedPageCount);
|
|
31876
32190
|
}, [onPageCountChange, stableReportedPageCount]);
|
|
31877
|
-
|
|
32191
|
+
React2.useEffect(() => {
|
|
31878
32192
|
const nextCurrentPage = clampNumber(
|
|
31879
32193
|
(internalMostVisiblePageIndex ?? visiblePageStartIndex) + 1,
|
|
31880
32194
|
1,
|
|
@@ -31890,7 +32204,7 @@ function DocxEditorViewer({
|
|
|
31890
32204
|
stableReportedPageCount,
|
|
31891
32205
|
visiblePageStartIndex
|
|
31892
32206
|
]);
|
|
31893
|
-
const trackedChangesByPage =
|
|
32207
|
+
const trackedChangesByPage = React2.useMemo(() => {
|
|
31894
32208
|
const pageBuckets = pageNodeSegmentsByPage.map(
|
|
31895
32209
|
() => []
|
|
31896
32210
|
);
|
|
@@ -31946,13 +32260,13 @@ function DocxEditorViewer({
|
|
|
31946
32260
|
pageNodeSegmentsByPage,
|
|
31947
32261
|
trackedChangesEnabled
|
|
31948
32262
|
]);
|
|
31949
|
-
const [trackedChangeAnchorByPage, setTrackedChangeAnchorByPage] =
|
|
31950
|
-
const [headerBodyClearanceByPage, setHeaderBodyClearanceByPage] =
|
|
31951
|
-
|
|
32263
|
+
const [trackedChangeAnchorByPage, setTrackedChangeAnchorByPage] = React2.useState([]);
|
|
32264
|
+
const [headerBodyClearanceByPage, setHeaderBodyClearanceByPage] = React2.useState({});
|
|
32265
|
+
React2.useEffect(() => {
|
|
31952
32266
|
setHeaderBodyClearanceByPage({});
|
|
31953
32267
|
}, [editor.documentLoadNonce]);
|
|
31954
|
-
const [trackedChangeCardHeightsByPage, setTrackedChangeCardHeightsByPage] =
|
|
31955
|
-
|
|
32268
|
+
const [trackedChangeCardHeightsByPage, setTrackedChangeCardHeightsByPage] = React2.useState([]);
|
|
32269
|
+
React2.useLayoutEffect(() => {
|
|
31956
32270
|
if (!showTrackedChangeGutter || trackedChangesByPage.length === 0) {
|
|
31957
32271
|
setTrackedChangeAnchorByPage(
|
|
31958
32272
|
(current) => current.length === 0 ? current : []
|
|
@@ -32005,7 +32319,7 @@ function DocxEditorViewer({
|
|
|
32005
32319
|
visiblePageEndIndex,
|
|
32006
32320
|
visiblePageStartIndex
|
|
32007
32321
|
]);
|
|
32008
|
-
|
|
32322
|
+
React2.useLayoutEffect(() => {
|
|
32009
32323
|
if (!showTrackedChangeGutter || trackedChangesByPage.length === 0) {
|
|
32010
32324
|
setTrackedChangeCardHeightsByPage(
|
|
32011
32325
|
(current) => current.length === 0 ? current : []
|
|
@@ -32068,7 +32382,7 @@ function DocxEditorViewer({
|
|
|
32068
32382
|
visiblePageEndIndex,
|
|
32069
32383
|
visiblePageStartIndex
|
|
32070
32384
|
]);
|
|
32071
|
-
const positionedTrackedChangesByPage =
|
|
32385
|
+
const positionedTrackedChangesByPage = React2.useMemo(() => {
|
|
32072
32386
|
return trackedChangesByPage.map((changes, pageIndex) => {
|
|
32073
32387
|
const pageLayout = pageSectionInfoByIndex[pageIndex]?.layout ?? documentLayout;
|
|
32074
32388
|
const anchorsByChangeId = trackedChangeAnchorByPage[pageIndex] ?? /* @__PURE__ */ new Map();
|
|
@@ -32088,7 +32402,7 @@ function DocxEditorViewer({
|
|
|
32088
32402
|
trackedChangeCardHeightsByPage,
|
|
32089
32403
|
trackedChangesByPage
|
|
32090
32404
|
]);
|
|
32091
|
-
const totalPagesForFieldResolution =
|
|
32405
|
+
const totalPagesForFieldResolution = React2.useMemo(() => {
|
|
32092
32406
|
if (editor.canUndo || editor.canRedo) {
|
|
32093
32407
|
return pageCount;
|
|
32094
32408
|
}
|
|
@@ -32103,7 +32417,7 @@ function DocxEditorViewer({
|
|
|
32103
32417
|
editor.model.metadata.documentPageCount,
|
|
32104
32418
|
pageCount
|
|
32105
32419
|
]);
|
|
32106
|
-
const isPageVisible =
|
|
32420
|
+
const isPageVisible = React2.useCallback(
|
|
32107
32421
|
(pageIndex) => {
|
|
32108
32422
|
return hasRequestedPageIndexes ? requestedPageIndexes.includes(pageIndex) : pageIndex >= visiblePageStartIndex && pageIndex <= visiblePageEndIndex;
|
|
32109
32423
|
},
|
|
@@ -32114,7 +32428,7 @@ function DocxEditorViewer({
|
|
|
32114
32428
|
visiblePageStartIndex
|
|
32115
32429
|
]
|
|
32116
32430
|
);
|
|
32117
|
-
const requestPageReveal =
|
|
32431
|
+
const requestPageReveal = React2.useCallback(
|
|
32118
32432
|
(targetPageIndex) => {
|
|
32119
32433
|
if (onRequestPageReveal) {
|
|
32120
32434
|
onRequestPageReveal(targetPageIndex);
|
|
@@ -32140,7 +32454,7 @@ function DocxEditorViewer({
|
|
|
32140
32454
|
pageCount
|
|
32141
32455
|
]
|
|
32142
32456
|
);
|
|
32143
|
-
const scrollToBookmark =
|
|
32457
|
+
const scrollToBookmark = React2.useCallback(
|
|
32144
32458
|
(bookmarkName) => {
|
|
32145
32459
|
const normalized = bookmarkName.trim();
|
|
32146
32460
|
if (!normalized) {
|
|
@@ -32204,7 +32518,7 @@ function DocxEditorViewer({
|
|
|
32204
32518
|
visiblePageStartIndex
|
|
32205
32519
|
]
|
|
32206
32520
|
);
|
|
32207
|
-
const pageHeaderAndFooterNodes =
|
|
32521
|
+
const pageHeaderAndFooterNodes = React2.useMemo(
|
|
32208
32522
|
() => pageNodeSegmentsByPage.map((_, pageIndex) => {
|
|
32209
32523
|
const sectionInfo = pageSectionInfoByIndex[pageIndex];
|
|
32210
32524
|
const sectionHeaderSections = sectionInfo?.section.headerSections ?? editor.model.metadata.headerSections;
|
|
@@ -32247,7 +32561,7 @@ function DocxEditorViewer({
|
|
|
32247
32561
|
editor.model.metadata.sectionPropertiesXml
|
|
32248
32562
|
]
|
|
32249
32563
|
);
|
|
32250
|
-
const headerBodyClearanceFloorByPage =
|
|
32564
|
+
const headerBodyClearanceFloorByPage = React2.useMemo(() => {
|
|
32251
32565
|
const next = {};
|
|
32252
32566
|
for (let pageIndex = 0; pageIndex < pageNodeSegmentsByPage.length; pageIndex += 1) {
|
|
32253
32567
|
const headerNodes = pageHeaderAndFooterNodes[pageIndex]?.headerNodes ?? [];
|
|
@@ -32277,7 +32591,7 @@ function DocxEditorViewer({
|
|
|
32277
32591
|
pageNodeSegmentsByPage.length,
|
|
32278
32592
|
pageSectionInfoByIndex
|
|
32279
32593
|
]);
|
|
32280
|
-
|
|
32594
|
+
React2.useLayoutEffect(() => {
|
|
32281
32595
|
if (!paginationMeasurementEnabled) {
|
|
32282
32596
|
return;
|
|
32283
32597
|
}
|
|
@@ -32379,7 +32693,7 @@ function DocxEditorViewer({
|
|
|
32379
32693
|
visiblePageEndIndex,
|
|
32380
32694
|
visiblePageStartIndex
|
|
32381
32695
|
]);
|
|
32382
|
-
|
|
32696
|
+
React2.useEffect(() => {
|
|
32383
32697
|
if (disableMeasuredImportPagination) {
|
|
32384
32698
|
setMeasuredPageContentHeightByIndex(
|
|
32385
32699
|
(current) => current.length === 0 ? current : []
|
|
@@ -32668,7 +32982,7 @@ function DocxEditorViewer({
|
|
|
32668
32982
|
visiblePageEndIndex,
|
|
32669
32983
|
visiblePageStartIndex
|
|
32670
32984
|
]);
|
|
32671
|
-
|
|
32985
|
+
React2.useEffect(() => {
|
|
32672
32986
|
if (!deferInitialPaginationPaint || isInitialPaginationSettled || disableMeasuredImportPagination) {
|
|
32673
32987
|
return;
|
|
32674
32988
|
}
|
|
@@ -32696,7 +33010,7 @@ function DocxEditorViewer({
|
|
|
32696
33010
|
isInitialPaginationSettled,
|
|
32697
33011
|
pageCount
|
|
32698
33012
|
]);
|
|
32699
|
-
|
|
33013
|
+
React2.useEffect(() => {
|
|
32700
33014
|
if (!deferInitialPaginationPaint || !isInitialPaginationSettled || initialPaginationBackgroundRefinementUnlocked) {
|
|
32701
33015
|
return;
|
|
32702
33016
|
}
|
|
@@ -32705,7 +33019,7 @@ function DocxEditorViewer({
|
|
|
32705
33019
|
return;
|
|
32706
33020
|
}
|
|
32707
33021
|
const timeoutId = window.setTimeout(() => {
|
|
32708
|
-
|
|
33022
|
+
React2.startTransition(() => {
|
|
32709
33023
|
setInitialPaginationBackgroundRefinementUnlocked(true);
|
|
32710
33024
|
});
|
|
32711
33025
|
}, INITIAL_PAGINATION_BACKGROUND_REFINEMENT_DELAY_MS);
|
|
@@ -32717,7 +33031,7 @@ function DocxEditorViewer({
|
|
|
32717
33031
|
initialPaginationBackgroundRefinementUnlocked,
|
|
32718
33032
|
isInitialPaginationSettled
|
|
32719
33033
|
]);
|
|
32720
|
-
|
|
33034
|
+
React2.useEffect(() => {
|
|
32721
33035
|
if (!deferInitialPaginationPaint || isInitialPaginationSettled) {
|
|
32722
33036
|
return;
|
|
32723
33037
|
}
|
|
@@ -32833,7 +33147,7 @@ function DocxEditorViewer({
|
|
|
32833
33147
|
visiblePageEndIndex,
|
|
32834
33148
|
visiblePageStartIndex
|
|
32835
33149
|
]);
|
|
32836
|
-
const setSingleTableCellSelection =
|
|
33150
|
+
const setSingleTableCellSelection = React2.useCallback(
|
|
32837
33151
|
(tableIndex, rowIndex, cellIndex) => {
|
|
32838
33152
|
const nextRange = {
|
|
32839
33153
|
tableIndex,
|
|
@@ -32851,10 +33165,10 @@ function DocxEditorViewer({
|
|
|
32851
33165
|
},
|
|
32852
33166
|
[]
|
|
32853
33167
|
);
|
|
32854
|
-
const clearTableCellSelection =
|
|
33168
|
+
const clearTableCellSelection = React2.useCallback(() => {
|
|
32855
33169
|
setTableCellSelectionRange((current) => current ? void 0 : current);
|
|
32856
33170
|
}, []);
|
|
32857
|
-
const isPointWithinTableHandleHoverZone =
|
|
33171
|
+
const isPointWithinTableHandleHoverZone = React2.useCallback(
|
|
32858
33172
|
(tableIndex, x, y) => {
|
|
32859
33173
|
const tableElement = tableElementsRef.current.get(tableIndex);
|
|
32860
33174
|
if (!tableElement || !tableElement.isConnected) {
|
|
@@ -32868,7 +33182,7 @@ function DocxEditorViewer({
|
|
|
32868
33182
|
},
|
|
32869
33183
|
[]
|
|
32870
33184
|
);
|
|
32871
|
-
const resolveHoveredTableHandleIndexFromPoint =
|
|
33185
|
+
const resolveHoveredTableHandleIndexFromPoint = React2.useCallback(
|
|
32872
33186
|
(x, y) => {
|
|
32873
33187
|
let nextHoveredTableIndex;
|
|
32874
33188
|
let bestDistance = Number.POSITIVE_INFINITY;
|
|
@@ -32895,7 +33209,7 @@ function DocxEditorViewer({
|
|
|
32895
33209
|
},
|
|
32896
33210
|
[]
|
|
32897
33211
|
);
|
|
32898
|
-
const onViewerPointerMove =
|
|
33212
|
+
const onViewerPointerMove = React2.useCallback(
|
|
32899
33213
|
(event) => {
|
|
32900
33214
|
if (isReadOnly) {
|
|
32901
33215
|
return;
|
|
@@ -32913,7 +33227,7 @@ function DocxEditorViewer({
|
|
|
32913
33227
|
},
|
|
32914
33228
|
[isReadOnly, resolveHoveredTableHandleIndexFromPoint]
|
|
32915
33229
|
);
|
|
32916
|
-
const onViewerPointerLeave =
|
|
33230
|
+
const onViewerPointerLeave = React2.useCallback(() => {
|
|
32917
33231
|
if (isReadOnly) {
|
|
32918
33232
|
return;
|
|
32919
33233
|
}
|
|
@@ -32922,7 +33236,7 @@ function DocxEditorViewer({
|
|
|
32922
33236
|
}
|
|
32923
33237
|
setHoveredTableHandleTableIndex(void 0);
|
|
32924
33238
|
}, [isReadOnly]);
|
|
32925
|
-
const selectWholeTable =
|
|
33239
|
+
const selectWholeTable = React2.useCallback(
|
|
32926
33240
|
(tableIndex) => {
|
|
32927
33241
|
const tableNode = editor.model.nodes[tableIndex];
|
|
32928
33242
|
if (!tableNode || tableNode.type !== "table") {
|
|
@@ -32948,7 +33262,7 @@ function DocxEditorViewer({
|
|
|
32948
33262
|
},
|
|
32949
33263
|
[editor]
|
|
32950
33264
|
);
|
|
32951
|
-
const resolveTableMoveDropTarget =
|
|
33265
|
+
const resolveTableMoveDropTarget = React2.useCallback(
|
|
32952
33266
|
(tableIndex, point) => {
|
|
32953
33267
|
const rootElement = viewerRootRef.current;
|
|
32954
33268
|
if (!rootElement) {
|
|
@@ -33009,9 +33323,9 @@ function DocxEditorViewer({
|
|
|
33009
33323
|
},
|
|
33010
33324
|
[editor.model.nodes.length]
|
|
33011
33325
|
);
|
|
33012
|
-
const objectWrapDragSignatureRef =
|
|
33013
|
-
const objectWrapDragLatestRef =
|
|
33014
|
-
const updateObjectWrapDragPreview =
|
|
33326
|
+
const objectWrapDragSignatureRef = React2.useRef("");
|
|
33327
|
+
const objectWrapDragLatestRef = React2.useRef(void 0);
|
|
33328
|
+
const updateObjectWrapDragPreview = React2.useCallback(
|
|
33015
33329
|
(frame, source, distances) => {
|
|
33016
33330
|
const bandsByPage = /* @__PURE__ */ new Map();
|
|
33017
33331
|
let pageIndex = -1;
|
|
@@ -33100,7 +33414,7 @@ function DocxEditorViewer({
|
|
|
33100
33414
|
},
|
|
33101
33415
|
[resolveViewerMeasurementZoomScale]
|
|
33102
33416
|
);
|
|
33103
|
-
const clearObjectDragPreview =
|
|
33417
|
+
const clearObjectDragPreview = React2.useCallback(
|
|
33104
33418
|
(preserveMeasurements = false) => {
|
|
33105
33419
|
if (preserveMeasurements && objectWrapDragLatestRef.current) {
|
|
33106
33420
|
const next = new Map(measuredWrapBands);
|
|
@@ -33120,7 +33434,7 @@ function DocxEditorViewer({
|
|
|
33120
33434
|
},
|
|
33121
33435
|
[measuredWrapBands]
|
|
33122
33436
|
);
|
|
33123
|
-
const beginTableMoveDrag =
|
|
33437
|
+
const beginTableMoveDrag = React2.useCallback(
|
|
33124
33438
|
(event, tableIndex) => {
|
|
33125
33439
|
if (isReadOnly || event.button !== 0) return;
|
|
33126
33440
|
const element = tableElementsRef.current.get(tableIndex);
|
|
@@ -33138,12 +33452,12 @@ function DocxEditorViewer({
|
|
|
33138
33452
|
startY: event.clientY,
|
|
33139
33453
|
hasMoved: false
|
|
33140
33454
|
};
|
|
33141
|
-
const
|
|
33455
|
+
const zoom2 = resolveViewerMeasurementZoomScale(element, 1);
|
|
33142
33456
|
const floating = table.style?.floating;
|
|
33143
33457
|
objectDragCleanupRef.current = startObjectDrag({
|
|
33144
33458
|
event,
|
|
33145
33459
|
element,
|
|
33146
|
-
zoom,
|
|
33460
|
+
zoom: zoom2,
|
|
33147
33461
|
resolveElement: () => tableElementsRef.current.get(tableIndex),
|
|
33148
33462
|
onFrame: (frame) => {
|
|
33149
33463
|
if (tableMoveDragRef.current)
|
|
@@ -33178,7 +33492,7 @@ function DocxEditorViewer({
|
|
|
33178
33492
|
const anchorLayout = anchorParagraph?.type === "paragraph" && anchorSource && anchorRect ? layoutParagraphPretextSource(
|
|
33179
33493
|
anchorParagraph,
|
|
33180
33494
|
anchorSource,
|
|
33181
|
-
anchorRect.width /
|
|
33495
|
+
anchorRect.width / zoom2,
|
|
33182
33496
|
Number(anchor?.host.dataset.docxParagraphLineHeight) || estimateParagraphLineHeightPx(anchorParagraph),
|
|
33183
33497
|
[]
|
|
33184
33498
|
) : void 0;
|
|
@@ -33189,9 +33503,9 @@ function DocxEditorViewer({
|
|
|
33189
33503
|
tableIndex,
|
|
33190
33504
|
{
|
|
33191
33505
|
xTwips: pixelsToTwips(
|
|
33192
|
-
(frame.left - (bodyRect?.left ?? anchorRect.left)) /
|
|
33506
|
+
(frame.left - (bodyRect?.left ?? anchorRect.left)) / zoom2
|
|
33193
33507
|
),
|
|
33194
|
-
yTwips: pixelsToTwips((frame.top - anchorRect.top) /
|
|
33508
|
+
yTwips: pixelsToTwips((frame.top - anchorRect.top) / zoom2),
|
|
33195
33509
|
horizontalAnchor: "margin",
|
|
33196
33510
|
verticalAnchor: "text",
|
|
33197
33511
|
horizontalAlign: void 0,
|
|
@@ -33215,13 +33529,13 @@ function DocxEditorViewer({
|
|
|
33215
33529
|
clearObjectDragPreview
|
|
33216
33530
|
]
|
|
33217
33531
|
);
|
|
33218
|
-
const closeTableContextMenu =
|
|
33532
|
+
const closeTableContextMenu = React2.useCallback(() => {
|
|
33219
33533
|
setTableContextMenuState(void 0);
|
|
33220
33534
|
}, []);
|
|
33221
|
-
const closeContextMenu =
|
|
33535
|
+
const closeContextMenu = React2.useCallback(() => {
|
|
33222
33536
|
setContextMenuState(void 0);
|
|
33223
33537
|
}, []);
|
|
33224
|
-
const openContextMenu =
|
|
33538
|
+
const openContextMenu = React2.useCallback(
|
|
33225
33539
|
(context, point) => {
|
|
33226
33540
|
setTableContextMenuState(void 0);
|
|
33227
33541
|
setContextMenuState({
|
|
@@ -33232,7 +33546,7 @@ function DocxEditorViewer({
|
|
|
33232
33546
|
},
|
|
33233
33547
|
[]
|
|
33234
33548
|
);
|
|
33235
|
-
const openTableContextMenu =
|
|
33549
|
+
const openTableContextMenu = React2.useCallback(
|
|
33236
33550
|
(context, point) => {
|
|
33237
33551
|
setContextMenuState(void 0);
|
|
33238
33552
|
setTableContextMenuState({
|
|
@@ -33243,7 +33557,7 @@ function DocxEditorViewer({
|
|
|
33243
33557
|
},
|
|
33244
33558
|
[]
|
|
33245
33559
|
);
|
|
33246
|
-
const runTableContextMenuAction =
|
|
33560
|
+
const runTableContextMenuAction = React2.useCallback(
|
|
33247
33561
|
(actionId, providedContext) => {
|
|
33248
33562
|
const context = providedContext ?? tableContextMenuState;
|
|
33249
33563
|
if (!context) {
|
|
@@ -33292,11 +33606,11 @@ function DocxEditorViewer({
|
|
|
33292
33606
|
},
|
|
33293
33607
|
[closeTableContextMenu, editor, tableContextMenuState]
|
|
33294
33608
|
);
|
|
33295
|
-
const tableContextMenuActions =
|
|
33609
|
+
const tableContextMenuActions = React2.useMemo(
|
|
33296
33610
|
() => [...DEFAULT_TABLE_CONTEXT_MENU_ACTIONS],
|
|
33297
33611
|
[]
|
|
33298
33612
|
);
|
|
33299
|
-
const resolveTableContextMenuLocation =
|
|
33613
|
+
const resolveTableContextMenuLocation = React2.useCallback(
|
|
33300
33614
|
(tableIndex, fallbackRowIndex = 0, fallbackCellIndex = 0) => {
|
|
33301
33615
|
const tableNode = editor.model.nodes[tableIndex];
|
|
33302
33616
|
if (!tableNode || tableNode.type !== "table") {
|
|
@@ -33326,7 +33640,7 @@ function DocxEditorViewer({
|
|
|
33326
33640
|
},
|
|
33327
33641
|
[editor.model.nodes, editor.selection]
|
|
33328
33642
|
);
|
|
33329
|
-
|
|
33643
|
+
React2.useEffect(() => {
|
|
33330
33644
|
if (!tableContextMenuState && !contextMenuState) {
|
|
33331
33645
|
return;
|
|
33332
33646
|
}
|
|
@@ -33355,7 +33669,7 @@ function DocxEditorViewer({
|
|
|
33355
33669
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
33356
33670
|
};
|
|
33357
33671
|
}, [contextMenuState, tableContextMenuState]);
|
|
33358
|
-
|
|
33672
|
+
React2.useEffect(() => {
|
|
33359
33673
|
if (!tableCellSelectionRange) {
|
|
33360
33674
|
return;
|
|
33361
33675
|
}
|
|
@@ -33364,7 +33678,7 @@ function DocxEditorViewer({
|
|
|
33364
33678
|
setTableCellSelectionRange(void 0);
|
|
33365
33679
|
}
|
|
33366
33680
|
}, [editor.model.nodes, tableCellSelectionRange]);
|
|
33367
|
-
|
|
33681
|
+
React2.useEffect(() => {
|
|
33368
33682
|
if (!tableContextMenuState) {
|
|
33369
33683
|
return;
|
|
33370
33684
|
}
|
|
@@ -33373,7 +33687,7 @@ function DocxEditorViewer({
|
|
|
33373
33687
|
setTableContextMenuState(void 0);
|
|
33374
33688
|
}
|
|
33375
33689
|
}, [editor.model.nodes, tableContextMenuState]);
|
|
33376
|
-
|
|
33690
|
+
React2.useEffect(() => {
|
|
33377
33691
|
if (!contextMenuState || contextMenuState.kind !== "image") {
|
|
33378
33692
|
return;
|
|
33379
33693
|
}
|
|
@@ -33391,7 +33705,7 @@ function DocxEditorViewer({
|
|
|
33391
33705
|
setContextMenuState(void 0);
|
|
33392
33706
|
}
|
|
33393
33707
|
}, [contextMenuState, editor.model]);
|
|
33394
|
-
const placeCaretInsideElement =
|
|
33708
|
+
const placeCaretInsideElement = React2.useCallback(
|
|
33395
33709
|
(element, point) => {
|
|
33396
33710
|
const selection = window.getSelection();
|
|
33397
33711
|
if (!selection) {
|
|
@@ -33568,7 +33882,7 @@ function DocxEditorViewer({
|
|
|
33568
33882
|
},
|
|
33569
33883
|
[]
|
|
33570
33884
|
);
|
|
33571
|
-
|
|
33885
|
+
React2.useEffect(() => {
|
|
33572
33886
|
const pendingFocus = pendingSectionParagraphFocusRef.current;
|
|
33573
33887
|
if (!pendingFocus) {
|
|
33574
33888
|
return;
|
|
@@ -33589,7 +33903,7 @@ function DocxEditorViewer({
|
|
|
33589
33903
|
pendingSectionParagraphFocusRef.current = void 0;
|
|
33590
33904
|
});
|
|
33591
33905
|
}, [activeHeaderFooterEdit, placeCaretInsideElement]);
|
|
33592
|
-
const setSelectionWithinElementByTextOffsets =
|
|
33906
|
+
const setSelectionWithinElementByTextOffsets = React2.useCallback(
|
|
33593
33907
|
(element, startOffset, endOffset) => {
|
|
33594
33908
|
const selection = window.getSelection();
|
|
33595
33909
|
if (!selection) {
|
|
@@ -33644,7 +33958,7 @@ function DocxEditorViewer({
|
|
|
33644
33958
|
},
|
|
33645
33959
|
[placeCaretInsideElement]
|
|
33646
33960
|
);
|
|
33647
|
-
const paragraphTextLengthFromElement =
|
|
33961
|
+
const paragraphTextLengthFromElement = React2.useCallback(
|
|
33648
33962
|
(element) => {
|
|
33649
33963
|
const range = document.createRange();
|
|
33650
33964
|
range.selectNodeContents(element);
|
|
@@ -33652,7 +33966,7 @@ function DocxEditorViewer({
|
|
|
33652
33966
|
},
|
|
33653
33967
|
[]
|
|
33654
33968
|
);
|
|
33655
|
-
const activateEditableParagraphSegment =
|
|
33969
|
+
const activateEditableParagraphSegment = React2.useCallback(
|
|
33656
33970
|
(nodeIndex, paragraphLineRange, point) => {
|
|
33657
33971
|
if (!paragraphSegmentHasPartialLineRange(paragraphLineRange)) {
|
|
33658
33972
|
pendingParagraphSegmentFocusRef.current = void 0;
|
|
@@ -33677,7 +33991,7 @@ function DocxEditorViewer({
|
|
|
33677
33991
|
},
|
|
33678
33992
|
[]
|
|
33679
33993
|
);
|
|
33680
|
-
const resolveParagraphHostElement =
|
|
33994
|
+
const resolveParagraphHostElement = React2.useCallback(
|
|
33681
33995
|
(location) => {
|
|
33682
33996
|
if (location.kind === "paragraph") {
|
|
33683
33997
|
const wrappedSurface = wrappedParagraphSurfaceRegistryRef.current.get(
|
|
@@ -33714,7 +34028,7 @@ function DocxEditorViewer({
|
|
|
33714
34028
|
},
|
|
33715
34029
|
[paragraphElementsRef]
|
|
33716
34030
|
);
|
|
33717
|
-
const resolveDomPositionFromTextOffset =
|
|
34031
|
+
const resolveDomPositionFromTextOffset = React2.useCallback(
|
|
33718
34032
|
(element, targetOffset) => {
|
|
33719
34033
|
const safeOffset = Math.max(0, Math.round(targetOffset));
|
|
33720
34034
|
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
@@ -33744,7 +34058,7 @@ function DocxEditorViewer({
|
|
|
33744
34058
|
},
|
|
33745
34059
|
[]
|
|
33746
34060
|
);
|
|
33747
|
-
const resolveParagraphHostElementForOffset =
|
|
34061
|
+
const resolveParagraphHostElementForOffset = React2.useCallback(
|
|
33748
34062
|
(paragraphIndex, offset) => {
|
|
33749
34063
|
const rootElement = viewerRootRef.current;
|
|
33750
34064
|
const trackedElement = paragraphElementsRef.current.get(paragraphIndex);
|
|
@@ -33782,7 +34096,7 @@ function DocxEditorViewer({
|
|
|
33782
34096
|
},
|
|
33783
34097
|
[resolveDomPositionFromTextOffset]
|
|
33784
34098
|
);
|
|
33785
|
-
const resolveDomPositionFromBoundary =
|
|
34099
|
+
const resolveDomPositionFromBoundary = React2.useCallback(
|
|
33786
34100
|
(boundary) => {
|
|
33787
34101
|
const location = boundary.location;
|
|
33788
34102
|
const hostElement = resolveParagraphHostElement(location);
|
|
@@ -33801,7 +34115,7 @@ function DocxEditorViewer({
|
|
|
33801
34115
|
paragraphTextLengthFromElement
|
|
33802
34116
|
]
|
|
33803
34117
|
);
|
|
33804
|
-
const setSelectionFromDocxBoundaries =
|
|
34118
|
+
const setSelectionFromDocxBoundaries = React2.useCallback(
|
|
33805
34119
|
(rawStartBoundary, rawEndBoundary) => {
|
|
33806
34120
|
const selection = window.getSelection();
|
|
33807
34121
|
if (!selection) {
|
|
@@ -33897,7 +34211,7 @@ function DocxEditorViewer({
|
|
|
33897
34211
|
placeCaretInsideElement
|
|
33898
34212
|
]
|
|
33899
34213
|
);
|
|
33900
|
-
const syncSelectionFromDocxRange =
|
|
34214
|
+
const syncSelectionFromDocxRange = React2.useCallback(
|
|
33901
34215
|
(range) => {
|
|
33902
34216
|
const selectionIntentNonce = beginSelectionIntent();
|
|
33903
34217
|
editor.beginSelectionSession("command", { settleAfterMs: 140 });
|
|
@@ -33987,7 +34301,7 @@ function DocxEditorViewer({
|
|
|
33987
34301
|
setSelectionFromDocxBoundaries
|
|
33988
34302
|
]
|
|
33989
34303
|
);
|
|
33990
|
-
const resolveWrappedParagraphBoundaryFromPoint =
|
|
34304
|
+
const resolveWrappedParagraphBoundaryFromPoint = React2.useCallback(
|
|
33991
34305
|
(point) => {
|
|
33992
34306
|
const elementAtPoint = document.elementFromPoint(point.x, point.y);
|
|
33993
34307
|
if (!(elementAtPoint instanceof Element)) {
|
|
@@ -34026,7 +34340,7 @@ function DocxEditorViewer({
|
|
|
34026
34340
|
},
|
|
34027
34341
|
[]
|
|
34028
34342
|
);
|
|
34029
|
-
const selectAllDocumentText =
|
|
34343
|
+
const selectAllDocumentText = React2.useCallback(() => {
|
|
34030
34344
|
const rootElement = viewerRootRef.current;
|
|
34031
34345
|
if (!rootElement) {
|
|
34032
34346
|
return;
|
|
@@ -34061,7 +34375,7 @@ function DocxEditorViewer({
|
|
|
34061
34375
|
paragraphTextLengthFromElement,
|
|
34062
34376
|
setSelectionFromDocxBoundaries
|
|
34063
34377
|
]);
|
|
34064
|
-
const resolveParagraphBoundaryFromSelectionPoint =
|
|
34378
|
+
const resolveParagraphBoundaryFromSelectionPoint = React2.useCallback(
|
|
34065
34379
|
(container, offset) => {
|
|
34066
34380
|
if (!container) {
|
|
34067
34381
|
return void 0;
|
|
@@ -34132,7 +34446,7 @@ function DocxEditorViewer({
|
|
|
34132
34446
|
},
|
|
34133
34447
|
[]
|
|
34134
34448
|
);
|
|
34135
|
-
const resolveBoundaryFromPoint =
|
|
34449
|
+
const resolveBoundaryFromPoint = React2.useCallback(
|
|
34136
34450
|
(point, fallbackBias) => {
|
|
34137
34451
|
const wrappedParagraphBoundary = resolveWrappedParagraphBoundaryFromPoint(point);
|
|
34138
34452
|
if (wrappedParagraphBoundary) {
|
|
@@ -34341,7 +34655,7 @@ function DocxEditorViewer({
|
|
|
34341
34655
|
resolveWrappedParagraphBoundaryFromPoint
|
|
34342
34656
|
]
|
|
34343
34657
|
);
|
|
34344
|
-
const resolveActiveRangeFromDomSelection =
|
|
34658
|
+
const resolveActiveRangeFromDomSelection = React2.useCallback(() => {
|
|
34345
34659
|
const rootElement = viewerRootRef.current;
|
|
34346
34660
|
const selection = window.getSelection();
|
|
34347
34661
|
if (!rootElement || !selection || selection.rangeCount === 0) {
|
|
@@ -34367,7 +34681,7 @@ function DocxEditorViewer({
|
|
|
34367
34681
|
end: endBoundary
|
|
34368
34682
|
});
|
|
34369
34683
|
}, [resolveParagraphBoundaryFromSelectionPoint]);
|
|
34370
|
-
const setActiveRangeFromSelection =
|
|
34684
|
+
const setActiveRangeFromSelection = React2.useCallback(() => {
|
|
34371
34685
|
const session = editor.selectionSessionKind;
|
|
34372
34686
|
const rootElement = viewerRootRef.current;
|
|
34373
34687
|
const activeElement = document.activeElement;
|
|
@@ -34424,7 +34738,7 @@ function DocxEditorViewer({
|
|
|
34424
34738
|
resolveParagraphHostElement,
|
|
34425
34739
|
setSelectionFromDocxBoundaries
|
|
34426
34740
|
]);
|
|
34427
|
-
const flushActiveRangeFromSelection =
|
|
34741
|
+
const flushActiveRangeFromSelection = React2.useCallback(() => {
|
|
34428
34742
|
if (deferredCollapsedSelectionSyncTimeoutRef.current !== null) {
|
|
34429
34743
|
window.clearTimeout(deferredCollapsedSelectionSyncTimeoutRef.current);
|
|
34430
34744
|
deferredCollapsedSelectionSyncTimeoutRef.current = null;
|
|
@@ -34437,7 +34751,7 @@ function DocxEditorViewer({
|
|
|
34437
34751
|
setActiveRangeFromSelection();
|
|
34438
34752
|
});
|
|
34439
34753
|
}, [setActiveRangeFromSelection]);
|
|
34440
|
-
|
|
34754
|
+
React2.useLayoutEffect(() => {
|
|
34441
34755
|
if (isReadOnly) {
|
|
34442
34756
|
return;
|
|
34443
34757
|
}
|
|
@@ -34521,7 +34835,7 @@ function DocxEditorViewer({
|
|
|
34521
34835
|
}
|
|
34522
34836
|
setSelectionFromDocxBoundaries(normalized.start, normalized.end);
|
|
34523
34837
|
});
|
|
34524
|
-
const selectionIsExpandedWithinElement =
|
|
34838
|
+
const selectionIsExpandedWithinElement = React2.useCallback(
|
|
34525
34839
|
(element) => {
|
|
34526
34840
|
const selection = window.getSelection();
|
|
34527
34841
|
if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
|
|
@@ -34532,7 +34846,7 @@ function DocxEditorViewer({
|
|
|
34532
34846
|
},
|
|
34533
34847
|
[]
|
|
34534
34848
|
);
|
|
34535
|
-
const ensureCaretPlacementInsideElement =
|
|
34849
|
+
const ensureCaretPlacementInsideElement = React2.useCallback(
|
|
34536
34850
|
(element, point, selectionIntentNonce) => {
|
|
34537
34851
|
const selection = window.getSelection();
|
|
34538
34852
|
const selectedRange = selection && selection.rangeCount > 0 ? selection.getRangeAt(0) : void 0;
|
|
@@ -34585,7 +34899,7 @@ function DocxEditorViewer({
|
|
|
34585
34899
|
scheduleSelectionIntentFrame
|
|
34586
34900
|
]
|
|
34587
34901
|
);
|
|
34588
|
-
const schedulePointerSelectionReconcile =
|
|
34902
|
+
const schedulePointerSelectionReconcile = React2.useCallback(
|
|
34589
34903
|
(element, point, syncSelection) => {
|
|
34590
34904
|
const selectionIntentNonce = beginSelectionIntent();
|
|
34591
34905
|
editor.beginSelectionSession("pointer", { settleAfterMs: 320 });
|
|
@@ -34652,11 +34966,11 @@ function DocxEditorViewer({
|
|
|
34652
34966
|
scheduleSelectionIntentFrame
|
|
34653
34967
|
]
|
|
34654
34968
|
);
|
|
34655
|
-
const cancelPendingPointerSelectionReconcile =
|
|
34969
|
+
const cancelPendingPointerSelectionReconcile = React2.useCallback(() => {
|
|
34656
34970
|
cancelPendingSelectionIntent();
|
|
34657
34971
|
editor.clearSelectionSession("pointer");
|
|
34658
34972
|
}, [cancelPendingSelectionIntent, editor]);
|
|
34659
|
-
const clearObjectSelectionForParagraphEntry =
|
|
34973
|
+
const clearObjectSelectionForParagraphEntry = React2.useCallback(
|
|
34660
34974
|
(nodeIndex) => {
|
|
34661
34975
|
clearTableCellSelection();
|
|
34662
34976
|
setSelectedImage(void 0);
|
|
@@ -34670,7 +34984,7 @@ function DocxEditorViewer({
|
|
|
34670
34984
|
},
|
|
34671
34985
|
[clearTableCellSelection, editor]
|
|
34672
34986
|
);
|
|
34673
|
-
const syncWrappedParagraphRange =
|
|
34987
|
+
const syncWrappedParagraphRange = React2.useCallback(
|
|
34674
34988
|
(location, startOffset, endOffset, options) => {
|
|
34675
34989
|
const paragraph = getParagraphAtLocation(
|
|
34676
34990
|
editor.model,
|
|
@@ -34730,7 +35044,7 @@ function DocxEditorViewer({
|
|
|
34730
35044
|
},
|
|
34731
35045
|
[editor]
|
|
34732
35046
|
);
|
|
34733
|
-
const focusWrappedParagraphTextarea =
|
|
35047
|
+
const focusWrappedParagraphTextarea = React2.useCallback(() => {
|
|
34734
35048
|
scheduleDomWrite(() => {
|
|
34735
35049
|
const textarea = wrappedParagraphTextareaRef.current;
|
|
34736
35050
|
if (!textarea || !textarea.isConnected) {
|
|
@@ -34764,7 +35078,7 @@ function DocxEditorViewer({
|
|
|
34764
35078
|
}
|
|
34765
35079
|
});
|
|
34766
35080
|
}, [activeWrappedParagraphSession]);
|
|
34767
|
-
const commitWrappedParagraphTextAtLocation =
|
|
35081
|
+
const commitWrappedParagraphTextAtLocation = React2.useCallback(
|
|
34768
35082
|
(location, text) => {
|
|
34769
35083
|
editor.suppressNextDomSelectionRestore();
|
|
34770
35084
|
if (location.kind === "paragraph") {
|
|
@@ -34781,7 +35095,7 @@ function DocxEditorViewer({
|
|
|
34781
35095
|
},
|
|
34782
35096
|
[editor]
|
|
34783
35097
|
);
|
|
34784
|
-
const focusDropCapWrappedParagraph =
|
|
35098
|
+
const focusDropCapWrappedParagraph = React2.useCallback(
|
|
34785
35099
|
(nodeIndex, point) => {
|
|
34786
35100
|
clearObjectSelectionForParagraphEntry(nodeIndex);
|
|
34787
35101
|
editor.selectParagraph(nodeIndex);
|
|
@@ -34805,7 +35119,7 @@ function DocxEditorViewer({
|
|
|
34805
35119
|
placeCaretInsideElement
|
|
34806
35120
|
]
|
|
34807
35121
|
);
|
|
34808
|
-
const activateDropCapEditor =
|
|
35122
|
+
const activateDropCapEditor = React2.useCallback(
|
|
34809
35123
|
(nodeIndex) => {
|
|
34810
35124
|
if (isReadOnly) {
|
|
34811
35125
|
return;
|
|
@@ -34818,7 +35132,7 @@ function DocxEditorViewer({
|
|
|
34818
35132
|
},
|
|
34819
35133
|
[clearTableCellSelection, isReadOnly]
|
|
34820
35134
|
);
|
|
34821
|
-
const scheduleDeferredCollapsedSelectionSync =
|
|
35135
|
+
const scheduleDeferredCollapsedSelectionSync = React2.useCallback(() => {
|
|
34822
35136
|
if (deferredCollapsedSelectionSyncTimeoutRef.current !== null) {
|
|
34823
35137
|
window.clearTimeout(deferredCollapsedSelectionSyncTimeoutRef.current);
|
|
34824
35138
|
}
|
|
@@ -34827,7 +35141,7 @@ function DocxEditorViewer({
|
|
|
34827
35141
|
flushActiveRangeFromSelection();
|
|
34828
35142
|
}, 80);
|
|
34829
35143
|
}, [flushActiveRangeFromSelection]);
|
|
34830
|
-
|
|
35144
|
+
React2.useLayoutEffect(() => {
|
|
34831
35145
|
const request = editor.historyRestoreRequest;
|
|
34832
35146
|
if (!request?.textInput || !request.activeTextRange || request.nonce === appliedHistoryRestoreNonceRef.current || compositionActiveRef.current) {
|
|
34833
35147
|
return;
|
|
@@ -34875,7 +35189,7 @@ function DocxEditorViewer({
|
|
|
34875
35189
|
resolveDomPositionFromBoundary,
|
|
34876
35190
|
resolveParagraphHostElement
|
|
34877
35191
|
]);
|
|
34878
|
-
|
|
35192
|
+
React2.useEffect(() => {
|
|
34879
35193
|
const restoreRequest = editor.historyRestoreRequest;
|
|
34880
35194
|
if (!restoreRequest) {
|
|
34881
35195
|
return;
|
|
@@ -35007,7 +35321,7 @@ function DocxEditorViewer({
|
|
|
35007
35321
|
scheduleSelectionIntentFrame,
|
|
35008
35322
|
setSelectionFromDocxBoundaries
|
|
35009
35323
|
]);
|
|
35010
|
-
|
|
35324
|
+
React2.useEffect(() => {
|
|
35011
35325
|
const handleSelectionChange = () => {
|
|
35012
35326
|
const selection = window.getSelection();
|
|
35013
35327
|
if (!selection) {
|
|
@@ -35073,7 +35387,7 @@ function DocxEditorViewer({
|
|
|
35073
35387
|
document.removeEventListener("selectionchange", handleSelectionChange);
|
|
35074
35388
|
};
|
|
35075
35389
|
}, [flushActiveRangeFromSelection, scheduleDeferredCollapsedSelectionSync]);
|
|
35076
|
-
|
|
35390
|
+
React2.useEffect(() => {
|
|
35077
35391
|
const onPointerDown = (event) => {
|
|
35078
35392
|
commandSelectionGuardRef.current = void 0;
|
|
35079
35393
|
const rootElement = viewerRootRef.current;
|
|
@@ -35108,7 +35422,7 @@ function DocxEditorViewer({
|
|
|
35108
35422
|
editor,
|
|
35109
35423
|
resolveActiveRangeFromDomSelection
|
|
35110
35424
|
]);
|
|
35111
|
-
const beginCrossNodeSelectionDrag =
|
|
35425
|
+
const beginCrossNodeSelectionDrag = React2.useCallback(
|
|
35112
35426
|
(startBoundary, pointerId, startX, startY) => {
|
|
35113
35427
|
tableSelectionDragRef.current = {
|
|
35114
35428
|
pointerId,
|
|
@@ -35196,14 +35510,14 @@ function DocxEditorViewer({
|
|
|
35196
35510
|
},
|
|
35197
35511
|
[resolveBoundaryFromPoint, setSelectionFromDocxBoundaries]
|
|
35198
35512
|
);
|
|
35199
|
-
const resolveTableCellLocationFromPoint =
|
|
35513
|
+
const resolveTableCellLocationFromPoint = React2.useCallback(
|
|
35200
35514
|
(point) => {
|
|
35201
35515
|
const element = document.elementFromPoint(point.x, point.y);
|
|
35202
35516
|
return parseTableCellLocationFromElement(element);
|
|
35203
35517
|
},
|
|
35204
35518
|
[]
|
|
35205
35519
|
);
|
|
35206
|
-
const beginTableCellSelectionDrag =
|
|
35520
|
+
const beginTableCellSelectionDrag = React2.useCallback(
|
|
35207
35521
|
(pointerId, anchorCell, startX, startY, startBoundary) => {
|
|
35208
35522
|
tableCellSelectionDragRef.current = {
|
|
35209
35523
|
pointerId,
|
|
@@ -35319,7 +35633,7 @@ function DocxEditorViewer({
|
|
|
35319
35633
|
setSelectionFromDocxBoundaries
|
|
35320
35634
|
]
|
|
35321
35635
|
);
|
|
35322
|
-
const onViewerPointerDown =
|
|
35636
|
+
const onViewerPointerDown = React2.useCallback(
|
|
35323
35637
|
(event) => {
|
|
35324
35638
|
if (tableContextMenuState || contextMenuState) {
|
|
35325
35639
|
const target2 = event.target;
|
|
@@ -35380,7 +35694,7 @@ function DocxEditorViewer({
|
|
|
35380
35694
|
tableContextMenuState
|
|
35381
35695
|
]
|
|
35382
35696
|
);
|
|
35383
|
-
const onViewerFormFieldDoubleClick =
|
|
35697
|
+
const onViewerFormFieldDoubleClick = React2.useCallback(
|
|
35384
35698
|
(event) => {
|
|
35385
35699
|
if (isReadOnly || !(event.target instanceof Element)) {
|
|
35386
35700
|
return;
|
|
@@ -35407,7 +35721,7 @@ function DocxEditorViewer({
|
|
|
35407
35721
|
},
|
|
35408
35722
|
[editor.model, editor.selectFormField, isReadOnly, onFormFieldDoubleClick]
|
|
35409
35723
|
);
|
|
35410
|
-
const onViewerContextMenu =
|
|
35724
|
+
const onViewerContextMenu = React2.useCallback(
|
|
35411
35725
|
(event) => {
|
|
35412
35726
|
if (isReadOnly || event.defaultPrevented) {
|
|
35413
35727
|
return;
|
|
@@ -35482,7 +35796,7 @@ function DocxEditorViewer({
|
|
|
35482
35796
|
setSelectionFromDocxBoundaries
|
|
35483
35797
|
]
|
|
35484
35798
|
);
|
|
35485
|
-
const handleDeleteAcrossTableCellSelection =
|
|
35799
|
+
const handleDeleteAcrossTableCellSelection = React2.useCallback(
|
|
35486
35800
|
(event) => {
|
|
35487
35801
|
if (isReadOnly) {
|
|
35488
35802
|
return false;
|
|
@@ -35558,7 +35872,7 @@ function DocxEditorViewer({
|
|
|
35558
35872
|
tableCellSelectionRange
|
|
35559
35873
|
]
|
|
35560
35874
|
);
|
|
35561
|
-
const onViewerKeyDown =
|
|
35875
|
+
const onViewerKeyDown = React2.useCallback(
|
|
35562
35876
|
(event) => {
|
|
35563
35877
|
commandSelectionGuardRef.current = void 0;
|
|
35564
35878
|
if (!isReadOnly && handleDeleteAcrossTableCellSelection(event)) {
|
|
@@ -35647,7 +35961,7 @@ function DocxEditorViewer({
|
|
|
35647
35961
|
syncSelectionFromDocxRange
|
|
35648
35962
|
]
|
|
35649
35963
|
);
|
|
35650
|
-
const onViewerKeyUp =
|
|
35964
|
+
const onViewerKeyUp = React2.useCallback(
|
|
35651
35965
|
(event) => {
|
|
35652
35966
|
if (!shouldSyncActiveRangeOnKeyUp(event)) {
|
|
35653
35967
|
return;
|
|
@@ -35656,7 +35970,7 @@ function DocxEditorViewer({
|
|
|
35656
35970
|
},
|
|
35657
35971
|
[flushActiveRangeFromSelection]
|
|
35658
35972
|
);
|
|
35659
|
-
const handleDeleteAcrossSelection =
|
|
35973
|
+
const handleDeleteAcrossSelection = React2.useCallback(
|
|
35660
35974
|
(event) => {
|
|
35661
35975
|
if (isReadOnly) {
|
|
35662
35976
|
return false;
|
|
@@ -35726,7 +36040,7 @@ function DocxEditorViewer({
|
|
|
35726
36040
|
syncSelectionFromDocxRange
|
|
35727
36041
|
]
|
|
35728
36042
|
);
|
|
35729
|
-
const replaceExpandedSelectionWithText =
|
|
36043
|
+
const replaceExpandedSelectionWithText = React2.useCallback(
|
|
35730
36044
|
(rawText) => {
|
|
35731
36045
|
if (isReadOnly) {
|
|
35732
36046
|
return false;
|
|
@@ -35783,7 +36097,7 @@ function DocxEditorViewer({
|
|
|
35783
36097
|
syncSelectionFromDocxRange
|
|
35784
36098
|
]
|
|
35785
36099
|
);
|
|
35786
|
-
const resolveContextMenuActions =
|
|
36100
|
+
const resolveContextMenuActions = React2.useCallback(
|
|
35787
36101
|
(context) => {
|
|
35788
36102
|
if (context.kind === "table") {
|
|
35789
36103
|
return tableContextMenuActions.map((action) => ({
|
|
@@ -35888,7 +36202,7 @@ function DocxEditorViewer({
|
|
|
35888
36202
|
},
|
|
35889
36203
|
[tableContextMenuActions]
|
|
35890
36204
|
);
|
|
35891
|
-
const runContextMenuAction =
|
|
36205
|
+
const runContextMenuAction = React2.useCallback(
|
|
35892
36206
|
(actionId, providedContext) => {
|
|
35893
36207
|
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";
|
|
35894
36208
|
if (isTableAction(actionId)) {
|
|
@@ -36359,7 +36673,7 @@ function DocxEditorViewer({
|
|
|
36359
36673
|
syncSelectionFromDocxRange
|
|
36360
36674
|
]
|
|
36361
36675
|
);
|
|
36362
|
-
|
|
36676
|
+
React2.useEffect(() => {
|
|
36363
36677
|
const onWindowKeyDown = (event) => {
|
|
36364
36678
|
if (isReadOnly || event.defaultPrevented) {
|
|
36365
36679
|
return;
|
|
@@ -36433,7 +36747,7 @@ function DocxEditorViewer({
|
|
|
36433
36747
|
resolveParagraphBoundaryFromSelectionPoint,
|
|
36434
36748
|
syncSelectionFromDocxRange
|
|
36435
36749
|
]);
|
|
36436
|
-
|
|
36750
|
+
React2.useEffect(() => {
|
|
36437
36751
|
if (!selectedImage) {
|
|
36438
36752
|
return;
|
|
36439
36753
|
}
|
|
@@ -36447,10 +36761,10 @@ function DocxEditorViewer({
|
|
|
36447
36761
|
setResizePreview(void 0);
|
|
36448
36762
|
}
|
|
36449
36763
|
}, [editor.model, selectedImage]);
|
|
36450
|
-
|
|
36764
|
+
React2.useEffect(() => {
|
|
36451
36765
|
activeWrappedParagraphSessionRef.current = activeWrappedParagraphSession;
|
|
36452
36766
|
}, [activeWrappedParagraphSession]);
|
|
36453
|
-
|
|
36767
|
+
React2.useEffect(() => {
|
|
36454
36768
|
if (!selectedImage && !selectedSectionImageKey) {
|
|
36455
36769
|
return;
|
|
36456
36770
|
}
|
|
@@ -36459,7 +36773,7 @@ function DocxEditorViewer({
|
|
|
36459
36773
|
setDropCapMovePreview(void 0);
|
|
36460
36774
|
setActiveWrappedParagraphSession(void 0);
|
|
36461
36775
|
}, [selectedImage, selectedSectionImageKey]);
|
|
36462
|
-
|
|
36776
|
+
React2.useEffect(() => {
|
|
36463
36777
|
if (selectedDropCapNodeIndex === void 0) {
|
|
36464
36778
|
return;
|
|
36465
36779
|
}
|
|
@@ -36470,7 +36784,7 @@ function DocxEditorViewer({
|
|
|
36470
36784
|
setDropCapMovePreview(void 0);
|
|
36471
36785
|
}
|
|
36472
36786
|
}, [editor.model, selectedDropCapNodeIndex]);
|
|
36473
|
-
|
|
36787
|
+
React2.useEffect(() => {
|
|
36474
36788
|
if (!activeWrappedParagraphSession) {
|
|
36475
36789
|
return;
|
|
36476
36790
|
}
|
|
@@ -36500,13 +36814,13 @@ function DocxEditorViewer({
|
|
|
36500
36814
|
);
|
|
36501
36815
|
}
|
|
36502
36816
|
}, [activeWrappedParagraphSession, editor.model]);
|
|
36503
|
-
|
|
36817
|
+
React2.useEffect(() => {
|
|
36504
36818
|
if (!activeWrappedParagraphSession) {
|
|
36505
36819
|
return;
|
|
36506
36820
|
}
|
|
36507
36821
|
focusWrappedParagraphTextarea();
|
|
36508
36822
|
}, [activeWrappedParagraphSession, focusWrappedParagraphTextarea]);
|
|
36509
|
-
|
|
36823
|
+
React2.useEffect(() => {
|
|
36510
36824
|
const textarea = wrappedParagraphTextareaRef.current;
|
|
36511
36825
|
const session = activeWrappedParagraphSession;
|
|
36512
36826
|
if (!textarea || !session) {
|
|
@@ -36527,7 +36841,7 @@ function DocxEditorViewer({
|
|
|
36527
36841
|
} catch {
|
|
36528
36842
|
}
|
|
36529
36843
|
}, [activeWrappedParagraphSession]);
|
|
36530
|
-
const focusParagraphAtOffset =
|
|
36844
|
+
const focusParagraphAtOffset = React2.useCallback(
|
|
36531
36845
|
(paragraphIndex, offset) => {
|
|
36532
36846
|
const focusAttempt = (attempt) => {
|
|
36533
36847
|
const element = resolveParagraphHostElementForOffset(
|
|
@@ -36572,7 +36886,7 @@ function DocxEditorViewer({
|
|
|
36572
36886
|
setSelectionWithinElementByTextOffsets
|
|
36573
36887
|
]
|
|
36574
36888
|
);
|
|
36575
|
-
const focusTableCellParagraphAtOffset =
|
|
36889
|
+
const focusTableCellParagraphAtOffset = React2.useCallback(
|
|
36576
36890
|
(cellDraftKey, paragraphIndex, offset) => {
|
|
36577
36891
|
window.requestAnimationFrame(() => {
|
|
36578
36892
|
const cellElement = tableCellEditorElementsRef.current.get(cellDraftKey);
|
|
@@ -36603,7 +36917,7 @@ function DocxEditorViewer({
|
|
|
36603
36917
|
},
|
|
36604
36918
|
[setSelectionWithinElementByTextOffsets]
|
|
36605
36919
|
);
|
|
36606
|
-
const focusParagraphLocationAtOffset =
|
|
36920
|
+
const focusParagraphLocationAtOffset = React2.useCallback(
|
|
36607
36921
|
(location, offset) => {
|
|
36608
36922
|
if (location.kind === "paragraph") {
|
|
36609
36923
|
focusParagraphAtOffset(location.nodeIndex, offset);
|
|
@@ -36618,7 +36932,7 @@ function DocxEditorViewer({
|
|
|
36618
36932
|
},
|
|
36619
36933
|
[focusParagraphAtOffset, focusTableCellParagraphAtOffset]
|
|
36620
36934
|
);
|
|
36621
|
-
const focusParagraphLocationAtClientPoint =
|
|
36935
|
+
const focusParagraphLocationAtClientPoint = React2.useCallback(
|
|
36622
36936
|
(location, preferredPoint, fallbackOffset) => {
|
|
36623
36937
|
const targetElement = resolveParagraphHostElement(location);
|
|
36624
36938
|
if (!targetElement) {
|
|
@@ -36664,7 +36978,7 @@ function DocxEditorViewer({
|
|
|
36664
36978
|
setSelectionFromDocxBoundaries
|
|
36665
36979
|
]
|
|
36666
36980
|
);
|
|
36667
|
-
const focusParagraphAtEnd =
|
|
36981
|
+
const focusParagraphAtEnd = React2.useCallback(
|
|
36668
36982
|
(paragraphIndex) => {
|
|
36669
36983
|
window.requestAnimationFrame(() => {
|
|
36670
36984
|
const element = paragraphElementsRef.current.get(paragraphIndex);
|
|
@@ -36685,7 +36999,7 @@ function DocxEditorViewer({
|
|
|
36685
36999
|
},
|
|
36686
37000
|
[]
|
|
36687
37001
|
);
|
|
36688
|
-
const selectionOffsetsWithinElement =
|
|
37002
|
+
const selectionOffsetsWithinElement = React2.useCallback(
|
|
36689
37003
|
(element) => {
|
|
36690
37004
|
const selection = window.getSelection();
|
|
36691
37005
|
if (!selection || selection.rangeCount === 0) {
|
|
@@ -36724,7 +37038,7 @@ function DocxEditorViewer({
|
|
|
36724
37038
|
},
|
|
36725
37039
|
[]
|
|
36726
37040
|
);
|
|
36727
|
-
const collapsedCaretClientPointWithinElement =
|
|
37041
|
+
const collapsedCaretClientPointWithinElement = React2.useCallback(
|
|
36728
37042
|
(element) => {
|
|
36729
37043
|
const selection = window.getSelection();
|
|
36730
37044
|
if (!selection || selection.rangeCount === 0 || !selection.isCollapsed) {
|
|
@@ -36751,7 +37065,7 @@ function DocxEditorViewer({
|
|
|
36751
37065
|
},
|
|
36752
37066
|
[]
|
|
36753
37067
|
);
|
|
36754
|
-
const activeTableCellParagraphContext =
|
|
37068
|
+
const activeTableCellParagraphContext = React2.useCallback(
|
|
36755
37069
|
(cellElement) => {
|
|
36756
37070
|
const selection = window.getSelection();
|
|
36757
37071
|
if (!selection) {
|
|
@@ -36788,7 +37102,7 @@ function DocxEditorViewer({
|
|
|
36788
37102
|
},
|
|
36789
37103
|
[]
|
|
36790
37104
|
);
|
|
36791
|
-
const updateActiveTextRangeFromTableCell =
|
|
37105
|
+
const updateActiveTextRangeFromTableCell = React2.useCallback(
|
|
36792
37106
|
(cellElement, tableIndex, rowIndex, cellIndex) => {
|
|
36793
37107
|
const selection = window.getSelection();
|
|
36794
37108
|
if (!selection || selection.rangeCount === 0) {
|
|
@@ -36827,7 +37141,7 @@ function DocxEditorViewer({
|
|
|
36827
37141
|
resolveParagraphBoundaryFromSelectionPoint
|
|
36828
37142
|
]
|
|
36829
37143
|
);
|
|
36830
|
-
const updateActiveTextRangeFromElement =
|
|
37144
|
+
const updateActiveTextRangeFromElement = React2.useCallback(
|
|
36831
37145
|
(element, location) => {
|
|
36832
37146
|
const selection = window.getSelection();
|
|
36833
37147
|
if (!selection || selection.rangeCount === 0) {
|
|
@@ -36859,7 +37173,7 @@ function DocxEditorViewer({
|
|
|
36859
37173
|
},
|
|
36860
37174
|
[clearTableCellSelection, editor, selectionOffsetsWithinElement]
|
|
36861
37175
|
);
|
|
36862
|
-
const commitTableCellDraftFromElement =
|
|
37176
|
+
const commitTableCellDraftFromElement = React2.useCallback(
|
|
36863
37177
|
(tableIndex, rowIndex, cellIndex, cellParagraphs, draftKey, element) => {
|
|
36864
37178
|
const nextText = editableTextFromTableCellElement(element);
|
|
36865
37179
|
const nextHtml = element.innerHTML;
|
|
@@ -36873,7 +37187,7 @@ function DocxEditorViewer({
|
|
|
36873
37187
|
},
|
|
36874
37188
|
[editor]
|
|
36875
37189
|
);
|
|
36876
|
-
const registerTableCellParagraphElement =
|
|
37190
|
+
const registerTableCellParagraphElement = React2.useCallback(
|
|
36877
37191
|
(draftKey, element) => {
|
|
36878
37192
|
if (element) {
|
|
36879
37193
|
tableCellParagraphElementsRef.current.set(draftKey, element);
|
|
@@ -36883,27 +37197,27 @@ function DocxEditorViewer({
|
|
|
36883
37197
|
},
|
|
36884
37198
|
[]
|
|
36885
37199
|
);
|
|
36886
|
-
const readTableCellParagraphDraft =
|
|
37200
|
+
const readTableCellParagraphDraft = React2.useCallback(
|
|
36887
37201
|
(draftKey) => {
|
|
36888
37202
|
return tableCellParagraphDraftsRef.current.get(draftKey);
|
|
36889
37203
|
},
|
|
36890
37204
|
[]
|
|
36891
37205
|
);
|
|
36892
|
-
const writeTableCellParagraphDraft =
|
|
37206
|
+
const writeTableCellParagraphDraft = React2.useCallback(
|
|
36893
37207
|
(draftKey, html) => {
|
|
36894
37208
|
tableCellParagraphDraftsRef.current.set(draftKey, html);
|
|
36895
37209
|
requestTableDraftLayoutRefresh();
|
|
36896
37210
|
},
|
|
36897
37211
|
[requestTableDraftLayoutRefresh]
|
|
36898
37212
|
);
|
|
36899
|
-
const clearTableCellParagraphDraft =
|
|
37213
|
+
const clearTableCellParagraphDraft = React2.useCallback(
|
|
36900
37214
|
(draftKey) => {
|
|
36901
37215
|
tableCellParagraphDraftsRef.current.delete(draftKey);
|
|
36902
37216
|
requestTableDraftLayoutRefresh();
|
|
36903
37217
|
},
|
|
36904
37218
|
[requestTableDraftLayoutRefresh]
|
|
36905
37219
|
);
|
|
36906
|
-
const commitTableCellParagraphDraft =
|
|
37220
|
+
const commitTableCellParagraphDraft = React2.useCallback(
|
|
36907
37221
|
(tableIndex, rowIndex, cellIndex, paragraphIndex, text) => {
|
|
36908
37222
|
const draftKey = tableCellParagraphDraftKey(
|
|
36909
37223
|
tableIndex,
|
|
@@ -36935,7 +37249,7 @@ function DocxEditorViewer({
|
|
|
36935
37249
|
},
|
|
36936
37250
|
[editor]
|
|
36937
37251
|
);
|
|
36938
|
-
const registerSectionParagraphElement =
|
|
37252
|
+
const registerSectionParagraphElement = React2.useCallback(
|
|
36939
37253
|
(draftKey, element) => {
|
|
36940
37254
|
if (element) {
|
|
36941
37255
|
sectionParagraphElementsRef.current.set(draftKey, element);
|
|
@@ -36945,25 +37259,25 @@ function DocxEditorViewer({
|
|
|
36945
37259
|
},
|
|
36946
37260
|
[]
|
|
36947
37261
|
);
|
|
36948
|
-
const readSectionParagraphDraft =
|
|
37262
|
+
const readSectionParagraphDraft = React2.useCallback(
|
|
36949
37263
|
(draftKey) => {
|
|
36950
37264
|
return sectionParagraphDraftsRef.current.get(draftKey);
|
|
36951
37265
|
},
|
|
36952
37266
|
[]
|
|
36953
37267
|
);
|
|
36954
|
-
const writeSectionParagraphDraft =
|
|
37268
|
+
const writeSectionParagraphDraft = React2.useCallback(
|
|
36955
37269
|
(draftKey, html) => {
|
|
36956
37270
|
sectionParagraphDraftsRef.current.set(draftKey, html);
|
|
36957
37271
|
},
|
|
36958
37272
|
[]
|
|
36959
37273
|
);
|
|
36960
|
-
const clearSectionParagraphDraft =
|
|
37274
|
+
const clearSectionParagraphDraft = React2.useCallback(
|
|
36961
37275
|
(draftKey) => {
|
|
36962
37276
|
sectionParagraphDraftsRef.current.delete(draftKey);
|
|
36963
37277
|
},
|
|
36964
37278
|
[]
|
|
36965
37279
|
);
|
|
36966
|
-
const commitSectionParagraphDraft =
|
|
37280
|
+
const commitSectionParagraphDraft = React2.useCallback(
|
|
36967
37281
|
(location, text) => {
|
|
36968
37282
|
const draftKey = sectionParagraphLocationKey(location);
|
|
36969
37283
|
const currentSectionLists = location.region === "header" ? [
|
|
@@ -36993,7 +37307,7 @@ function DocxEditorViewer({
|
|
|
36993
37307
|
},
|
|
36994
37308
|
[editor]
|
|
36995
37309
|
);
|
|
36996
|
-
const updateSectionParagraphDraftFromTarget =
|
|
37310
|
+
const updateSectionParagraphDraftFromTarget = React2.useCallback(
|
|
36997
37311
|
(target) => {
|
|
36998
37312
|
if (!(target instanceof Element)) {
|
|
36999
37313
|
return;
|
|
@@ -37014,7 +37328,7 @@ function DocxEditorViewer({
|
|
|
37014
37328
|
},
|
|
37015
37329
|
[]
|
|
37016
37330
|
);
|
|
37017
|
-
const commitSectionRegionDraftsFromContainer =
|
|
37331
|
+
const commitSectionRegionDraftsFromContainer = React2.useCallback(
|
|
37018
37332
|
(container, region, partName) => {
|
|
37019
37333
|
const paragraphHosts = Array.from(
|
|
37020
37334
|
container.querySelectorAll(
|
|
@@ -37073,7 +37387,7 @@ function DocxEditorViewer({
|
|
|
37073
37387
|
closeActiveHeaderFooterEdit(activeEdit);
|
|
37074
37388
|
});
|
|
37075
37389
|
}
|
|
37076
|
-
|
|
37390
|
+
React2.useEffect(() => {
|
|
37077
37391
|
const flushPendingDraftsForExport = (currentModel) => {
|
|
37078
37392
|
if (tableCellDraftsRef.current.size === 0 && tableCellParagraphDraftsRef.current.size === 0 && sectionParagraphDraftsRef.current.size === 0) {
|
|
37079
37393
|
return currentModel;
|
|
@@ -37195,7 +37509,7 @@ function DocxEditorViewer({
|
|
|
37195
37509
|
editor.registerPendingExportModelTransformer(void 0);
|
|
37196
37510
|
};
|
|
37197
37511
|
}, [editor, editor.pendingRunStyle]);
|
|
37198
|
-
const handleEditorHistoryShortcut =
|
|
37512
|
+
const handleEditorHistoryShortcut = React2.useCallback(
|
|
37199
37513
|
(event, commitDraft) => {
|
|
37200
37514
|
if (event.defaultPrevented || !(event.metaKey || event.ctrlKey) || event.altKey) {
|
|
37201
37515
|
return false;
|
|
@@ -37220,7 +37534,7 @@ function DocxEditorViewer({
|
|
|
37220
37534
|
},
|
|
37221
37535
|
[editor]
|
|
37222
37536
|
);
|
|
37223
|
-
const handleEditableHostBeforeInput =
|
|
37537
|
+
const handleEditableHostBeforeInput = React2.useCallback(
|
|
37224
37538
|
(event) => {
|
|
37225
37539
|
if (isReadOnly) {
|
|
37226
37540
|
return;
|
|
@@ -37625,7 +37939,7 @@ function DocxEditorViewer({
|
|
|
37625
37939
|
syncSelectionFromDocxRange
|
|
37626
37940
|
]
|
|
37627
37941
|
);
|
|
37628
|
-
|
|
37942
|
+
React2.useEffect(() => {
|
|
37629
37943
|
const rootElement = viewerRootRef.current;
|
|
37630
37944
|
if (!rootElement) {
|
|
37631
37945
|
return;
|
|
@@ -37638,7 +37952,7 @@ function DocxEditorViewer({
|
|
|
37638
37952
|
rootElement.removeEventListener("beforeinput", handleBeforeInput);
|
|
37639
37953
|
};
|
|
37640
37954
|
}, [handleEditableHostBeforeInput]);
|
|
37641
|
-
const resolveTableColumnWidths =
|
|
37955
|
+
const resolveTableColumnWidths = React2.useCallback(
|
|
37642
37956
|
(tableIndex, table, tableWidthPx) => {
|
|
37643
37957
|
const columnCount = tableColumnCount(table);
|
|
37644
37958
|
const storedWidths = tableColumnWidths[tableIndex];
|
|
@@ -37669,7 +37983,7 @@ function DocxEditorViewer({
|
|
|
37669
37983
|
},
|
|
37670
37984
|
[tableColumnWidths]
|
|
37671
37985
|
);
|
|
37672
|
-
const resolveTableRowHeights =
|
|
37986
|
+
const resolveTableRowHeights = React2.useCallback(
|
|
37673
37987
|
(tableIndex, table) => {
|
|
37674
37988
|
const storedHeights = tableRowHeights[tableIndex];
|
|
37675
37989
|
return table.rows.map((row, rowIndex) => {
|
|
@@ -37689,7 +38003,7 @@ function DocxEditorViewer({
|
|
|
37689
38003
|
},
|
|
37690
38004
|
[tableRowHeights]
|
|
37691
38005
|
);
|
|
37692
|
-
const resolveEmbeddedTableColumnWidths =
|
|
38006
|
+
const resolveEmbeddedTableColumnWidths = React2.useCallback(
|
|
37693
38007
|
(tableKey, table, tableWidthPx) => {
|
|
37694
38008
|
const columnCount = tableColumnCount(table);
|
|
37695
38009
|
const storedWidths = embeddedTableColumnWidths[tableKey];
|
|
@@ -37720,7 +38034,7 @@ function DocxEditorViewer({
|
|
|
37720
38034
|
},
|
|
37721
38035
|
[embeddedTableColumnWidths]
|
|
37722
38036
|
);
|
|
37723
|
-
const resolveEmbeddedTableRowHeights =
|
|
38037
|
+
const resolveEmbeddedTableRowHeights = React2.useCallback(
|
|
37724
38038
|
(tableKey, table) => {
|
|
37725
38039
|
const storedHeights = embeddedTableRowHeights[tableKey];
|
|
37726
38040
|
return table.rows.map((row, rowIndex) => {
|
|
@@ -37740,7 +38054,7 @@ function DocxEditorViewer({
|
|
|
37740
38054
|
},
|
|
37741
38055
|
[embeddedTableRowHeights]
|
|
37742
38056
|
);
|
|
37743
|
-
|
|
38057
|
+
React2.useLayoutEffect(() => {
|
|
37744
38058
|
if (disableMeasuredImportPagination) {
|
|
37745
38059
|
setTableMeasuredRowHeights(
|
|
37746
38060
|
(current) => Object.keys(current).length === 0 ? current : {}
|
|
@@ -37918,7 +38232,7 @@ function DocxEditorViewer({
|
|
|
37918
38232
|
virtualizerMeasurementScale,
|
|
37919
38233
|
visibleTableRowIndexesByNodeIndex
|
|
37920
38234
|
]);
|
|
37921
|
-
const normalizeResizableHeights =
|
|
38235
|
+
const normalizeResizableHeights = React2.useCallback(
|
|
37922
38236
|
(rowHeights) => {
|
|
37923
38237
|
return rowHeights.map((height) => {
|
|
37924
38238
|
if (typeof height !== "number" || !Number.isFinite(height) || height <= 0) {
|
|
@@ -37929,7 +38243,7 @@ function DocxEditorViewer({
|
|
|
37929
38243
|
},
|
|
37930
38244
|
[]
|
|
37931
38245
|
);
|
|
37932
|
-
const distributeHeightByTotal =
|
|
38246
|
+
const distributeHeightByTotal = React2.useCallback(
|
|
37933
38247
|
(rowHeights, totalHeightPx) => {
|
|
37934
38248
|
const safeCount = rowHeights.length;
|
|
37935
38249
|
if (safeCount === 0) {
|
|
@@ -37978,7 +38292,7 @@ function DocxEditorViewer({
|
|
|
37978
38292
|
},
|
|
37979
38293
|
[]
|
|
37980
38294
|
);
|
|
37981
|
-
const beginTableColumnResize =
|
|
38295
|
+
const beginTableColumnResize = React2.useCallback(
|
|
37982
38296
|
(event, tableIndex, boundaryColumnIndex, tableWidthPx, columnWidths) => {
|
|
37983
38297
|
if (isReadOnly) {
|
|
37984
38298
|
return;
|
|
@@ -38068,7 +38382,7 @@ function DocxEditorViewer({
|
|
|
38068
38382
|
},
|
|
38069
38383
|
[isReadOnly]
|
|
38070
38384
|
);
|
|
38071
|
-
const beginTableRowResize =
|
|
38385
|
+
const beginTableRowResize = React2.useCallback(
|
|
38072
38386
|
(event, tableIndex, boundaryRowIndex, rowHeights) => {
|
|
38073
38387
|
if (isReadOnly) {
|
|
38074
38388
|
return;
|
|
@@ -38149,7 +38463,7 @@ function DocxEditorViewer({
|
|
|
38149
38463
|
},
|
|
38150
38464
|
[isReadOnly]
|
|
38151
38465
|
);
|
|
38152
|
-
const beginEmbeddedTableColumnResize =
|
|
38466
|
+
const beginEmbeddedTableColumnResize = React2.useCallback(
|
|
38153
38467
|
(event, tableKey, boundaryColumnIndex, tableWidthPx, columnWidths) => {
|
|
38154
38468
|
if (isReadOnly) {
|
|
38155
38469
|
return;
|
|
@@ -38242,7 +38556,7 @@ function DocxEditorViewer({
|
|
|
38242
38556
|
},
|
|
38243
38557
|
[isReadOnly]
|
|
38244
38558
|
);
|
|
38245
|
-
const beginEmbeddedTableRowResize =
|
|
38559
|
+
const beginEmbeddedTableRowResize = React2.useCallback(
|
|
38246
38560
|
(event, tableKey, boundaryRowIndex, rowHeights) => {
|
|
38247
38561
|
if (isReadOnly) {
|
|
38248
38562
|
return;
|
|
@@ -38323,7 +38637,7 @@ function DocxEditorViewer({
|
|
|
38323
38637
|
},
|
|
38324
38638
|
[isReadOnly]
|
|
38325
38639
|
);
|
|
38326
|
-
const beginImageResize =
|
|
38640
|
+
const beginImageResize = React2.useCallback(
|
|
38327
38641
|
(event, location, startWidthPx, startHeightPx, xDirection, yDirection) => {
|
|
38328
38642
|
if (isReadOnly) {
|
|
38329
38643
|
return;
|
|
@@ -38377,7 +38691,7 @@ function DocxEditorViewer({
|
|
|
38377
38691
|
},
|
|
38378
38692
|
[editor, isReadOnly]
|
|
38379
38693
|
);
|
|
38380
|
-
const beginFloatingImageMove =
|
|
38694
|
+
const beginFloatingImageMove = React2.useCallback(
|
|
38381
38695
|
(event, location, image, isWrappedFloatingImage, isAbsoluteFloatingImage) => {
|
|
38382
38696
|
if (isReadOnly || event.button !== 0 || event.target.closest(
|
|
38383
38697
|
"[data-image-resize-handle='true']"
|
|
@@ -38389,7 +38703,7 @@ function DocxEditorViewer({
|
|
|
38389
38703
|
setSelectedImage(location);
|
|
38390
38704
|
const element = event.currentTarget;
|
|
38391
38705
|
const imageKey = imageLocationKey(location);
|
|
38392
|
-
const
|
|
38706
|
+
const zoom2 = resolveViewerMeasurementZoomScale(element, 1);
|
|
38393
38707
|
const isInline = !isWrappedFloatingImage && !isAbsoluteFloatingImage;
|
|
38394
38708
|
const floating = image.floating;
|
|
38395
38709
|
let caret;
|
|
@@ -38469,7 +38783,7 @@ function DocxEditorViewer({
|
|
|
38469
38783
|
objectDragCleanupRef.current = startObjectDrag({
|
|
38470
38784
|
event,
|
|
38471
38785
|
element,
|
|
38472
|
-
zoom,
|
|
38786
|
+
zoom: zoom2,
|
|
38473
38787
|
resolveElement: () => viewerRootRef.current?.querySelector(
|
|
38474
38788
|
`[data-docx-image-location="${imageKey}"]`
|
|
38475
38789
|
) ?? void 0,
|
|
@@ -38529,7 +38843,7 @@ function DocxEditorViewer({
|
|
|
38529
38843
|
const anchorLayout = anchorParagraph?.type === "paragraph" && anchorSource ? layoutParagraphPretextSource(
|
|
38530
38844
|
anchorParagraph,
|
|
38531
38845
|
anchorSource,
|
|
38532
|
-
hostRect.width /
|
|
38846
|
+
hostRect.width / zoom2,
|
|
38533
38847
|
Number(host?.dataset.docxParagraphLineHeight) || estimateParagraphLineHeightPx(anchorParagraph),
|
|
38534
38848
|
[]
|
|
38535
38849
|
) : void 0;
|
|
@@ -38547,9 +38861,9 @@ function DocxEditorViewer({
|
|
|
38547
38861
|
{
|
|
38548
38862
|
...resolveWrappedFloatingImageDropPatch(
|
|
38549
38863
|
image,
|
|
38550
|
-
hostRect.width /
|
|
38551
|
-
(frame.left - hostRect.left) /
|
|
38552
|
-
(frame.top - hostRect.top) /
|
|
38864
|
+
hostRect.width / zoom2,
|
|
38865
|
+
(frame.left - hostRect.left) / zoom2,
|
|
38866
|
+
(frame.top - hostRect.top) / zoom2
|
|
38553
38867
|
),
|
|
38554
38868
|
horizontalAlign: void 0,
|
|
38555
38869
|
verticalAlign: void 0,
|
|
@@ -38570,12 +38884,12 @@ function DocxEditorViewer({
|
|
|
38570
38884
|
documentLayout,
|
|
38571
38885
|
{
|
|
38572
38886
|
wrapperRect: {
|
|
38573
|
-
left: frame.left /
|
|
38574
|
-
top: frame.top /
|
|
38575
|
-
width: frame.width /
|
|
38576
|
-
height: frame.height /
|
|
38887
|
+
left: frame.left / zoom2,
|
|
38888
|
+
top: frame.top / zoom2,
|
|
38889
|
+
width: frame.width / zoom2,
|
|
38890
|
+
height: frame.height / zoom2
|
|
38577
38891
|
},
|
|
38578
|
-
pageSurfaceRect: surfaceRect ? normalizeFloatingDropRectForZoom(surfaceRect,
|
|
38892
|
+
pageSurfaceRect: surfaceRect ? normalizeFloatingDropRectForZoom(surfaceRect, zoom2) : void 0,
|
|
38579
38893
|
deltaX: 0,
|
|
38580
38894
|
deltaY: 0
|
|
38581
38895
|
}
|
|
@@ -38603,7 +38917,7 @@ function DocxEditorViewer({
|
|
|
38603
38917
|
clearObjectDragPreview
|
|
38604
38918
|
]
|
|
38605
38919
|
);
|
|
38606
|
-
const beginDropCapMove =
|
|
38920
|
+
const beginDropCapMove = React2.useCallback(
|
|
38607
38921
|
(event, nodeIndex, dropCap) => {
|
|
38608
38922
|
if (isReadOnly) {
|
|
38609
38923
|
return;
|
|
@@ -38650,7 +38964,7 @@ function DocxEditorViewer({
|
|
|
38650
38964
|
},
|
|
38651
38965
|
[editor, isReadOnly]
|
|
38652
38966
|
);
|
|
38653
|
-
const beginDropCapResize =
|
|
38967
|
+
const beginDropCapResize = React2.useCallback(
|
|
38654
38968
|
(event, nodeIndex, currentFontSizePx, currentWidthPx, currentHeightPx) => {
|
|
38655
38969
|
if (isReadOnly || event.button !== 0) {
|
|
38656
38970
|
return;
|
|
@@ -38701,7 +39015,7 @@ function DocxEditorViewer({
|
|
|
38701
39015
|
},
|
|
38702
39016
|
[editor, isReadOnly]
|
|
38703
39017
|
);
|
|
38704
|
-
const beginSectionFloatingImageMove =
|
|
39018
|
+
const beginSectionFloatingImageMove = React2.useCallback(
|
|
38705
39019
|
(event, location, image, isWrappedFloatingImage, isAbsoluteFloatingImage) => {
|
|
38706
39020
|
if (isReadOnly) {
|
|
38707
39021
|
return;
|
|
@@ -38863,7 +39177,7 @@ function DocxEditorViewer({
|
|
|
38863
39177
|
resolveViewerMeasurementZoomScale
|
|
38864
39178
|
]
|
|
38865
39179
|
);
|
|
38866
|
-
const onSectionImageClick =
|
|
39180
|
+
const onSectionImageClick = React2.useCallback(
|
|
38867
39181
|
(location) => {
|
|
38868
39182
|
if (isReadOnly) {
|
|
38869
39183
|
return;
|
|
@@ -38876,7 +39190,7 @@ function DocxEditorViewer({
|
|
|
38876
39190
|
},
|
|
38877
39191
|
[activeHeaderFooterEdit, isReadOnly]
|
|
38878
39192
|
);
|
|
38879
|
-
const onImageDragStart =
|
|
39193
|
+
const onImageDragStart = React2.useCallback(
|
|
38880
39194
|
(event, location) => {
|
|
38881
39195
|
if (isReadOnly) {
|
|
38882
39196
|
event.preventDefault();
|
|
@@ -38891,12 +39205,12 @@ function DocxEditorViewer({
|
|
|
38891
39205
|
},
|
|
38892
39206
|
[isReadOnly]
|
|
38893
39207
|
);
|
|
38894
|
-
const onImageDragEnd =
|
|
39208
|
+
const onImageDragEnd = React2.useCallback(() => {
|
|
38895
39209
|
draggedImageRef.current = null;
|
|
38896
39210
|
setIsDraggingImage(false);
|
|
38897
39211
|
setActiveDropTarget(void 0);
|
|
38898
39212
|
}, []);
|
|
38899
|
-
const beginTableCornerResize =
|
|
39213
|
+
const beginTableCornerResize = React2.useCallback(
|
|
38900
39214
|
(event, tableIndex, tableWidthPx, columnWidths, rowHeights, maxTableWidthPx) => {
|
|
38901
39215
|
if (isReadOnly) {
|
|
38902
39216
|
return;
|
|
@@ -38999,7 +39313,7 @@ function DocxEditorViewer({
|
|
|
38999
39313
|
},
|
|
39000
39314
|
[isReadOnly]
|
|
39001
39315
|
);
|
|
39002
|
-
const beginEmbeddedTableCornerResize =
|
|
39316
|
+
const beginEmbeddedTableCornerResize = React2.useCallback(
|
|
39003
39317
|
(event, tableKey, tableWidthPx, columnWidths, rowHeights, maxTableWidthPx) => {
|
|
39004
39318
|
if (isReadOnly) {
|
|
39005
39319
|
return;
|
|
@@ -39102,7 +39416,7 @@ function DocxEditorViewer({
|
|
|
39102
39416
|
},
|
|
39103
39417
|
[distributeHeightByTotal, isReadOnly, normalizeResizableHeights]
|
|
39104
39418
|
);
|
|
39105
|
-
const beginEmbeddedTableMove =
|
|
39419
|
+
const beginEmbeddedTableMove = React2.useCallback(
|
|
39106
39420
|
(event, tableKey) => {
|
|
39107
39421
|
if (isReadOnly) {
|
|
39108
39422
|
return;
|
|
@@ -39188,7 +39502,7 @@ function DocxEditorViewer({
|
|
|
39188
39502
|
},
|
|
39189
39503
|
[editor, isReadOnly, resolveTableMoveDropTarget]
|
|
39190
39504
|
);
|
|
39191
|
-
const embeddedTableResizeController =
|
|
39505
|
+
const embeddedTableResizeController = React2.useMemo(
|
|
39192
39506
|
() => ({
|
|
39193
39507
|
isReadOnly,
|
|
39194
39508
|
hoveredTableKey: hoveredEmbeddedTableKey,
|
|
@@ -39250,7 +39564,7 @@ function DocxEditorViewer({
|
|
|
39250
39564
|
resolveEmbeddedTableRowHeights
|
|
39251
39565
|
]
|
|
39252
39566
|
);
|
|
39253
|
-
const onDropImageAtTarget =
|
|
39567
|
+
const onDropImageAtTarget = React2.useCallback(
|
|
39254
39568
|
(target) => {
|
|
39255
39569
|
if (isReadOnly) {
|
|
39256
39570
|
return;
|
|
@@ -39282,7 +39596,7 @@ function DocxEditorViewer({
|
|
|
39282
39596
|
},
|
|
39283
39597
|
[editor, isReadOnly]
|
|
39284
39598
|
);
|
|
39285
|
-
const renderImageDropZone =
|
|
39599
|
+
const renderImageDropZone = React2.useCallback(
|
|
39286
39600
|
(target, key) => {
|
|
39287
39601
|
if (isReadOnly || !isDraggingImage) {
|
|
39288
39602
|
return null;
|
|
@@ -40049,7 +40363,7 @@ function DocxEditorViewer({
|
|
|
40049
40363
|
}
|
|
40050
40364
|
);
|
|
40051
40365
|
};
|
|
40052
|
-
const renderInteractiveParagraphRuns =
|
|
40366
|
+
const renderInteractiveParagraphRuns = React2.useCallback(
|
|
40053
40367
|
(paragraph, keyPrefix, location, options) => {
|
|
40054
40368
|
const lineRange = options?.paragraphLineRange;
|
|
40055
40369
|
const sliceTop = (lineRange?.startLineIndex ?? 0) * (lineRange?.lineHeightPx ?? 0);
|
|
@@ -42252,13 +42566,13 @@ function DocxEditorViewer({
|
|
|
42252
42566
|
trackedChangesEnabled
|
|
42253
42567
|
]
|
|
42254
42568
|
);
|
|
42255
|
-
const hasFilePayload =
|
|
42569
|
+
const hasFilePayload = React2.useCallback(
|
|
42256
42570
|
(dataTransfer) => {
|
|
42257
42571
|
return Array.from(dataTransfer?.types ?? []).includes("Files");
|
|
42258
42572
|
},
|
|
42259
42573
|
[]
|
|
42260
42574
|
);
|
|
42261
|
-
const extractDroppedDocxFile =
|
|
42575
|
+
const extractDroppedDocxFile = React2.useCallback(
|
|
42262
42576
|
(dataTransfer) => {
|
|
42263
42577
|
return Array.from(dataTransfer?.files ?? []).find(
|
|
42264
42578
|
(candidate) => /\.docx?$/i.test(candidate.name)
|
|
@@ -42266,7 +42580,7 @@ function DocxEditorViewer({
|
|
|
42266
42580
|
},
|
|
42267
42581
|
[]
|
|
42268
42582
|
);
|
|
42269
|
-
const onCanvasDragOver =
|
|
42583
|
+
const onCanvasDragOver = React2.useCallback(
|
|
42270
42584
|
(event) => {
|
|
42271
42585
|
if (isDraggingImage) {
|
|
42272
42586
|
event.preventDefault();
|
|
@@ -42288,7 +42602,7 @@ function DocxEditorViewer({
|
|
|
42288
42602
|
},
|
|
42289
42603
|
[canReplaceDocumentByDrop, hasFilePayload, isDraggingImage]
|
|
42290
42604
|
);
|
|
42291
|
-
const onCanvasDragLeave =
|
|
42605
|
+
const onCanvasDragLeave = React2.useCallback(
|
|
42292
42606
|
(event) => {
|
|
42293
42607
|
if (event.currentTarget.contains(event.relatedTarget)) {
|
|
42294
42608
|
return;
|
|
@@ -42297,7 +42611,7 @@ function DocxEditorViewer({
|
|
|
42297
42611
|
},
|
|
42298
42612
|
[]
|
|
42299
42613
|
);
|
|
42300
|
-
const onCanvasDrop =
|
|
42614
|
+
const onCanvasDrop = React2.useCallback(
|
|
42301
42615
|
async (event) => {
|
|
42302
42616
|
setIsDragOverCanvas(false);
|
|
42303
42617
|
if (isDraggingImage) {
|
|
@@ -42317,7 +42631,7 @@ function DocxEditorViewer({
|
|
|
42317
42631
|
},
|
|
42318
42632
|
[canReplaceDocumentByDrop, editor, extractDroppedDocxFile, isDraggingImage]
|
|
42319
42633
|
);
|
|
42320
|
-
|
|
42634
|
+
React2.useEffect(() => {
|
|
42321
42635
|
if (!canReplaceDocumentByDrop) {
|
|
42322
42636
|
fileDragDepthRef.current = 0;
|
|
42323
42637
|
setIsDragOverCanvas(false);
|
|
@@ -42390,7 +42704,7 @@ function DocxEditorViewer({
|
|
|
42390
42704
|
120,
|
|
42391
42705
|
documentLayout.pageWidthPx - documentLayout.marginsPx.left - documentLayout.marginsPx.right
|
|
42392
42706
|
);
|
|
42393
|
-
const documentInheritedFontFamily =
|
|
42707
|
+
const documentInheritedFontFamily = React2.useMemo(
|
|
42394
42708
|
() => resolveDocumentInheritedFontFamily(editor.model),
|
|
42395
42709
|
[editor.model]
|
|
42396
42710
|
);
|
|
@@ -42402,19 +42716,19 @@ function DocxEditorViewer({
|
|
|
42402
42716
|
boxSizing: "border-box",
|
|
42403
42717
|
overflow: floatingMovePreview || dropCapMovePreview ? "visible" : "clip"
|
|
42404
42718
|
};
|
|
42405
|
-
const tableCellParagraphSliceLayoutCacheRef =
|
|
42719
|
+
const tableCellParagraphSliceLayoutCacheRef = React2.useRef(
|
|
42406
42720
|
/* @__PURE__ */ new Map()
|
|
42407
42721
|
);
|
|
42408
|
-
const tableCellParagraphFlowLayoutCacheRef =
|
|
42722
|
+
const tableCellParagraphFlowLayoutCacheRef = React2.useRef(
|
|
42409
42723
|
/* @__PURE__ */ new Map()
|
|
42410
42724
|
);
|
|
42411
|
-
const tableCellParagraphSlicePlanCacheRef =
|
|
42725
|
+
const tableCellParagraphSlicePlanCacheRef = React2.useRef(
|
|
42412
42726
|
/* @__PURE__ */ new Map()
|
|
42413
42727
|
);
|
|
42414
|
-
const tableCellParagraphSliceSignatureCacheRef =
|
|
42728
|
+
const tableCellParagraphSliceSignatureCacheRef = React2.useRef(
|
|
42415
42729
|
/* @__PURE__ */ new WeakMap()
|
|
42416
42730
|
);
|
|
42417
|
-
|
|
42731
|
+
React2.useEffect(() => {
|
|
42418
42732
|
tableCellParagraphSliceLayoutCacheRef.current.clear();
|
|
42419
42733
|
tableCellParagraphFlowLayoutCacheRef.current.clear();
|
|
42420
42734
|
tableCellParagraphSlicePlanCacheRef.current.clear();
|
|
@@ -45840,11 +46154,11 @@ ${currentText.slice(end)}`;
|
|
|
45840
46154
|
}
|
|
45841
46155
|
return renderedTableBlock;
|
|
45842
46156
|
};
|
|
45843
|
-
const objectDragPageRenderCacheRef =
|
|
46157
|
+
const objectDragPageRenderCacheRef = React2.useRef(
|
|
45844
46158
|
/* @__PURE__ */ new Map()
|
|
45845
46159
|
);
|
|
45846
46160
|
if (!objectWrapDragPreview) objectDragPageRenderCacheRef.current.clear();
|
|
45847
|
-
const renderNodeSegments =
|
|
46161
|
+
const renderNodeSegments = React2.useCallback(
|
|
45848
46162
|
(nodeSegments, options) => {
|
|
45849
46163
|
const dragSourceIndex = objectWrapDragPreview?.tableIndex ?? (objectWrapDragPreview?.imageKey?.startsWith("p:") ? Number(objectWrapDragPreview.imageKey.split(":")[1]) : -1);
|
|
45850
46164
|
const dragPagePreview = objectWrapDragPreview?.bandsByPage.has(
|
|
@@ -45899,7 +46213,7 @@ ${currentText.slice(end)}`;
|
|
|
45899
46213
|
Math.round(segment2.tableRowSlice.sliceHeightPx)
|
|
45900
46214
|
)}` : ""}` : segment2.paragraphLineRange ? `lines-${segment2.paragraphLineRange.startLineIndex}-${segment2.paragraphLineRange.endLineIndex}` : "all";
|
|
45901
46215
|
return /* @__PURE__ */ jsx(
|
|
45902
|
-
|
|
46216
|
+
React2.Fragment,
|
|
45903
46217
|
{
|
|
45904
46218
|
children: renderDocumentNode(
|
|
45905
46219
|
groupNode,
|
|
@@ -45949,7 +46263,7 @@ ${currentText.slice(end)}`;
|
|
|
45949
46263
|
const leftSegment = leftSegments[rowIndex];
|
|
45950
46264
|
const rightSegment = rightSegments[rowIndex];
|
|
45951
46265
|
return /* @__PURE__ */ jsxs(
|
|
45952
|
-
|
|
46266
|
+
React2.Fragment,
|
|
45953
46267
|
{
|
|
45954
46268
|
children: [
|
|
45955
46269
|
/* @__PURE__ */ jsx("div", { style: letterheadColumnStackStyle(), children: leftSegment ? renderLetterheadSegment(
|
|
@@ -46591,23 +46905,23 @@ ${currentText.slice(end)}`;
|
|
|
46591
46905
|
);
|
|
46592
46906
|
const footnotes = editor.model.metadata.footnotes ?? [];
|
|
46593
46907
|
const endnotes = editor.model.metadata.endnotes ?? [];
|
|
46594
|
-
const footnoteDisplayIndexById =
|
|
46908
|
+
const footnoteDisplayIndexById = React2.useMemo(
|
|
46595
46909
|
() => new Map(footnotes.map((note, index) => [note.id, index + 1])),
|
|
46596
46910
|
[footnotes]
|
|
46597
46911
|
);
|
|
46598
|
-
const endnoteDisplayIndexById =
|
|
46912
|
+
const endnoteDisplayIndexById = React2.useMemo(
|
|
46599
46913
|
() => new Map(endnotes.map((note, index) => [note.id, index + 1])),
|
|
46600
46914
|
[endnotes]
|
|
46601
46915
|
);
|
|
46602
|
-
const footnotesById =
|
|
46916
|
+
const footnotesById = React2.useMemo(
|
|
46603
46917
|
() => new Map(footnotes.map((note) => [note.id, note])),
|
|
46604
46918
|
[footnotes]
|
|
46605
46919
|
);
|
|
46606
|
-
const endnotesById =
|
|
46920
|
+
const endnotesById = React2.useMemo(
|
|
46607
46921
|
() => new Map(endnotes.map((note) => [note.id, note])),
|
|
46608
46922
|
[endnotes]
|
|
46609
46923
|
);
|
|
46610
|
-
const pageFootnotesByIndex =
|
|
46924
|
+
const pageFootnotesByIndex = React2.useMemo(() => {
|
|
46611
46925
|
if (footnotes.length === 0) {
|
|
46612
46926
|
return pageNodeSegmentsByPage.map(() => []);
|
|
46613
46927
|
}
|
|
@@ -46640,7 +46954,7 @@ ${currentText.slice(end)}`;
|
|
|
46640
46954
|
footnotesById,
|
|
46641
46955
|
pageNodeSegmentsByPage
|
|
46642
46956
|
]);
|
|
46643
|
-
const referencedEndnotes =
|
|
46957
|
+
const referencedEndnotes = React2.useMemo(() => {
|
|
46644
46958
|
if (endnotes.length === 0) {
|
|
46645
46959
|
return endnotes;
|
|
46646
46960
|
}
|
|
@@ -46658,7 +46972,7 @@ ${currentText.slice(end)}`;
|
|
|
46658
46972
|
const referenced = referencedIds.map((referenceId) => endnotesById.get(referenceId)).filter((note) => Boolean(note));
|
|
46659
46973
|
return referenced.length > 0 ? referenced : endnotes;
|
|
46660
46974
|
}, [editor.model.nodes, endnotes, endnotesById]);
|
|
46661
|
-
const placedFootnoteIds =
|
|
46975
|
+
const placedFootnoteIds = React2.useMemo(() => {
|
|
46662
46976
|
const ids = /* @__PURE__ */ new Set();
|
|
46663
46977
|
pageFootnotesByIndex.forEach((notesForPage) => {
|
|
46664
46978
|
notesForPage.forEach((note) => {
|
|
@@ -46667,11 +46981,11 @@ ${currentText.slice(end)}`;
|
|
|
46667
46981
|
});
|
|
46668
46982
|
return ids;
|
|
46669
46983
|
}, [pageFootnotesByIndex]);
|
|
46670
|
-
const remainingFootnotes =
|
|
46984
|
+
const remainingFootnotes = React2.useMemo(
|
|
46671
46985
|
() => footnotes.filter((note) => !placedFootnoteIds.has(note.id)),
|
|
46672
46986
|
[footnotes, placedFootnoteIds]
|
|
46673
46987
|
);
|
|
46674
|
-
const renderDocumentNote =
|
|
46988
|
+
const renderDocumentNote = React2.useCallback(
|
|
46675
46989
|
(note, noteKind, keyPrefix, pageNumberValue, runRenderOptions) => {
|
|
46676
46990
|
const noteNodes = note.nodes?.filter(
|
|
46677
46991
|
(node) => node.type === "paragraph"
|
|
@@ -46735,7 +47049,7 @@ ${currentText.slice(end)}`;
|
|
|
46735
47049
|
totalPagesForFieldResolution
|
|
46736
47050
|
]
|
|
46737
47051
|
);
|
|
46738
|
-
const headerFooterEditHandlers =
|
|
47052
|
+
const headerFooterEditHandlers = React2.useMemo(
|
|
46739
47053
|
() => ({
|
|
46740
47054
|
registerElement: registerSectionParagraphElement,
|
|
46741
47055
|
readDraftHtml: readSectionParagraphDraft,
|
|
@@ -46751,7 +47065,7 @@ ${currentText.slice(end)}`;
|
|
|
46751
47065
|
writeSectionParagraphDraft
|
|
46752
47066
|
]
|
|
46753
47067
|
);
|
|
46754
|
-
const activateHeaderFooterEdit =
|
|
47068
|
+
const activateHeaderFooterEdit = React2.useCallback(
|
|
46755
47069
|
(region, partName, pageIndex, options) => {
|
|
46756
47070
|
if (isReadOnly || !partName) {
|
|
46757
47071
|
return;
|
|
@@ -46778,6 +47092,8 @@ ${currentText.slice(end)}`;
|
|
|
46778
47092
|
"div",
|
|
46779
47093
|
{
|
|
46780
47094
|
"data-testid": "docx-editor-viewer",
|
|
47095
|
+
"data-docx-zoom-level": viewerZoom.level,
|
|
47096
|
+
"data-docx-resolved-zoom": viewerZoom.resolvedZoom,
|
|
46781
47097
|
ref: viewerRootRef,
|
|
46782
47098
|
className,
|
|
46783
47099
|
style: {
|
|
@@ -46786,7 +47102,8 @@ ${currentText.slice(end)}`;
|
|
|
46786
47102
|
gap: DOC_PAGE_BREAK_GAP,
|
|
46787
47103
|
minHeight: hideDocumentUntilPaginationSettled && stableHiddenDocumentHeightPx > 0 ? stableHiddenDocumentHeightPx : void 0,
|
|
46788
47104
|
backgroundColor: pageGapBackgroundColor ?? "transparent",
|
|
46789
|
-
...style
|
|
47105
|
+
...style,
|
|
47106
|
+
zoom: builtInViewerZoomScale
|
|
46790
47107
|
},
|
|
46791
47108
|
onDragOver: onCanvasDragOver,
|
|
46792
47109
|
onDragLeave: onCanvasDragLeave,
|
|
@@ -47407,7 +47724,7 @@ ${currentText.slice(end)}`;
|
|
|
47407
47724
|
const explicitColumnBreakParagraphSegments = columnNode.type === "paragraph" && !columnSegment.tableRowRange && !columnSegment.tableRowSlice && !columnSegment.paragraphLineRange && !explicitColumnWidthsPx && (sectionColumns?.count ?? 0) > 1 ? splitParagraphAtExplicitColumnBreaks(columnNode) : void 0;
|
|
47408
47725
|
if (explicitColumnBreakParagraphSegments && explicitColumnBreakParagraphSegments.length > 1) {
|
|
47409
47726
|
return /* @__PURE__ */ jsx(
|
|
47410
|
-
|
|
47727
|
+
React2.Fragment,
|
|
47411
47728
|
{
|
|
47412
47729
|
children: explicitColumnBreakParagraphSegments.map(
|
|
47413
47730
|
(segmentParagraph, segmentIndex) => {
|
|
@@ -47478,7 +47795,7 @@ ${currentText.slice(end)}`;
|
|
|
47478
47795
|
};
|
|
47479
47796
|
if (!sectionColumns || sectionColumns.count <= 1 || requiresPlainFlowRender) {
|
|
47480
47797
|
return /* @__PURE__ */ jsx(
|
|
47481
|
-
|
|
47798
|
+
React2.Fragment,
|
|
47482
47799
|
{
|
|
47483
47800
|
children: renderNodeSegments(group.segments, {
|
|
47484
47801
|
pageIndex,
|
|
@@ -47538,7 +47855,7 @@ ${currentText.slice(end)}`;
|
|
|
47538
47855
|
return null;
|
|
47539
47856
|
}
|
|
47540
47857
|
return /* @__PURE__ */ jsx(
|
|
47541
|
-
|
|
47858
|
+
React2.Fragment,
|
|
47542
47859
|
{
|
|
47543
47860
|
children: renderDocumentNode(
|
|
47544
47861
|
overlayNode,
|
|
@@ -47866,7 +48183,7 @@ ${currentText.slice(end)}`;
|
|
|
47866
48183
|
)
|
|
47867
48184
|
)}` : ""}` : overlaySegment.paragraphLineRange ? `lines-${overlaySegment.paragraphLineRange.startLineIndex}-${overlaySegment.paragraphLineRange.endLineIndex}` : "all";
|
|
47868
48185
|
return /* @__PURE__ */ jsx(
|
|
47869
|
-
|
|
48186
|
+
React2.Fragment,
|
|
47870
48187
|
{
|
|
47871
48188
|
children: renderDocumentNode(
|
|
47872
48189
|
overlayNode,
|
|
@@ -50636,10 +50953,10 @@ function headingFontSize(level) {
|
|
|
50636
50953
|
}
|
|
50637
50954
|
}
|
|
50638
50955
|
function useDocxModel(file) {
|
|
50639
|
-
const [state, setState] =
|
|
50956
|
+
const [state, setState] = React3.useState({
|
|
50640
50957
|
isLoading: Boolean(file)
|
|
50641
50958
|
});
|
|
50642
|
-
|
|
50959
|
+
React3.useEffect(() => {
|
|
50643
50960
|
if (!file) {
|
|
50644
50961
|
setState({ isLoading: false });
|
|
50645
50962
|
return;
|
|
@@ -50867,7 +51184,7 @@ var containerStyle = {
|
|
|
50867
51184
|
};
|
|
50868
51185
|
function renderBlock(block) {
|
|
50869
51186
|
if (block.kind === "table") {
|
|
50870
|
-
return /* @__PURE__ */ jsx2(
|
|
51187
|
+
return /* @__PURE__ */ jsx2(React3.Fragment, { children: renderTable(block) }, block.id);
|
|
50871
51188
|
}
|
|
50872
51189
|
return /* @__PURE__ */ jsx2(
|
|
50873
51190
|
"p",
|
|
@@ -50891,6 +51208,9 @@ function ReactDocxViewer({
|
|
|
50891
51208
|
loadEmbeddedFonts = true,
|
|
50892
51209
|
pageIndexes,
|
|
50893
51210
|
className,
|
|
51211
|
+
zoom,
|
|
51212
|
+
defaultZoom,
|
|
51213
|
+
onZoomChange,
|
|
50894
51214
|
layoutOptions,
|
|
50895
51215
|
emptyState
|
|
50896
51216
|
}) {
|
|
@@ -50900,12 +51220,12 @@ function ReactDocxViewer({
|
|
|
50900
51220
|
error
|
|
50901
51221
|
} = useDocxModel(model || document2 ? void 0 : file);
|
|
50902
51222
|
const resolvedModel = model ?? document2?.model ?? parsedModel;
|
|
50903
|
-
|
|
51223
|
+
React3.useEffect(() => {
|
|
50904
51224
|
if (document2 && loadEmbeddedFonts && !document2.embeddedFontsLoaded) {
|
|
50905
51225
|
void document2.loadEmbeddedFonts();
|
|
50906
51226
|
}
|
|
50907
51227
|
}, [document2, loadEmbeddedFonts]);
|
|
50908
|
-
const modelWithSections =
|
|
51228
|
+
const modelWithSections = React3.useMemo(() => {
|
|
50909
51229
|
if (!resolvedModel) {
|
|
50910
51230
|
return void 0;
|
|
50911
51231
|
}
|
|
@@ -50919,7 +51239,7 @@ function ReactDocxViewer({
|
|
|
50919
51239
|
nodes: [...headerNodes, ...resolvedModel.nodes, ...footerNodes]
|
|
50920
51240
|
};
|
|
50921
51241
|
}, [resolvedModel]);
|
|
50922
|
-
const resolvedLayoutOptions =
|
|
51242
|
+
const resolvedLayoutOptions = React3.useMemo(() => {
|
|
50923
51243
|
if (!resolvedModel) {
|
|
50924
51244
|
return layoutOptions;
|
|
50925
51245
|
}
|
|
@@ -50930,18 +51250,28 @@ function ReactDocxViewer({
|
|
|
50930
51250
|
pageHeight: layoutOptions?.pageHeight ?? documentLayout.pageHeightPx
|
|
50931
51251
|
};
|
|
50932
51252
|
}, [layoutOptions, resolvedModel]);
|
|
50933
|
-
const pages =
|
|
51253
|
+
const pages = React3.useMemo(() => {
|
|
50934
51254
|
if (!modelWithSections) {
|
|
50935
51255
|
return [];
|
|
50936
51256
|
}
|
|
50937
51257
|
return layoutDocument(modelWithSections, resolvedLayoutOptions);
|
|
50938
51258
|
}, [modelWithSections, resolvedLayoutOptions]);
|
|
50939
|
-
const requestedPageIndexSet =
|
|
51259
|
+
const requestedPageIndexSet = React3.useMemo(
|
|
50940
51260
|
() => pageIndexes === void 0 ? void 0 : new Set(
|
|
50941
51261
|
pageIndexes.filter((pageIndex) => Number.isFinite(pageIndex)).map((pageIndex) => Math.trunc(pageIndex))
|
|
50942
51262
|
),
|
|
50943
51263
|
[pageIndexes]
|
|
50944
51264
|
);
|
|
51265
|
+
const viewerRootRef = React3.useRef(null);
|
|
51266
|
+
const viewerZoom = useViewerZoom({
|
|
51267
|
+
zoom,
|
|
51268
|
+
defaultZoom,
|
|
51269
|
+
onZoomChange,
|
|
51270
|
+
rootRef: viewerRootRef,
|
|
51271
|
+
contentWidth: resolvedLayoutOptions?.pageWidth ?? DEFAULT_DOCUMENT_LAYOUT.pageWidthPx,
|
|
51272
|
+
contentHeight: resolvedLayoutOptions?.pageHeight ?? DEFAULT_DOCUMENT_LAYOUT.pageHeightPx,
|
|
51273
|
+
pageSelector: "[data-page-index]"
|
|
51274
|
+
});
|
|
50945
51275
|
if (isLoading) {
|
|
50946
51276
|
return /* @__PURE__ */ jsx2("div", { className, children: "Loading DOCX..." });
|
|
50947
51277
|
}
|
|
@@ -50960,9 +51290,12 @@ function ReactDocxViewer({
|
|
|
50960
51290
|
return /* @__PURE__ */ jsx2(
|
|
50961
51291
|
"div",
|
|
50962
51292
|
{
|
|
51293
|
+
ref: viewerRootRef,
|
|
50963
51294
|
className,
|
|
50964
51295
|
"data-testid": "react-docx-viewer",
|
|
50965
|
-
|
|
51296
|
+
"data-docx-zoom-level": viewerZoom.level,
|
|
51297
|
+
"data-docx-resolved-zoom": viewerZoom.resolvedZoom,
|
|
51298
|
+
style: { ...containerStyle, zoom: viewerZoom.resolvedZoom / 100 },
|
|
50966
51299
|
children: pages.map(
|
|
50967
51300
|
(page, pageIndex) => requestedPageIndexSet && !requestedPageIndexSet.has(pageIndex) ? null : /* @__PURE__ */ jsx2(
|
|
50968
51301
|
"section",
|