<template>
    <bubble-menu v-if="editor" :editor="editor">
        <div class="note-menu">
            <button
                @click="editor.chain().focus().toggleBold().run()"
                :class="{ active: editor.isActive('bold') }"
            >
                Bold
            </button>
            <button
                @click="editor.chain().focus().toggleItalic().run()"
                :class="{ active: editor.isActive('italic') }"
            >
                Italic
            </button>
            <button
                @click="editor.chain().focus().toggleHighlight().run()"
                :class="{ active: editor.isActive('highlight') }"
            >
                Highlight
            </button>
        </div>
    </bubble-menu>
</template>

<script setup>
import { BubbleMenu } from '@tiptap/vue-3/menus'

const props = defineProps({
    editor: {
        type: Object,
        required: true,
    },
})
</script>

<style lang="scss">
.note-menu {
    display: flex;
    gap: 5px;
    border: 1px solid var(--grey-100);
    color: var(--grey-100);
    border-radius: 0.2em;
    background: var(--theme-bg);

    button {
        cursor: pointer;
        padding: 0.2em;
        border-radius: 0.2em;

        &:hover {
            background: var(--grey-100);
            color: var(--theme-bg);
        }
        &.active {
            background: var(--theme-fg);
            color: var(--theme-bg);
        }
    }
}
</style>
