Skip to content

Commit 98667c5

Browse files
authored
Merge pull request #4 from PriDebnath/feat/tiptap/toolbar
Feat/tiptap/toolbar
2 parents bcda7cb + 251e271 commit 98667c5

24 files changed

Lines changed: 3288 additions & 14 deletions

‎frontend/package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"preview": "vite preview"
1414
},
1515
"dependencies": {
16+
"@floating-ui/react": "^0.27.16",
1617
"@radix-ui/react-dialog": "^1.1.15",
1718
"@radix-ui/react-label": "^2.1.8",
1819
"@radix-ui/react-slot": "^1.2.4",
@@ -40,6 +41,7 @@
4041
"eslint-plugin-react-hooks": "^7.0.1",
4142
"eslint-plugin-react-refresh": "^0.4.24",
4243
"globals": "^16.5.0",
44+
"sass-embedded": "^1.97.2",
4345
"tw-animate-css": "^1.4.0",
4446
"typescript": "~5.9.3",
4547
"typescript-eslint": "^8.46.4",

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import StarterKit from '@tiptap/starter-kit'
22
import { useEditor, EditorContent } from '@tiptap/react'
33
import { FloatingMenu, BubbleMenu } from '@tiptap/react/menus'
4+
import { BatteryFull, List } from 'lucide-react'
5+
import TiptapToolbar from '@/components/common/tiptap-toolbar'
46

57

68
interface Props {
@@ -22,9 +24,20 @@ const Tiptap = (props: Props) => {
2224

2325
return (
2426
<div>
27+
<button
28+
onClick={() => {
29+
console.log('can toggle:', editor.can().toggleBulletList())
30+
editor.chain().focus().toggleBulletList().run()
31+
console.log(editor.getHTML())
32+
}}
33+
>
34+
<List />
35+
36+
</button>
37+
<TiptapToolbar editor={editor}/>
2538
<EditorContent editor={editor} />
26-
<FloatingMenu editor={editor}>This is the floating menu</FloatingMenu>
27-
<BubbleMenu editor={editor}>This is the bubble menu</BubbleMenu>
39+
{/* <FloatingMenu editor={editor}>This is the floating menu</FloatingMenu>
40+
<BubbleMenu editor={editor}>This is the bubble menu</BubbleMenu> */}
2841
</div>
2942
)
3043
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Toolbar, ToolbarGroup, ToolbarSeparator } from '@/components/tiptap-ui-primitive/toolbar'
2+
import { Button } from '@/components/tiptap-ui-primitive/button'
3+
import { BoldIcon, ItalicIcon } from 'lucide-react'
4+
import type { Editor } from '@tiptap/react'
5+
// import { BoldIcon } from '@/components/icons/bold-icon'
6+
// import { ItalicIcon } from '@/components/icons/italic-icon'
7+
// import { Spacer } from '@/components/tiptap-ui-primitive/spacer'
8+
interface Props {
9+
editor: Editor
10+
}
11+
export default function TiptapToolbar(props: Props) {
12+
let { editor } = props
13+
return (
14+
<Toolbar variant='floating' >
15+
<ToolbarGroup>
16+
<Button data-style="ghost"
17+
onClick={() => {
18+
console.log('can toggle:', editor.can().toggleBulletList())
19+
editor.chain().focus().toggleBold().run()
20+
console.log(editor.getHTML())
21+
}}>
22+
<BoldIcon className="tiptap-button-icon" />
23+
</Button>
24+
<Button data-style="ghost">
25+
<ItalicIcon className="tiptap-button-icon" />
26+
</Button>
27+
</ToolbarGroup>
28+
29+
<ToolbarSeparator />
30+
31+
<ToolbarGroup>
32+
<Button data-style="ghost">Format</Button>
33+
</ToolbarGroup>
34+
35+
{/* <Spacer /> */}
36+
37+
<ToolbarGroup>
38+
<Button data-style="primary">Save</Button>
39+
</ToolbarGroup>
40+
</Toolbar>
41+
)
42+
}

0 commit comments

Comments
 (0)