Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(editor): add table row/column controls to the bubble menu

Andrejadde63db46b6
diff --git a/apps/web/src/components/activity/comment-editor.tsx b/apps/web/src/components/activity/comment-editor.tsx
index d02813eff..3ee5c14de 100644
--- a/apps/web/src/components/activity/comment-editor.tsx
+++ b/apps/web/src/components/activity/comment-editor.tsx
@@ -14,16 +14,23 @@ import { EditorContent, useEditor } from "@tiptap/react";
import { BubbleMenu } from "@tiptap/react/menus";
import StarterKit from "@tiptap/starter-kit";
import {
+ BetweenHorizontalEnd,
+ BetweenHorizontalStart,
+ BetweenVerticalEnd,
+ BetweenVerticalStart,
Bold,
Check,
ChevronDown,
+ Columns3,
Copy,
+ Grid2x2X,
Italic,
Link2,
List,
ListOrdered,
ListTodo,
Paperclip,
+ Rows3,
UnderlineIcon,
} from "lucide-react";
import type { MouseEvent as ReactMouseEvent } from "react";
@@ -1611,6 +1618,112 @@ export default function CommentEditor({
</Button>
</BubbleMenu>
)}
+ {editor && !readOnly && !disabled && showBubbleMenu && (
+ <BubbleMenu
+ editor={editor}
+ pluginKey="kaneo-comment-table-bubble"
+ className="kaneo-comment-editor-bubble"
+ shouldShow={({ editor: activeEditor, from, to }) =>
+ activeEditor.isActive("table") && from === to
+ }
+ >
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-comment-editor-bubble-btn"
+ title={t("activity:comment.editor.table.addColumnBefore", {
+ defaultValue: "Insert column left",
+ })}
+ onClick={() => editor.chain().focus().addColumnBefore().run()}
+ >
+ <BetweenVerticalStart className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-comment-editor-bubble-btn"
+ title={t("activity:comment.editor.table.addColumnAfter", {
+ defaultValue: "Insert column right",
+ })}
+ onClick={() => editor.chain().focus().addColumnAfter().run()}
+ >
+ <BetweenVerticalEnd className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className={cn(
+ "kaneo-comment-editor-bubble-btn",
+ "text-destructive",
+ )}
+ title={t("activity:comment.editor.table.deleteColumn", {
+ defaultValue: "Delete column",
+ })}
+ onClick={() => editor.chain().focus().deleteColumn().run()}
+ >
+ <Columns3 className="size-3.5" />
+ </Button>
+ <span className="kaneo-tiptap-bubble-separator" />
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-comment-editor-bubble-btn"
+ title={t("activity:comment.editor.table.addRowBefore", {
+ defaultValue: "Insert row above",
+ })}
+ onClick={() => editor.chain().focus().addRowBefore().run()}
+ >
+ <BetweenHorizontalStart className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-comment-editor-bubble-btn"
+ title={t("activity:comment.editor.table.addRowAfter", {
+ defaultValue: "Insert row below",
+ })}
+ onClick={() => editor.chain().focus().addRowAfter().run()}
+ >
+ <BetweenHorizontalEnd className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className={cn(
+ "kaneo-comment-editor-bubble-btn",
+ "text-destructive",
+ )}
+ title={t("activity:comment.editor.table.deleteRow", {
+ defaultValue: "Delete row",
+ })}
+ onClick={() => editor.chain().focus().deleteRow().run()}
+ >
+ <Rows3 className="size-3.5" />
+ </Button>
+ <span className="kaneo-tiptap-bubble-separator" />
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className={cn(
+ "kaneo-comment-editor-bubble-btn",
+ "text-destructive",
+ )}
+ title={t("activity:comment.editor.table.deleteTable", {
+ defaultValue: "Delete table",
+ })}
+ onClick={() => editor.chain().focus().deleteTable().run()}
+ >
+ <Grid2x2X className="size-3.5" />
+ </Button>
+ </BubbleMenu>
+ )}
{slashMenu && !readOnly && !disabled && (
<div
className="kaneo-tiptap-slash-menu"
diff --git a/apps/web/src/components/task/task-description.tsx b/apps/web/src/components/task/task-description.tsx
index 9697b0576..f10871bd4 100644
--- a/apps/web/src/components/task/task-description.tsx
+++ b/apps/web/src/components/task/task-description.tsx
@@ -14,12 +14,18 @@ import { EditorContent, useEditor } from "@tiptap/react";
import { BubbleMenu } from "@tiptap/react/menus";
import StarterKit from "@tiptap/starter-kit";
import {
+ BetweenHorizontalEnd,
+ BetweenHorizontalStart,
+ BetweenVerticalEnd,
+ BetweenVerticalStart,
Bold,
Braces,
Check,
ChevronDown,
Code,
+ Columns3,
Copy,
+ Grid2x2X,
Heading2,
Italic,
Link2,
@@ -28,6 +34,7 @@ import {
ListTodo,
Paperclip,
Quote,
+ Rows3,
Strikethrough,
Table2,
Underline as UnderlineIcon,
@@ -1609,6 +1616,104 @@ export default function TaskDescription({ taskId }: TaskDescriptionProps) {
</BubbleMenu>
)}
+ {editor && (
+ <BubbleMenu
+ editor={editor}
+ pluginKey="kaneo-table-bubble"
+ className="kaneo-tiptap-bubble"
+ shouldShow={({ editor: activeEditor, from, to }) =>
+ activeEditor.isActive("table") && from === to
+ }
+ >
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-tiptap-bubble-btn"
+ title={t("tasks:editor.table.addColumnBefore", {
+ defaultValue: "Insert column left",
+ })}
+ onClick={() => editor.chain().focus().addColumnBefore().run()}
+ >
+ <BetweenVerticalStart className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-tiptap-bubble-btn"
+ title={t("tasks:editor.table.addColumnAfter", {
+ defaultValue: "Insert column right",
+ })}
+ onClick={() => editor.chain().focus().addColumnAfter().run()}
+ >
+ <BetweenVerticalEnd className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className={cn("kaneo-tiptap-bubble-btn", "text-destructive")}
+ title={t("tasks:editor.table.deleteColumn", {
+ defaultValue: "Delete column",
+ })}
+ onClick={() => editor.chain().focus().deleteColumn().run()}
+ >
+ <Columns3 className="size-3.5" />
+ </Button>
+ <span className="kaneo-tiptap-bubble-separator" />
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-tiptap-bubble-btn"
+ title={t("tasks:editor.table.addRowBefore", {
+ defaultValue: "Insert row above",
+ })}
+ onClick={() => editor.chain().focus().addRowBefore().run()}
+ >
+ <BetweenHorizontalStart className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className="kaneo-tiptap-bubble-btn"
+ title={t("tasks:editor.table.addRowAfter", {
+ defaultValue: "Insert row below",
+ })}
+ onClick={() => editor.chain().focus().addRowAfter().run()}
+ >
+ <BetweenHorizontalEnd className="size-3.5" />
+ </Button>
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className={cn("kaneo-tiptap-bubble-btn", "text-destructive")}
+ title={t("tasks:editor.table.deleteRow", {
+ defaultValue: "Delete row",
+ })}
+ onClick={() => editor.chain().focus().deleteRow().run()}
+ >
+ <Rows3 className="size-3.5" />
+ </Button>
+ <span className="kaneo-tiptap-bubble-separator" />
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ className={cn("kaneo-tiptap-bubble-btn", "text-destructive")}
+ title={t("tasks:editor.table.deleteTable", {
+ defaultValue: "Delete table",
+ })}
+ onClick={() => editor.chain().focus().deleteTable().run()}
+ >
+ <Grid2x2X className="size-3.5" />
+ </Button>
+ </BubbleMenu>
+ )}
+
{editor && slashMenu && (
<div
className="kaneo-tiptap-slash-menu"