Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render() {
const {children, hideUnsupported} = this.props;
// Browser doesn't support `execCommand`
if (hideUnsupported && !Clip.isSupported()) {
return null;
}
if (!React.isValidElement(children)) {
return null;
}
return React.cloneElement(children, {
ref: this.handleMount,
});
}
}
render() {
const attributes = {
title: this.props.title || '',
type: this.getType(),
className: this.props.className || '',
style: this.props.style || {},
ref: element => this.element = element,
onClick: this.props.onClick,
...this.propsWith(/^data-/),
...this.propsWith(/^button-/, true),
};
const Clipboard = require('clipboard');
if (!this.props.isVisibleWhenUnsupported && !Clipboard.isSupported()) {
return null;
}
return React.createElement(
this.getComponent(),
attributes,
this.props.children
);
}
clipboardCapable() {
return ClipboardJS.isSupported();
},
dynamicHeightStyle() {
isSupported() {
return Clipboard.isSupported()
},
export default (urlAll, urlCategory) => {
if (Clipboard.isSupported()) {
const confirmMessage = dom('#confirm-message');
new Clipboard('.social__copy');
findAll(dom('#je-partage'), '.social__copy').forEach((item) => {
show(item);
on(item, 'click', () => {
addClass(confirmMessage, 'je-partage__copy--flash');
setTimeout(() => { removeClass(confirmMessage, 'je-partage__copy--flash'); }, 700);
});
});
}
const categoryChooser = dom('#je-partage-category');
on(categoryChooser, 'change', () => {
this.props.args.map(
arg =>
isString(arg) ? (
<span>{arg}</span>
) : (
<span>
{arg.t}
</span>
)
)}
{Clipboard.isSupported() && (
<span>
<button color="primary">
Copy
</button>
</span>
)}
);
}
}
import React, { Component } from 'react'
import { string, func } from 'prop-types'
import clipboard from 'clipboard'
import ClipboardButton from 'react-clipboard.js'
export const supported = clipboard.isSupported()
export default class ClipboardButtonWrapper extends Component {
static propTypes = {
className: string,
i18n: func.isRequired,
onSuccess: func,
}
static defaultProps = {
className: '',
i18n: function (n) { return n },
}
state = {}
componentWillUnmount () {
function handleClipboard(target, text) {
if (!ClipboardJS.isSupported()) {
Vue.prototype.$message({
text: 'The current browser does not support copying',
type: 'error',
});
return;
}
const clipboard = new ClipboardJS(target, {
text: () => text,
});
function removeEventListener() {
clipboard.off('error');
clipboard.off('success');
clipboard.destroy();
}