UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

36 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var create_event_1 = require("./create-event"); /** * Dispatch a paste event on the given ProseMirror instance * * Usage: * dispatchPasteEvent(pm, { * plain: 'copied text' * }); */ exports.default = function (editorView, content) { var event = create_event_1.default('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