@superdoc-dev/cli 0.5.0-next.30 → 0.5.0-next.31
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.js +556 -556
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -172583,7 +172583,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
|
|
|
172583
172583
|
init_remark_gfm_z_sDF4ss_es();
|
|
172584
172584
|
});
|
|
172585
172585
|
|
|
172586
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
172586
|
+
// ../../packages/superdoc/dist/chunks/src-CVvmm9fW.es.js
|
|
172587
172587
|
function deleteProps(obj, propOrProps) {
|
|
172588
172588
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
172589
172589
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -172876,6 +172876,18 @@ function normalizeZIndex(originalAttributes) {
|
|
|
172876
172876
|
return;
|
|
172877
172877
|
return Math.max(0, relativeHeight - OOXML_Z_INDEX_BASE);
|
|
172878
172878
|
}
|
|
172879
|
+
function resolveFloatingZIndex(behindDoc, raw, fallback = 1) {
|
|
172880
|
+
if (behindDoc)
|
|
172881
|
+
return 0;
|
|
172882
|
+
if (raw === undefined)
|
|
172883
|
+
return Math.max(1, fallback);
|
|
172884
|
+
return Math.max(1, raw);
|
|
172885
|
+
}
|
|
172886
|
+
function getFragmentZIndex(block) {
|
|
172887
|
+
const attrs = block.attrs;
|
|
172888
|
+
const raw = typeof block.zIndex === "number" ? block.zIndex : normalizeZIndex(attrs?.originalAttributes);
|
|
172889
|
+
return resolveFloatingZIndex(block.anchor?.behindDoc === true, raw);
|
|
172890
|
+
}
|
|
172879
172891
|
function shouldApplyJustify(params$1) {
|
|
172880
172892
|
const { alignment: alignment$1, hasExplicitPositioning, isLastLineOfParagraph, paragraphEndsWithLineBreak, skipJustifyOverride } = params$1;
|
|
172881
172893
|
if (alignment$1 !== "justify" && alignment$1 !== "both")
|
|
@@ -214281,431 +214293,6 @@ function sliceLines(lines, startIndex, availableHeight) {
|
|
|
214281
214293
|
function shouldSuppressOwnSpacing(ownStyleId, ownContextualSpacing, adjacentStyleId) {
|
|
214282
214294
|
return ownContextualSpacing && !!ownStyleId && !!adjacentStyleId && ownStyleId === adjacentStyleId;
|
|
214283
214295
|
}
|
|
214284
|
-
function coerceNumber(value) {
|
|
214285
|
-
if (isFiniteNumber(value))
|
|
214286
|
-
return Number(value);
|
|
214287
|
-
if (typeof value === "string" && value.trim() !== "") {
|
|
214288
|
-
const parsed = Number(value);
|
|
214289
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
214290
|
-
}
|
|
214291
|
-
}
|
|
214292
|
-
function coercePositiveNumber(value, fallback) {
|
|
214293
|
-
if (!isFiniteNumber(fallback) || fallback <= 0)
|
|
214294
|
-
throw new Error(`coercePositiveNumber: fallback must be a positive number, got ${fallback}`);
|
|
214295
|
-
const numeric = coerceNumber(value);
|
|
214296
|
-
if (numeric != null && numeric > 0)
|
|
214297
|
-
return numeric;
|
|
214298
|
-
return fallback;
|
|
214299
|
-
}
|
|
214300
|
-
function coerceBoolean(value) {
|
|
214301
|
-
if (typeof value === "boolean")
|
|
214302
|
-
return value;
|
|
214303
|
-
if (typeof value === "number") {
|
|
214304
|
-
if (value === 1)
|
|
214305
|
-
return true;
|
|
214306
|
-
if (value === 0)
|
|
214307
|
-
return false;
|
|
214308
|
-
return;
|
|
214309
|
-
}
|
|
214310
|
-
if (typeof value === "string") {
|
|
214311
|
-
const normalized = value.trim().toLowerCase();
|
|
214312
|
-
if ([
|
|
214313
|
-
"true",
|
|
214314
|
-
"1",
|
|
214315
|
-
"yes",
|
|
214316
|
-
"on"
|
|
214317
|
-
].includes(normalized))
|
|
214318
|
-
return true;
|
|
214319
|
-
if ([
|
|
214320
|
-
"false",
|
|
214321
|
-
"0",
|
|
214322
|
-
"no",
|
|
214323
|
-
"off"
|
|
214324
|
-
].includes(normalized))
|
|
214325
|
-
return false;
|
|
214326
|
-
}
|
|
214327
|
-
}
|
|
214328
|
-
function toBoxSpacing(spacing) {
|
|
214329
|
-
if (!spacing)
|
|
214330
|
-
return;
|
|
214331
|
-
const result = {};
|
|
214332
|
-
[
|
|
214333
|
-
"top",
|
|
214334
|
-
"right",
|
|
214335
|
-
"bottom",
|
|
214336
|
-
"left"
|
|
214337
|
-
].forEach((side) => {
|
|
214338
|
-
const value = spacing[side];
|
|
214339
|
-
if (isFiniteNumber(value))
|
|
214340
|
-
result[side] = Number(value);
|
|
214341
|
-
});
|
|
214342
|
-
return Object.keys(result).length > 0 ? result : undefined;
|
|
214343
|
-
}
|
|
214344
|
-
function normalizeCellPaddingTopBottom(padding) {
|
|
214345
|
-
const out = { ...padding };
|
|
214346
|
-
if (typeof out.top === "number" && out.top > 0 && out.top < MIN_TOP_BOTTOM_CELL_PADDING_PX)
|
|
214347
|
-
out.top = MIN_TOP_BOTTOM_CELL_PADDING_PX;
|
|
214348
|
-
if (typeof out.bottom === "number" && out.bottom > 0 && out.bottom < MIN_TOP_BOTTOM_CELL_PADDING_PX)
|
|
214349
|
-
out.bottom = MIN_TOP_BOTTOM_CELL_PADDING_PX;
|
|
214350
|
-
return out;
|
|
214351
|
-
}
|
|
214352
|
-
function toDrawingContentSnapshot(value) {
|
|
214353
|
-
if (!value || typeof value !== "object")
|
|
214354
|
-
return;
|
|
214355
|
-
const raw = value;
|
|
214356
|
-
const name = raw.name;
|
|
214357
|
-
if (typeof name !== "string")
|
|
214358
|
-
return;
|
|
214359
|
-
const snapshot2 = { name };
|
|
214360
|
-
if (raw.attributes && typeof raw.attributes === "object" && !Array.isArray(raw.attributes))
|
|
214361
|
-
snapshot2.attributes = { ...raw.attributes };
|
|
214362
|
-
if (Array.isArray(raw.elements)) {
|
|
214363
|
-
const validElements = raw.elements.filter((el) => el != null && typeof el === "object");
|
|
214364
|
-
if (validElements.length > 0)
|
|
214365
|
-
snapshot2.elements = validElements;
|
|
214366
|
-
}
|
|
214367
|
-
return snapshot2;
|
|
214368
|
-
}
|
|
214369
|
-
function isShapeGroupTransform(value) {
|
|
214370
|
-
if (!value || typeof value !== "object")
|
|
214371
|
-
return false;
|
|
214372
|
-
const maybe = value;
|
|
214373
|
-
return isFiniteNumber(maybe.x) || isFiniteNumber(maybe.y) || isFiniteNumber(maybe.width) || isFiniteNumber(maybe.height) || isFiniteNumber(maybe.childWidth) || isFiniteNumber(maybe.childHeight) || isFiniteNumber(maybe.childX) || isFiniteNumber(maybe.childY);
|
|
214374
|
-
}
|
|
214375
|
-
function normalizeShapeSize(value) {
|
|
214376
|
-
if (!value || typeof value !== "object")
|
|
214377
|
-
return;
|
|
214378
|
-
const maybe = value;
|
|
214379
|
-
const width = coerceNumber(maybe.width);
|
|
214380
|
-
const height = coerceNumber(maybe.height);
|
|
214381
|
-
if (width == null && height == null)
|
|
214382
|
-
return;
|
|
214383
|
-
const result = {};
|
|
214384
|
-
if (width != null)
|
|
214385
|
-
result.width = width;
|
|
214386
|
-
if (height != null)
|
|
214387
|
-
result.height = height;
|
|
214388
|
-
return result;
|
|
214389
|
-
}
|
|
214390
|
-
function normalizeLineEnds(value) {
|
|
214391
|
-
if (!value || typeof value !== "object")
|
|
214392
|
-
return;
|
|
214393
|
-
const maybe = value;
|
|
214394
|
-
const head = normalizeLineEnd(maybe.head);
|
|
214395
|
-
const tail = normalizeLineEnd(maybe.tail);
|
|
214396
|
-
if (!head && !tail)
|
|
214397
|
-
return;
|
|
214398
|
-
return {
|
|
214399
|
-
head,
|
|
214400
|
-
tail
|
|
214401
|
-
};
|
|
214402
|
-
}
|
|
214403
|
-
function normalizeEffectExtent(value) {
|
|
214404
|
-
if (!value || typeof value !== "object")
|
|
214405
|
-
return;
|
|
214406
|
-
const maybe = value;
|
|
214407
|
-
const left$1 = coerceNumber(maybe.left);
|
|
214408
|
-
const top$1 = coerceNumber(maybe.top);
|
|
214409
|
-
const right$1 = coerceNumber(maybe.right);
|
|
214410
|
-
const bottom$1 = coerceNumber(maybe.bottom);
|
|
214411
|
-
if (left$1 == null && top$1 == null && right$1 == null && bottom$1 == null)
|
|
214412
|
-
return;
|
|
214413
|
-
const clamp$2 = (val) => val != null && val > 0 ? val : 0;
|
|
214414
|
-
return {
|
|
214415
|
-
left: clamp$2(left$1),
|
|
214416
|
-
top: clamp$2(top$1),
|
|
214417
|
-
right: clamp$2(right$1),
|
|
214418
|
-
bottom: clamp$2(bottom$1)
|
|
214419
|
-
};
|
|
214420
|
-
}
|
|
214421
|
-
function normalizeShapeGroupChildren(value) {
|
|
214422
|
-
if (!Array.isArray(value))
|
|
214423
|
-
return [];
|
|
214424
|
-
return value.filter((child) => {
|
|
214425
|
-
if (!child || typeof child !== "object")
|
|
214426
|
-
return false;
|
|
214427
|
-
return typeof child.shapeType === "string";
|
|
214428
|
-
});
|
|
214429
|
-
}
|
|
214430
|
-
function normalizeMediaKey(value) {
|
|
214431
|
-
if (!value)
|
|
214432
|
-
return;
|
|
214433
|
-
return value.replace(/\\/g, "/").replace(/^(\.\/|\/)+/, "");
|
|
214434
|
-
}
|
|
214435
|
-
function inferExtensionFromPath(value) {
|
|
214436
|
-
if (!value)
|
|
214437
|
-
return;
|
|
214438
|
-
const fileName = value.split("/").pop()?.split("\\").pop();
|
|
214439
|
-
if (!fileName || fileName.startsWith("."))
|
|
214440
|
-
return;
|
|
214441
|
-
const parts = fileName.split(".");
|
|
214442
|
-
if (parts.length < 2)
|
|
214443
|
-
return;
|
|
214444
|
-
const ext = parts.at(-1);
|
|
214445
|
-
if (!ext || ext.length === 0)
|
|
214446
|
-
return;
|
|
214447
|
-
return ext.toLowerCase();
|
|
214448
|
-
}
|
|
214449
|
-
function hydrateImageBlocks(blocks2, mediaFiles) {
|
|
214450
|
-
if (!mediaFiles || Object.keys(mediaFiles).length === 0)
|
|
214451
|
-
return blocks2;
|
|
214452
|
-
const normalizedMedia = /* @__PURE__ */ new Map;
|
|
214453
|
-
Object.entries(mediaFiles).forEach(([key$1, value]) => {
|
|
214454
|
-
const normalized = normalizeMediaKey(key$1);
|
|
214455
|
-
if (normalized) {
|
|
214456
|
-
const stringValue = value instanceof Uint8Array ? new TextDecoder().decode(value) : value;
|
|
214457
|
-
normalizedMedia.set(normalized, stringValue);
|
|
214458
|
-
}
|
|
214459
|
-
});
|
|
214460
|
-
if (normalizedMedia.size === 0)
|
|
214461
|
-
return blocks2;
|
|
214462
|
-
const resolveImageSrc = (src, relId, attrSrc, extension2) => {
|
|
214463
|
-
if (!src || src.startsWith("data:"))
|
|
214464
|
-
return;
|
|
214465
|
-
const candidates = /* @__PURE__ */ new Set;
|
|
214466
|
-
candidates.add(src);
|
|
214467
|
-
if (attrSrc)
|
|
214468
|
-
candidates.add(attrSrc);
|
|
214469
|
-
if (relId) {
|
|
214470
|
-
const inferredExt = extension2 ?? inferExtensionFromPath(src) ?? "jpeg";
|
|
214471
|
-
candidates.add(`word/media/${relId}.${inferredExt}`);
|
|
214472
|
-
candidates.add(`media/${relId}.${inferredExt}`);
|
|
214473
|
-
}
|
|
214474
|
-
for (const candidate of candidates) {
|
|
214475
|
-
const normalized = normalizeMediaKey(candidate);
|
|
214476
|
-
if (!normalized)
|
|
214477
|
-
continue;
|
|
214478
|
-
const base64 = normalizedMedia.get(normalized);
|
|
214479
|
-
if (!base64)
|
|
214480
|
-
continue;
|
|
214481
|
-
const finalExt = extension2 ?? inferExtensionFromPath(normalized) ?? "jpeg";
|
|
214482
|
-
return base64.startsWith("data:") ? base64 : `data:image/${finalExt};base64,${base64}`;
|
|
214483
|
-
}
|
|
214484
|
-
};
|
|
214485
|
-
const hydrateRuns = (runs2) => {
|
|
214486
|
-
let hasChanges = false;
|
|
214487
|
-
const hydratedRuns = runs2.map((run2) => {
|
|
214488
|
-
if (run2.kind !== "image")
|
|
214489
|
-
return run2;
|
|
214490
|
-
const imageRun = run2;
|
|
214491
|
-
if (!imageRun.src || imageRun.src.startsWith("data:"))
|
|
214492
|
-
return run2;
|
|
214493
|
-
const resolvedSrc = resolveImageSrc(imageRun.src);
|
|
214494
|
-
if (resolvedSrc) {
|
|
214495
|
-
hasChanges = true;
|
|
214496
|
-
return {
|
|
214497
|
-
...imageRun,
|
|
214498
|
-
src: resolvedSrc
|
|
214499
|
-
};
|
|
214500
|
-
}
|
|
214501
|
-
return run2;
|
|
214502
|
-
});
|
|
214503
|
-
return hasChanges ? hydratedRuns : runs2;
|
|
214504
|
-
};
|
|
214505
|
-
return blocks2.map((block) => {
|
|
214506
|
-
const hydrateBlock = (blk) => {
|
|
214507
|
-
if (blk.kind === "image") {
|
|
214508
|
-
if (!blk.src || blk.src.startsWith("data:"))
|
|
214509
|
-
return blk;
|
|
214510
|
-
const attrs = blk.attrs ?? {};
|
|
214511
|
-
const relId = typeof attrs.rId === "string" ? attrs.rId : undefined;
|
|
214512
|
-
const attrSrc = typeof attrs.src === "string" ? attrs.src : undefined;
|
|
214513
|
-
const extension2 = typeof attrs.extension === "string" ? attrs.extension.toLowerCase() : undefined;
|
|
214514
|
-
const resolvedSrc = resolveImageSrc(blk.src, relId, attrSrc, extension2);
|
|
214515
|
-
if (resolvedSrc)
|
|
214516
|
-
return {
|
|
214517
|
-
...blk,
|
|
214518
|
-
src: resolvedSrc
|
|
214519
|
-
};
|
|
214520
|
-
return blk;
|
|
214521
|
-
}
|
|
214522
|
-
if (blk.kind === "paragraph") {
|
|
214523
|
-
const paragraphBlock = blk;
|
|
214524
|
-
if (!paragraphBlock.runs || paragraphBlock.runs.length === 0)
|
|
214525
|
-
return blk;
|
|
214526
|
-
const hydratedRuns = hydrateRuns(paragraphBlock.runs);
|
|
214527
|
-
if (hydratedRuns !== paragraphBlock.runs)
|
|
214528
|
-
return {
|
|
214529
|
-
...paragraphBlock,
|
|
214530
|
-
runs: hydratedRuns
|
|
214531
|
-
};
|
|
214532
|
-
return blk;
|
|
214533
|
-
}
|
|
214534
|
-
if (blk.kind === "table") {
|
|
214535
|
-
let rowsChanged = false;
|
|
214536
|
-
const newRows = blk.rows.map((row2) => {
|
|
214537
|
-
let cellsChanged = false;
|
|
214538
|
-
const newCells = row2.cells.map((cell2) => {
|
|
214539
|
-
let cellChanged = false;
|
|
214540
|
-
const hydratedBlocks = (cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : [])).map((cb) => hydrateBlock(cb));
|
|
214541
|
-
if (cell2.blocks && hydratedBlocks !== cell2.blocks)
|
|
214542
|
-
cellChanged = true;
|
|
214543
|
-
let hydratedParagraph = cell2.paragraph;
|
|
214544
|
-
if (!cell2.blocks && cell2.paragraph && cell2.paragraph.kind === "paragraph") {
|
|
214545
|
-
const hydratedPara = hydrateBlock(cell2.paragraph);
|
|
214546
|
-
if (hydratedPara !== cell2.paragraph) {
|
|
214547
|
-
hydratedParagraph = hydratedPara;
|
|
214548
|
-
cellChanged = true;
|
|
214549
|
-
}
|
|
214550
|
-
}
|
|
214551
|
-
if (cellChanged)
|
|
214552
|
-
return {
|
|
214553
|
-
...cell2,
|
|
214554
|
-
blocks: hydratedBlocks.length > 0 ? hydratedBlocks : cell2.blocks,
|
|
214555
|
-
paragraph: hydratedParagraph
|
|
214556
|
-
};
|
|
214557
|
-
return cell2;
|
|
214558
|
-
});
|
|
214559
|
-
if (newCells.some((c, idx) => c !== row2.cells[idx]))
|
|
214560
|
-
cellsChanged = true;
|
|
214561
|
-
if (cellsChanged) {
|
|
214562
|
-
rowsChanged = true;
|
|
214563
|
-
return {
|
|
214564
|
-
...row2,
|
|
214565
|
-
cells: newCells
|
|
214566
|
-
};
|
|
214567
|
-
}
|
|
214568
|
-
return row2;
|
|
214569
|
-
});
|
|
214570
|
-
if (rowsChanged)
|
|
214571
|
-
return {
|
|
214572
|
-
...blk,
|
|
214573
|
-
rows: newRows
|
|
214574
|
-
};
|
|
214575
|
-
return blk;
|
|
214576
|
-
}
|
|
214577
|
-
if (blk.kind === "drawing") {
|
|
214578
|
-
const drawingBlock = blk;
|
|
214579
|
-
if (drawingBlock.drawingKind !== "shapeGroup")
|
|
214580
|
-
return blk;
|
|
214581
|
-
const shapeGroupBlock = drawingBlock;
|
|
214582
|
-
if (!shapeGroupBlock.shapes || shapeGroupBlock.shapes.length === 0)
|
|
214583
|
-
return blk;
|
|
214584
|
-
let shapesChanged = false;
|
|
214585
|
-
const hydratedShapes = shapeGroupBlock.shapes.map((shape) => {
|
|
214586
|
-
if (shape.shapeType !== "image")
|
|
214587
|
-
return shape;
|
|
214588
|
-
const imageChild = shape;
|
|
214589
|
-
const src = imageChild.attrs?.src;
|
|
214590
|
-
if (!src || src.startsWith("data:"))
|
|
214591
|
-
return shape;
|
|
214592
|
-
const resolvedSrc = resolveImageSrc(src);
|
|
214593
|
-
if (resolvedSrc) {
|
|
214594
|
-
shapesChanged = true;
|
|
214595
|
-
return {
|
|
214596
|
-
...imageChild,
|
|
214597
|
-
attrs: {
|
|
214598
|
-
...imageChild.attrs,
|
|
214599
|
-
src: resolvedSrc
|
|
214600
|
-
}
|
|
214601
|
-
};
|
|
214602
|
-
}
|
|
214603
|
-
return shape;
|
|
214604
|
-
});
|
|
214605
|
-
if (shapesChanged)
|
|
214606
|
-
return {
|
|
214607
|
-
...shapeGroupBlock,
|
|
214608
|
-
shapes: hydratedShapes
|
|
214609
|
-
};
|
|
214610
|
-
return blk;
|
|
214611
|
-
}
|
|
214612
|
-
return blk;
|
|
214613
|
-
};
|
|
214614
|
-
return hydrateBlock(block);
|
|
214615
|
-
});
|
|
214616
|
-
}
|
|
214617
|
-
function isGradientFill(value) {
|
|
214618
|
-
if (!isPlainObject4(value))
|
|
214619
|
-
return false;
|
|
214620
|
-
if (value.type !== "gradient")
|
|
214621
|
-
return false;
|
|
214622
|
-
const gradientType = value.gradientType;
|
|
214623
|
-
if (gradientType !== "linear" && gradientType !== "radial")
|
|
214624
|
-
return false;
|
|
214625
|
-
if (gradientType === "linear") {
|
|
214626
|
-
if (typeof value.angle !== "number" || !Number.isFinite(value.angle))
|
|
214627
|
-
return false;
|
|
214628
|
-
}
|
|
214629
|
-
if (!Array.isArray(value.stops) || value.stops.length === 0)
|
|
214630
|
-
return false;
|
|
214631
|
-
return value.stops.every((stop) => {
|
|
214632
|
-
if (!isPlainObject4(stop))
|
|
214633
|
-
return false;
|
|
214634
|
-
return typeof stop.position === "number" && Number.isFinite(stop.position) && typeof stop.color === "string" && (stop.alpha === undefined || typeof stop.alpha === "number" && Number.isFinite(stop.alpha));
|
|
214635
|
-
});
|
|
214636
|
-
}
|
|
214637
|
-
function isSolidFillWithAlpha(value) {
|
|
214638
|
-
return isPlainObject4(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
|
|
214639
|
-
}
|
|
214640
|
-
function normalizeFillColor(value) {
|
|
214641
|
-
if (value === null)
|
|
214642
|
-
return null;
|
|
214643
|
-
if (typeof value === "string")
|
|
214644
|
-
return value;
|
|
214645
|
-
if (isGradientFill(value))
|
|
214646
|
-
return value;
|
|
214647
|
-
if (isSolidFillWithAlpha(value))
|
|
214648
|
-
return value;
|
|
214649
|
-
}
|
|
214650
|
-
function normalizeStrokeColor(value) {
|
|
214651
|
-
if (value === null)
|
|
214652
|
-
return null;
|
|
214653
|
-
if (typeof value === "string")
|
|
214654
|
-
return value;
|
|
214655
|
-
}
|
|
214656
|
-
function normalizeTextContent(value) {
|
|
214657
|
-
if (!isPlainObject4(value))
|
|
214658
|
-
return;
|
|
214659
|
-
if (!Array.isArray(value.parts))
|
|
214660
|
-
return;
|
|
214661
|
-
if (value.parts.length === 0)
|
|
214662
|
-
return;
|
|
214663
|
-
const validParts = value.parts.filter((p$12) => isPlainObject4(p$12) && typeof p$12.text === "string");
|
|
214664
|
-
if (validParts.length === 0)
|
|
214665
|
-
return;
|
|
214666
|
-
const result = { parts: validParts };
|
|
214667
|
-
if ([
|
|
214668
|
-
"left",
|
|
214669
|
-
"center",
|
|
214670
|
-
"right"
|
|
214671
|
-
].includes(value.horizontalAlign))
|
|
214672
|
-
result.horizontalAlign = value.horizontalAlign;
|
|
214673
|
-
return result;
|
|
214674
|
-
}
|
|
214675
|
-
function normalizeTextVerticalAlign(value) {
|
|
214676
|
-
if (typeof value !== "string")
|
|
214677
|
-
return;
|
|
214678
|
-
if (value === "top" || value === "center" || value === "bottom")
|
|
214679
|
-
return value;
|
|
214680
|
-
}
|
|
214681
|
-
function normalizeTextInsets(value) {
|
|
214682
|
-
if (!isPlainObject4(value))
|
|
214683
|
-
return;
|
|
214684
|
-
const top$1 = pickNumber(value.top);
|
|
214685
|
-
const right$1 = pickNumber(value.right);
|
|
214686
|
-
const bottom$1 = pickNumber(value.bottom);
|
|
214687
|
-
const left$1 = pickNumber(value.left);
|
|
214688
|
-
if (top$1 == null || right$1 == null || bottom$1 == null || left$1 == null)
|
|
214689
|
-
return;
|
|
214690
|
-
return {
|
|
214691
|
-
top: top$1,
|
|
214692
|
-
right: right$1,
|
|
214693
|
-
bottom: bottom$1,
|
|
214694
|
-
left: left$1
|
|
214695
|
-
};
|
|
214696
|
-
}
|
|
214697
|
-
function resolveFloatingZIndex(behindDoc, raw, fallback = 1) {
|
|
214698
|
-
if (behindDoc)
|
|
214699
|
-
return 0;
|
|
214700
|
-
if (raw === undefined)
|
|
214701
|
-
return Math.max(1, fallback);
|
|
214702
|
-
return Math.max(1, raw);
|
|
214703
|
-
}
|
|
214704
|
-
function getFragmentZIndex(block) {
|
|
214705
|
-
const attrs = block.attrs;
|
|
214706
|
-
const raw = typeof block.zIndex === "number" ? block.zIndex : normalizeZIndex(attrs?.originalAttributes);
|
|
214707
|
-
return resolveFloatingZIndex(block.anchor?.behindDoc === true, raw);
|
|
214708
|
-
}
|
|
214709
214296
|
function calculateFirstLineIndent(block, measure) {
|
|
214710
214297
|
const wordLayout = block.attrs?.wordLayout;
|
|
214711
214298
|
if (!wordLayout?.firstLineIndentMode)
|
|
@@ -221721,6 +221308,419 @@ function createLayoutMetrics(perf2, startMark, layout, blocks2) {
|
|
|
221721
221308
|
pageCount: layout.pages?.length ?? 0
|
|
221722
221309
|
};
|
|
221723
221310
|
}
|
|
221311
|
+
function coerceNumber(value) {
|
|
221312
|
+
if (isFiniteNumber(value))
|
|
221313
|
+
return Number(value);
|
|
221314
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
221315
|
+
const parsed = Number(value);
|
|
221316
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
221317
|
+
}
|
|
221318
|
+
}
|
|
221319
|
+
function coercePositiveNumber(value, fallback) {
|
|
221320
|
+
if (!isFiniteNumber(fallback) || fallback <= 0)
|
|
221321
|
+
throw new Error(`coercePositiveNumber: fallback must be a positive number, got ${fallback}`);
|
|
221322
|
+
const numeric = coerceNumber(value);
|
|
221323
|
+
if (numeric != null && numeric > 0)
|
|
221324
|
+
return numeric;
|
|
221325
|
+
return fallback;
|
|
221326
|
+
}
|
|
221327
|
+
function coerceBoolean(value) {
|
|
221328
|
+
if (typeof value === "boolean")
|
|
221329
|
+
return value;
|
|
221330
|
+
if (typeof value === "number") {
|
|
221331
|
+
if (value === 1)
|
|
221332
|
+
return true;
|
|
221333
|
+
if (value === 0)
|
|
221334
|
+
return false;
|
|
221335
|
+
return;
|
|
221336
|
+
}
|
|
221337
|
+
if (typeof value === "string") {
|
|
221338
|
+
const normalized = value.trim().toLowerCase();
|
|
221339
|
+
if ([
|
|
221340
|
+
"true",
|
|
221341
|
+
"1",
|
|
221342
|
+
"yes",
|
|
221343
|
+
"on"
|
|
221344
|
+
].includes(normalized))
|
|
221345
|
+
return true;
|
|
221346
|
+
if ([
|
|
221347
|
+
"false",
|
|
221348
|
+
"0",
|
|
221349
|
+
"no",
|
|
221350
|
+
"off"
|
|
221351
|
+
].includes(normalized))
|
|
221352
|
+
return false;
|
|
221353
|
+
}
|
|
221354
|
+
}
|
|
221355
|
+
function toBoxSpacing(spacing) {
|
|
221356
|
+
if (!spacing)
|
|
221357
|
+
return;
|
|
221358
|
+
const result = {};
|
|
221359
|
+
[
|
|
221360
|
+
"top",
|
|
221361
|
+
"right",
|
|
221362
|
+
"bottom",
|
|
221363
|
+
"left"
|
|
221364
|
+
].forEach((side) => {
|
|
221365
|
+
const value = spacing[side];
|
|
221366
|
+
if (isFiniteNumber(value))
|
|
221367
|
+
result[side] = Number(value);
|
|
221368
|
+
});
|
|
221369
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
221370
|
+
}
|
|
221371
|
+
function normalizeCellPaddingTopBottom(padding) {
|
|
221372
|
+
const out = { ...padding };
|
|
221373
|
+
if (typeof out.top === "number" && out.top > 0 && out.top < MIN_TOP_BOTTOM_CELL_PADDING_PX)
|
|
221374
|
+
out.top = MIN_TOP_BOTTOM_CELL_PADDING_PX;
|
|
221375
|
+
if (typeof out.bottom === "number" && out.bottom > 0 && out.bottom < MIN_TOP_BOTTOM_CELL_PADDING_PX)
|
|
221376
|
+
out.bottom = MIN_TOP_BOTTOM_CELL_PADDING_PX;
|
|
221377
|
+
return out;
|
|
221378
|
+
}
|
|
221379
|
+
function toDrawingContentSnapshot(value) {
|
|
221380
|
+
if (!value || typeof value !== "object")
|
|
221381
|
+
return;
|
|
221382
|
+
const raw = value;
|
|
221383
|
+
const name = raw.name;
|
|
221384
|
+
if (typeof name !== "string")
|
|
221385
|
+
return;
|
|
221386
|
+
const snapshot2 = { name };
|
|
221387
|
+
if (raw.attributes && typeof raw.attributes === "object" && !Array.isArray(raw.attributes))
|
|
221388
|
+
snapshot2.attributes = { ...raw.attributes };
|
|
221389
|
+
if (Array.isArray(raw.elements)) {
|
|
221390
|
+
const validElements = raw.elements.filter((el) => el != null && typeof el === "object");
|
|
221391
|
+
if (validElements.length > 0)
|
|
221392
|
+
snapshot2.elements = validElements;
|
|
221393
|
+
}
|
|
221394
|
+
return snapshot2;
|
|
221395
|
+
}
|
|
221396
|
+
function isShapeGroupTransform(value) {
|
|
221397
|
+
if (!value || typeof value !== "object")
|
|
221398
|
+
return false;
|
|
221399
|
+
const maybe = value;
|
|
221400
|
+
return isFiniteNumber(maybe.x) || isFiniteNumber(maybe.y) || isFiniteNumber(maybe.width) || isFiniteNumber(maybe.height) || isFiniteNumber(maybe.childWidth) || isFiniteNumber(maybe.childHeight) || isFiniteNumber(maybe.childX) || isFiniteNumber(maybe.childY);
|
|
221401
|
+
}
|
|
221402
|
+
function normalizeShapeSize(value) {
|
|
221403
|
+
if (!value || typeof value !== "object")
|
|
221404
|
+
return;
|
|
221405
|
+
const maybe = value;
|
|
221406
|
+
const width = coerceNumber(maybe.width);
|
|
221407
|
+
const height = coerceNumber(maybe.height);
|
|
221408
|
+
if (width == null && height == null)
|
|
221409
|
+
return;
|
|
221410
|
+
const result = {};
|
|
221411
|
+
if (width != null)
|
|
221412
|
+
result.width = width;
|
|
221413
|
+
if (height != null)
|
|
221414
|
+
result.height = height;
|
|
221415
|
+
return result;
|
|
221416
|
+
}
|
|
221417
|
+
function normalizeLineEnds(value) {
|
|
221418
|
+
if (!value || typeof value !== "object")
|
|
221419
|
+
return;
|
|
221420
|
+
const maybe = value;
|
|
221421
|
+
const head = normalizeLineEnd(maybe.head);
|
|
221422
|
+
const tail = normalizeLineEnd(maybe.tail);
|
|
221423
|
+
if (!head && !tail)
|
|
221424
|
+
return;
|
|
221425
|
+
return {
|
|
221426
|
+
head,
|
|
221427
|
+
tail
|
|
221428
|
+
};
|
|
221429
|
+
}
|
|
221430
|
+
function normalizeEffectExtent(value) {
|
|
221431
|
+
if (!value || typeof value !== "object")
|
|
221432
|
+
return;
|
|
221433
|
+
const maybe = value;
|
|
221434
|
+
const left$1 = coerceNumber(maybe.left);
|
|
221435
|
+
const top$1 = coerceNumber(maybe.top);
|
|
221436
|
+
const right$1 = coerceNumber(maybe.right);
|
|
221437
|
+
const bottom$1 = coerceNumber(maybe.bottom);
|
|
221438
|
+
if (left$1 == null && top$1 == null && right$1 == null && bottom$1 == null)
|
|
221439
|
+
return;
|
|
221440
|
+
const clamp$2 = (val) => val != null && val > 0 ? val : 0;
|
|
221441
|
+
return {
|
|
221442
|
+
left: clamp$2(left$1),
|
|
221443
|
+
top: clamp$2(top$1),
|
|
221444
|
+
right: clamp$2(right$1),
|
|
221445
|
+
bottom: clamp$2(bottom$1)
|
|
221446
|
+
};
|
|
221447
|
+
}
|
|
221448
|
+
function normalizeShapeGroupChildren(value) {
|
|
221449
|
+
if (!Array.isArray(value))
|
|
221450
|
+
return [];
|
|
221451
|
+
return value.filter((child) => {
|
|
221452
|
+
if (!child || typeof child !== "object")
|
|
221453
|
+
return false;
|
|
221454
|
+
return typeof child.shapeType === "string";
|
|
221455
|
+
});
|
|
221456
|
+
}
|
|
221457
|
+
function normalizeMediaKey(value) {
|
|
221458
|
+
if (!value)
|
|
221459
|
+
return;
|
|
221460
|
+
return value.replace(/\\/g, "/").replace(/^(\.\/|\/)+/, "");
|
|
221461
|
+
}
|
|
221462
|
+
function inferExtensionFromPath(value) {
|
|
221463
|
+
if (!value)
|
|
221464
|
+
return;
|
|
221465
|
+
const fileName = value.split("/").pop()?.split("\\").pop();
|
|
221466
|
+
if (!fileName || fileName.startsWith("."))
|
|
221467
|
+
return;
|
|
221468
|
+
const parts = fileName.split(".");
|
|
221469
|
+
if (parts.length < 2)
|
|
221470
|
+
return;
|
|
221471
|
+
const ext = parts.at(-1);
|
|
221472
|
+
if (!ext || ext.length === 0)
|
|
221473
|
+
return;
|
|
221474
|
+
return ext.toLowerCase();
|
|
221475
|
+
}
|
|
221476
|
+
function hydrateImageBlocks(blocks2, mediaFiles) {
|
|
221477
|
+
if (!mediaFiles || Object.keys(mediaFiles).length === 0)
|
|
221478
|
+
return blocks2;
|
|
221479
|
+
const normalizedMedia = /* @__PURE__ */ new Map;
|
|
221480
|
+
Object.entries(mediaFiles).forEach(([key$1, value]) => {
|
|
221481
|
+
const normalized = normalizeMediaKey(key$1);
|
|
221482
|
+
if (normalized) {
|
|
221483
|
+
const stringValue = value instanceof Uint8Array ? new TextDecoder().decode(value) : value;
|
|
221484
|
+
normalizedMedia.set(normalized, stringValue);
|
|
221485
|
+
}
|
|
221486
|
+
});
|
|
221487
|
+
if (normalizedMedia.size === 0)
|
|
221488
|
+
return blocks2;
|
|
221489
|
+
const resolveImageSrc = (src, relId, attrSrc, extension2) => {
|
|
221490
|
+
if (!src || src.startsWith("data:"))
|
|
221491
|
+
return;
|
|
221492
|
+
const candidates = /* @__PURE__ */ new Set;
|
|
221493
|
+
candidates.add(src);
|
|
221494
|
+
if (attrSrc)
|
|
221495
|
+
candidates.add(attrSrc);
|
|
221496
|
+
if (relId) {
|
|
221497
|
+
const inferredExt = extension2 ?? inferExtensionFromPath(src) ?? "jpeg";
|
|
221498
|
+
candidates.add(`word/media/${relId}.${inferredExt}`);
|
|
221499
|
+
candidates.add(`media/${relId}.${inferredExt}`);
|
|
221500
|
+
}
|
|
221501
|
+
for (const candidate of candidates) {
|
|
221502
|
+
const normalized = normalizeMediaKey(candidate);
|
|
221503
|
+
if (!normalized)
|
|
221504
|
+
continue;
|
|
221505
|
+
const base64 = normalizedMedia.get(normalized);
|
|
221506
|
+
if (!base64)
|
|
221507
|
+
continue;
|
|
221508
|
+
const finalExt = extension2 ?? inferExtensionFromPath(normalized) ?? "jpeg";
|
|
221509
|
+
return base64.startsWith("data:") ? base64 : `data:image/${finalExt};base64,${base64}`;
|
|
221510
|
+
}
|
|
221511
|
+
};
|
|
221512
|
+
const hydrateRuns = (runs2) => {
|
|
221513
|
+
let hasChanges = false;
|
|
221514
|
+
const hydratedRuns = runs2.map((run2) => {
|
|
221515
|
+
if (run2.kind !== "image")
|
|
221516
|
+
return run2;
|
|
221517
|
+
const imageRun = run2;
|
|
221518
|
+
if (!imageRun.src || imageRun.src.startsWith("data:"))
|
|
221519
|
+
return run2;
|
|
221520
|
+
const resolvedSrc = resolveImageSrc(imageRun.src);
|
|
221521
|
+
if (resolvedSrc) {
|
|
221522
|
+
hasChanges = true;
|
|
221523
|
+
return {
|
|
221524
|
+
...imageRun,
|
|
221525
|
+
src: resolvedSrc
|
|
221526
|
+
};
|
|
221527
|
+
}
|
|
221528
|
+
return run2;
|
|
221529
|
+
});
|
|
221530
|
+
return hasChanges ? hydratedRuns : runs2;
|
|
221531
|
+
};
|
|
221532
|
+
return blocks2.map((block) => {
|
|
221533
|
+
const hydrateBlock = (blk) => {
|
|
221534
|
+
if (blk.kind === "image") {
|
|
221535
|
+
if (!blk.src || blk.src.startsWith("data:"))
|
|
221536
|
+
return blk;
|
|
221537
|
+
const attrs = blk.attrs ?? {};
|
|
221538
|
+
const relId = typeof attrs.rId === "string" ? attrs.rId : undefined;
|
|
221539
|
+
const attrSrc = typeof attrs.src === "string" ? attrs.src : undefined;
|
|
221540
|
+
const extension2 = typeof attrs.extension === "string" ? attrs.extension.toLowerCase() : undefined;
|
|
221541
|
+
const resolvedSrc = resolveImageSrc(blk.src, relId, attrSrc, extension2);
|
|
221542
|
+
if (resolvedSrc)
|
|
221543
|
+
return {
|
|
221544
|
+
...blk,
|
|
221545
|
+
src: resolvedSrc
|
|
221546
|
+
};
|
|
221547
|
+
return blk;
|
|
221548
|
+
}
|
|
221549
|
+
if (blk.kind === "paragraph") {
|
|
221550
|
+
const paragraphBlock = blk;
|
|
221551
|
+
if (!paragraphBlock.runs || paragraphBlock.runs.length === 0)
|
|
221552
|
+
return blk;
|
|
221553
|
+
const hydratedRuns = hydrateRuns(paragraphBlock.runs);
|
|
221554
|
+
if (hydratedRuns !== paragraphBlock.runs)
|
|
221555
|
+
return {
|
|
221556
|
+
...paragraphBlock,
|
|
221557
|
+
runs: hydratedRuns
|
|
221558
|
+
};
|
|
221559
|
+
return blk;
|
|
221560
|
+
}
|
|
221561
|
+
if (blk.kind === "table") {
|
|
221562
|
+
let rowsChanged = false;
|
|
221563
|
+
const newRows = blk.rows.map((row2) => {
|
|
221564
|
+
let cellsChanged = false;
|
|
221565
|
+
const newCells = row2.cells.map((cell2) => {
|
|
221566
|
+
let cellChanged = false;
|
|
221567
|
+
const hydratedBlocks = (cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : [])).map((cb) => hydrateBlock(cb));
|
|
221568
|
+
if (cell2.blocks && hydratedBlocks !== cell2.blocks)
|
|
221569
|
+
cellChanged = true;
|
|
221570
|
+
let hydratedParagraph = cell2.paragraph;
|
|
221571
|
+
if (!cell2.blocks && cell2.paragraph && cell2.paragraph.kind === "paragraph") {
|
|
221572
|
+
const hydratedPara = hydrateBlock(cell2.paragraph);
|
|
221573
|
+
if (hydratedPara !== cell2.paragraph) {
|
|
221574
|
+
hydratedParagraph = hydratedPara;
|
|
221575
|
+
cellChanged = true;
|
|
221576
|
+
}
|
|
221577
|
+
}
|
|
221578
|
+
if (cellChanged)
|
|
221579
|
+
return {
|
|
221580
|
+
...cell2,
|
|
221581
|
+
blocks: hydratedBlocks.length > 0 ? hydratedBlocks : cell2.blocks,
|
|
221582
|
+
paragraph: hydratedParagraph
|
|
221583
|
+
};
|
|
221584
|
+
return cell2;
|
|
221585
|
+
});
|
|
221586
|
+
if (newCells.some((c, idx) => c !== row2.cells[idx]))
|
|
221587
|
+
cellsChanged = true;
|
|
221588
|
+
if (cellsChanged) {
|
|
221589
|
+
rowsChanged = true;
|
|
221590
|
+
return {
|
|
221591
|
+
...row2,
|
|
221592
|
+
cells: newCells
|
|
221593
|
+
};
|
|
221594
|
+
}
|
|
221595
|
+
return row2;
|
|
221596
|
+
});
|
|
221597
|
+
if (rowsChanged)
|
|
221598
|
+
return {
|
|
221599
|
+
...blk,
|
|
221600
|
+
rows: newRows
|
|
221601
|
+
};
|
|
221602
|
+
return blk;
|
|
221603
|
+
}
|
|
221604
|
+
if (blk.kind === "drawing") {
|
|
221605
|
+
const drawingBlock = blk;
|
|
221606
|
+
if (drawingBlock.drawingKind !== "shapeGroup")
|
|
221607
|
+
return blk;
|
|
221608
|
+
const shapeGroupBlock = drawingBlock;
|
|
221609
|
+
if (!shapeGroupBlock.shapes || shapeGroupBlock.shapes.length === 0)
|
|
221610
|
+
return blk;
|
|
221611
|
+
let shapesChanged = false;
|
|
221612
|
+
const hydratedShapes = shapeGroupBlock.shapes.map((shape) => {
|
|
221613
|
+
if (shape.shapeType !== "image")
|
|
221614
|
+
return shape;
|
|
221615
|
+
const imageChild = shape;
|
|
221616
|
+
const src = imageChild.attrs?.src;
|
|
221617
|
+
if (!src || src.startsWith("data:"))
|
|
221618
|
+
return shape;
|
|
221619
|
+
const resolvedSrc = resolveImageSrc(src);
|
|
221620
|
+
if (resolvedSrc) {
|
|
221621
|
+
shapesChanged = true;
|
|
221622
|
+
return {
|
|
221623
|
+
...imageChild,
|
|
221624
|
+
attrs: {
|
|
221625
|
+
...imageChild.attrs,
|
|
221626
|
+
src: resolvedSrc
|
|
221627
|
+
}
|
|
221628
|
+
};
|
|
221629
|
+
}
|
|
221630
|
+
return shape;
|
|
221631
|
+
});
|
|
221632
|
+
if (shapesChanged)
|
|
221633
|
+
return {
|
|
221634
|
+
...shapeGroupBlock,
|
|
221635
|
+
shapes: hydratedShapes
|
|
221636
|
+
};
|
|
221637
|
+
return blk;
|
|
221638
|
+
}
|
|
221639
|
+
return blk;
|
|
221640
|
+
};
|
|
221641
|
+
return hydrateBlock(block);
|
|
221642
|
+
});
|
|
221643
|
+
}
|
|
221644
|
+
function isGradientFill(value) {
|
|
221645
|
+
if (!isPlainObject4(value))
|
|
221646
|
+
return false;
|
|
221647
|
+
if (value.type !== "gradient")
|
|
221648
|
+
return false;
|
|
221649
|
+
const gradientType = value.gradientType;
|
|
221650
|
+
if (gradientType !== "linear" && gradientType !== "radial")
|
|
221651
|
+
return false;
|
|
221652
|
+
if (gradientType === "linear") {
|
|
221653
|
+
if (typeof value.angle !== "number" || !Number.isFinite(value.angle))
|
|
221654
|
+
return false;
|
|
221655
|
+
}
|
|
221656
|
+
if (!Array.isArray(value.stops) || value.stops.length === 0)
|
|
221657
|
+
return false;
|
|
221658
|
+
return value.stops.every((stop) => {
|
|
221659
|
+
if (!isPlainObject4(stop))
|
|
221660
|
+
return false;
|
|
221661
|
+
return typeof stop.position === "number" && Number.isFinite(stop.position) && typeof stop.color === "string" && (stop.alpha === undefined || typeof stop.alpha === "number" && Number.isFinite(stop.alpha));
|
|
221662
|
+
});
|
|
221663
|
+
}
|
|
221664
|
+
function isSolidFillWithAlpha(value) {
|
|
221665
|
+
return isPlainObject4(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
|
|
221666
|
+
}
|
|
221667
|
+
function normalizeFillColor(value) {
|
|
221668
|
+
if (value === null)
|
|
221669
|
+
return null;
|
|
221670
|
+
if (typeof value === "string")
|
|
221671
|
+
return value;
|
|
221672
|
+
if (isGradientFill(value))
|
|
221673
|
+
return value;
|
|
221674
|
+
if (isSolidFillWithAlpha(value))
|
|
221675
|
+
return value;
|
|
221676
|
+
}
|
|
221677
|
+
function normalizeStrokeColor(value) {
|
|
221678
|
+
if (value === null)
|
|
221679
|
+
return null;
|
|
221680
|
+
if (typeof value === "string")
|
|
221681
|
+
return value;
|
|
221682
|
+
}
|
|
221683
|
+
function normalizeTextContent(value) {
|
|
221684
|
+
if (!isPlainObject4(value))
|
|
221685
|
+
return;
|
|
221686
|
+
if (!Array.isArray(value.parts))
|
|
221687
|
+
return;
|
|
221688
|
+
if (value.parts.length === 0)
|
|
221689
|
+
return;
|
|
221690
|
+
const validParts = value.parts.filter((p$12) => isPlainObject4(p$12) && typeof p$12.text === "string");
|
|
221691
|
+
if (validParts.length === 0)
|
|
221692
|
+
return;
|
|
221693
|
+
const result = { parts: validParts };
|
|
221694
|
+
if ([
|
|
221695
|
+
"left",
|
|
221696
|
+
"center",
|
|
221697
|
+
"right"
|
|
221698
|
+
].includes(value.horizontalAlign))
|
|
221699
|
+
result.horizontalAlign = value.horizontalAlign;
|
|
221700
|
+
return result;
|
|
221701
|
+
}
|
|
221702
|
+
function normalizeTextVerticalAlign(value) {
|
|
221703
|
+
if (typeof value !== "string")
|
|
221704
|
+
return;
|
|
221705
|
+
if (value === "top" || value === "center" || value === "bottom")
|
|
221706
|
+
return value;
|
|
221707
|
+
}
|
|
221708
|
+
function normalizeTextInsets(value) {
|
|
221709
|
+
if (!isPlainObject4(value))
|
|
221710
|
+
return;
|
|
221711
|
+
const top$1 = pickNumber(value.top);
|
|
221712
|
+
const right$1 = pickNumber(value.right);
|
|
221713
|
+
const bottom$1 = pickNumber(value.bottom);
|
|
221714
|
+
const left$1 = pickNumber(value.left);
|
|
221715
|
+
if (top$1 == null || right$1 == null || bottom$1 == null || left$1 == null)
|
|
221716
|
+
return;
|
|
221717
|
+
return {
|
|
221718
|
+
top: top$1,
|
|
221719
|
+
right: right$1,
|
|
221720
|
+
bottom: bottom$1,
|
|
221721
|
+
left: left$1
|
|
221722
|
+
};
|
|
221723
|
+
}
|
|
221724
221724
|
function shiftBlockPositions(block, delta) {
|
|
221725
221725
|
if (block.kind === "paragraph") {
|
|
221726
221726
|
const paragraphBlock = block;
|
|
@@ -246333,104 +246333,6 @@ var Node$13 = class Node$14 {
|
|
|
246333
246333
|
pmStart: start$1,
|
|
246334
246334
|
pmEnd: (typeof attrs.pmEnd === "number" ? attrs.pmEnd : undefined) ?? (start$1 != null ? start$1 + 1 : undefined)
|
|
246335
246335
|
};
|
|
246336
|
-
}, SUBSCRIPT_SUPERSCRIPT_SCALE2 = 0.65, TWIPS_PER_INCH2 = 1440, PX_PER_PT2, VALID_TRACKED_MODES, DEFAULT_HYPERLINK_CONFIG, ATOMIC_INLINE_TYPES, TOKEN_INLINE_TYPES, twipsToPx$1 = (value) => value / TWIPS_PER_INCH2 * 96, ptToPx = (pt) => {
|
|
246337
|
-
if (pt == null || !Number.isFinite(pt))
|
|
246338
|
-
return;
|
|
246339
|
-
return pt * PX_PER_PT2;
|
|
246340
|
-
}, isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
|
|
246341
|
-
if (!value)
|
|
246342
|
-
return "";
|
|
246343
|
-
return String(value);
|
|
246344
|
-
}, pickNumber = (value) => {
|
|
246345
|
-
if (isFiniteNumber(value))
|
|
246346
|
-
return value;
|
|
246347
|
-
if (typeof value === "string") {
|
|
246348
|
-
const parsed = parseFloat(value);
|
|
246349
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
246350
|
-
}
|
|
246351
|
-
}, normalizeColor = (value) => {
|
|
246352
|
-
if (typeof value !== "string")
|
|
246353
|
-
return;
|
|
246354
|
-
const trimmed = value.trim();
|
|
246355
|
-
if (!trimmed || trimmed === "auto" || trimmed === "none")
|
|
246356
|
-
return;
|
|
246357
|
-
return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
246358
|
-
}, toBoolean = (value) => {
|
|
246359
|
-
if (typeof value === "boolean")
|
|
246360
|
-
return value;
|
|
246361
|
-
if (typeof value === "string") {
|
|
246362
|
-
const v = value.trim().toLowerCase();
|
|
246363
|
-
if (v === "true" || v === "1")
|
|
246364
|
-
return true;
|
|
246365
|
-
if (v === "false" || v === "0")
|
|
246366
|
-
return false;
|
|
246367
|
-
}
|
|
246368
|
-
if (typeof value === "number") {
|
|
246369
|
-
if (value === 1)
|
|
246370
|
-
return true;
|
|
246371
|
-
if (value === 0)
|
|
246372
|
-
return false;
|
|
246373
|
-
}
|
|
246374
|
-
}, MIN_TOP_BOTTOM_CELL_PADDING_PX = 2, buildPositionMap = (root3, options) => {
|
|
246375
|
-
const map$12 = /* @__PURE__ */ new WeakMap;
|
|
246376
|
-
const atomNodeTypes = new Set(ATOMIC_INLINE_TYPES);
|
|
246377
|
-
if (options?.atomNodeTypes) {
|
|
246378
|
-
for (const nodeType of options.atomNodeTypes)
|
|
246379
|
-
if (typeof nodeType === "string" && nodeType.length > 0)
|
|
246380
|
-
atomNodeTypes.add(nodeType);
|
|
246381
|
-
}
|
|
246382
|
-
const visit2 = (node3, pos) => {
|
|
246383
|
-
if (node3.type === "text") {
|
|
246384
|
-
const end$2 = pos + (node3.text?.length ?? 0);
|
|
246385
|
-
map$12.set(node3, {
|
|
246386
|
-
start: pos,
|
|
246387
|
-
end: end$2
|
|
246388
|
-
});
|
|
246389
|
-
return end$2;
|
|
246390
|
-
}
|
|
246391
|
-
if (atomNodeTypes.has(node3.type)) {
|
|
246392
|
-
const end$2 = pos + 1;
|
|
246393
|
-
map$12.set(node3, {
|
|
246394
|
-
start: pos,
|
|
246395
|
-
end: end$2
|
|
246396
|
-
});
|
|
246397
|
-
return end$2;
|
|
246398
|
-
}
|
|
246399
|
-
const open2 = node3.type === "doc" ? 0 : 1;
|
|
246400
|
-
const close2 = node3.type === "doc" ? 0 : 1;
|
|
246401
|
-
let nextPos = pos + open2;
|
|
246402
|
-
const content3 = Array.isArray(node3.content) ? node3.content : [];
|
|
246403
|
-
map$12.set(node3, {
|
|
246404
|
-
start: pos,
|
|
246405
|
-
end: pos
|
|
246406
|
-
});
|
|
246407
|
-
content3.forEach((child) => {
|
|
246408
|
-
nextPos = visit2(child, nextPos);
|
|
246409
|
-
});
|
|
246410
|
-
const end$1 = nextPos + close2;
|
|
246411
|
-
map$12.set(node3, {
|
|
246412
|
-
start: pos,
|
|
246413
|
-
end: end$1
|
|
246414
|
-
});
|
|
246415
|
-
return end$1;
|
|
246416
|
-
};
|
|
246417
|
-
visit2(root3, 0);
|
|
246418
|
-
return map$12;
|
|
246419
|
-
}, createBlockIdGenerator = (prefix2 = "") => {
|
|
246420
|
-
let counter = 0;
|
|
246421
|
-
return (kind) => `${prefix2}${counter++}-${kind}`;
|
|
246422
|
-
}, LINE_END_SIZES, normalizeLineEnd = (value) => {
|
|
246423
|
-
if (!value || typeof value !== "object")
|
|
246424
|
-
return;
|
|
246425
|
-
const maybe = value;
|
|
246426
|
-
const type = typeof maybe.type === "string" ? maybe.type : undefined;
|
|
246427
|
-
if (!type || type === "none")
|
|
246428
|
-
return;
|
|
246429
|
-
return {
|
|
246430
|
-
type,
|
|
246431
|
-
width: typeof maybe.width === "string" && LINE_END_SIZES.has(maybe.width) ? maybe.width : undefined,
|
|
246432
|
-
length: typeof maybe.length === "string" && LINE_END_SIZES.has(maybe.length) ? maybe.length : undefined
|
|
246433
|
-
};
|
|
246434
246336
|
}, getParagraphAttrs = (block) => {
|
|
246435
246337
|
if (!block.attrs || typeof block.attrs !== "object")
|
|
246436
246338
|
return;
|
|
@@ -249127,7 +249029,7 @@ var Node$13 = class Node$14 {
|
|
|
249127
249029
|
this.#onRebuild();
|
|
249128
249030
|
});
|
|
249129
249031
|
}
|
|
249130
|
-
}, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, isValidTrackedMode = (value) => {
|
|
249032
|
+
}, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, SUBSCRIPT_SUPERSCRIPT_SCALE2 = 0.65, TWIPS_PER_INCH2 = 1440, PX_PER_PT2, VALID_TRACKED_MODES, DEFAULT_HYPERLINK_CONFIG, ATOMIC_INLINE_TYPES, TOKEN_INLINE_TYPES, isValidTrackedMode = (value) => {
|
|
249131
249033
|
return typeof value === "string" && VALID_TRACKED_MODES.includes(value);
|
|
249132
249034
|
}, isTextRun$3 = (run2) => {
|
|
249133
249035
|
return "text" in run2 && run2.kind !== "tab";
|
|
@@ -249236,6 +249138,104 @@ var Node$13 = class Node$14 {
|
|
|
249236
249138
|
});
|
|
249237
249139
|
}
|
|
249238
249140
|
return filtered;
|
|
249141
|
+
}, twipsToPx$1 = (value) => value / TWIPS_PER_INCH2 * 96, ptToPx = (pt) => {
|
|
249142
|
+
if (pt == null || !Number.isFinite(pt))
|
|
249143
|
+
return;
|
|
249144
|
+
return pt * PX_PER_PT2;
|
|
249145
|
+
}, isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
|
|
249146
|
+
if (!value)
|
|
249147
|
+
return "";
|
|
249148
|
+
return String(value);
|
|
249149
|
+
}, pickNumber = (value) => {
|
|
249150
|
+
if (isFiniteNumber(value))
|
|
249151
|
+
return value;
|
|
249152
|
+
if (typeof value === "string") {
|
|
249153
|
+
const parsed = parseFloat(value);
|
|
249154
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
249155
|
+
}
|
|
249156
|
+
}, normalizeColor = (value) => {
|
|
249157
|
+
if (typeof value !== "string")
|
|
249158
|
+
return;
|
|
249159
|
+
const trimmed = value.trim();
|
|
249160
|
+
if (!trimmed || trimmed === "auto" || trimmed === "none")
|
|
249161
|
+
return;
|
|
249162
|
+
return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
249163
|
+
}, toBoolean = (value) => {
|
|
249164
|
+
if (typeof value === "boolean")
|
|
249165
|
+
return value;
|
|
249166
|
+
if (typeof value === "string") {
|
|
249167
|
+
const v = value.trim().toLowerCase();
|
|
249168
|
+
if (v === "true" || v === "1")
|
|
249169
|
+
return true;
|
|
249170
|
+
if (v === "false" || v === "0")
|
|
249171
|
+
return false;
|
|
249172
|
+
}
|
|
249173
|
+
if (typeof value === "number") {
|
|
249174
|
+
if (value === 1)
|
|
249175
|
+
return true;
|
|
249176
|
+
if (value === 0)
|
|
249177
|
+
return false;
|
|
249178
|
+
}
|
|
249179
|
+
}, MIN_TOP_BOTTOM_CELL_PADDING_PX = 2, buildPositionMap = (root3, options) => {
|
|
249180
|
+
const map$12 = /* @__PURE__ */ new WeakMap;
|
|
249181
|
+
const atomNodeTypes = new Set(ATOMIC_INLINE_TYPES);
|
|
249182
|
+
if (options?.atomNodeTypes) {
|
|
249183
|
+
for (const nodeType of options.atomNodeTypes)
|
|
249184
|
+
if (typeof nodeType === "string" && nodeType.length > 0)
|
|
249185
|
+
atomNodeTypes.add(nodeType);
|
|
249186
|
+
}
|
|
249187
|
+
const visit2 = (node3, pos) => {
|
|
249188
|
+
if (node3.type === "text") {
|
|
249189
|
+
const end$2 = pos + (node3.text?.length ?? 0);
|
|
249190
|
+
map$12.set(node3, {
|
|
249191
|
+
start: pos,
|
|
249192
|
+
end: end$2
|
|
249193
|
+
});
|
|
249194
|
+
return end$2;
|
|
249195
|
+
}
|
|
249196
|
+
if (atomNodeTypes.has(node3.type)) {
|
|
249197
|
+
const end$2 = pos + 1;
|
|
249198
|
+
map$12.set(node3, {
|
|
249199
|
+
start: pos,
|
|
249200
|
+
end: end$2
|
|
249201
|
+
});
|
|
249202
|
+
return end$2;
|
|
249203
|
+
}
|
|
249204
|
+
const open2 = node3.type === "doc" ? 0 : 1;
|
|
249205
|
+
const close2 = node3.type === "doc" ? 0 : 1;
|
|
249206
|
+
let nextPos = pos + open2;
|
|
249207
|
+
const content3 = Array.isArray(node3.content) ? node3.content : [];
|
|
249208
|
+
map$12.set(node3, {
|
|
249209
|
+
start: pos,
|
|
249210
|
+
end: pos
|
|
249211
|
+
});
|
|
249212
|
+
content3.forEach((child) => {
|
|
249213
|
+
nextPos = visit2(child, nextPos);
|
|
249214
|
+
});
|
|
249215
|
+
const end$1 = nextPos + close2;
|
|
249216
|
+
map$12.set(node3, {
|
|
249217
|
+
start: pos,
|
|
249218
|
+
end: end$1
|
|
249219
|
+
});
|
|
249220
|
+
return end$1;
|
|
249221
|
+
};
|
|
249222
|
+
visit2(root3, 0);
|
|
249223
|
+
return map$12;
|
|
249224
|
+
}, createBlockIdGenerator = (prefix2 = "") => {
|
|
249225
|
+
let counter = 0;
|
|
249226
|
+
return (kind) => `${prefix2}${counter++}-${kind}`;
|
|
249227
|
+
}, LINE_END_SIZES, normalizeLineEnd = (value) => {
|
|
249228
|
+
if (!value || typeof value !== "object")
|
|
249229
|
+
return;
|
|
249230
|
+
const maybe = value;
|
|
249231
|
+
const type = typeof maybe.type === "string" ? maybe.type : undefined;
|
|
249232
|
+
if (!type || type === "none")
|
|
249233
|
+
return;
|
|
249234
|
+
return {
|
|
249235
|
+
type,
|
|
249236
|
+
width: typeof maybe.width === "string" && LINE_END_SIZES.has(maybe.width) ? maybe.width : undefined,
|
|
249237
|
+
length: typeof maybe.length === "string" && LINE_END_SIZES.has(maybe.length) ? maybe.length : undefined
|
|
249238
|
+
};
|
|
249239
249239
|
}, getNodeRevision = (node3) => {
|
|
249240
249240
|
const attrs = node3?.attrs;
|
|
249241
249241
|
if (!attrs)
|
|
@@ -255272,7 +255272,7 @@ var Node$13 = class Node$14 {
|
|
|
255272
255272
|
return;
|
|
255273
255273
|
console.log(...args$1);
|
|
255274
255274
|
}, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
|
|
255275
|
-
var
|
|
255275
|
+
var init_src_CVvmm9fW_es = __esm(() => {
|
|
255276
255276
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
255277
255277
|
init_SuperConverter_B9oNf3OB_es();
|
|
255278
255278
|
init_jszip_ChlR43oI_es();
|
|
@@ -284722,35 +284722,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
284722
284722
|
count: 1,
|
|
284723
284723
|
gap: 0
|
|
284724
284724
|
};
|
|
284725
|
-
PX_PER_PT2 = 96 / 72;
|
|
284726
|
-
VALID_TRACKED_MODES = [
|
|
284727
|
-
"review",
|
|
284728
|
-
"original",
|
|
284729
|
-
"final",
|
|
284730
|
-
"off"
|
|
284731
|
-
];
|
|
284732
|
-
DEFAULT_HYPERLINK_CONFIG = { enableRichHyperlinks: false };
|
|
284733
|
-
ATOMIC_INLINE_TYPES = new Set([
|
|
284734
|
-
"image",
|
|
284735
|
-
"hardBreak",
|
|
284736
|
-
"lineBreak",
|
|
284737
|
-
"page-number",
|
|
284738
|
-
"total-page-number",
|
|
284739
|
-
"indexEntry",
|
|
284740
|
-
"tab",
|
|
284741
|
-
"footnoteReference",
|
|
284742
|
-
"mathInline",
|
|
284743
|
-
"passthroughInline",
|
|
284744
|
-
"bookmarkEnd",
|
|
284745
|
-
"fieldAnnotation",
|
|
284746
|
-
"documentStatField"
|
|
284747
|
-
]);
|
|
284748
|
-
TOKEN_INLINE_TYPES = new Map([["page-number", "pageNumber"], ["total-page-number", "totalPageCount"]]);
|
|
284749
|
-
LINE_END_SIZES = new Set([
|
|
284750
|
-
"sm",
|
|
284751
|
-
"med",
|
|
284752
|
-
"lg"
|
|
284753
|
-
]);
|
|
284754
284725
|
DEFAULT_BALANCING_CONFIG = {
|
|
284755
284726
|
enabled: true,
|
|
284756
284727
|
tolerance: 5,
|
|
@@ -284896,7 +284867,36 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
284896
284867
|
verbose: 3
|
|
284897
284868
|
};
|
|
284898
284869
|
import_lodash = require_lodash();
|
|
284870
|
+
PX_PER_PT2 = 96 / 72;
|
|
284871
|
+
VALID_TRACKED_MODES = [
|
|
284872
|
+
"review",
|
|
284873
|
+
"original",
|
|
284874
|
+
"final",
|
|
284875
|
+
"off"
|
|
284876
|
+
];
|
|
284877
|
+
DEFAULT_HYPERLINK_CONFIG = { enableRichHyperlinks: false };
|
|
284878
|
+
ATOMIC_INLINE_TYPES = new Set([
|
|
284879
|
+
"image",
|
|
284880
|
+
"hardBreak",
|
|
284881
|
+
"lineBreak",
|
|
284882
|
+
"page-number",
|
|
284883
|
+
"total-page-number",
|
|
284884
|
+
"indexEntry",
|
|
284885
|
+
"tab",
|
|
284886
|
+
"footnoteReference",
|
|
284887
|
+
"mathInline",
|
|
284888
|
+
"passthroughInline",
|
|
284889
|
+
"bookmarkEnd",
|
|
284890
|
+
"fieldAnnotation",
|
|
284891
|
+
"documentStatField"
|
|
284892
|
+
]);
|
|
284893
|
+
TOKEN_INLINE_TYPES = new Map([["page-number", "pageNumber"], ["total-page-number", "totalPageCount"]]);
|
|
284899
284894
|
init_dist4();
|
|
284895
|
+
LINE_END_SIZES = new Set([
|
|
284896
|
+
"sm",
|
|
284897
|
+
"med",
|
|
284898
|
+
"lg"
|
|
284899
|
+
]);
|
|
284900
284900
|
BORDER_STYLES = new Set([
|
|
284901
284901
|
"none",
|
|
284902
284902
|
"single",
|
|
@@ -289759,7 +289759,7 @@ var init_zipper_YmNpPIyc_es = __esm(() => {
|
|
|
289759
289759
|
|
|
289760
289760
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
289761
289761
|
var init_super_editor_es = __esm(() => {
|
|
289762
|
-
|
|
289762
|
+
init_src_CVvmm9fW_es();
|
|
289763
289763
|
init_SuperConverter_B9oNf3OB_es();
|
|
289764
289764
|
init_jszip_ChlR43oI_es();
|
|
289765
289765
|
init_xml_js_40FWvL78_es();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/cli",
|
|
3
|
-
"version": "0.5.0-next.
|
|
3
|
+
"version": "0.5.0-next.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@types/ws": "^8.5.13",
|
|
26
26
|
"typescript": "^5.9.2",
|
|
27
27
|
"@superdoc/pm-adapter": "0.0.0",
|
|
28
|
-
"@superdoc/document-api": "0.0.1",
|
|
29
28
|
"@superdoc/super-editor": "0.0.1",
|
|
29
|
+
"@superdoc/document-api": "0.0.1",
|
|
30
30
|
"superdoc": "1.23.0"
|
|
31
31
|
},
|
|
32
32
|
"module": "src/index.ts",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@superdoc-dev/cli-darwin-arm64": "0.5.0-next.
|
|
38
|
-
"@superdoc-dev/cli-darwin-x64": "0.5.0-next.
|
|
39
|
-
"@superdoc-dev/cli-linux-
|
|
40
|
-
"@superdoc-dev/cli-
|
|
41
|
-
"@superdoc-dev/cli-
|
|
37
|
+
"@superdoc-dev/cli-darwin-arm64": "0.5.0-next.31",
|
|
38
|
+
"@superdoc-dev/cli-darwin-x64": "0.5.0-next.31",
|
|
39
|
+
"@superdoc-dev/cli-linux-arm64": "0.5.0-next.31",
|
|
40
|
+
"@superdoc-dev/cli-windows-x64": "0.5.0-next.31",
|
|
41
|
+
"@superdoc-dev/cli-linux-x64": "0.5.0-next.31"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"predev": "node scripts/ensure-superdoc-build.js",
|