[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/js/tinymce/plugins/paste/ -> plugin.js (source)

   1  (function () {
   2  var paste = (function (domGlobals) {
   3      'use strict';
   4  
   5      var Cell = function (initial) {
   6        var value = initial;
   7        var get = function () {
   8          return value;
   9        };
  10        var set = function (v) {
  11          value = v;
  12        };
  13        var clone = function () {
  14          return Cell(get());
  15        };
  16        return {
  17          get: get,
  18          set: set,
  19          clone: clone
  20        };
  21      };
  22  
  23      var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
  24  
  25      var hasProPlugin = function (editor) {
  26        if (/(^|[ ,])powerpaste([, ]|$)/.test(editor.settings.plugins) && global$1.get('powerpaste')) {
  27          if (typeof domGlobals.window.console !== 'undefined' && domGlobals.window.console.log) {
  28            domGlobals.window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.');
  29          }
  30          return true;
  31        } else {
  32          return false;
  33        }
  34      };
  35      var DetectProPlugin = { hasProPlugin: hasProPlugin };
  36  
  37      var get = function (clipboard, quirks) {
  38        return {
  39          clipboard: clipboard,
  40          quirks: quirks
  41        };
  42      };
  43      var Api = { get: get };
  44  
  45      var firePastePreProcess = function (editor, html, internal, isWordHtml) {
  46        return editor.fire('PastePreProcess', {
  47          content: html,
  48          internal: internal,
  49          wordContent: isWordHtml
  50        });
  51      };
  52      var firePastePostProcess = function (editor, node, internal, isWordHtml) {
  53        return editor.fire('PastePostProcess', {
  54          node: node,
  55          internal: internal,
  56          wordContent: isWordHtml
  57        });
  58      };
  59      var firePastePlainTextToggle = function (editor, state) {
  60        return editor.fire('PastePlainTextToggle', { state: state });
  61      };
  62      var firePaste = function (editor, ieFake) {
  63        return editor.fire('paste', { ieFake: ieFake });
  64      };
  65      var Events = {
  66        firePastePreProcess: firePastePreProcess,
  67        firePastePostProcess: firePastePostProcess,
  68        firePastePlainTextToggle: firePastePlainTextToggle,
  69        firePaste: firePaste
  70      };
  71  
  72      var shouldPlainTextInform = function (editor) {
  73        return editor.getParam('paste_plaintext_inform', true);
  74      };
  75      var shouldBlockDrop = function (editor) {
  76        return editor.getParam('paste_block_drop', false);
  77      };
  78      var shouldPasteDataImages = function (editor) {
  79        return editor.getParam('paste_data_images', false);
  80      };
  81      var shouldFilterDrop = function (editor) {
  82        return editor.getParam('paste_filter_drop', true);
  83      };
  84      var getPreProcess = function (editor) {
  85        return editor.getParam('paste_preprocess');
  86      };
  87      var getPostProcess = function (editor) {
  88        return editor.getParam('paste_postprocess');
  89      };
  90      var getWebkitStyles = function (editor) {
  91        return editor.getParam('paste_webkit_styles');
  92      };
  93      var shouldRemoveWebKitStyles = function (editor) {
  94        return editor.getParam('paste_remove_styles_if_webkit', true);
  95      };
  96      var shouldMergeFormats = function (editor) {
  97        return editor.getParam('paste_merge_formats', true);
  98      };
  99      var isSmartPasteEnabled = function (editor) {
 100        return editor.getParam('smart_paste', true);
 101      };
 102      var isPasteAsTextEnabled = function (editor) {
 103        return editor.getParam('paste_as_text', false);
 104      };
 105      var getRetainStyleProps = function (editor) {
 106        return editor.getParam('paste_retain_style_properties');
 107      };
 108      var getWordValidElements = function (editor) {
 109        var defaultValidElements = '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' + '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' + 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody';
 110        return editor.getParam('paste_word_valid_elements', defaultValidElements);
 111      };
 112      var shouldConvertWordFakeLists = function (editor) {
 113        return editor.getParam('paste_convert_word_fake_lists', true);
 114      };
 115      var shouldUseDefaultFilters = function (editor) {
 116        return editor.getParam('paste_enable_default_filters', true);
 117      };
 118      var Settings = {
 119        shouldPlainTextInform: shouldPlainTextInform,
 120        shouldBlockDrop: shouldBlockDrop,
 121        shouldPasteDataImages: shouldPasteDataImages,
 122        shouldFilterDrop: shouldFilterDrop,
 123        getPreProcess: getPreProcess,
 124        getPostProcess: getPostProcess,
 125        getWebkitStyles: getWebkitStyles,
 126        shouldRemoveWebKitStyles: shouldRemoveWebKitStyles,
 127        shouldMergeFormats: shouldMergeFormats,
 128        isSmartPasteEnabled: isSmartPasteEnabled,
 129        isPasteAsTextEnabled: isPasteAsTextEnabled,
 130        getRetainStyleProps: getRetainStyleProps,
 131        getWordValidElements: getWordValidElements,
 132        shouldConvertWordFakeLists: shouldConvertWordFakeLists,
 133        shouldUseDefaultFilters: shouldUseDefaultFilters
 134      };
 135  
 136      var shouldInformUserAboutPlainText = function (editor, userIsInformedState) {
 137        return userIsInformedState.get() === false && Settings.shouldPlainTextInform(editor);
 138      };
 139      var displayNotification = function (editor, message) {
 140        editor.notificationManager.open({
 141          text: editor.translate(message),
 142          type: 'info'
 143        });
 144      };
 145      var togglePlainTextPaste = function (editor, clipboard, userIsInformedState) {
 146        if (clipboard.pasteFormat.get() === 'text') {
 147          clipboard.pasteFormat.set('html');
 148          Events.firePastePlainTextToggle(editor, false);
 149        } else {
 150          clipboard.pasteFormat.set('text');
 151          Events.firePastePlainTextToggle(editor, true);
 152          if (shouldInformUserAboutPlainText(editor, userIsInformedState)) {
 153            displayNotification(editor, 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.');
 154            userIsInformedState.set(true);
 155          }
 156        }
 157        editor.focus();
 158      };
 159      var Actions = { togglePlainTextPaste: togglePlainTextPaste };
 160  
 161      var register = function (editor, clipboard, userIsInformedState) {
 162        editor.addCommand('mceTogglePlainTextPaste', function () {
 163          Actions.togglePlainTextPaste(editor, clipboard, userIsInformedState);
 164        });
 165        editor.addCommand('mceInsertClipboardContent', function (ui, value) {
 166          if (value.content) {
 167            clipboard.pasteHtml(value.content, value.internal);
 168          }
 169          if (value.text) {
 170            clipboard.pasteText(value.text);
 171          }
 172        });
 173      };
 174      var Commands = { register: register };
 175  
 176      var global$2 = tinymce.util.Tools.resolve('tinymce.Env');
 177  
 178      var global$3 = tinymce.util.Tools.resolve('tinymce.util.Delay');
 179  
 180      var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
 181  
 182      var global$5 = tinymce.util.Tools.resolve('tinymce.util.VK');
 183  
 184      var internalMimeType = 'x-tinymce/html';
 185      var internalMark = '<!-- ' + internalMimeType + ' -->';
 186      var mark = function (html) {
 187        return internalMark + html;
 188      };
 189      var unmark = function (html) {
 190        return html.replace(internalMark, '');
 191      };
 192      var isMarked = function (html) {
 193        return html.indexOf(internalMark) !== -1;
 194      };
 195      var InternalHtml = {
 196        mark: mark,
 197        unmark: unmark,
 198        isMarked: isMarked,
 199        internalHtmlMime: function () {
 200          return internalMimeType;
 201        }
 202      };
 203  
 204      var global$6 = tinymce.util.Tools.resolve('tinymce.html.Entities');
 205  
 206      var isPlainText = function (text) {
 207        return !/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(text);
 208      };
 209      var toBRs = function (text) {
 210        return text.replace(/\r?\n/g, '<br>');
 211      };
 212      var openContainer = function (rootTag, rootAttrs) {
 213        var key;
 214        var attrs = [];
 215        var tag = '<' + rootTag;
 216        if (typeof rootAttrs === 'object') {
 217          for (key in rootAttrs) {
 218            if (rootAttrs.hasOwnProperty(key)) {
 219              attrs.push(key + '="' + global$6.encodeAllRaw(rootAttrs[key]) + '"');
 220            }
 221          }
 222          if (attrs.length) {
 223            tag += ' ' + attrs.join(' ');
 224          }
 225        }
 226        return tag + '>';
 227      };
 228      var toBlockElements = function (text, rootTag, rootAttrs) {
 229        var blocks = text.split(/\n\n/);
 230        var tagOpen = openContainer(rootTag, rootAttrs);
 231        var tagClose = '</' + rootTag + '>';
 232        var paragraphs = global$4.map(blocks, function (p) {
 233          return p.split(/\n/).join('<br />');
 234        });
 235        var stitch = function (p) {
 236          return tagOpen + p + tagClose;
 237        };
 238        return paragraphs.length === 1 ? paragraphs[0] : global$4.map(paragraphs, stitch).join('');
 239      };
 240      var convert = function (text, rootTag, rootAttrs) {
 241        return rootTag ? toBlockElements(text, rootTag, rootAttrs) : toBRs(text);
 242      };
 243      var Newlines = {
 244        isPlainText: isPlainText,
 245        convert: convert,
 246        toBRs: toBRs,
 247        toBlockElements: toBlockElements
 248      };
 249  
 250      var global$7 = tinymce.util.Tools.resolve('tinymce.html.DomParser');
 251  
 252      var global$8 = tinymce.util.Tools.resolve('tinymce.html.Node');
 253  
 254      var global$9 = tinymce.util.Tools.resolve('tinymce.html.Schema');
 255  
 256      var global$a = tinymce.util.Tools.resolve('tinymce.html.Serializer');
 257  
 258      function filter(content, items) {
 259        global$4.each(items, function (v) {
 260          if (v.constructor === RegExp) {
 261            content = content.replace(v, '');
 262          } else {
 263            content = content.replace(v[0], v[1]);
 264          }
 265        });
 266        return content;
 267      }
 268      function innerText(html) {
 269        var schema = global$9();
 270        var domParser = global$7({}, schema);
 271        var text = '';
 272        var shortEndedElements = schema.getShortEndedElements();
 273        var ignoreElements = global$4.makeMap('script noscript style textarea video audio iframe object', ' ');
 274        var blockElements = schema.getBlockElements();
 275        function walk(node) {
 276          var name = node.name, currentNode = node;
 277          if (name === 'br') {
 278            text += '\n';
 279            return;
 280          }
 281          if (name === 'wbr') {
 282            return;
 283          }
 284          if (shortEndedElements[name]) {
 285            text += ' ';
 286          }
 287          if (ignoreElements[name]) {
 288            text += ' ';
 289            return;
 290          }
 291          if (node.type === 3) {
 292            text += node.value;
 293          }
 294          if (!node.shortEnded) {
 295            if (node = node.firstChild) {
 296              do {
 297                walk(node);
 298              } while (node = node.next);
 299            }
 300          }
 301          if (blockElements[name] && currentNode.next) {
 302            text += '\n';
 303            if (name === 'p') {
 304              text += '\n';
 305            }
 306          }
 307        }
 308        html = filter(html, [/<!\[[^\]]+\]>/g]);
 309        walk(domParser.parse(html));
 310        return text;
 311      }
 312      function trimHtml(html) {
 313        function trimSpaces(all, s1, s2) {
 314          if (!s1 && !s2) {
 315            return ' ';
 316          }
 317          return '\xA0';
 318        }
 319        html = filter(html, [
 320          /^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig,
 321          /<!--StartFragment-->|<!--EndFragment-->/g,
 322          [
 323            /( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,
 324            trimSpaces
 325          ],
 326          /<br class="Apple-interchange-newline">/g,
 327          /<br>$/i
 328        ]);
 329        return html;
 330      }
 331      function createIdGenerator(prefix) {
 332        var count = 0;
 333        return function () {
 334          return prefix + count++;
 335        };
 336      }
 337      var isMsEdge = function () {
 338        return domGlobals.navigator.userAgent.indexOf(' Edge/') !== -1;
 339      };
 340      var Utils = {
 341        filter: filter,
 342        innerText: innerText,
 343        trimHtml: trimHtml,
 344        createIdGenerator: createIdGenerator,
 345        isMsEdge: isMsEdge
 346      };
 347  
 348      function isWordContent(content) {
 349        return /<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(content) || /class="OutlineElement/.test(content) || /id="?docs\-internal\-guid\-/.test(content);
 350      }
 351      function isNumericList(text) {
 352        var found, patterns;
 353        patterns = [
 354          /^[IVXLMCD]{1,2}\.[ \u00a0]/,
 355          /^[ivxlmcd]{1,2}\.[ \u00a0]/,
 356          /^[a-z]{1,2}[\.\)][ \u00a0]/,
 357          /^[A-Z]{1,2}[\.\)][ \u00a0]/,
 358          /^[0-9]+\.[ \u00a0]/,
 359          /^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,
 360          /^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/
 361        ];
 362        text = text.replace(/^[\u00a0 ]+/, '');
 363        global$4.each(patterns, function (pattern) {
 364          if (pattern.test(text)) {
 365            found = true;
 366            return false;
 367          }
 368        });
 369        return found;
 370      }
 371      function isBulletList(text) {
 372        return /^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(text);
 373      }
 374      function convertFakeListsToProperLists(node) {
 375        var currentListNode, prevListNode, lastLevel = 1;
 376        function getText(node) {
 377          var txt = '';
 378          if (node.type === 3) {
 379            return node.value;
 380          }
 381          if (node = node.firstChild) {
 382            do {
 383              txt += getText(node);
 384            } while (node = node.next);
 385          }
 386          return txt;
 387        }
 388        function trimListStart(node, regExp) {
 389          if (node.type === 3) {
 390            if (regExp.test(node.value)) {
 391              node.value = node.value.replace(regExp, '');
 392              return false;
 393            }
 394          }
 395          if (node = node.firstChild) {
 396            do {
 397              if (!trimListStart(node, regExp)) {
 398                return false;
 399              }
 400            } while (node = node.next);
 401          }
 402          return true;
 403        }
 404        function removeIgnoredNodes(node) {
 405          if (node._listIgnore) {
 406            node.remove();
 407            return;
 408          }
 409          if (node = node.firstChild) {
 410            do {
 411              removeIgnoredNodes(node);
 412            } while (node = node.next);
 413          }
 414        }
 415        function convertParagraphToLi(paragraphNode, listName, start) {
 416          var level = paragraphNode._listLevel || lastLevel;
 417          if (level !== lastLevel) {
 418            if (level < lastLevel) {
 419              if (currentListNode) {
 420                currentListNode = currentListNode.parent.parent;
 421              }
 422            } else {
 423              prevListNode = currentListNode;
 424              currentListNode = null;
 425            }
 426          }
 427          if (!currentListNode || currentListNode.name !== listName) {
 428            prevListNode = prevListNode || currentListNode;
 429            currentListNode = new global$8(listName, 1);
 430            if (start > 1) {
 431              currentListNode.attr('start', '' + start);
 432            }
 433            paragraphNode.wrap(currentListNode);
 434          } else {
 435            currentListNode.append(paragraphNode);
 436          }
 437          paragraphNode.name = 'li';
 438          if (level > lastLevel && prevListNode) {
 439            prevListNode.lastChild.append(currentListNode);
 440          }
 441          lastLevel = level;
 442          removeIgnoredNodes(paragraphNode);
 443          trimListStart(paragraphNode, /^\u00a0+/);
 444          trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
 445          trimListStart(paragraphNode, /^\u00a0+/);
 446        }
 447        var elements = [];
 448        var child = node.firstChild;
 449        while (typeof child !== 'undefined' && child !== null) {
 450          elements.push(child);
 451          child = child.walk();
 452          if (child !== null) {
 453            while (typeof child !== 'undefined' && child.parent !== node) {
 454              child = child.walk();
 455            }
 456          }
 457        }
 458        for (var i = 0; i < elements.length; i++) {
 459          node = elements[i];
 460          if (node.name === 'p' && node.firstChild) {
 461            var nodeText = getText(node);
 462            if (isBulletList(nodeText)) {
 463              convertParagraphToLi(node, 'ul');
 464              continue;
 465            }
 466            if (isNumericList(nodeText)) {
 467              var matches = /([0-9]+)\./.exec(nodeText);
 468              var start = 1;
 469              if (matches) {
 470                start = parseInt(matches[1], 10);
 471              }
 472              convertParagraphToLi(node, 'ol', start);
 473              continue;
 474            }
 475            if (node._listLevel) {
 476              convertParagraphToLi(node, 'ul', 1);
 477              continue;
 478            }
 479            currentListNode = null;
 480          } else {
 481            prevListNode = currentListNode;
 482            currentListNode = null;
 483          }
 484        }
 485      }
 486      function filterStyles(editor, validStyles, node, styleValue) {
 487        var outputStyles = {}, matches;
 488        var styles = editor.dom.parseStyle(styleValue);
 489        global$4.each(styles, function (value, name) {
 490          switch (name) {
 491          case 'mso-list':
 492            matches = /\w+ \w+([0-9]+)/i.exec(styleValue);
 493            if (matches) {
 494              node._listLevel = parseInt(matches[1], 10);
 495            }
 496            if (/Ignore/i.test(value) && node.firstChild) {
 497              node._listIgnore = true;
 498              node.firstChild._listIgnore = true;
 499            }
 500            break;
 501          case 'horiz-align':
 502            name = 'text-align';
 503            break;
 504          case 'vert-align':
 505            name = 'vertical-align';
 506            break;
 507          case 'font-color':
 508          case 'mso-foreground':
 509            name = 'color';
 510            break;
 511          case 'mso-background':
 512          case 'mso-highlight':
 513            name = 'background';
 514            break;
 515          case 'font-weight':
 516          case 'font-style':
 517            if (value !== 'normal') {
 518              outputStyles[name] = value;
 519            }
 520            return;
 521          case 'mso-element':
 522            if (/^(comment|comment-list)$/i.test(value)) {
 523              node.remove();
 524              return;
 525            }
 526            break;
 527          }
 528          if (name.indexOf('mso-comment') === 0) {
 529            node.remove();
 530            return;
 531          }
 532          if (name.indexOf('mso-') === 0) {
 533            return;
 534          }
 535          if (Settings.getRetainStyleProps(editor) === 'all' || validStyles && validStyles[name]) {
 536            outputStyles[name] = value;
 537          }
 538        });
 539        if (/(bold)/i.test(outputStyles['font-weight'])) {
 540          delete outputStyles['font-weight'];
 541          node.wrap(new global$8('b', 1));
 542        }
 543        if (/(italic)/i.test(outputStyles['font-style'])) {
 544          delete outputStyles['font-style'];
 545          node.wrap(new global$8('i', 1));
 546        }
 547        outputStyles = editor.dom.serializeStyle(outputStyles, node.name);
 548        if (outputStyles) {
 549          return outputStyles;
 550        }
 551        return null;
 552      }
 553      var filterWordContent = function (editor, content) {
 554        var retainStyleProperties, validStyles;
 555        retainStyleProperties = Settings.getRetainStyleProps(editor);
 556        if (retainStyleProperties) {
 557          validStyles = global$4.makeMap(retainStyleProperties.split(/[, ]/));
 558        }
 559        content = Utils.filter(content, [
 560          /<br class="?Apple-interchange-newline"?>/gi,
 561          /<b[^>]+id="?docs-internal-[^>]*>/gi,
 562          /<!--[\s\S]+?-->/gi,
 563          /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
 564          [
 565            /<(\/?)s>/gi,
 566            '<$1strike>'
 567          ],
 568          [
 569            /&nbsp;/gi,
 570            '\xA0'
 571          ],
 572          [
 573            /<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,
 574            function (str, spaces) {
 575              return spaces.length > 0 ? spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join('\xA0') : '';
 576            }
 577          ]
 578        ]);
 579        var validElements = Settings.getWordValidElements(editor);
 580        var schema = global$9({
 581          valid_elements: validElements,
 582          valid_children: '-li[p]'
 583        });
 584        global$4.each(schema.elements, function (rule) {
 585          if (!rule.attributes.class) {
 586            rule.attributes.class = {};
 587            rule.attributesOrder.push('class');
 588          }
 589          if (!rule.attributes.style) {
 590            rule.attributes.style = {};
 591            rule.attributesOrder.push('style');
 592          }
 593        });
 594        var domParser = global$7({}, schema);
 595        domParser.addAttributeFilter('style', function (nodes) {
 596          var i = nodes.length, node;
 597          while (i--) {
 598            node = nodes[i];
 599            node.attr('style', filterStyles(editor, validStyles, node, node.attr('style')));
 600            if (node.name === 'span' && node.parent && !node.attributes.length) {
 601              node.unwrap();
 602            }
 603          }
 604        });
 605        domParser.addAttributeFilter('class', function (nodes) {
 606          var i = nodes.length, node, className;
 607          while (i--) {
 608            node = nodes[i];
 609            className = node.attr('class');
 610            if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) {
 611              node.remove();
 612            }
 613            node.attr('class', null);
 614          }
 615        });
 616        domParser.addNodeFilter('del', function (nodes) {
 617          var i = nodes.length;
 618          while (i--) {
 619            nodes[i].remove();
 620          }
 621        });
 622        domParser.addNodeFilter('a', function (nodes) {
 623          var i = nodes.length, node, href, name;
 624          while (i--) {
 625            node = nodes[i];
 626            href = node.attr('href');
 627            name = node.attr('name');
 628            if (href && href.indexOf('#_msocom_') !== -1) {
 629              node.remove();
 630              continue;
 631            }
 632            if (href && href.indexOf('file://') === 0) {
 633              href = href.split('#')[1];
 634              if (href) {
 635                href = '#' + href;
 636              }
 637            }
 638            if (!href && !name) {
 639              node.unwrap();
 640            } else {
 641              if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) {
 642                node.unwrap();
 643                continue;
 644              }
 645              node.attr({
 646                href: href,
 647                name: name
 648              });
 649            }
 650          }
 651        });
 652        var rootNode = domParser.parse(content);
 653        if (Settings.shouldConvertWordFakeLists(editor)) {
 654          convertFakeListsToProperLists(rootNode);
 655        }
 656        content = global$a({ validate: editor.settings.validate }, schema).serialize(rootNode);
 657        return content;
 658      };
 659      var preProcess = function (editor, content) {
 660        return Settings.shouldUseDefaultFilters(editor) ? filterWordContent(editor, content) : content;
 661      };
 662      var WordFilter = {
 663        preProcess: preProcess,
 664        isWordContent: isWordContent
 665      };
 666  
 667      var processResult = function (content, cancelled) {
 668        return {
 669          content: content,
 670          cancelled: cancelled
 671        };
 672      };
 673      var postProcessFilter = function (editor, html, internal, isWordHtml) {
 674        var tempBody = editor.dom.create('div', { style: 'display:none' }, html);
 675        var postProcessArgs = Events.firePastePostProcess(editor, tempBody, internal, isWordHtml);
 676        return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented());
 677      };
 678      var filterContent = function (editor, content, internal, isWordHtml) {
 679        var preProcessArgs = Events.firePastePreProcess(editor, content, internal, isWordHtml);
 680        if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) {
 681          return postProcessFilter(editor, preProcessArgs.content, internal, isWordHtml);
 682        } else {
 683          return processResult(preProcessArgs.content, preProcessArgs.isDefaultPrevented());
 684        }
 685      };
 686      var process = function (editor, html, internal) {
 687        var isWordHtml = WordFilter.isWordContent(html);
 688        var content = isWordHtml ? WordFilter.preProcess(editor, html) : html;
 689        return filterContent(editor, content, internal, isWordHtml);
 690      };
 691      var ProcessFilters = { process: process };
 692  
 693      var removeMeta = function (editor, html) {
 694        var body = editor.dom.create('body', {}, html);
 695        global$4.each(body.querySelectorAll('meta'), function (elm) {
 696          return elm.parentNode.removeChild(elm);
 697        });
 698        return body.innerHTML;
 699      };
 700      var pasteHtml = function (editor, html) {
 701        editor.insertContent(removeMeta(editor, html), {
 702          merge: Settings.shouldMergeFormats(editor),
 703          paste: true
 704        });
 705        return true;
 706      };
 707      var isAbsoluteUrl = function (url) {
 708        return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url);
 709      };
 710      var isImageUrl = function (url) {
 711        return isAbsoluteUrl(url) && /.(gif|jpe?g|png)$/.test(url);
 712      };
 713      var createImage = function (editor, url, pasteHtmlFn) {
 714        editor.undoManager.extra(function () {
 715          pasteHtmlFn(editor, url);
 716        }, function () {
 717          editor.insertContent('<img src="' + url + '">');
 718        });
 719        return true;
 720      };
 721      var createLink = function (editor, url, pasteHtmlFn) {
 722        editor.undoManager.extra(function () {
 723          pasteHtmlFn(editor, url);
 724        }, function () {
 725          editor.execCommand('mceInsertLink', false, url);
 726        });
 727        return true;
 728      };
 729      var linkSelection = function (editor, html, pasteHtmlFn) {
 730        return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false;
 731      };
 732      var insertImage = function (editor, html, pasteHtmlFn) {
 733        return isImageUrl(html) ? createImage(editor, html, pasteHtmlFn) : false;
 734      };
 735      var smartInsertContent = function (editor, html) {
 736        global$4.each([
 737          linkSelection,
 738          insertImage,
 739          pasteHtml
 740        ], function (action) {
 741          return action(editor, html, pasteHtml) !== true;
 742        });
 743      };
 744      var insertContent = function (editor, html) {
 745        if (Settings.isSmartPasteEnabled(editor) === false) {
 746          pasteHtml(editor, html);
 747        } else {
 748          smartInsertContent(editor, html);
 749        }
 750      };
 751      var SmartPaste = {
 752        isImageUrl: isImageUrl,
 753        isAbsoluteUrl: isAbsoluteUrl,
 754        insertContent: insertContent
 755      };
 756  
 757      var constant = function (value) {
 758        return function () {
 759          return value;
 760        };
 761      };
 762      function curry(fn) {
 763        var initialArgs = [];
 764        for (var _i = 1; _i < arguments.length; _i++) {
 765          initialArgs[_i - 1] = arguments[_i];
 766        }
 767        return function () {
 768          var restArgs = [];
 769          for (var _i = 0; _i < arguments.length; _i++) {
 770            restArgs[_i] = arguments[_i];
 771          }
 772          var all = initialArgs.concat(restArgs);
 773          return fn.apply(null, all);
 774        };
 775      }
 776      var never = constant(false);
 777      var always = constant(true);
 778  
 779      var never$1 = never;
 780      var always$1 = always;
 781      var none = function () {
 782        return NONE;
 783      };
 784      var NONE = function () {
 785        var eq = function (o) {
 786          return o.isNone();
 787        };
 788        var call = function (thunk) {
 789          return thunk();
 790        };
 791        var id = function (n) {
 792          return n;
 793        };
 794        var noop = function () {
 795        };
 796        var nul = function () {
 797          return null;
 798        };
 799        var undef = function () {
 800          return undefined;
 801        };
 802        var me = {
 803          fold: function (n, s) {
 804            return n();
 805          },
 806          is: never$1,
 807          isSome: never$1,
 808          isNone: always$1,
 809          getOr: id,
 810          getOrThunk: call,
 811          getOrDie: function (msg) {
 812            throw new Error(msg || 'error: getOrDie called on none.');
 813          },
 814          getOrNull: nul,
 815          getOrUndefined: undef,
 816          or: id,
 817          orThunk: call,
 818          map: none,
 819          ap: none,
 820          each: noop,
 821          bind: none,
 822          flatten: none,
 823          exists: never$1,
 824          forall: always$1,
 825          filter: none,
 826          equals: eq,
 827          equals_: eq,
 828          toArray: function () {
 829            return [];
 830          },
 831          toString: constant('none()')
 832        };
 833        if (Object.freeze) {
 834          Object.freeze(me);
 835        }
 836        return me;
 837      }();
 838      var some = function (a) {
 839        var constant_a = function () {
 840          return a;
 841        };
 842        var self = function () {
 843          return me;
 844        };
 845        var map = function (f) {
 846          return some(f(a));
 847        };
 848        var bind = function (f) {
 849          return f(a);
 850        };
 851        var me = {
 852          fold: function (n, s) {
 853            return s(a);
 854          },
 855          is: function (v) {
 856            return a === v;
 857          },
 858          isSome: always$1,
 859          isNone: never$1,
 860          getOr: constant_a,
 861          getOrThunk: constant_a,
 862          getOrDie: constant_a,
 863          getOrNull: constant_a,
 864          getOrUndefined: constant_a,
 865          or: self,
 866          orThunk: self,
 867          map: map,
 868          ap: function (optfab) {
 869            return optfab.fold(none, function (fab) {
 870              return some(fab(a));
 871            });
 872          },
 873          each: function (f) {
 874            f(a);
 875          },
 876          bind: bind,
 877          flatten: constant_a,
 878          exists: bind,
 879          forall: bind,
 880          filter: function (f) {
 881            return f(a) ? me : NONE;
 882          },
 883          equals: function (o) {
 884            return o.is(a);
 885          },
 886          equals_: function (o, elementEq) {
 887            return o.fold(never$1, function (b) {
 888              return elementEq(a, b);
 889            });
 890          },
 891          toArray: function () {
 892            return [a];
 893          },
 894          toString: function () {
 895            return 'some(' + a + ')';
 896          }
 897        };
 898        return me;
 899      };
 900      var from = function (value) {
 901        return value === null || value === undefined ? NONE : some(value);
 902      };
 903      var Option = {
 904        some: some,
 905        none: none,
 906        from: from
 907      };
 908  
 909      var typeOf = function (x) {
 910        if (x === null) {
 911          return 'null';
 912        }
 913        var t = typeof x;
 914        if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
 915          return 'array';
 916        }
 917        if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
 918          return 'string';
 919        }
 920        return t;
 921      };
 922      var isType = function (type) {
 923        return function (value) {
 924          return typeOf(value) === type;
 925        };
 926      };
 927      var isFunction = isType('function');
 928  
 929      var slice = Array.prototype.slice;
 930      var map = function (xs, f) {
 931        var len = xs.length;
 932        var r = new Array(len);
 933        for (var i = 0; i < len; i++) {
 934          var x = xs[i];
 935          r[i] = f(x, i, xs);
 936        }
 937        return r;
 938      };
 939      var each = function (xs, f) {
 940        for (var i = 0, len = xs.length; i < len; i++) {
 941          var x = xs[i];
 942          f(x, i, xs);
 943        }
 944      };
 945      var filter$1 = function (xs, pred) {
 946        var r = [];
 947        for (var i = 0, len = xs.length; i < len; i++) {
 948          var x = xs[i];
 949          if (pred(x, i, xs)) {
 950            r.push(x);
 951          }
 952        }
 953        return r;
 954      };
 955      var from$1 = isFunction(Array.from) ? Array.from : function (x) {
 956        return slice.call(x);
 957      };
 958  
 959      var exports$1 = {}, module = { exports: exports$1 };
 960      (function (define, exports, module, require) {
 961        (function (f) {
 962          if (typeof exports === 'object' && typeof module !== 'undefined') {
 963            module.exports = f();
 964          } else if (typeof define === 'function' && define.amd) {
 965            define([], f);
 966          } else {
 967            var g;
 968            if (typeof window !== 'undefined') {
 969              g = window;
 970            } else if (typeof global !== 'undefined') {
 971              g = global;
 972            } else if (typeof self !== 'undefined') {
 973              g = self;
 974            } else {
 975              g = this;
 976            }
 977            g.EphoxContactWrapper = f();
 978          }
 979        }(function () {
 980          return function () {
 981            function r(e, n, t) {
 982              function o(i, f) {
 983                if (!n[i]) {
 984                  if (!e[i]) {
 985                    var c = 'function' == typeof require && require;
 986                    if (!f && c)
 987                      return c(i, !0);
 988                    if (u)
 989                      return u(i, !0);
 990                    var a = new Error('Cannot find module \'' + i + '\'');
 991                    throw a.code = 'MODULE_NOT_FOUND', a;
 992                  }
 993                  var p = n[i] = { exports: {} };
 994                  e[i][0].call(p.exports, function (r) {
 995                    var n = e[i][1][r];
 996                    return o(n || r);
 997                  }, p, p.exports, r, e, n, t);
 998                }
 999                return n[i].exports;
1000              }
1001              for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++)
1002                o(t[i]);
1003              return o;
1004            }
1005            return r;
1006          }()({
1007            1: [
1008              function (require, module, exports) {
1009                var process = module.exports = {};
1010                var cachedSetTimeout;
1011                var cachedClearTimeout;
1012                function defaultSetTimout() {
1013                  throw new Error('setTimeout has not been defined');
1014                }
1015                function defaultClearTimeout() {
1016                  throw new Error('clearTimeout has not been defined');
1017                }
1018                (function () {
1019                  try {
1020                    if (typeof setTimeout === 'function') {
1021                      cachedSetTimeout = setTimeout;
1022                    } else {
1023                      cachedSetTimeout = defaultSetTimout;
1024                    }
1025                  } catch (e) {
1026                    cachedSetTimeout = defaultSetTimout;
1027                  }
1028                  try {
1029                    if (typeof clearTimeout === 'function') {
1030                      cachedClearTimeout = clearTimeout;
1031                    } else {
1032                      cachedClearTimeout = defaultClearTimeout;
1033                    }
1034                  } catch (e) {
1035                    cachedClearTimeout = defaultClearTimeout;
1036                  }
1037                }());
1038                function runTimeout(fun) {
1039                  if (cachedSetTimeout === setTimeout) {
1040                    return setTimeout(fun, 0);
1041                  }
1042                  if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1043                    cachedSetTimeout = setTimeout;
1044                    return setTimeout(fun, 0);
1045                  }
1046                  try {
1047                    return cachedSetTimeout(fun, 0);
1048                  } catch (e) {
1049                    try {
1050                      return cachedSetTimeout.call(null, fun, 0);
1051                    } catch (e) {
1052                      return cachedSetTimeout.call(this, fun, 0);
1053                    }
1054                  }
1055                }
1056                function runClearTimeout(marker) {
1057                  if (cachedClearTimeout === clearTimeout) {
1058                    return clearTimeout(marker);
1059                  }
1060                  if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1061                    cachedClearTimeout = clearTimeout;
1062                    return clearTimeout(marker);
1063                  }
1064                  try {
1065                    return cachedClearTimeout(marker);
1066                  } catch (e) {
1067                    try {
1068                      return cachedClearTimeout.call(null, marker);
1069                    } catch (e) {
1070                      return cachedClearTimeout.call(this, marker);
1071                    }
1072                  }
1073                }
1074                var queue = [];
1075                var draining = false;
1076                var currentQueue;
1077                var queueIndex = -1;
1078                function cleanUpNextTick() {
1079                  if (!draining || !currentQueue) {
1080                    return;
1081                  }
1082                  draining = false;
1083                  if (currentQueue.length) {
1084                    queue = currentQueue.concat(queue);
1085                  } else {
1086                    queueIndex = -1;
1087                  }
1088                  if (queue.length) {
1089                    drainQueue();
1090                  }
1091                }
1092                function drainQueue() {
1093                  if (draining) {
1094                    return;
1095                  }
1096                  var timeout = runTimeout(cleanUpNextTick);
1097                  draining = true;
1098                  var len = queue.length;
1099                  while (len) {
1100                    currentQueue = queue;
1101                    queue = [];
1102                    while (++queueIndex < len) {
1103                      if (currentQueue) {
1104                        currentQueue[queueIndex].run();
1105                      }
1106                    }
1107                    queueIndex = -1;
1108                    len = queue.length;
1109                  }
1110                  currentQueue = null;
1111                  draining = false;
1112                  runClearTimeout(timeout);
1113                }
1114                process.nextTick = function (fun) {
1115                  var args = new Array(arguments.length - 1);
1116                  if (arguments.length > 1) {
1117                    for (var i = 1; i < arguments.length; i++) {
1118                      args[i - 1] = arguments[i];
1119                    }
1120                  }
1121                  queue.push(new Item(fun, args));
1122                  if (queue.length === 1 && !draining) {
1123                    runTimeout(drainQueue);
1124                  }
1125                };
1126                function Item(fun, array) {
1127                  this.fun = fun;
1128                  this.array = array;
1129                }
1130                Item.prototype.run = function () {
1131                  this.fun.apply(null, this.array);
1132                };
1133                process.title = 'browser';
1134                process.browser = true;
1135                process.env = {};
1136                process.argv = [];
1137                process.version = '';
1138                process.versions = {};
1139                function noop() {
1140                }
1141                process.on = noop;
1142                process.addListener = noop;
1143                process.once = noop;
1144                process.off = noop;
1145                process.removeListener = noop;
1146                process.removeAllListeners = noop;
1147                process.emit = noop;
1148                process.prependListener = noop;
1149                process.prependOnceListener = noop;
1150                process.listeners = function (name) {
1151                  return [];
1152                };
1153                process.binding = function (name) {
1154                  throw new Error('process.binding is not supported');
1155                };
1156                process.cwd = function () {
1157                  return '/';
1158                };
1159                process.chdir = function (dir) {
1160                  throw new Error('process.chdir is not supported');
1161                };
1162                process.umask = function () {
1163                  return 0;
1164                };
1165              },
1166              {}
1167            ],
1168            2: [
1169              function (require, module, exports) {
1170                (function (setImmediate) {
1171                  (function (root) {
1172                    var setTimeoutFunc = setTimeout;
1173                    function noop() {
1174                    }
1175                    function bind(fn, thisArg) {
1176                      return function () {
1177                        fn.apply(thisArg, arguments);
1178                      };
1179                    }
1180                    function Promise(fn) {
1181                      if (typeof this !== 'object')
1182                        throw new TypeError('Promises must be constructed via new');
1183                      if (typeof fn !== 'function')
1184                        throw new TypeError('not a function');
1185                      this._state = 0;
1186                      this._handled = false;
1187                      this._value = undefined;
1188                      this._deferreds = [];
1189                      doResolve(fn, this);
1190                    }
1191                    function handle(self, deferred) {
1192                      while (self._state === 3) {
1193                        self = self._value;
1194                      }
1195                      if (self._state === 0) {
1196                        self._deferreds.push(deferred);
1197                        return;
1198                      }
1199                      self._handled = true;
1200                      Promise._immediateFn(function () {
1201                        var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
1202                        if (cb === null) {
1203                          (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
1204                          return;
1205                        }
1206                        var ret;
1207                        try {
1208                          ret = cb(self._value);
1209                        } catch (e) {
1210                          reject(deferred.promise, e);
1211                          return;
1212                        }
1213                        resolve(deferred.promise, ret);
1214                      });
1215                    }
1216                    function resolve(self, newValue) {
1217                      try {
1218                        if (newValue === self)
1219                          throw new TypeError('A promise cannot be resolved with itself.');
1220                        if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
1221                          var then = newValue.then;
1222                          if (newValue instanceof Promise) {
1223                            self._state = 3;
1224                            self._value = newValue;
1225                            finale(self);
1226                            return;
1227                          } else if (typeof then === 'function') {
1228                            doResolve(bind(then, newValue), self);
1229                            return;
1230                          }
1231                        }
1232                        self._state = 1;
1233                        self._value = newValue;
1234                        finale(self);
1235                      } catch (e) {
1236                        reject(self, e);
1237                      }
1238                    }
1239                    function reject(self, newValue) {
1240                      self._state = 2;
1241                      self._value = newValue;
1242                      finale(self);
1243                    }
1244                    function finale(self) {
1245                      if (self._state === 2 && self._deferreds.length === 0) {
1246                        Promise._immediateFn(function () {
1247                          if (!self._handled) {
1248                            Promise._unhandledRejectionFn(self._value);
1249                          }
1250                        });
1251                      }
1252                      for (var i = 0, len = self._deferreds.length; i < len; i++) {
1253                        handle(self, self._deferreds[i]);
1254                      }
1255                      self._deferreds = null;
1256                    }
1257                    function Handler(onFulfilled, onRejected, promise) {
1258                      this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
1259                      this.onRejected = typeof onRejected === 'function' ? onRejected : null;
1260                      this.promise = promise;
1261                    }
1262                    function doResolve(fn, self) {
1263                      var done = false;
1264                      try {
1265                        fn(function (value) {
1266                          if (done)
1267                            return;
1268                          done = true;
1269                          resolve(self, value);
1270                        }, function (reason) {
1271                          if (done)
1272                            return;
1273                          done = true;
1274                          reject(self, reason);
1275                        });
1276                      } catch (ex) {
1277                        if (done)
1278                          return;
1279                        done = true;
1280                        reject(self, ex);
1281                      }
1282                    }
1283                    Promise.prototype['catch'] = function (onRejected) {
1284                      return this.then(null, onRejected);
1285                    };
1286                    Promise.prototype.then = function (onFulfilled, onRejected) {
1287                      var prom = new this.constructor(noop);
1288                      handle(this, new Handler(onFulfilled, onRejected, prom));
1289                      return prom;
1290                    };
1291                    Promise.all = function (arr) {
1292                      var args = Array.prototype.slice.call(arr);
1293                      return new Promise(function (resolve, reject) {
1294                        if (args.length === 0)
1295                          return resolve([]);
1296                        var remaining = args.length;
1297                        function res(i, val) {
1298                          try {
1299                            if (val && (typeof val === 'object' || typeof val === 'function')) {
1300                              var then = val.then;
1301                              if (typeof then === 'function') {
1302                                then.call(val, function (val) {
1303                                  res(i, val);
1304                                }, reject);
1305                                return;
1306                              }
1307                            }
1308                            args[i] = val;
1309                            if (--remaining === 0) {
1310                              resolve(args);
1311                            }
1312                          } catch (ex) {
1313                            reject(ex);
1314                          }
1315                        }
1316                        for (var i = 0; i < args.length; i++) {
1317                          res(i, args[i]);
1318                        }
1319                      });
1320                    };
1321                    Promise.resolve = function (value) {
1322                      if (value && typeof value === 'object' && value.constructor === Promise) {
1323                        return value;
1324                      }
1325                      return new Promise(function (resolve) {
1326                        resolve(value);
1327                      });
1328                    };
1329                    Promise.reject = function (value) {
1330                      return new Promise(function (resolve, reject) {
1331                        reject(value);
1332                      });
1333                    };
1334                    Promise.race = function (values) {
1335                      return new Promise(function (resolve, reject) {
1336                        for (var i = 0, len = values.length; i < len; i++) {
1337                          values[i].then(resolve, reject);
1338                        }
1339                      });
1340                    };
1341                    Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {
1342                      setImmediate(fn);
1343                    } : function (fn) {
1344                      setTimeoutFunc(fn, 0);
1345                    };
1346                    Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
1347                      if (typeof console !== 'undefined' && console) {
1348                        console.warn('Possible Unhandled Promise Rejection:', err);
1349                      }
1350                    };
1351                    Promise._setImmediateFn = function _setImmediateFn(fn) {
1352                      Promise._immediateFn = fn;
1353                    };
1354                    Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
1355                      Promise._unhandledRejectionFn = fn;
1356                    };
1357                    if (typeof module !== 'undefined' && module.exports) {
1358                      module.exports = Promise;
1359                    } else if (!root.Promise) {
1360                      root.Promise = Promise;
1361                    }
1362                  }(this));
1363                }.call(this, require('timers').setImmediate));
1364              },
1365              { 'timers': 3 }
1366            ],
1367            3: [
1368              function (require, module, exports) {
1369                (function (setImmediate, clearImmediate) {
1370                  var nextTick = require('process/browser.js').nextTick;
1371                  var apply = Function.prototype.apply;
1372                  var slice = Array.prototype.slice;
1373                  var immediateIds = {};
1374                  var nextImmediateId = 0;
1375                  exports.setTimeout = function () {
1376                    return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
1377                  };
1378                  exports.setInterval = function () {
1379                    return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
1380                  };
1381                  exports.clearTimeout = exports.clearInterval = function (timeout) {
1382                    timeout.close();
1383                  };
1384                  function Timeout(id, clearFn) {
1385                    this._id = id;
1386                    this._clearFn = clearFn;
1387                  }
1388                  Timeout.prototype.unref = Timeout.prototype.ref = function () {
1389                  };
1390                  Timeout.prototype.close = function () {
1391                    this._clearFn.call(window, this._id);
1392                  };
1393                  exports.enroll = function (item, msecs) {
1394                    clearTimeout(item._idleTimeoutId);
1395                    item._idleTimeout = msecs;
1396                  };
1397                  exports.unenroll = function (item) {
1398                    clearTimeout(item._idleTimeoutId);
1399                    item._idleTimeout = -1;
1400                  };
1401                  exports._unrefActive = exports.active = function (item) {
1402                    clearTimeout(item._idleTimeoutId);
1403                    var msecs = item._idleTimeout;
1404                    if (msecs >= 0) {
1405                      item._idleTimeoutId = setTimeout(function onTimeout() {
1406                        if (item._onTimeout)
1407                          item._onTimeout();
1408                      }, msecs);
1409                    }
1410                  };
1411                  exports.setImmediate = typeof setImmediate === 'function' ? setImmediate : function (fn) {
1412                    var id = nextImmediateId++;
1413                    var args = arguments.length < 2 ? false : slice.call(arguments, 1);
1414                    immediateIds[id] = true;
1415                    nextTick(function onNextTick() {
1416                      if (immediateIds[id]) {
1417                        if (args) {
1418                          fn.apply(null, args);
1419                        } else {
1420                          fn.call(null);
1421                        }
1422                        exports.clearImmediate(id);
1423                      }
1424                    });
1425                    return id;
1426                  };
1427                  exports.clearImmediate = typeof clearImmediate === 'function' ? clearImmediate : function (id) {
1428                    delete immediateIds[id];
1429                  };
1430                }.call(this, require('timers').setImmediate, require('timers').clearImmediate));
1431              },
1432              {
1433                'process/browser.js': 1,
1434                'timers': 3
1435              }
1436            ],
1437            4: [
1438              function (require, module, exports) {
1439                var promisePolyfill = require('promise-polyfill');
1440                var Global = function () {
1441                  if (typeof window !== 'undefined') {
1442                    return window;
1443                  } else {
1444                    return Function('return this;')();
1445                  }
1446                }();
1447                module.exports = { boltExport: Global.Promise || promisePolyfill };
1448              },
1449              { 'promise-polyfill': 2 }
1450            ]
1451          }, {}, [4])(4);
1452        }));
1453      }(undefined, exports$1, module, undefined));
1454      var Promise = module.exports.boltExport;
1455  
1456      var nu = function (baseFn) {
1457        var data = Option.none();
1458        var callbacks = [];
1459        var map = function (f) {
1460          return nu(function (nCallback) {
1461            get(function (data) {
1462              nCallback(f(data));
1463            });
1464          });
1465        };
1466        var get = function (nCallback) {
1467          if (isReady()) {
1468            call(nCallback);
1469          } else {
1470            callbacks.push(nCallback);
1471          }
1472        };
1473        var set = function (x) {
1474          data = Option.some(x);
1475          run(callbacks);
1476          callbacks = [];
1477        };
1478        var isReady = function () {
1479          return data.isSome();
1480        };
1481        var run = function (cbs) {
1482          each(cbs, call);
1483        };
1484        var call = function (cb) {
1485          data.each(function (x) {
1486            domGlobals.setTimeout(function () {
1487              cb(x);
1488            }, 0);
1489          });
1490        };
1491        baseFn(set);
1492        return {
1493          get: get,
1494          map: map,
1495          isReady: isReady
1496        };
1497      };
1498      var pure = function (a) {
1499        return nu(function (callback) {
1500          callback(a);
1501        });
1502      };
1503      var LazyValue = {
1504        nu: nu,
1505        pure: pure
1506      };
1507  
1508      var errorReporter = function (err) {
1509        domGlobals.setTimeout(function () {
1510          throw err;
1511        }, 0);
1512      };
1513      var make = function (run) {
1514        var get = function (callback) {
1515          run().then(callback, errorReporter);
1516        };
1517        var map = function (fab) {
1518          return make(function () {
1519            return run().then(fab);
1520          });
1521        };
1522        var bind = function (aFutureB) {
1523          return make(function () {
1524            return run().then(function (v) {
1525              return aFutureB(v).toPromise();
1526            });
1527          });
1528        };
1529        var anonBind = function (futureB) {
1530          return make(function () {
1531            return run().then(function () {
1532              return futureB.toPromise();
1533            });
1534          });
1535        };
1536        var toLazy = function () {
1537          return LazyValue.nu(get);
1538        };
1539        var toCached = function () {
1540          var cache = null;
1541          return make(function () {
1542            if (cache === null) {
1543              cache = run();
1544            }
1545            return cache;
1546          });
1547        };
1548        var toPromise = run;
1549        return {
1550          map: map,
1551          bind: bind,
1552          anonBind: anonBind,
1553          toLazy: toLazy,
1554          toCached: toCached,
1555          toPromise: toPromise,
1556          get: get
1557        };
1558      };
1559      var nu$1 = function (baseFn) {
1560        return make(function () {
1561          return new Promise(baseFn);
1562        });
1563      };
1564      var pure$1 = function (a) {
1565        return make(function () {
1566          return Promise.resolve(a);
1567        });
1568      };
1569      var Future = {
1570        nu: nu$1,
1571        pure: pure$1
1572      };
1573  
1574      var par = function (asyncValues, nu) {
1575        return nu(function (callback) {
1576          var r = [];
1577          var count = 0;
1578          var cb = function (i) {
1579            return function (value) {
1580              r[i] = value;
1581              count++;
1582              if (count >= asyncValues.length) {
1583                callback(r);
1584              }
1585            };
1586          };
1587          if (asyncValues.length === 0) {
1588            callback([]);
1589          } else {
1590            each(asyncValues, function (asyncValue, i) {
1591              asyncValue.get(cb(i));
1592            });
1593          }
1594        });
1595      };
1596  
1597      var par$1 = function (futures) {
1598        return par(futures, Future.nu);
1599      };
1600      var mapM = function (array, fn) {
1601        var futures = map(array, fn);
1602        return par$1(futures);
1603      };
1604  
1605      var value = function () {
1606        var subject = Cell(Option.none());
1607        var clear = function () {
1608          subject.set(Option.none());
1609        };
1610        var set = function (s) {
1611          subject.set(Option.some(s));
1612        };
1613        var on = function (f) {
1614          subject.get().each(f);
1615        };
1616        var isSet = function () {
1617          return subject.get().isSome();
1618        };
1619        return {
1620          clear: clear,
1621          set: set,
1622          isSet: isSet,
1623          on: on
1624        };
1625      };
1626  
1627      var pasteHtml$1 = function (editor, html, internalFlag) {
1628        var internal = internalFlag ? internalFlag : InternalHtml.isMarked(html);
1629        var args = ProcessFilters.process(editor, InternalHtml.unmark(html), internal);
1630        if (args.cancelled === false) {
1631          SmartPaste.insertContent(editor, args.content);
1632        }
1633      };
1634      var pasteText = function (editor, text) {
1635        text = editor.dom.encode(text).replace(/\r\n/g, '\n');
1636        text = Newlines.convert(text, editor.settings.forced_root_block, editor.settings.forced_root_block_attrs);
1637        pasteHtml$1(editor, text, false);
1638      };
1639      var getDataTransferItems = function (dataTransfer) {
1640        var items = {};
1641        var mceInternalUrlPrefix = 'data:text/mce-internal,';
1642        if (dataTransfer) {
1643          if (dataTransfer.getData) {
1644            var legacyText = dataTransfer.getData('Text');
1645            if (legacyText && legacyText.length > 0) {
1646              if (legacyText.indexOf(mceInternalUrlPrefix) === -1) {
1647                items['text/plain'] = legacyText;
1648              }
1649            }
1650          }
1651          if (dataTransfer.types) {
1652            for (var i = 0; i < dataTransfer.types.length; i++) {
1653              var contentType = dataTransfer.types[i];
1654              try {
1655                items[contentType] = dataTransfer.getData(contentType);
1656              } catch (ex) {
1657                items[contentType] = '';
1658              }
1659            }
1660          }
1661        }
1662        return items;
1663      };
1664      var getClipboardContent = function (editor, clipboardEvent) {
1665        var content = getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer);
1666        return Utils.isMsEdge() ? global$4.extend(content, { 'text/html': '' }) : content;
1667      };
1668      var hasContentType = function (clipboardContent, mimeType) {
1669        return mimeType in clipboardContent && clipboardContent[mimeType].length > 0;
1670      };
1671      var hasHtmlOrText = function (content) {
1672        return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain');
1673      };
1674      var getBase64FromUri = function (uri) {
1675        var idx;
1676        idx = uri.indexOf(',');
1677        if (idx !== -1) {
1678          return uri.substr(idx + 1);
1679        }
1680        return null;
1681      };
1682      var isValidDataUriImage = function (settings, imgElm) {
1683        return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true;
1684      };
1685      var extractFilename = function (editor, str) {
1686        var m = str.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i);
1687        return m ? editor.dom.encode(m[1]) : null;
1688      };
1689      var uniqueId = Utils.createIdGenerator('mceclip');
1690      var pasteImage = function (editor, imageItem) {
1691        var base64 = getBase64FromUri(imageItem.uri);
1692        var id = uniqueId();
1693        var name = editor.settings.images_reuse_filename && imageItem.blob.name ? extractFilename(editor, imageItem.blob.name) : id;
1694        var img = new domGlobals.Image();
1695        img.src = imageItem.uri;
1696        if (isValidDataUriImage(editor.settings, img)) {
1697          var blobCache = editor.editorUpload.blobCache;
1698          var blobInfo = void 0, existingBlobInfo = void 0;
1699          existingBlobInfo = blobCache.findFirst(function (cachedBlobInfo) {
1700            return cachedBlobInfo.base64() === base64;
1701          });
1702          if (!existingBlobInfo) {
1703            blobInfo = blobCache.create(id, imageItem.blob, base64, name);
1704            blobCache.add(blobInfo);
1705          } else {
1706            blobInfo = existingBlobInfo;
1707          }
1708          pasteHtml$1(editor, '<img src="' + blobInfo.blobUri() + '">', false);
1709        } else {
1710          pasteHtml$1(editor, '<img src="' + imageItem.uri + '">', false);
1711        }
1712      };
1713      var isClipboardEvent = function (event) {
1714        return event.type === 'paste';
1715      };
1716      var readBlobsAsDataUris = function (items) {
1717        return mapM(items, function (item) {
1718          return Future.nu(function (resolve) {
1719            var blob = item.getAsFile ? item.getAsFile() : item;
1720            var reader = new window.FileReader();
1721            reader.onload = function () {
1722              resolve({
1723                blob: blob,
1724                uri: reader.result
1725              });
1726            };
1727            reader.readAsDataURL(blob);
1728          });
1729        });
1730      };
1731      var getImagesFromDataTransfer = function (dataTransfer) {
1732        var items = dataTransfer.items ? map(from$1(dataTransfer.items), function (item) {
1733          return item.getAsFile();
1734        }) : [];
1735        var files = dataTransfer.files ? from$1(dataTransfer.files) : [];
1736        var images = filter$1(items.length > 0 ? items : files, function (file) {
1737          return /^image\/(jpeg|png|gif|bmp)$/.test(file.type);
1738        });
1739        return images;
1740      };
1741      var pasteImageData = function (editor, e, rng) {
1742        var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer;
1743        if (editor.settings.paste_data_images && dataTransfer) {
1744          var images = getImagesFromDataTransfer(dataTransfer);
1745          if (images.length > 0) {
1746            e.preventDefault();
1747            readBlobsAsDataUris(images).get(function (blobResults) {
1748              if (rng) {
1749                editor.selection.setRng(rng);
1750              }
1751              each(blobResults, function (result) {
1752                pasteImage(editor, result);
1753              });
1754            });
1755            return true;
1756          }
1757        }
1758        return false;
1759      };
1760      var isBrokenAndroidClipboardEvent = function (e) {
1761        var clipboardData = e.clipboardData;
1762        return domGlobals.navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
1763      };
1764      var isKeyboardPasteEvent = function (e) {
1765        return global$5.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45;
1766      };
1767      var registerEventHandlers = function (editor, pasteBin, pasteFormat) {
1768        var keyboardPasteEvent = value();
1769        var keyboardPastePlainTextState;
1770        editor.on('keydown', function (e) {
1771          function removePasteBinOnKeyUp(e) {
1772            if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
1773              pasteBin.remove();
1774            }
1775          }
1776          if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
1777            keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86;
1778            if (keyboardPastePlainTextState && global$2.webkit && domGlobals.navigator.userAgent.indexOf('Version/') !== -1) {
1779              return;
1780            }
1781            e.stopImmediatePropagation();
1782            keyboardPasteEvent.set(e);
1783            window.setTimeout(function () {
1784              keyboardPasteEvent.clear();
1785            }, 100);
1786            if (global$2.ie && keyboardPastePlainTextState) {
1787              e.preventDefault();
1788              Events.firePaste(editor, true);
1789              return;
1790            }
1791            pasteBin.remove();
1792            pasteBin.create();
1793            editor.once('keyup', removePasteBinOnKeyUp);
1794            editor.once('paste', function () {
1795              editor.off('keyup', removePasteBinOnKeyUp);
1796            });
1797          }
1798        });
1799        function insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal) {
1800          var content, isPlainTextHtml;
1801          if (hasContentType(clipboardContent, 'text/html')) {
1802            content = clipboardContent['text/html'];
1803          } else {
1804            content = pasteBin.getHtml();
1805            internal = internal ? internal : InternalHtml.isMarked(content);
1806            if (pasteBin.isDefaultContent(content)) {
1807              plainTextMode = true;
1808            }
1809          }
1810          content = Utils.trimHtml(content);
1811          pasteBin.remove();
1812          isPlainTextHtml = internal === false && Newlines.isPlainText(content);
1813          if (!content.length || isPlainTextHtml) {
1814            plainTextMode = true;
1815          }
1816          if (plainTextMode) {
1817            if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) {
1818              content = clipboardContent['text/plain'];
1819            } else {
1820              content = Utils.innerText(content);
1821            }
1822          }
1823          if (pasteBin.isDefaultContent(content)) {
1824            if (!isKeyBoardPaste) {
1825              editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
1826            }
1827            return;
1828          }
1829          if (plainTextMode) {
1830            pasteText(editor, content);
1831          } else {
1832            pasteHtml$1(editor, content, internal);
1833          }
1834        }
1835        var getLastRng = function () {
1836          return pasteBin.getLastRng() || editor.selection.getRng();
1837        };
1838        editor.on('paste', function (e) {
1839          var isKeyBoardPaste = keyboardPasteEvent.isSet();
1840          var clipboardContent = getClipboardContent(editor, e);
1841          var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState;
1842          var internal = hasContentType(clipboardContent, InternalHtml.internalHtmlMime());
1843          keyboardPastePlainTextState = false;
1844          if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
1845            pasteBin.remove();
1846            return;
1847          }
1848          if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) {
1849            pasteBin.remove();
1850            return;
1851          }
1852          if (!isKeyBoardPaste) {
1853            e.preventDefault();
1854          }
1855          if (global$2.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) {
1856            pasteBin.create();
1857            editor.dom.bind(pasteBin.getEl(), 'paste', function (e) {
1858              e.stopPropagation();
1859            });
1860            editor.getDoc().execCommand('Paste', false, null);
1861            clipboardContent['text/html'] = pasteBin.getHtml();
1862          }
1863          if (hasContentType(clipboardContent, 'text/html')) {
1864            e.preventDefault();
1865            if (!internal) {
1866              internal = InternalHtml.isMarked(clipboardContent['text/html']);
1867            }
1868            insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
1869          } else {
1870            global$3.setEditorTimeout(editor, function () {
1871              insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
1872            }, 0);
1873          }
1874        });
1875      };
1876      var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) {
1877        registerEventHandlers(editor, pasteBin, pasteFormat);
1878        var src;
1879        editor.parser.addNodeFilter('img', function (nodes, name, args) {
1880          var isPasteInsert = function (args) {
1881            return args.data && args.data.paste === true;
1882          };
1883          var remove = function (node) {
1884            if (!node.attr('data-mce-object') && src !== global$2.transparentSrc) {
1885              node.remove();
1886            }
1887          };
1888          var isWebKitFakeUrl = function (src) {
1889            return src.indexOf('webkit-fake-url') === 0;
1890          };
1891          var isDataUri = function (src) {
1892            return src.indexOf('data:') === 0;
1893          };
1894          if (!editor.settings.paste_data_images && isPasteInsert(args)) {
1895            var i = nodes.length;
1896            while (i--) {
1897              src = nodes[i].attributes.map.src;
1898              if (!src) {
1899                continue;
1900              }
1901              if (isWebKitFakeUrl(src)) {
1902                remove(nodes[i]);
1903              } else if (!editor.settings.allow_html_data_urls && isDataUri(src)) {
1904                remove(nodes[i]);
1905              }
1906            }
1907          }
1908        });
1909      };
1910  
1911      var getPasteBinParent = function (editor) {
1912        return global$2.ie && editor.inline ? domGlobals.document.body : editor.getBody();
1913      };
1914      var isExternalPasteBin = function (editor) {
1915        return getPasteBinParent(editor) !== editor.getBody();
1916      };
1917      var delegatePasteEvents = function (editor, pasteBinElm, pasteBinDefaultContent) {
1918        if (isExternalPasteBin(editor)) {
1919          editor.dom.bind(pasteBinElm, 'paste keyup', function (e) {
1920            if (!isDefault(editor, pasteBinDefaultContent)) {
1921              editor.fire('paste');
1922            }
1923          });
1924        }
1925      };
1926      var create = function (editor, lastRngCell, pasteBinDefaultContent) {
1927        var dom = editor.dom, body = editor.getBody();
1928        var pasteBinElm;
1929        lastRngCell.set(editor.selection.getRng());
1930        pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', {
1931          'id': 'mcepastebin',
1932          'class': 'mce-pastebin',
1933          'contentEditable': true,
1934          'data-mce-bogus': 'all',
1935          'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0'
1936        }, pasteBinDefaultContent);
1937        if (global$2.ie || global$2.gecko) {
1938          dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535);
1939        }
1940        dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) {
1941          e.stopPropagation();
1942        });
1943        delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent);
1944        pasteBinElm.focus();
1945        editor.selection.select(pasteBinElm, true);
1946      };
1947      var remove = function (editor, lastRngCell) {
1948        if (getEl(editor)) {
1949          var pasteBinClone = void 0;
1950          var lastRng = lastRngCell.get();
1951          while (pasteBinClone = editor.dom.get('mcepastebin')) {
1952            editor.dom.remove(pasteBinClone);
1953            editor.dom.unbind(pasteBinClone);
1954          }
1955          if (lastRng) {
1956            editor.selection.setRng(lastRng);
1957          }
1958        }
1959        lastRngCell.set(null);
1960      };
1961      var getEl = function (editor) {
1962        return editor.dom.get('mcepastebin');
1963      };
1964      var getHtml = function (editor) {
1965        var pasteBinElm, pasteBinClones, i, dirtyWrappers, cleanWrapper;
1966        var copyAndRemove = function (toElm, fromElm) {
1967          toElm.appendChild(fromElm);
1968          editor.dom.remove(fromElm, true);
1969        };
1970        pasteBinClones = global$4.grep(getPasteBinParent(editor).childNodes, function (elm) {
1971          return elm.id === 'mcepastebin';
1972        });
1973        pasteBinElm = pasteBinClones.shift();
1974        global$4.each(pasteBinClones, function (pasteBinClone) {
1975          copyAndRemove(pasteBinElm, pasteBinClone);
1976        });
1977        dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm);
1978        for (i = dirtyWrappers.length - 1; i >= 0; i--) {
1979          cleanWrapper = editor.dom.create('div');
1980          pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]);
1981          copyAndRemove(cleanWrapper, dirtyWrappers[i]);
1982        }
1983        return pasteBinElm ? pasteBinElm.innerHTML : '';
1984      };
1985      var getLastRng = function (lastRng) {
1986        return lastRng.get();
1987      };
1988      var isDefaultContent = function (pasteBinDefaultContent, content) {
1989        return content === pasteBinDefaultContent;
1990      };
1991      var isPasteBin = function (elm) {
1992        return elm && elm.id === 'mcepastebin';
1993      };
1994      var isDefault = function (editor, pasteBinDefaultContent) {
1995        var pasteBinElm = getEl(editor);
1996        return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML);
1997      };
1998      var PasteBin = function (editor) {
1999        var lastRng = Cell(null);
2000        var pasteBinDefaultContent = '%MCEPASTEBIN%';
2001        return {
2002          create: function () {
2003            return create(editor, lastRng, pasteBinDefaultContent);
2004          },
2005          remove: function () {
2006            return remove(editor, lastRng);
2007          },
2008          getEl: function () {
2009            return getEl(editor);
2010          },
2011          getHtml: function () {
2012            return getHtml(editor);
2013          },
2014          getLastRng: function () {
2015            return getLastRng(lastRng);
2016          },
2017          isDefault: function () {
2018            return isDefault(editor, pasteBinDefaultContent);
2019          },
2020          isDefaultContent: function (content) {
2021            return isDefaultContent(pasteBinDefaultContent, content);
2022          }
2023        };
2024      };
2025  
2026      var Clipboard = function (editor, pasteFormat) {
2027        var pasteBin = PasteBin(editor);
2028        editor.on('preInit', function () {
2029          return registerEventsAndFilters(editor, pasteBin, pasteFormat);
2030        });
2031        return {
2032          pasteFormat: pasteFormat,
2033          pasteHtml: function (html, internalFlag) {
2034            return pasteHtml$1(editor, html, internalFlag);
2035          },
2036          pasteText: function (text) {
2037            return pasteText(editor, text);
2038          },
2039          pasteImageData: function (e, rng) {
2040            return pasteImageData(editor, e, rng);
2041          },
2042          getDataTransferItems: getDataTransferItems,
2043          hasHtmlOrText: hasHtmlOrText,
2044          hasContentType: hasContentType
2045        };
2046      };
2047  
2048      var noop = function () {
2049      };
2050      var hasWorkingClipboardApi = function (clipboardData) {
2051        return global$2.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && Utils.isMsEdge() !== true;
2052      };
2053      var setHtml5Clipboard = function (clipboardData, html, text) {
2054        if (hasWorkingClipboardApi(clipboardData)) {
2055          try {
2056            clipboardData.clearData();
2057            clipboardData.setData('text/html', html);
2058            clipboardData.setData('text/plain', text);
2059            clipboardData.setData(InternalHtml.internalHtmlMime(), html);
2060            return true;
2061          } catch (e) {
2062            return false;
2063          }
2064        } else {
2065          return false;
2066        }
2067      };
2068      var setClipboardData = function (evt, data, fallback, done) {
2069        if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) {
2070          evt.preventDefault();
2071          done();
2072        } else {
2073          fallback(data.html, done);
2074        }
2075      };
2076      var fallback = function (editor) {
2077        return function (html, done) {
2078          var markedHtml = InternalHtml.mark(html);
2079          var outer = editor.dom.create('div', {
2080            'contenteditable': 'false',
2081            'data-mce-bogus': 'all'
2082          });
2083          var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml);
2084          editor.dom.setStyles(outer, {
2085            position: 'fixed',
2086            top: '0',
2087            left: '-3000px',
2088            width: '1000px',
2089            overflow: 'hidden'
2090          });
2091          outer.appendChild(inner);
2092          editor.dom.add(editor.getBody(), outer);
2093          var range = editor.selection.getRng();
2094          inner.focus();
2095          var offscreenRange = editor.dom.createRng();
2096          offscreenRange.selectNodeContents(inner);
2097          editor.selection.setRng(offscreenRange);
2098          setTimeout(function () {
2099            editor.selection.setRng(range);
2100            outer.parentNode.removeChild(outer);
2101            done();
2102          }, 0);
2103        };
2104      };
2105      var getData = function (editor) {
2106        return {
2107          html: editor.selection.getContent({ contextual: true }),
2108          text: editor.selection.getContent({ format: 'text' })
2109        };
2110      };
2111      var isTableSelection = function (editor) {
2112        return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());
2113      };
2114      var hasSelectedContent = function (editor) {
2115        return !editor.selection.isCollapsed() || isTableSelection(editor);
2116      };
2117      var cut = function (editor) {
2118        return function (evt) {
2119          if (hasSelectedContent(editor)) {
2120            setClipboardData(evt, getData(editor), fallback(editor), function () {
2121              setTimeout(function () {
2122                editor.execCommand('Delete');
2123              }, 0);
2124            });
2125          }
2126        };
2127      };
2128      var copy = function (editor) {
2129        return function (evt) {
2130          if (hasSelectedContent(editor)) {
2131            setClipboardData(evt, getData(editor), fallback(editor), noop);
2132          }
2133        };
2134      };
2135      var register$1 = function (editor) {
2136        editor.on('cut', cut(editor));
2137        editor.on('copy', copy(editor));
2138      };
2139      var CutCopy = { register: register$1 };
2140  
2141      var global$b = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
2142  
2143      var getCaretRangeFromEvent = function (editor, e) {
2144        return global$b.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
2145      };
2146      var isPlainTextFileUrl = function (content) {
2147        var plainTextContent = content['text/plain'];
2148        return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false;
2149      };
2150      var setFocusedRange = function (editor, rng) {
2151        editor.focus();
2152        editor.selection.setRng(rng);
2153      };
2154      var setup = function (editor, clipboard, draggingInternallyState) {
2155        if (Settings.shouldBlockDrop(editor)) {
2156          editor.on('dragend dragover draggesture dragdrop drop drag', function (e) {
2157            e.preventDefault();
2158            e.stopPropagation();
2159          });
2160        }
2161        if (!Settings.shouldPasteDataImages(editor)) {
2162          editor.on('drop', function (e) {
2163            var dataTransfer = e.dataTransfer;
2164            if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
2165              e.preventDefault();
2166            }
2167          });
2168        }
2169        editor.on('drop', function (e) {
2170          var dropContent, rng;
2171          rng = getCaretRangeFromEvent(editor, e);
2172          if (e.isDefaultPrevented() || draggingInternallyState.get()) {
2173            return;
2174          }
2175          dropContent = clipboard.getDataTransferItems(e.dataTransfer);
2176          var internal = clipboard.hasContentType(dropContent, InternalHtml.internalHtmlMime());
2177          if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) {
2178            return;
2179          }
2180          if (rng && Settings.shouldFilterDrop(editor)) {
2181            var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
2182            if (content_1) {
2183              e.preventDefault();
2184              global$3.setEditorTimeout(editor, function () {
2185                editor.undoManager.transact(function () {
2186                  if (dropContent['mce-internal']) {
2187                    editor.execCommand('Delete');
2188                  }
2189                  setFocusedRange(editor, rng);
2190                  content_1 = Utils.trimHtml(content_1);
2191                  if (!dropContent['text/html']) {
2192                    clipboard.pasteText(content_1);
2193                  } else {
2194                    clipboard.pasteHtml(content_1, internal);
2195                  }
2196                });
2197              });
2198            }
2199          }
2200        });
2201        editor.on('dragstart', function (e) {
2202          draggingInternallyState.set(true);
2203        });
2204        editor.on('dragover dragend', function (e) {
2205          if (Settings.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) {
2206            e.preventDefault();
2207            setFocusedRange(editor, getCaretRangeFromEvent(editor, e));
2208          }
2209          if (e.type === 'dragend') {
2210            draggingInternallyState.set(false);
2211          }
2212        });
2213      };
2214      var DragDrop = { setup: setup };
2215  
2216      var setup$1 = function (editor) {
2217        var plugin = editor.plugins.paste;
2218        var preProcess = Settings.getPreProcess(editor);
2219        if (preProcess) {
2220          editor.on('PastePreProcess', function (e) {
2221            preProcess.call(plugin, plugin, e);
2222          });
2223        }
2224        var postProcess = Settings.getPostProcess(editor);
2225        if (postProcess) {
2226          editor.on('PastePostProcess', function (e) {
2227            postProcess.call(plugin, plugin, e);
2228          });
2229        }
2230      };
2231      var PrePostProcess = { setup: setup$1 };
2232  
2233      function addPreProcessFilter(editor, filterFunc) {
2234        editor.on('PastePreProcess', function (e) {
2235          e.content = filterFunc(editor, e.content, e.internal, e.wordContent);
2236        });
2237      }
2238      function addPostProcessFilter(editor, filterFunc) {
2239        editor.on('PastePostProcess', function (e) {
2240          filterFunc(editor, e.node);
2241        });
2242      }
2243      function removeExplorerBrElementsAfterBlocks(editor, html) {
2244        if (!WordFilter.isWordContent(html)) {
2245          return html;
2246        }
2247        var blockElements = [];
2248        global$4.each(editor.schema.getBlockElements(), function (block, blockName) {
2249          blockElements.push(blockName);
2250        });
2251        var explorerBlocksRegExp = new RegExp('(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*', 'g');
2252        html = Utils.filter(html, [[
2253            explorerBlocksRegExp,
2254            '$1'
2255          ]]);
2256        html = Utils.filter(html, [
2257          [
2258            /<br><br>/g,
2259            '<BR><BR>'
2260          ],
2261          [
2262            /<br>/g,
2263            ' '
2264          ],
2265          [
2266            /<BR><BR>/g,
2267            '<br>'
2268          ]
2269        ]);
2270        return html;
2271      }
2272      function removeWebKitStyles(editor, content, internal, isWordHtml) {
2273        if (isWordHtml || internal) {
2274          return content;
2275        }
2276        var webKitStylesSetting = Settings.getWebkitStyles(editor);
2277        var webKitStyles;
2278        if (Settings.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') {
2279          return content;
2280        }
2281        if (webKitStylesSetting) {
2282          webKitStyles = webKitStylesSetting.split(/[, ]/);
2283        }
2284        if (webKitStyles) {
2285          var dom_1 = editor.dom, node_1 = editor.selection.getNode();
2286          content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) {
2287            var inputStyles = dom_1.parseStyle(dom_1.decode(value));
2288            var outputStyles = {};
2289            if (webKitStyles === 'none') {
2290              return before + after;
2291            }
2292            for (var i = 0; i < webKitStyles.length; i++) {
2293              var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true);
2294              if (/color/.test(webKitStyles[i])) {
2295                inputValue = dom_1.toHex(inputValue);
2296                currentValue = dom_1.toHex(currentValue);
2297              }
2298              if (currentValue !== inputValue) {
2299                outputStyles[webKitStyles[i]] = inputValue;
2300              }
2301            }
2302            outputStyles = dom_1.serializeStyle(outputStyles, 'span');
2303            if (outputStyles) {
2304              return before + ' style="' + outputStyles + '"' + after;
2305            }
2306            return before + after;
2307          });
2308        } else {
2309          content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
2310        }
2311        content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) {
2312          return before + ' style="' + value + '"' + after;
2313        });
2314        return content;
2315      }
2316      function removeUnderlineAndFontInAnchor(editor, root) {
2317        editor.$('a', root).find('font,u').each(function (i, node) {
2318          editor.dom.remove(node, true);
2319        });
2320      }
2321      var setup$2 = function (editor) {
2322        if (global$2.webkit) {
2323          addPreProcessFilter(editor, removeWebKitStyles);
2324        }
2325        if (global$2.ie) {
2326          addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks);
2327          addPostProcessFilter(editor, removeUnderlineAndFontInAnchor);
2328        }
2329      };
2330      var Quirks = { setup: setup$2 };
2331  
2332      var stateChange = function (editor, clipboard, e) {
2333        var ctrl = e.control;
2334        ctrl.active(clipboard.pasteFormat.get() === 'text');
2335        editor.on('PastePlainTextToggle', function (e) {
2336          ctrl.active(e.state);
2337        });
2338      };
2339      var register$2 = function (editor, clipboard) {
2340        var postRender = curry(stateChange, editor, clipboard);
2341        editor.addButton('pastetext', {
2342          active: false,
2343          icon: 'pastetext',
2344          tooltip: 'Paste as text',
2345          cmd: 'mceTogglePlainTextPaste',
2346          onPostRender: postRender
2347        });
2348        editor.addMenuItem('pastetext', {
2349          text: 'Paste as text',
2350          selectable: true,
2351          active: clipboard.pasteFormat,
2352          cmd: 'mceTogglePlainTextPaste',
2353          onPostRender: postRender
2354        });
2355      };
2356      var Buttons = { register: register$2 };
2357  
2358      global$1.add('paste', function (editor) {
2359        if (DetectProPlugin.hasProPlugin(editor) === false) {
2360          var userIsInformedState = Cell(false);
2361          var draggingInternallyState = Cell(false);
2362          var pasteFormat = Cell(Settings.isPasteAsTextEnabled(editor) ? 'text' : 'html');
2363          var clipboard = Clipboard(editor, pasteFormat);
2364          var quirks = Quirks.setup(editor);
2365          Buttons.register(editor, clipboard);
2366          Commands.register(editor, clipboard, userIsInformedState);
2367          PrePostProcess.setup(editor);
2368          CutCopy.register(editor);
2369          DragDrop.setup(editor, clipboard, draggingInternallyState);
2370          return Api.get(clipboard, quirks);
2371        }
2372      });
2373      function Plugin () {
2374      }
2375  
2376      return Plugin;
2377  
2378  }(window));
2379  })();


Generated: Fri Oct 25 08:20:01 2019 Cross-referenced by PHPXref 0.7