@underverse-ui/underverse 2.0.33 → 2.0.35

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.
@@ -94,7 +94,7 @@ import {
94
94
  sanitizeUEditorUrl,
95
95
  useEditorColors,
96
96
  useSharedEditorUiRenderState
97
- } from "./chunk-OTPC2OTQ.js";
97
+ } from "./chunk-F2P3DJSC.js";
98
98
  import {
99
99
  Tooltip,
100
100
  UEditorPortalProvider,
@@ -522,7 +522,7 @@ async function prepareUEditorContentForSave({
522
522
  }
523
523
 
524
524
  // src/components/UEditor/UEditor.tsx
525
- import React17, { useEffect as useEffect10, useImperativeHandle as useImperativeHandle4, useMemo as useMemo2, useRef as useRef10 } from "react";
525
+ import React16, { useEffect as useEffect10, useImperativeHandle as useImperativeHandle4, useMemo as useMemo2, useRef as useRef10 } from "react";
526
526
  import { useEditor, EditorContent } from "@tiptap/react";
527
527
 
528
528
  // src/components/UEditor/extensions.ts
@@ -12057,7 +12057,9 @@ function TableAddRails({
12057
12057
  ),
12058
12058
  style: {
12059
12059
  top: columnRailTop,
12060
- left: columnRailLeft,
12060
+ // An invisible rail must not sit outside the table: even at
12061
+ // opacity 0 its box would otherwise create a horizontal scrollbar.
12062
+ left: showColumnRail ? columnRailLeft : Math.max(visibleBounds.left, visibleBounds.right - BUTTON_SHORT_SIZE),
12061
12063
  width: BUTTON_SHORT_SIZE,
12062
12064
  height: BUTTON_LONG_SIZE,
12063
12065
  opacity: showColumnRail ? 1 : 0,
@@ -12335,18 +12337,16 @@ function TableColumnHandles({
12335
12337
  // src/components/UEditor/table-resize-handles.tsx
12336
12338
  import { MoveDiagonal2 } from "lucide-react";
12337
12339
  import { Fragment as Fragment6, jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
12338
- var HANDLE_BASE_CLASS = cn(
12339
- "pointer-events-auto absolute z-10 inline-flex touch-none items-center justify-center rounded-md",
12340
- "bg-background/95 text-primary shadow-sm backdrop-blur-sm",
12341
- "transition-[color,background-color,box-shadow,transform] duration-150",
12342
- "hover:bg-primary hover:text-primary-foreground hover:shadow-md active:scale-95",
12343
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
12344
- );
12345
12340
  var EDGE_HANDLE_CLASS = cn(
12346
12341
  "pointer-events-auto absolute top-0 z-10 h-full w-2 touch-none cursor-col-resize bg-transparent p-0",
12347
12342
  "border-transparent transition-colors duration-150 hover:border-primary",
12348
12343
  "focus-visible:border-primary focus-visible:outline-none"
12349
12344
  );
12345
+ var CORNER_HANDLE_CLASS = cn(
12346
+ "pointer-events-auto absolute z-10 inline-flex touch-none items-center justify-center p-0",
12347
+ "text-primary/70 transition-[color,transform] duration-150 hover:text-primary active:scale-95",
12348
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
12349
+ );
12350
12350
  function formatTableResizeDimensionLabel({
12351
12351
  width,
12352
12352
  height,
@@ -12426,9 +12426,9 @@ function TableResizeHandles({
12426
12426
  title: `${resizeBothLabel}. ${ctrlHint}`,
12427
12427
  "data-table-resize-handle": "both",
12428
12428
  className: cn(
12429
- HANDLE_BASE_CLASS,
12430
- "bottom-[-28px] right-[-30px] h-6 w-6 cursor-nwse-resize",
12431
- active && "bg-primary text-primary-foreground shadow-md"
12429
+ CORNER_HANDLE_CLASS,
12430
+ "bottom-[-28px] right-0 h-6 w-6 cursor-nwse-resize",
12431
+ active && "text-primary"
12432
12432
  ),
12433
12433
  onDoubleClick: onFitWidth,
12434
12434
  onClick: (event) => {
@@ -14885,78 +14885,13 @@ function useUEditorOutput({
14885
14885
  };
14886
14886
  }
14887
14887
 
14888
- // src/components/UEditor/use-wide-table-layout.ts
14889
- import React16 from "react";
14890
- function useWideTableLayout(editor, enabled, widthBoundaryRef, editorShellRef, editorSurfaceRef) {
14891
- React16.useLayoutEffect(() => {
14892
- const boundary = widthBoundaryRef.current;
14893
- const shell = editorShellRef.current;
14894
- const surface = editorSurfaceRef.current;
14895
- if (!editor || !boundary || !shell || !surface) return;
14896
- const editorDocument = editor.view.dom.ownerDocument;
14897
- const editorWindow = editorDocument.defaultView;
14898
- if (!editorWindow) return;
14899
- const editorDom = editor.view.dom;
14900
- let frame = 0;
14901
- const resetWidths = () => {
14902
- shell.style.removeProperty("width");
14903
- editorDom.style.removeProperty("width");
14904
- };
14905
- const sync = () => {
14906
- frame = 0;
14907
- resetWidths();
14908
- if (!enabled || editor.isDestroyed) return;
14909
- const boundaryWidth = boundary.getBoundingClientRect().width || boundary.clientWidth;
14910
- const surfaceWidth = surface.getBoundingClientRect().width || surface.clientWidth;
14911
- if (boundaryWidth <= 0 || surfaceWidth <= 0) return;
14912
- editorDom.style.width = `${surfaceWidth}px`;
14913
- const shellRect = shell.getBoundingClientRect();
14914
- let requiredWidth = boundaryWidth;
14915
- editorDom.querySelectorAll("table").forEach((table) => {
14916
- const tableRect = table.getBoundingClientRect();
14917
- if (tableRect.width > 0) {
14918
- requiredWidth = Math.max(requiredWidth, tableRect.right - shellRect.left + 32);
14919
- return;
14920
- }
14921
- const widthBp = Number(table.getAttribute("data-table-width-bp"));
14922
- if (Number.isFinite(widthBp) && widthBp > 1e4) {
14923
- requiredWidth = Math.max(requiredWidth, surfaceWidth * widthBp / 1e4 + 32);
14924
- }
14925
- });
14926
- if (requiredWidth <= boundaryWidth + 1) {
14927
- editorDom.style.removeProperty("width");
14928
- return;
14929
- }
14930
- shell.style.width = `${Math.ceil(requiredWidth)}px`;
14931
- };
14932
- const schedule = () => {
14933
- if (frame) editorWindow.cancelAnimationFrame(frame);
14934
- frame = editorWindow.requestAnimationFrame(sync);
14935
- };
14936
- const resizeObserver = typeof editorWindow.ResizeObserver === "function" ? new editorWindow.ResizeObserver(schedule) : null;
14937
- resizeObserver?.observe(boundary);
14938
- editor.on("transaction", schedule);
14939
- surface.addEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, schedule);
14940
- editorWindow.addEventListener("resize", schedule);
14941
- schedule();
14942
- return () => {
14943
- if (frame) editorWindow.cancelAnimationFrame(frame);
14944
- resizeObserver?.disconnect();
14945
- editor.off("transaction", schedule);
14946
- surface.removeEventListener(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT, schedule);
14947
- editorWindow.removeEventListener("resize", schedule);
14948
- resetWidths();
14949
- };
14950
- }, [editor, editorShellRef, editorSurfaceRef, enabled, widthBoundaryRef]);
14951
- }
14952
-
14953
14888
  // src/components/UEditor/UEditor.tsx
14954
14889
  import { jsx as jsx20, jsxs as jsxs17 } from "react/jsx-runtime";
14955
- var LazyMenuBar = React17.lazy(async () => {
14956
- const { MenuBar } = await import("./menu-bar-HZBBRX42.js");
14890
+ var LazyMenuBar = React16.lazy(async () => {
14891
+ const { MenuBar } = await import("./menu-bar-MUISXLMR.js");
14957
14892
  return { default: MenuBar };
14958
14893
  });
14959
- var UEditor = React17.forwardRef(({
14894
+ var UEditor = React16.forwardRef(({
14960
14895
  getPortalContainer,
14961
14896
  content = "",
14962
14897
  onChange,
@@ -14987,6 +14922,7 @@ var UEditor = React17.forwardRef(({
14987
14922
  maxCharacters,
14988
14923
  minHeight = "200px",
14989
14924
  maxHeight = "auto",
14925
+ tableCellHorizontalPadding = 8,
14990
14926
  expandWideTables = true,
14991
14927
  variant = "default",
14992
14928
  rounded = true,
@@ -15008,6 +14944,7 @@ var UEditor = React17.forwardRef(({
15008
14944
  }, ref) => {
15009
14945
  const t = useSmartTranslations("UEditor");
15010
14946
  const effectivePlaceholder = placeholder ?? t("placeholder");
14947
+ const resolvedTableCellHorizontalPadding = Number.isFinite(tableCellHorizontalPadding) ? Math.max(0, tableCellHorizontalPadding) : 8;
15011
14948
  const inFlightPrepareRef = useRef10(null);
15012
14949
  const lastAppliedContentRef = useRef10(content ?? "");
15013
14950
  const scheduledFormulaRecalculateRef = useRef10(false);
@@ -15015,10 +14952,8 @@ var UEditor = React17.forwardRef(({
15015
14952
  const editorInstanceRef = useRef10(null);
15016
14953
  const formulaRangePickRef = useRef10(null);
15017
14954
  const formulaRangeSurfaceRef = useRef10(null);
15018
- const [formulaRangeHighlight, setFormulaRangeHighlight] = React17.useState(null);
15019
- const [isMenuBarVisible, setIsMenuBarVisible] = React17.useState(showMenuBar);
15020
- const widthBoundaryRef = useRef10(null);
15021
- const editorShellRef = useRef10(null);
14955
+ const [formulaRangeHighlight, setFormulaRangeHighlight] = React16.useState(null);
14956
+ const [isMenuBarVisible, setIsMenuBarVisible] = React16.useState(showMenuBar);
15022
14957
  useEffect10(() => {
15023
14958
  setIsMenuBarVisible(showMenuBar);
15024
14959
  }, [showMenuBar]);
@@ -15028,7 +14963,7 @@ var UEditor = React17.forwardRef(({
15028
14963
  onJsonChange,
15029
14964
  outputDebounceMs
15030
14965
  });
15031
- const scheduleFormulaRecalculate = React17.useCallback((editor2, options) => {
14966
+ const scheduleFormulaRecalculate = React16.useCallback((editor2, options) => {
15032
14967
  if (editor2.isDestroyed || scheduledFormulaRecalculateRef.current) return;
15033
14968
  if (!options?.force && isEditingTableFormulaText(editor2)) return;
15034
14969
  scheduledFormulaRecalculateRef.current = true;
@@ -15070,7 +15005,7 @@ var UEditor = React17.forwardRef(({
15070
15005
  ],
15071
15006
  [getPortalContainer, effectivePlaceholder, t, maxCharacters, uploadImage, resolvedUploadFile, imageInsertMode, maxImageFileSize, allowedImageMimeTypes, fallbackToDataUrl, onImageUploadError, editable, fetchMetadata, extraExtensions]
15072
15007
  );
15073
- const syncFormulaRangeHighlight = React17.useCallback((pickState) => {
15008
+ const syncFormulaRangeHighlight = React16.useCallback((pickState) => {
15074
15009
  const container = formulaRangeSurfaceRef.current;
15075
15010
  setFormulaRangeHighlight(container && pickState ? getFormulaRangePickHighlight(container, pickState) : null);
15076
15011
  }, []);
@@ -15211,7 +15146,6 @@ var UEditor = React17.forwardRef(({
15211
15146
  apply: t("tableMenu.apply"),
15212
15147
  cancel: t("imageInput.cancelBtn")
15213
15148
  });
15214
- useWideTableLayout(editor, expandWideTables, widthBoundaryRef, editorShellRef, editorContentRef);
15215
15149
  useImperativeHandle4(
15216
15150
  ref,
15217
15151
  () => ({
@@ -15279,10 +15213,9 @@ var UEditor = React17.forwardRef(({
15279
15213
  }
15280
15214
  ) });
15281
15215
  }
15282
- return /* @__PURE__ */ jsx20(UEditorPortalProvider, { getPortalContainer, children: /* @__PURE__ */ jsx20("div", { ref: widthBoundaryRef, "data-ueditor-width-boundary": "", className: "w-full", children: /* @__PURE__ */ jsxs17(
15216
+ return /* @__PURE__ */ jsx20(UEditorPortalProvider, { getPortalContainer, children: /* @__PURE__ */ jsx20("div", { "data-ueditor-width-boundary": "", className: "w-full", children: /* @__PURE__ */ jsxs17(
15283
15217
  "div",
15284
15218
  {
15285
- ref: editorShellRef,
15286
15219
  className: cn(
15287
15220
  "group relative flex flex-col text-card-foreground",
15288
15221
  editable ? [
@@ -15297,7 +15230,7 @@ var UEditor = React17.forwardRef(({
15297
15230
  ),
15298
15231
  children: [
15299
15232
  editable && (showMenuBar || showToolbar || showBubbleMenu) ? /* @__PURE__ */ jsxs17(EditorUiRenderStateProvider, { editor, children: [
15300
- isMenuBarVisible && /* @__PURE__ */ jsx20(React17.Suspense, { fallback: null, children: /* @__PURE__ */ jsx20(
15233
+ isMenuBarVisible && /* @__PURE__ */ jsx20(React16.Suspense, { fallback: null, children: /* @__PURE__ */ jsx20(
15301
15234
  LazyMenuBar,
15302
15235
  {
15303
15236
  editor,
@@ -15355,13 +15288,14 @@ var UEditor = React17.forwardRef(({
15355
15288
  formulaRangeSurfaceRef.current = node;
15356
15289
  },
15357
15290
  className: cn(
15358
- "relative flex-1 overflow-y-auto",
15291
+ "relative flex-1 overflow-x-auto overflow-y-auto [scrollbar-width:thin] [scrollbar-color:hsl(var(--border))_transparent]",
15359
15292
  expandWideTables && "[&_.tableWrapper]:!overflow-visible [&_.tableWrapper]:!pb-0"
15360
15293
  ),
15361
15294
  style: {
15362
15295
  fontFamily: defaultFontFamily,
15363
15296
  minHeight: editable ? minHeight : void 0,
15364
- maxHeight
15297
+ maxHeight,
15298
+ "--ueditor-table-cell-padding-x": `${resolvedTableCellHorizontalPadding}px`
15365
15299
  },
15366
15300
  children: [
15367
15301
  /* @__PURE__ */ jsx20(
@@ -15448,4 +15382,4 @@ export {
15448
15382
  prepareUEditorContentForSave,
15449
15383
  UEditor_default
15450
15384
  };
15451
- //# sourceMappingURL=chunk-FQVWYDKP.js.map
15385
+ //# sourceMappingURL=chunk-H4AVZA4K.js.map