@underverse-ui/underverse 1.0.159 → 1.0.161
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/index.cjs +580 -253
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +568 -233
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3433,7 +3433,7 @@ var Tooltip = React10.forwardRef(({
|
|
|
3433
3433
|
setIsOpen(true);
|
|
3434
3434
|
}, delayOpen);
|
|
3435
3435
|
};
|
|
3436
|
-
const
|
|
3436
|
+
const handleMouseLeave2 = () => {
|
|
3437
3437
|
clearTimeout(timeoutRef.current);
|
|
3438
3438
|
timeoutRef.current = setTimeout(() => {
|
|
3439
3439
|
setIsOpen(false);
|
|
@@ -3558,7 +3558,7 @@ var Tooltip = React10.forwardRef(({
|
|
|
3558
3558
|
childProps.onMouseLeave,
|
|
3559
3559
|
(e) => {
|
|
3560
3560
|
triggerRef.current = e.currentTarget;
|
|
3561
|
-
|
|
3561
|
+
handleMouseLeave2();
|
|
3562
3562
|
}
|
|
3563
3563
|
),
|
|
3564
3564
|
onPointerDown: chainEventHandlers(
|
|
@@ -7593,6 +7593,23 @@ var DropdownMenu = ({
|
|
|
7593
7593
|
const itemsRef = React25.useRef([]);
|
|
7594
7594
|
const [activeIndex, setActiveIndex] = useResettingIndex(open);
|
|
7595
7595
|
const parentMenu = React25.useContext(DropdownMenuContext);
|
|
7596
|
+
const closeMenu = React25.useCallback(() => {
|
|
7597
|
+
setOpen(false);
|
|
7598
|
+
parentMenu?.closeMenu();
|
|
7599
|
+
}, [parentMenu, setOpen]);
|
|
7600
|
+
const getEnabledMenuItems = React25.useCallback(() => {
|
|
7601
|
+
const menuEl = menuRef.current;
|
|
7602
|
+
if (!menuEl) return [];
|
|
7603
|
+
return Array.from(menuEl.querySelectorAll("[data-dropdown-menu-item]")).filter((el) => !el.disabled);
|
|
7604
|
+
}, []);
|
|
7605
|
+
const focusMenuItem = React25.useCallback((index) => {
|
|
7606
|
+
const enabled = getEnabledMenuItems();
|
|
7607
|
+
const item = enabled[index];
|
|
7608
|
+
if (!item) return;
|
|
7609
|
+
setActiveIndex(index);
|
|
7610
|
+
item.focus();
|
|
7611
|
+
item.scrollIntoView({ block: "nearest" });
|
|
7612
|
+
}, [getEnabledMenuItems, setActiveIndex]);
|
|
7596
7613
|
useShadCNAnimations();
|
|
7597
7614
|
React25.useEffect(() => {
|
|
7598
7615
|
if (!open) return;
|
|
@@ -7603,38 +7620,34 @@ var DropdownMenu = ({
|
|
|
7603
7620
|
if (!active || !triggerEl || !menuEl) return;
|
|
7604
7621
|
const isInMenu = menuEl.contains(active);
|
|
7605
7622
|
const isOnTrigger = triggerEl.contains(active);
|
|
7606
|
-
|
|
7607
|
-
const enabled = itemsRef.current.filter((el) => el && !el.disabled);
|
|
7623
|
+
const enabled = getEnabledMenuItems();
|
|
7608
7624
|
if (enabled.length === 0) return;
|
|
7625
|
+
const currentIndex = enabled.findIndex((el) => el === active);
|
|
7626
|
+
const baseIndex = currentIndex >= 0 ? currentIndex : activeIndex;
|
|
7609
7627
|
if (e.key === "ArrowDown") {
|
|
7610
7628
|
e.preventDefault();
|
|
7611
|
-
const next = (
|
|
7612
|
-
|
|
7613
|
-
enabled[next]?.focus();
|
|
7629
|
+
const next = (baseIndex + 1 + enabled.length) % enabled.length;
|
|
7630
|
+
focusMenuItem(next);
|
|
7614
7631
|
} else if (e.key === "ArrowUp") {
|
|
7615
7632
|
e.preventDefault();
|
|
7616
|
-
const prev = (
|
|
7617
|
-
|
|
7618
|
-
enabled[prev]?.focus();
|
|
7633
|
+
const prev = (baseIndex - 1 + enabled.length) % enabled.length;
|
|
7634
|
+
focusMenuItem(prev);
|
|
7619
7635
|
} else if (e.key === "Home") {
|
|
7620
7636
|
e.preventDefault();
|
|
7621
|
-
|
|
7622
|
-
enabled[0]?.focus();
|
|
7637
|
+
focusMenuItem(0);
|
|
7623
7638
|
} else if (e.key === "End") {
|
|
7624
7639
|
e.preventDefault();
|
|
7625
|
-
|
|
7626
|
-
|
|
7640
|
+
focusMenuItem(enabled.length - 1);
|
|
7641
|
+
} else if (e.key === "Escape" && (isInMenu || isOnTrigger)) {
|
|
7642
|
+
e.preventDefault();
|
|
7643
|
+
closeMenu();
|
|
7627
7644
|
}
|
|
7628
7645
|
};
|
|
7629
|
-
document.addEventListener("keydown", handleKeyNav);
|
|
7646
|
+
document.addEventListener("keydown", handleKeyNav, true);
|
|
7630
7647
|
return () => {
|
|
7631
|
-
document.removeEventListener("keydown", handleKeyNav);
|
|
7648
|
+
document.removeEventListener("keydown", handleKeyNav, true);
|
|
7632
7649
|
};
|
|
7633
|
-
}, [open, activeIndex,
|
|
7634
|
-
const closeMenu = React25.useCallback(() => {
|
|
7635
|
-
setOpen(false);
|
|
7636
|
-
parentMenu?.closeMenu();
|
|
7637
|
-
}, [parentMenu, setOpen]);
|
|
7650
|
+
}, [open, activeIndex, closeMenu, focusMenuItem, getEnabledMenuItems]);
|
|
7638
7651
|
const menuContext = React25.useMemo(
|
|
7639
7652
|
() => ({
|
|
7640
7653
|
closeMenu,
|
|
@@ -7659,6 +7672,7 @@ var DropdownMenu = ({
|
|
|
7659
7672
|
onClick: () => handleItemClick(item.onClick),
|
|
7660
7673
|
disabled: item.disabled,
|
|
7661
7674
|
role: "menuitem",
|
|
7675
|
+
"data-dropdown-menu-item": "",
|
|
7662
7676
|
tabIndex: -1,
|
|
7663
7677
|
style: {
|
|
7664
7678
|
animationDelay: open ? `${Math.min(index * 20, 200)}ms` : "0ms"
|
|
@@ -7694,13 +7708,13 @@ var DropdownMenu = ({
|
|
|
7694
7708
|
if (e.key === "ArrowDown") {
|
|
7695
7709
|
e.preventDefault();
|
|
7696
7710
|
setOpen(true);
|
|
7697
|
-
requestAnimationFrame(() =>
|
|
7711
|
+
requestAnimationFrame(() => focusMenuItem(0));
|
|
7698
7712
|
} else if (e.key === "ArrowUp") {
|
|
7699
7713
|
e.preventDefault();
|
|
7700
7714
|
setOpen(true);
|
|
7701
7715
|
requestAnimationFrame(() => {
|
|
7702
|
-
const enabled =
|
|
7703
|
-
enabled
|
|
7716
|
+
const enabled = getEnabledMenuItems();
|
|
7717
|
+
focusMenuItem(enabled.length - 1);
|
|
7704
7718
|
});
|
|
7705
7719
|
} else if (e.key === "Escape") {
|
|
7706
7720
|
e.preventDefault();
|
|
@@ -7751,6 +7765,8 @@ var DropdownMenuItem = ({
|
|
|
7751
7765
|
},
|
|
7752
7766
|
disabled,
|
|
7753
7767
|
onMouseDown: (e) => e.preventDefault(),
|
|
7768
|
+
"data-dropdown-menu-item": "",
|
|
7769
|
+
tabIndex: -1,
|
|
7754
7770
|
className: cn(
|
|
7755
7771
|
"flex w-full items-center gap-2 px-3 py-2 text-sm rounded-lg transition-colors group cursor-pointer",
|
|
7756
7772
|
"hover:bg-accent hover:text-accent-foreground",
|
|
@@ -17917,18 +17933,18 @@ function OverlayControls({
|
|
|
17917
17933
|
setControlsVisible(false);
|
|
17918
17934
|
}, autoHideDelay);
|
|
17919
17935
|
};
|
|
17920
|
-
const
|
|
17921
|
-
const
|
|
17936
|
+
const handleMouseMove2 = () => resetTimer();
|
|
17937
|
+
const handleMouseLeave2 = () => {
|
|
17922
17938
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
17923
17939
|
hideTimerRef.current = setTimeout(() => {
|
|
17924
17940
|
setControlsVisible(false);
|
|
17925
17941
|
}, autoHideDelay);
|
|
17926
17942
|
};
|
|
17927
17943
|
resetTimer();
|
|
17928
|
-
document.addEventListener("mousemove",
|
|
17944
|
+
document.addEventListener("mousemove", handleMouseMove2);
|
|
17929
17945
|
return () => {
|
|
17930
17946
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
17931
|
-
document.removeEventListener("mousemove",
|
|
17947
|
+
document.removeEventListener("mousemove", handleMouseMove2);
|
|
17932
17948
|
};
|
|
17933
17949
|
}, [autoHide, autoHideDelay, showOnHover]);
|
|
17934
17950
|
const showFeedback = React44.useCallback((type, value2) => {
|
|
@@ -27064,7 +27080,8 @@ import { mergeAttributes as mergeAttributes4 } from "@tiptap/core";
|
|
|
27064
27080
|
import { NodeViewWrapper as NodeViewWrapper4, ReactNodeViewRenderer as ReactNodeViewRenderer4 } from "@tiptap/react";
|
|
27065
27081
|
|
|
27066
27082
|
// src/components/UEditor/table-dom-utils.ts
|
|
27067
|
-
var
|
|
27083
|
+
var DEFAULT_TABLE_ROW_HEIGHT = 25;
|
|
27084
|
+
var MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
27068
27085
|
var COLUMN_RESIZE_LINE_THICKNESS = 2;
|
|
27069
27086
|
var ROW_RESIZE_LINE_THICKNESS = 2;
|
|
27070
27087
|
var UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor-table-layout-change";
|
|
@@ -27550,25 +27567,29 @@ function parseRowHeight(value) {
|
|
|
27550
27567
|
const match = String(value).match(/(\d+(?:\.\d+)?)/);
|
|
27551
27568
|
if (!match) return null;
|
|
27552
27569
|
const parsed = Number.parseFloat(match[1]);
|
|
27553
|
-
return
|
|
27570
|
+
return normalizeRowHeight(parsed);
|
|
27571
|
+
}
|
|
27572
|
+
function normalizeRowHeight(value) {
|
|
27573
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.max(MIN_TABLE_ROW_HEIGHT, Math.round(value)) : null;
|
|
27554
27574
|
}
|
|
27555
27575
|
var UEditorTableRow = TableRow2.extend({
|
|
27556
27576
|
addAttributes() {
|
|
27557
27577
|
return {
|
|
27558
27578
|
...this.parent?.(),
|
|
27559
27579
|
rowHeight: {
|
|
27560
|
-
default:
|
|
27580
|
+
default: DEFAULT_TABLE_ROW_HEIGHT,
|
|
27561
27581
|
parseHTML: (element) => {
|
|
27562
27582
|
if (!(element instanceof HTMLElement)) return null;
|
|
27563
27583
|
return parseRowHeight(element.getAttribute("data-row-height")) ?? parseRowHeight(element.style.height);
|
|
27564
27584
|
},
|
|
27565
27585
|
renderHTML: (attributes) => {
|
|
27566
|
-
|
|
27586
|
+
const rowHeight = normalizeRowHeight(attributes.rowHeight);
|
|
27587
|
+
if (!rowHeight) {
|
|
27567
27588
|
return {};
|
|
27568
27589
|
}
|
|
27569
27590
|
return {
|
|
27570
|
-
"data-row-height": String(
|
|
27571
|
-
style: `height: ${
|
|
27591
|
+
"data-row-height": String(rowHeight),
|
|
27592
|
+
style: `height: ${rowHeight}px; min-height: ${rowHeight}px;`
|
|
27572
27593
|
};
|
|
27573
27594
|
}
|
|
27574
27595
|
}
|
|
@@ -27723,7 +27744,371 @@ var letter_spacing_default = LetterSpacing;
|
|
|
27723
27744
|
|
|
27724
27745
|
// src/components/UEditor/table-align.ts
|
|
27725
27746
|
import { Table as Table3 } from "@tiptap/extension-table";
|
|
27747
|
+
import { Plugin as Plugin5 } from "@tiptap/pm/state";
|
|
27748
|
+
import { tableEditing } from "@tiptap/pm/tables";
|
|
27749
|
+
|
|
27750
|
+
// src/components/UEditor/table-column-resize.ts
|
|
27726
27751
|
import { Plugin as Plugin4 } from "@tiptap/pm/state";
|
|
27752
|
+
import {
|
|
27753
|
+
Decoration as Decoration2,
|
|
27754
|
+
DecorationSet as DecorationSet2
|
|
27755
|
+
} from "@tiptap/pm/view";
|
|
27756
|
+
import {
|
|
27757
|
+
ResizeState,
|
|
27758
|
+
TableMap,
|
|
27759
|
+
cellAround,
|
|
27760
|
+
columnResizingPluginKey,
|
|
27761
|
+
tableNodeTypes
|
|
27762
|
+
} from "@tiptap/pm/tables";
|
|
27763
|
+
var DEFAULT_TABLE_COLUMN_WIDTH = 100;
|
|
27764
|
+
var MIN_RESIZED_TABLE_COLUMN_WIDTH = 25;
|
|
27765
|
+
function getDynamicColumnMinWidth(startWidth, fallbackMinWidth) {
|
|
27766
|
+
return Math.max(fallbackMinWidth, Math.round(startWidth / 3));
|
|
27767
|
+
}
|
|
27768
|
+
function setColumnStyle(column, width) {
|
|
27769
|
+
if (width == null) {
|
|
27770
|
+
column.style.width = "";
|
|
27771
|
+
column.style.minWidth = `${DEFAULT_TABLE_COLUMN_WIDTH}px`;
|
|
27772
|
+
return;
|
|
27773
|
+
}
|
|
27774
|
+
column.style.width = `${Math.max(width, MIN_RESIZED_TABLE_COLUMN_WIDTH)}px`;
|
|
27775
|
+
column.style.minWidth = "";
|
|
27776
|
+
}
|
|
27777
|
+
function isTableColumnElement(node) {
|
|
27778
|
+
return node instanceof HTMLElement && node.tagName.toLowerCase() === "col";
|
|
27779
|
+
}
|
|
27780
|
+
function updateDynamicColumns(node, colgroup, table, overrideCol, overrideValue) {
|
|
27781
|
+
let totalWidth = 0;
|
|
27782
|
+
let fixedWidth = true;
|
|
27783
|
+
let nextDOM = colgroup.firstChild;
|
|
27784
|
+
const row = node.firstChild;
|
|
27785
|
+
if (row) {
|
|
27786
|
+
for (let rowCellIndex = 0, col = 0; rowCellIndex < row.childCount; rowCellIndex += 1) {
|
|
27787
|
+
const { colspan, colwidth } = row.child(rowCellIndex).attrs;
|
|
27788
|
+
for (let spanIndex = 0; spanIndex < colspan; spanIndex += 1, col += 1) {
|
|
27789
|
+
const rawWidth = overrideCol === col ? overrideValue : colwidth?.[spanIndex];
|
|
27790
|
+
const width = rawWidth ? Math.max(rawWidth, MIN_RESIZED_TABLE_COLUMN_WIDTH) : null;
|
|
27791
|
+
totalWidth += width ?? DEFAULT_TABLE_COLUMN_WIDTH;
|
|
27792
|
+
if (!width) {
|
|
27793
|
+
fixedWidth = false;
|
|
27794
|
+
}
|
|
27795
|
+
const colElement = isTableColumnElement(nextDOM) ? nextDOM : colgroup.appendChild(document.createElement("col"));
|
|
27796
|
+
setColumnStyle(colElement, width);
|
|
27797
|
+
nextDOM = colElement.nextSibling;
|
|
27798
|
+
}
|
|
27799
|
+
}
|
|
27800
|
+
}
|
|
27801
|
+
while (nextDOM) {
|
|
27802
|
+
const after = nextDOM.nextSibling;
|
|
27803
|
+
nextDOM.parentNode?.removeChild(nextDOM);
|
|
27804
|
+
nextDOM = after;
|
|
27805
|
+
}
|
|
27806
|
+
const hasUserWidth = typeof node.attrs.style === "string" && /\bwidth\s*:/i.test(node.attrs.style);
|
|
27807
|
+
if (fixedWidth && !hasUserWidth) {
|
|
27808
|
+
table.style.width = `${totalWidth}px`;
|
|
27809
|
+
table.style.minWidth = "";
|
|
27810
|
+
} else {
|
|
27811
|
+
table.style.width = "";
|
|
27812
|
+
table.style.minWidth = `${totalWidth}px`;
|
|
27813
|
+
}
|
|
27814
|
+
}
|
|
27815
|
+
var UEditorTableView = class {
|
|
27816
|
+
constructor(node) {
|
|
27817
|
+
this.node = node;
|
|
27818
|
+
this.dom = document.createElement("div");
|
|
27819
|
+
this.dom.className = "tableWrapper";
|
|
27820
|
+
this.table = this.dom.appendChild(document.createElement("table"));
|
|
27821
|
+
if (node.attrs.style) {
|
|
27822
|
+
this.table.style.cssText = node.attrs.style;
|
|
27823
|
+
}
|
|
27824
|
+
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
27825
|
+
updateDynamicColumns(node, this.colgroup, this.table);
|
|
27826
|
+
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
27827
|
+
}
|
|
27828
|
+
update(node) {
|
|
27829
|
+
if (node.type !== this.node.type) return false;
|
|
27830
|
+
this.node = node;
|
|
27831
|
+
updateDynamicColumns(node, this.colgroup, this.table);
|
|
27832
|
+
return true;
|
|
27833
|
+
}
|
|
27834
|
+
ignoreMutation(mutation) {
|
|
27835
|
+
const target = mutation.target;
|
|
27836
|
+
const isInsideWrapper = this.dom.contains(target);
|
|
27837
|
+
const isInsideContent = this.contentDOM.contains(target);
|
|
27838
|
+
if (isInsideWrapper && !isInsideContent) {
|
|
27839
|
+
return mutation.type === "attributes" || mutation.type === "childList" || mutation.type === "characterData";
|
|
27840
|
+
}
|
|
27841
|
+
return false;
|
|
27842
|
+
}
|
|
27843
|
+
};
|
|
27844
|
+
function getDraggedWidth(dragging, event) {
|
|
27845
|
+
const offset = event.clientX - dragging.startX;
|
|
27846
|
+
return Math.max(dragging.minWidth, Math.round(dragging.startWidth + offset));
|
|
27847
|
+
}
|
|
27848
|
+
function getCurrentColWidth(view, cellPos, { colspan, colwidth }) {
|
|
27849
|
+
const width = colwidth?.[colwidth.length - 1];
|
|
27850
|
+
if (width) return width;
|
|
27851
|
+
const dom = view.domAtPos(cellPos);
|
|
27852
|
+
const cellElement = dom.node.childNodes[dom.offset];
|
|
27853
|
+
let domWidth = cellElement instanceof HTMLElement ? cellElement.offsetWidth : 0;
|
|
27854
|
+
let parts = Math.max(1, colspan);
|
|
27855
|
+
if (colwidth) {
|
|
27856
|
+
for (let index = 0; index < colspan; index += 1) {
|
|
27857
|
+
const partWidth = colwidth[index];
|
|
27858
|
+
if (partWidth) {
|
|
27859
|
+
domWidth -= partWidth;
|
|
27860
|
+
parts -= 1;
|
|
27861
|
+
}
|
|
27862
|
+
}
|
|
27863
|
+
}
|
|
27864
|
+
return domWidth / Math.max(1, parts);
|
|
27865
|
+
}
|
|
27866
|
+
function domCellAround(target) {
|
|
27867
|
+
let node = target instanceof Node ? target : null;
|
|
27868
|
+
while (node && node.nodeName !== "TD" && node.nodeName !== "TH") {
|
|
27869
|
+
const element = node instanceof Element ? node : null;
|
|
27870
|
+
if (element?.classList.contains("ProseMirror")) return null;
|
|
27871
|
+
node = node.parentNode;
|
|
27872
|
+
}
|
|
27873
|
+
return node instanceof HTMLElement ? node : null;
|
|
27874
|
+
}
|
|
27875
|
+
function edgeCell(view, event, side, handleWidth) {
|
|
27876
|
+
const offset = side === "right" ? -handleWidth : handleWidth;
|
|
27877
|
+
const found2 = view.posAtCoords({
|
|
27878
|
+
left: event.clientX + offset,
|
|
27879
|
+
top: event.clientY
|
|
27880
|
+
});
|
|
27881
|
+
if (!found2) return -1;
|
|
27882
|
+
const $cell = cellAround(view.state.doc.resolve(found2.pos));
|
|
27883
|
+
if (!$cell) return -1;
|
|
27884
|
+
if (side === "right") return $cell.pos;
|
|
27885
|
+
const map = TableMap.get($cell.node(-1));
|
|
27886
|
+
const start = $cell.start(-1);
|
|
27887
|
+
const index = map.map.indexOf($cell.pos - start);
|
|
27888
|
+
return index % map.width === 0 ? -1 : start + map.map[index - 1];
|
|
27889
|
+
}
|
|
27890
|
+
function updateHandle(view, value) {
|
|
27891
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));
|
|
27892
|
+
}
|
|
27893
|
+
function handleMouseMove(view, event, handleWidth, lastColumnResizable) {
|
|
27894
|
+
if (!view.editable) return;
|
|
27895
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
27896
|
+
if (!pluginState || pluginState.dragging) return;
|
|
27897
|
+
const target = domCellAround(event.target);
|
|
27898
|
+
let cell = -1;
|
|
27899
|
+
if (target) {
|
|
27900
|
+
const { left, right } = target.getBoundingClientRect();
|
|
27901
|
+
if (event.clientX - left <= handleWidth) cell = edgeCell(view, event, "left", handleWidth);
|
|
27902
|
+
else if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, "right", handleWidth);
|
|
27903
|
+
}
|
|
27904
|
+
if (cell === pluginState.activeHandle) return;
|
|
27905
|
+
if (!lastColumnResizable && cell !== -1) {
|
|
27906
|
+
const $cell = view.state.doc.resolve(cell);
|
|
27907
|
+
const table = $cell.node(-1);
|
|
27908
|
+
const map = TableMap.get(table);
|
|
27909
|
+
const tableStart = $cell.start(-1);
|
|
27910
|
+
const nodeAfter = $cell.nodeAfter;
|
|
27911
|
+
if (!nodeAfter) return;
|
|
27912
|
+
if (map.colCount($cell.pos - tableStart) + nodeAfter.attrs.colspan - 1 === map.width - 1) return;
|
|
27913
|
+
}
|
|
27914
|
+
updateHandle(view, cell);
|
|
27915
|
+
}
|
|
27916
|
+
function handleMouseLeave(view) {
|
|
27917
|
+
if (!view.editable) return;
|
|
27918
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
27919
|
+
if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) {
|
|
27920
|
+
updateHandle(view, -1);
|
|
27921
|
+
}
|
|
27922
|
+
}
|
|
27923
|
+
function updateColumnWidth(view, cell, width) {
|
|
27924
|
+
const $cell = view.state.doc.resolve(cell);
|
|
27925
|
+
const table = $cell.node(-1);
|
|
27926
|
+
const map = TableMap.get(table);
|
|
27927
|
+
const start = $cell.start(-1);
|
|
27928
|
+
const nodeAfter = $cell.nodeAfter;
|
|
27929
|
+
if (!nodeAfter) return;
|
|
27930
|
+
const col = map.colCount($cell.pos - start) + nodeAfter.attrs.colspan - 1;
|
|
27931
|
+
const tr = view.state.tr;
|
|
27932
|
+
for (let row = 0; row < map.height; row += 1) {
|
|
27933
|
+
const mapIndex = row * map.width + col;
|
|
27934
|
+
if (row && map.map[mapIndex] === map.map[mapIndex - map.width]) continue;
|
|
27935
|
+
const pos = map.map[mapIndex];
|
|
27936
|
+
const cellNode = table.nodeAt(pos);
|
|
27937
|
+
if (!cellNode) continue;
|
|
27938
|
+
const attrs = cellNode.attrs;
|
|
27939
|
+
const index = attrs.colspan === 1 ? 0 : col - map.colCount(pos);
|
|
27940
|
+
if (attrs.colwidth?.[index] === width) continue;
|
|
27941
|
+
const colwidth = attrs.colwidth ? attrs.colwidth.slice() : Array.from({ length: attrs.colspan }, () => 0);
|
|
27942
|
+
colwidth[index] = width;
|
|
27943
|
+
tr.setNodeMarkup(start + pos, null, {
|
|
27944
|
+
...attrs,
|
|
27945
|
+
colwidth
|
|
27946
|
+
});
|
|
27947
|
+
}
|
|
27948
|
+
if (tr.docChanged) view.dispatch(tr);
|
|
27949
|
+
}
|
|
27950
|
+
function getActiveDragging(state) {
|
|
27951
|
+
const dragging = columnResizingPluginKey.getState(state)?.dragging;
|
|
27952
|
+
return dragging ? dragging : null;
|
|
27953
|
+
}
|
|
27954
|
+
function getColumnResizeGhost(view) {
|
|
27955
|
+
const doc = view.dom.ownerDocument;
|
|
27956
|
+
let ghost = doc.querySelector("[data-ueditor-column-resize-ghost]");
|
|
27957
|
+
if (!ghost) {
|
|
27958
|
+
ghost = doc.createElement("div");
|
|
27959
|
+
ghost.setAttribute("data-ueditor-column-resize-ghost", "");
|
|
27960
|
+
ghost.style.position = "fixed";
|
|
27961
|
+
ghost.style.zIndex = "99999";
|
|
27962
|
+
ghost.style.pointerEvents = "none";
|
|
27963
|
+
ghost.style.width = "2px";
|
|
27964
|
+
ghost.style.backgroundColor = "var(--primary, #2563eb)";
|
|
27965
|
+
ghost.style.opacity = "1";
|
|
27966
|
+
ghost.style.borderRadius = "9999px";
|
|
27967
|
+
ghost.style.boxShadow = "0 0 0 1px color-mix(in oklch, var(--background, #fff) 80%, transparent)";
|
|
27968
|
+
ghost.style.transform = "translateX(-1px)";
|
|
27969
|
+
ghost.style.willChange = "left";
|
|
27970
|
+
doc.body.appendChild(ghost);
|
|
27971
|
+
}
|
|
27972
|
+
return ghost;
|
|
27973
|
+
}
|
|
27974
|
+
function hideColumnResizeGhost(view) {
|
|
27975
|
+
view.dom.ownerDocument.querySelector("[data-ueditor-column-resize-ghost]")?.remove();
|
|
27976
|
+
}
|
|
27977
|
+
function getTableElementAtCell(view, cell) {
|
|
27978
|
+
const $cell = view.state.doc.resolve(cell);
|
|
27979
|
+
let dom = view.domAtPos($cell.start(-1)).node;
|
|
27980
|
+
while (dom && dom.nodeName !== "TABLE") dom = dom.parentNode;
|
|
27981
|
+
return dom instanceof HTMLTableElement ? dom : null;
|
|
27982
|
+
}
|
|
27983
|
+
function showColumnResizeGhost(view, cell, dragging, width) {
|
|
27984
|
+
const table = getTableElementAtCell(view, cell);
|
|
27985
|
+
if (!table) return;
|
|
27986
|
+
const rect = table.getBoundingClientRect();
|
|
27987
|
+
const left = dragging.startX + width - dragging.startWidth;
|
|
27988
|
+
const ghost = getColumnResizeGhost(view);
|
|
27989
|
+
ghost.style.left = `${left}px`;
|
|
27990
|
+
ghost.style.top = `${rect.top}px`;
|
|
27991
|
+
ghost.style.height = `${rect.height}px`;
|
|
27992
|
+
}
|
|
27993
|
+
function handleMouseDown(view, event, cellMinWidth) {
|
|
27994
|
+
if (!view.editable) return false;
|
|
27995
|
+
const win = view.dom.ownerDocument.defaultView ?? window;
|
|
27996
|
+
const pluginState = columnResizingPluginKey.getState(view.state);
|
|
27997
|
+
if (!pluginState || pluginState.activeHandle === -1 || pluginState.dragging) return false;
|
|
27998
|
+
const cell = view.state.doc.nodeAt(pluginState.activeHandle);
|
|
27999
|
+
if (!cell) return false;
|
|
28000
|
+
const attrs = cell.attrs;
|
|
28001
|
+
const width = getCurrentColWidth(view, pluginState.activeHandle, {
|
|
28002
|
+
colspan: attrs.colspan ?? 1,
|
|
28003
|
+
colwidth: attrs.colwidth
|
|
28004
|
+
});
|
|
28005
|
+
const minWidth = getDynamicColumnMinWidth(width, cellMinWidth);
|
|
28006
|
+
const dragging = {
|
|
28007
|
+
startX: event.clientX,
|
|
28008
|
+
startWidth: width,
|
|
28009
|
+
minWidth
|
|
28010
|
+
};
|
|
28011
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: dragging }));
|
|
28012
|
+
function finish(nextEvent) {
|
|
28013
|
+
win.removeEventListener("mouseup", finish);
|
|
28014
|
+
win.removeEventListener("mousemove", move);
|
|
28015
|
+
const activeDragging = getActiveDragging(view.state);
|
|
28016
|
+
const activeHandle = columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
|
|
28017
|
+
if (activeDragging && activeHandle > -1) {
|
|
28018
|
+
updateColumnWidth(view, activeHandle, getDraggedWidth(activeDragging, nextEvent));
|
|
28019
|
+
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));
|
|
28020
|
+
}
|
|
28021
|
+
hideColumnResizeGhost(view);
|
|
28022
|
+
}
|
|
28023
|
+
function move(nextEvent) {
|
|
28024
|
+
if (!nextEvent.buttons) return finish(nextEvent);
|
|
28025
|
+
const activeDragging = getActiveDragging(view.state);
|
|
28026
|
+
const activeHandle = columnResizingPluginKey.getState(view.state)?.activeHandle ?? -1;
|
|
28027
|
+
if (activeDragging && activeHandle > -1) {
|
|
28028
|
+
showColumnResizeGhost(view, activeHandle, activeDragging, getDraggedWidth(activeDragging, nextEvent));
|
|
28029
|
+
}
|
|
28030
|
+
}
|
|
28031
|
+
showColumnResizeGhost(view, pluginState.activeHandle, dragging, width);
|
|
28032
|
+
win.addEventListener("mouseup", finish);
|
|
28033
|
+
win.addEventListener("mousemove", move);
|
|
28034
|
+
event.preventDefault();
|
|
28035
|
+
return true;
|
|
28036
|
+
}
|
|
28037
|
+
function handleDecorations(state, cell) {
|
|
28038
|
+
const decorations = [];
|
|
28039
|
+
const $cell = state.doc.resolve(cell);
|
|
28040
|
+
const table = $cell.node(-1);
|
|
28041
|
+
if (!table) return DecorationSet2.empty;
|
|
28042
|
+
const map = TableMap.get(table);
|
|
28043
|
+
const start = $cell.start(-1);
|
|
28044
|
+
const nodeAfter = $cell.nodeAfter;
|
|
28045
|
+
if (!nodeAfter) return DecorationSet2.empty;
|
|
28046
|
+
const col = map.colCount($cell.pos - start) + nodeAfter.attrs.colspan - 1;
|
|
28047
|
+
for (let row = 0; row < map.height; row += 1) {
|
|
28048
|
+
const index = col + row * map.width;
|
|
28049
|
+
if ((col === map.width - 1 || map.map[index] !== map.map[index + 1]) && (row === 0 || map.map[index] !== map.map[index - map.width])) {
|
|
28050
|
+
const cellPos = map.map[index];
|
|
28051
|
+
const cellNode = table.nodeAt(cellPos);
|
|
28052
|
+
if (!cellNode) continue;
|
|
28053
|
+
const pos = start + cellPos + cellNode.nodeSize - 1;
|
|
28054
|
+
const dom = document.createElement("div");
|
|
28055
|
+
dom.className = "column-resize-handle";
|
|
28056
|
+
if (columnResizingPluginKey.getState(state)?.dragging) {
|
|
28057
|
+
decorations.push(Decoration2.node(start + cellPos, start + cellPos + cellNode.nodeSize, { class: "column-resize-dragging" }));
|
|
28058
|
+
}
|
|
28059
|
+
decorations.push(Decoration2.widget(pos, dom));
|
|
28060
|
+
}
|
|
28061
|
+
}
|
|
28062
|
+
return DecorationSet2.create(state.doc, decorations);
|
|
28063
|
+
}
|
|
28064
|
+
function dynamicColumnResizing({
|
|
28065
|
+
handleWidth = 5,
|
|
28066
|
+
cellMinWidth = MIN_RESIZED_TABLE_COLUMN_WIDTH,
|
|
28067
|
+
defaultCellMinWidth = DEFAULT_TABLE_COLUMN_WIDTH,
|
|
28068
|
+
View = UEditorTableView,
|
|
28069
|
+
lastColumnResizable = true
|
|
28070
|
+
} = {}) {
|
|
28071
|
+
const plugin = new Plugin4({
|
|
28072
|
+
key: columnResizingPluginKey,
|
|
28073
|
+
state: {
|
|
28074
|
+
init(_, state) {
|
|
28075
|
+
const nodeViews = plugin.spec.props?.nodeViews;
|
|
28076
|
+
const tableName = tableNodeTypes(state.schema).table.name;
|
|
28077
|
+
if (View && nodeViews) {
|
|
28078
|
+
nodeViews[tableName] = (node, view) => new View(node, defaultCellMinWidth, view);
|
|
28079
|
+
}
|
|
28080
|
+
return new ResizeState(-1, false);
|
|
28081
|
+
},
|
|
28082
|
+
apply(tr, prev) {
|
|
28083
|
+
return prev.apply(tr);
|
|
28084
|
+
}
|
|
28085
|
+
},
|
|
28086
|
+
props: {
|
|
28087
|
+
attributes: (state) => {
|
|
28088
|
+
const pluginState = columnResizingPluginKey.getState(state);
|
|
28089
|
+
return pluginState && pluginState.activeHandle > -1 ? { class: "resize-cursor" } : {};
|
|
28090
|
+
},
|
|
28091
|
+
handleDOMEvents: {
|
|
28092
|
+
mousemove: (view, event) => {
|
|
28093
|
+
handleMouseMove(view, event, handleWidth, lastColumnResizable);
|
|
28094
|
+
},
|
|
28095
|
+
mouseleave: (view) => {
|
|
28096
|
+
handleMouseLeave(view);
|
|
28097
|
+
},
|
|
28098
|
+
mousedown: (view, event) => handleMouseDown(view, event, cellMinWidth)
|
|
28099
|
+
},
|
|
28100
|
+
decorations: (state) => {
|
|
28101
|
+
const pluginState = columnResizingPluginKey.getState(state);
|
|
28102
|
+
if (pluginState && pluginState.activeHandle > -1) {
|
|
28103
|
+
return handleDecorations(state, pluginState.activeHandle);
|
|
28104
|
+
}
|
|
28105
|
+
return void 0;
|
|
28106
|
+
},
|
|
28107
|
+
nodeViews: {}
|
|
28108
|
+
}
|
|
28109
|
+
});
|
|
28110
|
+
return plugin;
|
|
28111
|
+
}
|
|
27727
28112
|
|
|
27728
28113
|
// src/components/UEditor/table-align-utils.ts
|
|
27729
28114
|
function findTableNodeInfoAtResolvedPos($pos) {
|
|
@@ -27860,9 +28245,20 @@ var UEditorTable = Table3.extend({
|
|
|
27860
28245
|
};
|
|
27861
28246
|
},
|
|
27862
28247
|
addProseMirrorPlugins() {
|
|
28248
|
+
const isResizable = this.options.resizable && this.editor.isEditable;
|
|
27863
28249
|
return [
|
|
27864
|
-
...
|
|
27865
|
-
|
|
28250
|
+
...isResizable ? [
|
|
28251
|
+
dynamicColumnResizing({
|
|
28252
|
+
handleWidth: this.options.handleWidth,
|
|
28253
|
+
cellMinWidth: this.options.cellMinWidth,
|
|
28254
|
+
defaultCellMinWidth: DEFAULT_TABLE_COLUMN_WIDTH,
|
|
28255
|
+
lastColumnResizable: this.options.lastColumnResizable
|
|
28256
|
+
})
|
|
28257
|
+
] : [],
|
|
28258
|
+
tableEditing({
|
|
28259
|
+
allowTableNodeSelection: this.options.allowTableNodeSelection
|
|
28260
|
+
}),
|
|
28261
|
+
new Plugin5({
|
|
27866
28262
|
appendTransaction(_transactions, _oldState, newState) {
|
|
27867
28263
|
const { doc, schema } = newState;
|
|
27868
28264
|
const paragraphType = schema.nodes.paragraph;
|
|
@@ -28347,12 +28743,12 @@ function buildUEditorExtensions({
|
|
|
28347
28743
|
table_row_default,
|
|
28348
28744
|
CustomTableCell.configure({
|
|
28349
28745
|
HTMLAttributes: {
|
|
28350
|
-
class: "border border-
|
|
28746
|
+
class: "border border-black px-2 py-0 min-w-25"
|
|
28351
28747
|
}
|
|
28352
28748
|
}),
|
|
28353
28749
|
CustomTableHeader.configure({
|
|
28354
28750
|
HTMLAttributes: {
|
|
28355
|
-
class: "border border-
|
|
28751
|
+
class: "border border-black px-2 py-0 bg-muted font-semibold min-w-25"
|
|
28356
28752
|
}
|
|
28357
28753
|
}),
|
|
28358
28754
|
CharacterCount.configure({
|
|
@@ -28402,7 +28798,6 @@ import {
|
|
|
28402
28798
|
ArrowLeft,
|
|
28403
28799
|
ArrowRight,
|
|
28404
28800
|
ArrowUp,
|
|
28405
|
-
Baseline,
|
|
28406
28801
|
Bold as BoldIcon,
|
|
28407
28802
|
ChevronDown as ChevronDown8,
|
|
28408
28803
|
ChevronsUpDown,
|
|
@@ -28908,7 +29303,7 @@ var ImageInput = ({ onSubmit, onCancel }) => {
|
|
|
28908
29303
|
|
|
28909
29304
|
// src/components/UEditor/table-cell-commands.ts
|
|
28910
29305
|
import { TextSelection as TextSelection2 } from "@tiptap/pm/state";
|
|
28911
|
-
import { selectedRect, TableMap } from "@tiptap/pm/tables";
|
|
29306
|
+
import { selectedRect, TableMap as TableMap2 } from "@tiptap/pm/tables";
|
|
28912
29307
|
function getCellSelectionPositions(selection) {
|
|
28913
29308
|
const value = selection;
|
|
28914
29309
|
const anchor = value.$anchorCell?.pos;
|
|
@@ -29000,7 +29395,7 @@ function getSelectedTableRect(editor) {
|
|
|
29000
29395
|
if (cellSelection) {
|
|
29001
29396
|
const tableInfo = findTableInfoFromCellPos(editor, cellSelection.anchor);
|
|
29002
29397
|
if (tableInfo) {
|
|
29003
|
-
const map =
|
|
29398
|
+
const map = TableMap2.get(tableInfo.table);
|
|
29004
29399
|
const rect = map.rectBetween(
|
|
29005
29400
|
cellSelection.anchor - tableInfo.tableStart,
|
|
29006
29401
|
cellSelection.head - tableInfo.tableStart
|
|
@@ -29096,7 +29491,7 @@ function runTableCommandAtCellPos(editor, cellPos, command) {
|
|
|
29096
29491
|
function getTableCornerCellPos(editor, activePos) {
|
|
29097
29492
|
const tableInfo = findTableInfoFromCellPos(editor, activePos);
|
|
29098
29493
|
if (!tableInfo) return null;
|
|
29099
|
-
const map =
|
|
29494
|
+
const map = TableMap2.get(tableInfo.table);
|
|
29100
29495
|
return tableInfo.tableStart + map.positionAt(map.height - 1, map.width - 1, tableInfo.table);
|
|
29101
29496
|
}
|
|
29102
29497
|
function replaceTableAtCellPos(editor, cellPos, updateTable) {
|
|
@@ -29120,7 +29515,7 @@ function duplicateTableRowAt(editor, rowIndex, cellPos) {
|
|
|
29120
29515
|
}
|
|
29121
29516
|
function clearTableRowAt(editor, rowIndex, cellPos) {
|
|
29122
29517
|
return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
|
|
29123
|
-
const map =
|
|
29518
|
+
const map = TableMap2.get(tableNode);
|
|
29124
29519
|
if (rowIndex < 0 || rowIndex >= map.height) return null;
|
|
29125
29520
|
const rows = getTableRows(tableNode).map((rowInfo) => {
|
|
29126
29521
|
const cells = collectChildren(rowInfo.node);
|
|
@@ -29136,7 +29531,7 @@ function clearTableRowAt(editor, rowIndex, cellPos) {
|
|
|
29136
29531
|
}
|
|
29137
29532
|
function duplicateTableColumnAt(editor, columnIndex, cellPos) {
|
|
29138
29533
|
return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
|
|
29139
|
-
const map =
|
|
29534
|
+
const map = TableMap2.get(tableNode);
|
|
29140
29535
|
if (columnIndex < 0 || columnIndex >= map.width) return null;
|
|
29141
29536
|
const rows = getTableRows(tableNode).map((rowInfo, rowIndex) => {
|
|
29142
29537
|
const cells = collectChildren(rowInfo.node);
|
|
@@ -29158,7 +29553,7 @@ function duplicateTableColumnAt(editor, columnIndex, cellPos) {
|
|
|
29158
29553
|
}
|
|
29159
29554
|
function clearTableColumnAt(editor, columnIndex, cellPos) {
|
|
29160
29555
|
return replaceTableAtCellPos(editor, cellPos, (tableNode) => {
|
|
29161
|
-
const map =
|
|
29556
|
+
const map = TableMap2.get(tableNode);
|
|
29162
29557
|
if (columnIndex < 0 || columnIndex >= map.width) return null;
|
|
29163
29558
|
const rows = getTableRows(tableNode).map((rowInfo) => {
|
|
29164
29559
|
const cells = collectChildren(rowInfo.node);
|
|
@@ -29197,6 +29592,16 @@ function normalizeStyleValue(value) {
|
|
|
29197
29592
|
}
|
|
29198
29593
|
function getDefaultFontFamilies(t) {
|
|
29199
29594
|
return [
|
|
29595
|
+
{ label: "\uAD74\uB9BC", value: '"Gulim", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
|
|
29596
|
+
{ label: "\uAD74\uB9BC\uCCB4", value: '"GulimChe", "Gulim", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
|
|
29597
|
+
{ label: "\uAD81\uC11C", value: '"Gungsuh", "Nanum Myeongjo", serif' },
|
|
29598
|
+
{ label: "\uAD81\uC11C\uCCB4", value: '"GungsuhChe", "Gungsuh", "Nanum Myeongjo", serif' },
|
|
29599
|
+
{ label: "\uB3CB\uC6C0", value: '"Dotum", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
|
|
29600
|
+
{ label: "\uB3CB\uC6C0\uCCB4", value: '"DotumChe", "Dotum", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
|
|
29601
|
+
{ label: "\uBC14\uD0D5", value: '"Batang", "Nanum Myeongjo", serif' },
|
|
29602
|
+
{ label: "\uBC14\uD0D5\uCCB4", value: '"BatangChe", "Batang", "Nanum Myeongjo", serif' },
|
|
29603
|
+
{ label: "\uB9D1\uC740\uACE0\uB515", value: '"Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif' },
|
|
29604
|
+
{ label: "\uB098\uB214\uBA85\uC870", value: '"Nanum Myeongjo", "Batang", serif' },
|
|
29200
29605
|
{ label: "Inter", value: '"Inter", "Noto Sans", "Noto Sans CJK KR", "Noto Sans CJK JP", "Segoe UI", sans-serif' },
|
|
29201
29606
|
{ label: "System UI", value: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' },
|
|
29202
29607
|
{ label: "Roboto", value: '"Roboto", "Noto Sans", "Apple SD Gothic Neo", "Hiragino Kaku Gothic ProN", sans-serif' },
|
|
@@ -29218,13 +29623,21 @@ function getDefaultFontSizes() {
|
|
|
29218
29623
|
{ label: "10", value: "10px" },
|
|
29219
29624
|
{ label: "11", value: "11px" },
|
|
29220
29625
|
{ label: "12", value: "12px" },
|
|
29626
|
+
{ label: "13", value: "13px" },
|
|
29221
29627
|
{ label: "14", value: "14px" },
|
|
29628
|
+
{ label: "15", value: "15px" },
|
|
29222
29629
|
{ label: "16", value: "16px" },
|
|
29630
|
+
{ label: "17", value: "17px" },
|
|
29223
29631
|
{ label: "18", value: "18px" },
|
|
29632
|
+
{ label: "19", value: "19px" },
|
|
29224
29633
|
{ label: "20", value: "20px" },
|
|
29634
|
+
{ label: "21", value: "21px" },
|
|
29225
29635
|
{ label: "22", value: "22px" },
|
|
29636
|
+
{ label: "23", value: "23px" },
|
|
29226
29637
|
{ label: "24", value: "24px" },
|
|
29638
|
+
{ label: "25", value: "25px" },
|
|
29227
29639
|
{ label: "26", value: "26px" },
|
|
29640
|
+
{ label: "27", value: "27px" },
|
|
29228
29641
|
{ label: "28", value: "28px" },
|
|
29229
29642
|
{ label: "36", value: "36px" },
|
|
29230
29643
|
{ label: "48", value: "48px" },
|
|
@@ -29400,10 +29813,15 @@ var EditorToolbar = ({
|
|
|
29400
29813
|
const availableLetterSpacings = React77.useMemo(() => letterSpacings ?? getDefaultLetterSpacings(), [letterSpacings]);
|
|
29401
29814
|
const currentFontFamilyDisplayValue = currentFontFamily.split(",")[0]?.trim() ?? currentFontFamily;
|
|
29402
29815
|
const currentFontFamilyLabel = availableFontFamilies.find((option) => normalizeStyleValue(option.value) === currentFontFamily)?.label ?? (currentFontFamilyDisplayValue || t("toolbar.fontDefault"));
|
|
29403
|
-
const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ??
|
|
29816
|
+
const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? "13";
|
|
29404
29817
|
const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
|
|
29405
29818
|
const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
|
|
29406
|
-
const
|
|
29819
|
+
const defaultFontFamily = availableFontFamilies[0];
|
|
29820
|
+
const defaultFontFamilyValue = defaultFontFamily?.value ?? "";
|
|
29821
|
+
const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : defaultFontFamily?.label ?? t("toolbar.fontDefault");
|
|
29822
|
+
const displayedFontFamilyValue = currentFontFamily || defaultFontFamilyValue;
|
|
29823
|
+
const displayedFontSizeLabel = currentFontSize ? currentFontSizeLabel : "13";
|
|
29824
|
+
const activeFontSize = currentFontSize || "13px";
|
|
29407
29825
|
const tableCommandAnchorPos = tableCommandAnchorPosRef.current ?? tableAnchorPos ?? void 0;
|
|
29408
29826
|
const insertImageFiles = async (files) => {
|
|
29409
29827
|
if (files.length === 0) return;
|
|
@@ -29441,70 +29859,48 @@ var EditorToolbar = ({
|
|
|
29441
29859
|
] });
|
|
29442
29860
|
}
|
|
29443
29861
|
return /* @__PURE__ */ jsxs72("div", { className: "flex flex-wrap items-center gap-0.5 border-b border-border/35 bg-linear-to-r from-muted/25 to-transparent p-1.5", children: [
|
|
29444
|
-
/* @__PURE__ */
|
|
29862
|
+
/* @__PURE__ */ jsx86(
|
|
29445
29863
|
DropdownMenu,
|
|
29446
29864
|
{
|
|
29447
29865
|
trigger: /* @__PURE__ */ jsxs72(ToolbarButton, { onClick: () => {
|
|
29448
|
-
}, title: t("toolbar.fontFamily"), className: "px-1.5 w-auto gap-
|
|
29449
|
-
/* @__PURE__ */ jsx86(
|
|
29866
|
+
}, title: t("toolbar.fontFamily"), className: "min-w-0 max-w-40 px-1.5 w-auto gap-1", children: [
|
|
29867
|
+
/* @__PURE__ */ jsx86("span", { className: "max-w-28 truncate text-xs font-medium", style: { fontFamily: displayedFontFamilyValue || void 0 }, children: displayedFontFamilyLabel }),
|
|
29450
29868
|
/* @__PURE__ */ jsx86(ChevronDown8, { className: "h-3 w-3 text-muted-foreground" })
|
|
29451
29869
|
] }),
|
|
29452
29870
|
contentClassName: "max-h-80 overflow-y-auto min-w-56 p-2",
|
|
29453
|
-
children:
|
|
29454
|
-
|
|
29455
|
-
|
|
29456
|
-
|
|
29457
|
-
|
|
29458
|
-
|
|
29459
|
-
|
|
29460
|
-
|
|
29461
|
-
|
|
29462
|
-
|
|
29463
|
-
availableFontFamilies.map((option) => /* @__PURE__ */ jsx86(
|
|
29464
|
-
DropdownMenuItem,
|
|
29465
|
-
{
|
|
29466
|
-
label: option.label,
|
|
29467
|
-
onClick: () => editor.chain().focus().setFontFamily(option.value).run(),
|
|
29468
|
-
active: normalizeStyleValue(option.value) === currentFontFamily,
|
|
29469
|
-
className: "font-medium"
|
|
29470
|
-
},
|
|
29471
|
-
option.value
|
|
29472
|
-
))
|
|
29473
|
-
]
|
|
29871
|
+
children: availableFontFamilies.map((option) => /* @__PURE__ */ jsx86(
|
|
29872
|
+
DropdownMenuItem,
|
|
29873
|
+
{
|
|
29874
|
+
label: option.label,
|
|
29875
|
+
onClick: () => editor.chain().focus().setFontFamily(option.value).run(),
|
|
29876
|
+
active: normalizeStyleValue(option.value) === (currentFontFamily || normalizeStyleValue(defaultFontFamilyValue)),
|
|
29877
|
+
className: "font-medium"
|
|
29878
|
+
},
|
|
29879
|
+
option.value
|
|
29880
|
+
))
|
|
29474
29881
|
}
|
|
29475
29882
|
),
|
|
29476
|
-
/* @__PURE__ */
|
|
29883
|
+
/* @__PURE__ */ jsx86(
|
|
29477
29884
|
DropdownMenu,
|
|
29478
29885
|
{
|
|
29479
29886
|
trigger: /* @__PURE__ */ jsxs72(ToolbarButton, { onClick: () => {
|
|
29480
|
-
}, title: t("toolbar.fontSize"), className: "px-1.5 w-auto gap-
|
|
29887
|
+
}, title: t("toolbar.fontSize"), className: "px-1.5 w-auto gap-1", children: [
|
|
29481
29888
|
/* @__PURE__ */ jsxs72("div", { className: "flex items-center gap-0.5", children: [
|
|
29482
29889
|
/* @__PURE__ */ jsx86(ChevronsUpDown, { className: "h-3 w-3 text-muted-foreground", strokeWidth: 2.5 }),
|
|
29483
|
-
/* @__PURE__ */ jsx86("span", { className: "text-xs font-
|
|
29890
|
+
/* @__PURE__ */ jsx86("span", { className: "min-w-4 text-center text-xs font-semibold leading-none", children: displayedFontSizeLabel })
|
|
29484
29891
|
] }),
|
|
29485
29892
|
/* @__PURE__ */ jsx86(ChevronDown8, { className: "h-3 w-3 text-muted-foreground" })
|
|
29486
29893
|
] }),
|
|
29487
29894
|
contentClassName: "max-h-80 overflow-y-auto min-w-32 p-2",
|
|
29488
|
-
children:
|
|
29489
|
-
|
|
29490
|
-
|
|
29491
|
-
|
|
29492
|
-
|
|
29493
|
-
|
|
29494
|
-
|
|
29495
|
-
|
|
29496
|
-
|
|
29497
|
-
),
|
|
29498
|
-
availableFontSizes.map((option) => /* @__PURE__ */ jsx86(
|
|
29499
|
-
DropdownMenuItem,
|
|
29500
|
-
{
|
|
29501
|
-
label: option.label,
|
|
29502
|
-
onClick: () => editor.chain().focus().setFontSize(option.value).run(),
|
|
29503
|
-
active: normalizeStyleValue(option.value) === currentFontSize
|
|
29504
|
-
},
|
|
29505
|
-
option.value
|
|
29506
|
-
))
|
|
29507
|
-
]
|
|
29895
|
+
children: availableFontSizes.map((option) => /* @__PURE__ */ jsx86(
|
|
29896
|
+
DropdownMenuItem,
|
|
29897
|
+
{
|
|
29898
|
+
label: option.label,
|
|
29899
|
+
onClick: () => editor.chain().focus().setFontSize(option.value).run(),
|
|
29900
|
+
active: normalizeStyleValue(option.value) === activeFontSize
|
|
29901
|
+
},
|
|
29902
|
+
option.value
|
|
29903
|
+
))
|
|
29508
29904
|
}
|
|
29509
29905
|
),
|
|
29510
29906
|
/* @__PURE__ */ jsxs72(
|
|
@@ -30246,7 +30642,7 @@ import {
|
|
|
30246
30642
|
} from "lucide-react";
|
|
30247
30643
|
|
|
30248
30644
|
// src/components/UEditor/table-formula-commands.ts
|
|
30249
|
-
import { selectedRect as selectedRect2, setCellAttr, TableMap as
|
|
30645
|
+
import { selectedRect as selectedRect2, setCellAttr, TableMap as TableMap3 } from "@tiptap/pm/tables";
|
|
30250
30646
|
|
|
30251
30647
|
// src/components/UEditor/table-formula.ts
|
|
30252
30648
|
var CELL_ADDRESS_RE = /^([A-Z]+)([1-9]\d*)$/i;
|
|
@@ -30780,7 +31176,7 @@ function getSelectionTableCellLabel(editor) {
|
|
|
30780
31176
|
const tableNode = $from.node(tableDepth);
|
|
30781
31177
|
const tableStart = $from.start(tableDepth);
|
|
30782
31178
|
const relativeCellPos = $from.before(cellDepth) - tableStart;
|
|
30783
|
-
const rect = safeFindCell2(
|
|
31179
|
+
const rect = safeFindCell2(TableMap3.get(tableNode), relativeCellPos);
|
|
30784
31180
|
if (!rect) return null;
|
|
30785
31181
|
return `${indexToColumnName(rect.left)}${rect.top + 1}`;
|
|
30786
31182
|
}
|
|
@@ -30796,7 +31192,7 @@ function createCellDisplayContent(cellNode, displayValue) {
|
|
|
30796
31192
|
return [paragraphType.create(null, cellNode.type.schema.text(displayValue))];
|
|
30797
31193
|
}
|
|
30798
31194
|
function buildTableValueMap(tableNode) {
|
|
30799
|
-
const map =
|
|
31195
|
+
const map = TableMap3.get(tableNode);
|
|
30800
31196
|
const values = /* @__PURE__ */ new Map();
|
|
30801
31197
|
for (const rowInfo of getTableRows2(tableNode)) {
|
|
30802
31198
|
for (const entry of rowInfo.cells) {
|
|
@@ -30916,7 +31312,7 @@ function promoteFormulaTextInTableNode(tableNode) {
|
|
|
30916
31312
|
function recalculateTableNode(tableNode, options) {
|
|
30917
31313
|
const promoted = promoteFormulaTextInTableNode(tableNode);
|
|
30918
31314
|
tableNode = promoted.tableNode;
|
|
30919
|
-
const map =
|
|
31315
|
+
const map = TableMap3.get(tableNode);
|
|
30920
31316
|
const values = buildTableValueMap(tableNode);
|
|
30921
31317
|
const formulaEntries = /* @__PURE__ */ new Map();
|
|
30922
31318
|
let changed = false;
|
|
@@ -31743,9 +32139,14 @@ var CustomBubbleMenu = ({
|
|
|
31743
32139
|
}) => {
|
|
31744
32140
|
const SHOW_DELAY_MS = 180;
|
|
31745
32141
|
const BUBBLE_MENU_OFFSET = 16;
|
|
32142
|
+
const BUBBLE_MENU_ESTIMATED_HEIGHT = 44;
|
|
31746
32143
|
const [isVisible, setIsVisible] = useState48(false);
|
|
31747
32144
|
const [linkInputOpen, setLinkInputOpen] = useState48(false);
|
|
31748
|
-
const [position, setPosition] = useState48({
|
|
32145
|
+
const [position, setPosition] = useState48({
|
|
32146
|
+
top: 0,
|
|
32147
|
+
left: 0,
|
|
32148
|
+
placement: "top"
|
|
32149
|
+
});
|
|
31749
32150
|
const menuRef = useRef33(null);
|
|
31750
32151
|
const keepOpenRef = useRef33(false);
|
|
31751
32152
|
const showTimeoutRef = useRef33(null);
|
|
@@ -31802,12 +32203,18 @@ var CustomBubbleMenu = ({
|
|
|
31802
32203
|
return;
|
|
31803
32204
|
}
|
|
31804
32205
|
const viewportPadding = 8;
|
|
32206
|
+
const menuHeight = menuRef.current?.getBoundingClientRect().height || BUBBLE_MENU_ESTIMATED_HEIGHT;
|
|
32207
|
+
const editorTop = view.dom.getBoundingClientRect().top;
|
|
32208
|
+
const selectionTop = Math.min(start.top, end.top);
|
|
32209
|
+
const selectionBottom = Math.max(start.bottom, end.bottom);
|
|
32210
|
+
const hasRoomAboveEditor = selectionTop - BUBBLE_MENU_OFFSET - menuHeight >= editorTop + viewportPadding;
|
|
32211
|
+
const placement = hasRoomAboveEditor ? "top" : "bottom";
|
|
31805
32212
|
const left = Math.min(
|
|
31806
32213
|
window.innerWidth - viewportPadding,
|
|
31807
32214
|
Math.max(viewportPadding, (start.left + end.left) / 2)
|
|
31808
32215
|
);
|
|
31809
|
-
const top = Math.max(viewportPadding,
|
|
31810
|
-
setPosition({ top, left });
|
|
32216
|
+
const top = placement === "top" ? Math.max(viewportPadding, selectionTop - BUBBLE_MENU_OFFSET) : Math.min(window.innerHeight - viewportPadding, selectionBottom + BUBBLE_MENU_OFFSET);
|
|
32217
|
+
setPosition({ top, left, placement });
|
|
31811
32218
|
if (keepOpenRef.current) {
|
|
31812
32219
|
clearShowTimeout();
|
|
31813
32220
|
setIsVisible(true);
|
|
@@ -31852,7 +32259,7 @@ var CustomBubbleMenu = ({
|
|
|
31852
32259
|
style: {
|
|
31853
32260
|
top: `${position.top}px`,
|
|
31854
32261
|
left: `${position.left}px`,
|
|
31855
|
-
transform: "translate(-50%, -100%)"
|
|
32262
|
+
transform: position.placement === "top" ? "translate(-50%, -100%)" : "translate(-50%, 0)"
|
|
31856
32263
|
},
|
|
31857
32264
|
onMouseDown: (e) => {
|
|
31858
32265
|
const target = e.target;
|
|
@@ -35574,7 +35981,7 @@ if (typeof WeakMap != "undefined") {
|
|
|
35574
35981
|
return cache[cachePos++] = value;
|
|
35575
35982
|
};
|
|
35576
35983
|
}
|
|
35577
|
-
var
|
|
35984
|
+
var TableMap4 = class {
|
|
35578
35985
|
constructor(width, height, map, problems) {
|
|
35579
35986
|
this.width = width;
|
|
35580
35987
|
this.height = height;
|
|
@@ -35711,7 +36118,7 @@ function computeMap(table) {
|
|
|
35711
36118
|
pos++;
|
|
35712
36119
|
}
|
|
35713
36120
|
if (width === 0 || height === 0) (problems || (problems = [])).push({ type: "zero_sized" });
|
|
35714
|
-
const tableMap = new
|
|
36121
|
+
const tableMap = new TableMap4(width, height, map, problems);
|
|
35715
36122
|
let badWidths = false;
|
|
35716
36123
|
for (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;
|
|
35717
36124
|
if (badWidths) findBadColWidths(tableMap, colWidths, table);
|
|
@@ -35768,7 +36175,7 @@ function freshColWidth(attrs) {
|
|
|
35768
36175
|
for (let i = 0; i < attrs.colspan; i++) result.push(0);
|
|
35769
36176
|
return result;
|
|
35770
36177
|
}
|
|
35771
|
-
function
|
|
36178
|
+
function tableNodeTypes2(schema) {
|
|
35772
36179
|
let result = schema.cached.tableNodeTypes;
|
|
35773
36180
|
if (!result) {
|
|
35774
36181
|
result = schema.cached.tableNodeTypes = {};
|
|
@@ -35780,7 +36187,7 @@ function tableNodeTypes(schema) {
|
|
|
35780
36187
|
return result;
|
|
35781
36188
|
}
|
|
35782
36189
|
var tableEditingKey = new PluginKey5("selectingCells");
|
|
35783
|
-
function
|
|
36190
|
+
function cellAround2($pos) {
|
|
35784
36191
|
for (let d = $pos.depth - 1; d > 0; d--) if ($pos.node(d).type.spec.tableRole == "row") return $pos.node(0).resolve($pos.before(d + 1));
|
|
35785
36192
|
return null;
|
|
35786
36193
|
}
|
|
@@ -35793,7 +36200,7 @@ function selectionCell(state) {
|
|
|
35793
36200
|
const sel = state.selection;
|
|
35794
36201
|
if ("$anchorCell" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
35795
36202
|
else if ("node" in sel && sel.node && sel.node.type.spec.tableRole == "cell") return sel.$anchor;
|
|
35796
|
-
const $cell =
|
|
36203
|
+
const $cell = cellAround2(sel.$head) || cellNear(sel.$head);
|
|
35797
36204
|
if ($cell) return $cell;
|
|
35798
36205
|
throw new RangeError(`No cell found around position ${sel.head}`);
|
|
35799
36206
|
}
|
|
@@ -35807,7 +36214,7 @@ function cellNear($pos) {
|
|
|
35807
36214
|
if (role == "cell" || role == "header_cell") return $pos.doc.resolve(pos - before.nodeSize);
|
|
35808
36215
|
}
|
|
35809
36216
|
}
|
|
35810
|
-
function
|
|
36217
|
+
function pointsAtCell2($pos) {
|
|
35811
36218
|
return $pos.parent.type.spec.tableRole == "row" && !!$pos.nodeAfter;
|
|
35812
36219
|
}
|
|
35813
36220
|
function inSameTable($cellA, $cellB) {
|
|
@@ -35815,7 +36222,7 @@ function inSameTable($cellA, $cellB) {
|
|
|
35815
36222
|
}
|
|
35816
36223
|
function nextCell($pos, axis, dir) {
|
|
35817
36224
|
const table = $pos.node(-1);
|
|
35818
|
-
const map =
|
|
36225
|
+
const map = TableMap4.get(table);
|
|
35819
36226
|
const tableStart = $pos.start(-1);
|
|
35820
36227
|
const moved = map.nextCell($pos.pos - tableStart, axis, dir);
|
|
35821
36228
|
return moved == null ? null : $pos.node(0).resolve(tableStart + moved);
|
|
@@ -35835,7 +36242,7 @@ function removeColSpan(attrs, pos, n = 1) {
|
|
|
35835
36242
|
var CellSelection = class CellSelection2 extends Selection {
|
|
35836
36243
|
constructor($anchorCell, $headCell = $anchorCell) {
|
|
35837
36244
|
const table = $anchorCell.node(-1);
|
|
35838
|
-
const map =
|
|
36245
|
+
const map = TableMap4.get(table);
|
|
35839
36246
|
const tableStart = $anchorCell.start(-1);
|
|
35840
36247
|
const rect = map.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);
|
|
35841
36248
|
const doc = $anchorCell.node(0);
|
|
@@ -35854,7 +36261,7 @@ var CellSelection = class CellSelection2 extends Selection {
|
|
|
35854
36261
|
map(doc, mapping) {
|
|
35855
36262
|
const $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
|
|
35856
36263
|
const $headCell = doc.resolve(mapping.map(this.$headCell.pos));
|
|
35857
|
-
if (
|
|
36264
|
+
if (pointsAtCell2($anchorCell) && pointsAtCell2($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
35858
36265
|
const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
|
|
35859
36266
|
if (tableChanged && this.isRowSelection()) return CellSelection2.rowSelection($anchorCell, $headCell);
|
|
35860
36267
|
else if (tableChanged && this.isColSelection()) return CellSelection2.colSelection($anchorCell, $headCell);
|
|
@@ -35864,7 +36271,7 @@ var CellSelection = class CellSelection2 extends Selection {
|
|
|
35864
36271
|
}
|
|
35865
36272
|
content() {
|
|
35866
36273
|
const table = this.$anchorCell.node(-1);
|
|
35867
|
-
const map =
|
|
36274
|
+
const map = TableMap4.get(table);
|
|
35868
36275
|
const tableStart = this.$anchorCell.start(-1);
|
|
35869
36276
|
const rect = map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);
|
|
35870
36277
|
const seen = {};
|
|
@@ -35918,7 +36325,7 @@ var CellSelection = class CellSelection2 extends Selection {
|
|
|
35918
36325
|
}
|
|
35919
36326
|
forEachCell(f) {
|
|
35920
36327
|
const table = this.$anchorCell.node(-1);
|
|
35921
|
-
const map =
|
|
36328
|
+
const map = TableMap4.get(table);
|
|
35922
36329
|
const tableStart = this.$anchorCell.start(-1);
|
|
35923
36330
|
const cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));
|
|
35924
36331
|
for (let i = 0; i < cells.length; i++) f(table.nodeAt(cells[i]), tableStart + cells[i]);
|
|
@@ -35933,7 +36340,7 @@ var CellSelection = class CellSelection2 extends Selection {
|
|
|
35933
36340
|
}
|
|
35934
36341
|
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
35935
36342
|
const table = $anchorCell.node(-1);
|
|
35936
|
-
const map =
|
|
36343
|
+
const map = TableMap4.get(table);
|
|
35937
36344
|
const tableStart = $anchorCell.start(-1);
|
|
35938
36345
|
const anchorRect = map.findCell($anchorCell.pos - tableStart);
|
|
35939
36346
|
const headRect = map.findCell($headCell.pos - tableStart);
|
|
@@ -35949,7 +36356,7 @@ var CellSelection = class CellSelection2 extends Selection {
|
|
|
35949
36356
|
}
|
|
35950
36357
|
isRowSelection() {
|
|
35951
36358
|
const table = this.$anchorCell.node(-1);
|
|
35952
|
-
const map =
|
|
36359
|
+
const map = TableMap4.get(table);
|
|
35953
36360
|
const tableStart = this.$anchorCell.start(-1);
|
|
35954
36361
|
const anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);
|
|
35955
36362
|
const headLeft = map.colCount(this.$headCell.pos - tableStart);
|
|
@@ -35963,7 +36370,7 @@ var CellSelection = class CellSelection2 extends Selection {
|
|
|
35963
36370
|
}
|
|
35964
36371
|
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
35965
36372
|
const table = $anchorCell.node(-1);
|
|
35966
|
-
const map =
|
|
36373
|
+
const map = TableMap4.get(table);
|
|
35967
36374
|
const tableStart = $anchorCell.start(-1);
|
|
35968
36375
|
const anchorRect = map.findCell($anchorCell.pos - tableStart);
|
|
35969
36376
|
const headRect = map.findCell($headCell.pos - tableStart);
|
|
@@ -36012,7 +36419,7 @@ var CellBookmark = class CellBookmark2 {
|
|
|
36012
36419
|
};
|
|
36013
36420
|
var fixTablesKey = new PluginKey5("fix-tables");
|
|
36014
36421
|
function convertTableNodeToArrayOfRows(tableNode) {
|
|
36015
|
-
const map =
|
|
36422
|
+
const map = TableMap4.get(tableNode);
|
|
36016
36423
|
const rows = [];
|
|
36017
36424
|
const rowCount = map.height;
|
|
36018
36425
|
const colCount$1 = map.width;
|
|
@@ -36043,7 +36450,7 @@ function convertTableNodeToArrayOfRows(tableNode) {
|
|
|
36043
36450
|
}
|
|
36044
36451
|
function convertArrayOfRowsToTableNode(tableNode, arrayOfNodes) {
|
|
36045
36452
|
const newRows = [];
|
|
36046
|
-
const map =
|
|
36453
|
+
const map = TableMap4.get(tableNode);
|
|
36047
36454
|
const rowCount = map.height;
|
|
36048
36455
|
const colCount$1 = map.width;
|
|
36049
36456
|
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
@@ -36092,7 +36499,7 @@ function findParentNode(predicate, $pos) {
|
|
|
36092
36499
|
function getCellsInColumn(columnIndex, selection) {
|
|
36093
36500
|
const table = findTable(selection.$from);
|
|
36094
36501
|
if (!table) return;
|
|
36095
|
-
const map =
|
|
36502
|
+
const map = TableMap4.get(table.node);
|
|
36096
36503
|
if (columnIndex < 0 || columnIndex > map.width - 1) return;
|
|
36097
36504
|
return map.cellsInRect({
|
|
36098
36505
|
left: columnIndex,
|
|
@@ -36113,7 +36520,7 @@ function getCellsInColumn(columnIndex, selection) {
|
|
|
36113
36520
|
function getCellsInRow(rowIndex, selection) {
|
|
36114
36521
|
const table = findTable(selection.$from);
|
|
36115
36522
|
if (!table) return;
|
|
36116
|
-
const map =
|
|
36523
|
+
const map = TableMap4.get(table.node);
|
|
36117
36524
|
if (rowIndex < 0 || rowIndex > map.height - 1) return;
|
|
36118
36525
|
return map.cellsInRect({
|
|
36119
36526
|
left: 0,
|
|
@@ -36242,7 +36649,7 @@ function moveColumn(moveColParams) {
|
|
|
36242
36649
|
const newTable = moveTableColumn$1(table.node, indexesOriginColumn, indexesTargetColumn, 0);
|
|
36243
36650
|
tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
|
|
36244
36651
|
if (!select) return true;
|
|
36245
|
-
const map =
|
|
36652
|
+
const map = TableMap4.get(newTable);
|
|
36246
36653
|
const start = table.start;
|
|
36247
36654
|
const index = targetIndex;
|
|
36248
36655
|
const lastCell = map.positionAt(map.height - 1, index, newTable);
|
|
@@ -36270,7 +36677,7 @@ function moveRow(moveRowParams) {
|
|
|
36270
36677
|
const newTable = moveTableRow$1(table.node, indexesOriginRow, indexesTargetRow, 0);
|
|
36271
36678
|
tr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);
|
|
36272
36679
|
if (!select) return true;
|
|
36273
|
-
const map =
|
|
36680
|
+
const map = TableMap4.get(newTable);
|
|
36274
36681
|
const start = table.start;
|
|
36275
36682
|
const index = targetIndex;
|
|
36276
36683
|
const lastCell = map.positionAt(index, map.width - 1, newTable);
|
|
@@ -36290,7 +36697,7 @@ function selectedRect3(state) {
|
|
|
36290
36697
|
const $pos = selectionCell(state);
|
|
36291
36698
|
const table = $pos.node(-1);
|
|
36292
36699
|
const tableStart = $pos.start(-1);
|
|
36293
|
-
const map =
|
|
36700
|
+
const map = TableMap4.get(table);
|
|
36294
36701
|
return {
|
|
36295
36702
|
...sel instanceof CellSelection ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),
|
|
36296
36703
|
tableStart,
|
|
@@ -36302,7 +36709,7 @@ function deprecated_toggleHeader(type) {
|
|
|
36302
36709
|
return function(state, dispatch) {
|
|
36303
36710
|
if (!isInTable(state)) return false;
|
|
36304
36711
|
if (dispatch) {
|
|
36305
|
-
const types =
|
|
36712
|
+
const types = tableNodeTypes2(state.schema);
|
|
36306
36713
|
const rect = selectedRect3(state), tr = state.tr;
|
|
36307
36714
|
const cells = rect.map.cellsInRect(type == "column" ? {
|
|
36308
36715
|
left: rect.left,
|
|
@@ -36342,7 +36749,7 @@ function toggleHeader(type, options) {
|
|
|
36342
36749
|
return function(state, dispatch) {
|
|
36343
36750
|
if (!isInTable(state)) return false;
|
|
36344
36751
|
if (dispatch) {
|
|
36345
|
-
const types =
|
|
36752
|
+
const types = tableNodeTypes2(state.schema);
|
|
36346
36753
|
const rect = selectedRect3(state), tr = state.tr;
|
|
36347
36754
|
const isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types);
|
|
36348
36755
|
const isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types);
|
|
@@ -36377,7 +36784,7 @@ function deleteCellSelection(state, dispatch) {
|
|
|
36377
36784
|
if (!(sel instanceof CellSelection)) return false;
|
|
36378
36785
|
if (dispatch) {
|
|
36379
36786
|
const tr = state.tr;
|
|
36380
|
-
const baseContent =
|
|
36787
|
+
const baseContent = tableNodeTypes2(state.schema).cell.createAndFill().content;
|
|
36381
36788
|
sel.forEachCell((cell, pos) => {
|
|
36382
36789
|
if (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));
|
|
36383
36790
|
});
|
|
@@ -36488,7 +36895,7 @@ function atEndOfCell(view, axis, dir) {
|
|
|
36488
36895
|
}
|
|
36489
36896
|
return null;
|
|
36490
36897
|
}
|
|
36491
|
-
var
|
|
36898
|
+
var columnResizingPluginKey2 = new PluginKey5("tableColumnResizing");
|
|
36492
36899
|
|
|
36493
36900
|
// src/components/UEditor/table-controls.tsx
|
|
36494
36901
|
import {
|
|
@@ -36505,7 +36912,7 @@ import {
|
|
|
36505
36912
|
} from "lucide-react";
|
|
36506
36913
|
|
|
36507
36914
|
// src/components/UEditor/table-layout-model.ts
|
|
36508
|
-
var FALLBACK_TABLE_ROW_HEIGHT =
|
|
36915
|
+
var FALLBACK_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
|
|
36509
36916
|
var FALLBACK_TABLE_COLUMN_WIDTH = 160;
|
|
36510
36917
|
function getVisibleTableBounds(layout) {
|
|
36511
36918
|
const left = Math.max(layout.tableLeft, layout.wrapperLeft);
|
|
@@ -36587,7 +36994,7 @@ function buildLogicalColumnMetrics({
|
|
|
36587
36994
|
tableLeft,
|
|
36588
36995
|
tableWidth
|
|
36589
36996
|
}) {
|
|
36590
|
-
const map =
|
|
36997
|
+
const map = TableMap4.get(tableInfo.node);
|
|
36591
36998
|
const fallbackWidth = metricOrFallback(tableWidth / map.width, FALLBACK_TABLE_COLUMN_WIDTH);
|
|
36592
36999
|
const firstRow = tableElement.rows.item(0);
|
|
36593
37000
|
const visualColumns = [];
|
|
@@ -36640,7 +37047,7 @@ function buildLogicalRowMetrics({
|
|
|
36640
37047
|
tableHeight,
|
|
36641
37048
|
cornerCell
|
|
36642
37049
|
}) {
|
|
36643
|
-
const map =
|
|
37050
|
+
const map = TableMap4.get(tableInfo.node);
|
|
36644
37051
|
const fallbackHeight = metricOrFallback(tableHeight / map.height, FALLBACK_TABLE_ROW_HEIGHT);
|
|
36645
37052
|
const visualRows = [];
|
|
36646
37053
|
const seenCellPositions = /* @__PURE__ */ new Set();
|
|
@@ -36694,7 +37101,7 @@ function buildTableControlLayout(editor, surface, cell) {
|
|
|
36694
37101
|
if (rows.length === 0 || !tableInfo || !(cornerCell instanceof HTMLTableCellElement)) {
|
|
36695
37102
|
return null;
|
|
36696
37103
|
}
|
|
36697
|
-
const map =
|
|
37104
|
+
const map = TableMap4.get(tableInfo.node);
|
|
36698
37105
|
const surfaceRect = surface.getBoundingClientRect();
|
|
36699
37106
|
const tableRect = table.getBoundingClientRect();
|
|
36700
37107
|
const wrapperElement = table.closest(".tableWrapper");
|
|
@@ -37328,7 +37735,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
37328
37735
|
const handleSurfaceMouseMove = (event) => {
|
|
37329
37736
|
updateHoverState(event);
|
|
37330
37737
|
};
|
|
37331
|
-
const
|
|
37738
|
+
const handleMouseLeave2 = () => {
|
|
37332
37739
|
if (dragStateRef.current) return;
|
|
37333
37740
|
setHoverState(DEFAULT_TABLE_HOVER_STATE);
|
|
37334
37741
|
};
|
|
@@ -37338,7 +37745,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
37338
37745
|
syncFromCell(cell ?? getSelectedCell(editor));
|
|
37339
37746
|
};
|
|
37340
37747
|
proseMirror.addEventListener("mouseover", handleMouseOver);
|
|
37341
|
-
proseMirror.addEventListener("mouseleave",
|
|
37748
|
+
proseMirror.addEventListener("mouseleave", handleMouseLeave2);
|
|
37342
37749
|
proseMirror.addEventListener("click", handleFocusIn);
|
|
37343
37750
|
proseMirror.addEventListener("mouseup", handleFocusIn);
|
|
37344
37751
|
proseMirror.addEventListener("focusin", handleFocusIn);
|
|
@@ -37352,7 +37759,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
37352
37759
|
syncFromSelection();
|
|
37353
37760
|
return () => {
|
|
37354
37761
|
proseMirror.removeEventListener("mouseover", handleMouseOver);
|
|
37355
|
-
proseMirror.removeEventListener("mouseleave",
|
|
37762
|
+
proseMirror.removeEventListener("mouseleave", handleMouseLeave2);
|
|
37356
37763
|
proseMirror.removeEventListener("click", handleFocusIn);
|
|
37357
37764
|
proseMirror.removeEventListener("mouseup", handleFocusIn);
|
|
37358
37765
|
proseMirror.removeEventListener("focusin", handleFocusIn);
|
|
@@ -37451,7 +37858,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
37451
37858
|
document.body.style.cursor = "grabbing";
|
|
37452
37859
|
}, []);
|
|
37453
37860
|
React79.useEffect(() => {
|
|
37454
|
-
const
|
|
37861
|
+
const handleMouseMove2 = (event) => {
|
|
37455
37862
|
const dragState = dragStateRef.current;
|
|
37456
37863
|
const activeLayout = layoutRef.current;
|
|
37457
37864
|
const surface = containerRef.current;
|
|
@@ -37530,11 +37937,11 @@ function TableControls({ editor, containerRef }) {
|
|
|
37530
37937
|
}
|
|
37531
37938
|
clearDrag();
|
|
37532
37939
|
};
|
|
37533
|
-
window.addEventListener("mousemove",
|
|
37940
|
+
window.addEventListener("mousemove", handleMouseMove2);
|
|
37534
37941
|
window.addEventListener("mouseup", handleMouseUp);
|
|
37535
37942
|
window.addEventListener("blur", clearDrag);
|
|
37536
37943
|
return () => {
|
|
37537
|
-
window.removeEventListener("mousemove",
|
|
37944
|
+
window.removeEventListener("mousemove", handleMouseMove2);
|
|
37538
37945
|
window.removeEventListener("mouseup", handleMouseUp);
|
|
37539
37946
|
window.removeEventListener("blur", clearDrag);
|
|
37540
37947
|
};
|
|
@@ -37822,6 +38229,10 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
|
|
|
37822
38229
|
"[&_th]:px-2",
|
|
37823
38230
|
"[&_th]:py-0",
|
|
37824
38231
|
"[&_th_p]:my-0",
|
|
38232
|
+
"[&_td[colwidth]]:min-w-0",
|
|
38233
|
+
"[&_th[colwidth]]:min-w-0",
|
|
38234
|
+
"[&_td[data-colwidth]]:min-w-0",
|
|
38235
|
+
"[&_th[data-colwidth]]:min-w-0",
|
|
37825
38236
|
"[&_.selectedCell]:after:content-['']",
|
|
37826
38237
|
"[&_.selectedCell]:after:absolute",
|
|
37827
38238
|
"[&_.selectedCell]:after:inset-0",
|
|
@@ -37851,6 +38262,7 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
|
|
|
37851
38262
|
"[&_.column-resize-handle]:after:content-['']",
|
|
37852
38263
|
"[&.resize-cursor_.column-resize-handle]:opacity-100",
|
|
37853
38264
|
"[&.resize-cursor_.column-resize-handle]:after:bg-primary",
|
|
38265
|
+
"[&_.column-resize-dragging]:min-w-0",
|
|
37854
38266
|
"[&.resize-cursor]:cursor-col-resize",
|
|
37855
38267
|
"[&.resize-row-cursor]:cursor-row-resize",
|
|
37856
38268
|
"[&_img.ProseMirror-selectednode]:ring-2",
|
|
@@ -37923,55 +38335,12 @@ function useTableRowResize({
|
|
|
37923
38335
|
clearAllTableResizeHover,
|
|
37924
38336
|
scheduleTableLayoutSync
|
|
37925
38337
|
}) {
|
|
37926
|
-
const commitFrameRef = useRef34(null);
|
|
37927
38338
|
const stateRef = useRef34(null);
|
|
37928
|
-
const commitPreview = React80.useCallback(() => {
|
|
37929
|
-
if (!editor) return;
|
|
37930
|
-
const state = stateRef.current;
|
|
37931
|
-
if (!state) return;
|
|
37932
|
-
const nextHeight = state.pendingHeight;
|
|
37933
|
-
if (nextHeight === state.previewHeight) {
|
|
37934
|
-
document.body.style.cursor = "row-resize";
|
|
37935
|
-
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
37936
|
-
scheduleTableLayoutSync();
|
|
37937
|
-
return;
|
|
37938
|
-
}
|
|
37939
|
-
state.previewHeight = nextHeight;
|
|
37940
|
-
const tr = editor.view.state.tr;
|
|
37941
|
-
tr.setNodeMarkup(state.rowPos, void 0, {
|
|
37942
|
-
...state.rowNode.attrs,
|
|
37943
|
-
rowHeight: nextHeight
|
|
37944
|
-
});
|
|
37945
|
-
tr.setMeta("addToHistory", false);
|
|
37946
|
-
editor.view.dispatch(tr);
|
|
37947
|
-
state.rowNode = editor.view.state.doc.nodeAt(state.rowPos) ?? state.rowNode;
|
|
37948
|
-
const rowIndex = state.rowElement.rowIndex;
|
|
37949
|
-
if (rowIndex >= 0) {
|
|
37950
|
-
const refreshedRow = state.tableElement.rows.item(rowIndex);
|
|
37951
|
-
if (refreshedRow instanceof HTMLTableRowElement) {
|
|
37952
|
-
state.rowElement = refreshedRow;
|
|
37953
|
-
const refreshedCell = refreshedRow.cells.item(state.cellIndex);
|
|
37954
|
-
if (refreshedCell instanceof HTMLTableCellElement) {
|
|
37955
|
-
state.cellElement = refreshedCell;
|
|
37956
|
-
}
|
|
37957
|
-
}
|
|
37958
|
-
}
|
|
37959
|
-
document.body.style.cursor = "row-resize";
|
|
37960
|
-
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
37961
|
-
scheduleTableLayoutSync();
|
|
37962
|
-
}, [editor, scheduleTableLayoutSync, showRowGuide]);
|
|
37963
|
-
const scheduleCommit = React80.useCallback(() => {
|
|
37964
|
-
if (commitFrameRef.current !== null) return;
|
|
37965
|
-
commitFrameRef.current = window.requestAnimationFrame(() => {
|
|
37966
|
-
commitFrameRef.current = null;
|
|
37967
|
-
commitPreview();
|
|
37968
|
-
});
|
|
37969
|
-
}, [commitPreview]);
|
|
37970
38339
|
const syncActiveGuide = React80.useCallback(() => {
|
|
37971
38340
|
const state = stateRef.current;
|
|
37972
38341
|
if (!state) return false;
|
|
37973
38342
|
setHoveredTableCell(state.cellElement);
|
|
37974
|
-
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
38343
|
+
showRowGuide(state.tableElement, state.rowElement, state.cellElement, state.pendingHeight);
|
|
37975
38344
|
return true;
|
|
37976
38345
|
}, [setHoveredTableCell, showRowGuide]);
|
|
37977
38346
|
const isResizing = React80.useCallback(() => stateRef.current !== null, []);
|
|
@@ -37995,7 +38364,7 @@ function useTableRowResize({
|
|
|
37995
38364
|
previewHeight: startHeight,
|
|
37996
38365
|
pendingHeight: startHeight
|
|
37997
38366
|
};
|
|
37998
|
-
showRowGuide(table, row, cell);
|
|
38367
|
+
showRowGuide(table, row, cell, startHeight);
|
|
37999
38368
|
document.body.style.cursor = "row-resize";
|
|
38000
38369
|
event.preventDefault();
|
|
38001
38370
|
event.stopPropagation();
|
|
@@ -38010,13 +38379,14 @@ function useTableRowResize({
|
|
|
38010
38379
|
);
|
|
38011
38380
|
if (nextHeight === state.pendingHeight) {
|
|
38012
38381
|
document.body.style.cursor = "row-resize";
|
|
38013
|
-
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
38382
|
+
showRowGuide(state.tableElement, state.rowElement, state.cellElement, state.pendingHeight);
|
|
38014
38383
|
return;
|
|
38015
38384
|
}
|
|
38016
38385
|
state.pendingHeight = nextHeight;
|
|
38386
|
+
state.previewHeight = nextHeight;
|
|
38017
38387
|
document.body.style.cursor = "row-resize";
|
|
38018
|
-
|
|
38019
|
-
}, [
|
|
38388
|
+
showRowGuide(state.tableElement, state.rowElement, state.cellElement, nextHeight);
|
|
38389
|
+
}, [showRowGuide]);
|
|
38020
38390
|
const handlePointerUp = React80.useCallback((event) => {
|
|
38021
38391
|
if (!editor) return;
|
|
38022
38392
|
const state = stateRef.current;
|
|
@@ -38026,16 +38396,10 @@ function useTableRowResize({
|
|
|
38026
38396
|
Math.round(state.startHeight + (event.clientY - state.startY))
|
|
38027
38397
|
);
|
|
38028
38398
|
state.pendingHeight = nextHeight;
|
|
38029
|
-
|
|
38030
|
-
window.cancelAnimationFrame(commitFrameRef.current);
|
|
38031
|
-
commitFrameRef.current = null;
|
|
38032
|
-
}
|
|
38033
|
-
commitPreview();
|
|
38034
|
-
const latestState = stateRef.current ?? state;
|
|
38035
|
-
const rowNode = editor.view.state.doc.nodeAt(latestState.rowPos) ?? latestState.rowNode;
|
|
38399
|
+
const rowNode = editor.view.state.doc.nodeAt(state.rowPos) ?? state.rowNode;
|
|
38036
38400
|
if (rowNode.attrs.rowHeight !== nextHeight) {
|
|
38037
38401
|
const tr = editor.view.state.tr;
|
|
38038
|
-
tr.setNodeMarkup(
|
|
38402
|
+
tr.setNodeMarkup(state.rowPos, void 0, {
|
|
38039
38403
|
...rowNode.attrs,
|
|
38040
38404
|
rowHeight: nextHeight
|
|
38041
38405
|
});
|
|
@@ -38046,13 +38410,9 @@ function useTableRowResize({
|
|
|
38046
38410
|
clearHoveredTableCell();
|
|
38047
38411
|
clearAllTableResizeHover();
|
|
38048
38412
|
scheduleTableLayoutSync();
|
|
38049
|
-
}, [clearAllTableResizeHover, clearHoveredTableCell,
|
|
38413
|
+
}, [clearAllTableResizeHover, clearHoveredTableCell, editor, scheduleTableLayoutSync]);
|
|
38050
38414
|
const cancelResize = React80.useCallback(() => {
|
|
38051
38415
|
if (!stateRef.current) return;
|
|
38052
|
-
if (commitFrameRef.current !== null) {
|
|
38053
|
-
window.cancelAnimationFrame(commitFrameRef.current);
|
|
38054
|
-
commitFrameRef.current = null;
|
|
38055
|
-
}
|
|
38056
38416
|
stateRef.current = null;
|
|
38057
38417
|
document.body.style.cursor = "";
|
|
38058
38418
|
clearHoveredTableCell();
|
|
@@ -38060,10 +38420,6 @@ function useTableRowResize({
|
|
|
38060
38420
|
scheduleTableLayoutSync();
|
|
38061
38421
|
}, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
|
|
38062
38422
|
const cleanup = React80.useCallback(() => {
|
|
38063
|
-
if (commitFrameRef.current !== null) {
|
|
38064
|
-
window.cancelAnimationFrame(commitFrameRef.current);
|
|
38065
|
-
commitFrameRef.current = null;
|
|
38066
|
-
}
|
|
38067
38423
|
stateRef.current = null;
|
|
38068
38424
|
document.body.style.cursor = "";
|
|
38069
38425
|
}, []);
|
|
@@ -38173,13 +38529,15 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
38173
38529
|
getProseMirrorElement()?.classList.add("resize-cursor");
|
|
38174
38530
|
setEditorResizeCursor("col-resize");
|
|
38175
38531
|
}, [getProseMirrorElement, setEditorResizeCursor]);
|
|
38176
|
-
const showRowGuide = React81.useCallback((table, row, cell) => {
|
|
38532
|
+
const showRowGuide = React81.useCallback((table, row, cell, previewHeight) => {
|
|
38177
38533
|
const surface = editorContentRef.current;
|
|
38178
38534
|
const guide = tableRowGuideRef.current;
|
|
38179
38535
|
if (!surface || !guide) return;
|
|
38180
38536
|
const metrics = getRelativeBoundaryMetrics(surface, table, row, cell);
|
|
38537
|
+
const rowRect = row.getBoundingClientRect();
|
|
38538
|
+
const previewBottom = typeof previewHeight === "number" ? metrics.rowBottom - rowRect.height + previewHeight : metrics.rowBottom;
|
|
38181
38539
|
guide.style.left = `${metrics.left}px`;
|
|
38182
|
-
guide.style.top = `${
|
|
38540
|
+
guide.style.top = `${previewBottom - ROW_RESIZE_LINE_THICKNESS / 2}px`;
|
|
38183
38541
|
guide.style.width = `${metrics.width}px`;
|
|
38184
38542
|
guide.style.height = `${ROW_RESIZE_LINE_THICKNESS}px`;
|
|
38185
38543
|
guide.style.opacity = "1";
|
|
@@ -38419,7 +38777,7 @@ import {
|
|
|
38419
38777
|
} from "lucide-react";
|
|
38420
38778
|
|
|
38421
38779
|
// src/components/UEditor/preview-html.ts
|
|
38422
|
-
var
|
|
38780
|
+
var DEFAULT_TABLE_COLUMN_WIDTH2 = 100;
|
|
38423
38781
|
var TIPTAP_TABLE_MIN_COLUMN_WIDTH = 25;
|
|
38424
38782
|
function parsePixelWidth2(value) {
|
|
38425
38783
|
if (!value) return null;
|
|
@@ -38446,7 +38804,7 @@ function getCellWidths(cell) {
|
|
|
38446
38804
|
const width = parsePixelWidth2(cell.getAttribute("width")) ?? parseStyleWidth(cell.style);
|
|
38447
38805
|
if (!width) return null;
|
|
38448
38806
|
const colspan = getCellColspan(cell);
|
|
38449
|
-
return Array.from({ length: colspan }, () => Math.max(
|
|
38807
|
+
return Array.from({ length: colspan }, () => Math.max(DEFAULT_TABLE_COLUMN_WIDTH2, Math.round(width / colspan)));
|
|
38450
38808
|
}
|
|
38451
38809
|
function getColumnCount(table) {
|
|
38452
38810
|
const colCount = table.querySelectorAll("colgroup > col").length;
|
|
@@ -38461,7 +38819,7 @@ function getColumnCount(table) {
|
|
|
38461
38819
|
function resolveColumnWidths(table) {
|
|
38462
38820
|
const columnCount = getColumnCount(table);
|
|
38463
38821
|
if (columnCount <= 0) return [];
|
|
38464
|
-
const widths = Array.from({ length: columnCount }, () =>
|
|
38822
|
+
const widths = Array.from({ length: columnCount }, () => DEFAULT_TABLE_COLUMN_WIDTH2);
|
|
38465
38823
|
const cols = Array.from(table.querySelectorAll("colgroup > col"));
|
|
38466
38824
|
cols.slice(0, columnCount).forEach((col, index) => {
|
|
38467
38825
|
const width = parsePixelWidth2(col.getAttribute("width")) ?? parseStyleWidth(col.style);
|
|
@@ -38495,11 +38853,10 @@ function resolveExplicitRowHeight(row) {
|
|
|
38495
38853
|
const height = parsePixelWidth2(cell.getAttribute("height")) ?? parseStyleHeight(cell.style);
|
|
38496
38854
|
return height ? Math.max(maxHeight, height) : maxHeight;
|
|
38497
38855
|
}, 0);
|
|
38498
|
-
return cellHeight ? Math.max(MIN_TABLE_ROW_HEIGHT, cellHeight) :
|
|
38856
|
+
return cellHeight ? Math.max(MIN_TABLE_ROW_HEIGHT, cellHeight) : DEFAULT_TABLE_ROW_HEIGHT;
|
|
38499
38857
|
}
|
|
38500
38858
|
function normalizePreviewRowHeight(row) {
|
|
38501
38859
|
const rowHeight = resolveExplicitRowHeight(row);
|
|
38502
|
-
if (!rowHeight) return;
|
|
38503
38860
|
row.style.height = `${rowHeight}px`;
|
|
38504
38861
|
row.style.minHeight = `${rowHeight}px`;
|
|
38505
38862
|
Array.from(row.cells).forEach((cell) => {
|
|
@@ -38931,17 +39288,6 @@ function buildTableMenuItems(t, editor, onInsertTable) {
|
|
|
38931
39288
|
label: t("menubar.row"),
|
|
38932
39289
|
disabled: !inTable,
|
|
38933
39290
|
items: [
|
|
38934
|
-
{
|
|
38935
|
-
type: "action",
|
|
38936
|
-
label: t("menubar.addRowBefore"),
|
|
38937
|
-
onClick: () => editor.chain().focus().addRowBefore().run()
|
|
38938
|
-
},
|
|
38939
|
-
{
|
|
38940
|
-
type: "action",
|
|
38941
|
-
label: t("menubar.addRowAfter"),
|
|
38942
|
-
onClick: () => editor.chain().focus().addRowAfter().run()
|
|
38943
|
-
},
|
|
38944
|
-
{ type: "separator" },
|
|
38945
39291
|
{
|
|
38946
39292
|
type: "action",
|
|
38947
39293
|
label: t("menubar.deleteRow"),
|
|
@@ -38955,17 +39301,6 @@ function buildTableMenuItems(t, editor, onInsertTable) {
|
|
|
38955
39301
|
label: t("menubar.column"),
|
|
38956
39302
|
disabled: !inTable,
|
|
38957
39303
|
items: [
|
|
38958
|
-
{
|
|
38959
|
-
type: "action",
|
|
38960
|
-
label: t("menubar.addColumnBefore"),
|
|
38961
|
-
onClick: () => editor.chain().focus().addColumnBefore().run()
|
|
38962
|
-
},
|
|
38963
|
-
{
|
|
38964
|
-
type: "action",
|
|
38965
|
-
label: t("menubar.addColumnAfter"),
|
|
38966
|
-
onClick: () => editor.chain().focus().addColumnAfter().run()
|
|
38967
|
-
},
|
|
38968
|
-
{ type: "separator" },
|
|
38969
39304
|
{
|
|
38970
39305
|
type: "action",
|
|
38971
39306
|
label: t("menubar.deleteColumn"),
|
|
@@ -39302,7 +39637,7 @@ var MenuBar = ({
|
|
|
39302
39637
|
|
|
39303
39638
|
// src/components/UEditor/table-formula-range-picker.ts
|
|
39304
39639
|
import { TextSelection as TextSelection4 } from "@tiptap/pm/state";
|
|
39305
|
-
import { TableMap as
|
|
39640
|
+
import { TableMap as TableMap5 } from "@tiptap/pm/tables";
|
|
39306
39641
|
function getCellText2(cellNode) {
|
|
39307
39642
|
return cellNode.textBetween(0, cellNode.content.size, "\n").trim();
|
|
39308
39643
|
}
|
|
@@ -39357,7 +39692,7 @@ function getPickedCellLabel(view, target, tablePos) {
|
|
|
39357
39692
|
const domPos = view.posAtDOM(cell, 0);
|
|
39358
39693
|
const tableInfo = findTableForPos(view, domPos);
|
|
39359
39694
|
if (!tableInfo || tableInfo.pos !== tablePos) return null;
|
|
39360
|
-
const map =
|
|
39695
|
+
const map = TableMap5.get(tableInfo.node);
|
|
39361
39696
|
const relativeCellPos = getCellRelativePosFromDomPos2(map, tableInfo.start, domPos);
|
|
39362
39697
|
if (relativeCellPos == null) return null;
|
|
39363
39698
|
const rect = map.findCell(relativeCellPos);
|