@underverse-ui/underverse 1.0.143 → 1.0.144
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 +139 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +140 -133
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25741,6 +25741,45 @@ function getImageFiles(dataTransfer) {
|
|
|
25741
25741
|
}
|
|
25742
25742
|
return Array.from(byKey.values());
|
|
25743
25743
|
}
|
|
25744
|
+
function getClipboardData(dataTransfer, type) {
|
|
25745
|
+
try {
|
|
25746
|
+
return dataTransfer.getData(type) ?? "";
|
|
25747
|
+
} catch {
|
|
25748
|
+
return "";
|
|
25749
|
+
}
|
|
25750
|
+
}
|
|
25751
|
+
function extractClipboardHtmlFragment(html) {
|
|
25752
|
+
const startMarker = "<!--StartFragment-->";
|
|
25753
|
+
const endMarker = "<!--EndFragment-->";
|
|
25754
|
+
const start = html.indexOf(startMarker);
|
|
25755
|
+
const end = html.indexOf(endMarker);
|
|
25756
|
+
if (start >= 0 && end > start) {
|
|
25757
|
+
return html.slice(start + startMarker.length, end);
|
|
25758
|
+
}
|
|
25759
|
+
return html;
|
|
25760
|
+
}
|
|
25761
|
+
function getClipboardTableHtml(dataTransfer) {
|
|
25762
|
+
const html = getClipboardData(dataTransfer, "text/html");
|
|
25763
|
+
if (!/<table(?:\s|>)/i.test(html)) return "";
|
|
25764
|
+
const fragment = extractClipboardHtmlFragment(html);
|
|
25765
|
+
if (typeof DOMParser !== "undefined") {
|
|
25766
|
+
const doc = new DOMParser().parseFromString(fragment, "text/html");
|
|
25767
|
+
const table = doc.querySelector("table");
|
|
25768
|
+
if (table) return table.outerHTML;
|
|
25769
|
+
}
|
|
25770
|
+
return fragment;
|
|
25771
|
+
}
|
|
25772
|
+
function escapeHtml(value) {
|
|
25773
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
25774
|
+
}
|
|
25775
|
+
function getClipboardTsvTableHtml(dataTransfer) {
|
|
25776
|
+
const text = getClipboardData(dataTransfer, "text/plain").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\n+$/, "");
|
|
25777
|
+
if (!text.includes(" ")) return "";
|
|
25778
|
+
const rows = text.split("\n").map((row) => row.split(" "));
|
|
25779
|
+
if (rows.length === 0 || rows.every((row) => row.length < 2)) return "";
|
|
25780
|
+
const body = rows.map((row) => `<tr>${row.map((cell) => `<td>${escapeHtml(cell)}</td>`).join("")}</tr>`).join("");
|
|
25781
|
+
return `<table><tbody>${body}</tbody></table>`;
|
|
25782
|
+
}
|
|
25744
25783
|
function fileToDataUrl(file) {
|
|
25745
25784
|
return new Promise((resolve, reject) => {
|
|
25746
25785
|
const reader = new FileReader();
|
|
@@ -25795,6 +25834,18 @@ var ClipboardImages = Extension2.create({
|
|
|
25795
25834
|
props: {
|
|
25796
25835
|
handlePaste: (_view, event) => {
|
|
25797
25836
|
if (!event || !event.clipboardData) return false;
|
|
25837
|
+
const tableHtml = getClipboardTableHtml(event.clipboardData);
|
|
25838
|
+
if (tableHtml) {
|
|
25839
|
+
event.preventDefault();
|
|
25840
|
+
editor.chain().focus().insertContent(tableHtml).run();
|
|
25841
|
+
return true;
|
|
25842
|
+
}
|
|
25843
|
+
const tsvTableHtml = getClipboardTsvTableHtml(event.clipboardData);
|
|
25844
|
+
if (tsvTableHtml) {
|
|
25845
|
+
event.preventDefault();
|
|
25846
|
+
editor.chain().focus().insertContent(tsvTableHtml).run();
|
|
25847
|
+
return true;
|
|
25848
|
+
}
|
|
25798
25849
|
const files = getImageFiles(event.clipboardData);
|
|
25799
25850
|
if (files.length === 0) return false;
|
|
25800
25851
|
event.preventDefault();
|
|
@@ -28984,58 +29035,6 @@ import {
|
|
|
28984
29035
|
ExternalLink as ExternalLink3
|
|
28985
29036
|
} from "lucide-react";
|
|
28986
29037
|
import { Fragment as Fragment29, jsx as jsx86, jsxs as jsxs72 } from "react/jsx-runtime";
|
|
28987
|
-
var FloatingSlashCommandMenu = ({ editor, onClose }) => {
|
|
28988
|
-
const t = useSmartTranslations("UEditor");
|
|
28989
|
-
const messages = useMemo23(() => buildSlashCommandMessages(t), [t]);
|
|
28990
|
-
const items = useMemo23(() => buildSlashCommandItems({ query: "", messages }), [messages]);
|
|
28991
|
-
const listRef = useRef33(null);
|
|
28992
|
-
useEffect36(() => {
|
|
28993
|
-
const handleKeyDown2 = (event) => {
|
|
28994
|
-
if (event.key === "Escape") {
|
|
28995
|
-
event.preventDefault();
|
|
28996
|
-
onClose();
|
|
28997
|
-
return;
|
|
28998
|
-
}
|
|
28999
|
-
const handled = listRef.current?.onKeyDown({ event }) ?? false;
|
|
29000
|
-
if (handled) {
|
|
29001
|
-
event.preventDefault();
|
|
29002
|
-
}
|
|
29003
|
-
};
|
|
29004
|
-
document.addEventListener("keydown", handleKeyDown2);
|
|
29005
|
-
return () => document.removeEventListener("keydown", handleKeyDown2);
|
|
29006
|
-
}, [onClose]);
|
|
29007
|
-
return /* @__PURE__ */ jsx86(
|
|
29008
|
-
SlashCommandList,
|
|
29009
|
-
{
|
|
29010
|
-
ref: listRef,
|
|
29011
|
-
items,
|
|
29012
|
-
messages,
|
|
29013
|
-
command: (item) => {
|
|
29014
|
-
item.command({ editor });
|
|
29015
|
-
onClose();
|
|
29016
|
-
}
|
|
29017
|
-
}
|
|
29018
|
-
);
|
|
29019
|
-
};
|
|
29020
|
-
var FloatingMenuContent = ({ editor }) => {
|
|
29021
|
-
const t = useSmartTranslations("UEditor");
|
|
29022
|
-
const [showCommands, setShowCommands] = useState48(false);
|
|
29023
|
-
if (showCommands) {
|
|
29024
|
-
return /* @__PURE__ */ jsx86(FloatingSlashCommandMenu, { editor, onClose: () => setShowCommands(false) });
|
|
29025
|
-
}
|
|
29026
|
-
return /* @__PURE__ */ jsxs72(
|
|
29027
|
-
"button",
|
|
29028
|
-
{
|
|
29029
|
-
type: "button",
|
|
29030
|
-
onClick: () => setShowCommands(true),
|
|
29031
|
-
className: "flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-accent transition-all group",
|
|
29032
|
-
children: [
|
|
29033
|
-
/* @__PURE__ */ jsx86(Plus3, { className: "w-4 h-4 text-muted-foreground group-hover:text-foreground" }),
|
|
29034
|
-
/* @__PURE__ */ jsx86("span", { className: "text-sm text-muted-foreground group-hover:text-foreground", children: t("floatingMenu.addBlock") })
|
|
29035
|
-
]
|
|
29036
|
-
}
|
|
29037
|
-
);
|
|
29038
|
-
};
|
|
29039
29038
|
function applyTableCellBackground(editor, color) {
|
|
29040
29039
|
const value = color || null;
|
|
29041
29040
|
const { state, view } = editor;
|
|
@@ -29662,54 +29661,6 @@ var CustomBubbleMenu = ({
|
|
|
29662
29661
|
document.body
|
|
29663
29662
|
);
|
|
29664
29663
|
};
|
|
29665
|
-
var CustomFloatingMenu = ({ editor }) => {
|
|
29666
|
-
const FLOATING_MENU_OFFSET = 16;
|
|
29667
|
-
const [isVisible, setIsVisible] = useState48(false);
|
|
29668
|
-
const [position, setPosition] = useState48({ top: 0, left: 0 });
|
|
29669
|
-
useEffect36(() => {
|
|
29670
|
-
const updatePosition = () => {
|
|
29671
|
-
const { state, view } = editor;
|
|
29672
|
-
const { $from, empty } = state.selection;
|
|
29673
|
-
const isEmptyTextBlock = $from.parent.isTextblock && $from.parent.type.name === "paragraph" && $from.parent.textContent === "" && empty;
|
|
29674
|
-
if (!isEmptyTextBlock || !view.hasFocus()) {
|
|
29675
|
-
setIsVisible(false);
|
|
29676
|
-
return;
|
|
29677
|
-
}
|
|
29678
|
-
const coords = view.coordsAtPos($from.pos);
|
|
29679
|
-
setPosition({ top: coords.top - FLOATING_MENU_OFFSET, left: coords.left });
|
|
29680
|
-
setIsVisible(true);
|
|
29681
|
-
};
|
|
29682
|
-
const handleBlur = () => setIsVisible(false);
|
|
29683
|
-
editor.on("selectionUpdate", updatePosition);
|
|
29684
|
-
editor.on("focus", updatePosition);
|
|
29685
|
-
editor.on("blur", handleBlur);
|
|
29686
|
-
editor.on("update", updatePosition);
|
|
29687
|
-
return () => {
|
|
29688
|
-
editor.off("selectionUpdate", updatePosition);
|
|
29689
|
-
editor.off("focus", updatePosition);
|
|
29690
|
-
editor.off("blur", handleBlur);
|
|
29691
|
-
editor.off("update", updatePosition);
|
|
29692
|
-
};
|
|
29693
|
-
}, [editor]);
|
|
29694
|
-
if (!isVisible) return null;
|
|
29695
|
-
return createPortal8(
|
|
29696
|
-
/* @__PURE__ */ jsx86(
|
|
29697
|
-
"div",
|
|
29698
|
-
{
|
|
29699
|
-
"data-popover": true,
|
|
29700
|
-
className: "fixed z-99999 rounded-2xl border border-border/50 bg-card text-card-foreground shadow-lg backdrop-blur-sm overflow-hidden animate-in fade-in-0 slide-in-from-bottom-2",
|
|
29701
|
-
style: {
|
|
29702
|
-
top: `${position.top}px`,
|
|
29703
|
-
left: `${position.left}px`,
|
|
29704
|
-
transform: "translate(-50%, -100%)"
|
|
29705
|
-
},
|
|
29706
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
29707
|
-
children: /* @__PURE__ */ jsx86(FloatingMenuContent, { editor })
|
|
29708
|
-
}
|
|
29709
|
-
),
|
|
29710
|
-
document.body
|
|
29711
|
-
);
|
|
29712
|
-
};
|
|
29713
29664
|
|
|
29714
29665
|
// src/components/UEditor/CharacterCount.tsx
|
|
29715
29666
|
import { jsxs as jsxs73 } from "react/jsx-runtime";
|
|
@@ -34495,8 +34446,8 @@ function TableAddRails({
|
|
|
34495
34446
|
const visibleTableHeight = Math.min(layout.tableHeight, layout.viewportHeight);
|
|
34496
34447
|
const columnRailTop = layout.tableTop;
|
|
34497
34448
|
const columnRailLeft = layout.tableLeft + visibleTableWidth + ADD_COLUMN_RAIL_GAP;
|
|
34498
|
-
const rowRailTop = layout.
|
|
34499
|
-
const rowRailLeft = layout.tableLeft;
|
|
34449
|
+
const rowRailTop = layout.wrapperTop + layout.wrapperHeight + ADD_ROW_RAIL_GAP;
|
|
34450
|
+
const rowRailLeft = Math.max(layout.tableLeft, layout.wrapperLeft);
|
|
34500
34451
|
const showColumnRail = controlsVisible || addColumnVisible;
|
|
34501
34452
|
const showRowRail = controlsVisible || addRowVisible;
|
|
34502
34453
|
return /* @__PURE__ */ jsxs75(Fragment32, { children: [
|
|
@@ -35126,6 +35077,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
35126
35077
|
const proseMirror = editor.view.dom;
|
|
35127
35078
|
const surface = containerRef.current;
|
|
35128
35079
|
if (!surface) return void 0;
|
|
35080
|
+
const scrollListenerOptions = { passive: true, capture: true };
|
|
35129
35081
|
const handleMouseOver = (event) => {
|
|
35130
35082
|
if (dragStateRef.current) return;
|
|
35131
35083
|
const cell = getCellFromTarget(event.target);
|
|
@@ -35151,7 +35103,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
35151
35103
|
proseMirror.addEventListener("focusin", handleFocusIn);
|
|
35152
35104
|
surface.addEventListener("mouseover", handleSurfaceMouseMove);
|
|
35153
35105
|
surface.addEventListener("mousemove", handleSurfaceMouseMove);
|
|
35154
|
-
surface.addEventListener("scroll", refreshCurrentLayout,
|
|
35106
|
+
surface.addEventListener("scroll", refreshCurrentLayout, scrollListenerOptions);
|
|
35155
35107
|
surface.addEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, refreshCurrentLayout);
|
|
35156
35108
|
window.addEventListener("resize", refreshCurrentLayout);
|
|
35157
35109
|
editor.on("selectionUpdate", syncFromSelection);
|
|
@@ -35165,7 +35117,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
35165
35117
|
proseMirror.removeEventListener("focusin", handleFocusIn);
|
|
35166
35118
|
surface.removeEventListener("mouseover", handleSurfaceMouseMove);
|
|
35167
35119
|
surface.removeEventListener("mousemove", handleSurfaceMouseMove);
|
|
35168
|
-
surface.removeEventListener("scroll", refreshCurrentLayout);
|
|
35120
|
+
surface.removeEventListener("scroll", refreshCurrentLayout, scrollListenerOptions);
|
|
35169
35121
|
surface.removeEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, refreshCurrentLayout);
|
|
35170
35122
|
window.removeEventListener("resize", refreshCurrentLayout);
|
|
35171
35123
|
editor.off("selectionUpdate", syncFromSelection);
|
|
@@ -35635,7 +35587,7 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
|
|
|
35635
35587
|
"[&_.column-resize-handle]:top-[-1px]",
|
|
35636
35588
|
"[&_.column-resize-handle]:bottom-[-1px]",
|
|
35637
35589
|
"[&_.column-resize-handle]:right-[-5px]",
|
|
35638
|
-
"[&_.column-resize-handle]:z-
|
|
35590
|
+
"[&_.column-resize-handle]:z-30",
|
|
35639
35591
|
"[&_.column-resize-handle]:w-2.5",
|
|
35640
35592
|
"[&_.column-resize-handle]:bg-transparent",
|
|
35641
35593
|
"[&_.column-resize-handle]:rounded-none",
|
|
@@ -35889,26 +35841,31 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
35889
35841
|
const activeTableCellRef = useRef35(null);
|
|
35890
35842
|
const suppressActiveCellHighlightRef = useRef35(false);
|
|
35891
35843
|
const tableLayoutSyncFrameRef = useRef35(null);
|
|
35844
|
+
const getProseMirrorElement = React80.useCallback(() => {
|
|
35845
|
+
return editorContentRef.current?.querySelector(".ProseMirror");
|
|
35846
|
+
}, []);
|
|
35892
35847
|
const setEditorResizeCursor = React80.useCallback((cursor) => {
|
|
35893
|
-
const proseMirror =
|
|
35848
|
+
const proseMirror = getProseMirrorElement();
|
|
35894
35849
|
if (proseMirror) {
|
|
35895
35850
|
proseMirror.style.cursor = cursor;
|
|
35896
35851
|
}
|
|
35897
|
-
}, []);
|
|
35852
|
+
}, [getProseMirrorElement]);
|
|
35898
35853
|
const hideColumnGuide = React80.useCallback(() => {
|
|
35899
35854
|
editorContentRef.current?.classList.remove("resize-cursor");
|
|
35855
|
+
getProseMirrorElement()?.classList.remove("resize-cursor");
|
|
35900
35856
|
const guide = tableColumnGuideRef.current;
|
|
35901
35857
|
if (guide) {
|
|
35902
35858
|
guide.style.opacity = "0";
|
|
35903
35859
|
}
|
|
35904
|
-
}, []);
|
|
35860
|
+
}, [getProseMirrorElement]);
|
|
35905
35861
|
const hideRowGuide = React80.useCallback(() => {
|
|
35906
35862
|
editorContentRef.current?.classList.remove("resize-row-cursor");
|
|
35863
|
+
getProseMirrorElement()?.classList.remove("resize-row-cursor");
|
|
35907
35864
|
const guide = tableRowGuideRef.current;
|
|
35908
35865
|
if (guide) {
|
|
35909
35866
|
guide.style.opacity = "0";
|
|
35910
35867
|
}
|
|
35911
|
-
}, []);
|
|
35868
|
+
}, [getProseMirrorElement]);
|
|
35912
35869
|
const clearAllTableResizeHover = React80.useCallback(() => {
|
|
35913
35870
|
setEditorResizeCursor("");
|
|
35914
35871
|
hideColumnGuide();
|
|
@@ -35938,7 +35895,10 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
35938
35895
|
});
|
|
35939
35896
|
}, [updateActiveCellHighlight]);
|
|
35940
35897
|
const setActiveTableCell = React80.useCallback((cell) => {
|
|
35941
|
-
if (activeTableCellRef.current === cell)
|
|
35898
|
+
if (activeTableCellRef.current === cell) {
|
|
35899
|
+
updateActiveCellHighlight(cell);
|
|
35900
|
+
return;
|
|
35901
|
+
}
|
|
35942
35902
|
activeTableCellRef.current = cell;
|
|
35943
35903
|
updateActiveCellHighlight(activeTableCellRef.current);
|
|
35944
35904
|
}, [updateActiveCellHighlight]);
|
|
@@ -35963,8 +35923,9 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
35963
35923
|
guide.style.height = `${metrics.height}px`;
|
|
35964
35924
|
guide.style.opacity = "1";
|
|
35965
35925
|
surface.classList.add("resize-cursor");
|
|
35926
|
+
getProseMirrorElement()?.classList.add("resize-cursor");
|
|
35966
35927
|
setEditorResizeCursor("col-resize");
|
|
35967
|
-
}, [setEditorResizeCursor]);
|
|
35928
|
+
}, [getProseMirrorElement, setEditorResizeCursor]);
|
|
35968
35929
|
const showRowGuide = React80.useCallback((table, row, cell) => {
|
|
35969
35930
|
const surface = editorContentRef.current;
|
|
35970
35931
|
const guide = tableRowGuideRef.current;
|
|
@@ -35976,8 +35937,9 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
35976
35937
|
guide.style.height = `${ROW_RESIZE_LINE_THICKNESS}px`;
|
|
35977
35938
|
guide.style.opacity = "1";
|
|
35978
35939
|
surface.classList.add("resize-row-cursor");
|
|
35940
|
+
getProseMirrorElement()?.classList.add("resize-row-cursor");
|
|
35979
35941
|
setEditorResizeCursor("row-resize");
|
|
35980
|
-
}, [setEditorResizeCursor]);
|
|
35942
|
+
}, [getProseMirrorElement, setEditorResizeCursor]);
|
|
35981
35943
|
const {
|
|
35982
35944
|
beginResize,
|
|
35983
35945
|
cancelResize,
|
|
@@ -35996,19 +35958,32 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
35996
35958
|
});
|
|
35997
35959
|
const syncActiveTableCellFromSelection = React80.useCallback(() => {
|
|
35998
35960
|
if (!editor) return;
|
|
35961
|
+
if (!editor.isFocused) {
|
|
35962
|
+
clearActiveTableCell();
|
|
35963
|
+
return;
|
|
35964
|
+
}
|
|
35999
35965
|
setActiveTableCell(getSelectionTableCell(editor.view));
|
|
36000
|
-
}, [editor, setActiveTableCell]);
|
|
35966
|
+
}, [clearActiveTableCell, editor, setActiveTableCell]);
|
|
36001
35967
|
useEffect37(() => {
|
|
36002
35968
|
if (!editor || !editable) return void 0;
|
|
36003
35969
|
const proseMirror = editor.view.dom;
|
|
36004
35970
|
const surface = editorContentRef.current;
|
|
36005
35971
|
let selectionSyncTimeoutId = 0;
|
|
35972
|
+
const scrollListenerOptions = { passive: true, capture: true };
|
|
36006
35973
|
const scheduleActiveCellSync = (fallbackCell = null) => {
|
|
36007
35974
|
requestAnimationFrame(() => {
|
|
35975
|
+
if (!editor.isFocused) {
|
|
35976
|
+
clearActiveTableCell();
|
|
35977
|
+
return;
|
|
35978
|
+
}
|
|
36008
35979
|
setActiveTableCell(getSelectionTableCell(editor.view) ?? fallbackCell);
|
|
36009
35980
|
});
|
|
36010
35981
|
window.clearTimeout(selectionSyncTimeoutId);
|
|
36011
35982
|
selectionSyncTimeoutId = window.setTimeout(() => {
|
|
35983
|
+
if (!editor.isFocused) {
|
|
35984
|
+
clearActiveTableCell();
|
|
35985
|
+
return;
|
|
35986
|
+
}
|
|
36012
35987
|
setActiveTableCell(getSelectionTableCell(editor.view) ?? fallbackCell);
|
|
36013
35988
|
}, 0);
|
|
36014
35989
|
};
|
|
@@ -36112,13 +36087,15 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
36112
36087
|
proseMirror.addEventListener("keyup", handleSelectionChange);
|
|
36113
36088
|
proseMirror.addEventListener("focusin", handleSelectionChange);
|
|
36114
36089
|
document.addEventListener("selectionchange", handleSelectionChange);
|
|
36115
|
-
surface?.addEventListener("scroll", handleActiveCellLayoutChange,
|
|
36090
|
+
surface?.addEventListener("scroll", handleActiveCellLayoutChange, scrollListenerOptions);
|
|
36116
36091
|
window.addEventListener("resize", handleActiveCellLayoutChange);
|
|
36117
36092
|
document.addEventListener("pointermove", handlePointerMove);
|
|
36118
36093
|
document.addEventListener("pointerup", handlePointerUp);
|
|
36119
36094
|
window.addEventListener("blur", handleWindowBlur);
|
|
36120
36095
|
editor.on("selectionUpdate", syncActiveTableCellFromSelection);
|
|
36121
36096
|
editor.on("focus", syncActiveTableCellFromSelection);
|
|
36097
|
+
editor.on("blur", clearActiveTableCell);
|
|
36098
|
+
editor.on("update", scheduleTableLayoutSync);
|
|
36122
36099
|
syncActiveTableCellFromSelection();
|
|
36123
36100
|
return () => {
|
|
36124
36101
|
proseMirror.removeEventListener("mousemove", handleEditorMouseMove);
|
|
@@ -36129,13 +36106,15 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
36129
36106
|
proseMirror.removeEventListener("keyup", handleSelectionChange);
|
|
36130
36107
|
proseMirror.removeEventListener("focusin", handleSelectionChange);
|
|
36131
36108
|
document.removeEventListener("selectionchange", handleSelectionChange);
|
|
36132
|
-
surface?.removeEventListener("scroll", handleActiveCellLayoutChange);
|
|
36109
|
+
surface?.removeEventListener("scroll", handleActiveCellLayoutChange, scrollListenerOptions);
|
|
36133
36110
|
window.removeEventListener("resize", handleActiveCellLayoutChange);
|
|
36134
36111
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
36135
36112
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
36136
36113
|
window.removeEventListener("blur", handleWindowBlur);
|
|
36137
36114
|
editor.off("selectionUpdate", syncActiveTableCellFromSelection);
|
|
36138
36115
|
editor.off("focus", syncActiveTableCellFromSelection);
|
|
36116
|
+
editor.off("blur", clearActiveTableCell);
|
|
36117
|
+
editor.off("update", scheduleTableLayoutSync);
|
|
36139
36118
|
window.clearTimeout(selectionSyncTimeoutId);
|
|
36140
36119
|
if (tableLayoutSyncFrameRef.current !== null) {
|
|
36141
36120
|
window.cancelAnimationFrame(tableLayoutSyncFrameRef.current);
|
|
@@ -36148,7 +36127,7 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
36148
36127
|
clearHoveredTableCell();
|
|
36149
36128
|
clearAllTableResizeHover();
|
|
36150
36129
|
};
|
|
36151
|
-
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editable, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
36130
|
+
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editable, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, scheduleTableLayoutSync, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
36152
36131
|
return {
|
|
36153
36132
|
editorContentRef,
|
|
36154
36133
|
tableColumnGuideRef,
|
|
@@ -36167,6 +36146,7 @@ import {
|
|
|
36167
36146
|
AlignRight as AlignRight4,
|
|
36168
36147
|
Bold as BoldIcon3,
|
|
36169
36148
|
Code as CodeIcon3,
|
|
36149
|
+
Eye as Eye3,
|
|
36170
36150
|
FileCode as FileCode4,
|
|
36171
36151
|
Heading1 as Heading1Icon2,
|
|
36172
36152
|
Heading2 as Heading2Icon2,
|
|
@@ -36677,6 +36657,13 @@ var MenuBar = ({
|
|
|
36677
36657
|
const openPreviewDialog = () => {
|
|
36678
36658
|
setShowPreviewDialog(true);
|
|
36679
36659
|
};
|
|
36660
|
+
const handlePreview = () => {
|
|
36661
|
+
if (onPreview) {
|
|
36662
|
+
onPreview();
|
|
36663
|
+
return;
|
|
36664
|
+
}
|
|
36665
|
+
openPreviewDialog();
|
|
36666
|
+
};
|
|
36680
36667
|
const applySourceHtml = () => {
|
|
36681
36668
|
editor.chain().focus().setContent(sourceHtml).run();
|
|
36682
36669
|
setShowSourceDialog(false);
|
|
@@ -36788,7 +36775,7 @@ var MenuBar = ({
|
|
|
36788
36775
|
{ label: t("menubar.edit"), items: buildEditMenuItems(t, editor), open: void 0, onOpenChange: void 0 },
|
|
36789
36776
|
{
|
|
36790
36777
|
label: t("menubar.view"),
|
|
36791
|
-
items: buildViewMenuItems(t, { containerRef, onSourceCode, openSourceDialog, onPreview, openPreviewDialog }),
|
|
36778
|
+
items: buildViewMenuItems(t, { containerRef, onSourceCode, openSourceDialog, onPreview: handlePreview, openPreviewDialog }),
|
|
36792
36779
|
open: void 0,
|
|
36793
36780
|
onOpenChange: void 0
|
|
36794
36781
|
},
|
|
@@ -36825,17 +36812,33 @@ var MenuBar = ({
|
|
|
36825
36812
|
onChange: (e) => handleImageFiles(e.target.files)
|
|
36826
36813
|
}
|
|
36827
36814
|
),
|
|
36828
|
-
/* @__PURE__ */
|
|
36829
|
-
|
|
36830
|
-
|
|
36831
|
-
|
|
36832
|
-
|
|
36833
|
-
|
|
36834
|
-
|
|
36835
|
-
|
|
36836
|
-
|
|
36837
|
-
|
|
36838
|
-
|
|
36815
|
+
/* @__PURE__ */ jsxs77("div", { className: "flex items-center gap-0.5 border-b border-border/35 bg-muted/20 px-1.5 py-0.5", children: [
|
|
36816
|
+
menus.map(({ label, items, open, onOpenChange }) => /* @__PURE__ */ jsx92(
|
|
36817
|
+
DropdownMenu,
|
|
36818
|
+
{
|
|
36819
|
+
trigger: /* @__PURE__ */ jsx92(MenuBarTrigger, { children: label }),
|
|
36820
|
+
placement: "bottom-start",
|
|
36821
|
+
isOpen: open,
|
|
36822
|
+
onOpenChange,
|
|
36823
|
+
children: renderMenuItems(items)
|
|
36824
|
+
},
|
|
36825
|
+
label
|
|
36826
|
+
)),
|
|
36827
|
+
/* @__PURE__ */ jsx92(
|
|
36828
|
+
"button",
|
|
36829
|
+
{
|
|
36830
|
+
type: "button",
|
|
36831
|
+
onClick: handlePreview,
|
|
36832
|
+
"aria-label": t("menubar.preview"),
|
|
36833
|
+
title: t("menubar.preview"),
|
|
36834
|
+
className: cn(
|
|
36835
|
+
"ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors",
|
|
36836
|
+
"hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1"
|
|
36837
|
+
),
|
|
36838
|
+
children: /* @__PURE__ */ jsx92(Eye3, { className: "h-4 w-4", "aria-hidden": "true" })
|
|
36839
|
+
}
|
|
36840
|
+
)
|
|
36841
|
+
] }),
|
|
36839
36842
|
/* @__PURE__ */ jsx92(
|
|
36840
36843
|
Modal_default,
|
|
36841
36844
|
{
|
|
@@ -36889,8 +36892,14 @@ var MenuBar = ({
|
|
|
36889
36892
|
"div",
|
|
36890
36893
|
{
|
|
36891
36894
|
"data-testid": "preview-content",
|
|
36892
|
-
className:
|
|
36893
|
-
|
|
36895
|
+
className: "max-h-[70vh] overflow-y-auto overscroll-contain pr-2",
|
|
36896
|
+
children: /* @__PURE__ */ jsx92(
|
|
36897
|
+
"div",
|
|
36898
|
+
{
|
|
36899
|
+
className: UEDITOR_PROSEMIRROR_CLASS_NAME,
|
|
36900
|
+
dangerouslySetInnerHTML: { __html: editor.getHTML() }
|
|
36901
|
+
}
|
|
36902
|
+
)
|
|
36894
36903
|
}
|
|
36895
36904
|
)
|
|
36896
36905
|
}
|
|
@@ -36918,7 +36927,6 @@ var UEditor = React82.forwardRef(({
|
|
|
36918
36927
|
autofocus = false,
|
|
36919
36928
|
showToolbar = true,
|
|
36920
36929
|
showBubbleMenu = true,
|
|
36921
|
-
showFloatingMenu = false,
|
|
36922
36930
|
showCharacterCount = true,
|
|
36923
36931
|
maxCharacters,
|
|
36924
36932
|
minHeight = "200px",
|
|
@@ -37120,7 +37128,6 @@ var UEditor = React82.forwardRef(({
|
|
|
37120
37128
|
lineHeights
|
|
37121
37129
|
}
|
|
37122
37130
|
),
|
|
37123
|
-
editable && showFloatingMenu && /* @__PURE__ */ jsx93(CustomFloatingMenu, { editor }),
|
|
37124
37131
|
/* @__PURE__ */ jsxs78(
|
|
37125
37132
|
"div",
|
|
37126
37133
|
{
|
|
@@ -37153,7 +37160,7 @@ var UEditor = React82.forwardRef(({
|
|
|
37153
37160
|
ref: activeTableCellHighlightRef,
|
|
37154
37161
|
"aria-hidden": "true",
|
|
37155
37162
|
"data-ueditor-active-cell-highlight": "",
|
|
37156
|
-
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border-2 border-primary bg-primary/10
|
|
37163
|
+
className: "pointer-events-none hidden absolute z-20 rounded-[2px] border-2 border-primary bg-primary/10"
|
|
37157
37164
|
}
|
|
37158
37165
|
),
|
|
37159
37166
|
editable && /* @__PURE__ */ jsx93(TableControls, { editor, containerRef: editorContentRef }),
|