@extend-ai/react-docx 0.7.1 → 0.7.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/dist/index.cjs CHANGED
@@ -5834,10 +5834,11 @@ 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 = 28;
5838
- var TRACKED_CHANGE_GUTTER_CARD_RIGHT_PX = 10;
5839
- var TRACKED_CHANGE_GUTTER_CARD_GAP_PX = 8;
5840
- var TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX = 52;
5837
+ var TRACKED_CHANGE_GUTTER_CARD_LEFT_PX = 14;
5838
+ var TRACKED_CHANGE_GUTTER_CARD_RIGHT_PX = 12;
5839
+ var TRACKED_CHANGE_GUTTER_CARD_GAP_PX = 4;
5840
+ var TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX = 30;
5841
+ var TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX = 8;
5841
5842
  var INITIAL_PAGINATION_STABILITY_IDLE_MS = 240;
5842
5843
  function scheduleDomWrite(callback) {
5843
5844
  if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
@@ -14250,9 +14251,10 @@ function trackedInlineStyle(baseStyle, change) {
14250
14251
  return baseStyle;
14251
14252
  }
14252
14253
  if (change.kind === "insertion" || change.kind === "move-to") {
14254
+ const accentColor = change.kind === "move-to" ? "#70ad47" : "#dc2626";
14253
14255
  return {
14254
14256
  ...baseStyle,
14255
- color: "#2563eb",
14257
+ color: accentColor,
14256
14258
  textDecoration: mergeTextDecorations(
14257
14259
  baseStyle.textDecoration,
14258
14260
  "underline"
@@ -15877,11 +15879,22 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
15877
15879
  if (!commentIds || commentIds.length === 0) {
15878
15880
  return void 0;
15879
15881
  }
15880
- const accent = commentAccentColor(documentTheme);
15881
- return {
15882
- backgroundColor: documentTheme === "dark" ? "rgba(251, 191, 36, 0.24)" : "rgba(251, 191, 36, 0.3)",
15883
- borderBottom: `2px solid ${accent}`
15884
- };
15882
+ return commentHighlightStyle(documentTheme, commentIds[0]);
15883
+ };
15884
+ const currentAnnotationAttributes = (trackedInlineChange) => {
15885
+ const attributes = {};
15886
+ if (trackedInlineChange) {
15887
+ attributes["data-docx-tracked-change"] = trackedInlineChange.kind;
15888
+ attributes["data-docx-tracked-change-id"] = trackedInlineChange.id;
15889
+ }
15890
+ const commentIds = commentMarkup?.commentIdsByVisibleChildIndex[trackedVisibleChildCursor];
15891
+ if (commentIds && commentIds.length > 0) {
15892
+ attributes["data-docx-comment-ids"] = commentIds.join(" ");
15893
+ if (commentIds.length === 1) {
15894
+ attributes["data-docx-comment-id"] = String(commentIds[0]);
15895
+ }
15896
+ }
15897
+ return attributes;
15885
15898
  };
15886
15899
  const consumeTrackedVisibleChild = (child) => {
15887
15900
  if (!trackedMarkup && !commentMarkup) {
@@ -15915,11 +15928,11 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
15915
15928
  fallbackTabWidthPx,
15916
15929
  checkboxChoiceRow
15917
15930
  );
15918
- const appendPlainTextWithSoftBreakControl = (target, keySeed, text, style, measureStyle) => {
15931
+ const appendPlainTextWithSoftBreakControl = (target, keySeed, text, style, measureStyle, spanAttributes) => {
15919
15932
  const shouldControlSoftBreakStretch = paragraph.style?.align === "justify" && text.includes("\n");
15920
15933
  if (!shouldControlSoftBreakStretch) {
15921
15934
  target.push(
15922
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style, children: text }, keySeed)
15935
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ...spanAttributes, style, children: text }, keySeed)
15923
15936
  );
15924
15937
  trackTextAdvance(text, measureStyle);
15925
15938
  return;
@@ -15935,6 +15948,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
15935
15948
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
15936
15949
  "span",
15937
15950
  {
15951
+ ...spanAttributes,
15938
15952
  style: isLastSegment ? {
15939
15953
  ...style,
15940
15954
  display: "inline-block",
@@ -16085,6 +16099,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16085
16099
  " "
16086
16100
  );
16087
16101
  const text = textOverride ?? textValue;
16102
+ const annotationAttributes2 = currentAnnotationAttributes(trackedInlineChange);
16088
16103
  if (child.link) {
16089
16104
  const linkHref = child.link;
16090
16105
  const isInternalLink = linkHref.startsWith("#");
@@ -16092,6 +16107,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16092
16107
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
16093
16108
  "a",
16094
16109
  {
16110
+ ...annotationAttributes2,
16095
16111
  href: linkHref,
16096
16112
  target: isInternalLink ? void 0 : "_blank",
16097
16113
  rel: isInternalLink ? void 0 : "noreferrer noopener",
@@ -16128,12 +16144,20 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16128
16144
  };
16129
16145
  if (text === " " && !useTabLeaderLayout && !useAnchoredTabLayout) {
16130
16146
  target.push(
16131
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: tabTextStyle(child.style, trackedStyle), children: "\xA0" }, key)
16147
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
16148
+ "span",
16149
+ {
16150
+ ...annotationAttributes2,
16151
+ style: tabTextStyle(child.style, trackedStyle),
16152
+ children: "\xA0"
16153
+ },
16154
+ key
16155
+ )
16132
16156
  );
16133
16157
  return;
16134
16158
  }
16135
16159
  target.push(
16136
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: trackedStyle, children: text }, key)
16160
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ...annotationAttributes2, style: trackedStyle, children: text }, key)
16137
16161
  );
16138
16162
  trackTextAdvance(text, child.style);
16139
16163
  return;
@@ -16202,7 +16226,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16202
16226
  const sectionImageCursor = sectionImageLocation && !sectionImageInteraction?.isReadOnly && !behavesAsDecorativeBehindTextBackground && (isWrappedFloatingImage || isAbsoluteFloatingImage) ? "move" : void 0;
16203
16227
  const isCenteredStandaloneInlineImage = !isWrappedFloatingImage && !isAbsoluteFloatingImage && paragraph.style?.align === "center" && paragraph.children.length === 1 && paragraph.children[0]?.type === "image";
16204
16228
  const trackedImageStyle = trackedInlineChange?.kind === "insertion" || trackedInlineChange?.kind === "move-to" ? {
16205
- outline: "2px solid rgba(37, 99, 235, 0.35)",
16229
+ outline: trackedInlineChange.kind === "move-to" ? "2px solid rgba(112, 173, 71, 0.35)" : "2px solid rgba(220, 38, 38, 0.3)",
16206
16230
  outlineOffset: 1
16207
16231
  } : void 0;
16208
16232
  const renderableImageSrc = syntheticTextBoxSvg(
@@ -16388,6 +16412,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16388
16412
  ),
16389
16413
  ...currentCommentHighlightStyle()
16390
16414
  };
16415
+ const annotationAttributes = currentAnnotationAttributes(trackedInlineChange);
16391
16416
  const noteLabel = noteMarkerLabel(
16392
16417
  child.noteReference,
16393
16418
  safeNoteMarkerIndexes.footnote,
@@ -16398,6 +16423,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16398
16423
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
16399
16424
  "span",
16400
16425
  {
16426
+ ...annotationAttributes,
16401
16427
  style: {
16402
16428
  ...textStyle,
16403
16429
  verticalAlign: "super",
@@ -16413,7 +16439,15 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16413
16439
  }
16414
16440
  if ((textOverride ?? child.text) === " " && !useTabLeaderLayout && !useAnchoredTabLayout) {
16415
16441
  target.push(
16416
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: tabTextStyle(child.style, textStyle), children: "\xA0" }, key)
16442
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
16443
+ "span",
16444
+ {
16445
+ ...annotationAttributes,
16446
+ style: tabTextStyle(child.style, textStyle),
16447
+ children: "\xA0"
16448
+ },
16449
+ key
16450
+ )
16417
16451
  );
16418
16452
  return;
16419
16453
  }
@@ -16424,6 +16458,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16424
16458
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
16425
16459
  "a",
16426
16460
  {
16461
+ ...annotationAttributes,
16427
16462
  href: linkHref,
16428
16463
  target: isInternalLink ? void 0 : "_blank",
16429
16464
  rel: isInternalLink ? void 0 : "noreferrer noopener",
@@ -16456,7 +16491,8 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
16456
16491
  key,
16457
16492
  textOverride ?? child.text,
16458
16493
  textStyle,
16459
- child.style
16494
+ child.style,
16495
+ annotationAttributes
16460
16496
  );
16461
16497
  };
16462
16498
  const anchoredTabZoneStyle = {
@@ -19167,6 +19203,7 @@ function collectTrackedChangesFromModel(model) {
19167
19203
  trackedMarkup.changes.forEach((change, changeIndex) => {
19168
19204
  trackedChanges.push({
19169
19205
  id: `${paragraphLocationKey(location)}:${change.id}:${changeIndex}`,
19206
+ inlineAnchorId: change.id,
19170
19207
  kind: change.kind,
19171
19208
  author: change.author,
19172
19209
  date: change.date,
@@ -19345,13 +19382,42 @@ function collectCommentsFromModel(model) {
19345
19382
  });
19346
19383
  return comments;
19347
19384
  }
19348
- function commentAccentColor(documentTheme) {
19349
- return documentTheme === "dark" ? "#fbbf24" : "#d97706";
19385
+ function hexColorWithAlpha(color, alpha) {
19386
+ const normalized = color.trim().replace(/^#/, "");
19387
+ if (!/^[\da-f]{6}$/i.test(normalized)) {
19388
+ return color;
19389
+ }
19390
+ const red = Number.parseInt(normalized.slice(0, 2), 16);
19391
+ const green = Number.parseInt(normalized.slice(2, 4), 16);
19392
+ const blue = Number.parseInt(normalized.slice(4, 6), 16);
19393
+ return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
19394
+ }
19395
+ function commentAccentColor(documentTheme, commentId) {
19396
+ const lightPalette = ["#5b9bd5", "#d65f5f", "#8f6ac8", "#70ad47", "#d9872b"];
19397
+ const darkPalette = ["#7dd3fc", "#fca5a5", "#c4b5fd", "#86efac", "#fdba74"];
19398
+ if (Number.isFinite(commentId)) {
19399
+ const palette = documentTheme === "dark" ? darkPalette : lightPalette;
19400
+ return palette[Math.abs(Math.round(commentId)) % palette.length];
19401
+ }
19402
+ return documentTheme === "dark" ? darkPalette[0] : lightPalette[0];
19403
+ }
19404
+ function commentHighlightStyle(documentTheme, commentId) {
19405
+ const accent = commentAccentColor(documentTheme, commentId);
19406
+ return {
19407
+ backgroundColor: hexColorWithAlpha(
19408
+ accent,
19409
+ documentTheme === "dark" ? 0.3 : 0.22
19410
+ ),
19411
+ boxShadow: `inset 0 -1px 0 ${hexColorWithAlpha(
19412
+ accent,
19413
+ documentTheme === "dark" ? 0.7 : 0.48
19414
+ )}`
19415
+ };
19350
19416
  }
19351
19417
  function estimateCommentCardHeight(comment) {
19352
19418
  const snippet = comment.text || "Comment";
19353
- const lines = Math.max(1, Math.ceil(snippet.length / 30));
19354
- return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 34 + lines * 14);
19419
+ const lines = Math.min(2, Math.max(1, Math.ceil(snippet.length / 42)));
19420
+ return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 24 + lines * 11);
19355
19421
  }
19356
19422
  function trackedChangeKindLabel(kind) {
19357
19423
  switch (kind) {
@@ -19373,16 +19439,16 @@ function trackedChangeKindLabel(kind) {
19373
19439
  }
19374
19440
  function trackedChangeAccentColor(kind, documentTheme) {
19375
19441
  const palette = documentTheme === "dark" ? {
19376
- insertion: "#60a5fa",
19442
+ insertion: "#f87171",
19377
19443
  deletion: "#f87171",
19378
- moveFrom: "#fbbf24",
19379
- moveTo: "#22d3ee",
19444
+ moveFrom: "#86efac",
19445
+ moveTo: "#86efac",
19380
19446
  format: "#c084fc"
19381
19447
  } : {
19382
- insertion: "#2563eb",
19448
+ insertion: "#dc2626",
19383
19449
  deletion: "#dc2626",
19384
- moveFrom: "#d97706",
19385
- moveTo: "#0891b2",
19450
+ moveFrom: "#70ad47",
19451
+ moveTo: "#70ad47",
19386
19452
  format: "#7c3aed"
19387
19453
  };
19388
19454
  switch (kind) {
@@ -19401,6 +19467,9 @@ function trackedChangeAccentColor(kind, documentTheme) {
19401
19467
  return palette.format;
19402
19468
  }
19403
19469
  }
19470
+ function trackedChangeUsesGutterBalloon(change) {
19471
+ return change.kind !== "insertion" && change.kind !== "move-to";
19472
+ }
19404
19473
  function gutterAnnotationSortTuple(location) {
19405
19474
  if (location.kind === "paragraph") {
19406
19475
  return [location.nodeIndex, 0, 0, 0];
@@ -19481,10 +19550,92 @@ function elementRectWithinContainer(element, container) {
19481
19550
  height: elementRect.height / scaleY
19482
19551
  };
19483
19552
  }
19553
+ function findFirstElementWithSpaceSeparatedDataValue(rootElement, attributeName, value) {
19554
+ const candidateElements = [];
19555
+ if (rootElement.hasAttribute(attributeName)) {
19556
+ candidateElements.push(rootElement);
19557
+ }
19558
+ candidateElements.push(
19559
+ ...rootElement.querySelectorAll(
19560
+ `[${attributeName}]`
19561
+ )
19562
+ );
19563
+ for (const candidate of candidateElements) {
19564
+ const rawValue = candidate.getAttribute(attributeName);
19565
+ if (!rawValue) {
19566
+ continue;
19567
+ }
19568
+ if (rawValue.split(/\s+/).includes(value)) {
19569
+ return candidate;
19570
+ }
19571
+ }
19572
+ return void 0;
19573
+ }
19574
+ function findGutterAnnotationScopeElementInPage(pageElement, annotation) {
19575
+ return findTrackedChangeAnchorElementInPage(pageElement, annotation.location);
19576
+ }
19577
+ function findGutterAnnotationDataAnchorInPage(pageElement, annotation, attributeName, value) {
19578
+ const scopedRoot = findGutterAnnotationScopeElementInPage(
19579
+ pageElement,
19580
+ annotation
19581
+ );
19582
+ if (scopedRoot) {
19583
+ const scopedAnchor = findFirstElementWithSpaceSeparatedDataValue(
19584
+ scopedRoot,
19585
+ attributeName,
19586
+ value
19587
+ );
19588
+ if (scopedAnchor) {
19589
+ return scopedAnchor;
19590
+ }
19591
+ }
19592
+ return findFirstElementWithSpaceSeparatedDataValue(
19593
+ pageElement,
19594
+ attributeName,
19595
+ value
19596
+ );
19597
+ }
19598
+ function findGutterAnnotationAnchorElementInPage(pageElement, annotation) {
19599
+ if (annotation.trackedChange) {
19600
+ const trackedAnchor = findGutterAnnotationDataAnchorInPage(
19601
+ pageElement,
19602
+ annotation,
19603
+ "data-docx-tracked-change-id",
19604
+ annotation.trackedChange.id
19605
+ );
19606
+ if (trackedAnchor) {
19607
+ return trackedAnchor;
19608
+ }
19609
+ const inlineAnchorId = annotation.trackedChange.inlineAnchorId;
19610
+ if (inlineAnchorId && inlineAnchorId !== annotation.trackedChange.id) {
19611
+ const inlineTrackedAnchor = findGutterAnnotationDataAnchorInPage(
19612
+ pageElement,
19613
+ annotation,
19614
+ "data-docx-tracked-change-id",
19615
+ inlineAnchorId
19616
+ );
19617
+ if (inlineTrackedAnchor) {
19618
+ return inlineTrackedAnchor;
19619
+ }
19620
+ }
19621
+ }
19622
+ if (annotation.comment) {
19623
+ const commentAnchor = findGutterAnnotationDataAnchorInPage(
19624
+ pageElement,
19625
+ annotation,
19626
+ "data-docx-comment-ids",
19627
+ String(annotation.comment.commentId)
19628
+ );
19629
+ if (commentAnchor) {
19630
+ return commentAnchor;
19631
+ }
19632
+ }
19633
+ return findTrackedChangeAnchorElementInPage(pageElement, annotation.location);
19634
+ }
19484
19635
  function estimateTrackedChangeCardHeight(change) {
19485
19636
  const snippet = normalizeTrackedChangeSnippet(change.text) ?? trackedChangeKindLabel(change.kind);
19486
- const lines = Math.max(1, Math.ceil(snippet.length / 30));
19487
- return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 34 + lines * 14);
19637
+ const lines = Math.min(2, Math.max(1, Math.ceil(snippet.length / 42)));
19638
+ return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 22 + lines * 11);
19488
19639
  }
19489
19640
  function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsByChangeId, pageWidthPx, pageHeightPx) {
19490
19641
  if (annotations.length === 0) {
@@ -19524,11 +19675,21 @@ function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsB
19524
19675
  heightPx
19525
19676
  };
19526
19677
  });
19527
- withAnchors.sort((left, right) => left.anchorY - right.anchorY);
19678
+ withAnchors.sort((left, right) => {
19679
+ const yDelta = left.anchorY - right.anchorY;
19680
+ if (Math.abs(yDelta) > 2) {
19681
+ return yDelta;
19682
+ }
19683
+ const xDelta = left.anchorX - right.anchorX;
19684
+ if (xDelta !== 0) {
19685
+ return xDelta;
19686
+ }
19687
+ return left.annotation.id.localeCompare(right.annotation.id);
19688
+ });
19528
19689
  const minTopPx = 8;
19529
19690
  let cursorTopPx = minTopPx;
19530
19691
  withAnchors.forEach((entry) => {
19531
- const desiredTop = entry.anchorY - Math.round(entry.heightPx / 2);
19692
+ const desiredTop = entry.anchorY - 8;
19532
19693
  entry.top = Math.max(desiredTop, cursorTopPx);
19533
19694
  cursorTopPx = entry.top + entry.heightPx + TRACKED_CHANGE_GUTTER_CARD_GAP_PX;
19534
19695
  });
@@ -28711,6 +28872,9 @@ function DocxEditorViewer({
28711
28872
  };
28712
28873
  if (trackedChangesEnabled) {
28713
28874
  editor.trackedChanges.forEach((change) => {
28875
+ if (!trackedChangeUsesGutterBalloon(change)) {
28876
+ return;
28877
+ }
28714
28878
  placeAnnotation({
28715
28879
  id: change.id,
28716
28880
  location: change.location,
@@ -28761,45 +28925,45 @@ function DocxEditorViewer({
28761
28925
  );
28762
28926
  return;
28763
28927
  }
28764
- const nextAnchorMaps = trackedChangesByPage.map((annotations, pageIndex) => {
28765
- const pageElement = pageElementsRef.current.get(pageIndex);
28766
- const anchorsByChangeId = /* @__PURE__ */ new Map();
28767
- if (!pageElement || annotations.length === 0) {
28928
+ const nextAnchorMaps = trackedChangesByPage.map(
28929
+ (annotations, pageIndex) => {
28930
+ const pageElement = pageElementsRef.current.get(pageIndex);
28931
+ const anchorsByChangeId = /* @__PURE__ */ new Map();
28932
+ if (!pageElement || annotations.length === 0) {
28933
+ return anchorsByChangeId;
28934
+ }
28935
+ const pageHeightPx = Math.max(1, pageElement.offsetHeight);
28936
+ const pageWidthPx = Math.max(1, pageElement.offsetWidth);
28937
+ annotations.forEach((annotation) => {
28938
+ const anchorElement = findGutterAnnotationAnchorElementInPage(
28939
+ pageElement,
28940
+ annotation
28941
+ );
28942
+ if (!anchorElement) {
28943
+ return;
28944
+ }
28945
+ const anchorRect = elementRectWithinContainer(
28946
+ anchorElement,
28947
+ pageElement
28948
+ );
28949
+ if (!anchorRect) {
28950
+ return;
28951
+ }
28952
+ const anchorY = clampNumber(
28953
+ Math.round(anchorRect.top + anchorRect.height / 2),
28954
+ 10,
28955
+ Math.max(10, pageHeightPx - 10)
28956
+ );
28957
+ const anchorX = clampNumber(
28958
+ Math.round(anchorRect.right),
28959
+ 10,
28960
+ Math.max(10, pageWidthPx - 10)
28961
+ );
28962
+ anchorsByChangeId.set(annotation.id, { x: anchorX, y: anchorY });
28963
+ });
28768
28964
  return anchorsByChangeId;
28769
28965
  }
28770
- const pageHeightPx = Math.max(1, pageElement.offsetHeight);
28771
- const pageWidthPx = Math.max(1, pageElement.offsetWidth);
28772
- annotations.forEach((annotation) => {
28773
- const anchorElement = findTrackedChangeAnchorElementInPage(
28774
- pageElement,
28775
- annotation.location
28776
- );
28777
- if (!anchorElement) {
28778
- return;
28779
- }
28780
- const anchorRect = elementRectWithinContainer(
28781
- anchorElement,
28782
- pageElement
28783
- );
28784
- if (!anchorRect) {
28785
- return;
28786
- }
28787
- const anchorY = clampNumber(
28788
- Math.round(anchorRect.top + anchorRect.height / 2),
28789
- 10,
28790
- Math.max(10, pageHeightPx - 10)
28791
- );
28792
- const anchorX = clampNumber(
28793
- Math.round(
28794
- anchorRect.left + Math.min(24, Math.max(8, anchorRect.width * 0.2))
28795
- ),
28796
- 10,
28797
- Math.max(10, pageWidthPx - 10)
28798
- );
28799
- anchorsByChangeId.set(annotation.id, { x: anchorX, y: anchorY });
28800
- });
28801
- return anchorsByChangeId;
28802
- });
28966
+ );
28803
28967
  setTrackedChangeAnchorByPage(nextAnchorMaps);
28804
28968
  }, [
28805
28969
  trackedChangesByPage,
@@ -42650,6 +42814,7 @@ ${currentText.slice(end)}`;
42650
42814
  });
42651
42815
  const headerFooterBodyDimmed = pageHeaderFooterEditActive;
42652
42816
  const documentPageBackgroundColor = editor.model.metadata.documentBackgroundColor;
42817
+ const resolvedPageSurfaceBackgroundColor = pageBackgroundColor ?? documentPageBackgroundColor ?? pageSurfaceBaseStyle.backgroundColor;
42653
42818
  const pageBorders = parseSectionPageBorders(
42654
42819
  pageInfo?.section.sectionPropertiesXml ?? editor.model.metadata.sectionPropertiesXml
42655
42820
  );
@@ -42672,7 +42837,7 @@ ${currentText.slice(end)}`;
42672
42837
  width: pageLayout.pageWidthPx,
42673
42838
  height: pageLayout.pageHeightPx,
42674
42839
  minHeight: pageLayout.pageHeightPx,
42675
- backgroundColor: pageBackgroundColor ?? documentPageBackgroundColor ?? pageSurfaceBaseStyle.backgroundColor,
42840
+ backgroundColor: resolvedPageSurfaceBackgroundColor,
42676
42841
  position: "relative",
42677
42842
  ...pageMarginPaddingStyle(pageLayout.marginsPx)
42678
42843
  };
@@ -43774,6 +43939,7 @@ ${currentText.slice(end)}`;
43774
43939
  top: 0,
43775
43940
  width: TRACKED_CHANGE_GUTTER_WIDTH_PX,
43776
43941
  height: pageLayout.pageHeightPx,
43942
+ backgroundColor: resolvedPageSurfaceBackgroundColor,
43777
43943
  pointerEvents: "none",
43778
43944
  overflow: "visible"
43779
43945
  },
@@ -43804,14 +43970,14 @@ ${currentText.slice(end)}`;
43804
43970
  overflow: "visible"
43805
43971
  },
43806
43972
  children: pageTrackedChanges.map((entry) => {
43807
- const accentColor = entry.annotation.trackedChange ? trackedChangeAccentColor(
43808
- entry.annotation.trackedChange.kind,
43973
+ const trackedChange = entry.annotation.trackedChange;
43974
+ const comment = entry.annotation.comment;
43975
+ const accentColor = trackedChange ? trackedChangeAccentColor(
43976
+ trackedChange.kind,
43809
43977
  editor.documentTheme
43810
- ) : commentAccentColor(editor.documentTheme);
43811
- const cardCenterY = clampNumber(
43812
- Math.round(entry.top + entry.heightPx / 2),
43813
- 8,
43814
- Math.max(8, pageLayout.pageHeightPx - 8)
43978
+ ) : commentAccentColor(
43979
+ editor.documentTheme,
43980
+ comment?.commentId
43815
43981
  );
43816
43982
  const anchorY = clampNumber(
43817
43983
  Math.round(entry.anchorY),
@@ -43823,48 +43989,50 @@ ${currentText.slice(end)}`;
43823
43989
  8,
43824
43990
  Math.max(8, pageLayout.pageWidthPx - 8)
43825
43991
  );
43826
- const cardLeadX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_CARD_LEFT_PX - 6;
43827
- const bendX = clampNumber(
43828
- Math.round((anchorX + cardLeadX) / 2),
43829
- anchorX + 8,
43830
- Math.max(anchorX + 8, cardLeadX - 8)
43992
+ const cardAttachX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_CARD_LEFT_PX;
43993
+ const gutterBendX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX;
43994
+ const cardCenterY = clampNumber(
43995
+ Math.round(entry.top + entry.heightPx / 2),
43996
+ 8,
43997
+ Math.max(8, pageLayout.pageHeightPx - 8)
43998
+ );
43999
+ const connectorPath = Math.abs(cardCenterY - anchorY) <= 2 ? `M ${anchorX} ${anchorY} H ${cardAttachX}` : `M ${anchorX} ${anchorY} H ${gutterBendX} V ${cardCenterY} H ${cardAttachX}`;
44000
+ const revisionBarX = clampNumber(
44001
+ Math.round(pageLayout.marginsPx.left - 20),
44002
+ 8,
44003
+ Math.max(8, pageLayout.pageWidthPx - 8)
43831
44004
  );
43832
44005
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
43833
44006
  "g",
43834
44007
  {
43835
44008
  children: [
44009
+ trackedChange ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44010
+ "line",
44011
+ {
44012
+ x1: revisionBarX,
44013
+ y1: Math.max(8, anchorY - 16),
44014
+ x2: revisionBarX,
44015
+ y2: Math.min(
44016
+ pageLayout.pageHeightPx - 8,
44017
+ anchorY + 16
44018
+ ),
44019
+ stroke: editor.documentTheme === "dark" ? "#94a3b8" : "#9ca3af",
44020
+ strokeWidth: 1.25,
44021
+ strokeLinecap: "square"
44022
+ }
44023
+ ) : null,
43836
44024
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
43837
44025
  "path",
43838
44026
  {
43839
- d: `M ${anchorX} ${anchorY} L ${bendX} ${anchorY} L ${cardLeadX} ${cardCenterY}`,
44027
+ d: connectorPath,
43840
44028
  stroke: accentColor,
43841
- strokeWidth: 1.75,
43842
- strokeOpacity: 1,
43843
- strokeDasharray: "5 4",
44029
+ strokeWidth: 1.15,
44030
+ strokeOpacity: 0.78,
44031
+ strokeDasharray: "2 3",
43844
44032
  strokeLinejoin: "round",
43845
44033
  strokeLinecap: "round",
43846
44034
  fill: "none"
43847
44035
  }
43848
- ),
43849
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
43850
- "circle",
43851
- {
43852
- cx: anchorX,
43853
- cy: anchorY,
43854
- r: 2.2,
43855
- fill: accentColor,
43856
- stroke: editor.documentTheme === "dark" ? "#020617" : "#ffffff",
43857
- strokeWidth: 1
43858
- }
43859
- ),
43860
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
43861
- "circle",
43862
- {
43863
- cx: cardLeadX,
43864
- cy: cardCenterY,
43865
- r: 1.8,
43866
- fill: accentColor
43867
- }
43868
44036
  )
43869
44037
  ]
43870
44038
  },
@@ -43895,7 +44063,10 @@ ${currentText.slice(end)}`;
43895
44063
  const accentColor = trackedChange ? trackedChangeAccentColor(
43896
44064
  trackedChange.kind,
43897
44065
  editor.documentTheme
43898
- ) : commentAccentColor(editor.documentTheme);
44066
+ ) : commentAccentColor(
44067
+ editor.documentTheme,
44068
+ comment?.commentId
44069
+ );
43899
44070
  const formattedDate = formatTrackedChangeDate(
43900
44071
  trackedChange?.date ?? comment?.date
43901
44072
  );
@@ -43922,15 +44093,15 @@ ${currentText.slice(end)}`;
43922
44093
  {
43923
44094
  style: {
43924
44095
  ...cardStyle,
43925
- padding: "6px 8px",
44096
+ padding: "4px 6px",
43926
44097
  boxSizing: "border-box",
43927
- borderLeft: `2px solid ${accentColor}`,
43928
- borderTop: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.28)" : "rgba(15, 23, 42, 0.12)"}`,
43929
- borderRight: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.28)" : "rgba(15, 23, 42, 0.12)"}`,
43930
- borderBottom: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.28)" : "rgba(15, 23, 42, 0.12)"}`,
43931
- backgroundColor: editor.documentTheme === "dark" ? "rgba(2, 6, 23, 0.96)" : "rgba(255, 255, 255, 0.96)",
44098
+ borderLeft: `1.5px solid ${accentColor}`,
44099
+ borderTop: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.18)" : "rgba(15, 23, 42, 0.08)"}`,
44100
+ borderRight: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.18)" : "rgba(15, 23, 42, 0.08)"}`,
44101
+ borderBottom: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.18)" : "rgba(15, 23, 42, 0.08)"}`,
44102
+ backgroundColor: editor.documentTheme === "dark" ? "rgba(15, 23, 42, 0.92)" : "rgba(255, 255, 255, 0.72)",
43932
44103
  color: editor.documentTheme === "dark" ? "#f3f4f6" : "#111827",
43933
- boxShadow: editor.documentTheme === "dark" ? "0 2px 6px rgba(2, 6, 23, 0.55)" : "0 1px 2px rgba(15, 23, 42, 0.14)"
44104
+ boxShadow: editor.documentTheme === "dark" ? "0 1px 2px rgba(2, 6, 23, 0.45)" : "0 1px 1px rgba(15, 23, 42, 0.08)"
43934
44105
  },
43935
44106
  children: [
43936
44107
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -43948,9 +44119,9 @@ ${currentText.slice(end)}`;
43948
44119
  {
43949
44120
  style: {
43950
44121
  margin: 0,
43951
- fontSize: 12,
44122
+ fontSize: 10,
43952
44123
  fontWeight: 700,
43953
- lineHeight: 1.25
44124
+ lineHeight: 1.2
43954
44125
  },
43955
44126
  children: (trackedChange?.author ?? comment?.author)?.trim() || "Unknown author"
43956
44127
  }
@@ -43960,8 +44131,8 @@ ${currentText.slice(end)}`;
43960
44131
  {
43961
44132
  style: {
43962
44133
  margin: 0,
43963
- fontSize: 11,
43964
- lineHeight: 1.2,
44134
+ fontSize: 9,
44135
+ lineHeight: 1.15,
43965
44136
  color: editor.documentTheme === "dark" ? "#94a3b8" : "#6b7280",
43966
44137
  whiteSpace: "nowrap"
43967
44138
  },
@@ -43976,8 +44147,8 @@ ${currentText.slice(end)}`;
43976
44147
  {
43977
44148
  style: {
43978
44149
  margin: "2px 0 0",
43979
- fontSize: 11,
43980
- lineHeight: 1.3,
44150
+ fontSize: 9,
44151
+ lineHeight: 1.25,
43981
44152
  fontStyle: "italic",
43982
44153
  color: editor.documentTheme === "dark" ? "#94a3b8" : "#6b7280"
43983
44154
  },
@@ -43993,8 +44164,8 @@ ${currentText.slice(end)}`;
43993
44164
  {
43994
44165
  style: {
43995
44166
  margin: "2px 0 0",
43996
- fontSize: 12,
43997
- lineHeight: 1.35
44167
+ fontSize: 10,
44168
+ lineHeight: 1.25
43998
44169
  },
43999
44170
  children: [
44000
44171
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
@@ -44031,6 +44202,9 @@ ${currentText.slice(end)}`;
44031
44202
  "div",
44032
44203
  {
44033
44204
  "data-docx-gutter-annotation": trackedChange ? "tracked-change" : "comment",
44205
+ "data-docx-gutter-annotation-id": entry.annotation.id,
44206
+ "data-docx-gutter-anchor-x": Math.round(entry.anchorX),
44207
+ "data-docx-gutter-anchor-y": Math.round(entry.anchorY),
44034
44208
  ref: (element) => {
44035
44209
  const elementKey = `${pageIndex}:${entry.annotation.id}`;
44036
44210
  if (element) {