@underverse-ui/underverse 2.0.42 → 2.0.44
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/api-reference.json +1 -1
- package/dist/{chunk-7YU3O5JK.js → chunk-2ELWYT7Y.js} +16 -13
- package/dist/chunk-2ELWYT7Y.js.map +1 -0
- package/dist/{chunk-TVCZXO6G.js → chunk-4IJ53MI3.js} +208 -208
- package/dist/chunk-4IJ53MI3.js.map +1 -0
- package/dist/index.cjs +229 -222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/{menu-bar-67LDC7IR.js → menu-bar-SGKLM6IK.js} +2 -2
- package/dist/ueditor.cjs +223 -218
- package/dist/ueditor.cjs.map +1 -1
- package/dist/ueditor.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-7YU3O5JK.js.map +0 -1
- package/dist/chunk-TVCZXO6G.js.map +0 -1
- /package/dist/{menu-bar-67LDC7IR.js.map → menu-bar-SGKLM6IK.js.map} +0 -0
|
@@ -749,6 +749,203 @@ function deleteResponsiveColumnLayout(widthBp, ratios, deleteIndex) {
|
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
751
|
|
|
752
|
+
// src/components/UEditor/table-dom-utils.ts
|
|
753
|
+
var DEFAULT_TABLE_ROW_HEIGHT = 25;
|
|
754
|
+
var MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
755
|
+
var COLUMN_RESIZE_LINE_THICKNESS = 2;
|
|
756
|
+
var ROW_RESIZE_LINE_THICKNESS = 2;
|
|
757
|
+
var UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
|
|
758
|
+
var isRowResizingGlobal = { active: false };
|
|
759
|
+
function isCrossRealmNode(value) {
|
|
760
|
+
return Boolean(value && typeof value === "object" && value.nodeType != null);
|
|
761
|
+
}
|
|
762
|
+
function isCrossRealmElement(value) {
|
|
763
|
+
return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
|
|
764
|
+
}
|
|
765
|
+
function isCrossRealmHTMLElement(value) {
|
|
766
|
+
return isCrossRealmElement(value) && typeof value.style === "object";
|
|
767
|
+
}
|
|
768
|
+
function isCrossRealmTable(value) {
|
|
769
|
+
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
|
|
770
|
+
}
|
|
771
|
+
function isCrossRealmTableRow(value) {
|
|
772
|
+
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
|
|
773
|
+
}
|
|
774
|
+
function isCrossRealmTableCell(value) {
|
|
775
|
+
return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
|
|
776
|
+
}
|
|
777
|
+
function isValidProseMirrorPosition(doc, pos) {
|
|
778
|
+
return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
|
|
779
|
+
}
|
|
780
|
+
var TABLE_RESIZE_HIT_ZONE = 5;
|
|
781
|
+
function findTableRowNodeInfo(view, rowElement) {
|
|
782
|
+
if (!view.dom.contains(rowElement)) return null;
|
|
783
|
+
const firstCell = rowElement.querySelector("th,td");
|
|
784
|
+
if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
|
|
785
|
+
const cellPos = view.posAtDOM(firstCell, 0);
|
|
786
|
+
if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
|
|
787
|
+
const $pos = view.state.doc.resolve(cellPos);
|
|
788
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
789
|
+
const node = $pos.node(depth);
|
|
790
|
+
if (node.type.name === "tableRow") {
|
|
791
|
+
return {
|
|
792
|
+
pos: $pos.before(depth),
|
|
793
|
+
node
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
function resolveEventElement(target) {
|
|
800
|
+
if (isCrossRealmElement(target)) return target;
|
|
801
|
+
if (isCrossRealmNode(target)) return target.parentElement;
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
function isPointOverRenderedText(root, clientX, clientY) {
|
|
805
|
+
const view = root.ownerDocument.defaultView;
|
|
806
|
+
if (!view) return false;
|
|
807
|
+
const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
|
|
808
|
+
let textNode = walker.nextNode();
|
|
809
|
+
while (textNode) {
|
|
810
|
+
if (textNode.textContent?.length) {
|
|
811
|
+
const range = root.ownerDocument.createRange();
|
|
812
|
+
range.selectNodeContents(textNode);
|
|
813
|
+
const textRects = Array.from(range.getClientRects());
|
|
814
|
+
range.detach?.();
|
|
815
|
+
if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
|
|
816
|
+
return true;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
textNode = walker.nextNode();
|
|
820
|
+
}
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
function getSelectionTableCell(view) {
|
|
824
|
+
const realm = view.dom.ownerDocument.defaultView;
|
|
825
|
+
const browserSelection = realm?.getSelection();
|
|
826
|
+
const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
|
|
827
|
+
const anchorCell = anchorElement?.closest?.("th,td");
|
|
828
|
+
if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
|
|
829
|
+
return anchorCell;
|
|
830
|
+
}
|
|
831
|
+
const { from } = view.state.selection;
|
|
832
|
+
const domAtPos = view.domAtPos(from);
|
|
833
|
+
const element = resolveEventElement(domAtPos.node);
|
|
834
|
+
const cell = element?.closest?.("th,td");
|
|
835
|
+
return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
|
|
836
|
+
}
|
|
837
|
+
function resolveRowResizeTarget(cell, clientX, clientY) {
|
|
838
|
+
const rect = cell.getBoundingClientRect();
|
|
839
|
+
const row = cell.closest("tr");
|
|
840
|
+
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
844
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
845
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
846
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
847
|
+
if (distToRight <= 3 || distToLeft <= 3) {
|
|
848
|
+
return null;
|
|
849
|
+
}
|
|
850
|
+
if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
|
|
851
|
+
return { row, cell };
|
|
852
|
+
}
|
|
853
|
+
if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
|
|
854
|
+
const prevRow = row.previousElementSibling;
|
|
855
|
+
if (isCrossRealmTableRow(prevRow)) {
|
|
856
|
+
const cellIndex = cell.cellIndex;
|
|
857
|
+
const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
|
|
858
|
+
if (isCrossRealmTableCell(prevCell)) {
|
|
859
|
+
return { row: prevRow, cell: prevCell };
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
function resolveColumnResizeTarget(cell, clientX, clientY) {
|
|
866
|
+
const rect = cell.getBoundingClientRect();
|
|
867
|
+
const row = cell.closest("tr");
|
|
868
|
+
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
872
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
873
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
874
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
875
|
+
if (distToBottom <= 3 || distToTop <= 3) {
|
|
876
|
+
return null;
|
|
877
|
+
}
|
|
878
|
+
if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
|
|
879
|
+
return { row, cell };
|
|
880
|
+
}
|
|
881
|
+
if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
|
|
882
|
+
const prevCell = cell.previousElementSibling;
|
|
883
|
+
if (isCrossRealmTableCell(prevCell)) {
|
|
884
|
+
return { row, cell: prevCell };
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
function isRowResizeHotspot(cell, clientX, clientY) {
|
|
890
|
+
return resolveRowResizeTarget(cell, clientX, clientY) !== null;
|
|
891
|
+
}
|
|
892
|
+
function getRelativeBoundaryMetrics(surface, table, row, cell) {
|
|
893
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
894
|
+
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
895
|
+
const originTop = surfaceRect.top + surface.clientTop;
|
|
896
|
+
const tableRect = table.getBoundingClientRect();
|
|
897
|
+
const rowRect = row.getBoundingClientRect();
|
|
898
|
+
const cellRect = cell.getBoundingClientRect();
|
|
899
|
+
return {
|
|
900
|
+
left: tableRect.left - originLeft + surface.scrollLeft,
|
|
901
|
+
top: tableRect.top - originTop + surface.scrollTop,
|
|
902
|
+
width: tableRect.width,
|
|
903
|
+
height: tableRect.height,
|
|
904
|
+
rowBottom: rowRect.bottom - originTop + surface.scrollTop,
|
|
905
|
+
columnRight: cellRect.right - originLeft + surface.scrollLeft
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
function getRelativeCellMetrics(surface, cell) {
|
|
909
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
910
|
+
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
911
|
+
const originTop = surfaceRect.top + surface.clientTop;
|
|
912
|
+
const cellRect = cell.getBoundingClientRect();
|
|
913
|
+
return {
|
|
914
|
+
left: cellRect.left - originLeft + surface.scrollLeft,
|
|
915
|
+
top: cellRect.top - originTop + surface.scrollTop,
|
|
916
|
+
width: cellRect.width,
|
|
917
|
+
height: cellRect.height
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
function getRelativeSelectedCellsMetrics(surface) {
|
|
921
|
+
const selectedCells = Array.from(
|
|
922
|
+
surface.querySelectorAll("td.selectedCell, th.selectedCell")
|
|
923
|
+
);
|
|
924
|
+
if (selectedCells.length === 0) {
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
928
|
+
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
929
|
+
const originTop = surfaceRect.top + surface.clientTop;
|
|
930
|
+
let left = Number.POSITIVE_INFINITY;
|
|
931
|
+
let top = Number.POSITIVE_INFINITY;
|
|
932
|
+
let right = Number.NEGATIVE_INFINITY;
|
|
933
|
+
let bottom = Number.NEGATIVE_INFINITY;
|
|
934
|
+
selectedCells.forEach((cell) => {
|
|
935
|
+
const rect = cell.getBoundingClientRect();
|
|
936
|
+
left = Math.min(left, rect.left);
|
|
937
|
+
top = Math.min(top, rect.top);
|
|
938
|
+
right = Math.max(right, rect.right);
|
|
939
|
+
bottom = Math.max(bottom, rect.bottom);
|
|
940
|
+
});
|
|
941
|
+
return {
|
|
942
|
+
left: left - originLeft + surface.scrollLeft,
|
|
943
|
+
top: top - originTop + surface.scrollTop,
|
|
944
|
+
width: right - left,
|
|
945
|
+
height: bottom - top
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
|
|
752
949
|
// src/components/UEditor/clipboard-tables.ts
|
|
753
950
|
var DEFAULT_HTML_TABLE_CELL_BACKGROUND_COLOR = "#ffffff";
|
|
754
951
|
var DEFAULT_HTML_TABLE_TEXT_COLOR = "#000000";
|
|
@@ -1195,7 +1392,7 @@ function getClipboardCellText(node) {
|
|
|
1195
1392
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
1196
1393
|
return node.textContent ?? "";
|
|
1197
1394
|
}
|
|
1198
|
-
if (!(node
|
|
1395
|
+
if (!isCrossRealmHTMLElement(node)) {
|
|
1199
1396
|
return "";
|
|
1200
1397
|
}
|
|
1201
1398
|
if (node.tagName === "BR") {
|
|
@@ -1212,7 +1409,7 @@ function getClipboardCellSegments(node, styleMap, inheritedMarks) {
|
|
|
1212
1409
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
1213
1410
|
return [{ text: node.textContent ?? "", marks: inheritedMarks }];
|
|
1214
1411
|
}
|
|
1215
|
-
if (!(node
|
|
1412
|
+
if (!isCrossRealmHTMLElement(node)) {
|
|
1216
1413
|
return [];
|
|
1217
1414
|
}
|
|
1218
1415
|
if (node.tagName === "BR") {
|
|
@@ -1244,7 +1441,7 @@ function getHtmlTableRows(table, styleMap) {
|
|
|
1244
1441
|
const rows = Array.from(table.querySelectorAll("tr")).map(
|
|
1245
1442
|
(row) => ({
|
|
1246
1443
|
attrs: getTableRowAttrs(row, getElementStyleDeclarations(row, styleMap)),
|
|
1247
|
-
cells: Array.from(row.children).filter((cell) => cell
|
|
1444
|
+
cells: Array.from(row.children).filter((cell) => isCrossRealmTableCell(cell)).map((cell) => {
|
|
1248
1445
|
const styles = getElementStyleDeclarations(cell, styleMap);
|
|
1249
1446
|
const textColor = normalizeTextColorValue(styles.get("color")) ?? DEFAULT_HTML_TABLE_TEXT_COLOR;
|
|
1250
1447
|
const inheritedMarks = [{ type: "textStyle", attrs: { color: textColor } }];
|
|
@@ -1427,7 +1624,7 @@ function getClipboardTableContent(dataTransfer) {
|
|
|
1427
1624
|
const tables = sourceBody.querySelectorAll("table");
|
|
1428
1625
|
if (tables.length !== 1 || hasMeaningfulContentOutsideTable(sourceBody)) return null;
|
|
1429
1626
|
const table = tables[0];
|
|
1430
|
-
if (!(table
|
|
1627
|
+
if (!isCrossRealmTable(table)) return null;
|
|
1431
1628
|
const storedWidthValue = table.getAttribute("data-table-width-bp");
|
|
1432
1629
|
const storedOffsetValue = table.getAttribute("data-table-offset-bp");
|
|
1433
1630
|
const storedWidthBp = Number(storedWidthValue);
|
|
@@ -1610,203 +1807,6 @@ var ClipboardImages = Extension.create({
|
|
|
1610
1807
|
import { TextSelection as TextSelection2 } from "@tiptap/pm/state";
|
|
1611
1808
|
import { selectedRect as selectedRect2, TableMap as TableMap3 } from "@tiptap/pm/tables";
|
|
1612
1809
|
|
|
1613
|
-
// src/components/UEditor/table-dom-utils.ts
|
|
1614
|
-
var DEFAULT_TABLE_ROW_HEIGHT = 25;
|
|
1615
|
-
var MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
1616
|
-
var COLUMN_RESIZE_LINE_THICKNESS = 2;
|
|
1617
|
-
var ROW_RESIZE_LINE_THICKNESS = 2;
|
|
1618
|
-
var UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
|
|
1619
|
-
var isRowResizingGlobal = { active: false };
|
|
1620
|
-
function isCrossRealmNode(value) {
|
|
1621
|
-
return Boolean(value && typeof value === "object" && value.nodeType != null);
|
|
1622
|
-
}
|
|
1623
|
-
function isCrossRealmElement(value) {
|
|
1624
|
-
return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
|
|
1625
|
-
}
|
|
1626
|
-
function isCrossRealmHTMLElement(value) {
|
|
1627
|
-
return isCrossRealmElement(value) && typeof value.style === "object";
|
|
1628
|
-
}
|
|
1629
|
-
function isCrossRealmTable(value) {
|
|
1630
|
-
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
|
|
1631
|
-
}
|
|
1632
|
-
function isCrossRealmTableRow(value) {
|
|
1633
|
-
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
|
|
1634
|
-
}
|
|
1635
|
-
function isCrossRealmTableCell(value) {
|
|
1636
|
-
return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
|
|
1637
|
-
}
|
|
1638
|
-
function isValidProseMirrorPosition(doc, pos) {
|
|
1639
|
-
return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
|
|
1640
|
-
}
|
|
1641
|
-
var TABLE_RESIZE_HIT_ZONE = 5;
|
|
1642
|
-
function findTableRowNodeInfo(view, rowElement) {
|
|
1643
|
-
if (!view.dom.contains(rowElement)) return null;
|
|
1644
|
-
const firstCell = rowElement.querySelector("th,td");
|
|
1645
|
-
if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
|
|
1646
|
-
const cellPos = view.posAtDOM(firstCell, 0);
|
|
1647
|
-
if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
|
|
1648
|
-
const $pos = view.state.doc.resolve(cellPos);
|
|
1649
|
-
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
1650
|
-
const node = $pos.node(depth);
|
|
1651
|
-
if (node.type.name === "tableRow") {
|
|
1652
|
-
return {
|
|
1653
|
-
pos: $pos.before(depth),
|
|
1654
|
-
node
|
|
1655
|
-
};
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
return null;
|
|
1659
|
-
}
|
|
1660
|
-
function resolveEventElement(target) {
|
|
1661
|
-
if (isCrossRealmElement(target)) return target;
|
|
1662
|
-
if (isCrossRealmNode(target)) return target.parentElement;
|
|
1663
|
-
return null;
|
|
1664
|
-
}
|
|
1665
|
-
function isPointOverRenderedText(root, clientX, clientY) {
|
|
1666
|
-
const view = root.ownerDocument.defaultView;
|
|
1667
|
-
if (!view) return false;
|
|
1668
|
-
const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
|
|
1669
|
-
let textNode = walker.nextNode();
|
|
1670
|
-
while (textNode) {
|
|
1671
|
-
if (textNode.textContent?.length) {
|
|
1672
|
-
const range = root.ownerDocument.createRange();
|
|
1673
|
-
range.selectNodeContents(textNode);
|
|
1674
|
-
const textRects = Array.from(range.getClientRects());
|
|
1675
|
-
range.detach?.();
|
|
1676
|
-
if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
|
|
1677
|
-
return true;
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
textNode = walker.nextNode();
|
|
1681
|
-
}
|
|
1682
|
-
return false;
|
|
1683
|
-
}
|
|
1684
|
-
function getSelectionTableCell(view) {
|
|
1685
|
-
const realm = view.dom.ownerDocument.defaultView;
|
|
1686
|
-
const browserSelection = realm?.getSelection();
|
|
1687
|
-
const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
|
|
1688
|
-
const anchorCell = anchorElement?.closest?.("th,td");
|
|
1689
|
-
if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
|
|
1690
|
-
return anchorCell;
|
|
1691
|
-
}
|
|
1692
|
-
const { from } = view.state.selection;
|
|
1693
|
-
const domAtPos = view.domAtPos(from);
|
|
1694
|
-
const element = resolveEventElement(domAtPos.node);
|
|
1695
|
-
const cell = element?.closest?.("th,td");
|
|
1696
|
-
return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
|
|
1697
|
-
}
|
|
1698
|
-
function resolveRowResizeTarget(cell, clientX, clientY) {
|
|
1699
|
-
const rect = cell.getBoundingClientRect();
|
|
1700
|
-
const row = cell.closest("tr");
|
|
1701
|
-
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
1702
|
-
return null;
|
|
1703
|
-
}
|
|
1704
|
-
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
1705
|
-
const distToTop = Math.abs(clientY - rect.top);
|
|
1706
|
-
const distToRight = Math.abs(clientX - rect.right);
|
|
1707
|
-
const distToLeft = Math.abs(clientX - rect.left);
|
|
1708
|
-
if (distToRight <= 3 || distToLeft <= 3) {
|
|
1709
|
-
return null;
|
|
1710
|
-
}
|
|
1711
|
-
if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
|
|
1712
|
-
return { row, cell };
|
|
1713
|
-
}
|
|
1714
|
-
if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
|
|
1715
|
-
const prevRow = row.previousElementSibling;
|
|
1716
|
-
if (isCrossRealmTableRow(prevRow)) {
|
|
1717
|
-
const cellIndex = cell.cellIndex;
|
|
1718
|
-
const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
|
|
1719
|
-
if (isCrossRealmTableCell(prevCell)) {
|
|
1720
|
-
return { row: prevRow, cell: prevCell };
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
return null;
|
|
1725
|
-
}
|
|
1726
|
-
function resolveColumnResizeTarget(cell, clientX, clientY) {
|
|
1727
|
-
const rect = cell.getBoundingClientRect();
|
|
1728
|
-
const row = cell.closest("tr");
|
|
1729
|
-
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
1730
|
-
return null;
|
|
1731
|
-
}
|
|
1732
|
-
const distToRight = Math.abs(clientX - rect.right);
|
|
1733
|
-
const distToLeft = Math.abs(clientX - rect.left);
|
|
1734
|
-
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
1735
|
-
const distToTop = Math.abs(clientY - rect.top);
|
|
1736
|
-
if (distToBottom <= 3 || distToTop <= 3) {
|
|
1737
|
-
return null;
|
|
1738
|
-
}
|
|
1739
|
-
if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
|
|
1740
|
-
return { row, cell };
|
|
1741
|
-
}
|
|
1742
|
-
if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
|
|
1743
|
-
const prevCell = cell.previousElementSibling;
|
|
1744
|
-
if (isCrossRealmTableCell(prevCell)) {
|
|
1745
|
-
return { row, cell: prevCell };
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
return null;
|
|
1749
|
-
}
|
|
1750
|
-
function isRowResizeHotspot(cell, clientX, clientY) {
|
|
1751
|
-
return resolveRowResizeTarget(cell, clientX, clientY) !== null;
|
|
1752
|
-
}
|
|
1753
|
-
function getRelativeBoundaryMetrics(surface, table, row, cell) {
|
|
1754
|
-
const surfaceRect = surface.getBoundingClientRect();
|
|
1755
|
-
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
1756
|
-
const originTop = surfaceRect.top + surface.clientTop;
|
|
1757
|
-
const tableRect = table.getBoundingClientRect();
|
|
1758
|
-
const rowRect = row.getBoundingClientRect();
|
|
1759
|
-
const cellRect = cell.getBoundingClientRect();
|
|
1760
|
-
return {
|
|
1761
|
-
left: tableRect.left - originLeft + surface.scrollLeft,
|
|
1762
|
-
top: tableRect.top - originTop + surface.scrollTop,
|
|
1763
|
-
width: tableRect.width,
|
|
1764
|
-
height: tableRect.height,
|
|
1765
|
-
rowBottom: rowRect.bottom - originTop + surface.scrollTop,
|
|
1766
|
-
columnRight: cellRect.right - originLeft + surface.scrollLeft
|
|
1767
|
-
};
|
|
1768
|
-
}
|
|
1769
|
-
function getRelativeCellMetrics(surface, cell) {
|
|
1770
|
-
const surfaceRect = surface.getBoundingClientRect();
|
|
1771
|
-
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
1772
|
-
const originTop = surfaceRect.top + surface.clientTop;
|
|
1773
|
-
const cellRect = cell.getBoundingClientRect();
|
|
1774
|
-
return {
|
|
1775
|
-
left: cellRect.left - originLeft + surface.scrollLeft,
|
|
1776
|
-
top: cellRect.top - originTop + surface.scrollTop,
|
|
1777
|
-
width: cellRect.width,
|
|
1778
|
-
height: cellRect.height
|
|
1779
|
-
};
|
|
1780
|
-
}
|
|
1781
|
-
function getRelativeSelectedCellsMetrics(surface) {
|
|
1782
|
-
const selectedCells = Array.from(
|
|
1783
|
-
surface.querySelectorAll("td.selectedCell, th.selectedCell")
|
|
1784
|
-
);
|
|
1785
|
-
if (selectedCells.length === 0) {
|
|
1786
|
-
return null;
|
|
1787
|
-
}
|
|
1788
|
-
const surfaceRect = surface.getBoundingClientRect();
|
|
1789
|
-
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
1790
|
-
const originTop = surfaceRect.top + surface.clientTop;
|
|
1791
|
-
let left = Number.POSITIVE_INFINITY;
|
|
1792
|
-
let top = Number.POSITIVE_INFINITY;
|
|
1793
|
-
let right = Number.NEGATIVE_INFINITY;
|
|
1794
|
-
let bottom = Number.NEGATIVE_INFINITY;
|
|
1795
|
-
selectedCells.forEach((cell) => {
|
|
1796
|
-
const rect = cell.getBoundingClientRect();
|
|
1797
|
-
left = Math.min(left, rect.left);
|
|
1798
|
-
top = Math.min(top, rect.top);
|
|
1799
|
-
right = Math.max(right, rect.right);
|
|
1800
|
-
bottom = Math.max(bottom, rect.bottom);
|
|
1801
|
-
});
|
|
1802
|
-
return {
|
|
1803
|
-
left: left - originLeft + surface.scrollLeft,
|
|
1804
|
-
top: top - originTop + surface.scrollTop,
|
|
1805
|
-
width: right - left,
|
|
1806
|
-
height: bottom - top
|
|
1807
|
-
};
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
1810
|
// src/components/UEditor/table-column-resize.ts
|
|
1811
1811
|
import { Plugin as Plugin2 } from "@tiptap/pm/state";
|
|
1812
1812
|
import {
|
|
@@ -7767,7 +7767,7 @@ function parsePixelWidth(value) {
|
|
|
7767
7767
|
}
|
|
7768
7768
|
function getDomColumnWidths(editor, rect) {
|
|
7769
7769
|
const tableDom = editor.view.nodeDOM(rect.tableStart - 1);
|
|
7770
|
-
if (!(tableDom
|
|
7770
|
+
if (!isCrossRealmTable(tableDom)) return null;
|
|
7771
7771
|
const cols = Array.from(tableDom.querySelectorAll("colgroup > col"));
|
|
7772
7772
|
if (cols.length === 0) return null;
|
|
7773
7773
|
const widths = [];
|
|
@@ -10569,11 +10569,6 @@ export {
|
|
|
10569
10569
|
moveResponsiveColumnRatio,
|
|
10570
10570
|
insertResponsiveColumnLayout,
|
|
10571
10571
|
deleteResponsiveColumnLayout,
|
|
10572
|
-
trackEditorInsertionPosition,
|
|
10573
|
-
resolveUEditorImageFiles,
|
|
10574
|
-
DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE,
|
|
10575
|
-
DEFAULT_UEDITOR_IMAGE_MIME_TYPES,
|
|
10576
|
-
ClipboardImages,
|
|
10577
10572
|
DEFAULT_TABLE_ROW_HEIGHT,
|
|
10578
10573
|
MIN_TABLE_ROW_HEIGHT,
|
|
10579
10574
|
COLUMN_RESIZE_LINE_THICKNESS,
|
|
@@ -10596,6 +10591,11 @@ export {
|
|
|
10596
10591
|
getRelativeBoundaryMetrics,
|
|
10597
10592
|
getRelativeCellMetrics,
|
|
10598
10593
|
getRelativeSelectedCellsMetrics,
|
|
10594
|
+
trackEditorInsertionPosition,
|
|
10595
|
+
resolveUEditorImageFiles,
|
|
10596
|
+
DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE,
|
|
10597
|
+
DEFAULT_UEDITOR_IMAGE_MIME_TYPES,
|
|
10598
|
+
ClipboardImages,
|
|
10599
10599
|
DEFAULT_TABLE_COLUMN_WIDTH,
|
|
10600
10600
|
MIN_RESIZED_TABLE_COLUMN_WIDTH,
|
|
10601
10601
|
dynamicColumnResizing,
|
|
@@ -10664,4 +10664,4 @@ export {
|
|
|
10664
10664
|
EditorToolbar,
|
|
10665
10665
|
UEDITOR_PROSEMIRROR_CLASS_NAME
|
|
10666
10666
|
};
|
|
10667
|
-
//# sourceMappingURL=chunk-
|
|
10667
|
+
//# sourceMappingURL=chunk-4IJ53MI3.js.map
|