Skip to content

Commit 10235a0

Browse files
committed
added table control
1 parent b2f379d commit 10235a0

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎frontend/src/components/common/tiptap-toolbar.tsx‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ export default function TiptapToolbar({ editor }: Props) {
7777
<Toolbar variant="floating"
7878
className="rounded! bg-card flex-wrap gap-1">
7979
{/* TEXT MARKS */}
80+
<ToolbarSeparator />
81+
<TableControls editor={editor}/>
82+
<ToolbarSeparator />
83+
8084
<ToolbarGroup className="" >
8185
<HeadingDropdown editor={editor} />
8286
<FontSizeDropdown editor={editor} />
@@ -169,6 +173,8 @@ export default function TiptapToolbar({ editor }: Props) {
169173
<Button onClick={() => editor.chain().focus().clearContent().run()}><TrashIcon /></Button>
170174
</ToolbarGroup>
171175

176+
177+
172178
</Toolbar>
173179
)
174180
}
@@ -212,6 +218,31 @@ function HeadingDropdown({ editor }: { editor: Editor }) {
212218
)
213219
}
214220

221+
function TableControls({ editor }: { editor: Editor }) {
222+
if (!editor.isActive("table")) return null
223+
224+
return (
225+
<ToolbarGroup>
226+
<Button onClick={() => editor.chain().focus().addRowBefore().run()}>
227+
+Row ↑
228+
</Button>
229+
<Button onClick={() => editor.chain().focus().addRowAfter().run()}>
230+
+Row ↓
231+
</Button>
232+
<Button onClick={() => editor.chain().focus().addColumnBefore().run()}>
233+
+Col ←
234+
</Button>
235+
<Button onClick={() => editor.chain().focus().addColumnAfter().run()}>
236+
+Col →
237+
</Button>
238+
<Button onClick={() => editor.chain().focus().deleteTable().run()}>
239+
Delete
240+
</Button>
241+
</ToolbarGroup>
242+
)
243+
}
244+
245+
215246
const SIZES = [
216247
{ label: "8px", value: "8px" },
217248
{ label: "10px", value: "10px" },

‎frontend/src/index.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ body {
766766
}
767767

768768

769+
770+
771+
772+
769773
.tiptap {
770774
color: hsl(var(--foreground)) !important;
771775
}

0 commit comments

Comments
 (0)