getLastRng: function () {
return getLastRng(lastRng);
return isDefault(editor, pasteBinDefaultContent);
isDefaultContent: function (content) {
return isDefaultContent(pasteBinDefaultContent, content);
var Clipboard = function (editor, pasteFormat) {
var pasteBin = PasteBin(editor);
editor.on('preInit', function () {
return registerEventsAndFilters(editor, pasteBin, pasteFormat);
pasteFormat: pasteFormat,
pasteHtml: function (html, internalFlag) {
return pasteHtml$1(editor, html, internalFlag);
pasteText: function (text) {
return pasteText(editor, text);
pasteImageData: function (e, rng) {
return pasteImageData(editor, e, rng);
getDataTransferItems: getDataTransferItems,
hasHtmlOrText: hasHtmlOrText,
hasContentType: hasContentType
var noop$1 = function () {
var hasWorkingClipboardApi = function (clipboardData) {
return global$2.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && Utils.isMsEdge() !== true;
var setHtml5Clipboard = function (clipboardData, html, text) {
if (hasWorkingClipboardApi(clipboardData)) {
clipboardData.clearData();
clipboardData.setData('text/html', html);
clipboardData.setData('text/plain', text);
clipboardData.setData(InternalHtml.internalHtmlMime(), html);
var setClipboardData = function (evt, data, fallback, done) {
if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) {
fallback(data.html, done);
var fallback = function (editor) {
return function (html, done) {
var markedHtml = InternalHtml.mark(html);
var outer = editor.dom.create('div', {
'contenteditable': 'false',
var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml);
editor.dom.setStyles(outer, {
outer.appendChild(inner);
editor.dom.add(editor.getBody(), outer);
var range = editor.selection.getRng();
var offscreenRange = editor.dom.createRng();
offscreenRange.selectNodeContents(inner);
editor.selection.setRng(offscreenRange);
editor.selection.setRng(range);
outer.parentNode.removeChild(outer);
var getData = function (editor) {
html: editor.selection.getContent({ contextual: true }),
text: editor.selection.getContent({ format: 'text' })
var isTableSelection = function (editor) {
return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());
var hasSelectedContent = function (editor) {
return !editor.selection.isCollapsed() || isTableSelection(editor);
var cut = function (editor) {
if (hasSelectedContent(editor)) {
setClipboardData(evt, getData(editor), fallback(editor), function () {
editor.execCommand('Delete');
var copy = function (editor) {
if (hasSelectedContent(editor)) {
setClipboardData(evt, getData(editor), fallback(editor), noop$1);
var register$1 = function (editor) {
editor.on('cut', cut(editor));
editor.on('copy', copy(editor));
var CutCopy = { register: register$1 };
var global$b = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
var getCaretRangeFromEvent = function (editor, e) {
return global$b.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
var isPlainTextFileUrl = function (content) {
var plainTextContent = content['text/plain'];
return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false;
var setFocusedRange = function (editor, rng) {
editor.selection.setRng(rng);
var setup = function (editor, clipboard, draggingInternallyState) {
if (Settings.shouldBlockDrop(editor)) {
editor.on('dragend dragover draggesture dragdrop drop drag', function (e) {
if (!Settings.shouldPasteDataImages(editor)) {
editor.on('drop', function (e) {
var dataTransfer = e.dataTransfer;
if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
editor.on('drop', function (e) {
rng = getCaretRangeFromEvent(editor, e);
if (e.isDefaultPrevented() || draggingInternallyState.get()) {
dropContent = clipboard.getDataTransferItems(e.dataTransfer);
var internal = clipboard.hasContentType(dropContent, InternalHtml.internalHtmlMime());
if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) {
if (rng && Settings.shouldFilterDrop(editor)) {
var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
global$3.setEditorTimeout(editor, function () {
editor.undoManager.transact(function () {
if (dropContent['mce-internal']) {
editor.execCommand('Delete');
setFocusedRange(editor, rng);
content_1 = Utils.trimHtml(content_1);
if (!dropContent['text/html']) {
clipboard.pasteText(content_1);
clipboard.pasteHtml(content_1, internal);
editor.on('dragstart', function (e) {
draggingInternallyState.set(true);
editor.on('dragover dragend', function (e) {
if (Settings.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) {
setFocusedRange(editor, getCaretRangeFromEvent(editor, e));
if (e.type === 'dragend') {
draggingInternallyState.set(false);
var DragDrop = { setup: setup };
var setup$1 = function (editor) {
var plugin = editor.plugins.paste;
var preProcess = Settings.getPreProcess(editor);
editor.on('PastePreProcess', function (e) {
preProcess.call(plugin, plugin, e);
var postProcess = Settings.getPostProcess(editor);
editor.on('PastePostProcess', function (e) {
postProcess.call(plugin, plugin, e);
var PrePostProcess = { setup: setup$1 };
function addPreProcessFilter(editor, filterFunc) {
editor.on('PastePreProcess', function (e) {
e.content = filterFunc(editor, e.content, e.internal, e.wordContent);
function addPostProcessFilter(editor, filterFunc) {
editor.on('PastePostProcess', function (e) {
filterFunc(editor, e.node);
function removeExplorerBrElementsAfterBlocks(editor, html) {
if (!WordFilter.isWordContent(html)) {
global$4.each(editor.schema.getBlockElements(), function (block, blockName) {
blockElements.push(blockName);
var explorerBlocksRegExp = new RegExp('(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*', 'g');
html = Utils.filter(html, [[
html = Utils.filter(html, [
function removeWebKitStyles(editor, content, internal, isWordHtml) {
if (isWordHtml || internal) {
var webKitStylesSetting = Settings.getWebkitStyles(editor);
if (Settings.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') {
if (webKitStylesSetting) {
webKitStyles = webKitStylesSetting.split(/[, ]/);
var dom_1 = editor.dom, node_1 = editor.selection.getNode();
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) {
var inputStyles = dom_1.parseStyle(dom_1.decode(value));
if (webKitStyles === 'none') {
for (var i = 0; i < webKitStyles.length; i++) {
var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true);
if (/color/.test(webKitStyles[i])) {
inputValue = dom_1.toHex(inputValue);
currentValue = dom_1.toHex(currentValue);
if (currentValue !== inputValue) {
outputStyles[webKitStyles[i]] = inputValue;
outputStyles = dom_1.serializeStyle(outputStyles, 'span');
return before + ' style="' + outputStyles + '"' + after;
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) {
return before + ' style="' + value + '"' + after;
function removeUnderlineAndFontInAnchor(editor, root) {
editor.$('a', root).find('font,u').each(function (i, node) {
editor.dom.remove(node, true);
var setup$2 = function (editor) {
addPreProcessFilter(editor, removeWebKitStyles);
addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks);
addPostProcessFilter(editor, removeUnderlineAndFontInAnchor);
var Quirks = { setup: setup$2 };
var stateChange = function (editor, clipboard, e) {
ctrl.active(clipboard.pasteFormat.get() === 'text');
editor.on('PastePlainTextToggle', function (e) {
var register$2 = function (editor, clipboard) {
var postRender = curry(stateChange, editor, clipboard);
editor.addButton('pastetext', {
tooltip: 'Paste as text',
cmd: 'mceTogglePlainTextPaste',
editor.addMenuItem('pastetext', {
active: clipboard.pasteFormat,
cmd: 'mceTogglePlainTextPaste',
var Buttons = { register: register$2 };
global$1.add('paste', function (editor) {
if (DetectProPlugin.hasProPlugin(editor) === false) {
var userIsInformedState = Cell(false);
var draggingInternallyState = Cell(false);
var pasteFormat = Cell(Settings.isPasteAsTextEnabled(editor) ? 'text' : 'html');
var clipboard = Clipboard(editor, pasteFormat);
var quirks = Quirks.setup(editor);
Buttons.register(editor, clipboard);
Commands.register(editor, clipboard, userIsInformedState);
PrePostProcess.setup(editor);
CutCopy.register(editor);
DragDrop.setup(editor, clipboard, draggingInternallyState);
return Api.get(clipboard, quirks);