Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
});
handleCopyQuery = () => {
const editor = this.getQueryEditor();
const query = editor.getValue();
if (!query) {
return;
}
copyToClipboard(query);
if (this.props.onCopyQuery) {
return this.props.onCopyQuery(query);
}
};
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);
});
};
handleAPIKeyClick(evt) {
this.apiKeyInput.input.setSelectionRange(0, this.apiKeyInput.input.value.length);
copy(this.apiKeyInput.getValue());
this.setState({isAPIKeyCopied: true});
}
onClick={() => {
copy(id);
setClickCount(clickCount + 1);
}}
>
copyToClipboard(text) {
copy(text);
this.setState({ isShowingCopied: false }, () => {
this.setState({ isShowingCopied: true });
this.copiedTimeout = window.setTimeout(() => {
this.setState({ isShowingCopied: false });
}, COPIED_TIMEOUT_LENGTH);
});
}
copy () {
copy(this.state.password)
this.passwordEl.style.animationName = 'flash'
setTimeout(() => {
if (this.passwordEl) {
this.passwordEl.style.animationName = ''
}
}, 1500)
}
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 }) },
});
}
};
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);
}
handleCopyTransaction = () => {
if (!this.state.CopyTransactionButtonState) {
return;
}
const values = this.props.form.getFieldsValue();
const { transaction } = values;
copy(transaction);
openNotification(this.state.formatMessage);
};