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.48-x64-mingw-ucrt app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.48-aarch64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.48-x86_64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.48-arm64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.48 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.48-x86_64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.47-x86_64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.47-x86_64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.47-arm64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.47-aarch64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.47-x64-mingw-ucrt app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.47 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.46-aarch64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.46-x64-mingw-ucrt app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.46 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.46-x86_64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.46-x86_64-linux app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.46-arm64-darwin app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.45-x64-mingw-ucrt app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js
ariadne_view_components-0.0.45 app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js