@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 +295 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +295 -121
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4581,10 +4581,11 @@ 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 =
|
|
4585
|
-
var TRACKED_CHANGE_GUTTER_CARD_RIGHT_PX =
|
|
4586
|
-
var TRACKED_CHANGE_GUTTER_CARD_GAP_PX =
|
|
4587
|
-
var TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX =
|
|
4584
|
+
var TRACKED_CHANGE_GUTTER_CARD_LEFT_PX = 14;
|
|
4585
|
+
var TRACKED_CHANGE_GUTTER_CARD_RIGHT_PX = 12;
|
|
4586
|
+
var TRACKED_CHANGE_GUTTER_CARD_GAP_PX = 4;
|
|
4587
|
+
var TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX = 30;
|
|
4588
|
+
var TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX = 8;
|
|
4588
4589
|
var INITIAL_PAGINATION_STABILITY_IDLE_MS = 240;
|
|
4589
4590
|
function scheduleDomWrite(callback) {
|
|
4590
4591
|
if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
|
|
@@ -12997,9 +12998,10 @@ function trackedInlineStyle(baseStyle, change) {
|
|
|
12997
12998
|
return baseStyle;
|
|
12998
12999
|
}
|
|
12999
13000
|
if (change.kind === "insertion" || change.kind === "move-to") {
|
|
13001
|
+
const accentColor = change.kind === "move-to" ? "#70ad47" : "#dc2626";
|
|
13000
13002
|
return {
|
|
13001
13003
|
...baseStyle,
|
|
13002
|
-
color:
|
|
13004
|
+
color: accentColor,
|
|
13003
13005
|
textDecoration: mergeTextDecorations(
|
|
13004
13006
|
baseStyle.textDecoration,
|
|
13005
13007
|
"underline"
|
|
@@ -14624,11 +14626,22 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14624
14626
|
if (!commentIds || commentIds.length === 0) {
|
|
14625
14627
|
return void 0;
|
|
14626
14628
|
}
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14629
|
+
return commentHighlightStyle(documentTheme, commentIds[0]);
|
|
14630
|
+
};
|
|
14631
|
+
const currentAnnotationAttributes = (trackedInlineChange) => {
|
|
14632
|
+
const attributes = {};
|
|
14633
|
+
if (trackedInlineChange) {
|
|
14634
|
+
attributes["data-docx-tracked-change"] = trackedInlineChange.kind;
|
|
14635
|
+
attributes["data-docx-tracked-change-id"] = trackedInlineChange.id;
|
|
14636
|
+
}
|
|
14637
|
+
const commentIds = commentMarkup?.commentIdsByVisibleChildIndex[trackedVisibleChildCursor];
|
|
14638
|
+
if (commentIds && commentIds.length > 0) {
|
|
14639
|
+
attributes["data-docx-comment-ids"] = commentIds.join(" ");
|
|
14640
|
+
if (commentIds.length === 1) {
|
|
14641
|
+
attributes["data-docx-comment-id"] = String(commentIds[0]);
|
|
14642
|
+
}
|
|
14643
|
+
}
|
|
14644
|
+
return attributes;
|
|
14632
14645
|
};
|
|
14633
14646
|
const consumeTrackedVisibleChild = (child) => {
|
|
14634
14647
|
if (!trackedMarkup && !commentMarkup) {
|
|
@@ -14662,11 +14675,11 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14662
14675
|
fallbackTabWidthPx,
|
|
14663
14676
|
checkboxChoiceRow
|
|
14664
14677
|
);
|
|
14665
|
-
const appendPlainTextWithSoftBreakControl = (target, keySeed, text, style, measureStyle) => {
|
|
14678
|
+
const appendPlainTextWithSoftBreakControl = (target, keySeed, text, style, measureStyle, spanAttributes) => {
|
|
14666
14679
|
const shouldControlSoftBreakStretch = paragraph.style?.align === "justify" && text.includes("\n");
|
|
14667
14680
|
if (!shouldControlSoftBreakStretch) {
|
|
14668
14681
|
target.push(
|
|
14669
|
-
/* @__PURE__ */ jsx("span", { style, children: text }, keySeed)
|
|
14682
|
+
/* @__PURE__ */ jsx("span", { ...spanAttributes, style, children: text }, keySeed)
|
|
14670
14683
|
);
|
|
14671
14684
|
trackTextAdvance(text, measureStyle);
|
|
14672
14685
|
return;
|
|
@@ -14682,6 +14695,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14682
14695
|
/* @__PURE__ */ jsx(
|
|
14683
14696
|
"span",
|
|
14684
14697
|
{
|
|
14698
|
+
...spanAttributes,
|
|
14685
14699
|
style: isLastSegment ? {
|
|
14686
14700
|
...style,
|
|
14687
14701
|
display: "inline-block",
|
|
@@ -14832,6 +14846,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14832
14846
|
" "
|
|
14833
14847
|
);
|
|
14834
14848
|
const text = textOverride ?? textValue;
|
|
14849
|
+
const annotationAttributes2 = currentAnnotationAttributes(trackedInlineChange);
|
|
14835
14850
|
if (child.link) {
|
|
14836
14851
|
const linkHref = child.link;
|
|
14837
14852
|
const isInternalLink = linkHref.startsWith("#");
|
|
@@ -14839,6 +14854,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14839
14854
|
/* @__PURE__ */ jsx(
|
|
14840
14855
|
"a",
|
|
14841
14856
|
{
|
|
14857
|
+
...annotationAttributes2,
|
|
14842
14858
|
href: linkHref,
|
|
14843
14859
|
target: isInternalLink ? void 0 : "_blank",
|
|
14844
14860
|
rel: isInternalLink ? void 0 : "noreferrer noopener",
|
|
@@ -14875,12 +14891,20 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14875
14891
|
};
|
|
14876
14892
|
if (text === " " && !useTabLeaderLayout && !useAnchoredTabLayout) {
|
|
14877
14893
|
target.push(
|
|
14878
|
-
/* @__PURE__ */ jsx(
|
|
14894
|
+
/* @__PURE__ */ jsx(
|
|
14895
|
+
"span",
|
|
14896
|
+
{
|
|
14897
|
+
...annotationAttributes2,
|
|
14898
|
+
style: tabTextStyle(child.style, trackedStyle),
|
|
14899
|
+
children: "\xA0"
|
|
14900
|
+
},
|
|
14901
|
+
key
|
|
14902
|
+
)
|
|
14879
14903
|
);
|
|
14880
14904
|
return;
|
|
14881
14905
|
}
|
|
14882
14906
|
target.push(
|
|
14883
|
-
/* @__PURE__ */ jsx("span", { style: trackedStyle, children: text }, key)
|
|
14907
|
+
/* @__PURE__ */ jsx("span", { ...annotationAttributes2, style: trackedStyle, children: text }, key)
|
|
14884
14908
|
);
|
|
14885
14909
|
trackTextAdvance(text, child.style);
|
|
14886
14910
|
return;
|
|
@@ -14949,7 +14973,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14949
14973
|
const sectionImageCursor = sectionImageLocation && !sectionImageInteraction?.isReadOnly && !behavesAsDecorativeBehindTextBackground && (isWrappedFloatingImage || isAbsoluteFloatingImage) ? "move" : void 0;
|
|
14950
14974
|
const isCenteredStandaloneInlineImage = !isWrappedFloatingImage && !isAbsoluteFloatingImage && paragraph.style?.align === "center" && paragraph.children.length === 1 && paragraph.children[0]?.type === "image";
|
|
14951
14975
|
const trackedImageStyle = trackedInlineChange?.kind === "insertion" || trackedInlineChange?.kind === "move-to" ? {
|
|
14952
|
-
outline: "2px solid rgba(
|
|
14976
|
+
outline: trackedInlineChange.kind === "move-to" ? "2px solid rgba(112, 173, 71, 0.35)" : "2px solid rgba(220, 38, 38, 0.3)",
|
|
14953
14977
|
outlineOffset: 1
|
|
14954
14978
|
} : void 0;
|
|
14955
14979
|
const renderableImageSrc = syntheticTextBoxSvg(
|
|
@@ -15135,6 +15159,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15135
15159
|
),
|
|
15136
15160
|
...currentCommentHighlightStyle()
|
|
15137
15161
|
};
|
|
15162
|
+
const annotationAttributes = currentAnnotationAttributes(trackedInlineChange);
|
|
15138
15163
|
const noteLabel = noteMarkerLabel(
|
|
15139
15164
|
child.noteReference,
|
|
15140
15165
|
safeNoteMarkerIndexes.footnote,
|
|
@@ -15145,6 +15170,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15145
15170
|
/* @__PURE__ */ jsx(
|
|
15146
15171
|
"span",
|
|
15147
15172
|
{
|
|
15173
|
+
...annotationAttributes,
|
|
15148
15174
|
style: {
|
|
15149
15175
|
...textStyle,
|
|
15150
15176
|
verticalAlign: "super",
|
|
@@ -15160,7 +15186,15 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15160
15186
|
}
|
|
15161
15187
|
if ((textOverride ?? child.text) === " " && !useTabLeaderLayout && !useAnchoredTabLayout) {
|
|
15162
15188
|
target.push(
|
|
15163
|
-
/* @__PURE__ */ jsx(
|
|
15189
|
+
/* @__PURE__ */ jsx(
|
|
15190
|
+
"span",
|
|
15191
|
+
{
|
|
15192
|
+
...annotationAttributes,
|
|
15193
|
+
style: tabTextStyle(child.style, textStyle),
|
|
15194
|
+
children: "\xA0"
|
|
15195
|
+
},
|
|
15196
|
+
key
|
|
15197
|
+
)
|
|
15164
15198
|
);
|
|
15165
15199
|
return;
|
|
15166
15200
|
}
|
|
@@ -15171,6 +15205,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15171
15205
|
/* @__PURE__ */ jsx(
|
|
15172
15206
|
"a",
|
|
15173
15207
|
{
|
|
15208
|
+
...annotationAttributes,
|
|
15174
15209
|
href: linkHref,
|
|
15175
15210
|
target: isInternalLink ? void 0 : "_blank",
|
|
15176
15211
|
rel: isInternalLink ? void 0 : "noreferrer noopener",
|
|
@@ -15203,7 +15238,8 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15203
15238
|
key,
|
|
15204
15239
|
textOverride ?? child.text,
|
|
15205
15240
|
textStyle,
|
|
15206
|
-
child.style
|
|
15241
|
+
child.style,
|
|
15242
|
+
annotationAttributes
|
|
15207
15243
|
);
|
|
15208
15244
|
};
|
|
15209
15245
|
const anchoredTabZoneStyle = {
|
|
@@ -17914,6 +17950,7 @@ function collectTrackedChangesFromModel(model) {
|
|
|
17914
17950
|
trackedMarkup.changes.forEach((change, changeIndex) => {
|
|
17915
17951
|
trackedChanges.push({
|
|
17916
17952
|
id: `${paragraphLocationKey(location)}:${change.id}:${changeIndex}`,
|
|
17953
|
+
inlineAnchorId: change.id,
|
|
17917
17954
|
kind: change.kind,
|
|
17918
17955
|
author: change.author,
|
|
17919
17956
|
date: change.date,
|
|
@@ -18092,13 +18129,42 @@ function collectCommentsFromModel(model) {
|
|
|
18092
18129
|
});
|
|
18093
18130
|
return comments;
|
|
18094
18131
|
}
|
|
18095
|
-
function
|
|
18096
|
-
|
|
18132
|
+
function hexColorWithAlpha(color, alpha) {
|
|
18133
|
+
const normalized = color.trim().replace(/^#/, "");
|
|
18134
|
+
if (!/^[\da-f]{6}$/i.test(normalized)) {
|
|
18135
|
+
return color;
|
|
18136
|
+
}
|
|
18137
|
+
const red = Number.parseInt(normalized.slice(0, 2), 16);
|
|
18138
|
+
const green = Number.parseInt(normalized.slice(2, 4), 16);
|
|
18139
|
+
const blue = Number.parseInt(normalized.slice(4, 6), 16);
|
|
18140
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
18141
|
+
}
|
|
18142
|
+
function commentAccentColor(documentTheme, commentId) {
|
|
18143
|
+
const lightPalette = ["#5b9bd5", "#d65f5f", "#8f6ac8", "#70ad47", "#d9872b"];
|
|
18144
|
+
const darkPalette = ["#7dd3fc", "#fca5a5", "#c4b5fd", "#86efac", "#fdba74"];
|
|
18145
|
+
if (Number.isFinite(commentId)) {
|
|
18146
|
+
const palette = documentTheme === "dark" ? darkPalette : lightPalette;
|
|
18147
|
+
return palette[Math.abs(Math.round(commentId)) % palette.length];
|
|
18148
|
+
}
|
|
18149
|
+
return documentTheme === "dark" ? darkPalette[0] : lightPalette[0];
|
|
18150
|
+
}
|
|
18151
|
+
function commentHighlightStyle(documentTheme, commentId) {
|
|
18152
|
+
const accent = commentAccentColor(documentTheme, commentId);
|
|
18153
|
+
return {
|
|
18154
|
+
backgroundColor: hexColorWithAlpha(
|
|
18155
|
+
accent,
|
|
18156
|
+
documentTheme === "dark" ? 0.3 : 0.22
|
|
18157
|
+
),
|
|
18158
|
+
boxShadow: `inset 0 -1px 0 ${hexColorWithAlpha(
|
|
18159
|
+
accent,
|
|
18160
|
+
documentTheme === "dark" ? 0.7 : 0.48
|
|
18161
|
+
)}`
|
|
18162
|
+
};
|
|
18097
18163
|
}
|
|
18098
18164
|
function estimateCommentCardHeight(comment) {
|
|
18099
18165
|
const snippet = comment.text || "Comment";
|
|
18100
|
-
const lines = Math.max(1, Math.ceil(snippet.length /
|
|
18101
|
-
return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX,
|
|
18166
|
+
const lines = Math.min(2, Math.max(1, Math.ceil(snippet.length / 42)));
|
|
18167
|
+
return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 24 + lines * 11);
|
|
18102
18168
|
}
|
|
18103
18169
|
function trackedChangeKindLabel(kind) {
|
|
18104
18170
|
switch (kind) {
|
|
@@ -18120,16 +18186,16 @@ function trackedChangeKindLabel(kind) {
|
|
|
18120
18186
|
}
|
|
18121
18187
|
function trackedChangeAccentColor(kind, documentTheme) {
|
|
18122
18188
|
const palette = documentTheme === "dark" ? {
|
|
18123
|
-
insertion: "#
|
|
18189
|
+
insertion: "#f87171",
|
|
18124
18190
|
deletion: "#f87171",
|
|
18125
|
-
moveFrom: "#
|
|
18126
|
-
moveTo: "#
|
|
18191
|
+
moveFrom: "#86efac",
|
|
18192
|
+
moveTo: "#86efac",
|
|
18127
18193
|
format: "#c084fc"
|
|
18128
18194
|
} : {
|
|
18129
|
-
insertion: "#
|
|
18195
|
+
insertion: "#dc2626",
|
|
18130
18196
|
deletion: "#dc2626",
|
|
18131
|
-
moveFrom: "#
|
|
18132
|
-
moveTo: "#
|
|
18197
|
+
moveFrom: "#70ad47",
|
|
18198
|
+
moveTo: "#70ad47",
|
|
18133
18199
|
format: "#7c3aed"
|
|
18134
18200
|
};
|
|
18135
18201
|
switch (kind) {
|
|
@@ -18148,6 +18214,9 @@ function trackedChangeAccentColor(kind, documentTheme) {
|
|
|
18148
18214
|
return palette.format;
|
|
18149
18215
|
}
|
|
18150
18216
|
}
|
|
18217
|
+
function trackedChangeUsesGutterBalloon(change) {
|
|
18218
|
+
return change.kind !== "insertion" && change.kind !== "move-to";
|
|
18219
|
+
}
|
|
18151
18220
|
function gutterAnnotationSortTuple(location) {
|
|
18152
18221
|
if (location.kind === "paragraph") {
|
|
18153
18222
|
return [location.nodeIndex, 0, 0, 0];
|
|
@@ -18228,10 +18297,92 @@ function elementRectWithinContainer(element, container) {
|
|
|
18228
18297
|
height: elementRect.height / scaleY
|
|
18229
18298
|
};
|
|
18230
18299
|
}
|
|
18300
|
+
function findFirstElementWithSpaceSeparatedDataValue(rootElement, attributeName, value) {
|
|
18301
|
+
const candidateElements = [];
|
|
18302
|
+
if (rootElement.hasAttribute(attributeName)) {
|
|
18303
|
+
candidateElements.push(rootElement);
|
|
18304
|
+
}
|
|
18305
|
+
candidateElements.push(
|
|
18306
|
+
...rootElement.querySelectorAll(
|
|
18307
|
+
`[${attributeName}]`
|
|
18308
|
+
)
|
|
18309
|
+
);
|
|
18310
|
+
for (const candidate of candidateElements) {
|
|
18311
|
+
const rawValue = candidate.getAttribute(attributeName);
|
|
18312
|
+
if (!rawValue) {
|
|
18313
|
+
continue;
|
|
18314
|
+
}
|
|
18315
|
+
if (rawValue.split(/\s+/).includes(value)) {
|
|
18316
|
+
return candidate;
|
|
18317
|
+
}
|
|
18318
|
+
}
|
|
18319
|
+
return void 0;
|
|
18320
|
+
}
|
|
18321
|
+
function findGutterAnnotationScopeElementInPage(pageElement, annotation) {
|
|
18322
|
+
return findTrackedChangeAnchorElementInPage(pageElement, annotation.location);
|
|
18323
|
+
}
|
|
18324
|
+
function findGutterAnnotationDataAnchorInPage(pageElement, annotation, attributeName, value) {
|
|
18325
|
+
const scopedRoot = findGutterAnnotationScopeElementInPage(
|
|
18326
|
+
pageElement,
|
|
18327
|
+
annotation
|
|
18328
|
+
);
|
|
18329
|
+
if (scopedRoot) {
|
|
18330
|
+
const scopedAnchor = findFirstElementWithSpaceSeparatedDataValue(
|
|
18331
|
+
scopedRoot,
|
|
18332
|
+
attributeName,
|
|
18333
|
+
value
|
|
18334
|
+
);
|
|
18335
|
+
if (scopedAnchor) {
|
|
18336
|
+
return scopedAnchor;
|
|
18337
|
+
}
|
|
18338
|
+
}
|
|
18339
|
+
return findFirstElementWithSpaceSeparatedDataValue(
|
|
18340
|
+
pageElement,
|
|
18341
|
+
attributeName,
|
|
18342
|
+
value
|
|
18343
|
+
);
|
|
18344
|
+
}
|
|
18345
|
+
function findGutterAnnotationAnchorElementInPage(pageElement, annotation) {
|
|
18346
|
+
if (annotation.trackedChange) {
|
|
18347
|
+
const trackedAnchor = findGutterAnnotationDataAnchorInPage(
|
|
18348
|
+
pageElement,
|
|
18349
|
+
annotation,
|
|
18350
|
+
"data-docx-tracked-change-id",
|
|
18351
|
+
annotation.trackedChange.id
|
|
18352
|
+
);
|
|
18353
|
+
if (trackedAnchor) {
|
|
18354
|
+
return trackedAnchor;
|
|
18355
|
+
}
|
|
18356
|
+
const inlineAnchorId = annotation.trackedChange.inlineAnchorId;
|
|
18357
|
+
if (inlineAnchorId && inlineAnchorId !== annotation.trackedChange.id) {
|
|
18358
|
+
const inlineTrackedAnchor = findGutterAnnotationDataAnchorInPage(
|
|
18359
|
+
pageElement,
|
|
18360
|
+
annotation,
|
|
18361
|
+
"data-docx-tracked-change-id",
|
|
18362
|
+
inlineAnchorId
|
|
18363
|
+
);
|
|
18364
|
+
if (inlineTrackedAnchor) {
|
|
18365
|
+
return inlineTrackedAnchor;
|
|
18366
|
+
}
|
|
18367
|
+
}
|
|
18368
|
+
}
|
|
18369
|
+
if (annotation.comment) {
|
|
18370
|
+
const commentAnchor = findGutterAnnotationDataAnchorInPage(
|
|
18371
|
+
pageElement,
|
|
18372
|
+
annotation,
|
|
18373
|
+
"data-docx-comment-ids",
|
|
18374
|
+
String(annotation.comment.commentId)
|
|
18375
|
+
);
|
|
18376
|
+
if (commentAnchor) {
|
|
18377
|
+
return commentAnchor;
|
|
18378
|
+
}
|
|
18379
|
+
}
|
|
18380
|
+
return findTrackedChangeAnchorElementInPage(pageElement, annotation.location);
|
|
18381
|
+
}
|
|
18231
18382
|
function estimateTrackedChangeCardHeight(change) {
|
|
18232
18383
|
const snippet = normalizeTrackedChangeSnippet(change.text) ?? trackedChangeKindLabel(change.kind);
|
|
18233
|
-
const lines = Math.max(1, Math.ceil(snippet.length /
|
|
18234
|
-
return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX,
|
|
18384
|
+
const lines = Math.min(2, Math.max(1, Math.ceil(snippet.length / 42)));
|
|
18385
|
+
return Math.max(TRACKED_CHANGE_GUTTER_CARD_MIN_HEIGHT_PX, 22 + lines * 11);
|
|
18235
18386
|
}
|
|
18236
18387
|
function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsByChangeId, pageWidthPx, pageHeightPx) {
|
|
18237
18388
|
if (annotations.length === 0) {
|
|
@@ -18271,11 +18422,21 @@ function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsB
|
|
|
18271
18422
|
heightPx
|
|
18272
18423
|
};
|
|
18273
18424
|
});
|
|
18274
|
-
withAnchors.sort((left, right) =>
|
|
18425
|
+
withAnchors.sort((left, right) => {
|
|
18426
|
+
const yDelta = left.anchorY - right.anchorY;
|
|
18427
|
+
if (Math.abs(yDelta) > 2) {
|
|
18428
|
+
return yDelta;
|
|
18429
|
+
}
|
|
18430
|
+
const xDelta = left.anchorX - right.anchorX;
|
|
18431
|
+
if (xDelta !== 0) {
|
|
18432
|
+
return xDelta;
|
|
18433
|
+
}
|
|
18434
|
+
return left.annotation.id.localeCompare(right.annotation.id);
|
|
18435
|
+
});
|
|
18275
18436
|
const minTopPx = 8;
|
|
18276
18437
|
let cursorTopPx = minTopPx;
|
|
18277
18438
|
withAnchors.forEach((entry) => {
|
|
18278
|
-
const desiredTop = entry.anchorY -
|
|
18439
|
+
const desiredTop = entry.anchorY - 8;
|
|
18279
18440
|
entry.top = Math.max(desiredTop, cursorTopPx);
|
|
18280
18441
|
cursorTopPx = entry.top + entry.heightPx + TRACKED_CHANGE_GUTTER_CARD_GAP_PX;
|
|
18281
18442
|
});
|
|
@@ -27458,6 +27619,9 @@ function DocxEditorViewer({
|
|
|
27458
27619
|
};
|
|
27459
27620
|
if (trackedChangesEnabled) {
|
|
27460
27621
|
editor.trackedChanges.forEach((change) => {
|
|
27622
|
+
if (!trackedChangeUsesGutterBalloon(change)) {
|
|
27623
|
+
return;
|
|
27624
|
+
}
|
|
27461
27625
|
placeAnnotation({
|
|
27462
27626
|
id: change.id,
|
|
27463
27627
|
location: change.location,
|
|
@@ -27508,45 +27672,45 @@ function DocxEditorViewer({
|
|
|
27508
27672
|
);
|
|
27509
27673
|
return;
|
|
27510
27674
|
}
|
|
27511
|
-
const nextAnchorMaps = trackedChangesByPage.map(
|
|
27512
|
-
|
|
27513
|
-
|
|
27514
|
-
|
|
27675
|
+
const nextAnchorMaps = trackedChangesByPage.map(
|
|
27676
|
+
(annotations, pageIndex) => {
|
|
27677
|
+
const pageElement = pageElementsRef.current.get(pageIndex);
|
|
27678
|
+
const anchorsByChangeId = /* @__PURE__ */ new Map();
|
|
27679
|
+
if (!pageElement || annotations.length === 0) {
|
|
27680
|
+
return anchorsByChangeId;
|
|
27681
|
+
}
|
|
27682
|
+
const pageHeightPx = Math.max(1, pageElement.offsetHeight);
|
|
27683
|
+
const pageWidthPx = Math.max(1, pageElement.offsetWidth);
|
|
27684
|
+
annotations.forEach((annotation) => {
|
|
27685
|
+
const anchorElement = findGutterAnnotationAnchorElementInPage(
|
|
27686
|
+
pageElement,
|
|
27687
|
+
annotation
|
|
27688
|
+
);
|
|
27689
|
+
if (!anchorElement) {
|
|
27690
|
+
return;
|
|
27691
|
+
}
|
|
27692
|
+
const anchorRect = elementRectWithinContainer(
|
|
27693
|
+
anchorElement,
|
|
27694
|
+
pageElement
|
|
27695
|
+
);
|
|
27696
|
+
if (!anchorRect) {
|
|
27697
|
+
return;
|
|
27698
|
+
}
|
|
27699
|
+
const anchorY = clampNumber(
|
|
27700
|
+
Math.round(anchorRect.top + anchorRect.height / 2),
|
|
27701
|
+
10,
|
|
27702
|
+
Math.max(10, pageHeightPx - 10)
|
|
27703
|
+
);
|
|
27704
|
+
const anchorX = clampNumber(
|
|
27705
|
+
Math.round(anchorRect.right),
|
|
27706
|
+
10,
|
|
27707
|
+
Math.max(10, pageWidthPx - 10)
|
|
27708
|
+
);
|
|
27709
|
+
anchorsByChangeId.set(annotation.id, { x: anchorX, y: anchorY });
|
|
27710
|
+
});
|
|
27515
27711
|
return anchorsByChangeId;
|
|
27516
27712
|
}
|
|
27517
|
-
|
|
27518
|
-
const pageWidthPx = Math.max(1, pageElement.offsetWidth);
|
|
27519
|
-
annotations.forEach((annotation) => {
|
|
27520
|
-
const anchorElement = findTrackedChangeAnchorElementInPage(
|
|
27521
|
-
pageElement,
|
|
27522
|
-
annotation.location
|
|
27523
|
-
);
|
|
27524
|
-
if (!anchorElement) {
|
|
27525
|
-
return;
|
|
27526
|
-
}
|
|
27527
|
-
const anchorRect = elementRectWithinContainer(
|
|
27528
|
-
anchorElement,
|
|
27529
|
-
pageElement
|
|
27530
|
-
);
|
|
27531
|
-
if (!anchorRect) {
|
|
27532
|
-
return;
|
|
27533
|
-
}
|
|
27534
|
-
const anchorY = clampNumber(
|
|
27535
|
-
Math.round(anchorRect.top + anchorRect.height / 2),
|
|
27536
|
-
10,
|
|
27537
|
-
Math.max(10, pageHeightPx - 10)
|
|
27538
|
-
);
|
|
27539
|
-
const anchorX = clampNumber(
|
|
27540
|
-
Math.round(
|
|
27541
|
-
anchorRect.left + Math.min(24, Math.max(8, anchorRect.width * 0.2))
|
|
27542
|
-
),
|
|
27543
|
-
10,
|
|
27544
|
-
Math.max(10, pageWidthPx - 10)
|
|
27545
|
-
);
|
|
27546
|
-
anchorsByChangeId.set(annotation.id, { x: anchorX, y: anchorY });
|
|
27547
|
-
});
|
|
27548
|
-
return anchorsByChangeId;
|
|
27549
|
-
});
|
|
27713
|
+
);
|
|
27550
27714
|
setTrackedChangeAnchorByPage(nextAnchorMaps);
|
|
27551
27715
|
}, [
|
|
27552
27716
|
trackedChangesByPage,
|
|
@@ -41397,6 +41561,7 @@ ${currentText.slice(end)}`;
|
|
|
41397
41561
|
});
|
|
41398
41562
|
const headerFooterBodyDimmed = pageHeaderFooterEditActive;
|
|
41399
41563
|
const documentPageBackgroundColor = editor.model.metadata.documentBackgroundColor;
|
|
41564
|
+
const resolvedPageSurfaceBackgroundColor = pageBackgroundColor ?? documentPageBackgroundColor ?? pageSurfaceBaseStyle.backgroundColor;
|
|
41400
41565
|
const pageBorders = parseSectionPageBorders(
|
|
41401
41566
|
pageInfo?.section.sectionPropertiesXml ?? editor.model.metadata.sectionPropertiesXml
|
|
41402
41567
|
);
|
|
@@ -41419,7 +41584,7 @@ ${currentText.slice(end)}`;
|
|
|
41419
41584
|
width: pageLayout.pageWidthPx,
|
|
41420
41585
|
height: pageLayout.pageHeightPx,
|
|
41421
41586
|
minHeight: pageLayout.pageHeightPx,
|
|
41422
|
-
backgroundColor:
|
|
41587
|
+
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
41423
41588
|
position: "relative",
|
|
41424
41589
|
...pageMarginPaddingStyle(pageLayout.marginsPx)
|
|
41425
41590
|
};
|
|
@@ -42521,6 +42686,7 @@ ${currentText.slice(end)}`;
|
|
|
42521
42686
|
top: 0,
|
|
42522
42687
|
width: TRACKED_CHANGE_GUTTER_WIDTH_PX,
|
|
42523
42688
|
height: pageLayout.pageHeightPx,
|
|
42689
|
+
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
42524
42690
|
pointerEvents: "none",
|
|
42525
42691
|
overflow: "visible"
|
|
42526
42692
|
},
|
|
@@ -42551,14 +42717,14 @@ ${currentText.slice(end)}`;
|
|
|
42551
42717
|
overflow: "visible"
|
|
42552
42718
|
},
|
|
42553
42719
|
children: pageTrackedChanges.map((entry) => {
|
|
42554
|
-
const
|
|
42555
|
-
|
|
42720
|
+
const trackedChange = entry.annotation.trackedChange;
|
|
42721
|
+
const comment = entry.annotation.comment;
|
|
42722
|
+
const accentColor = trackedChange ? trackedChangeAccentColor(
|
|
42723
|
+
trackedChange.kind,
|
|
42556
42724
|
editor.documentTheme
|
|
42557
|
-
) : commentAccentColor(
|
|
42558
|
-
|
|
42559
|
-
|
|
42560
|
-
8,
|
|
42561
|
-
Math.max(8, pageLayout.pageHeightPx - 8)
|
|
42725
|
+
) : commentAccentColor(
|
|
42726
|
+
editor.documentTheme,
|
|
42727
|
+
comment?.commentId
|
|
42562
42728
|
);
|
|
42563
42729
|
const anchorY = clampNumber(
|
|
42564
42730
|
Math.round(entry.anchorY),
|
|
@@ -42570,48 +42736,50 @@ ${currentText.slice(end)}`;
|
|
|
42570
42736
|
8,
|
|
42571
42737
|
Math.max(8, pageLayout.pageWidthPx - 8)
|
|
42572
42738
|
);
|
|
42573
|
-
const
|
|
42574
|
-
const
|
|
42575
|
-
|
|
42576
|
-
|
|
42577
|
-
|
|
42739
|
+
const cardAttachX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_CARD_LEFT_PX;
|
|
42740
|
+
const gutterBendX = pageLayout.pageWidthPx + TRACKED_CHANGE_GUTTER_BEND_OFFSET_PX;
|
|
42741
|
+
const cardCenterY = clampNumber(
|
|
42742
|
+
Math.round(entry.top + entry.heightPx / 2),
|
|
42743
|
+
8,
|
|
42744
|
+
Math.max(8, pageLayout.pageHeightPx - 8)
|
|
42745
|
+
);
|
|
42746
|
+
const connectorPath = Math.abs(cardCenterY - anchorY) <= 2 ? `M ${anchorX} ${anchorY} H ${cardAttachX}` : `M ${anchorX} ${anchorY} H ${gutterBendX} V ${cardCenterY} H ${cardAttachX}`;
|
|
42747
|
+
const revisionBarX = clampNumber(
|
|
42748
|
+
Math.round(pageLayout.marginsPx.left - 20),
|
|
42749
|
+
8,
|
|
42750
|
+
Math.max(8, pageLayout.pageWidthPx - 8)
|
|
42578
42751
|
);
|
|
42579
42752
|
return /* @__PURE__ */ jsxs(
|
|
42580
42753
|
"g",
|
|
42581
42754
|
{
|
|
42582
42755
|
children: [
|
|
42756
|
+
trackedChange ? /* @__PURE__ */ jsx(
|
|
42757
|
+
"line",
|
|
42758
|
+
{
|
|
42759
|
+
x1: revisionBarX,
|
|
42760
|
+
y1: Math.max(8, anchorY - 16),
|
|
42761
|
+
x2: revisionBarX,
|
|
42762
|
+
y2: Math.min(
|
|
42763
|
+
pageLayout.pageHeightPx - 8,
|
|
42764
|
+
anchorY + 16
|
|
42765
|
+
),
|
|
42766
|
+
stroke: editor.documentTheme === "dark" ? "#94a3b8" : "#9ca3af",
|
|
42767
|
+
strokeWidth: 1.25,
|
|
42768
|
+
strokeLinecap: "square"
|
|
42769
|
+
}
|
|
42770
|
+
) : null,
|
|
42583
42771
|
/* @__PURE__ */ jsx(
|
|
42584
42772
|
"path",
|
|
42585
42773
|
{
|
|
42586
|
-
d:
|
|
42774
|
+
d: connectorPath,
|
|
42587
42775
|
stroke: accentColor,
|
|
42588
|
-
strokeWidth: 1.
|
|
42589
|
-
strokeOpacity:
|
|
42590
|
-
strokeDasharray: "
|
|
42776
|
+
strokeWidth: 1.15,
|
|
42777
|
+
strokeOpacity: 0.78,
|
|
42778
|
+
strokeDasharray: "2 3",
|
|
42591
42779
|
strokeLinejoin: "round",
|
|
42592
42780
|
strokeLinecap: "round",
|
|
42593
42781
|
fill: "none"
|
|
42594
42782
|
}
|
|
42595
|
-
),
|
|
42596
|
-
/* @__PURE__ */ jsx(
|
|
42597
|
-
"circle",
|
|
42598
|
-
{
|
|
42599
|
-
cx: anchorX,
|
|
42600
|
-
cy: anchorY,
|
|
42601
|
-
r: 2.2,
|
|
42602
|
-
fill: accentColor,
|
|
42603
|
-
stroke: editor.documentTheme === "dark" ? "#020617" : "#ffffff",
|
|
42604
|
-
strokeWidth: 1
|
|
42605
|
-
}
|
|
42606
|
-
),
|
|
42607
|
-
/* @__PURE__ */ jsx(
|
|
42608
|
-
"circle",
|
|
42609
|
-
{
|
|
42610
|
-
cx: cardLeadX,
|
|
42611
|
-
cy: cardCenterY,
|
|
42612
|
-
r: 1.8,
|
|
42613
|
-
fill: accentColor
|
|
42614
|
-
}
|
|
42615
42783
|
)
|
|
42616
42784
|
]
|
|
42617
42785
|
},
|
|
@@ -42642,7 +42810,10 @@ ${currentText.slice(end)}`;
|
|
|
42642
42810
|
const accentColor = trackedChange ? trackedChangeAccentColor(
|
|
42643
42811
|
trackedChange.kind,
|
|
42644
42812
|
editor.documentTheme
|
|
42645
|
-
) : commentAccentColor(
|
|
42813
|
+
) : commentAccentColor(
|
|
42814
|
+
editor.documentTheme,
|
|
42815
|
+
comment?.commentId
|
|
42816
|
+
);
|
|
42646
42817
|
const formattedDate = formatTrackedChangeDate(
|
|
42647
42818
|
trackedChange?.date ?? comment?.date
|
|
42648
42819
|
);
|
|
@@ -42669,15 +42840,15 @@ ${currentText.slice(end)}`;
|
|
|
42669
42840
|
{
|
|
42670
42841
|
style: {
|
|
42671
42842
|
...cardStyle,
|
|
42672
|
-
padding: "6px
|
|
42843
|
+
padding: "4px 6px",
|
|
42673
42844
|
boxSizing: "border-box",
|
|
42674
|
-
borderLeft: `
|
|
42675
|
-
borderTop: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.
|
|
42676
|
-
borderRight: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.
|
|
42677
|
-
borderBottom: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.
|
|
42678
|
-
backgroundColor: editor.documentTheme === "dark" ? "rgba(
|
|
42845
|
+
borderLeft: `1.5px solid ${accentColor}`,
|
|
42846
|
+
borderTop: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.18)" : "rgba(15, 23, 42, 0.08)"}`,
|
|
42847
|
+
borderRight: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.18)" : "rgba(15, 23, 42, 0.08)"}`,
|
|
42848
|
+
borderBottom: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.18)" : "rgba(15, 23, 42, 0.08)"}`,
|
|
42849
|
+
backgroundColor: editor.documentTheme === "dark" ? "rgba(15, 23, 42, 0.92)" : "rgba(255, 255, 255, 0.72)",
|
|
42679
42850
|
color: editor.documentTheme === "dark" ? "#f3f4f6" : "#111827",
|
|
42680
|
-
boxShadow: editor.documentTheme === "dark" ? "0 2px
|
|
42851
|
+
boxShadow: editor.documentTheme === "dark" ? "0 1px 2px rgba(2, 6, 23, 0.45)" : "0 1px 1px rgba(15, 23, 42, 0.08)"
|
|
42681
42852
|
},
|
|
42682
42853
|
children: [
|
|
42683
42854
|
/* @__PURE__ */ jsxs(
|
|
@@ -42695,9 +42866,9 @@ ${currentText.slice(end)}`;
|
|
|
42695
42866
|
{
|
|
42696
42867
|
style: {
|
|
42697
42868
|
margin: 0,
|
|
42698
|
-
fontSize:
|
|
42869
|
+
fontSize: 10,
|
|
42699
42870
|
fontWeight: 700,
|
|
42700
|
-
lineHeight: 1.
|
|
42871
|
+
lineHeight: 1.2
|
|
42701
42872
|
},
|
|
42702
42873
|
children: (trackedChange?.author ?? comment?.author)?.trim() || "Unknown author"
|
|
42703
42874
|
}
|
|
@@ -42707,8 +42878,8 @@ ${currentText.slice(end)}`;
|
|
|
42707
42878
|
{
|
|
42708
42879
|
style: {
|
|
42709
42880
|
margin: 0,
|
|
42710
|
-
fontSize:
|
|
42711
|
-
lineHeight: 1.
|
|
42881
|
+
fontSize: 9,
|
|
42882
|
+
lineHeight: 1.15,
|
|
42712
42883
|
color: editor.documentTheme === "dark" ? "#94a3b8" : "#6b7280",
|
|
42713
42884
|
whiteSpace: "nowrap"
|
|
42714
42885
|
},
|
|
@@ -42723,8 +42894,8 @@ ${currentText.slice(end)}`;
|
|
|
42723
42894
|
{
|
|
42724
42895
|
style: {
|
|
42725
42896
|
margin: "2px 0 0",
|
|
42726
|
-
fontSize:
|
|
42727
|
-
lineHeight: 1.
|
|
42897
|
+
fontSize: 9,
|
|
42898
|
+
lineHeight: 1.25,
|
|
42728
42899
|
fontStyle: "italic",
|
|
42729
42900
|
color: editor.documentTheme === "dark" ? "#94a3b8" : "#6b7280"
|
|
42730
42901
|
},
|
|
@@ -42740,8 +42911,8 @@ ${currentText.slice(end)}`;
|
|
|
42740
42911
|
{
|
|
42741
42912
|
style: {
|
|
42742
42913
|
margin: "2px 0 0",
|
|
42743
|
-
fontSize:
|
|
42744
|
-
lineHeight: 1.
|
|
42914
|
+
fontSize: 10,
|
|
42915
|
+
lineHeight: 1.25
|
|
42745
42916
|
},
|
|
42746
42917
|
children: [
|
|
42747
42918
|
/* @__PURE__ */ jsxs("strong", { children: [
|
|
@@ -42778,6 +42949,9 @@ ${currentText.slice(end)}`;
|
|
|
42778
42949
|
"div",
|
|
42779
42950
|
{
|
|
42780
42951
|
"data-docx-gutter-annotation": trackedChange ? "tracked-change" : "comment",
|
|
42952
|
+
"data-docx-gutter-annotation-id": entry.annotation.id,
|
|
42953
|
+
"data-docx-gutter-anchor-x": Math.round(entry.anchorX),
|
|
42954
|
+
"data-docx-gutter-anchor-y": Math.round(entry.anchorY),
|
|
42781
42955
|
ref: (element) => {
|
|
42782
42956
|
const elementKey = `${pageIndex}:${entry.annotation.id}`;
|
|
42783
42957
|
if (element) {
|