Sha256: 9b11669d2b98053471d8557f54c0977454924756229c013f85b0ce1725508c74
Contents?: true
Size: 1.06 KB
Versions: 28
Compression:
Stored size: 1.06 KB
Contents
import {Controller} from '@hotwired/stimulus' import {Editor} from '@tiptap/core' import {StarterKit} from '@tiptap/starter-kit' export default class RichTextArea extends Controller { connect() { const editorElements = document.getElementsByClassName('tiptap-editor') for (const editorElement of editorElements) { new Editor({ element: editorElement, extensions: [StarterKit], content: '', editorProps: { attributes: { class: 'ariadne-m-5 focus:ariadne-outline-none ariadne-block ariadne-w-full ariadne-resize-none ariadne-p-0 ariadne-pb-2 ariadne-border-none focus:ariadne-ring-0 sm:ariadne-text-sm' } } }) const tiptapValueContainer = document.querySelector('input[data-tiptap-value-container=true]') if (tiptapValueContainer) { const parentForm = editorElement.closest('form') parentForm?.addEventListener('submit', () => { tiptapValueContainer.setAttribute('value', editorElement.textContent || '') }) } } } }
Version data entries
28 entries across 28 versions & 1 rubygems