Sha256: 7705abdf67329ee6c91a0d92d5a9df7bdc045ee70af25d899e839376408f18c3
Contents?: true
Size: 712 Bytes
Versions: 102
Compression:
Stored size: 712 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 === null || node === void 0 ? void 0 : node.textContent) || ''); } else { // just copy inner text navigator.clipboard.writeText(this.element.textContent || ''); } } }
Version data entries
102 entries across 96 versions & 1 rubygems
Version | Path |
---|---|
ariadne_view_components-0.0.5 | app/components/ariadne/clipboard-copy-component.js |
ariadne_view_components-0.0.5 | app/components/ariadne/clipboard_copy_component.js |