@underverse-ui/underverse 2.0.12 → 2.0.13

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@underverse-ui/underverse",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 257,
6
6
  "exports": [
@@ -2371,6 +2371,18 @@ var EditorColorPalette = ({
2371
2371
  const automaticColor = colors[0]?.color ?? "";
2372
2372
  const paletteColors = colors.slice(1);
2373
2373
  const customColorSelect = onCustomColorSelect ?? onSelect;
2374
+ const [hexInput, setHexInput] = React6.useState(currentColor.startsWith("#") ? currentColor : "");
2375
+ React6.useEffect(() => {
2376
+ setHexInput(currentColor.startsWith("#") ? currentColor : "");
2377
+ }, [currentColor]);
2378
+ const commitHex = (val) => {
2379
+ let formatted = val.trim();
2380
+ if (!formatted) return;
2381
+ if (!formatted.startsWith("#")) formatted = `#${formatted}`;
2382
+ if (/^#([0-9A-F]{3}){1,2}$/i.test(formatted)) {
2383
+ customColorSelect(formatted);
2384
+ }
2385
+ };
2374
2386
  React6.useEffect(() => {
2375
2387
  const input = colorInputRef.current;
2376
2388
  if (!input) return;
@@ -2382,7 +2394,7 @@ var EditorColorPalette = ({
2382
2394
  const input = colorInputRef.current;
2383
2395
  if (input) input.value = currentColor.startsWith("#") ? currentColor : "#000000";
2384
2396
  }, [currentColor]);
2385
- return /* @__PURE__ */ jsxs4("div", { className: "w-56 p-2", children: [
2397
+ return /* @__PURE__ */ jsxs4("div", { className: "w-56 p-2", "data-ueditor-keep-open": true, children: [
2386
2398
  /* @__PURE__ */ jsx6("span", { className: "px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: label }),
2387
2399
  /* @__PURE__ */ jsxs4(
2388
2400
  "button",
@@ -2416,29 +2428,48 @@ var EditorColorPalette = ({
2416
2428
  children: currentColor === c.color && /* @__PURE__ */ jsx6("span", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx6(Check2, { className: cn("h-3.5 w-3.5", getSwatchCheckClass(c.color)) }) })
2417
2429
  }
2418
2430
  ) }, `${c.name}-${c.color}`)) }),
2419
- /* @__PURE__ */ jsxs4(
2420
- "button",
2421
- {
2422
- type: "button",
2423
- onMouseDown: (e) => e.preventDefault(),
2424
- onClick: () => colorInputRef.current?.click(),
2425
- className: "mt-3 flex h-9 w-full items-center gap-3 rounded-md px-2 text-sm text-foreground transition-colors hover:bg-muted",
2426
- children: [
2427
- /* @__PURE__ */ jsx6(
2428
- "span",
2429
- {
2430
- "aria-hidden": "true",
2431
- className: "h-5 w-5 rounded border border-border",
2432
- style: {
2433
- background: "linear-gradient(135deg, #ff004c 0%, #fffb00 22%, #00ff66 42%, #00d5ff 62%, #2446ff 78%, #ff00d4 100%)"
2431
+ /* @__PURE__ */ jsxs4("div", { className: "mt-3 flex items-center gap-2", children: [
2432
+ /* @__PURE__ */ jsxs4("div", { className: "flex h-8 flex-1 items-center gap-1.5 rounded-md border border-input bg-muted/30 px-2", children: [
2433
+ /* @__PURE__ */ jsx6(
2434
+ "span",
2435
+ {
2436
+ className: "h-4 w-4 shrink-0 rounded-[2px] border border-border",
2437
+ style: { backgroundColor: hexInput.startsWith("#") ? hexInput : currentColor.startsWith("#") ? currentColor : "transparent" }
2438
+ }
2439
+ ),
2440
+ /* @__PURE__ */ jsx6(
2441
+ "input",
2442
+ {
2443
+ type: "text",
2444
+ value: hexInput,
2445
+ onChange: (e) => setHexInput(e.target.value),
2446
+ onBlur: () => commitHex(hexInput),
2447
+ onMouseDown: (e) => e.stopPropagation(),
2448
+ onClick: (e) => e.stopPropagation(),
2449
+ onKeyDown: (e) => {
2450
+ e.stopPropagation();
2451
+ if (e.key === "Enter") {
2452
+ e.preventDefault();
2453
+ commitHex(hexInput);
2434
2454
  }
2435
- }
2436
- ),
2437
- /* @__PURE__ */ jsx6("span", { className: "flex-1 text-center", children: t("colors.moreColors") }),
2438
- /* @__PURE__ */ jsx6(Palette, { className: "h-4 w-4 text-muted-foreground" })
2439
- ]
2440
- }
2441
- ),
2455
+ },
2456
+ placeholder: "#HEX",
2457
+ className: "h-full w-full bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground"
2458
+ }
2459
+ )
2460
+ ] }),
2461
+ /* @__PURE__ */ jsx6(
2462
+ "button",
2463
+ {
2464
+ type: "button",
2465
+ onMouseDown: (e) => e.stopPropagation(),
2466
+ onClick: () => colorInputRef.current?.click(),
2467
+ title: t("colors.moreColors"),
2468
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-input bg-muted/30 text-foreground transition-colors hover:bg-muted",
2469
+ children: /* @__PURE__ */ jsx6(Palette, { className: "h-4 w-4 text-muted-foreground" })
2470
+ }
2471
+ )
2472
+ ] }),
2442
2473
  /* @__PURE__ */ jsx6(
2443
2474
  "input",
2444
2475
  {
@@ -2584,8 +2615,9 @@ var DEFAULT_TABLE_ROW_HEIGHT = 25;
2584
2615
  var MIN_TABLE_ROW_HEIGHT = DEFAULT_TABLE_ROW_HEIGHT;
2585
2616
  var COLUMN_RESIZE_LINE_THICKNESS = 2;
2586
2617
  var ROW_RESIZE_LINE_THICKNESS = 2;
2587
- var UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor-table-layout-change";
2588
- var TABLE_RESIZE_HIT_ZONE = 10;
2618
+ var UEDITOR_TABLE_LAYOUT_CHANGE_EVENT = "ueditor:table-layout-change";
2619
+ var isRowResizingGlobal = { active: false };
2620
+ var TABLE_RESIZE_HIT_ZONE = 5;
2589
2621
  function findTableRowNodeInfo(view, rowElement) {
2590
2622
  const firstCell = rowElement.querySelector("th,td");
2591
2623
  if (!firstCell) return null;
@@ -2639,17 +2671,60 @@ function getSelectionTableCell(view) {
2639
2671
  const cell = element?.closest?.("th,td");
2640
2672
  return cell instanceof HTMLElement ? cell : null;
2641
2673
  }
2642
- function isRowResizeHotspot(cell, clientX, clientY) {
2674
+ function resolveRowResizeTarget(cell, clientX, clientY) {
2643
2675
  const rect = cell.getBoundingClientRect();
2644
- const nearBottom = rect.bottom - clientY <= TABLE_RESIZE_HIT_ZONE;
2645
- const nearRight = rect.right - clientX <= TABLE_RESIZE_HIT_ZONE;
2646
- return nearBottom && !nearRight;
2676
+ const row = cell.closest("tr");
2677
+ if (!(row instanceof HTMLTableRowElement) || !(cell instanceof HTMLTableCellElement)) {
2678
+ return null;
2679
+ }
2680
+ const distToBottom = Math.abs(clientY - rect.bottom);
2681
+ const distToTop = Math.abs(clientY - rect.top);
2682
+ const distToRight = Math.abs(clientX - rect.right);
2683
+ const distToLeft = Math.abs(clientX - rect.left);
2684
+ if (distToRight <= 3 || distToLeft <= 3) {
2685
+ return null;
2686
+ }
2687
+ if (distToBottom <= TABLE_RESIZE_HIT_ZONE) {
2688
+ return { row, cell };
2689
+ }
2690
+ if (distToTop <= TABLE_RESIZE_HIT_ZONE) {
2691
+ const prevRow = row.previousElementSibling;
2692
+ if (prevRow instanceof HTMLTableRowElement) {
2693
+ const cellIndex = cell.cellIndex;
2694
+ const prevCell = prevRow.children[cellIndex] ?? prevRow.firstElementChild;
2695
+ if (prevCell instanceof HTMLTableCellElement) {
2696
+ return { row: prevRow, cell: prevCell };
2697
+ }
2698
+ }
2699
+ }
2700
+ return null;
2647
2701
  }
2648
- function isColumnResizeHotspot(cell, clientX, clientY) {
2702
+ function resolveColumnResizeTarget(cell, clientX, clientY) {
2649
2703
  const rect = cell.getBoundingClientRect();
2650
- const nearRight = rect.right - clientX <= TABLE_RESIZE_HIT_ZONE;
2651
- const nearBottom = rect.bottom - clientY <= TABLE_RESIZE_HIT_ZONE;
2652
- return nearRight && !nearBottom;
2704
+ const row = cell.closest("tr");
2705
+ if (!(row instanceof HTMLTableRowElement) || !(cell instanceof HTMLTableCellElement)) {
2706
+ return null;
2707
+ }
2708
+ const distToRight = Math.abs(clientX - rect.right);
2709
+ const distToLeft = Math.abs(clientX - rect.left);
2710
+ const distToBottom = Math.abs(clientY - rect.bottom);
2711
+ const distToTop = Math.abs(clientY - rect.top);
2712
+ if (distToBottom <= 3 || distToTop <= 3) {
2713
+ return null;
2714
+ }
2715
+ if (distToRight <= TABLE_RESIZE_HIT_ZONE) {
2716
+ return { row, cell };
2717
+ }
2718
+ if (distToLeft <= TABLE_RESIZE_HIT_ZONE) {
2719
+ const prevCell = cell.previousElementSibling;
2720
+ if (prevCell instanceof HTMLTableCellElement) {
2721
+ return { row, cell: prevCell };
2722
+ }
2723
+ }
2724
+ return null;
2725
+ }
2726
+ function isRowResizeHotspot(cell, clientX, clientY) {
2727
+ return resolveRowResizeTarget(cell, clientX, clientY) !== null;
2653
2728
  }
2654
2729
  function getRelativeBoundaryMetrics(surface, table, row, cell) {
2655
2730
  const surfaceRect = surface.getBoundingClientRect();
@@ -3280,7 +3355,7 @@ var ToolbarButton = React7.forwardRef(({ onClick, onMouseDown, active, disabled,
3280
3355
  return button;
3281
3356
  });
3282
3357
  ToolbarButton.displayName = "ToolbarButton";
3283
- var ToolbarDivider = () => /* @__PURE__ */ jsx7("div", { "aria-hidden": "true", className: "mx-1.5 h-7 w-px shrink-0 bg-[rgba(123,129,132,0.24)]" });
3358
+ var ToolbarDivider = () => /* @__PURE__ */ jsx7("div", { "aria-hidden": "true", className: "mx-1 h-5 w-px shrink-0 bg-[rgba(123,129,132,0.24)]" });
3284
3359
  var TableInsertGrid = ({
3285
3360
  insertLabel,
3286
3361
  previewTemplate,
@@ -3334,6 +3409,7 @@ var EditorToolbar = ({
3334
3409
  maxImageFileSize = DEFAULT_UEDITOR_IMAGE_MAX_FILE_SIZE,
3335
3410
  allowedImageMimeTypes = DEFAULT_UEDITOR_IMAGE_MIME_TYPES,
3336
3411
  fontFamilies,
3412
+ defaultFontFamily = "Inter",
3337
3413
  fontSizes,
3338
3414
  lineHeights,
3339
3415
  letterSpacings
@@ -3376,9 +3452,9 @@ var EditorToolbar = ({
3376
3452
  const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? "13";
3377
3453
  const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
3378
3454
  const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
3379
- const defaultFontFamily = availableFontFamilies[0];
3380
- const defaultFontFamilyValue = defaultFontFamily?.value ?? "";
3381
- const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : defaultFontFamily?.label ?? t("toolbar.fontDefault");
3455
+ const defaultFontFamilyOption = availableFontFamilies.find((opt) => normalizeStyleValue(opt.value) === normalizeStyleValue(defaultFontFamily)) ?? availableFontFamilies[0];
3456
+ const defaultFontFamilyValue = defaultFontFamilyOption?.value ?? defaultFontFamily ?? "Inter";
3457
+ const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : defaultFontFamilyOption?.label ?? defaultFontFamily ?? t("toolbar.fontDefault");
3382
3458
  const displayedFontFamilyValue = currentFontFamily || defaultFontFamilyValue;
3383
3459
  const displayedFontSizeLabel = currentFontSize ? currentFontSizeLabel : "13";
3384
3460
  const activeFontSize = currentFontSize || "13px";
@@ -3510,7 +3586,7 @@ var EditorToolbar = ({
3510
3586
  "div",
3511
3587
  {
3512
3588
  role: "toolbar",
3513
- className: "flex min-h-12 flex-nowrap items-center gap-0.5 overflow-x-auto border-b border-[rgba(196,197,213,0.6)] bg-[#F4F4F4] px-2 py-2 dark:bg-muted/60",
3589
+ className: "flex min-h-9 flex-nowrap items-center gap-0.5 overflow-x-auto border-b border-[rgba(196,197,213,0.6)] bg-[#F4F4F4] px-1.5 py-1 dark:bg-muted/60",
3514
3590
  children: [
3515
3591
  isFull && /* @__PURE__ */ jsx7(
3516
3592
  DropdownMenu,
@@ -3521,9 +3597,9 @@ var EditorToolbar = ({
3521
3597
  onClick: () => {
3522
3598
  },
3523
3599
  title: t("toolbar.fontFamily"),
3524
- className: "h-8 w-44 max-w-44 justify-between gap-2 border border-[rgba(196,197,213,0.6)] bg-white px-2.5 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
3600
+ className: "h-7 w-40 max-w-40 justify-between gap-1.5 border border-[rgba(196,197,213,0.6)] bg-white px-2 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
3525
3601
  children: [
3526
- /* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate text-left text-sm font-normal", style: { fontFamily: displayedFontFamilyValue || void 0 }, children: displayedFontFamilyLabel }),
3602
+ /* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate text-left text-xs font-normal", style: { fontFamily: displayedFontFamilyValue || void 0 }, children: displayedFontFamilyLabel }),
3527
3603
  /* @__PURE__ */ jsx7(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
3528
3604
  ]
3529
3605
  }
@@ -3550,9 +3626,9 @@ var EditorToolbar = ({
3550
3626
  onClick: () => {
3551
3627
  },
3552
3628
  title: t("toolbar.fontSize"),
3553
- className: "h-8 w-16 justify-between gap-2 border border-[rgba(196,197,213,0.6)] bg-white px-2.5 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
3629
+ className: "h-7 w-14 justify-between gap-1 border border-[rgba(196,197,213,0.6)] bg-white px-2 text-[#404040] shadow-[0_1px_2px_rgba(0,0,0,0.07)] hover:bg-white hover:text-[#404040] dark:bg-background dark:text-foreground",
3554
3630
  children: [
3555
- /* @__PURE__ */ jsx7("span", { className: "text-sm font-normal leading-none", children: displayedFontSizeLabel }),
3631
+ /* @__PURE__ */ jsx7("span", { className: "text-xs font-normal leading-none", children: displayedFontSizeLabel }),
3556
3632
  /* @__PURE__ */ jsx7(FigmaChevronDownIcon, { className: "h-3 w-3 shrink-0 text-[#7B8184]" })
3557
3633
  ]
3558
3634
  }
@@ -3677,6 +3753,27 @@ var EditorToolbar = ({
3677
3753
  )
3678
3754
  ] }),
3679
3755
  /* @__PURE__ */ jsx7(ToolbarDivider, {}),
3756
+ (isMediumFull || isFull) && /* @__PURE__ */ jsx7(
3757
+ DropdownMenu,
3758
+ {
3759
+ isOpen: isTableMenuOpen,
3760
+ onOpenChange: setIsTableMenuOpen,
3761
+ trigger: /* @__PURE__ */ jsx7(ToolbarButton, { onClick: () => {
3762
+ }, title: t("toolbar.table"), children: /* @__PURE__ */ jsx7(FigmaTableIcon, { className: "h-4 w-4" }) }),
3763
+ contentClassName: "p-2 min-w-56",
3764
+ children: /* @__PURE__ */ jsx7(
3765
+ TableInsertGrid,
3766
+ {
3767
+ insertLabel: t("tableMenu.insertTable"),
3768
+ previewTemplate: t("tableMenu.gridPreview"),
3769
+ onInsert: (rows, cols) => {
3770
+ editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
3771
+ setIsTableMenuOpen(false);
3772
+ }
3773
+ }
3774
+ )
3775
+ }
3776
+ ),
3680
3777
  /* @__PURE__ */ jsx7(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ jsx7(FigmaBoldIcon, { className: "h-4 w-4" }) }),
3681
3778
  /* @__PURE__ */ jsx7(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ jsx7(FigmaItalicIcon, { className: "h-4 w-4" }) }),
3682
3779
  /* @__PURE__ */ jsx7(
@@ -4147,27 +4244,6 @@ var EditorToolbar = ({
4147
4244
  ] })
4148
4245
  }
4149
4246
  ),
4150
- (isMediumFull || isFull) && /* @__PURE__ */ jsx7(
4151
- DropdownMenu,
4152
- {
4153
- isOpen: isTableMenuOpen,
4154
- onOpenChange: setIsTableMenuOpen,
4155
- trigger: /* @__PURE__ */ jsx7(ToolbarButton, { onClick: () => {
4156
- }, title: t("toolbar.table"), children: /* @__PURE__ */ jsx7(FigmaTableIcon, { className: "h-4 w-4" }) }),
4157
- contentClassName: "p-2 min-w-56",
4158
- children: /* @__PURE__ */ jsx7(
4159
- TableInsertGrid,
4160
- {
4161
- insertLabel: t("tableMenu.insertTable"),
4162
- previewTemplate: t("tableMenu.gridPreview"),
4163
- onInsert: (rows, cols) => {
4164
- editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run();
4165
- setIsTableMenuOpen(false);
4166
- }
4167
- }
4168
- )
4169
- }
4170
- ),
4171
4247
  /* @__PURE__ */ jsx7(ToolbarDivider, {}),
4172
4248
  /* @__PURE__ */ jsx7(ToolbarButton, { onClick: () => editor.chain().focus().undo().run(), disabled: !editor.can().undo(), title: t("toolbar.undo"), children: /* @__PURE__ */ jsx7(FigmaUndoIcon, { className: "h-4 w-4" }) }),
4173
4249
  /* @__PURE__ */ jsx7(ToolbarButton, { onClick: () => editor.chain().focus().redo().run(), disabled: !editor.can().redo(), title: t("toolbar.redo"), children: /* @__PURE__ */ jsx7(FigmaRedoIcon, { className: "h-4 w-4" }) }),
@@ -4359,7 +4435,7 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
4359
4435
  "[&_.selectedCell]:after:absolute",
4360
4436
  "[&_.selectedCell]:after:inset-0",
4361
4437
  "[&_.selectedCell]:after:z-[2]",
4362
- "[&_.selectedCell]:after:bg-primary/15",
4438
+ "[&_.selectedCell]:after:bg-primary/8",
4363
4439
  "[&_.selectedCell]:after:pointer-events-none",
4364
4440
  "[&_.column-resize-handle]:pointer-events-auto",
4365
4441
  "[&_.column-resize-handle]:cursor-col-resize",
@@ -4373,17 +4449,10 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
4373
4449
  "[&_.column-resize-handle]:rounded-none",
4374
4450
  "[&_.column-resize-handle]:opacity-0",
4375
4451
  "[&_.column-resize-handle]:transition-opacity",
4376
- "[&_.column-resize-handle]:after:absolute",
4377
- "[&_.column-resize-handle]:after:top-0",
4378
- "[&_.column-resize-handle]:after:bottom-0",
4379
- "[&_.column-resize-handle]:after:left-1/2",
4380
- "[&_.column-resize-handle]:after:w-0.5",
4381
- "[&_.column-resize-handle]:after:-translate-x-1/2",
4382
- "[&_.column-resize-handle]:after:rounded-full",
4383
- "[&_.column-resize-handle]:after:bg-primary/75",
4384
- "[&_.column-resize-handle]:after:content-['']",
4385
- "[&.resize-cursor_.column-resize-handle]:opacity-100",
4386
- "[&.resize-cursor_.column-resize-handle]:after:bg-primary",
4452
+ "[&_.column-resize-handle]:duration-200",
4453
+ "[&_.column-resize-handle]:delay-100",
4454
+ "[&_.column-resize-handle]:ease-out",
4455
+ "[&_.column-resize-handle]:after:hidden",
4387
4456
  "[&_.column-resize-dragging]:min-w-0",
4388
4457
  "[&.resize-cursor]:cursor-col-resize",
4389
4458
  "[&.resize-row-cursor]:cursor-row-resize",
@@ -4471,12 +4540,14 @@ export {
4471
4540
  COLUMN_RESIZE_LINE_THICKNESS,
4472
4541
  ROW_RESIZE_LINE_THICKNESS,
4473
4542
  UEDITOR_TABLE_LAYOUT_CHANGE_EVENT,
4543
+ isRowResizingGlobal,
4474
4544
  findTableRowNodeInfo,
4475
4545
  resolveEventElement,
4476
4546
  isPointOverRenderedText,
4477
4547
  getSelectionTableCell,
4548
+ resolveRowResizeTarget,
4549
+ resolveColumnResizeTarget,
4478
4550
  isRowResizeHotspot,
4479
- isColumnResizeHotspot,
4480
4551
  getRelativeBoundaryMetrics,
4481
4552
  getRelativeCellMetrics,
4482
4553
  getRelativeSelectedCellsMetrics,
@@ -4515,4 +4586,4 @@ export {
4515
4586
  EditorToolbar,
4516
4587
  UEDITOR_PROSEMIRROR_CLASS_NAME
4517
4588
  };
4518
- //# sourceMappingURL=chunk-EVS5YWTO.js.map
4589
+ //# sourceMappingURL=chunk-MMMCBJ2L.js.map