@extend-ai/react-docx 0.7.2 → 0.7.4
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 +81 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +81 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5834,11 +5834,13 @@ var BASE_DOC_STYLE = {
|
|
|
5834
5834
|
transition: "box-shadow 0.2s ease"
|
|
5835
5835
|
};
|
|
5836
5836
|
var TRACKED_CHANGE_GUTTER_WIDTH_PX = 300;
|
|
5837
|
-
var TRACKED_CHANGE_GUTTER_CARD_LEFT_PX =
|
|
5837
|
+
var TRACKED_CHANGE_GUTTER_CARD_LEFT_PX = 48;
|
|
5838
5838
|
var TRACKED_CHANGE_GUTTER_CARD_RIGHT_PX = 12;
|
|
5839
5839
|
var TRACKED_CHANGE_GUTTER_CARD_GAP_PX = 4;
|
|
5840
5840
|
var TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX = 30;
|
|
5841
5841
|
var TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX = 8;
|
|
5842
|
+
var TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_GAP_PX = 7;
|
|
5843
|
+
var TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_COUNT = 5;
|
|
5842
5844
|
var INITIAL_PAGINATION_STABILITY_IDLE_MS = 240;
|
|
5843
5845
|
function scheduleDomWrite(callback) {
|
|
5844
5846
|
if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
|
|
@@ -19637,6 +19639,51 @@ function estimateTrackedChangeCardHeight(change) {
|
|
|
19637
19639
|
const lines = Math.min(2, Math.max(1, Math.ceil(snippet.length / 42)));
|
|
19638
19640
|
return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 22 + lines * 11);
|
|
19639
19641
|
}
|
|
19642
|
+
function assignGutterConnectorLanes(entries) {
|
|
19643
|
+
if (entries.length <= 1) {
|
|
19644
|
+
entries.forEach((entry) => {
|
|
19645
|
+
entry.connectorLane = 0;
|
|
19646
|
+
});
|
|
19647
|
+
return;
|
|
19648
|
+
}
|
|
19649
|
+
const intervalPaddingPx = 3;
|
|
19650
|
+
const laneEndY = Array.from(
|
|
19651
|
+
{ length: TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_COUNT },
|
|
19652
|
+
() => Number.NEGATIVE_INFINITY
|
|
19653
|
+
);
|
|
19654
|
+
const routedEntries = entries.map((entry, index) => {
|
|
19655
|
+
const cardCenterY = entry.top + entry.heightPx / 2;
|
|
19656
|
+
return {
|
|
19657
|
+
entry,
|
|
19658
|
+
index,
|
|
19659
|
+
startY: Math.min(entry.anchorY, cardCenterY) - intervalPaddingPx,
|
|
19660
|
+
endY: Math.max(entry.anchorY, cardCenterY) + intervalPaddingPx
|
|
19661
|
+
};
|
|
19662
|
+
}).sort((left, right) => {
|
|
19663
|
+
const startDelta = left.startY - right.startY;
|
|
19664
|
+
if (startDelta !== 0) {
|
|
19665
|
+
return startDelta;
|
|
19666
|
+
}
|
|
19667
|
+
const endDelta = left.endY - right.endY;
|
|
19668
|
+
if (endDelta !== 0) {
|
|
19669
|
+
return endDelta;
|
|
19670
|
+
}
|
|
19671
|
+
return left.index - right.index;
|
|
19672
|
+
});
|
|
19673
|
+
routedEntries.forEach((route) => {
|
|
19674
|
+
let laneIndex = laneEndY.findIndex(
|
|
19675
|
+
(laneEnd) => route.startY > laneEnd + intervalPaddingPx
|
|
19676
|
+
);
|
|
19677
|
+
if (laneIndex < 0) {
|
|
19678
|
+
laneIndex = laneEndY.reduce(
|
|
19679
|
+
(bestLane, laneEnd, index) => laneEnd < laneEndY[bestLane] ? index : bestLane,
|
|
19680
|
+
0
|
|
19681
|
+
);
|
|
19682
|
+
}
|
|
19683
|
+
route.entry.connectorLane = laneIndex;
|
|
19684
|
+
laneEndY[laneIndex] = Math.max(laneEndY[laneIndex], route.endY);
|
|
19685
|
+
});
|
|
19686
|
+
}
|
|
19640
19687
|
function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsByChangeId, pageWidthPx, pageHeightPx) {
|
|
19641
19688
|
if (annotations.length === 0) {
|
|
19642
19689
|
return [];
|
|
@@ -19672,7 +19719,8 @@ function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsB
|
|
|
19672
19719
|
Math.max(10, pageHeightPx - 10)
|
|
19673
19720
|
),
|
|
19674
19721
|
top: 0,
|
|
19675
|
-
heightPx
|
|
19722
|
+
heightPx,
|
|
19723
|
+
connectorLane: 0
|
|
19676
19724
|
};
|
|
19677
19725
|
});
|
|
19678
19726
|
withAnchors.sort((left, right) => {
|
|
@@ -19704,6 +19752,7 @@ function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsB
|
|
|
19704
19752
|
shiftedCursorTopPx = entry.top + entry.heightPx + TRACKED_CHANGE_GUTTER_CARD_GAP_PX;
|
|
19705
19753
|
});
|
|
19706
19754
|
}
|
|
19755
|
+
assignGutterConnectorLanes(withAnchors);
|
|
19707
19756
|
return withAnchors;
|
|
19708
19757
|
}
|
|
19709
19758
|
function sameParagraphLocation(a, b) {
|
|
@@ -42832,16 +42881,28 @@ ${currentText.slice(end)}`;
|
|
|
42832
42881
|
boxSizing: "border-box",
|
|
42833
42882
|
zIndex: 0
|
|
42834
42883
|
} : void 0;
|
|
42884
|
+
const pageTrackedChanges = positionedTrackedChangesByPage[pageIndex] ?? [];
|
|
42885
|
+
const pageGutterContentHeightPx = showTrackedChangeGutter && pageTrackedChanges.length > 0 ? pageTrackedChanges.reduce((maxBottomPx, entry) => {
|
|
42886
|
+
return Math.max(
|
|
42887
|
+
maxBottomPx,
|
|
42888
|
+
Math.ceil(
|
|
42889
|
+
entry.top + entry.heightPx + TRACKED_CHANGE_GUTTER_CARD_GAP_PX + 8
|
|
42890
|
+
)
|
|
42891
|
+
);
|
|
42892
|
+
}, pageLayout.pageHeightPx) : pageLayout.pageHeightPx;
|
|
42893
|
+
const pageVisualHeightPx = Math.max(
|
|
42894
|
+
pageLayout.pageHeightPx,
|
|
42895
|
+
pageGutterContentHeightPx
|
|
42896
|
+
);
|
|
42835
42897
|
const pageSurfaceStyle = {
|
|
42836
42898
|
...pageSurfaceBaseStyle,
|
|
42837
42899
|
width: pageLayout.pageWidthPx,
|
|
42838
|
-
height:
|
|
42839
|
-
minHeight:
|
|
42900
|
+
height: pageVisualHeightPx,
|
|
42901
|
+
minHeight: pageVisualHeightPx,
|
|
42840
42902
|
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
42841
42903
|
position: "relative",
|
|
42842
42904
|
...pageMarginPaddingStyle(pageLayout.marginsPx)
|
|
42843
42905
|
};
|
|
42844
|
-
const pageTrackedChanges = positionedTrackedChangesByPage[pageIndex] ?? [];
|
|
42845
42906
|
const pageCoverBackgroundImages = (() => {
|
|
42846
42907
|
const collected = /* @__PURE__ */ new Map();
|
|
42847
42908
|
const pageContentHeightPx = Math.max(
|
|
@@ -42889,7 +42950,7 @@ ${currentText.slice(end)}`;
|
|
|
42889
42950
|
style: {
|
|
42890
42951
|
position: "relative",
|
|
42891
42952
|
width: pageWrapperWidthPx,
|
|
42892
|
-
minHeight:
|
|
42953
|
+
minHeight: pageVisualHeightPx,
|
|
42893
42954
|
margin: "0 auto",
|
|
42894
42955
|
// Isolate per-page layout/style recalculation so scrolling and
|
|
42895
42956
|
// edits on one page don't force whole-document layout passes.
|
|
@@ -43938,7 +43999,7 @@ ${currentText.slice(end)}`;
|
|
|
43938
43999
|
left: pageLayout.pageWidthPx,
|
|
43939
44000
|
top: 0,
|
|
43940
44001
|
width: TRACKED_CHANGE_GUTTER_WIDTH_PX,
|
|
43941
|
-
height:
|
|
44002
|
+
height: pageVisualHeightPx,
|
|
43942
44003
|
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
43943
44004
|
pointerEvents: "none",
|
|
43944
44005
|
overflow: "visible"
|
|
@@ -43961,8 +44022,8 @@ ${currentText.slice(end)}`;
|
|
|
43961
44022
|
"svg",
|
|
43962
44023
|
{
|
|
43963
44024
|
width: pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX,
|
|
43964
|
-
height:
|
|
43965
|
-
viewBox: `0 0 ${pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX} ${
|
|
44025
|
+
height: pageVisualHeightPx,
|
|
44026
|
+
viewBox: `0 0 ${pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX} ${pageVisualHeightPx}`,
|
|
43966
44027
|
style: {
|
|
43967
44028
|
position: "absolute",
|
|
43968
44029
|
top: 0,
|
|
@@ -43990,11 +44051,19 @@ ${currentText.slice(end)}`;
|
|
|
43990
44051
|
Math.max(8, pageLayout.pageWidthPx - 8)
|
|
43991
44052
|
);
|
|
43992
44053
|
const cardAttachX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_CARD_LEFT_PX;
|
|
43993
|
-
const
|
|
44054
|
+
const maxConnectorLaneOffset = Math.max(
|
|
44055
|
+
TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX,
|
|
44056
|
+
TRACKED_CHANGE_GUTTER_CARD_LEFT_PX - 6
|
|
44057
|
+
);
|
|
44058
|
+
const connectorLaneOffset = Math.min(
|
|
44059
|
+
TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX + Math.max(0, entry.connectorLane) * TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_GAP_PX,
|
|
44060
|
+
maxConnectorLaneOffset
|
|
44061
|
+
);
|
|
44062
|
+
const gutterBendX = pageLayout.pageWidthPx + connectorLaneOffset;
|
|
43994
44063
|
const cardCenterY = clampNumber(
|
|
43995
44064
|
Math.round(entry.top + entry.heightPx / 2),
|
|
43996
44065
|
8,
|
|
43997
|
-
Math.max(8,
|
|
44066
|
+
Math.max(8, pageVisualHeightPx - 8)
|
|
43998
44067
|
);
|
|
43999
44068
|
const connectorPath = Math.abs(cardCenterY - anchorY) <= 2 ? `M ${anchorX} ${anchorY} H ${cardAttachX}` : `M ${anchorX} ${anchorY} H ${gutterBendX} V ${cardCenterY} H ${cardAttachX}`;
|
|
44000
44069
|
const revisionBarX = clampNumber(
|
|
@@ -44205,6 +44274,7 @@ ${currentText.slice(end)}`;
|
|
|
44205
44274
|
"data-docx-gutter-annotation-id": entry.annotation.id,
|
|
44206
44275
|
"data-docx-gutter-anchor-x": Math.round(entry.anchorX),
|
|
44207
44276
|
"data-docx-gutter-anchor-y": Math.round(entry.anchorY),
|
|
44277
|
+
"data-docx-gutter-connector-lane": entry.connectorLane,
|
|
44208
44278
|
ref: (element) => {
|
|
44209
44279
|
const elementKey = `${pageIndex}:${entry.annotation.id}`;
|
|
44210
44280
|
if (element) {
|