// Updates the URL hash and copies the URL to the clipboard function onCopyLinkClick(e) { window.location.hash = encodeURIComponent(hashPrefix + markdown.value); if (navigator.clipboard && navigator.clipboard.writeText) { navigator.clipboard.writeText(window.location).then(noop, noop); } else { /* eslint-disable-next-line no-alert */ alert("Document URL updated, select and copy it now."); } e.preventDefault(); }
/** * @param {!Event} event */ _onContextMenu(event) { const selection = this._terminal ? this._terminal.getSelection() : null; const contextMenu = new UI.ContextMenu(event); const copyItem = contextMenu.defaultSection().appendItem(ls`Copy`, () => navigator.clipboard.writeText(selection)); copyItem.setEnabled(!!selection); contextMenu.defaultSection().appendItem(ls`Paste`, async() => { if (this._backend) this._backend.write(await navigator.clipboard.readText()); }); contextMenu.show(); }
const copyCodeToClipboard = async () => { if (!navigator.clipboard) { notification.error({ message: 'Your browser doesn\'t support copy to clipboard', }); } try { await navigator.clipboard.writeText( showCode === 'query' ? queryText : codeExample ); notification.success({ message: 'Copied to clipboard', }); } catch (e) { notification.error({ message: 'Can\'t copy to clipboard', description: e, }); } }
InspectorFrontendHost.copyText = text => navigator.clipboard.writeText(text); InspectorFrontendHost.openInNewTab = url => Ndb.backend.openInNewTab(url); InspectorFrontendHost.bringToFront = () => Ndb.backend.bringToFront();
navigator.clipboard.writeText( `${process.env.REACT_APP_FRONTEND_URL}${generatePath(Routes.POST, { id: postId,
handleCopy(popupShowType, text) { window.navigator.clipboard.writeText(text); this.setState({ showPopup: popupShowType }); setTimeout(() => this.setState({ showPopup: '' }), 1000); }
const copyToCC = (content, e) => { e.preventDefault(); navigator.clipboard.writeText(content); setCopyText(afterCopyLabel); setTimeout(() => { setCopyText(beforeCopyLabel); }, 2000); }
navigator.clipboard .writeText(document.URL) .then(() => showAlert('Link copied to clipboard.')) .catch(() => showAlert('Could not copy link to clipboard.') );
navigator.clipboard = { writeText: jest.fn() } wrapper.find('.copy').props().onClick(eventMock) ; expect(navigator.clipboard.writeText).toHaveBeenCalled(); expect(wrapper.find('.copy').contains('Copied')).toEqual(true); })
navigator.clipboard .writeText(fullPath) .then((r) => { Message.success('Copied: ' + fullPath); }) .catch((e) => { Message.error(e.message); });
navigator.clipboard.writeText( `${process.env.REACT_APP_FRONTEND_URL}${generatePath(Routes.POST, { id: postId,
navigator.clipboard .writeText(document.URL) .then(() => showAlert('Link copied to clipboard.')) .catch(() => showAlert('Could not copy link to clipboard.') );
const copyToCC = (content, e) => { e.preventDefault(); navigator.clipboard.writeText(content); setCopyText(afterCopyLabel); setTimeout(() => { setCopyText(beforeCopyLabel); }, 2000); }
navigator.clipboard .writeText(fullPath) .then((r) => { Message.success('Copied: ' + fullPath); }) .catch((e) => { Message.error(e.message); });
navigator.clipboard = { writeText: jest.fn() } wrapper.find('.copy').props().onClick(eventMock) ; expect(navigator.clipboard.writeText).toHaveBeenCalled(); expect(wrapper.find('.copy').contains('Copied')).toEqual(true); })