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

Version Path
ariadne_view_components-0.0.17-x86_64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.17-x86_64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.17-x64-mingw32 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.17-x64-mingw-ucrt app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.17-arm64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.17-aarch64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.17 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.16-x86_64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.16-x86_64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.16-x64-mingw32 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.16-x64-mingw-ucrt app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.16-arm64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.16-aarch64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.16 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.15-x86_64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.15-x86_64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.15-x64-mingw32 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.15-x64-mingw-ucrt app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.15-arm64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.15-aarch64-linux app/components/ariadne/rich-text-area-component.ts