@underverse-ui/underverse 2.0.32 → 2.0.34
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/{EmojiPicker-ISJ6RXYG.js → EmojiPicker-6H52Q4YE.js} +4 -4
- package/dist/{chunk-ZP7F4ZD7.js → chunk-6FAHXNDQ.js} +5 -1
- package/dist/chunk-6FAHXNDQ.js.map +1 -0
- package/dist/{chunk-C4KZOMP3.js → chunk-JYAEYUGM.js} +36 -101
- package/dist/chunk-JYAEYUGM.js.map +1 -0
- package/dist/{chunk-S4UHFRL3.js → chunk-L73HBI6E.js} +3 -3
- package/dist/{chunk-4TXHZS3S.js → chunk-OTPC2OTQ.js} +2 -2
- package/dist/{chunk-RSSSQS2A.js → chunk-UHUKUI5S.js} +3 -3
- package/dist/{chunk-5W63IHIN.js → chunk-W3QTP2DM.js} +2 -2
- package/dist/index.cjs +68 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -6
- package/dist/{menu-bar-GDDGHNNJ.js → menu-bar-HZBBRX42.js} +4 -4
- package/dist/ueditor.cjs +83 -148
- package/dist/ueditor.cjs.map +1 -1
- package/dist/ueditor.d.cts +1 -1
- package/dist/ueditor.d.ts +1 -1
- package/dist/ueditor.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-C4KZOMP3.js.map +0 -1
- package/dist/chunk-ZP7F4ZD7.js.map +0 -1
- /package/dist/{EmojiPicker-ISJ6RXYG.js.map → EmojiPicker-6H52Q4YE.js.map} +0 -0
- /package/dist/{chunk-S4UHFRL3.js.map → chunk-L73HBI6E.js.map} +0 -0
- /package/dist/{chunk-4TXHZS3S.js.map → chunk-OTPC2OTQ.js.map} +0 -0
- /package/dist/{chunk-RSSSQS2A.js.map → chunk-UHUKUI5S.js.map} +0 -0
- /package/dist/{chunk-5W63IHIN.js.map → chunk-W3QTP2DM.js.map} +0 -0
- /package/dist/{menu-bar-GDDGHNNJ.js.map → menu-bar-HZBBRX42.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EmojiGridButton
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W3QTP2DM.js";
|
|
4
4
|
import {
|
|
5
5
|
EMOJI_LIST
|
|
6
6
|
} from "./chunk-4TYW5K4J.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
cn,
|
|
10
10
|
formControlOutlineClass,
|
|
11
11
|
useSmartTranslations
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6FAHXNDQ.js";
|
|
13
13
|
|
|
14
14
|
// src/components/EmojiPicker.tsx
|
|
15
15
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -205,4 +205,4 @@ export {
|
|
|
205
205
|
EmojiPicker,
|
|
206
206
|
EmojiPicker_default
|
|
207
207
|
};
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-L73HBI6E.js.map
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
setRefValue,
|
|
12
12
|
useSmartTranslations,
|
|
13
13
|
useUEditorPortalContainerGetter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-6FAHXNDQ.js";
|
|
15
15
|
|
|
16
16
|
// src/contexts/UnderverseConfigContext.tsx
|
|
17
17
|
import * as React from "react";
|
|
@@ -5827,4 +5827,4 @@ export {
|
|
|
5827
5827
|
EditorToolbar,
|
|
5828
5828
|
UEDITOR_PROSEMIRROR_CLASS_NAME
|
|
5829
5829
|
};
|
|
5830
|
-
//# sourceMappingURL=chunk-
|
|
5830
|
+
//# sourceMappingURL=chunk-OTPC2OTQ.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPanelBorderRadiusClass,
|
|
3
3
|
useUnderverseUIConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OTPC2OTQ.js";
|
|
5
5
|
import {
|
|
6
6
|
cn,
|
|
7
7
|
useGlobalI18n
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6FAHXNDQ.js";
|
|
9
9
|
|
|
10
10
|
// src/components/Modal.tsx
|
|
11
11
|
import * as React from "react";
|
|
@@ -253,4 +253,4 @@ var Modal_default = Modal;
|
|
|
253
253
|
export {
|
|
254
254
|
Modal_default
|
|
255
255
|
};
|
|
256
|
-
//# sourceMappingURL=chunk-
|
|
256
|
+
//# sourceMappingURL=chunk-UHUKUI5S.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cn
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6FAHXNDQ.js";
|
|
4
4
|
|
|
5
5
|
// src/components/emoji-ui.tsx
|
|
6
6
|
import React from "react";
|
|
@@ -79,4 +79,4 @@ export {
|
|
|
79
79
|
getEmojiImageUrl,
|
|
80
80
|
EmojiGridButton
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-W3QTP2DM.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -484,6 +484,7 @@ var init_en = __esm({
|
|
|
484
484
|
dragColumn: "Drag Column",
|
|
485
485
|
resizeBoth: "Resize Table",
|
|
486
486
|
resizeCtrlHint: "Drag freely. Hold Ctrl to lock to one axis; hold Ctrl+Shift to preserve proportions",
|
|
487
|
+
fitToEditorWidth: "Fit to Editor Width",
|
|
487
488
|
alignLeft: "Align Table Left",
|
|
488
489
|
alignCenter: "Align Table Center",
|
|
489
490
|
alignRight: "Align Table Right",
|
|
@@ -950,6 +951,7 @@ var init_vi = __esm({
|
|
|
950
951
|
dragColumn: "K\xE9o c\u1ED9t",
|
|
951
952
|
resizeBoth: "\u0110\u1ED5i k\xEDch th\u01B0\u1EDBc b\u1EA3ng",
|
|
952
953
|
resizeCtrlHint: "K\xE9o t\u1EF1 do; gi\u1EEF Ctrl \u0111\u1EC3 kh\xF3a m\u1ED9t chi\u1EC1u, ho\u1EB7c Ctrl+Shift \u0111\u1EC3 gi\u1EEF nguy\xEAn t\u1EF7 l\u1EC7",
|
|
954
|
+
fitToEditorWidth: "V\u1EEBa chi\u1EC1u r\u1ED9ng tr\xECnh so\u1EA1n th\u1EA3o",
|
|
953
955
|
alignLeft: "C\u0103n b\u1EA3ng tr\xE1i",
|
|
954
956
|
alignCenter: "C\u0103n b\u1EA3ng gi\u1EEFa",
|
|
955
957
|
alignRight: "C\u0103n b\u1EA3ng ph\u1EA3i",
|
|
@@ -1416,6 +1418,7 @@ var init_ko = __esm({
|
|
|
1416
1418
|
dragColumn: "\uC5F4 \uB4DC\uB798\uADF8",
|
|
1417
1419
|
resizeBoth: "\uD45C \uD06C\uAE30 \uC870\uC808",
|
|
1418
1420
|
resizeCtrlHint: "\uC790\uC720\uB86D\uAC8C \uB4DC\uB798\uADF8\uD569\uB2C8\uB2E4. Ctrl \uD0A4\uB97C \uB204\uB974\uBA74 \uD55C \uCD95\uC73C\uB85C \uACE0\uC815\uB418\uACE0, Ctrl+Shift \uD0A4\uB97C \uB204\uB974\uBA74 \uBE44\uC728\uC774 \uC720\uC9C0\uB429\uB2C8\uB2E4",
|
|
1421
|
+
fitToEditorWidth: "\uD3B8\uC9D1\uAE30 \uB108\uBE44\uC5D0 \uB9DE\uCD94\uAE30",
|
|
1419
1422
|
alignLeft: "\uD45C \uC67C\uCABD \uC815\uB82C",
|
|
1420
1423
|
alignCenter: "\uD45C \uAC00\uC6B4\uB370 \uC815\uB82C",
|
|
1421
1424
|
alignRight: "\uD45C \uC624\uB978\uCABD \uC815\uB82C",
|
|
@@ -1882,6 +1885,7 @@ var init_ja = __esm({
|
|
|
1882
1885
|
dragColumn: "\u5217\u3092\u30C9\u30E9\u30C3\u30B0",
|
|
1883
1886
|
resizeBoth: "\u8868\u306E\u30B5\u30A4\u30BA\u3092\u5909\u66F4",
|
|
1884
1887
|
resizeCtrlHint: "\u81EA\u7531\u306B\u30C9\u30E9\u30C3\u30B0\u3067\u304D\u307E\u3059\u3002Ctrl\u30AD\u30FC\u30671\u65B9\u5411\u306B\u56FA\u5B9A\u3057\u3001Ctrl+Shift\u30AD\u30FC\u3067\u7E26\u6A2A\u6BD4\u3092\u7DAD\u6301\u3057\u307E\u3059",
|
|
1888
|
+
fitToEditorWidth: "\u30A8\u30C7\u30A3\u30BF\u30FC\u306E\u5E45\u306B\u5408\u308F\u305B\u308B",
|
|
1885
1889
|
alignLeft: "\u8868\u3092\u5DE6\u5BC4\u305B",
|
|
1886
1890
|
alignCenter: "\u8868\u3092\u4E2D\u592E\u63C3\u3048",
|
|
1887
1891
|
alignRight: "\u8868\u3092\u53F3\u5BC4\u305B",
|
|
@@ -10144,7 +10148,7 @@ function renderMenuItems(items) {
|
|
|
10144
10148
|
case "sub":
|
|
10145
10149
|
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(DropdownMenuSub, { label: item.label, icon: item.icon, disabled: item.disabled, children: renderMenuItems(item.items) }, i);
|
|
10146
10150
|
case "custom":
|
|
10147
|
-
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
10151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_react84.default.Fragment, { children: item.render() }, item.key);
|
|
10148
10152
|
}
|
|
10149
10153
|
});
|
|
10150
10154
|
}
|
|
@@ -10527,12 +10531,12 @@ function buildTableMenuItems(t, editor, onInsertTable) {
|
|
|
10527
10531
|
}
|
|
10528
10532
|
];
|
|
10529
10533
|
}
|
|
10530
|
-
var
|
|
10534
|
+
var import_react84, import_lucide_react59, import_jsx_runtime104, MenuBarTrigger, MenuBar;
|
|
10531
10535
|
var init_menu_bar = __esm({
|
|
10532
10536
|
"src/components/UEditor/menu-bar.tsx"() {
|
|
10533
10537
|
"use strict";
|
|
10534
10538
|
"use client";
|
|
10535
|
-
|
|
10539
|
+
import_react84 = __toESM(require("react"), 1);
|
|
10536
10540
|
import_lucide_react59 = require("lucide-react");
|
|
10537
10541
|
init_useSmartTranslations();
|
|
10538
10542
|
init_cn();
|
|
@@ -10549,7 +10553,7 @@ var init_menu_bar = __esm({
|
|
|
10549
10553
|
init_async_insertion_position();
|
|
10550
10554
|
init_image_file_upload();
|
|
10551
10555
|
import_jsx_runtime104 = require("react/jsx-runtime");
|
|
10552
|
-
MenuBarTrigger =
|
|
10556
|
+
MenuBarTrigger = import_react84.default.forwardRef(
|
|
10553
10557
|
({ children, className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
10554
10558
|
"button",
|
|
10555
10559
|
{
|
|
@@ -10586,25 +10590,25 @@ var init_menu_bar = __esm({
|
|
|
10586
10590
|
const t = useSmartTranslations("UEditor");
|
|
10587
10591
|
useSharedEditorUiRenderState(editor);
|
|
10588
10592
|
const getPortalContainer = useUEditorPortalContainerGetter();
|
|
10589
|
-
const fileInputRef = (0,
|
|
10590
|
-
const sourceTextareaRef = (0,
|
|
10591
|
-
const [showImageInput, setShowImageInput] = (0,
|
|
10592
|
-
const [showLinkInput, setShowLinkInput] = (0,
|
|
10593
|
-
const [isUploadingImage, setIsUploadingImage] = (0,
|
|
10594
|
-
const [imageUploadError, setImageUploadError] = (0,
|
|
10595
|
-
const [openMenuKey, setOpenMenuKey] = (0,
|
|
10596
|
-
const [showSourceDialog, setShowSourceDialog] = (0,
|
|
10597
|
-
const [sourceHtml, setSourceHtml] = (0,
|
|
10598
|
-
const [sourceError, setSourceError] = (0,
|
|
10599
|
-
const sourceErrorId =
|
|
10600
|
-
const [showPreviewDialog, setShowPreviewDialog] = (0,
|
|
10601
|
-
const [previewHtml, setPreviewHtml] = (0,
|
|
10593
|
+
const fileInputRef = (0, import_react84.useRef)(null);
|
|
10594
|
+
const sourceTextareaRef = (0, import_react84.useRef)(null);
|
|
10595
|
+
const [showImageInput, setShowImageInput] = (0, import_react84.useState)(false);
|
|
10596
|
+
const [showLinkInput, setShowLinkInput] = (0, import_react84.useState)(false);
|
|
10597
|
+
const [isUploadingImage, setIsUploadingImage] = (0, import_react84.useState)(false);
|
|
10598
|
+
const [imageUploadError, setImageUploadError] = (0, import_react84.useState)(null);
|
|
10599
|
+
const [openMenuKey, setOpenMenuKey] = (0, import_react84.useState)(null);
|
|
10600
|
+
const [showSourceDialog, setShowSourceDialog] = (0, import_react84.useState)(false);
|
|
10601
|
+
const [sourceHtml, setSourceHtml] = (0, import_react84.useState)("");
|
|
10602
|
+
const [sourceError, setSourceError] = (0, import_react84.useState)("");
|
|
10603
|
+
const sourceErrorId = import_react84.default.useId();
|
|
10604
|
+
const [showPreviewDialog, setShowPreviewDialog] = (0, import_react84.useState)(false);
|
|
10605
|
+
const [previewHtml, setPreviewHtml] = (0, import_react84.useState)("");
|
|
10602
10606
|
const modalPortalContainer = resolveUEditorPortalContainer(
|
|
10603
10607
|
getPortalContainer,
|
|
10604
10608
|
void 0,
|
|
10605
10609
|
editor.view.dom.ownerDocument
|
|
10606
10610
|
);
|
|
10607
|
-
(0,
|
|
10611
|
+
(0, import_react84.useEffect)(() => {
|
|
10608
10612
|
if (!showPreviewDialog) return;
|
|
10609
10613
|
const updatePreview = () => {
|
|
10610
10614
|
if (!editor.isDestroyed) {
|
|
@@ -35294,9 +35298,9 @@ init_UnderverseConfigContext();
|
|
|
35294
35298
|
init_useSmartTranslations();
|
|
35295
35299
|
|
|
35296
35300
|
// src/components/UEditor/UEditor.tsx
|
|
35297
|
-
var
|
|
35301
|
+
var import_react85 = __toESM(require("react"), 1);
|
|
35298
35302
|
init_useSmartTranslations();
|
|
35299
|
-
var
|
|
35303
|
+
var import_react86 = require("@tiptap/react");
|
|
35300
35304
|
init_cn();
|
|
35301
35305
|
|
|
35302
35306
|
// src/components/UEditor/extensions.ts
|
|
@@ -47240,7 +47244,9 @@ function TableAddRails({
|
|
|
47240
47244
|
),
|
|
47241
47245
|
style: {
|
|
47242
47246
|
top: columnRailTop,
|
|
47243
|
-
|
|
47247
|
+
// An invisible rail must not sit outside the table: even at
|
|
47248
|
+
// opacity 0 its box would otherwise create a horizontal scrollbar.
|
|
47249
|
+
left: showColumnRail ? columnRailLeft : Math.max(visibleBounds.left, visibleBounds.right - BUTTON_SHORT_SIZE),
|
|
47244
47250
|
width: BUTTON_SHORT_SIZE,
|
|
47245
47251
|
height: BUTTON_LONG_SIZE,
|
|
47246
47252
|
opacity: showColumnRail ? 1 : 0,
|
|
@@ -47526,18 +47532,16 @@ var import_lucide_react56 = require("lucide-react");
|
|
|
47526
47532
|
init_cn();
|
|
47527
47533
|
init_table_width_model();
|
|
47528
47534
|
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
47529
|
-
var HANDLE_BASE_CLASS = cn(
|
|
47530
|
-
"pointer-events-auto absolute z-10 inline-flex touch-none items-center justify-center rounded-md",
|
|
47531
|
-
"bg-background/95 text-primary shadow-sm backdrop-blur-sm",
|
|
47532
|
-
"transition-[color,background-color,box-shadow,transform] duration-150",
|
|
47533
|
-
"hover:bg-primary hover:text-primary-foreground hover:shadow-md active:scale-95",
|
|
47534
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
47535
|
-
);
|
|
47536
47535
|
var EDGE_HANDLE_CLASS = cn(
|
|
47537
47536
|
"pointer-events-auto absolute top-0 z-10 h-full w-2 touch-none cursor-col-resize bg-transparent p-0",
|
|
47538
47537
|
"border-transparent transition-colors duration-150 hover:border-primary",
|
|
47539
47538
|
"focus-visible:border-primary focus-visible:outline-none"
|
|
47540
47539
|
);
|
|
47540
|
+
var CORNER_HANDLE_CLASS = cn(
|
|
47541
|
+
"pointer-events-auto absolute z-10 inline-flex touch-none items-center justify-center p-0",
|
|
47542
|
+
"text-primary/70 transition-[color,transform] duration-150 hover:text-primary active:scale-95",
|
|
47543
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
|
47544
|
+
);
|
|
47541
47545
|
function formatTableResizeDimensionLabel({
|
|
47542
47546
|
width,
|
|
47543
47547
|
height,
|
|
@@ -47617,9 +47621,9 @@ function TableResizeHandles({
|
|
|
47617
47621
|
title: `${resizeBothLabel}. ${ctrlHint}`,
|
|
47618
47622
|
"data-table-resize-handle": "both",
|
|
47619
47623
|
className: cn(
|
|
47620
|
-
|
|
47621
|
-
"bottom-[-28px] right-
|
|
47622
|
-
active && "
|
|
47624
|
+
CORNER_HANDLE_CLASS,
|
|
47625
|
+
"bottom-[-28px] right-0 h-6 w-6 cursor-nwse-resize",
|
|
47626
|
+
active && "text-primary"
|
|
47623
47627
|
),
|
|
47624
47628
|
onDoubleClick: onFitWidth,
|
|
47625
47629
|
onClick: (event) => {
|
|
@@ -48220,8 +48224,8 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
48220
48224
|
updateTableResizePreview(pendingDimensions);
|
|
48221
48225
|
setDocumentCursor(editorDocument, edge === "both" ? "nwse-resize" : "ew-resize");
|
|
48222
48226
|
}, [editor, editorDocument, updateTableResizePreview]);
|
|
48223
|
-
const fitTableToEditorWidth = import_react78.default.useCallback((
|
|
48224
|
-
if (
|
|
48227
|
+
const fitTableToEditorWidth = import_react78.default.useCallback(() => {
|
|
48228
|
+
if (dragStateRef.current) return;
|
|
48225
48229
|
const activeLayout = layoutRef.current;
|
|
48226
48230
|
if (!activeLayout) return;
|
|
48227
48231
|
const snapshot = createTableSizeSnapshot(
|
|
@@ -48232,8 +48236,6 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
48232
48236
|
activeLayout.viewportWidth
|
|
48233
48237
|
);
|
|
48234
48238
|
if (!snapshot) return;
|
|
48235
|
-
event.preventDefault();
|
|
48236
|
-
event.stopPropagation();
|
|
48237
48239
|
const didResize = applyTableSize(editor, snapshot, {
|
|
48238
48240
|
width: Math.round(activeLayout.viewportWidth),
|
|
48239
48241
|
height: snapshot.startHeight,
|
|
@@ -48621,6 +48623,11 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
48621
48623
|
icon: import_lucide_react57.Paintbrush,
|
|
48622
48624
|
onClick: openCellInspector
|
|
48623
48625
|
}] : [],
|
|
48626
|
+
{
|
|
48627
|
+
label: t("tableMenu.fitToEditorWidth"),
|
|
48628
|
+
icon: import_lucide_react57.Minimize2,
|
|
48629
|
+
onClick: fitTableToEditorWidth
|
|
48630
|
+
},
|
|
48624
48631
|
{
|
|
48625
48632
|
label: t("tableMenu.alignLeft"),
|
|
48626
48633
|
icon: import_lucide_react57.AlignLeft,
|
|
@@ -48685,7 +48692,7 @@ function TableControls({ editor, containerRef, showCellInspector = true }) {
|
|
|
48685
48692
|
destructive: true
|
|
48686
48693
|
}
|
|
48687
48694
|
];
|
|
48688
|
-
}, [editor, layout, openCellInspector, runAtActiveCell, showCellInspector, t]);
|
|
48695
|
+
}, [editor, fitTableToEditorWidth, layout, openCellInspector, runAtActiveCell, showCellInspector, t]);
|
|
48689
48696
|
const getRowHandleMenuItems = import_react78.default.useCallback((rowHandle) => [
|
|
48690
48697
|
{
|
|
48691
48698
|
label: t("tableMenu.addRowBefore"),
|
|
@@ -50096,80 +50103,12 @@ function useUEditorOutput({
|
|
|
50096
50103
|
|
|
50097
50104
|
// src/components/UEditor/UEditor.tsx
|
|
50098
50105
|
init_portal_context();
|
|
50099
|
-
|
|
50100
|
-
// src/components/UEditor/use-wide-table-layout.ts
|
|
50101
|
-
var import_react84 = __toESM(require("react"), 1);
|
|
50102
|
-
init_table_dom_utils();
|
|
50103
|
-
function useWideTableLayout(editor, enabled, widthBoundaryRef, editorShellRef, editorSurfaceRef) {
|
|
50104
|
-
import_react84.default.useLayoutEffect(() => {
|
|
50105
|
-
const boundary = widthBoundaryRef.current;
|
|
50106
|
-
const shell = editorShellRef.current;
|
|
50107
|
-
const surface = editorSurfaceRef.current;
|
|
50108
|
-
if (!editor || !boundary || !shell || !surface) return;
|
|
50109
|
-
const editorDocument = editor.view.dom.ownerDocument;
|
|
50110
|
-
const editorWindow = editorDocument.defaultView;
|
|
50111
|
-
if (!editorWindow) return;
|
|
50112
|
-
const editorDom = editor.view.dom;
|
|
50113
|
-
let frame = 0;
|
|
50114
|
-
const resetWidths = () => {
|
|
50115
|
-
shell.style.removeProperty("width");
|
|
50116
|
-
editorDom.style.removeProperty("width");
|
|
50117
|
-
};
|
|
50118
|
-
const sync = () => {
|
|
50119
|
-
frame = 0;
|
|
50120
|
-
resetWidths();
|
|
50121
|
-
if (!enabled || editor.isDestroyed) return;
|
|
50122
|
-
const boundaryWidth = boundary.getBoundingClientRect().width || boundary.clientWidth;
|
|
50123
|
-
const surfaceWidth = surface.getBoundingClientRect().width || surface.clientWidth;
|
|
50124
|
-
if (boundaryWidth <= 0 || surfaceWidth <= 0) return;
|
|
50125
|
-
editorDom.style.width = `${surfaceWidth}px`;
|
|
50126
|
-
const shellRect = shell.getBoundingClientRect();
|
|
50127
|
-
let requiredWidth = boundaryWidth;
|
|
50128
|
-
editorDom.querySelectorAll("table").forEach((table) => {
|
|
50129
|
-
const tableRect = table.getBoundingClientRect();
|
|
50130
|
-
if (tableRect.width > 0) {
|
|
50131
|
-
requiredWidth = Math.max(requiredWidth, tableRect.right - shellRect.left + 32);
|
|
50132
|
-
return;
|
|
50133
|
-
}
|
|
50134
|
-
const widthBp = Number(table.getAttribute("data-table-width-bp"));
|
|
50135
|
-
if (Number.isFinite(widthBp) && widthBp > 1e4) {
|
|
50136
|
-
requiredWidth = Math.max(requiredWidth, surfaceWidth * widthBp / 1e4 + 32);
|
|
50137
|
-
}
|
|
50138
|
-
});
|
|
50139
|
-
if (requiredWidth <= boundaryWidth + 1) {
|
|
50140
|
-
editorDom.style.removeProperty("width");
|
|
50141
|
-
return;
|
|
50142
|
-
}
|
|
50143
|
-
shell.style.width = `${Math.ceil(requiredWidth)}px`;
|
|
50144
|
-
};
|
|
50145
|
-
const schedule = () => {
|
|
50146
|
-
if (frame) editorWindow.cancelAnimationFrame(frame);
|
|
50147
|
-
frame = editorWindow.requestAnimationFrame(sync);
|
|
50148
|
-
};
|
|
50149
|
-
const resizeObserver = typeof editorWindow.ResizeObserver === "function" ? new editorWindow.ResizeObserver(schedule) : null;
|
|
50150
|
-
resizeObserver?.observe(boundary);
|
|
50151
|
-
editor.on("transaction", schedule);
|
|
50152
|
-
surface.addEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, schedule);
|
|
50153
|
-
editorWindow.addEventListener("resize", schedule);
|
|
50154
|
-
schedule();
|
|
50155
|
-
return () => {
|
|
50156
|
-
if (frame) editorWindow.cancelAnimationFrame(frame);
|
|
50157
|
-
resizeObserver?.disconnect();
|
|
50158
|
-
editor.off("transaction", schedule);
|
|
50159
|
-
surface.removeEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, schedule);
|
|
50160
|
-
editorWindow.removeEventListener("resize", schedule);
|
|
50161
|
-
resetWidths();
|
|
50162
|
-
};
|
|
50163
|
-
}, [editor, editorShellRef, editorSurfaceRef, enabled, widthBoundaryRef]);
|
|
50164
|
-
}
|
|
50165
|
-
|
|
50166
|
-
// src/components/UEditor/UEditor.tsx
|
|
50167
50106
|
var import_jsx_runtime105 = require("react/jsx-runtime");
|
|
50168
|
-
var LazyMenuBar =
|
|
50107
|
+
var LazyMenuBar = import_react85.default.lazy(async () => {
|
|
50169
50108
|
const { MenuBar: MenuBar2 } = await Promise.resolve().then(() => (init_menu_bar(), menu_bar_exports));
|
|
50170
50109
|
return { default: MenuBar2 };
|
|
50171
50110
|
});
|
|
50172
|
-
var UEditor =
|
|
50111
|
+
var UEditor = import_react85.default.forwardRef(({
|
|
50173
50112
|
getPortalContainer,
|
|
50174
50113
|
content = "",
|
|
50175
50114
|
onChange,
|
|
@@ -50221,18 +50160,16 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50221
50160
|
}, ref) => {
|
|
50222
50161
|
const t = useSmartTranslations("UEditor");
|
|
50223
50162
|
const effectivePlaceholder = placeholder ?? t("placeholder");
|
|
50224
|
-
const inFlightPrepareRef = (0,
|
|
50225
|
-
const lastAppliedContentRef = (0,
|
|
50226
|
-
const scheduledFormulaRecalculateRef = (0,
|
|
50227
|
-
const pendingFormulaTextRecalculateRef = (0,
|
|
50228
|
-
const editorInstanceRef = (0,
|
|
50229
|
-
const formulaRangePickRef = (0,
|
|
50230
|
-
const formulaRangeSurfaceRef = (0,
|
|
50231
|
-
const [formulaRangeHighlight, setFormulaRangeHighlight] =
|
|
50232
|
-
const [isMenuBarVisible, setIsMenuBarVisible] =
|
|
50233
|
-
|
|
50234
|
-
const editorShellRef = (0, import_react86.useRef)(null);
|
|
50235
|
-
(0, import_react86.useEffect)(() => {
|
|
50163
|
+
const inFlightPrepareRef = (0, import_react85.useRef)(null);
|
|
50164
|
+
const lastAppliedContentRef = (0, import_react85.useRef)(content ?? "");
|
|
50165
|
+
const scheduledFormulaRecalculateRef = (0, import_react85.useRef)(false);
|
|
50166
|
+
const pendingFormulaTextRecalculateRef = (0, import_react85.useRef)(false);
|
|
50167
|
+
const editorInstanceRef = (0, import_react85.useRef)(null);
|
|
50168
|
+
const formulaRangePickRef = (0, import_react85.useRef)(null);
|
|
50169
|
+
const formulaRangeSurfaceRef = (0, import_react85.useRef)(null);
|
|
50170
|
+
const [formulaRangeHighlight, setFormulaRangeHighlight] = import_react85.default.useState(null);
|
|
50171
|
+
const [isMenuBarVisible, setIsMenuBarVisible] = import_react85.default.useState(showMenuBar);
|
|
50172
|
+
(0, import_react85.useEffect)(() => {
|
|
50236
50173
|
setIsMenuBarVisible(showMenuBar);
|
|
50237
50174
|
}, [showMenuBar]);
|
|
50238
50175
|
const { flushOutputUpdates, scheduleOutputUpdate } = useUEditorOutput({
|
|
@@ -50241,7 +50178,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50241
50178
|
onJsonChange,
|
|
50242
50179
|
outputDebounceMs
|
|
50243
50180
|
});
|
|
50244
|
-
const scheduleFormulaRecalculate =
|
|
50181
|
+
const scheduleFormulaRecalculate = import_react85.default.useCallback((editor2, options) => {
|
|
50245
50182
|
if (editor2.isDestroyed || scheduledFormulaRecalculateRef.current) return;
|
|
50246
50183
|
if (!options?.force && isEditingTableFormulaText(editor2)) return;
|
|
50247
50184
|
scheduledFormulaRecalculateRef.current = true;
|
|
@@ -50252,7 +50189,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50252
50189
|
}
|
|
50253
50190
|
});
|
|
50254
50191
|
}, []);
|
|
50255
|
-
const resolvedUploadFile = (0,
|
|
50192
|
+
const resolvedUploadFile = (0, import_react85.useMemo)(() => {
|
|
50256
50193
|
if (uploadFile) return uploadFile;
|
|
50257
50194
|
if (uploadFileForSave) {
|
|
50258
50195
|
return async (file) => {
|
|
@@ -50262,7 +50199,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50262
50199
|
}
|
|
50263
50200
|
return uploadImage;
|
|
50264
50201
|
}, [uploadFile, uploadFileForSave, uploadImage]);
|
|
50265
|
-
const extensions = (0,
|
|
50202
|
+
const extensions = (0, import_react85.useMemo)(
|
|
50266
50203
|
() => [
|
|
50267
50204
|
...buildUEditorExtensions({
|
|
50268
50205
|
getPortalContainer,
|
|
@@ -50283,11 +50220,11 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50283
50220
|
],
|
|
50284
50221
|
[getPortalContainer, effectivePlaceholder, t, maxCharacters, uploadImage, resolvedUploadFile, imageInsertMode, maxImageFileSize, allowedImageMimeTypes, fallbackToDataUrl, onImageUploadError, editable, fetchMetadata, extraExtensions]
|
|
50285
50222
|
);
|
|
50286
|
-
const syncFormulaRangeHighlight =
|
|
50223
|
+
const syncFormulaRangeHighlight = import_react85.default.useCallback((pickState) => {
|
|
50287
50224
|
const container = formulaRangeSurfaceRef.current;
|
|
50288
50225
|
setFormulaRangeHighlight(container && pickState ? getFormulaRangePickHighlight(container, pickState) : null);
|
|
50289
50226
|
}, []);
|
|
50290
|
-
const editor = (0,
|
|
50227
|
+
const editor = (0, import_react86.useEditor)({
|
|
50291
50228
|
immediatelyRender: false,
|
|
50292
50229
|
extensions,
|
|
50293
50230
|
content,
|
|
@@ -50408,7 +50345,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50408
50345
|
queueMicrotask(flushOutputUpdates);
|
|
50409
50346
|
}
|
|
50410
50347
|
});
|
|
50411
|
-
(0,
|
|
50348
|
+
(0, import_react85.useEffect)(() => {
|
|
50412
50349
|
editorInstanceRef.current = editor;
|
|
50413
50350
|
return () => {
|
|
50414
50351
|
if (editorInstanceRef.current === editor) editorInstanceRef.current = null;
|
|
@@ -50424,8 +50361,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50424
50361
|
apply: t("tableMenu.apply"),
|
|
50425
50362
|
cancel: t("imageInput.cancelBtn")
|
|
50426
50363
|
});
|
|
50427
|
-
|
|
50428
|
-
(0, import_react86.useImperativeHandle)(
|
|
50364
|
+
(0, import_react85.useImperativeHandle)(
|
|
50429
50365
|
ref,
|
|
50430
50366
|
() => ({
|
|
50431
50367
|
editor,
|
|
@@ -50454,7 +50390,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50454
50390
|
}),
|
|
50455
50391
|
[content, editor, uploadImageForSave, uploadFileForSave, uploadImageConcurrency]
|
|
50456
50392
|
);
|
|
50457
|
-
(0,
|
|
50393
|
+
(0, import_react85.useEffect)(() => {
|
|
50458
50394
|
if (!editor) return;
|
|
50459
50395
|
queueMicrotask(() => {
|
|
50460
50396
|
if (!editor.isDestroyed) {
|
|
@@ -50462,7 +50398,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50462
50398
|
}
|
|
50463
50399
|
});
|
|
50464
50400
|
}, [editor]);
|
|
50465
|
-
(0,
|
|
50401
|
+
(0, import_react85.useEffect)(() => {
|
|
50466
50402
|
if (!editor) return;
|
|
50467
50403
|
const nextContent = content ?? "";
|
|
50468
50404
|
if (lastAppliedContentRef.current === nextContent) return;
|
|
@@ -50492,10 +50428,9 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50492
50428
|
}
|
|
50493
50429
|
) });
|
|
50494
50430
|
}
|
|
50495
|
-
return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(UEditorPortalProvider, { getPortalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", {
|
|
50431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(UEditorPortalProvider, { getPortalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { "data-ueditor-width-boundary": "", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
|
|
50496
50432
|
"div",
|
|
50497
50433
|
{
|
|
50498
|
-
ref: editorShellRef,
|
|
50499
50434
|
className: cn(
|
|
50500
50435
|
"group relative flex flex-col text-card-foreground",
|
|
50501
50436
|
editable ? [
|
|
@@ -50510,7 +50445,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50510
50445
|
),
|
|
50511
50446
|
children: [
|
|
50512
50447
|
editable && (showMenuBar || showToolbar || showBubbleMenu) ? /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(EditorUiRenderStateProvider, { editor, children: [
|
|
50513
|
-
isMenuBarVisible && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
|
|
50448
|
+
isMenuBarVisible && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_react85.default.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
|
|
50514
50449
|
LazyMenuBar,
|
|
50515
50450
|
{
|
|
50516
50451
|
editor,
|
|
@@ -50568,7 +50503,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50568
50503
|
formulaRangeSurfaceRef.current = node;
|
|
50569
50504
|
},
|
|
50570
50505
|
className: cn(
|
|
50571
|
-
"relative flex-1 overflow-y-auto",
|
|
50506
|
+
"relative flex-1 overflow-x-auto overflow-y-auto [scrollbar-width:thin] [scrollbar-color:hsl(var(--border))_transparent]",
|
|
50572
50507
|
expandWideTables && "[&_.tableWrapper]:!overflow-visible [&_.tableWrapper]:!pb-0"
|
|
50573
50508
|
),
|
|
50574
50509
|
style: {
|
|
@@ -50637,7 +50572,7 @@ var UEditor = import_react86.default.forwardRef(({
|
|
|
50637
50572
|
}
|
|
50638
50573
|
),
|
|
50639
50574
|
/* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
|
|
50640
|
-
|
|
50575
|
+
import_react86.EditorContent,
|
|
50641
50576
|
{
|
|
50642
50577
|
editor,
|
|
50643
50578
|
className: "min-h-full"
|