@superdoc-dev/cli 0.5.0-next.30 → 0.5.0-next.32
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 +560 -559
- package/package.json +9 -9
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-Cj-jgZJT.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)
|
|
@@ -221472,9 +221059,10 @@ function computeDomCaretPageLocal(options, pos) {
|
|
|
221472
221059
|
const textNode = targetEl.firstChild;
|
|
221473
221060
|
if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
|
|
221474
221061
|
const elRect = targetEl.getBoundingClientRect();
|
|
221062
|
+
const atEnd = pos >= entry.pmEnd;
|
|
221475
221063
|
return {
|
|
221476
221064
|
pageIndex: Number(page.dataset.pageIndex ?? "0"),
|
|
221477
|
-
x: (elRect.left - pageRect.left) / zoom,
|
|
221065
|
+
x: ((atEnd ? elRect.right : elRect.left) - pageRect.left) / zoom,
|
|
221478
221066
|
y: (elRect.top - pageRect.top) / zoom
|
|
221479
221067
|
};
|
|
221480
221068
|
}
|
|
@@ -221721,6 +221309,419 @@ function createLayoutMetrics(perf2, startMark, layout, blocks2) {
|
|
|
221721
221309
|
pageCount: layout.pages?.length ?? 0
|
|
221722
221310
|
};
|
|
221723
221311
|
}
|
|
221312
|
+
function coerceNumber(value) {
|
|
221313
|
+
if (isFiniteNumber(value))
|
|
221314
|
+
return Number(value);
|
|
221315
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
221316
|
+
const parsed = Number(value);
|
|
221317
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
221318
|
+
}
|
|
221319
|
+
}
|
|
221320
|
+
function coercePositiveNumber(value, fallback) {
|
|
221321
|
+
if (!isFiniteNumber(fallback) || fallback <= 0)
|
|
221322
|
+
throw new Error(`coercePositiveNumber: fallback must be a positive number, got ${fallback}`);
|
|
221323
|
+
const numeric = coerceNumber(value);
|
|
221324
|
+
if (numeric != null && numeric > 0)
|
|
221325
|
+
return numeric;
|
|
221326
|
+
return fallback;
|
|
221327
|
+
}
|
|
221328
|
+
function coerceBoolean(value) {
|
|
221329
|
+
if (typeof value === "boolean")
|
|
221330
|
+
return value;
|
|
221331
|
+
if (typeof value === "number") {
|
|
221332
|
+
if (value === 1)
|
|
221333
|
+
return true;
|
|
221334
|
+
if (value === 0)
|
|
221335
|
+
return false;
|
|
221336
|
+
return;
|
|
221337
|
+
}
|
|
221338
|
+
if (typeof value === "string") {
|
|
221339
|
+
const normalized = value.trim().toLowerCase();
|
|
221340
|
+
if ([
|
|
221341
|
+
"true",
|
|
221342
|
+
"1",
|
|
221343
|
+
"yes",
|
|
221344
|
+
"on"
|
|
221345
|
+
].includes(normalized))
|
|
221346
|
+
return true;
|
|
221347
|
+
if ([
|
|
221348
|
+
"false",
|
|
221349
|
+
"0",
|
|
221350
|
+
"no",
|
|
221351
|
+
"off"
|
|
221352
|
+
].includes(normalized))
|
|
221353
|
+
return false;
|
|
221354
|
+
}
|
|
221355
|
+
}
|
|
221356
|
+
function toBoxSpacing(spacing) {
|
|
221357
|
+
if (!spacing)
|
|
221358
|
+
return;
|
|
221359
|
+
const result = {};
|
|
221360
|
+
[
|
|
221361
|
+
"top",
|
|
221362
|
+
"right",
|
|
221363
|
+
"bottom",
|
|
221364
|
+
"left"
|
|
221365
|
+
].forEach((side) => {
|
|
221366
|
+
const value = spacing[side];
|
|
221367
|
+
if (isFiniteNumber(value))
|
|
221368
|
+
result[side] = Number(value);
|
|
221369
|
+
});
|
|
221370
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
221371
|
+
}
|
|
221372
|
+
function normalizeCellPaddingTopBottom(padding) {
|
|
221373
|
+
const out = { ...padding };
|
|
221374
|
+
if (typeof out.top === "number" && out.top > 0 && out.top < MIN_TOP_BOTTOM_CELL_PADDING_PX)
|
|
221375
|
+
out.top = MIN_TOP_BOTTOM_CELL_PADDING_PX;
|
|
221376
|
+
if (typeof out.bottom === "number" && out.bottom > 0 && out.bottom < MIN_TOP_BOTTOM_CELL_PADDING_PX)
|
|
221377
|
+
out.bottom = MIN_TOP_BOTTOM_CELL_PADDING_PX;
|
|
221378
|
+
return out;
|
|
221379
|
+
}
|
|
221380
|
+
function toDrawingContentSnapshot(value) {
|
|
221381
|
+
if (!value || typeof value !== "object")
|
|
221382
|
+
return;
|
|
221383
|
+
const raw = value;
|
|
221384
|
+
const name = raw.name;
|
|
221385
|
+
if (typeof name !== "string")
|
|
221386
|
+
return;
|
|
221387
|
+
const snapshot2 = { name };
|
|
221388
|
+
if (raw.attributes && typeof raw.attributes === "object" && !Array.isArray(raw.attributes))
|
|
221389
|
+
snapshot2.attributes = { ...raw.attributes };
|
|
221390
|
+
if (Array.isArray(raw.elements)) {
|
|
221391
|
+
const validElements = raw.elements.filter((el) => el != null && typeof el === "object");
|
|
221392
|
+
if (validElements.length > 0)
|
|
221393
|
+
snapshot2.elements = validElements;
|
|
221394
|
+
}
|
|
221395
|
+
return snapshot2;
|
|
221396
|
+
}
|
|
221397
|
+
function isShapeGroupTransform(value) {
|
|
221398
|
+
if (!value || typeof value !== "object")
|
|
221399
|
+
return false;
|
|
221400
|
+
const maybe = value;
|
|
221401
|
+
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);
|
|
221402
|
+
}
|
|
221403
|
+
function normalizeShapeSize(value) {
|
|
221404
|
+
if (!value || typeof value !== "object")
|
|
221405
|
+
return;
|
|
221406
|
+
const maybe = value;
|
|
221407
|
+
const width = coerceNumber(maybe.width);
|
|
221408
|
+
const height = coerceNumber(maybe.height);
|
|
221409
|
+
if (width == null && height == null)
|
|
221410
|
+
return;
|
|
221411
|
+
const result = {};
|
|
221412
|
+
if (width != null)
|
|
221413
|
+
result.width = width;
|
|
221414
|
+
if (height != null)
|
|
221415
|
+
result.height = height;
|
|
221416
|
+
return result;
|
|
221417
|
+
}
|
|
221418
|
+
function normalizeLineEnds(value) {
|
|
221419
|
+
if (!value || typeof value !== "object")
|
|
221420
|
+
return;
|
|
221421
|
+
const maybe = value;
|
|
221422
|
+
const head = normalizeLineEnd(maybe.head);
|
|
221423
|
+
const tail = normalizeLineEnd(maybe.tail);
|
|
221424
|
+
if (!head && !tail)
|
|
221425
|
+
return;
|
|
221426
|
+
return {
|
|
221427
|
+
head,
|
|
221428
|
+
tail
|
|
221429
|
+
};
|
|
221430
|
+
}
|
|
221431
|
+
function normalizeEffectExtent(value) {
|
|
221432
|
+
if (!value || typeof value !== "object")
|
|
221433
|
+
return;
|
|
221434
|
+
const maybe = value;
|
|
221435
|
+
const left$1 = coerceNumber(maybe.left);
|
|
221436
|
+
const top$1 = coerceNumber(maybe.top);
|
|
221437
|
+
const right$1 = coerceNumber(maybe.right);
|
|
221438
|
+
const bottom$1 = coerceNumber(maybe.bottom);
|
|
221439
|
+
if (left$1 == null && top$1 == null && right$1 == null && bottom$1 == null)
|
|
221440
|
+
return;
|
|
221441
|
+
const clamp$2 = (val) => val != null && val > 0 ? val : 0;
|
|
221442
|
+
return {
|
|
221443
|
+
left: clamp$2(left$1),
|
|
221444
|
+
top: clamp$2(top$1),
|
|
221445
|
+
right: clamp$2(right$1),
|
|
221446
|
+
bottom: clamp$2(bottom$1)
|
|
221447
|
+
};
|
|
221448
|
+
}
|
|
221449
|
+
function normalizeShapeGroupChildren(value) {
|
|
221450
|
+
if (!Array.isArray(value))
|
|
221451
|
+
return [];
|
|
221452
|
+
return value.filter((child) => {
|
|
221453
|
+
if (!child || typeof child !== "object")
|
|
221454
|
+
return false;
|
|
221455
|
+
return typeof child.shapeType === "string";
|
|
221456
|
+
});
|
|
221457
|
+
}
|
|
221458
|
+
function normalizeMediaKey(value) {
|
|
221459
|
+
if (!value)
|
|
221460
|
+
return;
|
|
221461
|
+
return value.replace(/\\/g, "/").replace(/^(\.\/|\/)+/, "");
|
|
221462
|
+
}
|
|
221463
|
+
function inferExtensionFromPath(value) {
|
|
221464
|
+
if (!value)
|
|
221465
|
+
return;
|
|
221466
|
+
const fileName = value.split("/").pop()?.split("\\").pop();
|
|
221467
|
+
if (!fileName || fileName.startsWith("."))
|
|
221468
|
+
return;
|
|
221469
|
+
const parts = fileName.split(".");
|
|
221470
|
+
if (parts.length < 2)
|
|
221471
|
+
return;
|
|
221472
|
+
const ext = parts.at(-1);
|
|
221473
|
+
if (!ext || ext.length === 0)
|
|
221474
|
+
return;
|
|
221475
|
+
return ext.toLowerCase();
|
|
221476
|
+
}
|
|
221477
|
+
function hydrateImageBlocks(blocks2, mediaFiles) {
|
|
221478
|
+
if (!mediaFiles || Object.keys(mediaFiles).length === 0)
|
|
221479
|
+
return blocks2;
|
|
221480
|
+
const normalizedMedia = /* @__PURE__ */ new Map;
|
|
221481
|
+
Object.entries(mediaFiles).forEach(([key$1, value]) => {
|
|
221482
|
+
const normalized = normalizeMediaKey(key$1);
|
|
221483
|
+
if (normalized) {
|
|
221484
|
+
const stringValue = value instanceof Uint8Array ? new TextDecoder().decode(value) : value;
|
|
221485
|
+
normalizedMedia.set(normalized, stringValue);
|
|
221486
|
+
}
|
|
221487
|
+
});
|
|
221488
|
+
if (normalizedMedia.size === 0)
|
|
221489
|
+
return blocks2;
|
|
221490
|
+
const resolveImageSrc = (src, relId, attrSrc, extension2) => {
|
|
221491
|
+
if (!src || src.startsWith("data:"))
|
|
221492
|
+
return;
|
|
221493
|
+
const candidates = /* @__PURE__ */ new Set;
|
|
221494
|
+
candidates.add(src);
|
|
221495
|
+
if (attrSrc)
|
|
221496
|
+
candidates.add(attrSrc);
|
|
221497
|
+
if (relId) {
|
|
221498
|
+
const inferredExt = extension2 ?? inferExtensionFromPath(src) ?? "jpeg";
|
|
221499
|
+
candidates.add(`word/media/${relId}.${inferredExt}`);
|
|
221500
|
+
candidates.add(`media/${relId}.${inferredExt}`);
|
|
221501
|
+
}
|
|
221502
|
+
for (const candidate of candidates) {
|
|
221503
|
+
const normalized = normalizeMediaKey(candidate);
|
|
221504
|
+
if (!normalized)
|
|
221505
|
+
continue;
|
|
221506
|
+
const base64 = normalizedMedia.get(normalized);
|
|
221507
|
+
if (!base64)
|
|
221508
|
+
continue;
|
|
221509
|
+
const finalExt = extension2 ?? inferExtensionFromPath(normalized) ?? "jpeg";
|
|
221510
|
+
return base64.startsWith("data:") ? base64 : `data:image/${finalExt};base64,${base64}`;
|
|
221511
|
+
}
|
|
221512
|
+
};
|
|
221513
|
+
const hydrateRuns = (runs2) => {
|
|
221514
|
+
let hasChanges = false;
|
|
221515
|
+
const hydratedRuns = runs2.map((run2) => {
|
|
221516
|
+
if (run2.kind !== "image")
|
|
221517
|
+
return run2;
|
|
221518
|
+
const imageRun = run2;
|
|
221519
|
+
if (!imageRun.src || imageRun.src.startsWith("data:"))
|
|
221520
|
+
return run2;
|
|
221521
|
+
const resolvedSrc = resolveImageSrc(imageRun.src);
|
|
221522
|
+
if (resolvedSrc) {
|
|
221523
|
+
hasChanges = true;
|
|
221524
|
+
return {
|
|
221525
|
+
...imageRun,
|
|
221526
|
+
src: resolvedSrc
|
|
221527
|
+
};
|
|
221528
|
+
}
|
|
221529
|
+
return run2;
|
|
221530
|
+
});
|
|
221531
|
+
return hasChanges ? hydratedRuns : runs2;
|
|
221532
|
+
};
|
|
221533
|
+
return blocks2.map((block) => {
|
|
221534
|
+
const hydrateBlock = (blk) => {
|
|
221535
|
+
if (blk.kind === "image") {
|
|
221536
|
+
if (!blk.src || blk.src.startsWith("data:"))
|
|
221537
|
+
return blk;
|
|
221538
|
+
const attrs = blk.attrs ?? {};
|
|
221539
|
+
const relId = typeof attrs.rId === "string" ? attrs.rId : undefined;
|
|
221540
|
+
const attrSrc = typeof attrs.src === "string" ? attrs.src : undefined;
|
|
221541
|
+
const extension2 = typeof attrs.extension === "string" ? attrs.extension.toLowerCase() : undefined;
|
|
221542
|
+
const resolvedSrc = resolveImageSrc(blk.src, relId, attrSrc, extension2);
|
|
221543
|
+
if (resolvedSrc)
|
|
221544
|
+
return {
|
|
221545
|
+
...blk,
|
|
221546
|
+
src: resolvedSrc
|
|
221547
|
+
};
|
|
221548
|
+
return blk;
|
|
221549
|
+
}
|
|
221550
|
+
if (blk.kind === "paragraph") {
|
|
221551
|
+
const paragraphBlock = blk;
|
|
221552
|
+
if (!paragraphBlock.runs || paragraphBlock.runs.length === 0)
|
|
221553
|
+
return blk;
|
|
221554
|
+
const hydratedRuns = hydrateRuns(paragraphBlock.runs);
|
|
221555
|
+
if (hydratedRuns !== paragraphBlock.runs)
|
|
221556
|
+
return {
|
|
221557
|
+
...paragraphBlock,
|
|
221558
|
+
runs: hydratedRuns
|
|
221559
|
+
};
|
|
221560
|
+
return blk;
|
|
221561
|
+
}
|
|
221562
|
+
if (blk.kind === "table") {
|
|
221563
|
+
let rowsChanged = false;
|
|
221564
|
+
const newRows = blk.rows.map((row2) => {
|
|
221565
|
+
let cellsChanged = false;
|
|
221566
|
+
const newCells = row2.cells.map((cell2) => {
|
|
221567
|
+
let cellChanged = false;
|
|
221568
|
+
const hydratedBlocks = (cell2.blocks ?? (cell2.paragraph ? [cell2.paragraph] : [])).map((cb) => hydrateBlock(cb));
|
|
221569
|
+
if (cell2.blocks && hydratedBlocks !== cell2.blocks)
|
|
221570
|
+
cellChanged = true;
|
|
221571
|
+
let hydratedParagraph = cell2.paragraph;
|
|
221572
|
+
if (!cell2.blocks && cell2.paragraph && cell2.paragraph.kind === "paragraph") {
|
|
221573
|
+
const hydratedPara = hydrateBlock(cell2.paragraph);
|
|
221574
|
+
if (hydratedPara !== cell2.paragraph) {
|
|
221575
|
+
hydratedParagraph = hydratedPara;
|
|
221576
|
+
cellChanged = true;
|
|
221577
|
+
}
|
|
221578
|
+
}
|
|
221579
|
+
if (cellChanged)
|
|
221580
|
+
return {
|
|
221581
|
+
...cell2,
|
|
221582
|
+
blocks: hydratedBlocks.length > 0 ? hydratedBlocks : cell2.blocks,
|
|
221583
|
+
paragraph: hydratedParagraph
|
|
221584
|
+
};
|
|
221585
|
+
return cell2;
|
|
221586
|
+
});
|
|
221587
|
+
if (newCells.some((c, idx) => c !== row2.cells[idx]))
|
|
221588
|
+
cellsChanged = true;
|
|
221589
|
+
if (cellsChanged) {
|
|
221590
|
+
rowsChanged = true;
|
|
221591
|
+
return {
|
|
221592
|
+
...row2,
|
|
221593
|
+
cells: newCells
|
|
221594
|
+
};
|
|
221595
|
+
}
|
|
221596
|
+
return row2;
|
|
221597
|
+
});
|
|
221598
|
+
if (rowsChanged)
|
|
221599
|
+
return {
|
|
221600
|
+
...blk,
|
|
221601
|
+
rows: newRows
|
|
221602
|
+
};
|
|
221603
|
+
return blk;
|
|
221604
|
+
}
|
|
221605
|
+
if (blk.kind === "drawing") {
|
|
221606
|
+
const drawingBlock = blk;
|
|
221607
|
+
if (drawingBlock.drawingKind !== "shapeGroup")
|
|
221608
|
+
return blk;
|
|
221609
|
+
const shapeGroupBlock = drawingBlock;
|
|
221610
|
+
if (!shapeGroupBlock.shapes || shapeGroupBlock.shapes.length === 0)
|
|
221611
|
+
return blk;
|
|
221612
|
+
let shapesChanged = false;
|
|
221613
|
+
const hydratedShapes = shapeGroupBlock.shapes.map((shape) => {
|
|
221614
|
+
if (shape.shapeType !== "image")
|
|
221615
|
+
return shape;
|
|
221616
|
+
const imageChild = shape;
|
|
221617
|
+
const src = imageChild.attrs?.src;
|
|
221618
|
+
if (!src || src.startsWith("data:"))
|
|
221619
|
+
return shape;
|
|
221620
|
+
const resolvedSrc = resolveImageSrc(src);
|
|
221621
|
+
if (resolvedSrc) {
|
|
221622
|
+
shapesChanged = true;
|
|
221623
|
+
return {
|
|
221624
|
+
...imageChild,
|
|
221625
|
+
attrs: {
|
|
221626
|
+
...imageChild.attrs,
|
|
221627
|
+
src: resolvedSrc
|
|
221628
|
+
}
|
|
221629
|
+
};
|
|
221630
|
+
}
|
|
221631
|
+
return shape;
|
|
221632
|
+
});
|
|
221633
|
+
if (shapesChanged)
|
|
221634
|
+
return {
|
|
221635
|
+
...shapeGroupBlock,
|
|
221636
|
+
shapes: hydratedShapes
|
|
221637
|
+
};
|
|
221638
|
+
return blk;
|
|
221639
|
+
}
|
|
221640
|
+
return blk;
|
|
221641
|
+
};
|
|
221642
|
+
return hydrateBlock(block);
|
|
221643
|
+
});
|
|
221644
|
+
}
|
|
221645
|
+
function isGradientFill(value) {
|
|
221646
|
+
if (!isPlainObject4(value))
|
|
221647
|
+
return false;
|
|
221648
|
+
if (value.type !== "gradient")
|
|
221649
|
+
return false;
|
|
221650
|
+
const gradientType = value.gradientType;
|
|
221651
|
+
if (gradientType !== "linear" && gradientType !== "radial")
|
|
221652
|
+
return false;
|
|
221653
|
+
if (gradientType === "linear") {
|
|
221654
|
+
if (typeof value.angle !== "number" || !Number.isFinite(value.angle))
|
|
221655
|
+
return false;
|
|
221656
|
+
}
|
|
221657
|
+
if (!Array.isArray(value.stops) || value.stops.length === 0)
|
|
221658
|
+
return false;
|
|
221659
|
+
return value.stops.every((stop) => {
|
|
221660
|
+
if (!isPlainObject4(stop))
|
|
221661
|
+
return false;
|
|
221662
|
+
return typeof stop.position === "number" && Number.isFinite(stop.position) && typeof stop.color === "string" && (stop.alpha === undefined || typeof stop.alpha === "number" && Number.isFinite(stop.alpha));
|
|
221663
|
+
});
|
|
221664
|
+
}
|
|
221665
|
+
function isSolidFillWithAlpha(value) {
|
|
221666
|
+
return isPlainObject4(value) && value.type === "solidWithAlpha" && typeof value.color === "string" && typeof value.alpha === "number";
|
|
221667
|
+
}
|
|
221668
|
+
function normalizeFillColor(value) {
|
|
221669
|
+
if (value === null)
|
|
221670
|
+
return null;
|
|
221671
|
+
if (typeof value === "string")
|
|
221672
|
+
return value;
|
|
221673
|
+
if (isGradientFill(value))
|
|
221674
|
+
return value;
|
|
221675
|
+
if (isSolidFillWithAlpha(value))
|
|
221676
|
+
return value;
|
|
221677
|
+
}
|
|
221678
|
+
function normalizeStrokeColor(value) {
|
|
221679
|
+
if (value === null)
|
|
221680
|
+
return null;
|
|
221681
|
+
if (typeof value === "string")
|
|
221682
|
+
return value;
|
|
221683
|
+
}
|
|
221684
|
+
function normalizeTextContent(value) {
|
|
221685
|
+
if (!isPlainObject4(value))
|
|
221686
|
+
return;
|
|
221687
|
+
if (!Array.isArray(value.parts))
|
|
221688
|
+
return;
|
|
221689
|
+
if (value.parts.length === 0)
|
|
221690
|
+
return;
|
|
221691
|
+
const validParts = value.parts.filter((p$12) => isPlainObject4(p$12) && typeof p$12.text === "string");
|
|
221692
|
+
if (validParts.length === 0)
|
|
221693
|
+
return;
|
|
221694
|
+
const result = { parts: validParts };
|
|
221695
|
+
if ([
|
|
221696
|
+
"left",
|
|
221697
|
+
"center",
|
|
221698
|
+
"right"
|
|
221699
|
+
].includes(value.horizontalAlign))
|
|
221700
|
+
result.horizontalAlign = value.horizontalAlign;
|
|
221701
|
+
return result;
|
|
221702
|
+
}
|
|
221703
|
+
function normalizeTextVerticalAlign(value) {
|
|
221704
|
+
if (typeof value !== "string")
|
|
221705
|
+
return;
|
|
221706
|
+
if (value === "top" || value === "center" || value === "bottom")
|
|
221707
|
+
return value;
|
|
221708
|
+
}
|
|
221709
|
+
function normalizeTextInsets(value) {
|
|
221710
|
+
if (!isPlainObject4(value))
|
|
221711
|
+
return;
|
|
221712
|
+
const top$1 = pickNumber(value.top);
|
|
221713
|
+
const right$1 = pickNumber(value.right);
|
|
221714
|
+
const bottom$1 = pickNumber(value.bottom);
|
|
221715
|
+
const left$1 = pickNumber(value.left);
|
|
221716
|
+
if (top$1 == null || right$1 == null || bottom$1 == null || left$1 == null)
|
|
221717
|
+
return;
|
|
221718
|
+
return {
|
|
221719
|
+
top: top$1,
|
|
221720
|
+
right: right$1,
|
|
221721
|
+
bottom: bottom$1,
|
|
221722
|
+
left: left$1
|
|
221723
|
+
};
|
|
221724
|
+
}
|
|
221724
221725
|
function shiftBlockPositions(block, delta) {
|
|
221725
221726
|
if (block.kind === "paragraph") {
|
|
221726
221727
|
const paragraphBlock = block;
|
|
@@ -246333,104 +246334,6 @@ var Node$13 = class Node$14 {
|
|
|
246333
246334
|
pmStart: start$1,
|
|
246334
246335
|
pmEnd: (typeof attrs.pmEnd === "number" ? attrs.pmEnd : undefined) ?? (start$1 != null ? start$1 + 1 : undefined)
|
|
246335
246336
|
};
|
|
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
246337
|
}, getParagraphAttrs = (block) => {
|
|
246435
246338
|
if (!block.attrs || typeof block.attrs !== "object")
|
|
246436
246339
|
return;
|
|
@@ -249127,7 +249030,7 @@ var Node$13 = class Node$14 {
|
|
|
249127
249030
|
this.#onRebuild();
|
|
249128
249031
|
});
|
|
249129
249032
|
}
|
|
249130
|
-
}, Y_SORT_THRESHOLD_PX = 2, Y_SAME_LINE_THRESHOLD_PX = 3, HORIZONTAL_OVERLAP_THRESHOLD = 0.8, isValidTrackedMode = (value) => {
|
|
249033
|
+
}, 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
249034
|
return typeof value === "string" && VALID_TRACKED_MODES.includes(value);
|
|
249132
249035
|
}, isTextRun$3 = (run2) => {
|
|
249133
249036
|
return "text" in run2 && run2.kind !== "tab";
|
|
@@ -249236,6 +249139,104 @@ var Node$13 = class Node$14 {
|
|
|
249236
249139
|
});
|
|
249237
249140
|
}
|
|
249238
249141
|
return filtered;
|
|
249142
|
+
}, twipsToPx$1 = (value) => value / TWIPS_PER_INCH2 * 96, ptToPx = (pt) => {
|
|
249143
|
+
if (pt == null || !Number.isFinite(pt))
|
|
249144
|
+
return;
|
|
249145
|
+
return pt * PX_PER_PT2;
|
|
249146
|
+
}, isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value), isPlainObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), normalizePrefix = (value) => {
|
|
249147
|
+
if (!value)
|
|
249148
|
+
return "";
|
|
249149
|
+
return String(value);
|
|
249150
|
+
}, pickNumber = (value) => {
|
|
249151
|
+
if (isFiniteNumber(value))
|
|
249152
|
+
return value;
|
|
249153
|
+
if (typeof value === "string") {
|
|
249154
|
+
const parsed = parseFloat(value);
|
|
249155
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
249156
|
+
}
|
|
249157
|
+
}, normalizeColor = (value) => {
|
|
249158
|
+
if (typeof value !== "string")
|
|
249159
|
+
return;
|
|
249160
|
+
const trimmed = value.trim();
|
|
249161
|
+
if (!trimmed || trimmed === "auto" || trimmed === "none")
|
|
249162
|
+
return;
|
|
249163
|
+
return trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
249164
|
+
}, toBoolean = (value) => {
|
|
249165
|
+
if (typeof value === "boolean")
|
|
249166
|
+
return value;
|
|
249167
|
+
if (typeof value === "string") {
|
|
249168
|
+
const v = value.trim().toLowerCase();
|
|
249169
|
+
if (v === "true" || v === "1")
|
|
249170
|
+
return true;
|
|
249171
|
+
if (v === "false" || v === "0")
|
|
249172
|
+
return false;
|
|
249173
|
+
}
|
|
249174
|
+
if (typeof value === "number") {
|
|
249175
|
+
if (value === 1)
|
|
249176
|
+
return true;
|
|
249177
|
+
if (value === 0)
|
|
249178
|
+
return false;
|
|
249179
|
+
}
|
|
249180
|
+
}, MIN_TOP_BOTTOM_CELL_PADDING_PX = 2, buildPositionMap = (root3, options) => {
|
|
249181
|
+
const map$12 = /* @__PURE__ */ new WeakMap;
|
|
249182
|
+
const atomNodeTypes = new Set(ATOMIC_INLINE_TYPES);
|
|
249183
|
+
if (options?.atomNodeTypes) {
|
|
249184
|
+
for (const nodeType of options.atomNodeTypes)
|
|
249185
|
+
if (typeof nodeType === "string" && nodeType.length > 0)
|
|
249186
|
+
atomNodeTypes.add(nodeType);
|
|
249187
|
+
}
|
|
249188
|
+
const visit2 = (node3, pos) => {
|
|
249189
|
+
if (node3.type === "text") {
|
|
249190
|
+
const end$2 = pos + (node3.text?.length ?? 0);
|
|
249191
|
+
map$12.set(node3, {
|
|
249192
|
+
start: pos,
|
|
249193
|
+
end: end$2
|
|
249194
|
+
});
|
|
249195
|
+
return end$2;
|
|
249196
|
+
}
|
|
249197
|
+
if (atomNodeTypes.has(node3.type)) {
|
|
249198
|
+
const end$2 = pos + 1;
|
|
249199
|
+
map$12.set(node3, {
|
|
249200
|
+
start: pos,
|
|
249201
|
+
end: end$2
|
|
249202
|
+
});
|
|
249203
|
+
return end$2;
|
|
249204
|
+
}
|
|
249205
|
+
const open2 = node3.type === "doc" ? 0 : 1;
|
|
249206
|
+
const close2 = node3.type === "doc" ? 0 : 1;
|
|
249207
|
+
let nextPos = pos + open2;
|
|
249208
|
+
const content3 = Array.isArray(node3.content) ? node3.content : [];
|
|
249209
|
+
map$12.set(node3, {
|
|
249210
|
+
start: pos,
|
|
249211
|
+
end: pos
|
|
249212
|
+
});
|
|
249213
|
+
content3.forEach((child) => {
|
|
249214
|
+
nextPos = visit2(child, nextPos);
|
|
249215
|
+
});
|
|
249216
|
+
const end$1 = nextPos + close2;
|
|
249217
|
+
map$12.set(node3, {
|
|
249218
|
+
start: pos,
|
|
249219
|
+
end: end$1
|
|
249220
|
+
});
|
|
249221
|
+
return end$1;
|
|
249222
|
+
};
|
|
249223
|
+
visit2(root3, 0);
|
|
249224
|
+
return map$12;
|
|
249225
|
+
}, createBlockIdGenerator = (prefix2 = "") => {
|
|
249226
|
+
let counter = 0;
|
|
249227
|
+
return (kind) => `${prefix2}${counter++}-${kind}`;
|
|
249228
|
+
}, LINE_END_SIZES, normalizeLineEnd = (value) => {
|
|
249229
|
+
if (!value || typeof value !== "object")
|
|
249230
|
+
return;
|
|
249231
|
+
const maybe = value;
|
|
249232
|
+
const type = typeof maybe.type === "string" ? maybe.type : undefined;
|
|
249233
|
+
if (!type || type === "none")
|
|
249234
|
+
return;
|
|
249235
|
+
return {
|
|
249236
|
+
type,
|
|
249237
|
+
width: typeof maybe.width === "string" && LINE_END_SIZES.has(maybe.width) ? maybe.width : undefined,
|
|
249238
|
+
length: typeof maybe.length === "string" && LINE_END_SIZES.has(maybe.length) ? maybe.length : undefined
|
|
249239
|
+
};
|
|
249239
249240
|
}, getNodeRevision = (node3) => {
|
|
249240
249241
|
const attrs = node3?.attrs;
|
|
249241
249242
|
if (!attrs)
|
|
@@ -255272,7 +255273,7 @@ var Node$13 = class Node$14 {
|
|
|
255272
255273
|
return;
|
|
255273
255274
|
console.log(...args$1);
|
|
255274
255275
|
}, 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
|
|
255276
|
+
var init_src_Cj_jgZJT_es = __esm(() => {
|
|
255276
255277
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
255277
255278
|
init_SuperConverter_B9oNf3OB_es();
|
|
255278
255279
|
init_jszip_ChlR43oI_es();
|
|
@@ -276189,8 +276190,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
276189
276190
|
wrapper.className = "sd-math";
|
|
276190
276191
|
wrapper.style.display = "inline-block";
|
|
276191
276192
|
wrapper.style.verticalAlign = "middle";
|
|
276192
|
-
wrapper.style.
|
|
276193
|
-
wrapper.style.
|
|
276193
|
+
wrapper.style.minWidth = `${run2.width}px`;
|
|
276194
|
+
wrapper.style.minHeight = `${run2.height}px`;
|
|
276194
276195
|
wrapper.dataset.layoutEpoch = String(this.layoutEpoch ?? 0);
|
|
276195
276196
|
const mathEl = convertOmmlToMathml(run2.ommlJson, this.doc);
|
|
276196
276197
|
if (mathEl)
|
|
@@ -284722,35 +284723,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
284722
284723
|
count: 1,
|
|
284723
284724
|
gap: 0
|
|
284724
284725
|
};
|
|
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
284726
|
DEFAULT_BALANCING_CONFIG = {
|
|
284755
284727
|
enabled: true,
|
|
284756
284728
|
tolerance: 5,
|
|
@@ -284896,7 +284868,36 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
284896
284868
|
verbose: 3
|
|
284897
284869
|
};
|
|
284898
284870
|
import_lodash = require_lodash();
|
|
284871
|
+
PX_PER_PT2 = 96 / 72;
|
|
284872
|
+
VALID_TRACKED_MODES = [
|
|
284873
|
+
"review",
|
|
284874
|
+
"original",
|
|
284875
|
+
"final",
|
|
284876
|
+
"off"
|
|
284877
|
+
];
|
|
284878
|
+
DEFAULT_HYPERLINK_CONFIG = { enableRichHyperlinks: false };
|
|
284879
|
+
ATOMIC_INLINE_TYPES = new Set([
|
|
284880
|
+
"image",
|
|
284881
|
+
"hardBreak",
|
|
284882
|
+
"lineBreak",
|
|
284883
|
+
"page-number",
|
|
284884
|
+
"total-page-number",
|
|
284885
|
+
"indexEntry",
|
|
284886
|
+
"tab",
|
|
284887
|
+
"footnoteReference",
|
|
284888
|
+
"mathInline",
|
|
284889
|
+
"passthroughInline",
|
|
284890
|
+
"bookmarkEnd",
|
|
284891
|
+
"fieldAnnotation",
|
|
284892
|
+
"documentStatField"
|
|
284893
|
+
]);
|
|
284894
|
+
TOKEN_INLINE_TYPES = new Map([["page-number", "pageNumber"], ["total-page-number", "totalPageCount"]]);
|
|
284899
284895
|
init_dist4();
|
|
284896
|
+
LINE_END_SIZES = new Set([
|
|
284897
|
+
"sm",
|
|
284898
|
+
"med",
|
|
284899
|
+
"lg"
|
|
284900
|
+
]);
|
|
284900
284901
|
BORDER_STYLES = new Set([
|
|
284901
284902
|
"none",
|
|
284902
284903
|
"single",
|
|
@@ -289759,7 +289760,7 @@ var init_zipper_YmNpPIyc_es = __esm(() => {
|
|
|
289759
289760
|
|
|
289760
289761
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
289761
289762
|
var init_super_editor_es = __esm(() => {
|
|
289762
|
-
|
|
289763
|
+
init_src_Cj_jgZJT_es();
|
|
289763
289764
|
init_SuperConverter_B9oNf3OB_es();
|
|
289764
289765
|
init_jszip_ChlR43oI_es();
|
|
289765
289766
|
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.32",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"@types/node": "22.19.2",
|
|
25
25
|
"@types/ws": "^8.5.13",
|
|
26
26
|
"typescript": "^5.9.2",
|
|
27
|
-
"@superdoc/pm-adapter": "0.0.0",
|
|
28
27
|
"@superdoc/document-api": "0.0.1",
|
|
29
|
-
"@superdoc/
|
|
30
|
-
"superdoc": "1.23.0"
|
|
28
|
+
"@superdoc/pm-adapter": "0.0.0",
|
|
29
|
+
"superdoc": "1.23.0",
|
|
30
|
+
"@superdoc/super-editor": "0.0.1"
|
|
31
31
|
},
|
|
32
32
|
"module": "src/index.ts",
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@superdoc-dev/cli-darwin-arm64": "0.5.0-next.
|
|
38
|
-
"@superdoc-dev/cli-
|
|
39
|
-
"@superdoc-dev/cli-linux-
|
|
40
|
-
"@superdoc-dev/cli-
|
|
41
|
-
"@superdoc-dev/cli-
|
|
37
|
+
"@superdoc-dev/cli-darwin-arm64": "0.5.0-next.32",
|
|
38
|
+
"@superdoc-dev/cli-linux-x64": "0.5.0-next.32",
|
|
39
|
+
"@superdoc-dev/cli-linux-arm64": "0.5.0-next.32",
|
|
40
|
+
"@superdoc-dev/cli-windows-x64": "0.5.0-next.32",
|
|
41
|
+
"@superdoc-dev/cli-darwin-x64": "0.5.0-next.32"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"predev": "node scripts/ensure-superdoc-build.js",
|