import './styles.scss'
import Highlight from '@tiptap/extension-highlight'
import TextAlign from '@tiptap/extension-text-align'
import { EditorContent, useEditor } from '@tiptap/react'
import StarterKit from '@tiptap/starter-kit'
import React from 'react'
const MenuBar = ({ editor }) => {
if (!editor) {
return null
}
return (
<>
editor.chain().focus().toggleHeading({ level: 1 }).run()} className={editor.isActive('heading', { level: 1 }) ? 'is-active' : ''}>
h1
editor.chain().focus().toggleHeading({ level: 2 }).run()} className={editor.isActive('heading', { level: 2 }) ? 'is-active' : ''}>
h2
editor.chain().focus().toggleHeading({ level: 3 }).run()} className={editor.isActive('heading', { level: 3 }) ? 'is-active' : ''}>
h3
editor.chain().focus().setParagraph().run()} className={editor.isActive('paragraph') ? 'is-active' : ''}>
paragraph
editor.chain().focus().toggleBold().run()} className={editor.isActive('bold') ? 'is-active' : ''}>
bold
editor.chain().focus().toggleItalic().run()} className={editor.isActive('italic') ? 'is-active' : ''}>
italic
editor.chain().focus().toggleStrike().run()} className={editor.isActive('strike') ? 'is-active' : ''}>
strike
editor.chain().focus().toggleHighlight().run()} className={editor.isActive('highlight') ? 'is-active' : ''}>
highlight
editor.chain().focus().setTextAlign('left').run()} className={editor.isActive({ textAlign: 'left' }) ? 'is-active' : ''}>
left
editor.chain().focus().setTextAlign('center').run()} className={editor.isActive({ textAlign: 'center' }) ? 'is-active' : ''}>
center
editor.chain().focus().setTextAlign('right').run()} className={editor.isActive({ textAlign: 'right' }) ? 'is-active' : ''}>
right
editor.chain().focus().setTextAlign('justify').run()} className={editor.isActive({ textAlign: 'justify' }) ? 'is-active' : ''}>
justify
>
)
}
export default () => {
const editor = useEditor({
extensions: [
StarterKit,
TextAlign.configure({
types: ['heading', 'paragraph'],
}),
Highlight,
],
content: `
Devs Just Want to Have Fun by Cyndi Lauper
I come home in the morning light
My mother says, “When you gonna live your life right?”
Oh mother dear we’re not the fortunate ones
And devs, they wanna have fun
Oh devs just want to have fun
The phone rings in the middle of the night
My father yells, "What you gonna do with your life?"
Oh daddy dear, you know you’re still number one
But girls devs, they wanna have fun
Oh devs just want to have
That’s all they really want
Some fun
When the working day is done
Oh devs, they wanna have fun
Oh devs just wanna have fun
(devs, they wanna, wanna have fun, devs wanna have)
`,
})
return (
)
}