Sha256: bd8e5cf667a52d8d21176d7c16258837a13a1f299515146246595b2c4db8e8ae

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 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 === null || parentForm === void 0 ? void 0 : parentForm.addEventListener('submit', () => {
                    tiptapValueContainer.setAttribute('value', editorElement.textContent || '');
                });
            }
        }
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.17 app/components/ariadne/rich-text-area-component.js
ariadne_view_components-0.0.16 app/components/ariadne/rich-text-area-component.js
ariadne_view_components-0.0.15 app/components/ariadne/rich-text-area-component.js