import type { ContentEditorTextStyle } from './content-editor-text-style' import type { Editor } from '@tiptap/react' export function applyContentEditorTextStyle(editor: Editor, style: ContentEditorTextStyle) { const chain = editor.chain().focus() switch (style) { case 'paragraph': chain.clearNodes().setParagraph().run() return case 'heading-1': chain.clearNodes().setHeading({ level: 1 }).run() return case 'heading-2': chain.clearNodes().setHeading({ level: 2 }).run() return case 'heading-3': chain.clearNodes().setHeading({ level: 3 }).run() return case 'bullet-list': chain.toggleBulletList().run() return case 'ordered-list': chain.toggleOrderedList().run() return case 'task-list': chain.toggleTaskList().run() return case 'blockquote': chain.toggleBlockquote().run() return case 'code-block': chain.toggleCodeBlock().run() return case 'divider': chain.setHorizontalRule().run() } }