@underverse-ui/underverse 2.0.33 → 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/dist/index.cjs CHANGED
@@ -10148,7 +10148,7 @@ function renderMenuItems(items) {
10148
10148
  case "sub":
10149
10149
  return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(DropdownMenuSub, { label: item.label, icon: item.icon, disabled: item.disabled, children: renderMenuItems(item.items) }, i);
10150
10150
  case "custom":
10151
- return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_react85.default.Fragment, { children: item.render() }, item.key);
10151
+ return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_react84.default.Fragment, { children: item.render() }, item.key);
10152
10152
  }
10153
10153
  });
10154
10154
  }
@@ -10531,12 +10531,12 @@ function buildTableMenuItems(t, editor, onInsertTable) {
10531
10531
  }
10532
10532
  ];
10533
10533
  }
10534
- var import_react85, import_lucide_react59, import_jsx_runtime104, MenuBarTrigger, MenuBar;
10534
+ var import_react84, import_lucide_react59, import_jsx_runtime104, MenuBarTrigger, MenuBar;
10535
10535
  var init_menu_bar = __esm({
10536
10536
  "src/components/UEditor/menu-bar.tsx"() {
10537
10537
  "use strict";
10538
10538
  "use client";
10539
- import_react85 = __toESM(require("react"), 1);
10539
+ import_react84 = __toESM(require("react"), 1);
10540
10540
  import_lucide_react59 = require("lucide-react");
10541
10541
  init_useSmartTranslations();
10542
10542
  init_cn();
@@ -10553,7 +10553,7 @@ var init_menu_bar = __esm({
10553
10553
  init_async_insertion_position();
10554
10554
  init_image_file_upload();
10555
10555
  import_jsx_runtime104 = require("react/jsx-runtime");
10556
- MenuBarTrigger = import_react85.default.forwardRef(
10556
+ MenuBarTrigger = import_react84.default.forwardRef(
10557
10557
  ({ children, className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
10558
10558
  "button",
10559
10559
  {
@@ -10590,25 +10590,25 @@ var init_menu_bar = __esm({
10590
10590
  const t = useSmartTranslations("UEditor");
10591
10591
  useSharedEditorUiRenderState(editor);
10592
10592
  const getPortalContainer = useUEditorPortalContainerGetter();
10593
- const fileInputRef = (0, import_react85.useRef)(null);
10594
- const sourceTextareaRef = (0, import_react85.useRef)(null);
10595
- const [showImageInput, setShowImageInput] = (0, import_react85.useState)(false);
10596
- const [showLinkInput, setShowLinkInput] = (0, import_react85.useState)(false);
10597
- const [isUploadingImage, setIsUploadingImage] = (0, import_react85.useState)(false);
10598
- const [imageUploadError, setImageUploadError] = (0, import_react85.useState)(null);
10599
- const [openMenuKey, setOpenMenuKey] = (0, import_react85.useState)(null);
10600
- const [showSourceDialog, setShowSourceDialog] = (0, import_react85.useState)(false);
10601
- const [sourceHtml, setSourceHtml] = (0, import_react85.useState)("");
10602
- const [sourceError, setSourceError] = (0, import_react85.useState)("");
10603
- const sourceErrorId = import_react85.default.useId();
10604
- const [showPreviewDialog, setShowPreviewDialog] = (0, import_react85.useState)(false);
10605
- const [previewHtml, setPreviewHtml] = (0, import_react85.useState)("");
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)("");
10606
10606
  const modalPortalContainer = resolveUEditorPortalContainer(
10607
10607
  getPortalContainer,
10608
10608
  void 0,
10609
10609
  editor.view.dom.ownerDocument
10610
10610
  );
10611
- (0, import_react85.useEffect)(() => {
10611
+ (0, import_react84.useEffect)(() => {
10612
10612
  if (!showPreviewDialog) return;
10613
10613
  const updatePreview = () => {
10614
10614
  if (!editor.isDestroyed) {
@@ -35298,9 +35298,9 @@ init_UnderverseConfigContext();
35298
35298
  init_useSmartTranslations();
35299
35299
 
35300
35300
  // src/components/UEditor/UEditor.tsx
35301
- var import_react86 = __toESM(require("react"), 1);
35301
+ var import_react85 = __toESM(require("react"), 1);
35302
35302
  init_useSmartTranslations();
35303
- var import_react87 = require("@tiptap/react");
35303
+ var import_react86 = require("@tiptap/react");
35304
35304
  init_cn();
35305
35305
 
35306
35306
  // src/components/UEditor/extensions.ts
@@ -47244,7 +47244,9 @@ function TableAddRails({
47244
47244
  ),
47245
47245
  style: {
47246
47246
  top: columnRailTop,
47247
- left: columnRailLeft,
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),
47248
47250
  width: BUTTON_SHORT_SIZE,
47249
47251
  height: BUTTON_LONG_SIZE,
47250
47252
  opacity: showColumnRail ? 1 : 0,
@@ -47530,18 +47532,16 @@ var import_lucide_react56 = require("lucide-react");
47530
47532
  init_cn();
47531
47533
  init_table_width_model();
47532
47534
  var import_jsx_runtime101 = require("react/jsx-runtime");
47533
- var HANDLE_BASE_CLASS = cn(
47534
- "pointer-events-auto absolute z-10 inline-flex touch-none items-center justify-center rounded-md",
47535
- "bg-background/95 text-primary shadow-sm backdrop-blur-sm",
47536
- "transition-[color,background-color,box-shadow,transform] duration-150",
47537
- "hover:bg-primary hover:text-primary-foreground hover:shadow-md active:scale-95",
47538
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
47539
- );
47540
47535
  var EDGE_HANDLE_CLASS = cn(
47541
47536
  "pointer-events-auto absolute top-0 z-10 h-full w-2 touch-none cursor-col-resize bg-transparent p-0",
47542
47537
  "border-transparent transition-colors duration-150 hover:border-primary",
47543
47538
  "focus-visible:border-primary focus-visible:outline-none"
47544
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
+ );
47545
47545
  function formatTableResizeDimensionLabel({
47546
47546
  width,
47547
47547
  height,
@@ -47621,9 +47621,9 @@ function TableResizeHandles({
47621
47621
  title: `${resizeBothLabel}. ${ctrlHint}`,
47622
47622
  "data-table-resize-handle": "both",
47623
47623
  className: cn(
47624
- HANDLE_BASE_CLASS,
47625
- "bottom-[-28px] right-[-30px] h-6 w-6 cursor-nwse-resize",
47626
- active && "bg-primary text-primary-foreground shadow-md"
47624
+ CORNER_HANDLE_CLASS,
47625
+ "bottom-[-28px] right-0 h-6 w-6 cursor-nwse-resize",
47626
+ active && "text-primary"
47627
47627
  ),
47628
47628
  onDoubleClick: onFitWidth,
47629
47629
  onClick: (event) => {
@@ -50103,80 +50103,12 @@ function useUEditorOutput({
50103
50103
 
50104
50104
  // src/components/UEditor/UEditor.tsx
50105
50105
  init_portal_context();
50106
-
50107
- // src/components/UEditor/use-wide-table-layout.ts
50108
- var import_react84 = __toESM(require("react"), 1);
50109
- init_table_dom_utils();
50110
- function useWideTableLayout(editor, enabled, widthBoundaryRef, editorShellRef, editorSurfaceRef) {
50111
- import_react84.default.useLayoutEffect(() => {
50112
- const boundary = widthBoundaryRef.current;
50113
- const shell = editorShellRef.current;
50114
- const surface = editorSurfaceRef.current;
50115
- if (!editor || !boundary || !shell || !surface) return;
50116
- const editorDocument = editor.view.dom.ownerDocument;
50117
- const editorWindow = editorDocument.defaultView;
50118
- if (!editorWindow) return;
50119
- const editorDom = editor.view.dom;
50120
- let frame = 0;
50121
- const resetWidths = () => {
50122
- shell.style.removeProperty("width");
50123
- editorDom.style.removeProperty("width");
50124
- };
50125
- const sync = () => {
50126
- frame = 0;
50127
- resetWidths();
50128
- if (!enabled || editor.isDestroyed) return;
50129
- const boundaryWidth = boundary.getBoundingClientRect().width || boundary.clientWidth;
50130
- const surfaceWidth = surface.getBoundingClientRect().width || surface.clientWidth;
50131
- if (boundaryWidth <= 0 || surfaceWidth <= 0) return;
50132
- editorDom.style.width = `${surfaceWidth}px`;
50133
- const shellRect = shell.getBoundingClientRect();
50134
- let requiredWidth = boundaryWidth;
50135
- editorDom.querySelectorAll("table").forEach((table) => {
50136
- const tableRect = table.getBoundingClientRect();
50137
- if (tableRect.width > 0) {
50138
- requiredWidth = Math.max(requiredWidth, tableRect.right - shellRect.left + 32);
50139
- return;
50140
- }
50141
- const widthBp = Number(table.getAttribute("data-table-width-bp"));
50142
- if (Number.isFinite(widthBp) && widthBp > 1e4) {
50143
- requiredWidth = Math.max(requiredWidth, surfaceWidth * widthBp / 1e4 + 32);
50144
- }
50145
- });
50146
- if (requiredWidth <= boundaryWidth + 1) {
50147
- editorDom.style.removeProperty("width");
50148
- return;
50149
- }
50150
- shell.style.width = `${Math.ceil(requiredWidth)}px`;
50151
- };
50152
- const schedule = () => {
50153
- if (frame) editorWindow.cancelAnimationFrame(frame);
50154
- frame = editorWindow.requestAnimationFrame(sync);
50155
- };
50156
- const resizeObserver = typeof editorWindow.ResizeObserver === "function" ? new editorWindow.ResizeObserver(schedule) : null;
50157
- resizeObserver?.observe(boundary);
50158
- editor.on("transaction", schedule);
50159
- surface.addEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, schedule);
50160
- editorWindow.addEventListener("resize", schedule);
50161
- schedule();
50162
- return () => {
50163
- if (frame) editorWindow.cancelAnimationFrame(frame);
50164
- resizeObserver?.disconnect();
50165
- editor.off("transaction", schedule);
50166
- surface.removeEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, schedule);
50167
- editorWindow.removeEventListener("resize", schedule);
50168
- resetWidths();
50169
- };
50170
- }, [editor, editorShellRef, editorSurfaceRef, enabled, widthBoundaryRef]);
50171
- }
50172
-
50173
- // src/components/UEditor/UEditor.tsx
50174
50106
  var import_jsx_runtime105 = require("react/jsx-runtime");
50175
- var LazyMenuBar = import_react86.default.lazy(async () => {
50107
+ var LazyMenuBar = import_react85.default.lazy(async () => {
50176
50108
  const { MenuBar: MenuBar2 } = await Promise.resolve().then(() => (init_menu_bar(), menu_bar_exports));
50177
50109
  return { default: MenuBar2 };
50178
50110
  });
50179
- var UEditor = import_react86.default.forwardRef(({
50111
+ var UEditor = import_react85.default.forwardRef(({
50180
50112
  getPortalContainer,
50181
50113
  content = "",
50182
50114
  onChange,
@@ -50228,18 +50160,16 @@ var UEditor = import_react86.default.forwardRef(({
50228
50160
  }, ref) => {
50229
50161
  const t = useSmartTranslations("UEditor");
50230
50162
  const effectivePlaceholder = placeholder ?? t("placeholder");
50231
- const inFlightPrepareRef = (0, import_react86.useRef)(null);
50232
- const lastAppliedContentRef = (0, import_react86.useRef)(content ?? "");
50233
- const scheduledFormulaRecalculateRef = (0, import_react86.useRef)(false);
50234
- const pendingFormulaTextRecalculateRef = (0, import_react86.useRef)(false);
50235
- const editorInstanceRef = (0, import_react86.useRef)(null);
50236
- const formulaRangePickRef = (0, import_react86.useRef)(null);
50237
- const formulaRangeSurfaceRef = (0, import_react86.useRef)(null);
50238
- const [formulaRangeHighlight, setFormulaRangeHighlight] = import_react86.default.useState(null);
50239
- const [isMenuBarVisible, setIsMenuBarVisible] = import_react86.default.useState(showMenuBar);
50240
- const widthBoundaryRef = (0, import_react86.useRef)(null);
50241
- const editorShellRef = (0, import_react86.useRef)(null);
50242
- (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)(() => {
50243
50173
  setIsMenuBarVisible(showMenuBar);
50244
50174
  }, [showMenuBar]);
50245
50175
  const { flushOutputUpdates, scheduleOutputUpdate } = useUEditorOutput({
@@ -50248,7 +50178,7 @@ var UEditor = import_react86.default.forwardRef(({
50248
50178
  onJsonChange,
50249
50179
  outputDebounceMs
50250
50180
  });
50251
- const scheduleFormulaRecalculate = import_react86.default.useCallback((editor2, options) => {
50181
+ const scheduleFormulaRecalculate = import_react85.default.useCallback((editor2, options) => {
50252
50182
  if (editor2.isDestroyed || scheduledFormulaRecalculateRef.current) return;
50253
50183
  if (!options?.force && isEditingTableFormulaText(editor2)) return;
50254
50184
  scheduledFormulaRecalculateRef.current = true;
@@ -50259,7 +50189,7 @@ var UEditor = import_react86.default.forwardRef(({
50259
50189
  }
50260
50190
  });
50261
50191
  }, []);
50262
- const resolvedUploadFile = (0, import_react86.useMemo)(() => {
50192
+ const resolvedUploadFile = (0, import_react85.useMemo)(() => {
50263
50193
  if (uploadFile) return uploadFile;
50264
50194
  if (uploadFileForSave) {
50265
50195
  return async (file) => {
@@ -50269,7 +50199,7 @@ var UEditor = import_react86.default.forwardRef(({
50269
50199
  }
50270
50200
  return uploadImage;
50271
50201
  }, [uploadFile, uploadFileForSave, uploadImage]);
50272
- const extensions = (0, import_react86.useMemo)(
50202
+ const extensions = (0, import_react85.useMemo)(
50273
50203
  () => [
50274
50204
  ...buildUEditorExtensions({
50275
50205
  getPortalContainer,
@@ -50290,11 +50220,11 @@ var UEditor = import_react86.default.forwardRef(({
50290
50220
  ],
50291
50221
  [getPortalContainer, effectivePlaceholder, t, maxCharacters, uploadImage, resolvedUploadFile, imageInsertMode, maxImageFileSize, allowedImageMimeTypes, fallbackToDataUrl, onImageUploadError, editable, fetchMetadata, extraExtensions]
50292
50222
  );
50293
- const syncFormulaRangeHighlight = import_react86.default.useCallback((pickState) => {
50223
+ const syncFormulaRangeHighlight = import_react85.default.useCallback((pickState) => {
50294
50224
  const container = formulaRangeSurfaceRef.current;
50295
50225
  setFormulaRangeHighlight(container && pickState ? getFormulaRangePickHighlight(container, pickState) : null);
50296
50226
  }, []);
50297
- const editor = (0, import_react87.useEditor)({
50227
+ const editor = (0, import_react86.useEditor)({
50298
50228
  immediatelyRender: false,
50299
50229
  extensions,
50300
50230
  content,
@@ -50415,7 +50345,7 @@ var UEditor = import_react86.default.forwardRef(({
50415
50345
  queueMicrotask(flushOutputUpdates);
50416
50346
  }
50417
50347
  });
50418
- (0, import_react86.useEffect)(() => {
50348
+ (0, import_react85.useEffect)(() => {
50419
50349
  editorInstanceRef.current = editor;
50420
50350
  return () => {
50421
50351
  if (editorInstanceRef.current === editor) editorInstanceRef.current = null;
@@ -50431,8 +50361,7 @@ var UEditor = import_react86.default.forwardRef(({
50431
50361
  apply: t("tableMenu.apply"),
50432
50362
  cancel: t("imageInput.cancelBtn")
50433
50363
  });
50434
- useWideTableLayout(editor, expandWideTables, widthBoundaryRef, editorShellRef, editorContentRef);
50435
- (0, import_react86.useImperativeHandle)(
50364
+ (0, import_react85.useImperativeHandle)(
50436
50365
  ref,
50437
50366
  () => ({
50438
50367
  editor,
@@ -50461,7 +50390,7 @@ var UEditor = import_react86.default.forwardRef(({
50461
50390
  }),
50462
50391
  [content, editor, uploadImageForSave, uploadFileForSave, uploadImageConcurrency]
50463
50392
  );
50464
- (0, import_react86.useEffect)(() => {
50393
+ (0, import_react85.useEffect)(() => {
50465
50394
  if (!editor) return;
50466
50395
  queueMicrotask(() => {
50467
50396
  if (!editor.isDestroyed) {
@@ -50469,7 +50398,7 @@ var UEditor = import_react86.default.forwardRef(({
50469
50398
  }
50470
50399
  });
50471
50400
  }, [editor]);
50472
- (0, import_react86.useEffect)(() => {
50401
+ (0, import_react85.useEffect)(() => {
50473
50402
  if (!editor) return;
50474
50403
  const nextContent = content ?? "";
50475
50404
  if (lastAppliedContentRef.current === nextContent) return;
@@ -50499,10 +50428,9 @@ var UEditor = import_react86.default.forwardRef(({
50499
50428
  }
50500
50429
  ) });
50501
50430
  }
50502
- return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(UEditorPortalProvider, { getPortalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { ref: widthBoundaryRef, "data-ueditor-width-boundary": "", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
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)(
50503
50432
  "div",
50504
50433
  {
50505
- ref: editorShellRef,
50506
50434
  className: cn(
50507
50435
  "group relative flex flex-col text-card-foreground",
50508
50436
  editable ? [
@@ -50517,7 +50445,7 @@ var UEditor = import_react86.default.forwardRef(({
50517
50445
  ),
50518
50446
  children: [
50519
50447
  editable && (showMenuBar || showToolbar || showBubbleMenu) ? /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(EditorUiRenderStateProvider, { editor, children: [
50520
- isMenuBarVisible && /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_react86.default.Suspense, { fallback: null, children: /* @__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)(
50521
50449
  LazyMenuBar,
50522
50450
  {
50523
50451
  editor,
@@ -50575,7 +50503,7 @@ var UEditor = import_react86.default.forwardRef(({
50575
50503
  formulaRangeSurfaceRef.current = node;
50576
50504
  },
50577
50505
  className: cn(
50578
- "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]",
50579
50507
  expandWideTables && "[&_.tableWrapper]:!overflow-visible [&_.tableWrapper]:!pb-0"
50580
50508
  ),
50581
50509
  style: {
@@ -50644,7 +50572,7 @@ var UEditor = import_react86.default.forwardRef(({
50644
50572
  }
50645
50573
  ),
50646
50574
  /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
50647
- import_react87.EditorContent,
50575
+ import_react86.EditorContent,
50648
50576
  {
50649
50577
  editor,
50650
50578
  className: "min-h-full"