[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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.Serializer');
 253  
 254      var global$9 = tinymce.util.Tools.resolve('tinymce.html.Node');
 255  
 256      var global$a = tinymce.util.Tools.resolve('tinymce.html.Schema');
 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$a();
 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$9(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$9('b', 1));
 542        }
 543        if (/(italic)/i.test(outputStyles['font-style'])) {
 544          delete outputStyles['font-style'];
 545          node.wrap(new global$9('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$a({
 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$8({ 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 preProcess$1 = function (editor, html) {
 668        var parser = global$7({}, editor.schema);
 669        parser.addNodeFilter('meta', function (nodes) {
 670          global$4.each(nodes, function (node) {
 671            return node.remove();
 672          });
 673        });
 674        var fragment = parser.parse(html, {
 675          forced_root_block: false,
 676          isRootContent: true
 677        });
 678        return global$8({ validate: editor.settings.validate }, editor.schema).serialize(fragment);
 679      };
 680      var processResult = function (content, cancelled) {
 681        return {
 682          content: content,
 683          cancelled: cancelled
 684        };
 685      };
 686      var postProcessFilter = function (editor, html, internal, isWordHtml) {
 687        var tempBody = editor.dom.create('div', { style: 'display:none' }, html);
 688        var postProcessArgs = Events.firePastePostProcess(editor, tempBody, internal, isWordHtml);
 689        return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented());
 690      };
 691      var filterContent = function (editor, content, internal, isWordHtml) {
 692        var preProcessArgs = Events.firePastePreProcess(editor, content, internal, isWordHtml);
 693        var filteredContent = preProcess$1(editor, preProcessArgs.content);
 694        if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) {
 695          return postProcessFilter(editor, filteredContent, internal, isWordHtml);
 696        } else {
 697          return processResult(filteredContent, preProcessArgs.isDefaultPrevented());
 698        }
 699      };
 700      var process = function (editor, html, internal) {
 701        var isWordHtml = WordFilter.isWordContent(html);
 702        var content = isWordHtml ? WordFilter.preProcess(editor, html) : html;
 703        return filterContent(editor, content, internal, isWordHtml);
 704      };
 705      var ProcessFilters = { process: process };
 706  
 707      var pasteHtml = function (editor, html) {
 708        editor.insertContent(html, {
 709          merge: Settings.shouldMergeFormats(editor),
 710          paste: true
 711        });
 712        return true;
 713      };
 714      var isAbsoluteUrl = function (url) {
 715        return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url);
 716      };
 717      var isImageUrl = function (url) {
 718        return isAbsoluteUrl(url) && /.(gif|jpe?g|png)$/.test(url);
 719      };
 720      var createImage = function (editor, url, pasteHtmlFn) {
 721        editor.undoManager.extra(function () {
 722          pasteHtmlFn(editor, url);
 723        }, function () {
 724          editor.insertContent('<img src="' + url + '">');
 725        });
 726        return true;
 727      };
 728      var createLink = function (editor, url, pasteHtmlFn) {
 729        editor.undoManager.extra(function () {
 730          pasteHtmlFn(editor, url);
 731        }, function () {
 732          editor.execCommand('mceInsertLink', false, url);
 733        });
 734        return true;
 735      };
 736      var linkSelection = function (editor, html, pasteHtmlFn) {
 737        return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false;
 738      };
 739      var insertImage = function (editor, html, pasteHtmlFn) {
 740        return isImageUrl(html) ? createImage(editor, html, pasteHtmlFn) : false;
 741      };
 742      var smartInsertContent = function (editor, html) {
 743        global$4.each([
 744          linkSelection,
 745          insertImage,
 746          pasteHtml
 747        ], function (action) {
 748          return action(editor, html, pasteHtml) !== true;
 749        });
 750      };
 751      var insertContent = function (editor, html) {
 752        if (Settings.isSmartPasteEnabled(editor) === false) {
 753          pasteHtml(editor, html);
 754        } else {
 755          smartInsertContent(editor, html);
 756        }
 757      };
 758      var SmartPaste = {
 759        isImageUrl: isImageUrl,
 760        isAbsoluteUrl: isAbsoluteUrl,
 761        insertContent: insertContent
 762      };
 763  
 764      var noop = function () {
 765      };
 766      var constant = function (value) {
 767        return function () {
 768          return value;
 769        };
 770      };
 771      function curry(fn) {
 772        var initialArgs = [];
 773        for (var _i = 1; _i < arguments.length; _i++) {
 774          initialArgs[_i - 1] = arguments[_i];
 775        }
 776        return function () {
 777          var restArgs = [];
 778          for (var _i = 0; _i < arguments.length; _i++) {
 779            restArgs[_i] = arguments[_i];
 780          }
 781          var all = initialArgs.concat(restArgs);
 782          return fn.apply(null, all);
 783        };
 784      }
 785      var never = constant(false);
 786      var always = constant(true);
 787  
 788      var none = function () {
 789        return NONE;
 790      };
 791      var NONE = function () {
 792        var eq = function (o) {
 793          return o.isNone();
 794        };
 795        var call = function (thunk) {
 796          return thunk();
 797        };
 798        var id = function (n) {
 799          return n;
 800        };
 801        var me = {
 802          fold: function (n, s) {
 803            return n();
 804          },
 805          is: never,
 806          isSome: never,
 807          isNone: always,
 808          getOr: id,
 809          getOrThunk: call,
 810          getOrDie: function (msg) {
 811            throw new Error(msg || 'error: getOrDie called on none.');
 812          },
 813          getOrNull: constant(null),
 814          getOrUndefined: constant(undefined),
 815          or: id,
 816          orThunk: call,
 817          map: none,
 818          each: noop,
 819          bind: none,
 820          exists: never,
 821          forall: always,
 822          filter: none,
 823          equals: eq,
 824          equals_: eq,
 825          toArray: function () {
 826            return [];
 827          },
 828          toString: constant('none()')
 829        };
 830        if (Object.freeze) {
 831          Object.freeze(me);
 832        }
 833        return me;
 834      }();
 835      var some = function (a) {
 836        var constant_a = constant(a);
 837        var self = function () {
 838          return me;
 839        };
 840        var bind = function (f) {
 841          return f(a);
 842        };
 843        var me = {
 844          fold: function (n, s) {
 845            return s(a);
 846          },
 847          is: function (v) {
 848            return a === v;
 849          },
 850          isSome: always,
 851          isNone: never,
 852          getOr: constant_a,
 853          getOrThunk: constant_a,
 854          getOrDie: constant_a,
 855          getOrNull: constant_a,
 856          getOrUndefined: constant_a,
 857          or: self,
 858          orThunk: self,
 859          map: function (f) {
 860            return some(f(a));
 861          },
 862          each: function (f) {
 863            f(a);
 864          },
 865          bind: bind,
 866          exists: bind,
 867          forall: bind,
 868          filter: function (f) {
 869            return f(a) ? me : NONE;
 870          },
 871          toArray: function () {
 872            return [a];
 873          },
 874          toString: function () {
 875            return 'some(' + a + ')';
 876          },
 877          equals: function (o) {
 878            return o.is(a);
 879          },
 880          equals_: function (o, elementEq) {
 881            return o.fold(never, function (b) {
 882              return elementEq(a, b);
 883            });
 884          }
 885        };
 886        return me;
 887      };
 888      var from = function (value) {
 889        return value === null || value === undefined ? NONE : some(value);
 890      };
 891      var Option = {
 892        some: some,
 893        none: none,
 894        from: from
 895      };
 896  
 897      var typeOf = function (x) {
 898        if (x === null) {
 899          return 'null';
 900        }
 901        var t = typeof x;
 902        if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
 903          return 'array';
 904        }
 905        if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
 906          return 'string';
 907        }
 908        return t;
 909      };
 910      var isType = function (type) {
 911        return function (value) {
 912          return typeOf(value) === type;
 913        };
 914      };
 915      var isFunction = isType('function');
 916  
 917      var nativeSlice = Array.prototype.slice;
 918      var map = function (xs, f) {
 919        var len = xs.length;
 920        var r = new Array(len);
 921        for (var i = 0; i < len; i++) {
 922          var x = xs[i];
 923          r[i] = f(x, i);
 924        }
 925        return r;
 926      };
 927      var each = function (xs, f) {
 928        for (var i = 0, len = xs.length; i < len; i++) {
 929          var x = xs[i];
 930          f(x, i);
 931        }
 932      };
 933      var filter$1 = function (xs, pred) {
 934        var r = [];
 935        for (var i = 0, len = xs.length; i < len; i++) {
 936          var x = xs[i];
 937          if (pred(x, i)) {
 938            r.push(x);
 939          }
 940        }
 941        return r;
 942      };
 943      var from$1 = isFunction(Array.from) ? Array.from : function (x) {
 944        return nativeSlice.call(x);
 945      };
 946  
 947      var exports$1 = {}, module = { exports: exports$1 };
 948      (function (define, exports, module, require) {
 949        (function (f) {
 950          if (typeof exports === 'object' && typeof module !== 'undefined') {
 951            module.exports = f();
 952          } else if (typeof define === 'function' && define.amd) {
 953            define([], f);
 954          } else {
 955            var g;
 956            if (typeof window !== 'undefined') {
 957              g = window;
 958            } else if (typeof global !== 'undefined') {
 959              g = global;
 960            } else if (typeof self !== 'undefined') {
 961              g = self;
 962            } else {
 963              g = this;
 964            }
 965            g.EphoxContactWrapper = f();
 966          }
 967        }(function () {
 968          return function () {
 969            function r(e, n, t) {
 970              function o(i, f) {
 971                if (!n[i]) {
 972                  if (!e[i]) {
 973                    var c = 'function' == typeof require && require;
 974                    if (!f && c)
 975                      return c(i, !0);
 976                    if (u)
 977                      return u(i, !0);
 978                    var a = new Error('Cannot find module \'' + i + '\'');
 979                    throw a.code = 'MODULE_NOT_FOUND', a;
 980                  }
 981                  var p = n[i] = { exports: {} };
 982                  e[i][0].call(p.exports, function (r) {
 983                    var n = e[i][1][r];
 984                    return o(n || r);
 985                  }, p, p.exports, r, e, n, t);
 986                }
 987                return n[i].exports;
 988              }
 989              for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++)
 990                o(t[i]);
 991              return o;
 992            }
 993            return r;
 994          }()({
 995            1: [
 996              function (require, module, exports) {
 997                var process = module.exports = {};
 998                var cachedSetTimeout;
 999                var cachedClearTimeout;
1000                function defaultSetTimout() {
1001                  throw new Error('setTimeout has not been defined');
1002                }
1003                function defaultClearTimeout() {
1004                  throw new Error('clearTimeout has not been defined');
1005                }
1006                (function () {
1007                  try {
1008                    if (typeof setTimeout === 'function') {
1009                      cachedSetTimeout = setTimeout;
1010                    } else {
1011                      cachedSetTimeout = defaultSetTimout;
1012                    }
1013                  } catch (e) {
1014                    cachedSetTimeout = defaultSetTimout;
1015                  }
1016                  try {
1017                    if (typeof clearTimeout === 'function') {
1018                      cachedClearTimeout = clearTimeout;
1019                    } else {
1020                      cachedClearTimeout = defaultClearTimeout;
1021                    }
1022                  } catch (e) {
1023                    cachedClearTimeout = defaultClearTimeout;
1024                  }
1025                }());
1026                function runTimeout(fun) {
1027                  if (cachedSetTimeout === setTimeout) {
1028                    return setTimeout(fun, 0);
1029                  }
1030                  if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1031                    cachedSetTimeout = setTimeout;
1032                    return setTimeout(fun, 0);
1033                  }
1034                  try {
1035                    return cachedSetTimeout(fun, 0);
1036                  } catch (e) {
1037                    try {
1038                      return cachedSetTimeout.call(null, fun, 0);
1039                    } catch (e) {
1040                      return cachedSetTimeout.call(this, fun, 0);
1041                    }
1042                  }
1043                }
1044                function runClearTimeout(marker) {
1045                  if (cachedClearTimeout === clearTimeout) {
1046                    return clearTimeout(marker);
1047                  }
1048                  if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1049                    cachedClearTimeout = clearTimeout;
1050                    return clearTimeout(marker);
1051                  }
1052                  try {
1053                    return cachedClearTimeout(marker);
1054                  } catch (e) {
1055                    try {
1056                      return cachedClearTimeout.call(null, marker);
1057                    } catch (e) {
1058                      return cachedClearTimeout.call(this, marker);
1059                    }
1060                  }
1061                }
1062                var queue = [];
1063                var draining = false;
1064                var currentQueue;
1065                var queueIndex = -1;
1066                function cleanUpNextTick() {
1067                  if (!draining || !currentQueue) {
1068                    return;
1069                  }
1070                  draining = false;
1071                  if (currentQueue.length) {
1072                    queue = currentQueue.concat(queue);
1073                  } else {
1074                    queueIndex = -1;
1075                  }
1076                  if (queue.length) {
1077                    drainQueue();
1078                  }
1079                }
1080                function drainQueue() {
1081                  if (draining) {
1082                    return;
1083                  }
1084                  var timeout = runTimeout(cleanUpNextTick);
1085                  draining = true;
1086                  var len = queue.length;
1087                  while (len) {
1088                    currentQueue = queue;
1089                    queue = [];
1090                    while (++queueIndex < len) {
1091                      if (currentQueue) {
1092                        currentQueue[queueIndex].run();
1093                      }
1094                    }
1095                    queueIndex = -1;
1096                    len = queue.length;
1097                  }
1098                  currentQueue = null;
1099                  draining = false;
1100                  runClearTimeout(timeout);
1101                }
1102                process.nextTick = function (fun) {
1103                  var args = new Array(arguments.length - 1);
1104                  if (arguments.length > 1) {
1105                    for (var i = 1; i < arguments.length; i++) {
1106                      args[i - 1] = arguments[i];
1107                    }
1108                  }
1109                  queue.push(new Item(fun, args));
1110                  if (queue.length === 1 && !draining) {
1111                    runTimeout(drainQueue);
1112                  }
1113                };
1114                function Item(fun, array) {
1115                  this.fun = fun;
1116                  this.array = array;
1117                }
1118                Item.prototype.run = function () {
1119                  this.fun.apply(null, this.array);
1120                };
1121                process.title = 'browser';
1122                process.browser = true;
1123                process.env = {};
1124                process.argv = [];
1125                process.version = '';
1126                process.versions = {};
1127                function noop() {
1128                }
1129                process.on = noop;
1130                process.addListener = noop;
1131                process.once = noop;
1132                process.off = noop;
1133                process.removeListener = noop;
1134                process.removeAllListeners = noop;
1135                process.emit = noop;
1136                process.prependListener = noop;
1137                process.prependOnceListener = noop;
1138                process.listeners = function (name) {
1139                  return [];
1140                };
1141                process.binding = function (name) {
1142                  throw new Error('process.binding is not supported');
1143                };
1144                process.cwd = function () {
1145                  return '/';
1146                };
1147                process.chdir = function (dir) {
1148                  throw new Error('process.chdir is not supported');
1149                };
1150                process.umask = function () {
1151                  return 0;
1152                };
1153              },
1154              {}
1155            ],
1156            2: [
1157              function (require, module, exports) {
1158                (function (setImmediate) {
1159                  (function (root) {
1160                    var setTimeoutFunc = setTimeout;
1161                    function noop() {
1162                    }
1163                    function bind(fn, thisArg) {
1164                      return function () {
1165                        fn.apply(thisArg, arguments);
1166                      };
1167                    }
1168                    function Promise(fn) {
1169                      if (typeof this !== 'object')
1170                        throw new TypeError('Promises must be constructed via new');
1171                      if (typeof fn !== 'function')
1172                        throw new TypeError('not a function');
1173                      this._state = 0;
1174                      this._handled = false;
1175                      this._value = undefined;
1176                      this._deferreds = [];
1177                      doResolve(fn, this);
1178                    }
1179                    function handle(self, deferred) {
1180                      while (self._state === 3) {
1181                        self = self._value;
1182                      }
1183                      if (self._state === 0) {
1184                        self._deferreds.push(deferred);
1185                        return;
1186                      }
1187                      self._handled = true;
1188                      Promise._immediateFn(function () {
1189                        var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
1190                        if (cb === null) {
1191                          (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
1192                          return;
1193                        }
1194                        var ret;
1195                        try {
1196                          ret = cb(self._value);
1197                        } catch (e) {
1198                          reject(deferred.promise, e);
1199                          return;
1200                        }
1201                        resolve(deferred.promise, ret);
1202                      });
1203                    }
1204                    function resolve(self, newValue) {
1205                      try {
1206                        if (newValue === self)
1207                          throw new TypeError('A promise cannot be resolved with itself.');
1208                        if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
1209                          var then = newValue.then;
1210                          if (newValue instanceof Promise) {
1211                            self._state = 3;
1212                            self._value = newValue;
1213                            finale(self);
1214                            return;
1215                          } else if (typeof then === 'function') {
1216                            doResolve(bind(then, newValue), self);
1217                            return;
1218                          }
1219                        }
1220                        self._state = 1;
1221                        self._value = newValue;
1222                        finale(self);
1223                      } catch (e) {
1224                        reject(self, e);
1225                      }
1226                    }
1227                    function reject(self, newValue) {
1228                      self._state = 2;
1229                      self._value = newValue;
1230                      finale(self);
1231                    }
1232                    function finale(self) {
1233                      if (self._state === 2 && self._deferreds.length === 0) {
1234                        Promise._immediateFn(function () {
1235                          if (!self._handled) {
1236                            Promise._unhandledRejectionFn(self._value);
1237                          }
1238                        });
1239                      }
1240                      for (var i = 0, len = self._deferreds.length; i < len; i++) {
1241                        handle(self, self._deferreds[i]);
1242                      }
1243                      self._deferreds = null;
1244                    }
1245                    function Handler(onFulfilled, onRejected, promise) {
1246                      this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
1247                      this.onRejected = typeof onRejected === 'function' ? onRejected : null;
1248                      this.promise = promise;
1249                    }
1250                    function doResolve(fn, self) {
1251                      var done = false;
1252                      try {
1253                        fn(function (value) {
1254                          if (done)
1255                            return;
1256                          done = true;
1257                          resolve(self, value);
1258                        }, function (reason) {
1259                          if (done)
1260                            return;
1261                          done = true;
1262                          reject(self, reason);
1263                        });
1264                      } catch (ex) {
1265                        if (done)
1266                          return;
1267                        done = true;
1268                        reject(self, ex);
1269                      }
1270                    }
1271                    Promise.prototype['catch'] = function (onRejected) {
1272                      return this.then(null, onRejected);
1273                    };
1274                    Promise.prototype.then = function (onFulfilled, onRejected) {
1275                      var prom = new this.constructor(noop);
1276                      handle(this, new Handler(onFulfilled, onRejected, prom));
1277                      return prom;
1278                    };
1279                    Promise.all = function (arr) {
1280                      var args = Array.prototype.slice.call(arr);
1281                      return new Promise(function (resolve, reject) {
1282                        if (args.length === 0)
1283                          return resolve([]);
1284                        var remaining = args.length;
1285                        function res(i, val) {
1286                          try {
1287                            if (val && (typeof val === 'object' || typeof val === 'function')) {
1288                              var then = val.then;
1289                              if (typeof then === 'function') {
1290                                then.call(val, function (val) {
1291                                  res(i, val);
1292                                }, reject);
1293                                return;
1294                              }
1295                            }
1296                            args[i] = val;
1297                            if (--remaining === 0) {
1298                              resolve(args);
1299                            }
1300                          } catch (ex) {
1301                            reject(ex);
1302                          }
1303                        }
1304                        for (var i = 0; i < args.length; i++) {
1305                          res(i, args[i]);
1306                        }
1307                      });
1308                    };
1309                    Promise.resolve = function (value) {
1310                      if (value && typeof value === 'object' && value.constructor === Promise) {
1311                        return value;
1312                      }
1313                      return new Promise(function (resolve) {
1314                        resolve(value);
1315                      });
1316                    };
1317                    Promise.reject = function (value) {
1318                      return new Promise(function (resolve, reject) {
1319                        reject(value);
1320                      });
1321                    };
1322                    Promise.race = function (values) {
1323                      return new Promise(function (resolve, reject) {
1324                        for (var i = 0, len = values.length; i < len; i++) {
1325                          values[i].then(resolve, reject);
1326                        }
1327                      });
1328                    };
1329                    Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {
1330                      setImmediate(fn);
1331                    } : function (fn) {
1332                      setTimeoutFunc(fn, 0);
1333                    };
1334                    Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
1335                      if (typeof console !== 'undefined' && console) {
1336                        console.warn('Possible Unhandled Promise Rejection:', err);
1337                      }
1338                    };
1339                    Promise._setImmediateFn = function _setImmediateFn(fn) {
1340                      Promise._immediateFn = fn;
1341                    };
1342                    Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
1343                      Promise._unhandledRejectionFn = fn;
1344                    };
1345                    if (typeof module !== 'undefined' && module.exports) {
1346                      module.exports = Promise;
1347                    } else if (!root.Promise) {
1348                      root.Promise = Promise;
1349                    }
1350                  }(this));
1351                }.call(this, require('timers').setImmediate));
1352              },
1353              { 'timers': 3 }
1354            ],
1355            3: [
1356              function (require, module, exports) {
1357                (function (setImmediate, clearImmediate) {
1358                  var nextTick = require('process/browser.js').nextTick;
1359                  var apply = Function.prototype.apply;
1360                  var slice = Array.prototype.slice;
1361                  var immediateIds = {};
1362                  var nextImmediateId = 0;
1363                  exports.setTimeout = function () {
1364                    return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
1365                  };
1366                  exports.setInterval = function () {
1367                    return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
1368                  };
1369                  exports.clearTimeout = exports.clearInterval = function (timeout) {
1370                    timeout.close();
1371                  };
1372                  function Timeout(id, clearFn) {
1373                    this._id = id;
1374                    this._clearFn = clearFn;
1375                  }
1376                  Timeout.prototype.unref = Timeout.prototype.ref = function () {
1377                  };
1378                  Timeout.prototype.close = function () {
1379                    this._clearFn.call(window, this._id);
1380                  };
1381                  exports.enroll = function (item, msecs) {
1382                    clearTimeout(item._idleTimeoutId);
1383                    item._idleTimeout = msecs;
1384                  };
1385                  exports.unenroll = function (item) {
1386                    clearTimeout(item._idleTimeoutId);
1387                    item._idleTimeout = -1;
1388                  };
1389                  exports._unrefActive = exports.active = function (item) {
1390                    clearTimeout(item._idleTimeoutId);
1391                    var msecs = item._idleTimeout;
1392                    if (msecs >= 0) {
1393                      item._idleTimeoutId = setTimeout(function onTimeout() {
1394                        if (item._onTimeout)
1395                          item._onTimeout();
1396                      }, msecs);
1397                    }
1398                  };
1399                  exports.setImmediate = typeof setImmediate === 'function' ? setImmediate : function (fn) {
1400                    var id = nextImmediateId++;
1401                    var args = arguments.length < 2 ? false : slice.call(arguments, 1);
1402                    immediateIds[id] = true;
1403                    nextTick(function onNextTick() {
1404                      if (immediateIds[id]) {
1405                        if (args) {
1406                          fn.apply(null, args);
1407                        } else {
1408                          fn.call(null);
1409                        }
1410                        exports.clearImmediate(id);
1411                      }
1412                    });
1413                    return id;
1414                  };
1415                  exports.clearImmediate = typeof clearImmediate === 'function' ? clearImmediate : function (id) {
1416                    delete immediateIds[id];
1417                  };
1418                }.call(this, require('timers').setImmediate, require('timers').clearImmediate));
1419              },
1420              {
1421                'process/browser.js': 1,
1422                'timers': 3
1423              }
1424            ],
1425            4: [
1426              function (require, module, exports) {
1427                var promisePolyfill = require('promise-polyfill');
1428                var Global = function () {
1429                  if (typeof window !== 'undefined') {
1430                    return window;
1431                  } else {
1432                    return Function('return this;')();
1433                  }
1434                }();
1435                module.exports = { boltExport: Global.Promise || promisePolyfill };
1436              },
1437              { 'promise-polyfill': 2 }
1438            ]
1439          }, {}, [4])(4);
1440        }));
1441      }(undefined, exports$1, module, undefined));
1442      var Promise = module.exports.boltExport;
1443  
1444      var nu = function (baseFn) {
1445        var data = Option.none();
1446        var callbacks = [];
1447        var map = function (f) {
1448          return nu(function (nCallback) {
1449            get(function (data) {
1450              nCallback(f(data));
1451            });
1452          });
1453        };
1454        var get = function (nCallback) {
1455          if (isReady()) {
1456            call(nCallback);
1457          } else {
1458            callbacks.push(nCallback);
1459          }
1460        };
1461        var set = function (x) {
1462          data = Option.some(x);
1463          run(callbacks);
1464          callbacks = [];
1465        };
1466        var isReady = function () {
1467          return data.isSome();
1468        };
1469        var run = function (cbs) {
1470          each(cbs, call);
1471        };
1472        var call = function (cb) {
1473          data.each(function (x) {
1474            domGlobals.setTimeout(function () {
1475              cb(x);
1476            }, 0);
1477          });
1478        };
1479        baseFn(set);
1480        return {
1481          get: get,
1482          map: map,
1483          isReady: isReady
1484        };
1485      };
1486      var pure = function (a) {
1487        return nu(function (callback) {
1488          callback(a);
1489        });
1490      };
1491      var LazyValue = {
1492        nu: nu,
1493        pure: pure
1494      };
1495  
1496      var errorReporter = function (err) {
1497        domGlobals.setTimeout(function () {
1498          throw err;
1499        }, 0);
1500      };
1501      var make = function (run) {
1502        var get = function (callback) {
1503          run().then(callback, errorReporter);
1504        };
1505        var map = function (fab) {
1506          return make(function () {
1507            return run().then(fab);
1508          });
1509        };
1510        var bind = function (aFutureB) {
1511          return make(function () {
1512            return run().then(function (v) {
1513              return aFutureB(v).toPromise();
1514            });
1515          });
1516        };
1517        var anonBind = function (futureB) {
1518          return make(function () {
1519            return run().then(function () {
1520              return futureB.toPromise();
1521            });
1522          });
1523        };
1524        var toLazy = function () {
1525          return LazyValue.nu(get);
1526        };
1527        var toCached = function () {
1528          var cache = null;
1529          return make(function () {
1530            if (cache === null) {
1531              cache = run();
1532            }
1533            return cache;
1534          });
1535        };
1536        var toPromise = run;
1537        return {
1538          map: map,
1539          bind: bind,
1540          anonBind: anonBind,
1541          toLazy: toLazy,
1542          toCached: toCached,
1543          toPromise: toPromise,
1544          get: get
1545        };
1546      };
1547      var nu$1 = function (baseFn) {
1548        return make(function () {
1549          return new Promise(baseFn);
1550        });
1551      };
1552      var pure$1 = function (a) {
1553        return make(function () {
1554          return Promise.resolve(a);
1555        });
1556      };
1557      var Future = {
1558        nu: nu$1,
1559        pure: pure$1
1560      };
1561  
1562      var par = function (asyncValues, nu) {
1563        return nu(function (callback) {
1564          var r = [];
1565          var count = 0;
1566          var cb = function (i) {
1567            return function (value) {
1568              r[i] = value;
1569              count++;
1570              if (count >= asyncValues.length) {
1571                callback(r);
1572              }
1573            };
1574          };
1575          if (asyncValues.length === 0) {
1576            callback([]);
1577          } else {
1578            each(asyncValues, function (asyncValue, i) {
1579              asyncValue.get(cb(i));
1580            });
1581          }
1582        });
1583      };
1584  
1585      var par$1 = function (futures) {
1586        return par(futures, Future.nu);
1587      };
1588      var traverse = function (array, fn) {
1589        return par$1(map(array, fn));
1590      };
1591      var mapM = traverse;
1592  
1593      var value = function () {
1594        var subject = Cell(Option.none());
1595        var clear = function () {
1596          subject.set(Option.none());
1597        };
1598        var set = function (s) {
1599          subject.set(Option.some(s));
1600        };
1601        var on = function (f) {
1602          subject.get().each(f);
1603        };
1604        var isSet = function () {
1605          return subject.get().isSome();
1606        };
1607        return {
1608          clear: clear,
1609          set: set,
1610          isSet: isSet,
1611          on: on
1612        };
1613      };
1614  
1615      var pasteHtml$1 = function (editor, html, internalFlag) {
1616        var internal = internalFlag ? internalFlag : InternalHtml.isMarked(html);
1617        var args = ProcessFilters.process(editor, InternalHtml.unmark(html), internal);
1618        if (args.cancelled === false) {
1619          SmartPaste.insertContent(editor, args.content);
1620        }
1621      };
1622      var pasteText = function (editor, text) {
1623        text = editor.dom.encode(text).replace(/\r\n/g, '\n');
1624        text = Newlines.convert(text, editor.settings.forced_root_block, editor.settings.forced_root_block_attrs);
1625        pasteHtml$1(editor, text, false);
1626      };
1627      var getDataTransferItems = function (dataTransfer) {
1628        var items = {};
1629        var mceInternalUrlPrefix = 'data:text/mce-internal,';
1630        if (dataTransfer) {
1631          if (dataTransfer.getData) {
1632            var legacyText = dataTransfer.getData('Text');
1633            if (legacyText && legacyText.length > 0) {
1634              if (legacyText.indexOf(mceInternalUrlPrefix) === -1) {
1635                items['text/plain'] = legacyText;
1636              }
1637            }
1638          }
1639          if (dataTransfer.types) {
1640            for (var i = 0; i < dataTransfer.types.length; i++) {
1641              var contentType = dataTransfer.types[i];
1642              try {
1643                items[contentType] = dataTransfer.getData(contentType);
1644              } catch (ex) {
1645                items[contentType] = '';
1646              }
1647            }
1648          }
1649        }
1650        return items;
1651      };
1652      var getClipboardContent = function (editor, clipboardEvent) {
1653        var content = getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer);
1654        return Utils.isMsEdge() ? global$4.extend(content, { 'text/html': '' }) : content;
1655      };
1656      var hasContentType = function (clipboardContent, mimeType) {
1657        return mimeType in clipboardContent && clipboardContent[mimeType].length > 0;
1658      };
1659      var hasHtmlOrText = function (content) {
1660        return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain');
1661      };
1662      var getBase64FromUri = function (uri) {
1663        var idx;
1664        idx = uri.indexOf(',');
1665        if (idx !== -1) {
1666          return uri.substr(idx + 1);
1667        }
1668        return null;
1669      };
1670      var isValidDataUriImage = function (settings, imgElm) {
1671        return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true;
1672      };
1673      var extractFilename = function (editor, str) {
1674        var m = str.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i);
1675        return m ? editor.dom.encode(m[1]) : null;
1676      };
1677      var uniqueId = Utils.createIdGenerator('mceclip');
1678      var pasteImage = function (editor, imageItem) {
1679        var base64 = getBase64FromUri(imageItem.uri);
1680        var id = uniqueId();
1681        var name = editor.settings.images_reuse_filename && imageItem.blob.name ? extractFilename(editor, imageItem.blob.name) : id;
1682        var img = new domGlobals.Image();
1683        img.src = imageItem.uri;
1684        if (isValidDataUriImage(editor.settings, img)) {
1685          var blobCache = editor.editorUpload.blobCache;
1686          var blobInfo = void 0, existingBlobInfo = void 0;
1687          existingBlobInfo = blobCache.findFirst(function (cachedBlobInfo) {
1688            return cachedBlobInfo.base64() === base64;
1689          });
1690          if (!existingBlobInfo) {
1691            blobInfo = blobCache.create(id, imageItem.blob, base64, name);
1692            blobCache.add(blobInfo);
1693          } else {
1694            blobInfo = existingBlobInfo;
1695          }
1696          pasteHtml$1(editor, '<img src="' + blobInfo.blobUri() + '">', false);
1697        } else {
1698          pasteHtml$1(editor, '<img src="' + imageItem.uri + '">', false);
1699        }
1700      };
1701      var isClipboardEvent = function (event) {
1702        return event.type === 'paste';
1703      };
1704      var readBlobsAsDataUris = function (items) {
1705        return mapM(items, function (item) {
1706          return Future.nu(function (resolve) {
1707            var blob = item.getAsFile ? item.getAsFile() : item;
1708            var reader = new window.FileReader();
1709            reader.onload = function () {
1710              resolve({
1711                blob: blob,
1712                uri: reader.result
1713              });
1714            };
1715            reader.readAsDataURL(blob);
1716          });
1717        });
1718      };
1719      var getImagesFromDataTransfer = function (dataTransfer) {
1720        var items = dataTransfer.items ? map(from$1(dataTransfer.items), function (item) {
1721          return item.getAsFile();
1722        }) : [];
1723        var files = dataTransfer.files ? from$1(dataTransfer.files) : [];
1724        var images = filter$1(items.length > 0 ? items : files, function (file) {
1725          return /^image\/(jpeg|png|gif|bmp)$/.test(file.type);
1726        });
1727        return images;
1728      };
1729      var pasteImageData = function (editor, e, rng) {
1730        var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer;
1731        if (editor.settings.paste_data_images && dataTransfer) {
1732          var images = getImagesFromDataTransfer(dataTransfer);
1733          if (images.length > 0) {
1734            e.preventDefault();
1735            readBlobsAsDataUris(images).get(function (blobResults) {
1736              if (rng) {
1737                editor.selection.setRng(rng);
1738              }
1739              each(blobResults, function (result) {
1740                pasteImage(editor, result);
1741              });
1742            });
1743            return true;
1744          }
1745        }
1746        return false;
1747      };
1748      var isBrokenAndroidClipboardEvent = function (e) {
1749        var clipboardData = e.clipboardData;
1750        return domGlobals.navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
1751      };
1752      var isKeyboardPasteEvent = function (e) {
1753        return global$5.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45;
1754      };
1755      var registerEventHandlers = function (editor, pasteBin, pasteFormat) {
1756        var keyboardPasteEvent = value();
1757        var keyboardPastePlainTextState;
1758        editor.on('keydown', function (e) {
1759          function removePasteBinOnKeyUp(e) {
1760            if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
1761              pasteBin.remove();
1762            }
1763          }
1764          if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
1765            keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86;
1766            if (keyboardPastePlainTextState && global$2.webkit && domGlobals.navigator.userAgent.indexOf('Version/') !== -1) {
1767              return;
1768            }
1769            e.stopImmediatePropagation();
1770            keyboardPasteEvent.set(e);
1771            window.setTimeout(function () {
1772              keyboardPasteEvent.clear();
1773            }, 100);
1774            if (global$2.ie && keyboardPastePlainTextState) {
1775              e.preventDefault();
1776              Events.firePaste(editor, true);
1777              return;
1778            }
1779            pasteBin.remove();
1780            pasteBin.create();
1781            editor.once('keyup', removePasteBinOnKeyUp);
1782            editor.once('paste', function () {
1783              editor.off('keyup', removePasteBinOnKeyUp);
1784            });
1785          }
1786        });
1787        function insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal) {
1788          var content, isPlainTextHtml;
1789          if (hasContentType(clipboardContent, 'text/html')) {
1790            content = clipboardContent['text/html'];
1791          } else {
1792            content = pasteBin.getHtml();
1793            internal = internal ? internal : InternalHtml.isMarked(content);
1794            if (pasteBin.isDefaultContent(content)) {
1795              plainTextMode = true;
1796            }
1797          }
1798          content = Utils.trimHtml(content);
1799          pasteBin.remove();
1800          isPlainTextHtml = internal === false && Newlines.isPlainText(content);
1801          if (!content.length || isPlainTextHtml) {
1802            plainTextMode = true;
1803          }
1804          if (plainTextMode) {
1805            if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) {
1806              content = clipboardContent['text/plain'];
1807            } else {
1808              content = Utils.innerText(content);
1809            }
1810          }
1811          if (pasteBin.isDefaultContent(content)) {
1812            if (!isKeyBoardPaste) {
1813              editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
1814            }
1815            return;
1816          }
1817          if (plainTextMode) {
1818            pasteText(editor, content);
1819          } else {
1820            pasteHtml$1(editor, content, internal);
1821          }
1822        }
1823        var getLastRng = function () {
1824          return pasteBin.getLastRng() || editor.selection.getRng();
1825        };
1826        editor.on('paste', function (e) {
1827          var isKeyBoardPaste = keyboardPasteEvent.isSet();
1828          var clipboardContent = getClipboardContent(editor, e);
1829          var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState;
1830          var internal = hasContentType(clipboardContent, InternalHtml.internalHtmlMime());
1831          keyboardPastePlainTextState = false;
1832          if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
1833            pasteBin.remove();
1834            return;
1835          }
1836          if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) {
1837            pasteBin.remove();
1838            return;
1839          }
1840          if (!isKeyBoardPaste) {
1841            e.preventDefault();
1842          }
1843          if (global$2.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) {
1844            pasteBin.create();
1845            editor.dom.bind(pasteBin.getEl(), 'paste', function (e) {
1846              e.stopPropagation();
1847            });
1848            editor.getDoc().execCommand('Paste', false, null);
1849            clipboardContent['text/html'] = pasteBin.getHtml();
1850          }
1851          if (hasContentType(clipboardContent, 'text/html')) {
1852            e.preventDefault();
1853            if (!internal) {
1854              internal = InternalHtml.isMarked(clipboardContent['text/html']);
1855            }
1856            insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
1857          } else {
1858            global$3.setEditorTimeout(editor, function () {
1859              insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
1860            }, 0);
1861          }
1862        });
1863      };
1864      var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) {
1865        registerEventHandlers(editor, pasteBin, pasteFormat);
1866        var src;
1867        editor.parser.addNodeFilter('img', function (nodes, name, args) {
1868          var isPasteInsert = function (args) {
1869            return args.data && args.data.paste === true;
1870          };
1871          var remove = function (node) {
1872            if (!node.attr('data-mce-object') && src !== global$2.transparentSrc) {
1873              node.remove();
1874            }
1875          };
1876          var isWebKitFakeUrl = function (src) {
1877            return src.indexOf('webkit-fake-url') === 0;
1878          };
1879          var isDataUri = function (src) {
1880            return src.indexOf('data:') === 0;
1881          };
1882          if (!editor.settings.paste_data_images && isPasteInsert(args)) {
1883            var i = nodes.length;
1884            while (i--) {
1885              src = nodes[i].attributes.map.src;
1886              if (!src) {
1887                continue;
1888              }
1889              if (isWebKitFakeUrl(src)) {
1890                remove(nodes[i]);
1891              } else if (!editor.settings.allow_html_data_urls && isDataUri(src)) {
1892                remove(nodes[i]);
1893              }
1894            }
1895          }
1896        });
1897      };
1898  
1899      var getPasteBinParent = function (editor) {
1900        return global$2.ie && editor.inline ? domGlobals.document.body : editor.getBody();
1901      };
1902      var isExternalPasteBin = function (editor) {
1903        return getPasteBinParent(editor) !== editor.getBody();
1904      };
1905      var delegatePasteEvents = function (editor, pasteBinElm, pasteBinDefaultContent) {
1906        if (isExternalPasteBin(editor)) {
1907          editor.dom.bind(pasteBinElm, 'paste keyup', function (e) {
1908            if (!isDefault(editor, pasteBinDefaultContent)) {
1909              editor.fire('paste');
1910            }
1911          });
1912        }
1913      };
1914      var create = function (editor, lastRngCell, pasteBinDefaultContent) {
1915        var dom = editor.dom, body = editor.getBody();
1916        var pasteBinElm;
1917        lastRngCell.set(editor.selection.getRng());
1918        pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', {
1919          'id': 'mcepastebin',
1920          'class': 'mce-pastebin',
1921          'contentEditable': true,
1922          'data-mce-bogus': 'all',
1923          'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0'
1924        }, pasteBinDefaultContent);
1925        if (global$2.ie || global$2.gecko) {
1926          dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535);
1927        }
1928        dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) {
1929          e.stopPropagation();
1930        });
1931        delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent);
1932        pasteBinElm.focus();
1933        editor.selection.select(pasteBinElm, true);
1934      };
1935      var remove = function (editor, lastRngCell) {
1936        if (getEl(editor)) {
1937          var pasteBinClone = void 0;
1938          var lastRng = lastRngCell.get();
1939          while (pasteBinClone = editor.dom.get('mcepastebin')) {
1940            editor.dom.remove(pasteBinClone);
1941            editor.dom.unbind(pasteBinClone);
1942          }
1943          if (lastRng) {
1944            editor.selection.setRng(lastRng);
1945          }
1946        }
1947        lastRngCell.set(null);
1948      };
1949      var getEl = function (editor) {
1950        return editor.dom.get('mcepastebin');
1951      };
1952      var getHtml = function (editor) {
1953        var pasteBinElm, pasteBinClones, i, dirtyWrappers, cleanWrapper;
1954        var copyAndRemove = function (toElm, fromElm) {
1955          toElm.appendChild(fromElm);
1956          editor.dom.remove(fromElm, true);
1957        };
1958        pasteBinClones = global$4.grep(getPasteBinParent(editor).childNodes, function (elm) {
1959          return elm.id === 'mcepastebin';
1960        });
1961        pasteBinElm = pasteBinClones.shift();
1962        global$4.each(pasteBinClones, function (pasteBinClone) {
1963          copyAndRemove(pasteBinElm, pasteBinClone);
1964        });
1965        dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm);
1966        for (i = dirtyWrappers.length - 1; i >= 0; i--) {
1967          cleanWrapper = editor.dom.create('div');
1968          pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]);
1969          copyAndRemove(cleanWrapper, dirtyWrappers[i]);
1970        }
1971        return pasteBinElm ? pasteBinElm.innerHTML : '';
1972      };
1973      var getLastRng = function (lastRng) {
1974        return lastRng.get();
1975      };
1976      var isDefaultContent = function (pasteBinDefaultContent, content) {
1977        return content === pasteBinDefaultContent;
1978      };
1979      var isPasteBin = function (elm) {
1980        return elm && elm.id === 'mcepastebin';
1981      };
1982      var isDefault = function (editor, pasteBinDefaultContent) {
1983        var pasteBinElm = getEl(editor);
1984        return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML);
1985      };
1986      var PasteBin = function (editor) {
1987        var lastRng = Cell(null);
1988        var pasteBinDefaultContent = '%MCEPASTEBIN%';
1989        return {
1990          create: function () {
1991            return create(editor, lastRng, pasteBinDefaultContent);
1992          },
1993          remove: function () {
1994            return remove(editor, lastRng);
1995          },
1996          getEl: function () {
1997            return getEl(editor);
1998          },
1999          getHtml: function () {
2000            return getHtml(editor);
2001          },
2002          getLastRng: function () {
2003            return getLastRng(lastRng);
2004          },
2005          isDefault: function () {
2006            return isDefault(editor, pasteBinDefaultContent);
2007          },
2008          isDefaultContent: function (content) {
2009            return isDefaultContent(pasteBinDefaultContent, content);
2010          }
2011        };
2012      };
2013  
2014      var Clipboard = function (editor, pasteFormat) {
2015        var pasteBin = PasteBin(editor);
2016        editor.on('preInit', function () {
2017          return registerEventsAndFilters(editor, pasteBin, pasteFormat);
2018        });
2019        return {
2020          pasteFormat: pasteFormat,
2021          pasteHtml: function (html, internalFlag) {
2022            return pasteHtml$1(editor, html, internalFlag);
2023          },
2024          pasteText: function (text) {
2025            return pasteText(editor, text);
2026          },
2027          pasteImageData: function (e, rng) {
2028            return pasteImageData(editor, e, rng);
2029          },
2030          getDataTransferItems: getDataTransferItems,
2031          hasHtmlOrText: hasHtmlOrText,
2032          hasContentType: hasContentType
2033        };
2034      };
2035  
2036      var noop$1 = function () {
2037      };
2038      var hasWorkingClipboardApi = function (clipboardData) {
2039        return global$2.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && Utils.isMsEdge() !== true;
2040      };
2041      var setHtml5Clipboard = function (clipboardData, html, text) {
2042        if (hasWorkingClipboardApi(clipboardData)) {
2043          try {
2044            clipboardData.clearData();
2045            clipboardData.setData('text/html', html);
2046            clipboardData.setData('text/plain', text);
2047            clipboardData.setData(InternalHtml.internalHtmlMime(), html);
2048            return true;
2049          } catch (e) {
2050            return false;
2051          }
2052        } else {
2053          return false;
2054        }
2055      };
2056      var setClipboardData = function (evt, data, fallback, done) {
2057        if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) {
2058          evt.preventDefault();
2059          done();
2060        } else {
2061          fallback(data.html, done);
2062        }
2063      };
2064      var fallback = function (editor) {
2065        return function (html, done) {
2066          var markedHtml = InternalHtml.mark(html);
2067          var outer = editor.dom.create('div', {
2068            'contenteditable': 'false',
2069            'data-mce-bogus': 'all'
2070          });
2071          var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml);
2072          editor.dom.setStyles(outer, {
2073            position: 'fixed',
2074            top: '0',
2075            left: '-3000px',
2076            width: '1000px',
2077            overflow: 'hidden'
2078          });
2079          outer.appendChild(inner);
2080          editor.dom.add(editor.getBody(), outer);
2081          var range = editor.selection.getRng();
2082          inner.focus();
2083          var offscreenRange = editor.dom.createRng();
2084          offscreenRange.selectNodeContents(inner);
2085          editor.selection.setRng(offscreenRange);
2086          setTimeout(function () {
2087            editor.selection.setRng(range);
2088            outer.parentNode.removeChild(outer);
2089            done();
2090          }, 0);
2091        };
2092      };
2093      var getData = function (editor) {
2094        return {
2095          html: editor.selection.getContent({ contextual: true }),
2096          text: editor.selection.getContent({ format: 'text' })
2097        };
2098      };
2099      var isTableSelection = function (editor) {
2100        return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());
2101      };
2102      var hasSelectedContent = function (editor) {
2103        return !editor.selection.isCollapsed() || isTableSelection(editor);
2104      };
2105      var cut = function (editor) {
2106        return function (evt) {
2107          if (hasSelectedContent(editor)) {
2108            setClipboardData(evt, getData(editor), fallback(editor), function () {
2109              setTimeout(function () {
2110                editor.execCommand('Delete');
2111              }, 0);
2112            });
2113          }
2114        };
2115      };
2116      var copy = function (editor) {
2117        return function (evt) {
2118          if (hasSelectedContent(editor)) {
2119            setClipboardData(evt, getData(editor), fallback(editor), noop$1);
2120          }
2121        };
2122      };
2123      var register$1 = function (editor) {
2124        editor.on('cut', cut(editor));
2125        editor.on('copy', copy(editor));
2126      };
2127      var CutCopy = { register: register$1 };
2128  
2129      var global$b = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
2130  
2131      var getCaretRangeFromEvent = function (editor, e) {
2132        return global$b.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
2133      };
2134      var isPlainTextFileUrl = function (content) {
2135        var plainTextContent = content['text/plain'];
2136        return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false;
2137      };
2138      var setFocusedRange = function (editor, rng) {
2139        editor.focus();
2140        editor.selection.setRng(rng);
2141      };
2142      var setup = function (editor, clipboard, draggingInternallyState) {
2143        if (Settings.shouldBlockDrop(editor)) {
2144          editor.on('dragend dragover draggesture dragdrop drop drag', function (e) {
2145            e.preventDefault();
2146            e.stopPropagation();
2147          });
2148        }
2149        if (!Settings.shouldPasteDataImages(editor)) {
2150          editor.on('drop', function (e) {
2151            var dataTransfer = e.dataTransfer;
2152            if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
2153              e.preventDefault();
2154            }
2155          });
2156        }
2157        editor.on('drop', function (e) {
2158          var dropContent, rng;
2159          rng = getCaretRangeFromEvent(editor, e);
2160          if (e.isDefaultPrevented() || draggingInternallyState.get()) {
2161            return;
2162          }
2163          dropContent = clipboard.getDataTransferItems(e.dataTransfer);
2164          var internal = clipboard.hasContentType(dropContent, InternalHtml.internalHtmlMime());
2165          if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) {
2166            return;
2167          }
2168          if (rng && Settings.shouldFilterDrop(editor)) {
2169            var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
2170            if (content_1) {
2171              e.preventDefault();
2172              global$3.setEditorTimeout(editor, function () {
2173                editor.undoManager.transact(function () {
2174                  if (dropContent['mce-internal']) {
2175                    editor.execCommand('Delete');
2176                  }
2177                  setFocusedRange(editor, rng);
2178                  content_1 = Utils.trimHtml(content_1);
2179                  if (!dropContent['text/html']) {
2180                    clipboard.pasteText(content_1);
2181                  } else {
2182                    clipboard.pasteHtml(content_1, internal);
2183                  }
2184                });
2185              });
2186            }
2187          }
2188        });
2189        editor.on('dragstart', function (e) {
2190          draggingInternallyState.set(true);
2191        });
2192        editor.on('dragover dragend', function (e) {
2193          if (Settings.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) {
2194            e.preventDefault();
2195            setFocusedRange(editor, getCaretRangeFromEvent(editor, e));
2196          }
2197          if (e.type === 'dragend') {
2198            draggingInternallyState.set(false);
2199          }
2200        });
2201      };
2202      var DragDrop = { setup: setup };
2203  
2204      var setup$1 = function (editor) {
2205        var plugin = editor.plugins.paste;
2206        var preProcess = Settings.getPreProcess(editor);
2207        if (preProcess) {
2208          editor.on('PastePreProcess', function (e) {
2209            preProcess.call(plugin, plugin, e);
2210          });
2211        }
2212        var postProcess = Settings.getPostProcess(editor);
2213        if (postProcess) {
2214          editor.on('PastePostProcess', function (e) {
2215            postProcess.call(plugin, plugin, e);
2216          });
2217        }
2218      };
2219      var PrePostProcess = { setup: setup$1 };
2220  
2221      function addPreProcessFilter(editor, filterFunc) {
2222        editor.on('PastePreProcess', function (e) {
2223          e.content = filterFunc(editor, e.content, e.internal, e.wordContent);
2224        });
2225      }
2226      function addPostProcessFilter(editor, filterFunc) {
2227        editor.on('PastePostProcess', function (e) {
2228          filterFunc(editor, e.node);
2229        });
2230      }
2231      function removeExplorerBrElementsAfterBlocks(editor, html) {
2232        if (!WordFilter.isWordContent(html)) {
2233          return html;
2234        }
2235        var blockElements = [];
2236        global$4.each(editor.schema.getBlockElements(), function (block, blockName) {
2237          blockElements.push(blockName);
2238        });
2239        var explorerBlocksRegExp = new RegExp('(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*', 'g');
2240        html = Utils.filter(html, [[
2241            explorerBlocksRegExp,
2242            '$1'
2243          ]]);
2244        html = Utils.filter(html, [
2245          [
2246            /<br><br>/g,
2247            '<BR><BR>'
2248          ],
2249          [
2250            /<br>/g,
2251            ' '
2252          ],
2253          [
2254            /<BR><BR>/g,
2255            '<br>'
2256          ]
2257        ]);
2258        return html;
2259      }
2260      function removeWebKitStyles(editor, content, internal, isWordHtml) {
2261        if (isWordHtml || internal) {
2262          return content;
2263        }
2264        var webKitStylesSetting = Settings.getWebkitStyles(editor);
2265        var webKitStyles;
2266        if (Settings.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') {
2267          return content;
2268        }
2269        if (webKitStylesSetting) {
2270          webKitStyles = webKitStylesSetting.split(/[, ]/);
2271        }
2272        if (webKitStyles) {
2273          var dom_1 = editor.dom, node_1 = editor.selection.getNode();
2274          content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) {
2275            var inputStyles = dom_1.parseStyle(dom_1.decode(value));
2276            var outputStyles = {};
2277            if (webKitStyles === 'none') {
2278              return before + after;
2279            }
2280            for (var i = 0; i < webKitStyles.length; i++) {
2281              var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true);
2282              if (/color/.test(webKitStyles[i])) {
2283                inputValue = dom_1.toHex(inputValue);
2284                currentValue = dom_1.toHex(currentValue);
2285              }
2286              if (currentValue !== inputValue) {
2287                outputStyles[webKitStyles[i]] = inputValue;
2288              }
2289            }
2290            outputStyles = dom_1.serializeStyle(outputStyles, 'span');
2291            if (outputStyles) {
2292              return before + ' style="' + outputStyles + '"' + after;
2293            }
2294            return before + after;
2295          });
2296        } else {
2297          content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
2298        }
2299        content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) {
2300          return before + ' style="' + value + '"' + after;
2301        });
2302        return content;
2303      }
2304      function removeUnderlineAndFontInAnchor(editor, root) {
2305        editor.$('a', root).find('font,u').each(function (i, node) {
2306          editor.dom.remove(node, true);
2307        });
2308      }
2309      var setup$2 = function (editor) {
2310        if (global$2.webkit) {
2311          addPreProcessFilter(editor, removeWebKitStyles);
2312        }
2313        if (global$2.ie) {
2314          addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks);
2315          addPostProcessFilter(editor, removeUnderlineAndFontInAnchor);
2316        }
2317      };
2318      var Quirks = { setup: setup$2 };
2319  
2320      var stateChange = function (editor, clipboard, e) {
2321        var ctrl = e.control;
2322        ctrl.active(clipboard.pasteFormat.get() === 'text');
2323        editor.on('PastePlainTextToggle', function (e) {
2324          ctrl.active(e.state);
2325        });
2326      };
2327      var register$2 = function (editor, clipboard) {
2328        var postRender = curry(stateChange, editor, clipboard);
2329        editor.addButton('pastetext', {
2330          active: false,
2331          icon: 'pastetext',
2332          tooltip: 'Paste as text',
2333          cmd: 'mceTogglePlainTextPaste',
2334          onPostRender: postRender
2335        });
2336        editor.addMenuItem('pastetext', {
2337          text: 'Paste as text',
2338          selectable: true,
2339          active: clipboard.pasteFormat,
2340          cmd: 'mceTogglePlainTextPaste',
2341          onPostRender: postRender
2342        });
2343      };
2344      var Buttons = { register: register$2 };
2345  
2346      global$1.add('paste', function (editor) {
2347        if (DetectProPlugin.hasProPlugin(editor) === false) {
2348          var userIsInformedState = Cell(false);
2349          var draggingInternallyState = Cell(false);
2350          var pasteFormat = Cell(Settings.isPasteAsTextEnabled(editor) ? 'text' : 'html');
2351          var clipboard = Clipboard(editor, pasteFormat);
2352          var quirks = Quirks.setup(editor);
2353          Buttons.register(editor, clipboard);
2354          Commands.register(editor, clipboard, userIsInformedState);
2355          PrePostProcess.setup(editor);
2356          CutCopy.register(editor);
2357          DragDrop.setup(editor, clipboard, draggingInternallyState);
2358          return Api.get(clipboard, quirks);
2359        }
2360      });
2361      function Plugin () {
2362      }
2363  
2364      return Plugin;
2365  
2366  }(window));
2367  })();


Generated : Tue Mar 19 08:20:01 2024 Cross-referenced by PHPXref