How to use copy-to-clipboard - 10 common examples

To help you get started, we’ve selected a few copy-to-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 ecomfe / santd / santd / typography / base.js View on Github external
handleCopy() {
            let copyable = this.data.get('copyable');
            const copyConfig = {
                ...(typeof copyable === 'object' ? copyable : null)
            };

            if (copyConfig.text === undefined) {
                let textnode = getComponentChildren(this.children,
                    item => item.nodeType === NodeType.TEXT);
                copyConfig.text = textnode.reduce(
                    (total, cur) => !/^\n\s*$/g.test(cur.content) ? (total + cur.content) : total, '');
            }
            copy(copyConfig.text || '');
            copyConfig.onCopy && typeof copyConfig.onCopy === 'function' && copyConfig.onCopy();

            this.data.set('copied', true);
            this.copyId = window.setTimeout(() => {
                this.data.set('copied', false);
            }, 3000);
        }
    });
github graphql / graphiql / packages / graphiql / src / components / GraphiQL.js View on Github external
handleCopyQuery = () => {
    const editor = this.getQueryEditor();
    const query = editor.getValue();

    if (!query) {
      return;
    }

    copyToClipboard(query);

    if (this.props.onCopyQuery) {
      return this.props.onCopyQuery(query);
    }
  };
github ant-design / ant-design / components / typography / Base.tsx View on Github external
onCopyClick = () => {
    const { children, copyable } = this.props;
    const copyConfig: CopyConfig = {
      ...(typeof copyable === 'object' ? copyable : null),
    };

    if (copyConfig.text === undefined) {
      copyConfig.text = String(children);
    }
    copy(copyConfig.text || '');

    this.setState({ copied: true }, () => {
      if (copyConfig.onCopy) {
        copyConfig.onCopy();
      }

      this.copyId = window.setTimeout(() => {
        this.setState({ copied: false });
      }, 3000);
    });
  };
github LINKIWI / linkr / frontend / app / components / pages / account / account-api-key.js View on Github external
handleAPIKeyClick(evt) {
    this.apiKeyInput.input.setSelectionRange(0, this.apiKeyInput.input.value.length);
    copy(this.apiKeyInput.getValue());

    this.setState({isAPIKeyCopied: true});
  }
github elasticpath / react-pwa-reference-storefront / components / src / B2bEditAccount / b2b.editaccount.tsx View on Github external
copyToClipboard(text) {
    copy(text);
    this.setState({ isShowingCopied: false }, () => {
      this.setState({ isShowingCopied: true });

      this.copiedTimeout = window.setTimeout(() => {
        this.setState({ isShowingCopied: false });
      }, COPIED_TIMEOUT_LENGTH);
    });
  }
github dotcypress / password / pages / index.js View on Github external
copy () {
    copy(this.state.password)
    this.passwordEl.style.animationName = 'flash'
    setTimeout(() => {
      if (this.passwordEl) {
        this.passwordEl.style.animationName = ''
      }
    }, 1500)
  }
github elastic / kibana / x-pack / plugins / siem / public / lib / clipboard / clipboard.tsx View on Github external
const onClick = (event: React.MouseEvent) => {
    event.preventDefault();
    event.stopPropagation();

    const isSuccess = copy(`${content}`, { debug: true });

    if (onCopy != null) {
      onCopy({ content, isSuccess });
    }

    if (isSuccess) {
      dispatchToaster({
        type: 'addToaster',
        toast: { toastLifeTimeMs, ...getSuccessToast({ titleSummary }) },
      });
    }
  };
github hackoregon / civic / packages / component-library / src / CivicCard / CivicCardLayoutFull.js View on Github external
function handleShareItemClick(option) {
    const linkLocation = `${_.get(window, "location.origin", "")}/cards/${
      cardMeta.slug
    }`;
    const scrOutput = document.querySelector("#scr-only");

    if (option === "link") {
      copy(linkLocation);
    } else {
      copy(`${linkLocation}/embed`);
    }

    setShareButtonText("Copied!");
    scrOutput.textContent = "Copied";
    setTimeout(() => {
      setShareButtonText("Share");
      scrOutput.textContent = "";
    }, 2000);
    setShareButtonOpen(false);
  }
github eoscannon / EosCannon-Offline-Tools / app / containers / StakePage / index.js View on Github external
handleCopyTransaction = () => {
    if (!this.state.CopyTransactionButtonState) {
      return;
    }
    const values = this.props.form.getFieldsValue();
    const { transaction } = values;
    copy(transaction);
    openNotification(this.state.formatMessage);
  };

copy-to-clipboard

Copy stuff into clipboard using JS with fallbacks

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Popular copy-to-clipboard functions