@extend-ai/react-docx 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -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 = 14;
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) {
@@ -43990,7 +44039,15 @@ ${currentText.slice(end)}`;
43990
44039
  Math.max(8, pageLayout.pageWidthPx - 8)
43991
44040
  );
43992
44041
  const cardAttachX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_CARD_LEFT_PX;
43993
- const gutterBendX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX;
44042
+ const maxConnectorLaneOffset = Math.max(
44043
+ TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX,
44044
+ TRACKED_CHANGE_GUTTER_CARD_LEFT_PX - 6
44045
+ );
44046
+ const connectorLaneOffset = Math.min(
44047
+ TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX + Math.max(0, entry.connectorLane) * TRACKED_CHANGE_GUTTER_CONNECTOR_LANE_GAP_PX,
44048
+ maxConnectorLaneOffset
44049
+ );
44050
+ const gutterBendX = pageLayout.pageWidthPx + connectorLaneOffset;
43994
44051
  const cardCenterY = clampNumber(
43995
44052
  Math.round(entry.top + entry.heightPx / 2),
43996
44053
  8,
@@ -44205,6 +44262,7 @@ ${currentText.slice(end)}`;
44205
44262
  "data-docx-gutter-annotation-id": entry.annotation.id,
44206
44263
  "data-docx-gutter-anchor-x": Math.round(entry.anchorX),
44207
44264
  "data-docx-gutter-anchor-y": Math.round(entry.anchorY),
44265
+ "data-docx-gutter-connector-lane": entry.connectorLane,
44208
44266
  ref: (element) => {
44209
44267
  const elementKey = `${pageIndex}:${entry.annotation.id}`;
44210
44268
  if (element) {