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