@superdoc-dev/cli 0.5.0-next.7 → 0.5.0-next.8
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 +88 -90
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -171536,7 +171536,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
|
|
|
171536
171536
|
init_remark_gfm_z_sDF4ss_es();
|
|
171537
171537
|
});
|
|
171538
171538
|
|
|
171539
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
171539
|
+
// ../../packages/superdoc/dist/chunks/src-DGLGUgC-.es.js
|
|
171540
171540
|
function deleteProps(obj, propOrProps) {
|
|
171541
171541
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
171542
171542
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -217329,6 +217329,12 @@ function findCharacterAtX(block, line, x, pmStart, availableWidthOverride, align
|
|
|
217329
217329
|
pmPosition
|
|
217330
217330
|
};
|
|
217331
217331
|
}
|
|
217332
|
+
function isRtlLine(lineEl) {
|
|
217333
|
+
return getComputedStyle(lineEl).direction === "rtl";
|
|
217334
|
+
}
|
|
217335
|
+
function isVisibleRect(rect) {
|
|
217336
|
+
return rect.width > 0 && rect.height > 0;
|
|
217337
|
+
}
|
|
217332
217338
|
function clickToPositionDom(domContainer, clientX, clientY) {
|
|
217333
217339
|
log2("=== clickToPositionDom START ===");
|
|
217334
217340
|
log2("Input coords:", {
|
|
@@ -217533,64 +217539,7 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
217533
217539
|
}
|
|
217534
217540
|
};
|
|
217535
217541
|
}));
|
|
217536
|
-
|
|
217537
|
-
log2("No spans in line, returning lineStart:", lineStart);
|
|
217538
|
-
return lineStart;
|
|
217539
|
-
}
|
|
217540
|
-
if (viewX <= spanEls[0].getBoundingClientRect().left) {
|
|
217541
|
-
log2("Click before first span, returning lineStart:", lineStart);
|
|
217542
|
-
return lineStart;
|
|
217543
|
-
}
|
|
217544
|
-
if (viewX >= spanEls[spanEls.length - 1].getBoundingClientRect().right) {
|
|
217545
|
-
log2("Click after last span, returning lineEnd:", lineEnd);
|
|
217546
|
-
return lineEnd;
|
|
217547
|
-
}
|
|
217548
|
-
const targetEl = findSpanAtX(spanEls, viewX);
|
|
217549
|
-
if (!targetEl) {
|
|
217550
|
-
log2("No target element found, returning lineStart:", lineStart);
|
|
217551
|
-
return lineStart;
|
|
217552
|
-
}
|
|
217553
|
-
const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
|
|
217554
|
-
const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
|
|
217555
|
-
const targetRect = targetEl.getBoundingClientRect();
|
|
217556
|
-
log2("Target element:", {
|
|
217557
|
-
tag: targetEl.tagName,
|
|
217558
|
-
pmStart: spanStart,
|
|
217559
|
-
pmEnd: spanEnd,
|
|
217560
|
-
text: targetEl.textContent?.substring(0, 30),
|
|
217561
|
-
visibility: targetEl.style.visibility,
|
|
217562
|
-
rect: {
|
|
217563
|
-
left: targetRect.left,
|
|
217564
|
-
right: targetRect.right,
|
|
217565
|
-
width: targetRect.width
|
|
217566
|
-
},
|
|
217567
|
-
pageX: viewX,
|
|
217568
|
-
pageY: viewY
|
|
217569
|
-
});
|
|
217570
|
-
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
|
|
217571
|
-
log2("Element has invalid PM positions");
|
|
217572
|
-
return null;
|
|
217573
|
-
}
|
|
217574
|
-
const firstChild = targetEl.firstChild;
|
|
217575
|
-
if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
|
|
217576
|
-
const elRect = targetEl.getBoundingClientRect();
|
|
217577
|
-
const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
|
|
217578
|
-
const snapPos = closerToLeft ? spanStart : spanEnd;
|
|
217579
|
-
log2("Empty/non-text element, snapping to:", {
|
|
217580
|
-
closerToLeft,
|
|
217581
|
-
snapPos
|
|
217582
|
-
});
|
|
217583
|
-
return snapPos;
|
|
217584
|
-
}
|
|
217585
|
-
const textNode = firstChild;
|
|
217586
|
-
const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
|
|
217587
|
-
const pos = mapCharIndexToPm(spanStart, spanEnd, textNode.length, charIndex);
|
|
217588
|
-
log2("Character position:", {
|
|
217589
|
-
charIndex,
|
|
217590
|
-
spanStart,
|
|
217591
|
-
finalPos: pos
|
|
217592
|
-
});
|
|
217593
|
-
return pos;
|
|
217542
|
+
return resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX);
|
|
217594
217543
|
}
|
|
217595
217544
|
function mapCharIndexToPm(spanStart, spanEnd, textLength, charIndex) {
|
|
217596
217545
|
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd))
|
|
@@ -217641,17 +217590,28 @@ function processLineElement(lineEl, viewX) {
|
|
|
217641
217590
|
}
|
|
217642
217591
|
};
|
|
217643
217592
|
}));
|
|
217593
|
+
return resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX);
|
|
217594
|
+
}
|
|
217595
|
+
function resolveLinePosition(lineEl, lineStart, lineEnd, spanEls, viewX) {
|
|
217644
217596
|
if (spanEls.length === 0) {
|
|
217645
217597
|
log2("No spans in line, returning lineStart:", lineStart);
|
|
217646
217598
|
return lineStart;
|
|
217647
217599
|
}
|
|
217648
|
-
|
|
217649
|
-
|
|
217650
|
-
|
|
217651
|
-
|
|
217652
|
-
|
|
217653
|
-
|
|
217654
|
-
|
|
217600
|
+
const rtl = isRtlLine(lineEl);
|
|
217601
|
+
const allRects = spanEls.map((el) => el.getBoundingClientRect());
|
|
217602
|
+
const visibleRects = allRects.filter(isVisibleRect);
|
|
217603
|
+
const boundsRects = visibleRects.length > 0 ? visibleRects : allRects;
|
|
217604
|
+
const visualLeft = Math.min(...boundsRects.map((r$1) => r$1.left));
|
|
217605
|
+
const visualRight = Math.max(...boundsRects.map((r$1) => r$1.right));
|
|
217606
|
+
if (viewX <= visualLeft) {
|
|
217607
|
+
const pos$1 = rtl ? lineEnd : lineStart;
|
|
217608
|
+
log2("Click to visual left of all spans, returning:", pos$1);
|
|
217609
|
+
return pos$1;
|
|
217610
|
+
}
|
|
217611
|
+
if (viewX >= visualRight) {
|
|
217612
|
+
const pos$1 = rtl ? lineStart : lineEnd;
|
|
217613
|
+
log2("Click to visual right of all spans, returning:", pos$1);
|
|
217614
|
+
return pos$1;
|
|
217655
217615
|
}
|
|
217656
217616
|
const targetEl = findSpanAtX(spanEls, viewX);
|
|
217657
217617
|
if (!targetEl) {
|
|
@@ -217660,18 +217620,20 @@ function processLineElement(lineEl, viewX) {
|
|
|
217660
217620
|
}
|
|
217661
217621
|
const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
|
|
217662
217622
|
const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
|
|
217663
|
-
const targetRect = targetEl.getBoundingClientRect();
|
|
217664
217623
|
log2("Target element:", {
|
|
217665
217624
|
tag: targetEl.tagName,
|
|
217666
217625
|
pmStart: spanStart,
|
|
217667
217626
|
pmEnd: spanEnd,
|
|
217668
217627
|
text: targetEl.textContent?.substring(0, 30),
|
|
217669
217628
|
visibility: targetEl.style.visibility,
|
|
217670
|
-
rect: {
|
|
217671
|
-
|
|
217672
|
-
|
|
217673
|
-
|
|
217674
|
-
|
|
217629
|
+
rect: (() => {
|
|
217630
|
+
const r$1 = targetEl.getBoundingClientRect();
|
|
217631
|
+
return {
|
|
217632
|
+
left: r$1.left,
|
|
217633
|
+
right: r$1.right,
|
|
217634
|
+
width: r$1.width
|
|
217635
|
+
};
|
|
217636
|
+
})()
|
|
217675
217637
|
});
|
|
217676
217638
|
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
|
|
217677
217639
|
log2("Element has invalid PM positions");
|
|
@@ -217681,18 +217643,21 @@ function processLineElement(lineEl, viewX) {
|
|
|
217681
217643
|
if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
|
|
217682
217644
|
const elRect = targetEl.getBoundingClientRect();
|
|
217683
217645
|
const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
|
|
217684
|
-
const snapPos = closerToLeft ? spanStart : spanEnd;
|
|
217646
|
+
const snapPos = rtl ? closerToLeft ? spanEnd : spanStart : closerToLeft ? spanStart : spanEnd;
|
|
217685
217647
|
log2("Empty/non-text element, snapping to:", {
|
|
217686
217648
|
closerToLeft,
|
|
217649
|
+
rtl,
|
|
217687
217650
|
snapPos
|
|
217688
217651
|
});
|
|
217689
217652
|
return snapPos;
|
|
217690
217653
|
}
|
|
217691
|
-
const
|
|
217692
|
-
const
|
|
217654
|
+
const textNode = firstChild;
|
|
217655
|
+
const charIndex = findCharIndexAtX(textNode, viewX, rtl);
|
|
217656
|
+
const pos = mapCharIndexToPm(spanStart, spanEnd, textNode.length, charIndex);
|
|
217693
217657
|
log2("Character position:", {
|
|
217694
217658
|
charIndex,
|
|
217695
217659
|
spanStart,
|
|
217660
|
+
rtl,
|
|
217696
217661
|
finalPos: pos
|
|
217697
217662
|
});
|
|
217698
217663
|
return pos;
|
|
@@ -217728,9 +217693,12 @@ function findSpanAtX(spanEls, viewX) {
|
|
|
217728
217693
|
if (spanEls.length === 0)
|
|
217729
217694
|
return null;
|
|
217730
217695
|
let targetSpan = spanEls[0];
|
|
217696
|
+
let minDist = Infinity;
|
|
217731
217697
|
for (let i4 = 0;i4 < spanEls.length; i4++) {
|
|
217732
217698
|
const span = spanEls[i4];
|
|
217733
217699
|
const rect = span.getBoundingClientRect();
|
|
217700
|
+
if (!isVisibleRect(rect))
|
|
217701
|
+
continue;
|
|
217734
217702
|
if (viewX >= rect.left && viewX <= rect.right) {
|
|
217735
217703
|
log2("findSpanAtX: Found containing element at index", i4, {
|
|
217736
217704
|
tag: span.tagName,
|
|
@@ -217744,8 +217712,11 @@ function findSpanAtX(spanEls, viewX) {
|
|
|
217744
217712
|
});
|
|
217745
217713
|
return span;
|
|
217746
217714
|
}
|
|
217747
|
-
|
|
217715
|
+
const dist = Math.min(Math.abs(viewX - rect.left), Math.abs(viewX - rect.right));
|
|
217716
|
+
if (dist < minDist) {
|
|
217717
|
+
minDist = dist;
|
|
217748
217718
|
targetSpan = span;
|
|
217719
|
+
}
|
|
217749
217720
|
}
|
|
217750
217721
|
log2("findSpanAtX: No containing element, using nearest:", {
|
|
217751
217722
|
tag: targetSpan.tagName,
|
|
@@ -217755,36 +217726,63 @@ function findSpanAtX(spanEls, viewX) {
|
|
|
217755
217726
|
});
|
|
217756
217727
|
return targetSpan;
|
|
217757
217728
|
}
|
|
217758
|
-
function findCharIndexAtX(textNode,
|
|
217729
|
+
function findCharIndexAtX(textNode, targetX, rtl) {
|
|
217759
217730
|
const text5 = textNode.textContent ?? "";
|
|
217760
|
-
|
|
217731
|
+
if (text5.length === 0)
|
|
217732
|
+
return 0;
|
|
217733
|
+
const container = textNode.parentElement;
|
|
217734
|
+
if (!container)
|
|
217735
|
+
return 0;
|
|
217736
|
+
const containerRect = container.getBoundingClientRect();
|
|
217737
|
+
const caretIndex = caretOffsetFromPoint(targetX, containerRect.top + containerRect.height / 2, textNode);
|
|
217738
|
+
if (caretIndex != null) {
|
|
217739
|
+
log2("findCharIndexAtX: caret API returned", caretIndex);
|
|
217740
|
+
return caretIndex;
|
|
217741
|
+
}
|
|
217742
|
+
log2("findCharIndexAtX: falling back to range binary search, rtl =", rtl);
|
|
217761
217743
|
const range = document.createRange();
|
|
217744
|
+
const measureX = (i4) => {
|
|
217745
|
+
if (i4 <= 0)
|
|
217746
|
+
return rtl ? containerRect.right : containerRect.left;
|
|
217747
|
+
range.setStart(textNode, 0);
|
|
217748
|
+
range.setEnd(textNode, i4);
|
|
217749
|
+
const r$1 = range.getBoundingClientRect();
|
|
217750
|
+
return rtl ? r$1.left : r$1.right;
|
|
217751
|
+
};
|
|
217762
217752
|
let lo = 0;
|
|
217763
217753
|
let hi = text5.length;
|
|
217764
217754
|
while (lo < hi) {
|
|
217765
217755
|
const mid = Math.floor((lo + hi) / 2);
|
|
217766
|
-
|
|
217767
|
-
|
|
217768
|
-
if (baseLeft + range.getBoundingClientRect().width < targetX)
|
|
217756
|
+
const x = measureX(mid);
|
|
217757
|
+
if (rtl ? x > targetX : x < targetX)
|
|
217769
217758
|
lo = mid + 1;
|
|
217770
217759
|
else
|
|
217771
217760
|
hi = mid;
|
|
217772
217761
|
}
|
|
217773
217762
|
const index2 = Math.max(0, Math.min(text5.length, lo));
|
|
217774
|
-
const
|
|
217775
|
-
range.setStart(textNode, 0);
|
|
217776
|
-
range.setEnd(textNode, i4);
|
|
217777
|
-
return baseLeft + range.getBoundingClientRect().width;
|
|
217778
|
-
};
|
|
217779
|
-
const xAt = measureAt(index2);
|
|
217763
|
+
const xAt = measureX(index2);
|
|
217780
217764
|
const distAt = Math.abs(xAt - targetX);
|
|
217781
217765
|
if (index2 > 0) {
|
|
217782
|
-
const xPrev =
|
|
217766
|
+
const xPrev = measureX(index2 - 1);
|
|
217783
217767
|
if (Math.abs(xPrev - targetX) < distAt)
|
|
217784
217768
|
return index2 - 1;
|
|
217785
217769
|
}
|
|
217786
217770
|
return index2;
|
|
217787
217771
|
}
|
|
217772
|
+
function caretOffsetFromPoint(x, y$1, expectedNode) {
|
|
217773
|
+
const doc$12 = document;
|
|
217774
|
+
if (typeof doc$12.caretPositionFromPoint === "function") {
|
|
217775
|
+
const cp = doc$12.caretPositionFromPoint(x, y$1);
|
|
217776
|
+
if (cp && cp.offsetNode === expectedNode)
|
|
217777
|
+
return cp.offset;
|
|
217778
|
+
}
|
|
217779
|
+
if (typeof doc$12.caretRangeFromPoint === "function") {
|
|
217780
|
+
const r$1 = doc$12.caretRangeFromPoint(x, y$1);
|
|
217781
|
+
if (r$1 && r$1.startContainer === expectedNode)
|
|
217782
|
+
return r$1.startOffset;
|
|
217783
|
+
}
|
|
217784
|
+
return null;
|
|
217785
|
+
}
|
|
217788
217786
|
function getWordLayoutConfig(block) {
|
|
217789
217787
|
if (!block || block.kind !== "paragraph")
|
|
217790
217788
|
return;
|
|
@@ -252330,7 +252328,7 @@ var Node$13 = class Node$14 {
|
|
|
252330
252328
|
return;
|
|
252331
252329
|
console.log(...args$1);
|
|
252332
252330
|
}, 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;
|
|
252333
|
-
var
|
|
252331
|
+
var init_src_DGLGUgC_es = __esm(() => {
|
|
252334
252332
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
252335
252333
|
init_SuperConverter_CXcZg9Os_es();
|
|
252336
252334
|
init_jszip_ChlR43oI_es();
|
|
@@ -285845,7 +285843,7 @@ var init_zipper_YmNpPIyc_es = __esm(() => {
|
|
|
285845
285843
|
|
|
285846
285844
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
285847
285845
|
var init_super_editor_es = __esm(() => {
|
|
285848
|
-
|
|
285846
|
+
init_src_DGLGUgC_es();
|
|
285849
285847
|
init_SuperConverter_CXcZg9Os_es();
|
|
285850
285848
|
init_jszip_ChlR43oI_es();
|
|
285851
285849
|
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.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"typescript": "^5.9.2",
|
|
27
27
|
"@superdoc/document-api": "0.0.1",
|
|
28
28
|
"@superdoc/pm-adapter": "0.0.0",
|
|
29
|
-
"
|
|
30
|
-
"superdoc": "
|
|
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-darwin-x64": "0.5.0-next.
|
|
39
|
-
"@superdoc-dev/cli-linux-x64": "0.5.0-next.
|
|
40
|
-
"@superdoc-dev/cli-
|
|
41
|
-
"@superdoc-dev/cli-
|
|
37
|
+
"@superdoc-dev/cli-darwin-arm64": "0.5.0-next.8",
|
|
38
|
+
"@superdoc-dev/cli-darwin-x64": "0.5.0-next.8",
|
|
39
|
+
"@superdoc-dev/cli-linux-x64": "0.5.0-next.8",
|
|
40
|
+
"@superdoc-dev/cli-linux-arm64": "0.5.0-next.8",
|
|
41
|
+
"@superdoc-dev/cli-windows-x64": "0.5.0-next.8"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"predev": "node scripts/ensure-superdoc-build.js",
|