@extend-ai/react-docx 0.7.0 → 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/README.md +4 -2
- package/dist/{chunk-P3B3Q7Y6.js → chunk-P3MKA55V.js} +3 -3
- package/dist/{chunk-2SXGXGWO.js → chunk-WKBPLHUA.js} +8 -2
- package/dist/{chunk-2SXGXGWO.js.map → chunk-WKBPLHUA.js.map} +1 -1
- package/dist/{chunk-QOXSE6WY.js → chunk-XBI2PYTU.js} +2 -2
- package/dist/docx-import-worker.cjs +19 -1
- package/dist/docx-import-worker.cjs.map +1 -1
- package/dist/docx-import-worker.js +8 -3
- package/dist/docx-import-worker.js.map +1 -1
- package/dist/index.cjs +499 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.js +494 -146
- package/dist/index.js.map +1 -1
- package/dist/{src-PJYTN6DB.js → src-2FP7IUE6.js} +3 -3
- package/dist/{src-NDPFDRVM.js → src-VN4V5N3K.js} +3 -3
- package/package.json +1 -1
- /package/dist/{chunk-P3B3Q7Y6.js.map → chunk-P3MKA55V.js.map} +0 -0
- /package/dist/{chunk-QOXSE6WY.js.map → chunk-XBI2PYTU.js.map} +0 -0
- /package/dist/{src-NDPFDRVM.js.map → src-2FP7IUE6.js.map} +0 -0
- /package/dist/{src-PJYTN6DB.js.map → src-VN4V5N3K.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -4,20 +4,20 @@ import {
|
|
|
4
4
|
packageToArrayBuffer,
|
|
5
5
|
parseDocx,
|
|
6
6
|
withPart
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XBI2PYTU.js";
|
|
8
8
|
import {
|
|
9
9
|
buildDocModel,
|
|
10
10
|
buildDocModelFromBytes,
|
|
11
11
|
cloneDocModel,
|
|
12
12
|
normalizeDocModel
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-P3MKA55V.js";
|
|
14
14
|
import {
|
|
15
15
|
initWasm,
|
|
16
16
|
mapsToWasmPackage,
|
|
17
17
|
setWasmSource,
|
|
18
18
|
wasmModelToDocumentXml,
|
|
19
19
|
wasmSerializeDocx
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-WKBPLHUA.js";
|
|
21
21
|
|
|
22
22
|
// src/index.tsx
|
|
23
23
|
import * as React2 from "react";
|
|
@@ -244,6 +244,56 @@ function layoutDocument(model, options = {}) {
|
|
|
244
244
|
return pages;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
// src/wasm-source.ts
|
|
248
|
+
var hasConfiguredWasmSource = false;
|
|
249
|
+
var configuredWorkerWasmSource;
|
|
250
|
+
function bufferSourceToArrayBuffer(source) {
|
|
251
|
+
if (source instanceof ArrayBuffer) {
|
|
252
|
+
return source.slice(0);
|
|
253
|
+
}
|
|
254
|
+
const bytes = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
255
|
+
const copy = new Uint8Array(bytes);
|
|
256
|
+
return copy.buffer;
|
|
257
|
+
}
|
|
258
|
+
function sourceToWorkerSource(source) {
|
|
259
|
+
if (typeof source === "string") {
|
|
260
|
+
return source;
|
|
261
|
+
}
|
|
262
|
+
if (typeof URL !== "undefined" && source instanceof URL) {
|
|
263
|
+
return source.href;
|
|
264
|
+
}
|
|
265
|
+
if (source instanceof ArrayBuffer || ArrayBuffer.isView(source)) {
|
|
266
|
+
return bufferSourceToArrayBuffer(source);
|
|
267
|
+
}
|
|
268
|
+
if (typeof WebAssembly !== "undefined" && source instanceof WebAssembly.Module) {
|
|
269
|
+
return source;
|
|
270
|
+
}
|
|
271
|
+
if (typeof Request !== "undefined" && source instanceof Request) {
|
|
272
|
+
return source.url;
|
|
273
|
+
}
|
|
274
|
+
return void 0;
|
|
275
|
+
}
|
|
276
|
+
function rememberWorkerWasmSource(source) {
|
|
277
|
+
hasConfiguredWasmSource = true;
|
|
278
|
+
configuredWorkerWasmSource = sourceToWorkerSource(source);
|
|
279
|
+
}
|
|
280
|
+
function setWasmSource2(source) {
|
|
281
|
+
setWasmSource(source);
|
|
282
|
+
rememberWorkerWasmSource(source);
|
|
283
|
+
}
|
|
284
|
+
function initWasm2(source) {
|
|
285
|
+
if (source !== void 0) {
|
|
286
|
+
rememberWorkerWasmSource(source);
|
|
287
|
+
}
|
|
288
|
+
return initWasm(source);
|
|
289
|
+
}
|
|
290
|
+
function canUseConfiguredWasmSourceInWorker() {
|
|
291
|
+
return !hasConfiguredWasmSource || configuredWorkerWasmSource !== void 0;
|
|
292
|
+
}
|
|
293
|
+
function getConfiguredWorkerWasmSource() {
|
|
294
|
+
return configuredWorkerWasmSource;
|
|
295
|
+
}
|
|
296
|
+
|
|
247
297
|
// src/docx-import.ts
|
|
248
298
|
var nextImportWorkerRequestId = 1;
|
|
249
299
|
function createAbortError() {
|
|
@@ -263,7 +313,7 @@ function errorFromWorkerResponse(response) {
|
|
|
263
313
|
return error;
|
|
264
314
|
}
|
|
265
315
|
function canUseDocxImportWorker(options) {
|
|
266
|
-
return options.useWorker !== false && typeof Worker !== "undefined";
|
|
316
|
+
return options.useWorker !== false && typeof Worker !== "undefined" && canUseConfiguredWasmSourceInWorker();
|
|
267
317
|
}
|
|
268
318
|
function createDocxImportWorker() {
|
|
269
319
|
return new Worker(new URL("./docx-import-worker.js", import.meta.url), {
|
|
@@ -277,8 +327,8 @@ async function importDocxOnMainThread(buffer, signal) {
|
|
|
277
327
|
}
|
|
278
328
|
const startedAt = performanceNow();
|
|
279
329
|
const [{ parseDocx: parseDocx2 }, { buildDocModel: buildDocModel2 }] = await Promise.all([
|
|
280
|
-
import("./src-
|
|
281
|
-
import("./src-
|
|
330
|
+
import("./src-2FP7IUE6.js"),
|
|
331
|
+
import("./src-VN4V5N3K.js")
|
|
282
332
|
]);
|
|
283
333
|
const pkg = await parseDocx2(buffer);
|
|
284
334
|
const parsedAt = performanceNow();
|
|
@@ -372,7 +422,8 @@ async function importDocxBuffer(buffer, options = {}) {
|
|
|
372
422
|
const request = {
|
|
373
423
|
id: requestId,
|
|
374
424
|
type: "import-docx",
|
|
375
|
-
buffer
|
|
425
|
+
buffer,
|
|
426
|
+
wasmSource: getConfiguredWorkerWasmSource()
|
|
376
427
|
};
|
|
377
428
|
const transfer = options.transferBuffer ? [buffer] : [];
|
|
378
429
|
worker.postMessage(request, transfer);
|
|
@@ -433,6 +484,18 @@ function readStringAttribute(tagXml, attribute) {
|
|
|
433
484
|
}
|
|
434
485
|
return tagXml.match(new RegExp(`${attribute}="([^"]+)"`, "i"))?.[1];
|
|
435
486
|
}
|
|
487
|
+
function resolvePageSizeForOrientation(params) {
|
|
488
|
+
const normalizedOrientation = params.orientation?.trim().toLowerCase();
|
|
489
|
+
const widthPx = Math.max(1, params.widthPx);
|
|
490
|
+
const heightPx = Math.max(1, params.heightPx);
|
|
491
|
+
if (normalizedOrientation === "landscape" && widthPx < heightPx) {
|
|
492
|
+
return { widthPx: heightPx, heightPx: widthPx };
|
|
493
|
+
}
|
|
494
|
+
if (normalizedOrientation === "portrait" && widthPx > heightPx) {
|
|
495
|
+
return { widthPx: heightPx, heightPx: widthPx };
|
|
496
|
+
}
|
|
497
|
+
return { widthPx, heightPx };
|
|
498
|
+
}
|
|
436
499
|
function normalizeHexColor(value) {
|
|
437
500
|
if (!value) {
|
|
438
501
|
return void 0;
|
|
@@ -518,8 +581,13 @@ function parseSectionLayout(sectionPropertiesXml) {
|
|
|
518
581
|
const pageSizeTag = sectionPropertiesXml.match(/<w:pgSz\b[^>]*>/i)?.[0];
|
|
519
582
|
const pageMarginTag = sectionPropertiesXml.match(/<w:pgMar\b[^>]*>/i)?.[0];
|
|
520
583
|
const docGridTag = sectionPropertiesXml.match(/<w:docGrid\b[^>]*\/?>/i)?.[0];
|
|
521
|
-
const
|
|
522
|
-
const
|
|
584
|
+
const rawPageWidthPx = twipsToPixels(readTwipsAttribute(pageSizeTag, "w:w")) ?? DEFAULT_DOCUMENT_LAYOUT.pageWidthPx;
|
|
585
|
+
const rawPageHeightPx = twipsToPixels(readTwipsAttribute(pageSizeTag, "w:h")) ?? DEFAULT_DOCUMENT_LAYOUT.pageHeightPx;
|
|
586
|
+
const pageSize = resolvePageSizeForOrientation({
|
|
587
|
+
widthPx: rawPageWidthPx,
|
|
588
|
+
heightPx: rawPageHeightPx,
|
|
589
|
+
orientation: readStringAttribute(pageSizeTag, "w:orient")
|
|
590
|
+
});
|
|
523
591
|
const topMarginPx = twipsToPixels(readTwipsAttribute(pageMarginTag, "w:top")) ?? DEFAULT_DOCUMENT_LAYOUT.marginsPx.top;
|
|
524
592
|
const rightMarginPx = twipsToPixels(readTwipsAttribute(pageMarginTag, "w:right")) ?? DEFAULT_DOCUMENT_LAYOUT.marginsPx.right;
|
|
525
593
|
const bottomMarginPx = twipsToPixels(readTwipsAttribute(pageMarginTag, "w:bottom")) ?? DEFAULT_DOCUMENT_LAYOUT.marginsPx.bottom;
|
|
@@ -529,8 +597,8 @@ function parseSectionLayout(sectionPropertiesXml) {
|
|
|
529
597
|
const docGridType = readStringAttribute(docGridTag, "w:type")?.toLowerCase();
|
|
530
598
|
const docGridLinePitchPx = docGridType === "lines" || docGridType === "linesandchars" || docGridType === "snaptochars" ? twipsToPixels(readTwipsAttribute(docGridTag, "w:linePitch")) ?? DEFAULT_DOCUMENT_LAYOUT.docGridLinePitchPx : DEFAULT_DOCUMENT_LAYOUT.docGridLinePitchPx;
|
|
531
599
|
return {
|
|
532
|
-
pageWidthPx,
|
|
533
|
-
pageHeightPx,
|
|
600
|
+
pageWidthPx: pageSize.widthPx,
|
|
601
|
+
pageHeightPx: pageSize.heightPx,
|
|
534
602
|
marginsPx: {
|
|
535
603
|
top: topMarginPx,
|
|
536
604
|
right: rightMarginPx,
|
|
@@ -1747,7 +1815,7 @@ async function serializeDocModel(model, basePackage) {
|
|
|
1747
1815
|
model,
|
|
1748
1816
|
basePackage ? mapsToWasmPackage(basePackage) : void 0
|
|
1749
1817
|
);
|
|
1750
|
-
const { parseDocx: parseDocx2 } = await import("./src-
|
|
1818
|
+
const { parseDocx: parseDocx2 } = await import("./src-2FP7IUE6.js");
|
|
1751
1819
|
return parseDocx2(bytes);
|
|
1752
1820
|
}
|
|
1753
1821
|
async function serializeDocx(model, basePackage) {
|
|
@@ -3231,6 +3299,26 @@ function getDownscaledThumbnailImageDataUri(src) {
|
|
|
3231
3299
|
downscaledThumbnailImageCache.set(src, pending);
|
|
3232
3300
|
return pending;
|
|
3233
3301
|
}
|
|
3302
|
+
var THUMBNAIL_DECODED_IMAGE_CACHE_MAX_ENTRIES = 48;
|
|
3303
|
+
var decodedThumbnailImageCache = /* @__PURE__ */ new Map();
|
|
3304
|
+
function getDecodedThumbnailImage(src) {
|
|
3305
|
+
const cached = decodedThumbnailImageCache.get(src);
|
|
3306
|
+
if (cached) {
|
|
3307
|
+
decodedThumbnailImageCache.delete(src);
|
|
3308
|
+
decodedThumbnailImageCache.set(src, cached);
|
|
3309
|
+
return cached;
|
|
3310
|
+
}
|
|
3311
|
+
const pending = loadThumbnailImage(src).catch(() => void 0);
|
|
3312
|
+
decodedThumbnailImageCache.set(src, pending);
|
|
3313
|
+
while (decodedThumbnailImageCache.size > THUMBNAIL_DECODED_IMAGE_CACHE_MAX_ENTRIES) {
|
|
3314
|
+
const oldestKey = decodedThumbnailImageCache.keys().next().value;
|
|
3315
|
+
if (oldestKey === void 0) {
|
|
3316
|
+
break;
|
|
3317
|
+
}
|
|
3318
|
+
decodedThumbnailImageCache.delete(oldestKey);
|
|
3319
|
+
}
|
|
3320
|
+
return pending;
|
|
3321
|
+
}
|
|
3234
3322
|
function directThumbnailPositivePx(value, fallback = 1) {
|
|
3235
3323
|
return Number.isFinite(value) && value > 0 ? Math.max(1, Number(value)) : fallback;
|
|
3236
3324
|
}
|
|
@@ -3486,6 +3574,32 @@ function drawDirectThumbnailImagePlaceholder(context, image, hairlineSourcePx) {
|
|
|
3486
3574
|
context.lineWidth = hairlineSourcePx;
|
|
3487
3575
|
context.strokeRect(xPx, yPx, widthPx, heightPx);
|
|
3488
3576
|
}
|
|
3577
|
+
function drawDirectThumbnailImage(context, image, decoded, hairlineSourcePx) {
|
|
3578
|
+
const xPx = Math.round(image.xPx);
|
|
3579
|
+
const yPx = Math.round(image.yPx);
|
|
3580
|
+
const widthPx = Math.max(1, Math.round(image.widthPx));
|
|
3581
|
+
const heightPx = Math.max(1, Math.round(image.heightPx));
|
|
3582
|
+
if (decoded && decoded.naturalWidth > 0 && decoded.naturalHeight > 0) {
|
|
3583
|
+
try {
|
|
3584
|
+
context.drawImage(decoded, xPx, yPx, widthPx, heightPx);
|
|
3585
|
+
return;
|
|
3586
|
+
} catch {
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
setCanvasFillStyle(
|
|
3590
|
+
context,
|
|
3591
|
+
image.backgroundColor,
|
|
3592
|
+
THUMBNAIL_DIRECT_IMAGE_BACKGROUND
|
|
3593
|
+
);
|
|
3594
|
+
context.fillRect(xPx, yPx, widthPx, heightPx);
|
|
3595
|
+
setCanvasStrokeStyle(
|
|
3596
|
+
context,
|
|
3597
|
+
image.borderColor,
|
|
3598
|
+
THUMBNAIL_DIRECT_TABLE_BORDER_COLOR
|
|
3599
|
+
);
|
|
3600
|
+
context.lineWidth = hairlineSourcePx;
|
|
3601
|
+
context.strokeRect(xPx, yPx, widthPx, heightPx);
|
|
3602
|
+
}
|
|
3489
3603
|
function drawDirectThumbnailTable(context, table, hairlineSourcePx) {
|
|
3490
3604
|
const tableXPx = Math.round(table.xPx);
|
|
3491
3605
|
const tableYPx = Math.round(table.yPx);
|
|
@@ -3525,7 +3639,7 @@ function drawDirectThumbnailTable(context, table, hairlineSourcePx) {
|
|
|
3525
3639
|
});
|
|
3526
3640
|
context.restore();
|
|
3527
3641
|
}
|
|
3528
|
-
function renderDocxThumbnailSnapshotSurface(params) {
|
|
3642
|
+
async function renderDocxThumbnailSnapshotSurface(params) {
|
|
3529
3643
|
if (typeof document === "undefined") {
|
|
3530
3644
|
throw new Error("DOCX thumbnails require a browser environment.");
|
|
3531
3645
|
}
|
|
@@ -3540,6 +3654,21 @@ function renderDocxThumbnailSnapshotSurface(params) {
|
|
|
3540
3654
|
if (!context) {
|
|
3541
3655
|
throw new Error("2D canvas context is unavailable for DOCX thumbnails.");
|
|
3542
3656
|
}
|
|
3657
|
+
const elements = params.snapshot.elements.slice(0, THUMBNAIL_DIRECT_MAX_ELEMENTS);
|
|
3658
|
+
const decodedImagesBySrc = /* @__PURE__ */ new Map();
|
|
3659
|
+
const imageSrcs = /* @__PURE__ */ new Set();
|
|
3660
|
+
for (const element of elements) {
|
|
3661
|
+
if (element.kind === "image" && element.src) {
|
|
3662
|
+
imageSrcs.add(element.src);
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
if (imageSrcs.size > 0) {
|
|
3666
|
+
await Promise.all(
|
|
3667
|
+
Array.from(imageSrcs, async (src) => {
|
|
3668
|
+
decodedImagesBySrc.set(src, await getDecodedThumbnailImage(src));
|
|
3669
|
+
})
|
|
3670
|
+
);
|
|
3671
|
+
}
|
|
3543
3672
|
const scaleX = pixelWidthPx / sourceWidthPx;
|
|
3544
3673
|
const scaleY = pixelHeightPx / sourceHeightPx;
|
|
3545
3674
|
const hairlineSourcePx = Math.max(0.75, 1 / Math.max(scaleX, scaleY));
|
|
@@ -3552,7 +3681,7 @@ function renderDocxThumbnailSnapshotSurface(params) {
|
|
|
3552
3681
|
"#ffffff"
|
|
3553
3682
|
);
|
|
3554
3683
|
context.fillRect(0, 0, sourceWidthPx, sourceHeightPx);
|
|
3555
|
-
|
|
3684
|
+
elements.forEach((element) => {
|
|
3556
3685
|
switch (element.kind) {
|
|
3557
3686
|
case "paragraph":
|
|
3558
3687
|
drawDirectThumbnailParagraph(context, element);
|
|
@@ -3564,6 +3693,14 @@ function renderDocxThumbnailSnapshotSurface(params) {
|
|
|
3564
3693
|
hairlineSourcePx
|
|
3565
3694
|
);
|
|
3566
3695
|
break;
|
|
3696
|
+
case "image":
|
|
3697
|
+
drawDirectThumbnailImage(
|
|
3698
|
+
context,
|
|
3699
|
+
element,
|
|
3700
|
+
decodedImagesBySrc.get(element.src),
|
|
3701
|
+
hairlineSourcePx
|
|
3702
|
+
);
|
|
3703
|
+
break;
|
|
3567
3704
|
case "table":
|
|
3568
3705
|
drawDirectThumbnailTable(context, element, hairlineSourcePx);
|
|
3569
3706
|
break;
|
|
@@ -4444,10 +4581,11 @@ var BASE_DOC_STYLE = {
|
|
|
4444
4581
|
transition: "box-shadow 0.2s ease"
|
|
4445
4582
|
};
|
|
4446
4583
|
var TRACKED_CHANGE_GUTTER_WIDTH_PX = 300;
|
|
4447
|
-
var TRACKED_CHANGE_GUTTER_CARD_LEFT_PX =
|
|
4448
|
-
var TRACKED_CHANGE_GUTTER_CARD_RIGHT_PX =
|
|
4449
|
-
var TRACKED_CHANGE_GUTTER_CARD_GAP_PX =
|
|
4450
|
-
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;
|
|
4451
4589
|
var INITIAL_PAGINATION_STABILITY_IDLE_MS = 240;
|
|
4452
4590
|
function scheduleDomWrite(callback) {
|
|
4453
4591
|
if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
|
|
@@ -12860,9 +12998,10 @@ function trackedInlineStyle(baseStyle, change) {
|
|
|
12860
12998
|
return baseStyle;
|
|
12861
12999
|
}
|
|
12862
13000
|
if (change.kind === "insertion" || change.kind === "move-to") {
|
|
13001
|
+
const accentColor = change.kind === "move-to" ? "#70ad47" : "#dc2626";
|
|
12863
13002
|
return {
|
|
12864
13003
|
...baseStyle,
|
|
12865
|
-
color:
|
|
13004
|
+
color: accentColor,
|
|
12866
13005
|
textDecoration: mergeTextDecorations(
|
|
12867
13006
|
baseStyle.textDecoration,
|
|
12868
13007
|
"underline"
|
|
@@ -14487,11 +14626,22 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14487
14626
|
if (!commentIds || commentIds.length === 0) {
|
|
14488
14627
|
return void 0;
|
|
14489
14628
|
}
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
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;
|
|
14495
14645
|
};
|
|
14496
14646
|
const consumeTrackedVisibleChild = (child) => {
|
|
14497
14647
|
if (!trackedMarkup && !commentMarkup) {
|
|
@@ -14525,11 +14675,11 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14525
14675
|
fallbackTabWidthPx,
|
|
14526
14676
|
checkboxChoiceRow
|
|
14527
14677
|
);
|
|
14528
|
-
const appendPlainTextWithSoftBreakControl = (target, keySeed, text, style, measureStyle) => {
|
|
14678
|
+
const appendPlainTextWithSoftBreakControl = (target, keySeed, text, style, measureStyle, spanAttributes) => {
|
|
14529
14679
|
const shouldControlSoftBreakStretch = paragraph.style?.align === "justify" && text.includes("\n");
|
|
14530
14680
|
if (!shouldControlSoftBreakStretch) {
|
|
14531
14681
|
target.push(
|
|
14532
|
-
/* @__PURE__ */ jsx("span", { style, children: text }, keySeed)
|
|
14682
|
+
/* @__PURE__ */ jsx("span", { ...spanAttributes, style, children: text }, keySeed)
|
|
14533
14683
|
);
|
|
14534
14684
|
trackTextAdvance(text, measureStyle);
|
|
14535
14685
|
return;
|
|
@@ -14545,6 +14695,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14545
14695
|
/* @__PURE__ */ jsx(
|
|
14546
14696
|
"span",
|
|
14547
14697
|
{
|
|
14698
|
+
...spanAttributes,
|
|
14548
14699
|
style: isLastSegment ? {
|
|
14549
14700
|
...style,
|
|
14550
14701
|
display: "inline-block",
|
|
@@ -14695,6 +14846,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14695
14846
|
" "
|
|
14696
14847
|
);
|
|
14697
14848
|
const text = textOverride ?? textValue;
|
|
14849
|
+
const annotationAttributes2 = currentAnnotationAttributes(trackedInlineChange);
|
|
14698
14850
|
if (child.link) {
|
|
14699
14851
|
const linkHref = child.link;
|
|
14700
14852
|
const isInternalLink = linkHref.startsWith("#");
|
|
@@ -14702,6 +14854,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14702
14854
|
/* @__PURE__ */ jsx(
|
|
14703
14855
|
"a",
|
|
14704
14856
|
{
|
|
14857
|
+
...annotationAttributes2,
|
|
14705
14858
|
href: linkHref,
|
|
14706
14859
|
target: isInternalLink ? void 0 : "_blank",
|
|
14707
14860
|
rel: isInternalLink ? void 0 : "noreferrer noopener",
|
|
@@ -14738,12 +14891,20 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14738
14891
|
};
|
|
14739
14892
|
if (text === " " && !useTabLeaderLayout && !useAnchoredTabLayout) {
|
|
14740
14893
|
target.push(
|
|
14741
|
-
/* @__PURE__ */ jsx(
|
|
14894
|
+
/* @__PURE__ */ jsx(
|
|
14895
|
+
"span",
|
|
14896
|
+
{
|
|
14897
|
+
...annotationAttributes2,
|
|
14898
|
+
style: tabTextStyle(child.style, trackedStyle),
|
|
14899
|
+
children: "\xA0"
|
|
14900
|
+
},
|
|
14901
|
+
key
|
|
14902
|
+
)
|
|
14742
14903
|
);
|
|
14743
14904
|
return;
|
|
14744
14905
|
}
|
|
14745
14906
|
target.push(
|
|
14746
|
-
/* @__PURE__ */ jsx("span", { style: trackedStyle, children: text }, key)
|
|
14907
|
+
/* @__PURE__ */ jsx("span", { ...annotationAttributes2, style: trackedStyle, children: text }, key)
|
|
14747
14908
|
);
|
|
14748
14909
|
trackTextAdvance(text, child.style);
|
|
14749
14910
|
return;
|
|
@@ -14812,7 +14973,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14812
14973
|
const sectionImageCursor = sectionImageLocation && !sectionImageInteraction?.isReadOnly && !behavesAsDecorativeBehindTextBackground && (isWrappedFloatingImage || isAbsoluteFloatingImage) ? "move" : void 0;
|
|
14813
14974
|
const isCenteredStandaloneInlineImage = !isWrappedFloatingImage && !isAbsoluteFloatingImage && paragraph.style?.align === "center" && paragraph.children.length === 1 && paragraph.children[0]?.type === "image";
|
|
14814
14975
|
const trackedImageStyle = trackedInlineChange?.kind === "insertion" || trackedInlineChange?.kind === "move-to" ? {
|
|
14815
|
-
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)",
|
|
14816
14977
|
outlineOffset: 1
|
|
14817
14978
|
} : void 0;
|
|
14818
14979
|
const renderableImageSrc = syntheticTextBoxSvg(
|
|
@@ -14998,6 +15159,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
14998
15159
|
),
|
|
14999
15160
|
...currentCommentHighlightStyle()
|
|
15000
15161
|
};
|
|
15162
|
+
const annotationAttributes = currentAnnotationAttributes(trackedInlineChange);
|
|
15001
15163
|
const noteLabel = noteMarkerLabel(
|
|
15002
15164
|
child.noteReference,
|
|
15003
15165
|
safeNoteMarkerIndexes.footnote,
|
|
@@ -15008,6 +15170,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15008
15170
|
/* @__PURE__ */ jsx(
|
|
15009
15171
|
"span",
|
|
15010
15172
|
{
|
|
15173
|
+
...annotationAttributes,
|
|
15011
15174
|
style: {
|
|
15012
15175
|
...textStyle,
|
|
15013
15176
|
verticalAlign: "super",
|
|
@@ -15023,7 +15186,15 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15023
15186
|
}
|
|
15024
15187
|
if ((textOverride ?? child.text) === " " && !useTabLeaderLayout && !useAnchoredTabLayout) {
|
|
15025
15188
|
target.push(
|
|
15026
|
-
/* @__PURE__ */ jsx(
|
|
15189
|
+
/* @__PURE__ */ jsx(
|
|
15190
|
+
"span",
|
|
15191
|
+
{
|
|
15192
|
+
...annotationAttributes,
|
|
15193
|
+
style: tabTextStyle(child.style, textStyle),
|
|
15194
|
+
children: "\xA0"
|
|
15195
|
+
},
|
|
15196
|
+
key
|
|
15197
|
+
)
|
|
15027
15198
|
);
|
|
15028
15199
|
return;
|
|
15029
15200
|
}
|
|
@@ -15034,6 +15205,7 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15034
15205
|
/* @__PURE__ */ jsx(
|
|
15035
15206
|
"a",
|
|
15036
15207
|
{
|
|
15208
|
+
...annotationAttributes,
|
|
15037
15209
|
href: linkHref,
|
|
15038
15210
|
target: isInternalLink ? void 0 : "_blank",
|
|
15039
15211
|
rel: isInternalLink ? void 0 : "noreferrer noopener",
|
|
@@ -15066,7 +15238,8 @@ function renderParagraphRuns(paragraph, keyPrefix, documentTheme = "light", numb
|
|
|
15066
15238
|
key,
|
|
15067
15239
|
textOverride ?? child.text,
|
|
15068
15240
|
textStyle,
|
|
15069
|
-
child.style
|
|
15241
|
+
child.style,
|
|
15242
|
+
annotationAttributes
|
|
15070
15243
|
);
|
|
15071
15244
|
};
|
|
15072
15245
|
const anchoredTabZoneStyle = {
|
|
@@ -17777,6 +17950,7 @@ function collectTrackedChangesFromModel(model) {
|
|
|
17777
17950
|
trackedMarkup.changes.forEach((change, changeIndex) => {
|
|
17778
17951
|
trackedChanges.push({
|
|
17779
17952
|
id: `${paragraphLocationKey(location)}:${change.id}:${changeIndex}`,
|
|
17953
|
+
inlineAnchorId: change.id,
|
|
17780
17954
|
kind: change.kind,
|
|
17781
17955
|
author: change.author,
|
|
17782
17956
|
date: change.date,
|
|
@@ -17955,13 +18129,42 @@ function collectCommentsFromModel(model) {
|
|
|
17955
18129
|
});
|
|
17956
18130
|
return comments;
|
|
17957
18131
|
}
|
|
17958
|
-
function
|
|
17959
|
-
|
|
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
|
+
};
|
|
17960
18163
|
}
|
|
17961
18164
|
function estimateCommentCardHeight(comment) {
|
|
17962
18165
|
const snippet = comment.text || "Comment";
|
|
17963
|
-
const lines = Math.max(1, Math.ceil(snippet.length /
|
|
17964
|
-
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);
|
|
17965
18168
|
}
|
|
17966
18169
|
function trackedChangeKindLabel(kind) {
|
|
17967
18170
|
switch (kind) {
|
|
@@ -17983,16 +18186,16 @@ function trackedChangeKindLabel(kind) {
|
|
|
17983
18186
|
}
|
|
17984
18187
|
function trackedChangeAccentColor(kind, documentTheme) {
|
|
17985
18188
|
const palette = documentTheme === "dark" ? {
|
|
17986
|
-
insertion: "#
|
|
18189
|
+
insertion: "#f87171",
|
|
17987
18190
|
deletion: "#f87171",
|
|
17988
|
-
moveFrom: "#
|
|
17989
|
-
moveTo: "#
|
|
18191
|
+
moveFrom: "#86efac",
|
|
18192
|
+
moveTo: "#86efac",
|
|
17990
18193
|
format: "#c084fc"
|
|
17991
18194
|
} : {
|
|
17992
|
-
insertion: "#
|
|
18195
|
+
insertion: "#dc2626",
|
|
17993
18196
|
deletion: "#dc2626",
|
|
17994
|
-
moveFrom: "#
|
|
17995
|
-
moveTo: "#
|
|
18197
|
+
moveFrom: "#70ad47",
|
|
18198
|
+
moveTo: "#70ad47",
|
|
17996
18199
|
format: "#7c3aed"
|
|
17997
18200
|
};
|
|
17998
18201
|
switch (kind) {
|
|
@@ -18011,6 +18214,9 @@ function trackedChangeAccentColor(kind, documentTheme) {
|
|
|
18011
18214
|
return palette.format;
|
|
18012
18215
|
}
|
|
18013
18216
|
}
|
|
18217
|
+
function trackedChangeUsesGutterBalloon(change) {
|
|
18218
|
+
return change.kind !== "insertion" && change.kind !== "move-to";
|
|
18219
|
+
}
|
|
18014
18220
|
function gutterAnnotationSortTuple(location) {
|
|
18015
18221
|
if (location.kind === "paragraph") {
|
|
18016
18222
|
return [location.nodeIndex, 0, 0, 0];
|
|
@@ -18091,10 +18297,92 @@ function elementRectWithinContainer(element, container) {
|
|
|
18091
18297
|
height: elementRect.height / scaleY
|
|
18092
18298
|
};
|
|
18093
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
|
+
}
|
|
18094
18382
|
function estimateTrackedChangeCardHeight(change) {
|
|
18095
18383
|
const snippet = normalizeTrackedChangeSnippet(change.text) ?? trackedChangeKindLabel(change.kind);
|
|
18096
|
-
const lines = Math.max(1, Math.ceil(snippet.length /
|
|
18097
|
-
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);
|
|
18098
18386
|
}
|
|
18099
18387
|
function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsByChangeId, pageWidthPx, pageHeightPx) {
|
|
18100
18388
|
if (annotations.length === 0) {
|
|
@@ -18134,11 +18422,21 @@ function layoutTrackedChangesForPage(annotations, anchorByChangeId, cardHeightsB
|
|
|
18134
18422
|
heightPx
|
|
18135
18423
|
};
|
|
18136
18424
|
});
|
|
18137
|
-
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
|
+
});
|
|
18138
18436
|
const minTopPx = 8;
|
|
18139
18437
|
let cursorTopPx = minTopPx;
|
|
18140
18438
|
withAnchors.forEach((entry) => {
|
|
18141
|
-
const desiredTop = entry.anchorY -
|
|
18439
|
+
const desiredTop = entry.anchorY - 8;
|
|
18142
18440
|
entry.top = Math.max(desiredTop, cursorTopPx);
|
|
18143
18441
|
cursorTopPx = entry.top + entry.heightPx + TRACKED_CHANGE_GUTTER_CARD_GAP_PX;
|
|
18144
18442
|
});
|
|
@@ -23020,7 +23318,7 @@ function docxThumbnailTextRunsFromParagraph(paragraph, documentTheme, maxChars =
|
|
|
23020
23318
|
return;
|
|
23021
23319
|
}
|
|
23022
23320
|
const style = child.type === "text" || child.type === "form-field" ? child.style : void 0;
|
|
23023
|
-
const text = child.type === "text" ? child.text : child.type === "form-field" ? formFieldDisplayValue2(child) :
|
|
23321
|
+
const text = child.type === "text" ? child.text : child.type === "form-field" ? formFieldDisplayValue2(child) : "";
|
|
23024
23322
|
appendDocxThumbnailTextRun(
|
|
23025
23323
|
runs,
|
|
23026
23324
|
{
|
|
@@ -23111,13 +23409,29 @@ function buildDocxThumbnailParagraphElements(params) {
|
|
|
23111
23409
|
(widthPx - 4) / imageWidthPx,
|
|
23112
23410
|
(bodyHeightPx - 4) / imageHeightPx
|
|
23113
23411
|
);
|
|
23114
|
-
|
|
23115
|
-
|
|
23116
|
-
|
|
23117
|
-
|
|
23118
|
-
|
|
23119
|
-
|
|
23120
|
-
|
|
23412
|
+
const elementXPx = xPx + 2;
|
|
23413
|
+
const elementYPx = bodyYPx + 2;
|
|
23414
|
+
const elementWidthPx = Math.max(12, imageWidthPx * scale);
|
|
23415
|
+
const elementHeightPx = Math.max(12, imageHeightPx * scale);
|
|
23416
|
+
const renderableSrc = resolveRenderableImageSource(imageRun);
|
|
23417
|
+
if (renderableSrc) {
|
|
23418
|
+
elements.push({
|
|
23419
|
+
kind: "image",
|
|
23420
|
+
xPx: elementXPx,
|
|
23421
|
+
yPx: elementYPx,
|
|
23422
|
+
widthPx: elementWidthPx,
|
|
23423
|
+
heightPx: elementHeightPx,
|
|
23424
|
+
src: renderableSrc
|
|
23425
|
+
});
|
|
23426
|
+
} else {
|
|
23427
|
+
elements.push({
|
|
23428
|
+
kind: "image-placeholder",
|
|
23429
|
+
xPx: elementXPx,
|
|
23430
|
+
yPx: elementYPx,
|
|
23431
|
+
widthPx: elementWidthPx,
|
|
23432
|
+
heightPx: elementHeightPx
|
|
23433
|
+
});
|
|
23434
|
+
}
|
|
23121
23435
|
});
|
|
23122
23436
|
}
|
|
23123
23437
|
return elements;
|
|
@@ -23216,6 +23530,24 @@ function buildDocxThumbnailTableElement(params) {
|
|
|
23216
23530
|
cells
|
|
23217
23531
|
};
|
|
23218
23532
|
}
|
|
23533
|
+
function docxThumbnailNodeRequiresDomRaster(node) {
|
|
23534
|
+
if (!node) {
|
|
23535
|
+
return false;
|
|
23536
|
+
}
|
|
23537
|
+
if (node.type === "paragraph") {
|
|
23538
|
+
return node.children.some((child) => child.type === "image");
|
|
23539
|
+
}
|
|
23540
|
+
return node.rows.some(
|
|
23541
|
+
(row) => row.cells.some(
|
|
23542
|
+
(cell) => cell.nodes.some((cellNode) => docxThumbnailNodeRequiresDomRaster(cellNode))
|
|
23543
|
+
)
|
|
23544
|
+
);
|
|
23545
|
+
}
|
|
23546
|
+
function docxThumbnailPageRequiresDomRaster(model, pageSegments) {
|
|
23547
|
+
return pageSegments.some(
|
|
23548
|
+
(segment) => docxThumbnailNodeRequiresDomRaster(model.nodes[segment.nodeIndex])
|
|
23549
|
+
);
|
|
23550
|
+
}
|
|
23219
23551
|
function buildDocxPageThumbnailRenderSnapshotEntries(params) {
|
|
23220
23552
|
const {
|
|
23221
23553
|
model,
|
|
@@ -23228,6 +23560,9 @@ function buildDocxPageThumbnailRenderSnapshotEntries(params) {
|
|
|
23228
23560
|
numberingDefinitions
|
|
23229
23561
|
} = params;
|
|
23230
23562
|
return pageNodeSegmentsByPage.map((pageSegments, pageIndex) => {
|
|
23563
|
+
if (docxThumbnailPageRequiresDomRaster(model, pageSegments)) {
|
|
23564
|
+
return void 0;
|
|
23565
|
+
}
|
|
23231
23566
|
const key = `${contentKeysByPage[pageIndex] ?? ""}|theme:${documentTheme}`;
|
|
23232
23567
|
let cachedSnapshot;
|
|
23233
23568
|
return {
|
|
@@ -23674,7 +24009,7 @@ function useDocxPageThumbnails(editor, options = {}) {
|
|
|
23674
24009
|
if (!surface) {
|
|
23675
24010
|
const thumbnailSnapshot = thumbnailSnapshotEntry?.getSnapshot();
|
|
23676
24011
|
if (thumbnailSnapshot) {
|
|
23677
|
-
surface = renderDocxThumbnailSnapshotSurface({
|
|
24012
|
+
surface = await renderDocxThumbnailSnapshotSurface({
|
|
23678
24013
|
snapshot: thumbnailSnapshot,
|
|
23679
24014
|
widthPx: resolution.widthPx,
|
|
23680
24015
|
heightPx: resolution.heightPx,
|
|
@@ -27284,6 +27619,9 @@ function DocxEditorViewer({
|
|
|
27284
27619
|
};
|
|
27285
27620
|
if (trackedChangesEnabled) {
|
|
27286
27621
|
editor.trackedChanges.forEach((change) => {
|
|
27622
|
+
if (!trackedChangeUsesGutterBalloon(change)) {
|
|
27623
|
+
return;
|
|
27624
|
+
}
|
|
27287
27625
|
placeAnnotation({
|
|
27288
27626
|
id: change.id,
|
|
27289
27627
|
location: change.location,
|
|
@@ -27334,45 +27672,45 @@ function DocxEditorViewer({
|
|
|
27334
27672
|
);
|
|
27335
27673
|
return;
|
|
27336
27674
|
}
|
|
27337
|
-
const nextAnchorMaps = trackedChangesByPage.map(
|
|
27338
|
-
|
|
27339
|
-
|
|
27340
|
-
|
|
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
|
+
});
|
|
27341
27711
|
return anchorsByChangeId;
|
|
27342
27712
|
}
|
|
27343
|
-
|
|
27344
|
-
const pageWidthPx = Math.max(1, pageElement.offsetWidth);
|
|
27345
|
-
annotations.forEach((annotation) => {
|
|
27346
|
-
const anchorElement = findTrackedChangeAnchorElementInPage(
|
|
27347
|
-
pageElement,
|
|
27348
|
-
annotation.location
|
|
27349
|
-
);
|
|
27350
|
-
if (!anchorElement) {
|
|
27351
|
-
return;
|
|
27352
|
-
}
|
|
27353
|
-
const anchorRect = elementRectWithinContainer(
|
|
27354
|
-
anchorElement,
|
|
27355
|
-
pageElement
|
|
27356
|
-
);
|
|
27357
|
-
if (!anchorRect) {
|
|
27358
|
-
return;
|
|
27359
|
-
}
|
|
27360
|
-
const anchorY = clampNumber(
|
|
27361
|
-
Math.round(anchorRect.top + anchorRect.height / 2),
|
|
27362
|
-
10,
|
|
27363
|
-
Math.max(10, pageHeightPx - 10)
|
|
27364
|
-
);
|
|
27365
|
-
const anchorX = clampNumber(
|
|
27366
|
-
Math.round(
|
|
27367
|
-
anchorRect.left + Math.min(24, Math.max(8, anchorRect.width * 0.2))
|
|
27368
|
-
),
|
|
27369
|
-
10,
|
|
27370
|
-
Math.max(10, pageWidthPx - 10)
|
|
27371
|
-
);
|
|
27372
|
-
anchorsByChangeId.set(annotation.id, { x: anchorX, y: anchorY });
|
|
27373
|
-
});
|
|
27374
|
-
return anchorsByChangeId;
|
|
27375
|
-
});
|
|
27713
|
+
);
|
|
27376
27714
|
setTrackedChangeAnchorByPage(nextAnchorMaps);
|
|
27377
27715
|
}, [
|
|
27378
27716
|
trackedChangesByPage,
|
|
@@ -41223,6 +41561,7 @@ ${currentText.slice(end)}`;
|
|
|
41223
41561
|
});
|
|
41224
41562
|
const headerFooterBodyDimmed = pageHeaderFooterEditActive;
|
|
41225
41563
|
const documentPageBackgroundColor = editor.model.metadata.documentBackgroundColor;
|
|
41564
|
+
const resolvedPageSurfaceBackgroundColor = pageBackgroundColor ?? documentPageBackgroundColor ?? pageSurfaceBaseStyle.backgroundColor;
|
|
41226
41565
|
const pageBorders = parseSectionPageBorders(
|
|
41227
41566
|
pageInfo?.section.sectionPropertiesXml ?? editor.model.metadata.sectionPropertiesXml
|
|
41228
41567
|
);
|
|
@@ -41245,7 +41584,7 @@ ${currentText.slice(end)}`;
|
|
|
41245
41584
|
width: pageLayout.pageWidthPx,
|
|
41246
41585
|
height: pageLayout.pageHeightPx,
|
|
41247
41586
|
minHeight: pageLayout.pageHeightPx,
|
|
41248
|
-
backgroundColor:
|
|
41587
|
+
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
41249
41588
|
position: "relative",
|
|
41250
41589
|
...pageMarginPaddingStyle(pageLayout.marginsPx)
|
|
41251
41590
|
};
|
|
@@ -42347,6 +42686,7 @@ ${currentText.slice(end)}`;
|
|
|
42347
42686
|
top: 0,
|
|
42348
42687
|
width: TRACKED_CHANGE_GUTTER_WIDTH_PX,
|
|
42349
42688
|
height: pageLayout.pageHeightPx,
|
|
42689
|
+
backgroundColor: resolvedPageSurfaceBackgroundColor,
|
|
42350
42690
|
pointerEvents: "none",
|
|
42351
42691
|
overflow: "visible"
|
|
42352
42692
|
},
|
|
@@ -42377,14 +42717,14 @@ ${currentText.slice(end)}`;
|
|
|
42377
42717
|
overflow: "visible"
|
|
42378
42718
|
},
|
|
42379
42719
|
children: pageTrackedChanges.map((entry) => {
|
|
42380
|
-
const
|
|
42381
|
-
|
|
42720
|
+
const trackedChange = entry.annotation.trackedChange;
|
|
42721
|
+
const comment = entry.annotation.comment;
|
|
42722
|
+
const accentColor = trackedChange ? trackedChangeAccentColor(
|
|
42723
|
+
trackedChange.kind,
|
|
42382
42724
|
editor.documentTheme
|
|
42383
|
-
) : commentAccentColor(
|
|
42384
|
-
|
|
42385
|
-
|
|
42386
|
-
8,
|
|
42387
|
-
Math.max(8, pageLayout.pageHeightPx - 8)
|
|
42725
|
+
) : commentAccentColor(
|
|
42726
|
+
editor.documentTheme,
|
|
42727
|
+
comment?.commentId
|
|
42388
42728
|
);
|
|
42389
42729
|
const anchorY = clampNumber(
|
|
42390
42730
|
Math.round(entry.anchorY),
|
|
@@ -42396,48 +42736,50 @@ ${currentText.slice(end)}`;
|
|
|
42396
42736
|
8,
|
|
42397
42737
|
Math.max(8, pageLayout.pageWidthPx - 8)
|
|
42398
42738
|
);
|
|
42399
|
-
const
|
|
42400
|
-
const
|
|
42401
|
-
|
|
42402
|
-
|
|
42403
|
-
|
|
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)
|
|
42404
42751
|
);
|
|
42405
42752
|
return /* @__PURE__ */ jsxs(
|
|
42406
42753
|
"g",
|
|
42407
42754
|
{
|
|
42408
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,
|
|
42409
42771
|
/* @__PURE__ */ jsx(
|
|
42410
42772
|
"path",
|
|
42411
42773
|
{
|
|
42412
|
-
d:
|
|
42774
|
+
d: connectorPath,
|
|
42413
42775
|
stroke: accentColor,
|
|
42414
|
-
strokeWidth: 1.
|
|
42415
|
-
strokeOpacity:
|
|
42416
|
-
strokeDasharray: "
|
|
42776
|
+
strokeWidth: 1.15,
|
|
42777
|
+
strokeOpacity: 0.78,
|
|
42778
|
+
strokeDasharray: "2 3",
|
|
42417
42779
|
strokeLinejoin: "round",
|
|
42418
42780
|
strokeLinecap: "round",
|
|
42419
42781
|
fill: "none"
|
|
42420
42782
|
}
|
|
42421
|
-
),
|
|
42422
|
-
/* @__PURE__ */ jsx(
|
|
42423
|
-
"circle",
|
|
42424
|
-
{
|
|
42425
|
-
cx: anchorX,
|
|
42426
|
-
cy: anchorY,
|
|
42427
|
-
r: 2.2,
|
|
42428
|
-
fill: accentColor,
|
|
42429
|
-
stroke: editor.documentTheme === "dark" ? "#020617" : "#ffffff",
|
|
42430
|
-
strokeWidth: 1
|
|
42431
|
-
}
|
|
42432
|
-
),
|
|
42433
|
-
/* @__PURE__ */ jsx(
|
|
42434
|
-
"circle",
|
|
42435
|
-
{
|
|
42436
|
-
cx: cardLeadX,
|
|
42437
|
-
cy: cardCenterY,
|
|
42438
|
-
r: 1.8,
|
|
42439
|
-
fill: accentColor
|
|
42440
|
-
}
|
|
42441
42783
|
)
|
|
42442
42784
|
]
|
|
42443
42785
|
},
|
|
@@ -42468,7 +42810,10 @@ ${currentText.slice(end)}`;
|
|
|
42468
42810
|
const accentColor = trackedChange ? trackedChangeAccentColor(
|
|
42469
42811
|
trackedChange.kind,
|
|
42470
42812
|
editor.documentTheme
|
|
42471
|
-
) : commentAccentColor(
|
|
42813
|
+
) : commentAccentColor(
|
|
42814
|
+
editor.documentTheme,
|
|
42815
|
+
comment?.commentId
|
|
42816
|
+
);
|
|
42472
42817
|
const formattedDate = formatTrackedChangeDate(
|
|
42473
42818
|
trackedChange?.date ?? comment?.date
|
|
42474
42819
|
);
|
|
@@ -42495,15 +42840,15 @@ ${currentText.slice(end)}`;
|
|
|
42495
42840
|
{
|
|
42496
42841
|
style: {
|
|
42497
42842
|
...cardStyle,
|
|
42498
|
-
padding: "6px
|
|
42843
|
+
padding: "4px 6px",
|
|
42499
42844
|
boxSizing: "border-box",
|
|
42500
|
-
borderLeft: `
|
|
42501
|
-
borderTop: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.
|
|
42502
|
-
borderRight: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.
|
|
42503
|
-
borderBottom: `1px solid ${editor.documentTheme === "dark" ? "rgba(148, 163, 184, 0.
|
|
42504
|
-
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)",
|
|
42505
42850
|
color: editor.documentTheme === "dark" ? "#f3f4f6" : "#111827",
|
|
42506
|
-
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)"
|
|
42507
42852
|
},
|
|
42508
42853
|
children: [
|
|
42509
42854
|
/* @__PURE__ */ jsxs(
|
|
@@ -42521,9 +42866,9 @@ ${currentText.slice(end)}`;
|
|
|
42521
42866
|
{
|
|
42522
42867
|
style: {
|
|
42523
42868
|
margin: 0,
|
|
42524
|
-
fontSize:
|
|
42869
|
+
fontSize: 10,
|
|
42525
42870
|
fontWeight: 700,
|
|
42526
|
-
lineHeight: 1.
|
|
42871
|
+
lineHeight: 1.2
|
|
42527
42872
|
},
|
|
42528
42873
|
children: (trackedChange?.author ?? comment?.author)?.trim() || "Unknown author"
|
|
42529
42874
|
}
|
|
@@ -42533,8 +42878,8 @@ ${currentText.slice(end)}`;
|
|
|
42533
42878
|
{
|
|
42534
42879
|
style: {
|
|
42535
42880
|
margin: 0,
|
|
42536
|
-
fontSize:
|
|
42537
|
-
lineHeight: 1.
|
|
42881
|
+
fontSize: 9,
|
|
42882
|
+
lineHeight: 1.15,
|
|
42538
42883
|
color: editor.documentTheme === "dark" ? "#94a3b8" : "#6b7280",
|
|
42539
42884
|
whiteSpace: "nowrap"
|
|
42540
42885
|
},
|
|
@@ -42549,8 +42894,8 @@ ${currentText.slice(end)}`;
|
|
|
42549
42894
|
{
|
|
42550
42895
|
style: {
|
|
42551
42896
|
margin: "2px 0 0",
|
|
42552
|
-
fontSize:
|
|
42553
|
-
lineHeight: 1.
|
|
42897
|
+
fontSize: 9,
|
|
42898
|
+
lineHeight: 1.25,
|
|
42554
42899
|
fontStyle: "italic",
|
|
42555
42900
|
color: editor.documentTheme === "dark" ? "#94a3b8" : "#6b7280"
|
|
42556
42901
|
},
|
|
@@ -42566,8 +42911,8 @@ ${currentText.slice(end)}`;
|
|
|
42566
42911
|
{
|
|
42567
42912
|
style: {
|
|
42568
42913
|
margin: "2px 0 0",
|
|
42569
|
-
fontSize:
|
|
42570
|
-
lineHeight: 1.
|
|
42914
|
+
fontSize: 10,
|
|
42915
|
+
lineHeight: 1.25
|
|
42571
42916
|
},
|
|
42572
42917
|
children: [
|
|
42573
42918
|
/* @__PURE__ */ jsxs("strong", { children: [
|
|
@@ -42604,6 +42949,9 @@ ${currentText.slice(end)}`;
|
|
|
42604
42949
|
"div",
|
|
42605
42950
|
{
|
|
42606
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),
|
|
42607
42955
|
ref: (element) => {
|
|
42608
42956
|
const elementKey = `${pageIndex}:${entry.annotation.id}`;
|
|
42609
42957
|
if (element) {
|
|
@@ -44857,7 +45205,7 @@ export {
|
|
|
44857
45205
|
defaultStarterModel,
|
|
44858
45206
|
duplicateParagraph,
|
|
44859
45207
|
getPart,
|
|
44860
|
-
initWasm,
|
|
45208
|
+
initWasm2 as initWasm,
|
|
44861
45209
|
insertParagraph,
|
|
44862
45210
|
layoutDocument,
|
|
44863
45211
|
modelToDocumentXml,
|
|
@@ -44899,7 +45247,7 @@ export {
|
|
|
44899
45247
|
setParagraphHeading,
|
|
44900
45248
|
setRunColor,
|
|
44901
45249
|
setRunHighlight,
|
|
44902
|
-
setWasmSource,
|
|
45250
|
+
setWasmSource2 as setWasmSource,
|
|
44903
45251
|
splitParagraphChildrenAtTextOffsets,
|
|
44904
45252
|
toggleRunStyleFlag,
|
|
44905
45253
|
updateParagraphText,
|