@extend-ai/react-docx 0.7.0-alpha.5 → 0.7.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +46 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +46 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -968,6 +968,22 @@ interface DocxPageVirtualizationOptions {
|
|
|
968
968
|
* @defaultValue `0`
|
|
969
969
|
*/
|
|
970
970
|
settleDelayMs?: number;
|
|
971
|
+
/**
|
|
972
|
+
* Explicit scroll container for internal page virtualization.
|
|
973
|
+
*
|
|
974
|
+
* Omit this to let the viewer discover the nearest scrollable ancestor.
|
|
975
|
+
* Provide it when the host app owns scrolling, such as when the viewer is
|
|
976
|
+
* mounted inside a custom scroll-area viewport.
|
|
977
|
+
*/
|
|
978
|
+
scrollElement?: HTMLElement | null;
|
|
979
|
+
/**
|
|
980
|
+
* Effective visual scale applied around the viewer.
|
|
981
|
+
*
|
|
982
|
+
* Omit this to let the viewer infer CSS `zoom` from its ancestor chain.
|
|
983
|
+
* Provide it when toolbar zoom is controlled outside the viewer so virtual
|
|
984
|
+
* page offsets update synchronously with the selected zoom.
|
|
985
|
+
*/
|
|
986
|
+
zoomScale?: number;
|
|
971
987
|
}
|
|
972
988
|
/**
|
|
973
989
|
* Externally controlled visible page window.
|
package/dist/index.d.ts
CHANGED
|
@@ -968,6 +968,22 @@ interface DocxPageVirtualizationOptions {
|
|
|
968
968
|
* @defaultValue `0`
|
|
969
969
|
*/
|
|
970
970
|
settleDelayMs?: number;
|
|
971
|
+
/**
|
|
972
|
+
* Explicit scroll container for internal page virtualization.
|
|
973
|
+
*
|
|
974
|
+
* Omit this to let the viewer discover the nearest scrollable ancestor.
|
|
975
|
+
* Provide it when the host app owns scrolling, such as when the viewer is
|
|
976
|
+
* mounted inside a custom scroll-area viewport.
|
|
977
|
+
*/
|
|
978
|
+
scrollElement?: HTMLElement | null;
|
|
979
|
+
/**
|
|
980
|
+
* Effective visual scale applied around the viewer.
|
|
981
|
+
*
|
|
982
|
+
* Omit this to let the viewer infer CSS `zoom` from its ancestor chain.
|
|
983
|
+
* Provide it when toolbar zoom is controlled outside the viewer so virtual
|
|
984
|
+
* page offsets update synchronously with the selected zoom.
|
|
985
|
+
*/
|
|
986
|
+
zoomScale?: number;
|
|
971
987
|
}
|
|
972
988
|
/**
|
|
973
989
|
* Externally controlled visible page window.
|
package/dist/index.js
CHANGED
|
@@ -3992,6 +3992,10 @@ function resolveEffectiveZoomScale(element) {
|
|
|
3992
3992
|
}
|
|
3993
3993
|
return Number.isFinite(scale) && scale > 0 ? scale : 1;
|
|
3994
3994
|
}
|
|
3995
|
+
function normalizePageVirtualizationZoomScale(value) {
|
|
3996
|
+
const scale = Number(value);
|
|
3997
|
+
return Number.isFinite(scale) && scale > 0 ? scale : void 0;
|
|
3998
|
+
}
|
|
3995
3999
|
var DOC_SURFACE_STYLE_BY_THEME = {
|
|
3996
4000
|
light: {
|
|
3997
4001
|
backgroundColor: "#ffffff",
|
|
@@ -25400,6 +25404,17 @@ function DocxEditorViewer({
|
|
|
25400
25404
|
const pageVirtualizationOverscan = hasLargeTableLayoutSurface && !Number.isFinite(pageVirtualization?.overscan) ? LARGE_TABLE_PAGE_VIRTUALIZATION_OVERSCAN : rawPageVirtualizationOverscan;
|
|
25401
25405
|
const webdriverActive = typeof navigator !== "undefined" && navigator.webdriver === true;
|
|
25402
25406
|
const internalPageVirtualizationRequested = pageVirtualization?.enabled !== false && !hasExternalVisiblePageRange && !hideDocumentUntilPaginationSettled && isInitialPaginationSettled && !deferInternalPageVirtualization && !webdriverActive && pageCount > 1;
|
|
25407
|
+
const explicitPageVirtualizationScrollElement = pageVirtualization?.scrollElement ?? null;
|
|
25408
|
+
const explicitPageVirtualizationZoomScale = normalizePageVirtualizationZoomScale(pageVirtualization?.zoomScale);
|
|
25409
|
+
const resolveViewerMeasurementZoomScale = React.useCallback(
|
|
25410
|
+
(rootElement, fallback = 1) => {
|
|
25411
|
+
if (explicitPageVirtualizationZoomScale !== void 0) {
|
|
25412
|
+
return explicitPageVirtualizationZoomScale;
|
|
25413
|
+
}
|
|
25414
|
+
return rootElement ? resolveEffectiveZoomScale(rootElement) : fallback;
|
|
25415
|
+
},
|
|
25416
|
+
[explicitPageVirtualizationZoomScale]
|
|
25417
|
+
);
|
|
25403
25418
|
React.useEffect(() => {
|
|
25404
25419
|
setDeferInternalPageVirtualization(!hasLargeTableLayoutSurface);
|
|
25405
25420
|
}, [editor.documentLoadNonce, hasLargeTableLayoutSurface]);
|
|
@@ -25430,9 +25445,14 @@ function DocxEditorViewer({
|
|
|
25430
25445
|
return;
|
|
25431
25446
|
}
|
|
25432
25447
|
setInternalVirtualScrollElement(
|
|
25433
|
-
nearestScrollableAncestor(viewerRootRef.current)
|
|
25448
|
+
explicitPageVirtualizationScrollElement instanceof HTMLElement ? explicitPageVirtualizationScrollElement : nearestScrollableAncestor(viewerRootRef.current)
|
|
25434
25449
|
);
|
|
25435
|
-
}, [
|
|
25450
|
+
}, [
|
|
25451
|
+
editor.documentLoadNonce,
|
|
25452
|
+
explicitPageVirtualizationScrollElement,
|
|
25453
|
+
pageCount,
|
|
25454
|
+
trackedChangesEnabled
|
|
25455
|
+
]);
|
|
25436
25456
|
const [zoomProbeNonce, setZoomProbeNonce] = React.useState(0);
|
|
25437
25457
|
React.useEffect(() => {
|
|
25438
25458
|
if (typeof window === "undefined") {
|
|
@@ -25461,11 +25481,22 @@ function DocxEditorViewer({
|
|
|
25461
25481
|
if (!rootElement) {
|
|
25462
25482
|
return;
|
|
25463
25483
|
}
|
|
25464
|
-
const nextScale = Math.round(
|
|
25484
|
+
const nextScale = Math.round(
|
|
25485
|
+
resolveViewerMeasurementZoomScale(
|
|
25486
|
+
rootElement,
|
|
25487
|
+
virtualizerMeasurementScale
|
|
25488
|
+
) * 100
|
|
25489
|
+
) / 100;
|
|
25465
25490
|
setVirtualizerMeasurementScale(
|
|
25466
25491
|
(current) => Math.abs(current - nextScale) < 5e-3 ? current : nextScale
|
|
25467
25492
|
);
|
|
25468
|
-
}, [
|
|
25493
|
+
}, [
|
|
25494
|
+
editor.documentLoadNonce,
|
|
25495
|
+
pageCount,
|
|
25496
|
+
resolveViewerMeasurementZoomScale,
|
|
25497
|
+
virtualizerMeasurementScale,
|
|
25498
|
+
zoomProbeNonce
|
|
25499
|
+
]);
|
|
25469
25500
|
const internalPageVirtualizationEnabled = internalPageVirtualizationRequested && internalVirtualScrollElement !== null;
|
|
25470
25501
|
const internalPageVirtualizationPending = typeof window !== "undefined" && internalPageVirtualizationRequested && internalVirtualScrollElement === null;
|
|
25471
25502
|
const internalVirtualScrollUsesWindow = typeof document !== "undefined" && internalVirtualScrollElement !== null && (internalVirtualScrollElement === document.scrollingElement || internalVirtualScrollElement === document.documentElement || internalVirtualScrollElement === document.body);
|
|
@@ -25867,7 +25898,7 @@ function DocxEditorViewer({
|
|
|
25867
25898
|
const next = new Map(current);
|
|
25868
25899
|
let changed = false;
|
|
25869
25900
|
const rootElement = viewerRootRef.current;
|
|
25870
|
-
const zoomScale =
|
|
25901
|
+
const zoomScale = resolveViewerMeasurementZoomScale(rootElement, 1);
|
|
25871
25902
|
paragraphElementsRef.current.forEach((element, nodeIndex) => {
|
|
25872
25903
|
if (!element.isConnected || element.dataset.docxParagraphPartialLineRange === "true" || element.closest('[data-docx-header-footer-region="footer"]') || element.closest('[data-docx-header-footer-region="header"]')) {
|
|
25873
25904
|
return;
|
|
@@ -25896,6 +25927,7 @@ function DocxEditorViewer({
|
|
|
25896
25927
|
}, [
|
|
25897
25928
|
editor.documentLoadNonce,
|
|
25898
25929
|
pageNodeSegmentIdentityKeysByPage,
|
|
25930
|
+
resolveViewerMeasurementZoomScale,
|
|
25899
25931
|
visiblePageEndIndex,
|
|
25900
25932
|
visiblePageStartIndex
|
|
25901
25933
|
]);
|
|
@@ -26417,7 +26449,7 @@ function DocxEditorViewer({
|
|
|
26417
26449
|
);
|
|
26418
26450
|
return;
|
|
26419
26451
|
}
|
|
26420
|
-
const zoomScale =
|
|
26452
|
+
const zoomScale = resolveViewerMeasurementZoomScale(rootElement, 1);
|
|
26421
26453
|
const next = {};
|
|
26422
26454
|
for (let pageIndex = 0; pageIndex < pageCount; pageIndex += 1) {
|
|
26423
26455
|
if (!isPageVisible(pageIndex)) {
|
|
@@ -26504,6 +26536,7 @@ function DocxEditorViewer({
|
|
|
26504
26536
|
pageCount,
|
|
26505
26537
|
pageHeaderAndFooterNodes,
|
|
26506
26538
|
pageSectionInfoByIndex,
|
|
26539
|
+
resolveViewerMeasurementZoomScale,
|
|
26507
26540
|
visiblePageEndIndex,
|
|
26508
26541
|
visiblePageStartIndex
|
|
26509
26542
|
]);
|
|
@@ -26533,7 +26566,7 @@ function DocxEditorViewer({
|
|
|
26533
26566
|
if (Date.now() < paginationMeasurementSuspendUntilRef.current) {
|
|
26534
26567
|
return;
|
|
26535
26568
|
}
|
|
26536
|
-
const zoomScale =
|
|
26569
|
+
const zoomScale = resolveViewerMeasurementZoomScale(rootElement, 1);
|
|
26537
26570
|
const nextMeasuredPageIdentityKeys = pageNodeSegmentIdentityKeysByPage;
|
|
26538
26571
|
const nextMeasuredPageDiagnostics = pageNodeSegmentsByPage.map(
|
|
26539
26572
|
(_, pageIndex) => {
|
|
@@ -26748,6 +26781,7 @@ function DocxEditorViewer({
|
|
|
26748
26781
|
pageNodeSegmentIdentityKeysByPage,
|
|
26749
26782
|
pageSectionInfoByIndex,
|
|
26750
26783
|
pageHeaderAndFooterNodes,
|
|
26784
|
+
resolveViewerMeasurementZoomScale,
|
|
26751
26785
|
visiblePageEndIndex,
|
|
26752
26786
|
visiblePageStartIndex
|
|
26753
26787
|
]);
|
|
@@ -31182,7 +31216,10 @@ function DocxEditorViewer({
|
|
|
31182
31216
|
return;
|
|
31183
31217
|
}
|
|
31184
31218
|
const rootElement = viewerRootRef.current;
|
|
31185
|
-
const zoomScale =
|
|
31219
|
+
const zoomScale = resolveViewerMeasurementZoomScale(
|
|
31220
|
+
rootElement,
|
|
31221
|
+
virtualizerMeasurementScale
|
|
31222
|
+
);
|
|
31186
31223
|
const nextMeasuredHeights = {};
|
|
31187
31224
|
editor.model.nodes.forEach((node, nodeIndex) => {
|
|
31188
31225
|
if (node.type !== "table") {
|
|
@@ -31324,6 +31361,7 @@ function DocxEditorViewer({
|
|
|
31324
31361
|
pageContentWidthPxByNodeIndex,
|
|
31325
31362
|
paginationMeasurementEnabled,
|
|
31326
31363
|
paginationMeasurementEpoch,
|
|
31364
|
+
resolveViewerMeasurementZoomScale,
|
|
31327
31365
|
tableMeasuredRowHeights,
|
|
31328
31366
|
tableColumnWidths,
|
|
31329
31367
|
tableRowHeights,
|