@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
34 lines • 929 B
JavaScript
import createEvent from './create-event';
/**
* Dispatch a paste event on the given ProseMirror instance
*
* Usage:
* dispatchPasteEvent(pm, {
* plain: 'copied text'
* });
*/
export default function (editorView, content) {
var event = createEvent('paste');
var clipboardData = {
getData: function (type) {
if (type === 'text/plain') {
return content.plain;
}
if (type === 'text/html') {
return content.html;
}
},
types: [],
};
try {
Object.defineProperty(event, 'clipboardData', { value: clipboardData });
}
catch (e) {
// iOS 9 will throw if we assign `clipboardData` to `event`
// revert this change once iOS 10 is out
return false;
}
editorView.dispatchEvent(event);
return true;
};
//# sourceMappingURL=dispatch-paste-event.js.map