@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.js
CHANGED
|
@@ -4581,11 +4581,13 @@ var BASE_DOC_STYLE = {
|
|
|
4581
4581
|
transition: "box-shadow 0.2s ease"
|
|
4582
4582
|
};
|
|
4583
4583
|
var TRACKED_CHANGE_GUTTER_WIDTH_PX = 300;
|
|
4584
|
-
var TRACKED_CHANGE_GUTTER_CARD_LEFT_PX =
|
|
4584
|
+
var TRACKED_CHANGE_GUTTER_CARD_LEFT_PX = 48;
|
|
4585
4585
|
var TRACKED_CHANGE_GUTTER_CARD_RIGHT_PX = 12;
|
|
4586
4586
|
var TRACKED_CHANGE_GUTTER_CARD_GAP_PX = 4;
|
|
4587
4587
|
var TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX = 30;
|
|
4588
4588
|
var TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX = 8;
|
|
4589
|
+
var TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_GAP_PX = 7;
|
|
4590
|
+
var TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_COUNT = 5;
|
|
4589
4591
|
var INITIAL_PAGINATION_STABILITY_IDLE_MS = 240;
|
|
4590
4592
|
function scheduleDomWrite(callback) {
|
|
4591
4593
|
if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
|
|
@@ -18384,6 +18386,51 @@ function estimateTrackedChangeCardHeight(change) {
|
|
|
18384
18386
|
const lines = Math.min(2, Math.max(1, Math.ceil(snippet.length / 42)));
|
|
18385
18387
|
return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 22 + lines * 11);
|
|
18386
18388
|
}
|
|
18389
|
+
function assignGutterConnectorLanes(entries) {
|
|
18390
|
+
if (entries.length <= 1) {
|
|
18391
|
+
entries.forEach((entry) => {
|
|
18392
|
+
entry.connectorLane = 0;
|
|
18393
|
+
});
|
|
18394
|
+
return;
|
|
18395
|
+
}
|
|
18396
|
+
const intervalPaddingPx = 3;
|
|
18397
|
+
const laneEndY = Array.from(
|
|
18398
|
+
{ length: TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_COUNT },
|
|
18399
|
+
() => Number.NEGATIVE_INFINITY
|
|
18400
|
+
);
|
|
18401
|
+
const routedEntries = entries.map((entry, index) => {
|
|
18402
|
+
const cardCenterY = entry.top + entry.heightPx / 2;
|
|
18403
|
+
return {
|
|
18404
|
+
entry,
|
|
18405
|
+
index,
|
|
18406
|
+
startY: Math.min(entry.anchorY, cardCenterY) - intervalPaddingPx,
|
|
18407
|
+
endY: Math.max(entry.anchorY, cardCenterY) + intervalPaddingPx
|
|
18408
|
+
};
|
|
18409
|
+
}).sort((left, right) => {
|
|
18410
|
+
const startDelta = left.startY - right.startY;
|
|
18411
|
+
if (startDelta !== 0) {
|
|
18412
|
+
return startDelta;
|
|
18413
|
+
}
|
|
18414
|
+
const endDelta = left.endY - right.endY;
|
|
18415
|
+
if (endDelta !== 0) {
|
|
18416
|
+
return endDelta;
|
|
18417
|
+
}
|
|
18418
|
+
return left.index - right.index;
|
|
18419
|
+
});
|
|
18420
|
+
routedEntries.forEach((route) => {
|
|
18421
|
+
let laneIndex = laneEndY.findIndex(
|
|
18422
|
+
(laneEnd) => route.startY > laneEnd + intervalPaddingPx
|
|
18423
|
+
);
|
|
18424
|
+
if (laneIndex < 0) {
|
|
18425
|
+
laneIndex = laneEndY.reduce(
|
|
18426
|
+
(bestLane, laneEnd, index) => laneEnd < laneEndY[bestLane] ? index : bestLane,
|
|
18427
|
+
0
|
|
18428
|
+
);
|
|
18429
|
+
}
|
|
18430
|
+
route.entry.connectorLane = laneIndex;
|
|
18431
|
+
laneEndY[laneIndex] = Math.max(laneEndY[laneIndex], route.endY);
|
|
18432
|
+
});
|
|
18433
|
+
}
|
|
18387
18434
|
function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsByChangeId, pageWidthPx, pageHeightPx) {
|
|
18388
18435
|
if (annotations.length === 0) {
|
|
18389
18436
|
return [];
|
|
@@ -18419,7 +18466,8 @@ function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsB
|
|
|
18419
18466
|
Math.max(10, pageHeightPx - 10)
|
|
18420
18467
|
),
|
|
18421
18468
|
top: 0,
|
|
18422
|
-
heightPx
|
|
18469
|
+
heightPx,
|
|
18470
|
+
connectorLane: 0
|
|
18423
18471
|
};
|
|
18424
18472
|
});
|
|
18425
18473
|
withAnchors.sort((left, right) => {
|
|
@@ -18451,6 +18499,7 @@ function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsB
|
|
|
18451
18499
|
shiftedCursorTopPx = entry.top + entry.heightPx + TRACKED_CHANGE_GUTTER_CARD_GAP_PX;
|
|
18452
18500
|
});
|
|
18453
18501
|
}
|
|
18502
|
+
assignGutterConnectorLanes(withAnchors);
|
|
18454
18503
|
return withAnchors;
|
|
18455
18504
|
}
|
|
18456
18505
|
function sameParagraphLocation(a, b) {
|
|
@@ -41579,16 +41628,28 @@ ${currentText.slice(end)}`;
|
|
|
41579
41628
|
boxSizing: "border-box",
|
|
41580
41629
|
zIndex: 0
|
|
41581
41630
|
} : void 0;
|
|
41631
|
+
const pageTrackedChanges = positionedTrackedChangesByPage[pageIndex] ?? [];
|
|
41632
|
+
const pageGutterContentHeightPx = showTrackedChangeGutter && pageTrackedChanges.length > 0 ? pageTrackedChanges.reduce((maxBottomPx, entry) => {
|
|
41633
|
+
return Math.max(
|
|
41634
|
+
maxBottomPx,
|
|
41635
|
+
Math.ceil(
|
|
41636
|
+
entry.top + entry.heightPx + TRACKED_CHANGE_GUTTER_CARD_GAP_PX + 8
|
|
41637
|
+
)
|
|
41638
|
+
);
|
|
41639
|
+
}, pageLayout.pageHeightPx) : pageLayout.pageHeightPx;
|
|
41640
|
+
const pageVisualHeightPx = Math.max(
|
|
41641
|
+
pageLayout.pageHeightPx,
|
|
41642
|
+
pageGutterContentHeightPx
|
|
41643
|
+
);
|
|
41582
41644
|
const pageSurfaceStyle = {
|
|
41583
41645
|
...pageSurfaceBaseStyle,
|
|
41584
41646
|
width: pageLayout.pageWidthPx,
|
|
41585
|
-
height:
|
|
41586
|
-
minHeight:
|
|
41647
|
+
height: pageVisualHeightPx,
|
|
41648
|
+
minHeight: pageVisualHeightPx,
|
|
41587
41649
|
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
41588
41650
|
position: "relative",
|
|
41589
41651
|
...pageMarginPaddingStyle(pageLayout.marginsPx)
|
|
41590
41652
|
};
|
|
41591
|
-
const pageTrackedChanges = positionedTrackedChangesByPage[pageIndex] ?? [];
|
|
41592
41653
|
const pageCoverBackgroundImages = (() => {
|
|
41593
41654
|
const collected = /* @__PURE__ */ new Map();
|
|
41594
41655
|
const pageContentHeightPx = Math.max(
|
|
@@ -41636,7 +41697,7 @@ ${currentText.slice(end)}`;
|
|
|
41636
41697
|
style: {
|
|
41637
41698
|
position: "relative",
|
|
41638
41699
|
width: pageWrapperWidthPx,
|
|
41639
|
-
minHeight:
|
|
41700
|
+
minHeight: pageVisualHeightPx,
|
|
41640
41701
|
margin: "0 auto",
|
|
41641
41702
|
// Isolate per-page layout/style recalculation so scrolling and
|
|
41642
41703
|
// edits on one page don't force whole-document layout passes.
|
|
@@ -42685,7 +42746,7 @@ ${currentText.slice(end)}`;
|
|
|
42685
42746
|
left: pageLayout.pageWidthPx,
|
|
42686
42747
|
top: 0,
|
|
42687
42748
|
width: TRACKED_CHANGE_GUTTER_WIDTH_PX,
|
|
42688
|
-
height:
|
|
42749
|
+
height: pageVisualHeightPx,
|
|
42689
42750
|
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
42690
42751
|
pointerEvents: "none",
|
|
42691
42752
|
overflow: "visible"
|
|
@@ -42708,8 +42769,8 @@ ${currentText.slice(end)}`;
|
|
|
42708
42769
|
"svg",
|
|
42709
42770
|
{
|
|
42710
42771
|
width: pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX,
|
|
42711
|
-
height:
|
|
42712
|
-
viewBox: `0 0 ${pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX} ${
|
|
42772
|
+
height: pageVisualHeightPx,
|
|
42773
|
+
viewBox: `0 0 ${pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_WIDTH_PX} ${pageVisualHeightPx}`,
|
|
42713
42774
|
style: {
|
|
42714
42775
|
position: "absolute",
|
|
42715
42776
|
top: 0,
|
|
@@ -42737,11 +42798,19 @@ ${currentText.slice(end)}`;
|
|
|
42737
42798
|
Math.max(8, pageLayout.pageWidthPx - 8)
|
|
42738
42799
|
);
|
|
42739
42800
|
const cardAttachX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_CARD_LEFT_PX;
|
|
42740
|
-
const
|
|
42801
|
+
const maxConnectorLaneOffset = Math.max(
|
|
42802
|
+
TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX,
|
|
42803
|
+
TRACKED_CHANGE_GUTTER_CARD_LEFT_PX - 6
|
|
42804
|
+
);
|
|
42805
|
+
const connectorLaneOffset = Math.min(
|
|
42806
|
+
TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX + Math.max(0, entry.connectorLane) * TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_GAP_PX,
|
|
42807
|
+
maxConnectorLaneOffset
|
|
42808
|
+
);
|
|
42809
|
+
const gutterBendX = pageLayout.pageWidthPx + connectorLaneOffset;
|
|
42741
42810
|
const cardCenterY = clampNumber(
|
|
42742
42811
|
Math.round(entry.top + entry.heightPx / 2),
|
|
42743
42812
|
8,
|
|
42744
|
-
Math.max(8,
|
|
42813
|
+
Math.max(8, pageVisualHeightPx - 8)
|
|
42745
42814
|
);
|
|
42746
42815
|
const connectorPath = Math.abs(cardCenterY - anchorY) <= 2 ? `M ${anchorX} ${anchorY} H ${cardAttachX}` : `M ${anchorX} ${anchorY} H ${gutterBendX} V ${cardCenterY} H ${cardAttachX}`;
|
|
42747
42816
|
const revisionBarX = clampNumber(
|
|
@@ -42952,6 +43021,7 @@ ${currentText.slice(end)}`;
|
|
|
42952
43021
|
"data-docx-gutter-annotation-id": entry.annotation.id,
|
|
42953
43022
|
"data-docx-gutter-anchor-x": Math.round(entry.anchorX),
|
|
42954
43023
|
"data-docx-gutter-anchor-y": Math.round(entry.anchorY),
|
|
43024
|
+
"data-docx-gutter-connector-lane": entry.connectorLane,
|
|
42955
43025
|
ref: (element) => {
|
|
42956
43026
|
const elementKey = `${pageIndex}:${entry.annotation.id}`;
|
|
42957
43027
|
if (element) {
|