Sha256: d0ebb3b13017228fd8ea8ff1079e349461ce7d75b6614c68606499ac0b5201d7

Contents?: true

Size: 1017 Bytes

Versions: 31

Compression:

Stored size: 1017 Bytes

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 editorElement = document.querySelector('.tiptap-editor')
    if (editorElement) {
      new Editor({
        element: editorElement,
        extensions: [StarterKit],
        content: 'Hello World!',
        editorProps: {
          attributes: {
            class:
              'ariadne-prose ariadne-prose-sm sm:ariadne-prose lg:ariadne-prose-lg xl:ariadne-prose-2xl ariadne-m-5 focus:ariadne-outline-none'
          }
        }
      })

      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

31 entries across 31 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.13 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.13-x86_64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.13-x86_64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.13-x64-mingw32 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.13-x64-mingw-ucrt app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.13-arm64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.13-aarch64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.12 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.12-x86_64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.12-x86_64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.12-x64-mingw32 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.12-x64-mingw-ucrt app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.12-arm64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.12-aarch64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.11 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.11-x86_64-linux app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.11-x86_64-darwin app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.11-x64-mingw32 app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.11-x64-mingw-ucrt app/components/ariadne/rich-text-area-component.ts
ariadne_view_components-0.0.11-arm64-darwin app/components/ariadne/rich-text-area-component.ts