@underverse-ui/underverse 1.0.128 → 1.0.129

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.d.cts CHANGED
@@ -3576,6 +3576,7 @@ declare const underverseMessages: {
3576
3576
  alignLeft: string;
3577
3577
  alignCenter: string;
3578
3578
  alignRight: string;
3579
+ cellBackground: string;
3579
3580
  };
3580
3581
  };
3581
3582
  };
@@ -3843,6 +3844,7 @@ declare const underverseMessages: {
3843
3844
  alignLeft: string;
3844
3845
  alignCenter: string;
3845
3846
  alignRight: string;
3847
+ cellBackground: string;
3846
3848
  };
3847
3849
  };
3848
3850
  };
@@ -4109,6 +4111,7 @@ declare const underverseMessages: {
4109
4111
  alignLeft: string;
4110
4112
  alignCenter: string;
4111
4113
  alignRight: string;
4114
+ cellBackground: string;
4112
4115
  };
4113
4116
  };
4114
4117
  };
@@ -4375,6 +4378,7 @@ declare const underverseMessages: {
4375
4378
  alignLeft: string;
4376
4379
  alignCenter: string;
4377
4380
  alignRight: string;
4381
+ cellBackground: string;
4378
4382
  };
4379
4383
  };
4380
4384
  };
@@ -4645,6 +4649,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
4645
4649
  alignLeft: string;
4646
4650
  alignCenter: string;
4647
4651
  alignRight: string;
4652
+ cellBackground: string;
4648
4653
  };
4649
4654
  };
4650
4655
  } | {
@@ -4911,6 +4916,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
4911
4916
  alignLeft: string;
4912
4917
  alignCenter: string;
4913
4918
  alignRight: string;
4919
+ cellBackground: string;
4914
4920
  };
4915
4921
  };
4916
4922
  } | {
@@ -5176,6 +5182,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
5176
5182
  alignLeft: string;
5177
5183
  alignCenter: string;
5178
5184
  alignRight: string;
5185
+ cellBackground: string;
5179
5186
  };
5180
5187
  };
5181
5188
  } | {
@@ -5441,6 +5448,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
5441
5448
  alignLeft: string;
5442
5449
  alignCenter: string;
5443
5450
  alignRight: string;
5451
+ cellBackground: string;
5444
5452
  };
5445
5453
  };
5446
5454
  };
package/dist/index.d.ts CHANGED
@@ -3576,6 +3576,7 @@ declare const underverseMessages: {
3576
3576
  alignLeft: string;
3577
3577
  alignCenter: string;
3578
3578
  alignRight: string;
3579
+ cellBackground: string;
3579
3580
  };
3580
3581
  };
3581
3582
  };
@@ -3843,6 +3844,7 @@ declare const underverseMessages: {
3843
3844
  alignLeft: string;
3844
3845
  alignCenter: string;
3845
3846
  alignRight: string;
3847
+ cellBackground: string;
3846
3848
  };
3847
3849
  };
3848
3850
  };
@@ -4109,6 +4111,7 @@ declare const underverseMessages: {
4109
4111
  alignLeft: string;
4110
4112
  alignCenter: string;
4111
4113
  alignRight: string;
4114
+ cellBackground: string;
4112
4115
  };
4113
4116
  };
4114
4117
  };
@@ -4375,6 +4378,7 @@ declare const underverseMessages: {
4375
4378
  alignLeft: string;
4376
4379
  alignCenter: string;
4377
4380
  alignRight: string;
4381
+ cellBackground: string;
4378
4382
  };
4379
4383
  };
4380
4384
  };
@@ -4645,6 +4649,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
4645
4649
  alignLeft: string;
4646
4650
  alignCenter: string;
4647
4651
  alignRight: string;
4652
+ cellBackground: string;
4648
4653
  };
4649
4654
  };
4650
4655
  } | {
@@ -4911,6 +4916,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
4911
4916
  alignLeft: string;
4912
4917
  alignCenter: string;
4913
4918
  alignRight: string;
4919
+ cellBackground: string;
4914
4920
  };
4915
4921
  };
4916
4922
  } | {
@@ -5176,6 +5182,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
5176
5182
  alignLeft: string;
5177
5183
  alignCenter: string;
5178
5184
  alignRight: string;
5185
+ cellBackground: string;
5179
5186
  };
5180
5187
  };
5181
5188
  } | {
@@ -5441,6 +5448,7 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
5441
5448
  alignLeft: string;
5442
5449
  alignCenter: string;
5443
5450
  alignRight: string;
5451
+ cellBackground: string;
5444
5452
  };
5445
5453
  };
5446
5454
  };
package/dist/index.js CHANGED
@@ -828,7 +828,8 @@ var en_default = {
828
828
  dragColumn: "Drag Column",
829
829
  alignLeft: "Align Table Left",
830
830
  alignCenter: "Align Table Center",
831
- alignRight: "Align Table Right"
831
+ alignRight: "Align Table Right",
832
+ cellBackground: "Cell Background"
832
833
  }
833
834
  }
834
835
  };
@@ -1097,7 +1098,8 @@ var vi_default = {
1097
1098
  dragColumn: "K\xE9o c\u1ED9t",
1098
1099
  alignLeft: "C\u0103n b\u1EA3ng tr\xE1i",
1099
1100
  alignCenter: "C\u0103n b\u1EA3ng gi\u1EEFa",
1100
- alignRight: "C\u0103n b\u1EA3ng ph\u1EA3i"
1101
+ alignRight: "C\u0103n b\u1EA3ng ph\u1EA3i",
1102
+ cellBackground: "M\xE0u n\u1EC1n \xF4"
1101
1103
  }
1102
1104
  }
1103
1105
  };
@@ -1365,7 +1367,8 @@ var ko_default = {
1365
1367
  dragColumn: "\uC5F4 \uB4DC\uB798\uADF8",
1366
1368
  alignLeft: "\uD45C \uC67C\uCABD \uC815\uB82C",
1367
1369
  alignCenter: "\uD45C \uAC00\uC6B4\uB370 \uC815\uB82C",
1368
- alignRight: "\uD45C \uC624\uB978\uCABD \uC815\uB82C"
1370
+ alignRight: "\uD45C \uC624\uB978\uCABD \uC815\uB82C",
1371
+ cellBackground: "\uC140 \uBC30\uACBD\uC0C9"
1369
1372
  }
1370
1373
  }
1371
1374
  };
@@ -1633,7 +1636,8 @@ var ja_default = {
1633
1636
  dragColumn: "\u5217\u3092\u30C9\u30E9\u30C3\u30B0",
1634
1637
  alignLeft: "\u8868\u3092\u5DE6\u5BC4\u305B",
1635
1638
  alignCenter: "\u8868\u3092\u4E2D\u592E\u63C3\u3048",
1636
- alignRight: "\u8868\u3092\u53F3\u5BC4\u305B"
1639
+ alignRight: "\u8868\u3092\u53F3\u5BC4\u305B",
1640
+ cellBackground: "\u30BB\u30EB\u80CC\u666F\u8272"
1637
1641
  }
1638
1642
  }
1639
1643
  };
@@ -23836,6 +23840,7 @@ import React78, { useEffect as useEffect36, useImperativeHandle as useImperative
23836
23840
  import { useEditor, EditorContent } from "@tiptap/react";
23837
23841
 
23838
23842
  // src/components/UEditor/extensions.ts
23843
+ import { mergeAttributes as mergeAttributes2 } from "@tiptap/core";
23839
23844
  import Document from "@tiptap/extension-document";
23840
23845
  import Paragraph from "@tiptap/extension-paragraph";
23841
23846
  import Text from "@tiptap/extension-text";
@@ -25161,6 +25166,64 @@ var UEditorTable = Table3.extend({
25161
25166
  var table_align_default = UEditorTable;
25162
25167
 
25163
25168
  // src/components/UEditor/extensions.ts
25169
+ var CustomTableCell = TableCell2.extend({
25170
+ addAttributes() {
25171
+ return {
25172
+ ...this.parent?.(),
25173
+ backgroundColor: {
25174
+ default: null,
25175
+ parseHTML: (element) => element.style.backgroundColor || element.getAttribute("data-background-color") || null,
25176
+ renderHTML: (attributes) => {
25177
+ if (!attributes.backgroundColor) {
25178
+ return {};
25179
+ }
25180
+ return {
25181
+ "data-background-color": attributes.backgroundColor
25182
+ };
25183
+ }
25184
+ }
25185
+ };
25186
+ },
25187
+ renderHTML({ HTMLAttributes }) {
25188
+ const style = HTMLAttributes.style || "";
25189
+ const bg = HTMLAttributes["data-background-color"];
25190
+ const mergedStyle = bg ? `${style}; background-color: ${bg}`.replace(/^;/, "") : style;
25191
+ return [
25192
+ "td",
25193
+ mergeAttributes2(this.options.HTMLAttributes, HTMLAttributes, mergedStyle ? { style: mergedStyle } : {}),
25194
+ 0
25195
+ ];
25196
+ }
25197
+ });
25198
+ var CustomTableHeader = TableHeader2.extend({
25199
+ addAttributes() {
25200
+ return {
25201
+ ...this.parent?.(),
25202
+ backgroundColor: {
25203
+ default: null,
25204
+ parseHTML: (element) => element.style.backgroundColor || element.getAttribute("data-background-color") || null,
25205
+ renderHTML: (attributes) => {
25206
+ if (!attributes.backgroundColor) {
25207
+ return {};
25208
+ }
25209
+ return {
25210
+ "data-background-color": attributes.backgroundColor
25211
+ };
25212
+ }
25213
+ }
25214
+ };
25215
+ },
25216
+ renderHTML({ HTMLAttributes }) {
25217
+ const style = HTMLAttributes.style || "";
25218
+ const bg = HTMLAttributes["data-background-color"];
25219
+ const mergedStyle = bg ? `${style}; background-color: ${bg}`.replace(/^;/, "") : style;
25220
+ return [
25221
+ "th",
25222
+ mergeAttributes2(this.options.HTMLAttributes, HTMLAttributes, mergedStyle ? { style: mergedStyle } : {}),
25223
+ 0
25224
+ ];
25225
+ }
25226
+ });
25164
25227
  var lowlight = createLowlight(common);
25165
25228
  function buildUEditorExtensions({
25166
25229
  placeholder,
@@ -25259,12 +25322,12 @@ function buildUEditorExtensions({
25259
25322
  }
25260
25323
  }),
25261
25324
  table_row_default,
25262
- TableCell2.configure({
25325
+ CustomTableCell.configure({
25263
25326
  HTMLAttributes: {
25264
25327
  class: "border border-border p-2 min-w-25"
25265
25328
  }
25266
25329
  }),
25267
- TableHeader2.configure({
25330
+ CustomTableHeader.configure({
25268
25331
  HTMLAttributes: {
25269
25332
  class: "border border-border p-2 bg-muted font-semibold min-w-25"
25270
25333
  }
@@ -25340,7 +25403,7 @@ import {
25340
25403
 
25341
25404
  // src/components/UEditor/colors.tsx
25342
25405
  import { useMemo as useMemo22, useRef as useRef29 } from "react";
25343
- import { Check as Check10, Highlighter, Palette as Palette2 } from "lucide-react";
25406
+ import { Check as Check10, Highlighter, Palette as Palette2, Paintbrush } from "lucide-react";
25344
25407
  import { jsx as jsx78, jsxs as jsxs65 } from "react/jsx-runtime";
25345
25408
  var TextColorIcon = ({ color }) => {
25346
25409
  const underlineColor = color && color !== "inherit" ? color : "currentColor";
@@ -25370,6 +25433,20 @@ var HighlightColorIcon = ({ color }) => {
25370
25433
  )
25371
25434
  ] });
25372
25435
  };
25436
+ var CellBgColorIcon = ({ color }) => {
25437
+ const underlineColor = color && color !== "inherit" ? color : "currentColor";
25438
+ return /* @__PURE__ */ jsxs65("span", { className: "relative flex h-5 w-5 items-center justify-center leading-none", children: [
25439
+ /* @__PURE__ */ jsx78(Paintbrush, { className: "h-4 w-4" }),
25440
+ /* @__PURE__ */ jsx78(
25441
+ "span",
25442
+ {
25443
+ "aria-hidden": "true",
25444
+ className: "absolute bottom-0 left-1/2 h-0.5 w-4 -translate-x-1/2 rounded-full",
25445
+ style: { backgroundColor: underlineColor }
25446
+ }
25447
+ )
25448
+ ] });
25449
+ };
25373
25450
  var EDITOR_COLOR_SWATCHES = [
25374
25451
  "#000000",
25375
25452
  "#3f3f46",
@@ -26682,6 +26759,7 @@ var EditorToolbar = ({
26682
26759
  // src/components/UEditor/menus.tsx
26683
26760
  import { useCallback as useCallback22, useEffect as useEffect34, useMemo as useMemo23, useRef as useRef32, useState as useState45 } from "react";
26684
26761
  import { useEditorState as useEditorState2 } from "@tiptap/react";
26762
+ import { isInTable as isSelectionInTable, setCellAttr } from "@tiptap/pm/tables";
26685
26763
  import { createPortal as createPortal8 } from "react-dom";
26686
26764
  import {
26687
26765
  AlignCenter as AlignCenter2,
@@ -26754,6 +26832,16 @@ var FloatingMenuContent = ({ editor }) => {
26754
26832
  }
26755
26833
  );
26756
26834
  };
26835
+ function applyTableCellBackground(editor, color) {
26836
+ const value = color || null;
26837
+ const { state, view } = editor;
26838
+ const applied = setCellAttr("backgroundColor", value)(state, view.dispatch.bind(view));
26839
+ if (applied) {
26840
+ view.focus();
26841
+ return;
26842
+ }
26843
+ editor.chain().focus().setCellAttribute("backgroundColor", value).run();
26844
+ }
26757
26845
  var BubbleMenuContent = ({
26758
26846
  editor,
26759
26847
  onKeepOpenChange,
@@ -26778,6 +26866,8 @@ var BubbleMenuContent = ({
26778
26866
  const textStyleAttrs = editor.getAttributes("textStyle");
26779
26867
  const currentTextColor = normalizeStyleValue(textStyleAttrs.color) || "inherit";
26780
26868
  const currentHighlightColor = normalizeStyleValue(editor.getAttributes("highlight").color) || "";
26869
+ const currentCellBgColor = normalizeStyleValue(editor.getAttributes("tableCell").backgroundColor || editor.getAttributes("tableHeader").backgroundColor) || "";
26870
+ const isInTable2 = isSelectionInTable(editor.state);
26781
26871
  const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
26782
26872
  const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
26783
26873
  const quickFontSizes = useMemo23(
@@ -26835,12 +26925,13 @@ var BubbleMenuContent = ({
26835
26925
  }
26836
26926
  if (activeColorPalette) {
26837
26927
  const isTextPalette = activeColorPalette === "text";
26928
+ const isHighlightPalette = activeColorPalette === "highlight";
26838
26929
  return /* @__PURE__ */ jsxs68("div", { className: "w-56", children: [
26839
26930
  /* @__PURE__ */ jsx82(
26840
26931
  EditorColorPalette,
26841
26932
  {
26842
26933
  colors: isTextPalette ? textColors : highlightColors,
26843
- currentColor: isTextPalette ? currentTextColor : currentHighlightColor,
26934
+ currentColor: isTextPalette ? currentTextColor : isHighlightPalette ? currentHighlightColor : currentCellBgColor,
26844
26935
  onSelect: (color) => {
26845
26936
  if (isTextPalette) {
26846
26937
  if (color === "inherit") {
@@ -26848,15 +26939,17 @@ var BubbleMenuContent = ({
26848
26939
  } else {
26849
26940
  editor.chain().focus().setColor(color).run();
26850
26941
  }
26851
- } else {
26942
+ } else if (isHighlightPalette) {
26852
26943
  if (color === "") {
26853
26944
  editor.chain().focus().unsetHighlight().run();
26854
26945
  } else {
26855
26946
  editor.chain().focus().toggleHighlight({ color }).run();
26856
26947
  }
26948
+ } else {
26949
+ applyTableCellBackground(editor, color);
26857
26950
  }
26858
26951
  },
26859
- label: isTextPalette ? t("colors.textColor") : t("colors.highlight")
26952
+ label: isTextPalette ? t("colors.textColor") : isHighlightPalette ? t("colors.highlight") : t("tableMenu.cellBackground") || "Cell background"
26860
26953
  }
26861
26954
  ),
26862
26955
  /* @__PURE__ */ jsx82("div", { className: "p-2 border-t", children: /* @__PURE__ */ jsx82(
@@ -27071,7 +27164,7 @@ var BubbleMenuContent = ({
27071
27164
  ),
27072
27165
  /* @__PURE__ */ jsx82(ToolbarButton, { onClick: () => setActiveColorPalette("text"), title: t("colors.textColor"), children: /* @__PURE__ */ jsx82(TextColorIcon, { color: currentTextColor }) }),
27073
27166
  /* @__PURE__ */ jsx82(ToolbarButton, { onClick: () => setActiveColorPalette("highlight"), active: editor.isActive("highlight"), title: t("colors.highlight"), children: /* @__PURE__ */ jsx82(HighlightColorIcon, { color: currentHighlightColor }) }),
27074
- /* @__PURE__ */ jsx82("div", { className: "w-px h-6 bg-border/50 mx-1" }),
27167
+ isInTable2 && /* @__PURE__ */ jsx82(ToolbarButton, { onClick: () => setActiveColorPalette("cell-bg"), active: Boolean(currentCellBgColor), title: t("tableMenu.cellBackground") || "Cell background", children: /* @__PURE__ */ jsx82(CellBgColorIcon, { color: currentCellBgColor }) }),
27075
27168
  /* @__PURE__ */ jsx82(
27076
27169
  ToolbarButton,
27077
27170
  {
@@ -32044,11 +32137,16 @@ function TableControls({ editor, containerRef }) {
32044
32137
  const directColumnHandleIndex = directColumnHandle instanceof HTMLElement ? Number.parseInt(directColumnHandle.dataset.columnHandleIndex ?? "", 10) : Number.NaN;
32045
32138
  const visibleTableWidth2 = Math.min(activeLayout.tableWidth, activeLayout.viewportWidth);
32046
32139
  const visibleTableHeight2 = Math.min(activeLayout.tableHeight, activeLayout.viewportHeight);
32140
+ const isMouseInTable = relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + activeLayout.tableWidth && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + activeLayout.tableHeight;
32047
32141
  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;
32048
32142
  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;
32049
- 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;
32050
- const addColumnVisible = Boolean(directAddColumn) || relativeX >= activeLayout.tableLeft + visibleTableWidth2 && relativeX <= activeLayout.tableLeft + visibleTableWidth2 + ADD_COLUMN_HOVER_WIDTH && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + visibleTableHeight2;
32051
- const addRowVisible = Boolean(directAddRow) || relativeY >= activeLayout.tableTop + visibleTableHeight2 && relativeY <= activeLayout.tableTop + visibleTableHeight2 + ADD_ROW_HOVER_HEIGHT && relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + visibleTableWidth2;
32143
+ 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;
32144
+ const lastRow = activeLayout.rowHandles[activeLayout.rowHandles.length - 1];
32145
+ const lastCol = activeLayout.columnHandles[activeLayout.columnHandles.length - 1];
32146
+ const isMouseInLastColumn = lastCol ? relativeX >= lastCol.start && relativeX <= lastCol.start + lastCol.size && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + visibleTableHeight2 : false;
32147
+ const addColumnVisible = Boolean(directAddColumn) || relativeX >= activeLayout.tableLeft + visibleTableWidth2 && relativeX <= activeLayout.tableLeft + visibleTableWidth2 + ADD_COLUMN_HOVER_WIDTH && relativeY >= activeLayout.tableTop && relativeY <= activeLayout.tableTop + visibleTableHeight2 || isMouseInLastColumn;
32148
+ const isMouseInLastRow = lastRow ? relativeY >= lastRow.start && relativeY <= lastRow.start + lastRow.size && relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + visibleTableWidth2 : false;
32149
+ const addRowVisible = Boolean(directAddRow) || relativeY >= activeLayout.tableTop + visibleTableHeight2 && relativeY <= activeLayout.tableTop + visibleTableHeight2 + ADD_ROW_HOVER_HEIGHT && relativeX >= activeLayout.tableLeft && relativeX <= activeLayout.tableLeft + visibleTableWidth2 || isMouseInLastRow;
32052
32150
  setHoverState((prev) => {
32053
32151
  if (prev.menuVisible === menuVisible && prev.addColumnVisible === addColumnVisible && prev.addRowVisible === addRowVisible && prev.rowHandleIndex === rowHandleIndex && prev.columnHandleIndex === columnHandleIndex) {
32054
32152
  return prev;