Sha256: 86d70c1cb3d00eb310acf81c90a537a8cfd610884ed65bbd5471f9f2f288485f

Contents?: true

Size: 1.66 KB

Versions: 78

Compression:

Stored size: 1.66 KB

Contents

import { Controller } from '@hotwired/stimulus';
import { Editor } from '@tiptap/core';
import { Document } from '@tiptap/extension-document';
import { Paragraph } from '@tiptap/extension-paragraph';
import { Text } from '@tiptap/extension-text';
import DropCursor from '@tiptap/extension-dropcursor';
import GapCursor from '@tiptap/extension-gapcursor';
import { History } from '@tiptap/extension-history';
class RichTextArea extends Controller {
    connect() {
        for (const editorElement of this.editorTargets) {
            const pmEditor = new Editor({
                extensions: [DropCursor, GapCursor, History, Document, Paragraph, Text],
                content: '',
                injectCSS: false,
                element: editorElement,
                editorProps: {
                    attributes: {
                        class: 'ariadne-h-28 ariadne-max-h-48 ariadne-p-2 ariadne-rounded-lg ariadne-overflow-y-auto focus:ariadne-outline-none',
                    },
                },
                parseOptions: {
                    preserveWhitespace: true,
                },
            });
            const tiptapValueContainer = editorElement.previousElementSibling;
            if (tiptapValueContainer) {
                const parentForm = editorElement.closest('form');
                parentForm === null || parentForm === void 0 ? void 0 : parentForm.addEventListener('submit', () => {
                    tiptapValueContainer.setAttribute('value', pmEditor.getText() || '');
                    pmEditor.commands.clearContent(); // TODO: test this
                });
            }
        }
    }
}
RichTextArea.targets = ['editor'];
export default RichTextArea;

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.46-aarch64-linux app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.46-x64-mingw-ucrt app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.46 app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.46-x86_64-darwin app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.46-x86_64-linux app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.46-arm64-darwin app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.45-x64-mingw-ucrt app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.45 app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.45-x86_64-darwin app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.45-arm64-darwin app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.45-x86_64-linux app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.45-aarch64-linux app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.44-aarch64-linux app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.44-arm64-darwin app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.44-x86_64-linux app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.44-x86_64-darwin app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.44-x64-mingw-ucrt app/components/ariadne/rich_text_area_component/rich-text-area-component.js
ariadne_view_components-0.0.44 app/components/ariadne/rich_text_area_component/rich-text-area-component.js