Sha256: 7baf19575ddcc3ba06fd594c30b8f12c7b8a8de79e213cee74e152bfdbd8d149

Contents?: true

Size: 587 Bytes

Versions: 300

Compression:

Stored size: 587 Bytes

Contents

import {Controller} from '@hotwired/stimulus'

export default class ClipboardCopyComponent extends Controller {
  copy() {
    const value = this.element.attributes.getNamedItem('value')

    const forNode = this.element.attributes.getNamedItem('for')

    if (value) {
      navigator.clipboard.writeText(value.value)
    } else if (forNode) {
      const node = document.getElementById(forNode.value)
      navigator.clipboard.writeText(node?.textContent || '')
    } else {
      // just copy inner text
      navigator.clipboard.writeText(this.element.textContent || '')
    }
  }
}

Version data entries

300 entries across 300 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.45-x86_64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.45-arm64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.45-x86_64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.45-aarch64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.44-aarch64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.44-arm64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.44-x86_64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.44-x86_64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.44-x64-mingw-ucrt app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.44 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.39-x86_64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.39-x86_64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.39-x64-mingw32 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.39-aarch64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.39-x64-mingw-ucrt app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.39-arm64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.39 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.38-x64-mingw32 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.38-aarch64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts
ariadne_view_components-0.0.38-x86_64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts