@underverse-ui/underverse 2.0.42 → 2.0.43
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 +223 -218
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- 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
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
extractImageSrcsFromHtml,
|
|
5
5
|
normalizeImageUrl,
|
|
6
6
|
prepareUEditorContentForSave
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-2ELWYT7Y.js";
|
|
8
8
|
import {
|
|
9
9
|
EmojiPicker_default
|
|
10
10
|
} from "./chunk-VYTIGF3V.js";
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
DropdownMenuSeparator,
|
|
29
29
|
DropdownMenu_default,
|
|
30
30
|
SelectDropdown
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-4IJ53MI3.js";
|
|
32
32
|
import {
|
|
33
33
|
Tooltip,
|
|
34
34
|
useHydrated
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
trackEditorInsertionPosition,
|
|
33
33
|
useDropdownMenuClose,
|
|
34
34
|
useSharedEditorUiRenderState
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-4IJ53MI3.js";
|
|
36
36
|
import "./chunk-IW6FSDIT.js";
|
|
37
37
|
import "./chunk-PNUDVGMI.js";
|
|
38
38
|
import {
|
|
@@ -1147,4 +1147,4 @@ var MenuBar = ({
|
|
|
1147
1147
|
export {
|
|
1148
1148
|
MenuBar
|
|
1149
1149
|
};
|
|
1150
|
-
//# sourceMappingURL=menu-bar-
|
|
1150
|
+
//# sourceMappingURL=menu-bar-SGKLM6IK.js.map
|
package/dist/ueditor.cjs
CHANGED
|
@@ -6171,6 +6171,209 @@ var init_table_width_model = __esm({
|
|
|
6171
6171
|
}
|
|
6172
6172
|
});
|
|
6173
6173
|
|
|
6174
|
+
// src/components/UEditor/table-dom-utils.ts
|
|
6175
|
+
function isCrossRealmNode(value) {
|
|
6176
|
+
return Boolean(value && typeof value === "object" && value.nodeType != null);
|
|
6177
|
+
}
|
|
6178
|
+
function isCrossRealmElement(value) {
|
|
6179
|
+
return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
|
|
6180
|
+
}
|
|
6181
|
+
function isCrossRealmHTMLElement(value) {
|
|
6182
|
+
return isCrossRealmElement(value) && typeof value.style === "object";
|
|
6183
|
+
}
|
|
6184
|
+
function isCrossRealmTable(value) {
|
|
6185
|
+
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
|
|
6186
|
+
}
|
|
6187
|
+
function isCrossRealmTableRow(value) {
|
|
6188
|
+
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
|
|
6189
|
+
}
|
|
6190
|
+
function isCrossRealmTableCell(value) {
|
|
6191
|
+
return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
|
|
6192
|
+
}
|
|
6193
|
+
function isValidProseMirrorPosition(doc, pos) {
|
|
6194
|
+
return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
|
|
6195
|
+
}
|
|
6196
|
+
function findTableRowNodeInfo(view, rowElement) {
|
|
6197
|
+
if (!view.dom.contains(rowElement)) return null;
|
|
6198
|
+
const firstCell = rowElement.querySelector("th,td");
|
|
6199
|
+
if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
|
|
6200
|
+
const cellPos = view.posAtDOM(firstCell, 0);
|
|
6201
|
+
if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
|
|
6202
|
+
const $pos = view.state.doc.resolve(cellPos);
|
|
6203
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
6204
|
+
const node = $pos.node(depth);
|
|
6205
|
+
if (node.type.name === "tableRow") {
|
|
6206
|
+
return {
|
|
6207
|
+
pos: $pos.before(depth),
|
|
6208
|
+
node
|
|
6209
|
+
};
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
return null;
|
|
6213
|
+
}
|
|
6214
|
+
function resolveEventElement(target) {
|
|
6215
|
+
if (isCrossRealmElement(target)) return target;
|
|
6216
|
+
if (isCrossRealmNode(target)) return target.parentElement;
|
|
6217
|
+
return null;
|
|
6218
|
+
}
|
|
6219
|
+
function isPointOverRenderedText(root, clientX, clientY) {
|
|
6220
|
+
const view = root.ownerDocument.defaultView;
|
|
6221
|
+
if (!view) return false;
|
|
6222
|
+
const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
|
|
6223
|
+
let textNode = walker.nextNode();
|
|
6224
|
+
while (textNode) {
|
|
6225
|
+
if (textNode.textContent?.length) {
|
|
6226
|
+
const range = root.ownerDocument.createRange();
|
|
6227
|
+
range.selectNodeContents(textNode);
|
|
6228
|
+
const textRects = Array.from(range.getClientRects());
|
|
6229
|
+
range.detach?.();
|
|
6230
|
+
if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
|
|
6231
|
+
return true;
|
|
6232
|
+
}
|
|
6233
|
+
}
|
|
6234
|
+
textNode = walker.nextNode();
|
|
6235
|
+
}
|
|
6236
|
+
return false;
|
|
6237
|
+
}
|
|
6238
|
+
function getSelectionTableCell(view) {
|
|
6239
|
+
const realm = view.dom.ownerDocument.defaultView;
|
|
6240
|
+
const browserSelection = realm?.getSelection();
|
|
6241
|
+
const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
|
|
6242
|
+
const anchorCell = anchorElement?.closest?.("th,td");
|
|
6243
|
+
if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
|
|
6244
|
+
return anchorCell;
|
|
6245
|
+
}
|
|
6246
|
+
const { from } = view.state.selection;
|
|
6247
|
+
const domAtPos = view.domAtPos(from);
|
|
6248
|
+
const element = resolveEventElement(domAtPos.node);
|
|
6249
|
+
const cell = element?.closest?.("th,td");
|
|
6250
|
+
return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
|
|
6251
|
+
}
|
|
6252
|
+
function resolveRowResizeTarget(cell, clientX, clientY) {
|
|
6253
|
+
const rect = cell.getBoundingClientRect();
|
|
6254
|
+
const row = cell.closest("tr");
|
|
6255
|
+
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
6256
|
+
return null;
|
|
6257
|
+
}
|
|
6258
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
6259
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
6260
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
6261
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
6262
|
+
if (distToRight <= 3 || distToLeft <= 3) {
|
|
6263
|
+
return null;
|
|
6264
|
+
}
|
|
6265
|
+
if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
|
|
6266
|
+
return { row, cell };
|
|
6267
|
+
}
|
|
6268
|
+
if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
|
|
6269
|
+
const prevRow = row.previousElementSibling;
|
|
6270
|
+
if (isCrossRealmTableRow(prevRow)) {
|
|
6271
|
+
const cellIndex = cell.cellIndex;
|
|
6272
|
+
const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
|
|
6273
|
+
if (isCrossRealmTableCell(prevCell)) {
|
|
6274
|
+
return { row: prevRow, cell: prevCell };
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
}
|
|
6278
|
+
return null;
|
|
6279
|
+
}
|
|
6280
|
+
function resolveColumnResizeTarget(cell, clientX, clientY) {
|
|
6281
|
+
const rect = cell.getBoundingClientRect();
|
|
6282
|
+
const row = cell.closest("tr");
|
|
6283
|
+
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
6284
|
+
return null;
|
|
6285
|
+
}
|
|
6286
|
+
const distToRight = Math.abs(clientX - rect.right);
|
|
6287
|
+
const distToLeft = Math.abs(clientX - rect.left);
|
|
6288
|
+
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
6289
|
+
const distToTop = Math.abs(clientY - rect.top);
|
|
6290
|
+
if (distToBottom <= 3 || distToTop <= 3) {
|
|
6291
|
+
return null;
|
|
6292
|
+
}
|
|
6293
|
+
if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
|
|
6294
|
+
return { row, cell };
|
|
6295
|
+
}
|
|
6296
|
+
if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
|
|
6297
|
+
const prevCell = cell.previousElementSibling;
|
|
6298
|
+
if (isCrossRealmTableCell(prevCell)) {
|
|
6299
|
+
return { row, cell: prevCell };
|
|
6300
|
+
}
|
|
6301
|
+
}
|
|
6302
|
+
return null;
|
|
6303
|
+
}
|
|
6304
|
+
function isRowResizeHotspot(cell, clientX, clientY) {
|
|
6305
|
+
return resolveRowResizeTarget(cell, clientX, clientY) !== null;
|
|
6306
|
+
}
|
|
6307
|
+
function getRelativeBoundaryMetrics(surface, table, row, cell) {
|
|
6308
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
6309
|
+
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
6310
|
+
const originTop = surfaceRect.top + surface.clientTop;
|
|
6311
|
+
const tableRect = table.getBoundingClientRect();
|
|
6312
|
+
const rowRect = row.getBoundingClientRect();
|
|
6313
|
+
const cellRect = cell.getBoundingClientRect();
|
|
6314
|
+
return {
|
|
6315
|
+
left: tableRect.left - originLeft + surface.scrollLeft,
|
|
6316
|
+
top: tableRect.top - originTop + surface.scrollTop,
|
|
6317
|
+
width: tableRect.width,
|
|
6318
|
+
height: tableRect.height,
|
|
6319
|
+
rowBottom: rowRect.bottom - originTop + surface.scrollTop,
|
|
6320
|
+
columnRight: cellRect.right - originLeft + surface.scrollLeft
|
|
6321
|
+
};
|
|
6322
|
+
}
|
|
6323
|
+
function getRelativeCellMetrics(surface, cell) {
|
|
6324
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
6325
|
+
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
6326
|
+
const originTop = surfaceRect.top + surface.clientTop;
|
|
6327
|
+
const cellRect = cell.getBoundingClientRect();
|
|
6328
|
+
return {
|
|
6329
|
+
left: cellRect.left - originLeft + surface.scrollLeft,
|
|
6330
|
+
top: cellRect.top - originTop + surface.scrollTop,
|
|
6331
|
+
width: cellRect.width,
|
|
6332
|
+
height: cellRect.height
|
|
6333
|
+
};
|
|
6334
|
+
}
|
|
6335
|
+
function getRelativeSelectedCellsMetrics(surface) {
|
|
6336
|
+
const selectedCells = Array.from(
|
|
6337
|
+
surface.querySelectorAll("td.selectedCell, th.selectedCell")
|
|
6338
|
+
);
|
|
6339
|
+
if (selectedCells.length === 0) {
|
|
6340
|
+
return null;
|
|
6341
|
+
}
|
|
6342
|
+
const surfaceRect = surface.getBoundingClientRect();
|
|
6343
|
+
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
6344
|
+
const originTop = surfaceRect.top + surface.clientTop;
|
|
6345
|
+
let left = Number.POSITIVE_INFINITY;
|
|
6346
|
+
let top = Number.POSITIVE_INFINITY;
|
|
6347
|
+
let right = Number.NEGATIVE_INFINITY;
|
|
6348
|
+
let bottom = Number.NEGATIVE_INFINITY;
|
|
6349
|
+
selectedCells.forEach((cell) => {
|
|
6350
|
+
const rect = cell.getBoundingClientRect();
|
|
6351
|
+
left = Math.min(left, rect.left);
|
|
6352
|
+
top = Math.min(top, rect.top);
|
|
6353
|
+
right = Math.max(right, rect.right);
|
|
6354
|
+
bottom = Math.max(bottom, rect.bottom);
|
|
6355
|
+
});
|
|
6356
|
+
return {
|
|
6357
|
+
left: left - originLeft + surface.scrollLeft,
|
|
6358
|
+
top: top - originTop + surface.scrollTop,
|
|
6359
|
+
width: right - left,
|
|
6360
|
+
height: bottom - top
|
|
6361
|
+
};
|
|
6362
|
+
}
|
|
6363
|
+
var DEFAULT_TABLE_ROW_HEIGHT, MIN_TABLE_ROW_HEIGHT, COLUMN_RESIZE_LINE_THICKNESS, ROW_RESIZE_LINE_THICKNESS, UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, isRowResizingGlobal, TABLE_RESIZE_HIT_ZONE;
|
|
6364
|
+
var init_table_dom_utils = __esm({
|
|
6365
|
+
"src/components/UEditor/table-dom-utils.ts"() {
|
|
6366
|
+
"use strict";
|
|
6367
|
+
DEFAULT_TABLE_ROW_HEIGHT = 25;
|
|
6368
|
+
MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
6369
|
+
COLUMN_RESIZE_LINE_THICKNESS = 2;
|
|
6370
|
+
ROW_RESIZE_LINE_THICKNESS = 2;
|
|
6371
|
+
UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
|
|
6372
|
+
isRowResizingGlobal = { active: false };
|
|
6373
|
+
TABLE_RESIZE_HIT_ZONE = 5;
|
|
6374
|
+
}
|
|
6375
|
+
});
|
|
6376
|
+
|
|
6174
6377
|
// src/components/UEditor/clipboard-tables.ts
|
|
6175
6378
|
function getClipboardData(dataTransfer, type) {
|
|
6176
6379
|
try {
|
|
@@ -6602,7 +6805,7 @@ function getClipboardCellText(node) {
|
|
|
6602
6805
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
6603
6806
|
return node.textContent ?? "";
|
|
6604
6807
|
}
|
|
6605
|
-
if (!(node
|
|
6808
|
+
if (!isCrossRealmHTMLElement(node)) {
|
|
6606
6809
|
return "";
|
|
6607
6810
|
}
|
|
6608
6811
|
if (node.tagName === "BR") {
|
|
@@ -6619,7 +6822,7 @@ function getClipboardCellSegments(node, styleMap, inheritedMarks) {
|
|
|
6619
6822
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
6620
6823
|
return [{ text: node.textContent ?? "", marks: inheritedMarks }];
|
|
6621
6824
|
}
|
|
6622
|
-
if (!(node
|
|
6825
|
+
if (!isCrossRealmHTMLElement(node)) {
|
|
6623
6826
|
return [];
|
|
6624
6827
|
}
|
|
6625
6828
|
if (node.tagName === "BR") {
|
|
@@ -6651,7 +6854,7 @@ function getHtmlTableRows(table, styleMap) {
|
|
|
6651
6854
|
const rows = Array.from(table.querySelectorAll("tr")).map(
|
|
6652
6855
|
(row) => ({
|
|
6653
6856
|
attrs: getTableRowAttrs(row, getElementStyleDeclarations(row, styleMap)),
|
|
6654
|
-
cells: Array.from(row.children).filter((cell) => cell
|
|
6857
|
+
cells: Array.from(row.children).filter((cell) => isCrossRealmTableCell(cell)).map((cell) => {
|
|
6655
6858
|
const styles = getElementStyleDeclarations(cell, styleMap);
|
|
6656
6859
|
const textColor = normalizeTextColorValue(styles.get("color")) ?? DEFAULT_HTML_TABLE_TEXT_COLOR;
|
|
6657
6860
|
const inheritedMarks = [{ type: "textStyle", attrs: { color: textColor } }];
|
|
@@ -6834,7 +7037,7 @@ function getClipboardTableContent(dataTransfer) {
|
|
|
6834
7037
|
const tables = sourceBody.querySelectorAll("table");
|
|
6835
7038
|
if (tables.length !== 1 || hasMeaningfulContentOutsideTable(sourceBody)) return null;
|
|
6836
7039
|
const table = tables[0];
|
|
6837
|
-
if (!(table
|
|
7040
|
+
if (!isCrossRealmTable(table)) return null;
|
|
6838
7041
|
const storedWidthValue = table.getAttribute("data-table-width-bp");
|
|
6839
7042
|
const storedOffsetValue = table.getAttribute("data-table-offset-bp");
|
|
6840
7043
|
const storedWidthBp = Number(storedWidthValue);
|
|
@@ -6918,6 +7121,7 @@ var init_clipboard_tables = __esm({
|
|
|
6918
7121
|
"src/components/UEditor/clipboard-tables.ts"() {
|
|
6919
7122
|
"use strict";
|
|
6920
7123
|
init_table_width_model();
|
|
7124
|
+
init_table_dom_utils();
|
|
6921
7125
|
DEFAULT_HTML_TABLE_CELL_BACKGROUND_COLOR = "#ffffff";
|
|
6922
7126
|
DEFAULT_HTML_TABLE_TEXT_COLOR = "#000000";
|
|
6923
7127
|
BORDER_STYLES = /* @__PURE__ */ new Set([
|
|
@@ -7138,209 +7342,6 @@ var init_clipboard_images = __esm({
|
|
|
7138
7342
|
}
|
|
7139
7343
|
});
|
|
7140
7344
|
|
|
7141
|
-
// src/components/UEditor/table-dom-utils.ts
|
|
7142
|
-
function isCrossRealmNode(value) {
|
|
7143
|
-
return Boolean(value && typeof value === "object" && value.nodeType != null);
|
|
7144
|
-
}
|
|
7145
|
-
function isCrossRealmElement(value) {
|
|
7146
|
-
return isCrossRealmNode(value) && value.nodeType === 1 && typeof value.closest === "function";
|
|
7147
|
-
}
|
|
7148
|
-
function isCrossRealmHTMLElement(value) {
|
|
7149
|
-
return isCrossRealmElement(value) && typeof value.style === "object";
|
|
7150
|
-
}
|
|
7151
|
-
function isCrossRealmTable(value) {
|
|
7152
|
-
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TABLE" && "rows" in value;
|
|
7153
|
-
}
|
|
7154
|
-
function isCrossRealmTableRow(value) {
|
|
7155
|
-
return isCrossRealmElement(value) && String(value.tagName).toUpperCase() === "TR" && "cells" in value;
|
|
7156
|
-
}
|
|
7157
|
-
function isCrossRealmTableCell(value) {
|
|
7158
|
-
return isCrossRealmElement(value) && ["TD", "TH"].includes(String(value.tagName).toUpperCase()) && "cellIndex" in value;
|
|
7159
|
-
}
|
|
7160
|
-
function isValidProseMirrorPosition(doc, pos) {
|
|
7161
|
-
return Number.isInteger(pos) && pos >= 0 && pos <= doc.content.size;
|
|
7162
|
-
}
|
|
7163
|
-
function findTableRowNodeInfo(view, rowElement) {
|
|
7164
|
-
if (!view.dom.contains(rowElement)) return null;
|
|
7165
|
-
const firstCell = rowElement.querySelector("th,td");
|
|
7166
|
-
if (!isCrossRealmTableCell(firstCell) || !view.dom.contains(firstCell)) return null;
|
|
7167
|
-
const cellPos = view.posAtDOM(firstCell, 0);
|
|
7168
|
-
if (!isValidProseMirrorPosition(view.state.doc, cellPos)) return null;
|
|
7169
|
-
const $pos = view.state.doc.resolve(cellPos);
|
|
7170
|
-
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
7171
|
-
const node = $pos.node(depth);
|
|
7172
|
-
if (node.type.name === "tableRow") {
|
|
7173
|
-
return {
|
|
7174
|
-
pos: $pos.before(depth),
|
|
7175
|
-
node
|
|
7176
|
-
};
|
|
7177
|
-
}
|
|
7178
|
-
}
|
|
7179
|
-
return null;
|
|
7180
|
-
}
|
|
7181
|
-
function resolveEventElement(target) {
|
|
7182
|
-
if (isCrossRealmElement(target)) return target;
|
|
7183
|
-
if (isCrossRealmNode(target)) return target.parentElement;
|
|
7184
|
-
return null;
|
|
7185
|
-
}
|
|
7186
|
-
function isPointOverRenderedText(root, clientX, clientY) {
|
|
7187
|
-
const view = root.ownerDocument.defaultView;
|
|
7188
|
-
if (!view) return false;
|
|
7189
|
-
const walker = root.ownerDocument.createTreeWalker(root, view.NodeFilter.SHOW_TEXT);
|
|
7190
|
-
let textNode = walker.nextNode();
|
|
7191
|
-
while (textNode) {
|
|
7192
|
-
if (textNode.textContent?.length) {
|
|
7193
|
-
const range = root.ownerDocument.createRange();
|
|
7194
|
-
range.selectNodeContents(textNode);
|
|
7195
|
-
const textRects = Array.from(range.getClientRects());
|
|
7196
|
-
range.detach?.();
|
|
7197
|
-
if (textRects.some((rect) => clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom)) {
|
|
7198
|
-
return true;
|
|
7199
|
-
}
|
|
7200
|
-
}
|
|
7201
|
-
textNode = walker.nextNode();
|
|
7202
|
-
}
|
|
7203
|
-
return false;
|
|
7204
|
-
}
|
|
7205
|
-
function getSelectionTableCell(view) {
|
|
7206
|
-
const realm = view.dom.ownerDocument.defaultView;
|
|
7207
|
-
const browserSelection = realm?.getSelection();
|
|
7208
|
-
const anchorElement = resolveEventElement(browserSelection?.anchorNode ?? null);
|
|
7209
|
-
const anchorCell = anchorElement?.closest?.("th,td");
|
|
7210
|
-
if (isCrossRealmTableCell(anchorCell) && view.dom.contains(anchorCell)) {
|
|
7211
|
-
return anchorCell;
|
|
7212
|
-
}
|
|
7213
|
-
const { from } = view.state.selection;
|
|
7214
|
-
const domAtPos = view.domAtPos(from);
|
|
7215
|
-
const element = resolveEventElement(domAtPos.node);
|
|
7216
|
-
const cell = element?.closest?.("th,td");
|
|
7217
|
-
return isCrossRealmTableCell(cell) && view.dom.contains(cell) ? cell : null;
|
|
7218
|
-
}
|
|
7219
|
-
function resolveRowResizeTarget(cell, clientX, clientY) {
|
|
7220
|
-
const rect = cell.getBoundingClientRect();
|
|
7221
|
-
const row = cell.closest("tr");
|
|
7222
|
-
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
7223
|
-
return null;
|
|
7224
|
-
}
|
|
7225
|
-
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
7226
|
-
const distToTop = Math.abs(clientY - rect.top);
|
|
7227
|
-
const distToRight = Math.abs(clientX - rect.right);
|
|
7228
|
-
const distToLeft = Math.abs(clientX - rect.left);
|
|
7229
|
-
if (distToRight <= 3 || distToLeft <= 3) {
|
|
7230
|
-
return null;
|
|
7231
|
-
}
|
|
7232
|
-
if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
|
|
7233
|
-
return { row, cell };
|
|
7234
|
-
}
|
|
7235
|
-
if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
|
|
7236
|
-
const prevRow = row.previousElementSibling;
|
|
7237
|
-
if (isCrossRealmTableRow(prevRow)) {
|
|
7238
|
-
const cellIndex = cell.cellIndex;
|
|
7239
|
-
const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
|
|
7240
|
-
if (isCrossRealmTableCell(prevCell)) {
|
|
7241
|
-
return { row: prevRow, cell: prevCell };
|
|
7242
|
-
}
|
|
7243
|
-
}
|
|
7244
|
-
}
|
|
7245
|
-
return null;
|
|
7246
|
-
}
|
|
7247
|
-
function resolveColumnResizeTarget(cell, clientX, clientY) {
|
|
7248
|
-
const rect = cell.getBoundingClientRect();
|
|
7249
|
-
const row = cell.closest("tr");
|
|
7250
|
-
if (!isCrossRealmTableRow(row) || !isCrossRealmTableCell(cell)) {
|
|
7251
|
-
return null;
|
|
7252
|
-
}
|
|
7253
|
-
const distToRight = Math.abs(clientX - rect.right);
|
|
7254
|
-
const distToLeft = Math.abs(clientX - rect.left);
|
|
7255
|
-
const distToBottom = Math.abs(clientY - rect.bottom);
|
|
7256
|
-
const distToTop = Math.abs(clientY - rect.top);
|
|
7257
|
-
if (distToBottom <= 3 || distToTop <= 3) {
|
|
7258
|
-
return null;
|
|
7259
|
-
}
|
|
7260
|
-
if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
|
|
7261
|
-
return { row, cell };
|
|
7262
|
-
}
|
|
7263
|
-
if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
|
|
7264
|
-
const prevCell = cell.previousElementSibling;
|
|
7265
|
-
if (isCrossRealmTableCell(prevCell)) {
|
|
7266
|
-
return { row, cell: prevCell };
|
|
7267
|
-
}
|
|
7268
|
-
}
|
|
7269
|
-
return null;
|
|
7270
|
-
}
|
|
7271
|
-
function isRowResizeHotspot(cell, clientX, clientY) {
|
|
7272
|
-
return resolveRowResizeTarget(cell, clientX, clientY) !== null;
|
|
7273
|
-
}
|
|
7274
|
-
function getRelativeBoundaryMetrics(surface, table, row, cell) {
|
|
7275
|
-
const surfaceRect = surface.getBoundingClientRect();
|
|
7276
|
-
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
7277
|
-
const originTop = surfaceRect.top + surface.clientTop;
|
|
7278
|
-
const tableRect = table.getBoundingClientRect();
|
|
7279
|
-
const rowRect = row.getBoundingClientRect();
|
|
7280
|
-
const cellRect = cell.getBoundingClientRect();
|
|
7281
|
-
return {
|
|
7282
|
-
left: tableRect.left - originLeft + surface.scrollLeft,
|
|
7283
|
-
top: tableRect.top - originTop + surface.scrollTop,
|
|
7284
|
-
width: tableRect.width,
|
|
7285
|
-
height: tableRect.height,
|
|
7286
|
-
rowBottom: rowRect.bottom - originTop + surface.scrollTop,
|
|
7287
|
-
columnRight: cellRect.right - originLeft + surface.scrollLeft
|
|
7288
|
-
};
|
|
7289
|
-
}
|
|
7290
|
-
function getRelativeCellMetrics(surface, cell) {
|
|
7291
|
-
const surfaceRect = surface.getBoundingClientRect();
|
|
7292
|
-
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
7293
|
-
const originTop = surfaceRect.top + surface.clientTop;
|
|
7294
|
-
const cellRect = cell.getBoundingClientRect();
|
|
7295
|
-
return {
|
|
7296
|
-
left: cellRect.left - originLeft + surface.scrollLeft,
|
|
7297
|
-
top: cellRect.top - originTop + surface.scrollTop,
|
|
7298
|
-
width: cellRect.width,
|
|
7299
|
-
height: cellRect.height
|
|
7300
|
-
};
|
|
7301
|
-
}
|
|
7302
|
-
function getRelativeSelectedCellsMetrics(surface) {
|
|
7303
|
-
const selectedCells = Array.from(
|
|
7304
|
-
surface.querySelectorAll("td.selectedCell, th.selectedCell")
|
|
7305
|
-
);
|
|
7306
|
-
if (selectedCells.length === 0) {
|
|
7307
|
-
return null;
|
|
7308
|
-
}
|
|
7309
|
-
const surfaceRect = surface.getBoundingClientRect();
|
|
7310
|
-
const originLeft = surfaceRect.left + surface.clientLeft;
|
|
7311
|
-
const originTop = surfaceRect.top + surface.clientTop;
|
|
7312
|
-
let left = Number.POSITIVE_INFINITY;
|
|
7313
|
-
let top = Number.POSITIVE_INFINITY;
|
|
7314
|
-
let right = Number.NEGATIVE_INFINITY;
|
|
7315
|
-
let bottom = Number.NEGATIVE_INFINITY;
|
|
7316
|
-
selectedCells.forEach((cell) => {
|
|
7317
|
-
const rect = cell.getBoundingClientRect();
|
|
7318
|
-
left = Math.min(left, rect.left);
|
|
7319
|
-
top = Math.min(top, rect.top);
|
|
7320
|
-
right = Math.max(right, rect.right);
|
|
7321
|
-
bottom = Math.max(bottom, rect.bottom);
|
|
7322
|
-
});
|
|
7323
|
-
return {
|
|
7324
|
-
left: left - originLeft + surface.scrollLeft,
|
|
7325
|
-
top: top - originTop + surface.scrollTop,
|
|
7326
|
-
width: right - left,
|
|
7327
|
-
height: bottom - top
|
|
7328
|
-
};
|
|
7329
|
-
}
|
|
7330
|
-
var DEFAULT_TABLE_ROW_HEIGHT, MIN_TABLE_ROW_HEIGHT, COLUMN_RESIZE_LINE_THICKNESS, ROW_RESIZE_LINE_THICKNESS, UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, isRowResizingGlobal, TABLE_RESIZE_HIT_ZONE;
|
|
7331
|
-
var init_table_dom_utils = __esm({
|
|
7332
|
-
"src/components/UEditor/table-dom-utils.ts"() {
|
|
7333
|
-
"use strict";
|
|
7334
|
-
DEFAULT_TABLE_ROW_HEIGHT = 25;
|
|
7335
|
-
MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
7336
|
-
COLUMN_RESIZE_LINE_THICKNESS = 2;
|
|
7337
|
-
ROW_RESIZE_LINE_THICKNESS = 2;
|
|
7338
|
-
UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
|
|
7339
|
-
isRowResizingGlobal = { active: false };
|
|
7340
|
-
TABLE_RESIZE_HIT_ZONE = 5;
|
|
7341
|
-
}
|
|
7342
|
-
});
|
|
7343
|
-
|
|
7344
7345
|
// src/components/UEditor/table-column-resize.ts
|
|
7345
7346
|
function getColumnResizeMinWidth(configuredMinWidth) {
|
|
7346
7347
|
const normalizedMinWidth = Number.isFinite(configuredMinWidth) && configuredMinWidth > 0 ? Math.round(configuredMinWidth) : MIN_RESIZED_TABLE_COLUMN_WIDTH;
|
|
@@ -13436,7 +13437,7 @@ function parsePixelWidth(value) {
|
|
|
13436
13437
|
}
|
|
13437
13438
|
function getDomColumnWidths(editor, rect) {
|
|
13438
13439
|
const tableDom = editor.view.nodeDOM(rect.tableStart - 1);
|
|
13439
|
-
if (!(tableDom
|
|
13440
|
+
if (!isCrossRealmTable(tableDom)) return null;
|
|
13440
13441
|
const cols = Array.from(tableDom.querySelectorAll("colgroup > col"));
|
|
13441
13442
|
if (cols.length === 0) return null;
|
|
13442
13443
|
const widths = [];
|
|
@@ -20615,7 +20616,7 @@ var UEditorTableRow = import_extension_table_row.TableRow.extend({
|
|
|
20615
20616
|
rowHeight: {
|
|
20616
20617
|
default: DEFAULT_TABLE_ROW_HEIGHT,
|
|
20617
20618
|
parseHTML: (element) => {
|
|
20618
|
-
if (!(element
|
|
20619
|
+
if (!isCrossRealmHTMLElement(element)) return null;
|
|
20619
20620
|
return parseRowHeight(element.getAttribute("data-row-height")) ?? parseRowHeight(element.style.height);
|
|
20620
20621
|
},
|
|
20621
20622
|
renderHTML: (attributes) => {
|
|
@@ -21148,7 +21149,7 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
21148
21149
|
textAlign: {
|
|
21149
21150
|
default: null,
|
|
21150
21151
|
parseHTML: (element) => {
|
|
21151
|
-
if (!(element
|
|
21152
|
+
if (!isCrossRealmHTMLElement(element)) return null;
|
|
21152
21153
|
return parseTableAlign(element);
|
|
21153
21154
|
},
|
|
21154
21155
|
renderHTML: (attributes) => {
|
|
@@ -21162,7 +21163,7 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
21162
21163
|
widthMode: {
|
|
21163
21164
|
default: "fixed",
|
|
21164
21165
|
parseHTML: (element) => {
|
|
21165
|
-
if (!(element
|
|
21166
|
+
if (!isCrossRealmHTMLElement(element)) return "fixed";
|
|
21166
21167
|
return parseTableWidthMode(element);
|
|
21167
21168
|
},
|
|
21168
21169
|
renderHTML: (attributes) => {
|
|
@@ -21175,7 +21176,7 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
21175
21176
|
widthBp: {
|
|
21176
21177
|
default: null,
|
|
21177
21178
|
parseHTML: (element) => {
|
|
21178
|
-
if (!(element
|
|
21179
|
+
if (!isCrossRealmHTMLElement(element) || parseTableWidthMode(element) !== "responsive") return null;
|
|
21179
21180
|
const stored = Number(element.getAttribute("data-table-width-bp"));
|
|
21180
21181
|
if (Number.isFinite(stored) && stored > 0) return clampResponsiveTableWidthBp(stored);
|
|
21181
21182
|
return parsePercentageToBasisPoints(element.getAttribute("data-table-width") ?? element.style.width) ?? DEFAULT_RESPONSIVE_TABLE_WIDTH_BP;
|
|
@@ -21185,7 +21186,7 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
21185
21186
|
offsetBp: {
|
|
21186
21187
|
default: null,
|
|
21187
21188
|
parseHTML: (element) => {
|
|
21188
|
-
if (!(element
|
|
21189
|
+
if (!isCrossRealmHTMLElement(element) || parseTableWidthMode(element) !== "responsive") return null;
|
|
21189
21190
|
const storedValue = element.getAttribute("data-table-offset-bp");
|
|
21190
21191
|
const stored = Number(storedValue);
|
|
21191
21192
|
if (storedValue !== null && Number.isFinite(stored) && stored >= 0) return Math.round(stored);
|
|
@@ -21204,7 +21205,7 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
21204
21205
|
columnRatios: {
|
|
21205
21206
|
default: null,
|
|
21206
21207
|
parseHTML: (element) => {
|
|
21207
|
-
if (!(element
|
|
21208
|
+
if (!isCrossRealmHTMLElement(element)) return null;
|
|
21208
21209
|
const storedRatios = parseColumnRatios(
|
|
21209
21210
|
element.getAttribute("data-table-column-ratios") ?? element.getAttribute("data-column-ratios")
|
|
21210
21211
|
);
|
|
@@ -21400,7 +21401,7 @@ var UEditorTable = import_extension_table.Table.extend({
|
|
|
21400
21401
|
if (event.button !== 0) return false;
|
|
21401
21402
|
const target = resolveEventElement(event.target);
|
|
21402
21403
|
const cell = target?.closest("th,td");
|
|
21403
|
-
if (cell
|
|
21404
|
+
if (isCrossRealmHTMLElement(cell) && isRowResizeHotspot(cell, event.clientX, event.clientY)) {
|
|
21404
21405
|
isRowResizingGlobal.active = true;
|
|
21405
21406
|
return true;
|
|
21406
21407
|
}
|
|
@@ -22311,6 +22312,7 @@ var TableFormulaRecalculation = import_core20.Extension.create({
|
|
|
22311
22312
|
});
|
|
22312
22313
|
|
|
22313
22314
|
// src/components/UEditor/extensions.ts
|
|
22315
|
+
init_table_dom_utils();
|
|
22314
22316
|
function getFormulaStateAttributes(attributes) {
|
|
22315
22317
|
const formula = attributes["data-formula"];
|
|
22316
22318
|
if (!formula) {
|
|
@@ -22630,7 +22632,7 @@ var CustomBulletList = import_extension_bullet_list.BulletList.extend({
|
|
|
22630
22632
|
bulletStyle: {
|
|
22631
22633
|
default: "disc",
|
|
22632
22634
|
parseHTML: (element) => {
|
|
22633
|
-
if (!(element
|
|
22635
|
+
if (!isCrossRealmHTMLElement(element)) return "disc";
|
|
22634
22636
|
const dataStyle = element.getAttribute("data-bullet-style");
|
|
22635
22637
|
if (dataStyle) return parseBulletStyle(dataStyle);
|
|
22636
22638
|
const style = element.style.listStyleType;
|
|
@@ -26801,8 +26803,11 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
26801
26803
|
(0, import_react44.useEffect)(() => {
|
|
26802
26804
|
if (!editor || !editable) return void 0;
|
|
26803
26805
|
const proseMirror = editor.view.dom;
|
|
26804
|
-
const editorDocument =
|
|
26805
|
-
const editorWindow = editorDocument.defaultView;
|
|
26806
|
+
const editorDocument = editorContentRef.current?.ownerDocument ?? editor?.view.dom.ownerDocument ?? document;
|
|
26807
|
+
const editorWindow = editorDocument.defaultView ?? window;
|
|
26808
|
+
if (editor?.view && editor.view.root !== editorDocument) {
|
|
26809
|
+
editor.view.updateRoot();
|
|
26810
|
+
}
|
|
26806
26811
|
if (!editorWindow) return void 0;
|
|
26807
26812
|
const surface = editorContentRef.current;
|
|
26808
26813
|
let selectionSyncFrameId = 0;
|