How to use the clipboard/dist/clipboard.min function in clipboard

To help you get started, we’ve selected a few clipboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BookStackApp / BookStack / resources / js / components / page-display.js View on Github external
// Prevent closing pointer when clicked or focused
        DOM.onEvents(pointer, ['click', 'focus'], event => {
            event.stopPropagation();
        });

        // Pointer mode toggle
        DOM.onChildEvent(pointer, 'span.icon', 'click', (event, icon) => {
            event.stopPropagation();
            pointerModeLink = !pointerModeLink;
            icon.querySelector('[data-icon="include"]').style.display = (!pointerModeLink) ? 'inline' : 'none';
            icon.querySelector('[data-icon="link"]').style.display = (pointerModeLink) ? 'inline' : 'none';
            updatePointerContent();
        });

        // Set up clipboard
        new Clipboard(pointer.querySelector('button'));

        // Hide pointer when clicking away
        DOM.onEvents(document.body, ['click', 'focus'], event => {
            if (!pointerShowing || isSelection) return;
            pointer = pointer.parentElement.removeChild(pointer);
            pointerShowing = false;
        });

        let updatePointerContent = (element) => {
            let inputText = pointerModeLink ? window.baseUrl(`/link/${this.pageId}#${pointerSectionId}`) : `{{@${this.pageId}#${pointerSectionId}}}`;
            if (pointerModeLink && !inputText.startsWith('http')) {
                inputText = window.location.protocol + "//" + window.location.host + inputText;
            }

            pointer.querySelector('input').value = inputText;
github ovh-ux / ovh-ui-angular / packages / oui-clipboard / src / clipboard.controller.js View on Github external
$postLink () {
        this.$timeout(() => {
            this.$element
                .addClass("oui-input-group oui-input-group_clipboard")
                .removeAttr("id")
                .removeAttr("name");
        });

        // Init the clipboard instance
        this.clipboard = new Clipboard(this.trigger, {
            target: () => this.target,
            text: () => this.model
        });

        // Events for updating the tooltip
        this.clipboard
            .on("success", () => this.selectInputText(this.translations.copiedLabel))
            .on("error", () => this.selectInputText(this.translations.notSupported));
    }
github alm-tools / alm / src / app / trueMain.tsx View on Github external
import $ = require('jquery');
(window as any).$ = $

// prevent backspace
import {preventBackspaceNav} from "./utils/preventBackspaceNav";
preventBackspaceNav();

// Normalize css
require('normalize.css');

// Lost connection indicator
require('./lostConnection.css')

// Load clipboard and enable for all things clipboard
let Clipboard = require('clipboard/dist/clipboard.min');
new Clipboard('[data-clipboard-text]');

// Load hint.css for fancy (styleable) titles
require('hint.css/hint.css');

// Setup font awesome
require('font-awesome/css/font-awesome.css');

const afterLoaded = () => {
    // The main app element
    var appElement = document.getElementById('app');

    // Register a modal location
    Modal.setAppElement(appElement);

    // Render the main app
    ReactDOM.render(, appElement);
github BookStackApp / BookStack / resources / assets / js / services / code.js View on Github external
function addCopyIcon(cmInstance) {
    const copyIcon = `<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"></path><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg>`;
    const copyButton = document.createElement('div');
    copyButton.classList.add('CodeMirror-copy');
    copyButton.innerHTML = copyIcon;
    cmInstance.display.wrapper.appendChild(copyButton);

    const clipboard = new Clipboard(copyButton, {
        text: function(trigger) {
            return cmInstance.getValue()
        }
    });

    clipboard.on('success', event =&gt; {
        copyButton.classList.add('success');
        setTimeout(() =&gt; {
            copyButton.classList.remove('success');
        }, 240);
    });
}