@underverse-ui/underverse 1.0.128 → 1.0.130

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": "1.0.128",
3
+ "version": "1.0.130",
4
4
  "sourceEntry": "src/index.ts",
5
5
  "totalExports": 232,
6
6
  "exports": [
package/dist/index.cjs CHANGED
@@ -1014,7 +1014,8 @@ var en_default = {
1014
1014
  dragColumn: "Drag Column",
1015
1015
  alignLeft: "Align Table Left",
1016
1016
  alignCenter: "Align Table Center",
1017
- alignRight: "Align Table Right"
1017
+ alignRight: "Align Table Right",
1018
+ cellBackground: "Cell Background"
1018
1019
  }
1019
1020
  }
1020
1021
  };
@@ -1283,7 +1284,8 @@ var vi_default = {
1283
1284
  dragColumn: "K\xE9o c\u1ED9t",
1284
1285
  alignLeft: "C\u0103n b\u1EA3ng tr\xE1i",
1285
1286
  alignCenter: "C\u0103n b\u1EA3ng gi\u1EEFa",
1286
- alignRight: "C\u0103n b\u1EA3ng ph\u1EA3i"
1287
+ alignRight: "C\u0103n b\u1EA3ng ph\u1EA3i",
1288
+ cellBackground: "M\xE0u n\u1EC1n \xF4"
1287
1289
  }
1288
1290
  }
1289
1291
  };
@@ -1551,7 +1553,8 @@ var ko_default = {
1551
1553
  dragColumn: "\uC5F4 \uB4DC\uB798\uADF8",
1552
1554
  alignLeft: "\uD45C \uC67C\uCABD \uC815\uB82C",
1553
1555
  alignCenter: "\uD45C \uAC00\uC6B4\uB370 \uC815\uB82C",
1554
- alignRight: "\uD45C \uC624\uB978\uCABD \uC815\uB82C"
1556
+ alignRight: "\uD45C \uC624\uB978\uCABD \uC815\uB82C",
1557
+ cellBackground: "\uC140 \uBC30\uACBD\uC0C9"
1555
1558
  }
1556
1559
  }
1557
1560
  };
@@ -1819,7 +1822,8 @@ var ja_default = {
1819
1822
  dragColumn: "\u5217\u3092\u30C9\u30E9\u30C3\u30B0",
1820
1823
  alignLeft: "\u8868\u3092\u5DE6\u5BC4\u305B",
1821
1824
  alignCenter: "\u8868\u3092\u4E2D\u592E\u63C3\u3048",
1822
- alignRight: "\u8868\u3092\u53F3\u5BC4\u305B"
1825
+ alignRight: "\u8868\u3092\u53F3\u5BC4\u305B",
1826
+ cellBackground: "\u30BB\u30EB\u80CC\u666F\u8272"
1823
1827
  }
1824
1828
  }
1825
1829
  };
@@ -24006,6 +24010,7 @@ var import_react56 = __toESM(require("react"), 1);
24006
24010
  var import_react57 = require("@tiptap/react");
24007
24011
 
24008
24012
  // src/components/UEditor/extensions.ts
24013
+ var import_core10 = require("@tiptap/core");
24009
24014
  var import_extension_document = __toESM(require("@tiptap/extension-document"), 1);
24010
24015
  var import_extension_paragraph = __toESM(require("@tiptap/extension-paragraph"), 1);
24011
24016
  var import_extension_text = __toESM(require("@tiptap/extension-text"), 1);
@@ -25319,6 +25324,64 @@ var UEditorTable = import_extension_table.Table.extend({
25319
25324
  var table_align_default = UEditorTable;
25320
25325
 
25321
25326
  // src/components/UEditor/extensions.ts
25327
+ var CustomTableCell = import_extension_table_cell.default.extend({
25328
+ addAttributes() {
25329
+ return {
25330
+ ...this.parent?.(),
25331
+ backgroundColor: {
25332
+ default: null,
25333
+ parseHTML: (element) => element.style.backgroundColor || element.getAttribute("data-background-color") || null,
25334
+ renderHTML: (attributes) => {
25335
+ if (!attributes.backgroundColor) {
25336
+ return {};
25337
+ }
25338
+ return {
25339
+ "data-background-color": attributes.backgroundColor
25340
+ };
25341
+ }
25342
+ }
25343
+ };
25344
+ },
25345
+ renderHTML({ HTMLAttributes }) {
25346
+ const style = HTMLAttributes.style || "";
25347
+ const bg = HTMLAttributes["data-background-color"];
25348
+ const mergedStyle = bg ? `${style}; background-color: ${bg}`.replace(/^;/, "") : style;
25349
+ return [
25350
+ "td",
25351
+ (0, import_core10.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, mergedStyle ? { style: mergedStyle } : {}),
25352
+ 0
25353
+ ];
25354
+ }
25355
+ });
25356
+ var CustomTableHeader = import_extension_table_header.default.extend({
25357
+ addAttributes() {
25358
+ return {
25359
+ ...this.parent?.(),
25360
+ backgroundColor: {
25361
+ default: null,
25362
+ parseHTML: (element) => element.style.backgroundColor || element.getAttribute("data-background-color") || null,
25363
+ renderHTML: (attributes) => {
25364
+ if (!attributes.backgroundColor) {
25365
+ return {};
25366
+ }
25367
+ return {
25368
+ "data-background-color": attributes.backgroundColor
25369
+ };
25370
+ }
25371
+ }
25372
+ };
25373
+ },
25374
+ renderHTML({ HTMLAttributes }) {
25375
+ const style = HTMLAttributes.style || "";
25376
+ const bg = HTMLAttributes["data-background-color"];
25377
+ const mergedStyle = bg ? `${style}; background-color: ${bg}`.replace(/^;/, "") : style;
25378
+ return [
25379
+ "th",
25380
+ (0, import_core10.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, mergedStyle ? { style: mergedStyle } : {}),
25381
+ 0
25382
+ ];
25383
+ }
25384
+ });
25322
25385
  var lowlight = (0, import_lowlight.createLowlight)(import_lowlight.common);
25323
25386
  function buildUEditorExtensions({
25324
25387
  placeholder,
@@ -25417,12 +25480,12 @@ function buildUEditorExtensions({
25417
25480
  }
25418
25481
  }),
25419
25482
  table_row_default,
25420
- import_extension_table_cell.default.configure({
25483
+ CustomTableCell.configure({
25421
25484
  HTMLAttributes: {
25422
25485
  class: "border border-border p-2 min-w-25"
25423
25486
  }
25424
25487
  }),
25425
- import_extension_table_header.default.configure({
25488
+ CustomTableHeader.configure({
25426
25489
  HTMLAttributes: {
25427
25490
  class: "border border-border p-2 bg-muted font-semibold min-w-25"
25428
25491
  }
@@ -25491,6 +25554,20 @@ var HighlightColorIcon = ({ color }) => {
25491
25554
  )
25492
25555
  ] });
25493
25556
  };
25557
+ var CellBgColorIcon = ({ color }) => {
25558
+ const underlineColor = color && color !== "inherit" ? color : "currentColor";
25559
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("span", { className: "relative flex h-5 w-5 items-center justify-center leading-none", children: [
25560
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_lucide_react42.Paintbrush, { className: "h-4 w-4" }),
25561
+ /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
25562
+ "span",
25563
+ {
25564
+ "aria-hidden": "true",
25565
+ className: "absolute bottom-0 left-1/2 h-0.5 w-4 -translate-x-1/2 rounded-full",
25566
+ style: { backgroundColor: underlineColor }
25567
+ }
25568
+ )
25569
+ ] });
25570
+ };
25494
25571
  var EDITOR_COLOR_SWATCHES = [
25495
25572
  "#000000",
25496
25573
  "#3f3f46",
@@ -26803,6 +26880,7 @@ var EditorToolbar = ({
26803
26880
  // src/components/UEditor/menus.tsx
26804
26881
  var import_react51 = require("react");
26805
26882
  var import_react52 = require("@tiptap/react");
26883
+ var import_tables = require("@tiptap/pm/tables");
26806
26884
  var import_react_dom8 = require("react-dom");
26807
26885
  var import_lucide_react45 = require("lucide-react");
26808
26886
  var import_jsx_runtime82 = require("react/jsx-runtime");
@@ -26858,6 +26936,16 @@ var FloatingMenuContent = ({ editor }) => {
26858
26936
  }
26859
26937
  );
26860
26938
  };
26939
+ function applyTableCellBackground(editor, color) {
26940
+ const value = color || null;
26941
+ const { state, view } = editor;
26942
+ const applied = (0, import_tables.setCellAttr)("backgroundColor", value)(state, view.dispatch.bind(view));
26943
+ if (applied) {
26944
+ view.focus();
26945
+ return;
26946
+ }
26947
+ editor.chain().focus().setCellAttribute("backgroundColor", value).run();
26948
+ }
26861
26949
  var BubbleMenuContent = ({
26862
26950
  editor,
26863
26951
  onKeepOpenChange,
@@ -26882,6 +26970,8 @@ var BubbleMenuContent = ({
26882
26970
  const textStyleAttrs = editor.getAttributes("textStyle");
26883
26971
  const currentTextColor = normalizeStyleValue(textStyleAttrs.color) || "inherit";
26884
26972
  const currentHighlightColor = normalizeStyleValue(editor.getAttributes("highlight").color) || "";
26973
+ const currentCellBgColor = normalizeStyleValue(editor.getAttributes("tableCell").backgroundColor || editor.getAttributes("tableHeader").backgroundColor) || "";
26974
+ const isInTable2 = (0, import_tables.isInTable)(editor.state);
26885
26975
  const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
26886
26976
  const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
26887
26977
  const quickFontSizes = (0, import_react51.useMemo)(
@@ -26939,40 +27029,33 @@ var BubbleMenuContent = ({
26939
27029
  }
26940
27030
  if (activeColorPalette) {
26941
27031
  const isTextPalette = activeColorPalette === "text";
26942
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "w-56", children: [
26943
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
26944
- EditorColorPalette,
26945
- {
26946
- colors: isTextPalette ? textColors : highlightColors,
26947
- currentColor: isTextPalette ? currentTextColor : currentHighlightColor,
26948
- onSelect: (color) => {
26949
- if (isTextPalette) {
26950
- if (color === "inherit") {
26951
- editor.chain().focus().unsetColor().run();
26952
- } else {
26953
- editor.chain().focus().setColor(color).run();
26954
- }
27032
+ const isHighlightPalette = activeColorPalette === "highlight";
27033
+ return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "w-56", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
27034
+ EditorColorPalette,
27035
+ {
27036
+ colors: isTextPalette ? textColors : highlightColors,
27037
+ currentColor: isTextPalette ? currentTextColor : isHighlightPalette ? currentHighlightColor : currentCellBgColor,
27038
+ onSelect: (color) => {
27039
+ if (isTextPalette) {
27040
+ if (color === "inherit") {
27041
+ editor.chain().focus().unsetColor().run();
26955
27042
  } else {
26956
- if (color === "") {
26957
- editor.chain().focus().unsetHighlight().run();
26958
- } else {
26959
- editor.chain().focus().toggleHighlight({ color }).run();
26960
- }
27043
+ editor.chain().focus().setColor(color).run();
26961
27044
  }
26962
- },
26963
- label: isTextPalette ? t("colors.textColor") : t("colors.highlight")
26964
- }
26965
- ),
26966
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "p-2 border-t", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
26967
- "button",
26968
- {
26969
- type: "button",
26970
- onClick: () => setActiveColorPalette(null),
26971
- className: "w-full py-1.5 text-sm rounded-lg hover:bg-muted transition-colors",
26972
- children: t("colors.done")
26973
- }
26974
- ) })
26975
- ] });
27045
+ } else if (isHighlightPalette) {
27046
+ if (color === "") {
27047
+ editor.chain().focus().unsetHighlight().run();
27048
+ } else {
27049
+ editor.chain().focus().toggleHighlight({ color }).run();
27050
+ }
27051
+ } else {
27052
+ applyTableCellBackground(editor, color);
27053
+ }
27054
+ setActiveColorPalette(null);
27055
+ },
27056
+ label: isTextPalette ? t("colors.textColor") : isHighlightPalette ? t("colors.highlight") : t("tableMenu.cellBackground") || "Cell background"
27057
+ }
27058
+ ) });
26976
27059
  }
26977
27060
  if (isImageSelected) {
26978
27061
  return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "flex items-center gap-0.5 p-1", children: [
@@ -27175,7 +27258,7 @@ var BubbleMenuContent = ({
27175
27258
  ),
27176
27259
  /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("text"), title: t("colors.textColor"), children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(TextColorIcon, { color: currentTextColor }) }),
27177
27260
  /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("highlight"), active: editor.isActive("highlight"), title: t("colors.highlight"), children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(HighlightColorIcon, { color: currentHighlightColor }) }),
27178
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
27261
+ isInTable2 && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("cell-bg"), active: Boolean(currentCellBgColor), title: t("tableMenu.cellBackground") || "Cell background", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(CellBgColorIcon, { color: currentCellBgColor }) }),
27179
27262
  /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
27180
27263
  ToolbarButton,
27181
27264
  {
@@ -32134,11 +32217,16 @@ function TableControls({ editor, containerRef }) {
32134
32217
  const directColumnHandleIndex = directColumnHandle instanceof HTMLElement ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
32135
32218
  const visibleTableWidth2 = Math.min(activeLayout.tableWidth, activeLayout.viewportWidth);
32136
32219
  const visibleTableHeight2 = Math.min(activeLayout.tableHeight, activeLayout.viewportHeight);
32220
+ const isMouseInTable = relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + activeLayout.tableWidth && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + activeLayout.tableHeight;
32137
32221
  const rowHandleIndex = Number.isFinite(directRowHandleIndex) ? directRowHandleIndex : activeLayout.rowHandles.find((rowHandle) => relativeX >= activeLayout.tableLeft - ROW_HANDLE_HOVER_WIDTH && relativeX <= activeLayout.tableLeft && Math.abs(relativeY - rowHandle.center) <= HANDLE_HOVER_RADIUS)?.index ?? null;
32138
32222
  const columnHandleIndex = Number.isFinite(directColumnHandleIndex) ? directColumnHandleIndex : activeLayout.columnHandles.find((columnHandle) => relativeY >= activeLayout.tableTop - COLUMN_HANDLE_HOVER_HEIGHT && relativeY <= activeLayout.tableTop && Math.abs(relativeX - columnHandle.center) <= HANDLE_HOVER_RADIUS)?.index ?? null;
32139
- const menuVisible = Boolean(directTableMenu) || relativeX >= activeLayout.tableLeft - MENU_HOVER_PADDING && relativeX <= activeLayout.tableLeft + 42 && relativeY >= activeLayout.tableTop - COLUMN_HANDLE_HOVER_HEIGHT && relativeY <= activeLayout.tableTop + MENU_HOVER_PADDING;
32140
- const addColumnVisible = Boolean(directAddColumn) || relativeX >= activeLayout.tableLeft + visibleTableWidth2 && relativeX <= activeLayout.tableLeft + visibleTableWidth2 + ADD_COLUMN_HOVER_WIDTH && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + visibleTableHeight2;
32141
- const addRowVisible = Boolean(directAddRow) || relativeY >= activeLayout.tableTop + visibleTableHeight2 && relativeY <= activeLayout.tableTop + visibleTableHeight2 + ADD_ROW_HOVER_HEIGHT && relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + visibleTableWidth2;
32223
+ const menuVisible = Boolean(directTableMenu) || isMouseInTable || relativeX >= activeLayout.tableLeft - MENU_HOVER_PADDING && relativeX <= activeLayout.tableLeft + 42 && relativeY >= activeLayout.tableTop - COLUMN_HANDLE_HOVER_HEIGHT && relativeY <= activeLayout.tableTop + MENU_HOVER_PADDING;
32224
+ const lastRow = activeLayout.rowHandles[activeLayout.rowHandles.length - 1];
32225
+ const lastCol = activeLayout.columnHandles[activeLayout.columnHandles.length - 1];
32226
+ const isMouseInLastColumn = lastCol ? relativeX >= lastCol.start && relativeX <= lastCol.start + lastCol.size && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + visibleTableHeight2 : false;
32227
+ const addColumnVisible = Boolean(directAddColumn) || relativeX >= activeLayout.tableLeft + visibleTableWidth2 && relativeX <= activeLayout.tableLeft + visibleTableWidth2 + ADD_COLUMN_HOVER_WIDTH && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + visibleTableHeight2 || isMouseInLastColumn;
32228
+ const isMouseInLastRow = lastRow ? relativeY >= lastRow.start && relativeY <= lastRow.start + lastRow.size && relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + visibleTableWidth2 : false;
32229
+ const addRowVisible = Boolean(directAddRow) || relativeY >= activeLayout.tableTop + visibleTableHeight2 && relativeY <= activeLayout.tableTop + visibleTableHeight2 + ADD_ROW_HOVER_HEIGHT && relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + visibleTableWidth2 || isMouseInLastRow;
32142
32230
  setHoverState((prev) => {
32143
32231
  if (prev.menuVisible === menuVisible && prev.addColumnVisible === addColumnVisible && prev.addRowVisible === addRowVisible && prev.rowHandleIndex === rowHandleIndex && prev.columnHandleIndex === columnHandleIndex) {
32144
32232
  return prev;