import type { StoryObj } from "@storybook/vue3"; import MtTextEditor from "./mt-text-editor.vue"; import type { SlottedMeta } from "@/_internal/story-helper"; import MtTextEditorToolbarButtonColor from "./_internal/mt-text-editor-toolbar-button-color.vue"; import { ref } from "vue"; import Highlight from "@tiptap/extension-highlight"; import { fn } from "@storybook/test"; export type MtTextEditorMeta = SlottedMeta< typeof MtTextEditor, "default" | "click" | "updateModelValue" >; export default { title: "Components/Form/mt-text-editor", component: MtTextEditor, args: { modelValue: `

Hello World

Some text

  1. Lorem

  2. Ipsum

First

Second

Third

Lorem

Ipsum

non

dolor

sit

amet

After table

`, updateModelValue: fn(), label: "My Text editor", }, render: (args) => ({ components: { MtTextEditor, MtTextEditorToolbarButtonColor }, setup() { const currentModelValue = ref(args.modelValue); const onUpdateModelValue = (value: string) => { currentModelValue.value = value; args.updateModelValue(value); }; return { args, currentModelValue, onUpdateModelValue, }; }, template: `
`, }), } as MtTextEditorMeta; export type MtTextEditorStory = StoryObj; export const DefaultStory: MtTextEditorStory = { name: "mt-text-editor", }; export const InlineEditStory: MtTextEditorStory = { name: "mt-text-editor (inline edit)", args: { isInlineEdit: true, }, }; export const CustomButtonsStory: MtTextEditorStory = { name: "mt-text-editor (custom buttons)", args: { modelValue: `

Hello World

In the toolbar you see now a new highlight button.

`, tipTapConfig: { extensions: [Highlight], }, customButtons: [ { name: "highlight", label: "Highlight", icon: "regular-circle-xs", action: (editor) => { editor.chain().focus().toggleMark("highlight").run(); }, }, ], }, };