[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

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

   1  (function () {
   2  var lists = (function (domGlobals) {
   3      'use strict';
   4  
   5      var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
   6  
   7      var global$1 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
   8  
   9      var global$2 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
  10  
  11      var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK');
  12  
  13      var global$4 = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager');
  14  
  15      var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools');
  16  
  17      var global$6 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
  18  
  19      var isTextNode = function (node) {
  20        return node && node.nodeType === 3;
  21      };
  22      var isListNode = function (node) {
  23        return node && /^(OL|UL|DL)$/.test(node.nodeName);
  24      };
  25      var isOlUlNode = function (node) {
  26        return node && /^(OL|UL)$/.test(node.nodeName);
  27      };
  28      var isListItemNode = function (node) {
  29        return node && /^(LI|DT|DD)$/.test(node.nodeName);
  30      };
  31      var isDlItemNode = function (node) {
  32        return node && /^(DT|DD)$/.test(node.nodeName);
  33      };
  34      var isTableCellNode = function (node) {
  35        return node && /^(TH|TD)$/.test(node.nodeName);
  36      };
  37      var isBr = function (node) {
  38        return node && node.nodeName === 'BR';
  39      };
  40      var isFirstChild = function (node) {
  41        return node.parentNode.firstChild === node;
  42      };
  43      var isLastChild = function (node) {
  44        return node.parentNode.lastChild === node;
  45      };
  46      var isTextBlock = function (editor, node) {
  47        return node && !!editor.schema.getTextBlockElements()[node.nodeName];
  48      };
  49      var isBlock = function (node, blockElements) {
  50        return node && node.nodeName in blockElements;
  51      };
  52      var isBogusBr = function (dom, node) {
  53        if (!isBr(node)) {
  54          return false;
  55        }
  56        if (dom.isBlock(node.nextSibling) && !isBr(node.previousSibling)) {
  57          return true;
  58        }
  59        return false;
  60      };
  61      var isEmpty = function (dom, elm, keepBookmarks) {
  62        var empty = dom.isEmpty(elm);
  63        if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) {
  64          return false;
  65        }
  66        return empty;
  67      };
  68      var isChildOfBody = function (dom, elm) {
  69        return dom.isChildOf(elm, dom.getRoot());
  70      };
  71      var NodeType = {
  72        isTextNode: isTextNode,
  73        isListNode: isListNode,
  74        isOlUlNode: isOlUlNode,
  75        isDlItemNode: isDlItemNode,
  76        isListItemNode: isListItemNode,
  77        isTableCellNode: isTableCellNode,
  78        isBr: isBr,
  79        isFirstChild: isFirstChild,
  80        isLastChild: isLastChild,
  81        isTextBlock: isTextBlock,
  82        isBlock: isBlock,
  83        isBogusBr: isBogusBr,
  84        isEmpty: isEmpty,
  85        isChildOfBody: isChildOfBody
  86      };
  87  
  88      var getNormalizedPoint = function (container, offset) {
  89        if (NodeType.isTextNode(container)) {
  90          return {
  91            container: container,
  92            offset: offset
  93          };
  94        }
  95        var node = global$1.getNode(container, offset);
  96        if (NodeType.isTextNode(node)) {
  97          return {
  98            container: node,
  99            offset: offset >= container.childNodes.length ? node.data.length : 0
 100          };
 101        } else if (node.previousSibling && NodeType.isTextNode(node.previousSibling)) {
 102          return {
 103            container: node.previousSibling,
 104            offset: node.previousSibling.data.length
 105          };
 106        } else if (node.nextSibling && NodeType.isTextNode(node.nextSibling)) {
 107          return {
 108            container: node.nextSibling,
 109            offset: 0
 110          };
 111        }
 112        return {
 113          container: container,
 114          offset: offset
 115        };
 116      };
 117      var normalizeRange = function (rng) {
 118        var outRng = rng.cloneRange();
 119        var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
 120        outRng.setStart(rangeStart.container, rangeStart.offset);
 121        var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
 122        outRng.setEnd(rangeEnd.container, rangeEnd.offset);
 123        return outRng;
 124      };
 125      var Range = {
 126        getNormalizedPoint: getNormalizedPoint,
 127        normalizeRange: normalizeRange
 128      };
 129  
 130      var DOM = global$6.DOM;
 131      var createBookmark = function (rng) {
 132        var bookmark = {};
 133        var setupEndPoint = function (start) {
 134          var offsetNode, container, offset;
 135          container = rng[start ? 'startContainer' : 'endContainer'];
 136          offset = rng[start ? 'startOffset' : 'endOffset'];
 137          if (container.nodeType === 1) {
 138            offsetNode = DOM.create('span', { 'data-mce-type': 'bookmark' });
 139            if (container.hasChildNodes()) {
 140              offset = Math.min(offset, container.childNodes.length - 1);
 141              if (start) {
 142                container.insertBefore(offsetNode, container.childNodes[offset]);
 143              } else {
 144                DOM.insertAfter(offsetNode, container.childNodes[offset]);
 145              }
 146            } else {
 147              container.appendChild(offsetNode);
 148            }
 149            container = offsetNode;
 150            offset = 0;
 151          }
 152          bookmark[start ? 'startContainer' : 'endContainer'] = container;
 153          bookmark[start ? 'startOffset' : 'endOffset'] = offset;
 154        };
 155        setupEndPoint(true);
 156        if (!rng.collapsed) {
 157          setupEndPoint();
 158        }
 159        return bookmark;
 160      };
 161      var resolveBookmark = function (bookmark) {
 162        function restoreEndPoint(start) {
 163          var container, offset, node;
 164          var nodeIndex = function (container) {
 165            var node = container.parentNode.firstChild, idx = 0;
 166            while (node) {
 167              if (node === container) {
 168                return idx;
 169              }
 170              if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
 171                idx++;
 172              }
 173              node = node.nextSibling;
 174            }
 175            return -1;
 176          };
 177          container = node = bookmark[start ? 'startContainer' : 'endContainer'];
 178          offset = bookmark[start ? 'startOffset' : 'endOffset'];
 179          if (!container) {
 180            return;
 181          }
 182          if (container.nodeType === 1) {
 183            offset = nodeIndex(container);
 184            container = container.parentNode;
 185            DOM.remove(node);
 186            if (!container.hasChildNodes() && DOM.isBlock(container)) {
 187              container.appendChild(DOM.create('br'));
 188            }
 189          }
 190          bookmark[start ? 'startContainer' : 'endContainer'] = container;
 191          bookmark[start ? 'startOffset' : 'endOffset'] = offset;
 192        }
 193        restoreEndPoint(true);
 194        restoreEndPoint();
 195        var rng = DOM.createRng();
 196        rng.setStart(bookmark.startContainer, bookmark.startOffset);
 197        if (bookmark.endContainer) {
 198          rng.setEnd(bookmark.endContainer, bookmark.endOffset);
 199        }
 200        return Range.normalizeRange(rng);
 201      };
 202      var Bookmark = {
 203        createBookmark: createBookmark,
 204        resolveBookmark: resolveBookmark
 205      };
 206  
 207      var constant = function (value) {
 208        return function () {
 209          return value;
 210        };
 211      };
 212      var not = function (f) {
 213        return function () {
 214          var args = [];
 215          for (var _i = 0; _i < arguments.length; _i++) {
 216            args[_i] = arguments[_i];
 217          }
 218          return !f.apply(null, args);
 219        };
 220      };
 221      var never = constant(false);
 222      var always = constant(true);
 223  
 224      var never$1 = never;
 225      var always$1 = always;
 226      var none = function () {
 227        return NONE;
 228      };
 229      var NONE = function () {
 230        var eq = function (o) {
 231          return o.isNone();
 232        };
 233        var call = function (thunk) {
 234          return thunk();
 235        };
 236        var id = function (n) {
 237          return n;
 238        };
 239        var noop = function () {
 240        };
 241        var nul = function () {
 242          return null;
 243        };
 244        var undef = function () {
 245          return undefined;
 246        };
 247        var me = {
 248          fold: function (n, s) {
 249            return n();
 250          },
 251          is: never$1,
 252          isSome: never$1,
 253          isNone: always$1,
 254          getOr: id,
 255          getOrThunk: call,
 256          getOrDie: function (msg) {
 257            throw new Error(msg || 'error: getOrDie called on none.');
 258          },
 259          getOrNull: nul,
 260          getOrUndefined: undef,
 261          or: id,
 262          orThunk: call,
 263          map: none,
 264          ap: none,
 265          each: noop,
 266          bind: none,
 267          flatten: none,
 268          exists: never$1,
 269          forall: always$1,
 270          filter: none,
 271          equals: eq,
 272          equals_: eq,
 273          toArray: function () {
 274            return [];
 275          },
 276          toString: constant('none()')
 277        };
 278        if (Object.freeze) {
 279          Object.freeze(me);
 280        }
 281        return me;
 282      }();
 283      var some = function (a) {
 284        var constant_a = function () {
 285          return a;
 286        };
 287        var self = function () {
 288          return me;
 289        };
 290        var map = function (f) {
 291          return some(f(a));
 292        };
 293        var bind = function (f) {
 294          return f(a);
 295        };
 296        var me = {
 297          fold: function (n, s) {
 298            return s(a);
 299          },
 300          is: function (v) {
 301            return a === v;
 302          },
 303          isSome: always$1,
 304          isNone: never$1,
 305          getOr: constant_a,
 306          getOrThunk: constant_a,
 307          getOrDie: constant_a,
 308          getOrNull: constant_a,
 309          getOrUndefined: constant_a,
 310          or: self,
 311          orThunk: self,
 312          map: map,
 313          ap: function (optfab) {
 314            return optfab.fold(none, function (fab) {
 315              return some(fab(a));
 316            });
 317          },
 318          each: function (f) {
 319            f(a);
 320          },
 321          bind: bind,
 322          flatten: constant_a,
 323          exists: bind,
 324          forall: bind,
 325          filter: function (f) {
 326            return f(a) ? me : NONE;
 327          },
 328          equals: function (o) {
 329            return o.is(a);
 330          },
 331          equals_: function (o, elementEq) {
 332            return o.fold(never$1, function (b) {
 333              return elementEq(a, b);
 334            });
 335          },
 336          toArray: function () {
 337            return [a];
 338          },
 339          toString: function () {
 340            return 'some(' + a + ')';
 341          }
 342        };
 343        return me;
 344      };
 345      var from = function (value) {
 346        return value === null || value === undefined ? NONE : some(value);
 347      };
 348      var Option = {
 349        some: some,
 350        none: none,
 351        from: from
 352      };
 353  
 354      var typeOf = function (x) {
 355        if (x === null) {
 356          return 'null';
 357        }
 358        var t = typeof x;
 359        if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
 360          return 'array';
 361        }
 362        if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
 363          return 'string';
 364        }
 365        return t;
 366      };
 367      var isType = function (type) {
 368        return function (value) {
 369          return typeOf(value) === type;
 370        };
 371      };
 372      var isString = isType('string');
 373      var isArray = isType('array');
 374      var isBoolean = isType('boolean');
 375      var isFunction = isType('function');
 376      var isNumber = isType('number');
 377  
 378      var slice = Array.prototype.slice;
 379      var map = function (xs, f) {
 380        var len = xs.length;
 381        var r = new Array(len);
 382        for (var i = 0; i < len; i++) {
 383          var x = xs[i];
 384          r[i] = f(x, i, xs);
 385        }
 386        return r;
 387      };
 388      var each = function (xs, f) {
 389        for (var i = 0, len = xs.length; i < len; i++) {
 390          var x = xs[i];
 391          f(x, i, xs);
 392        }
 393      };
 394      var filter = function (xs, pred) {
 395        var r = [];
 396        for (var i = 0, len = xs.length; i < len; i++) {
 397          var x = xs[i];
 398          if (pred(x, i, xs)) {
 399            r.push(x);
 400          }
 401        }
 402        return r;
 403      };
 404      var groupBy = function (xs, f) {
 405        if (xs.length === 0) {
 406          return [];
 407        } else {
 408          var wasType = f(xs[0]);
 409          var r = [];
 410          var group = [];
 411          for (var i = 0, len = xs.length; i < len; i++) {
 412            var x = xs[i];
 413            var type = f(x);
 414            if (type !== wasType) {
 415              r.push(group);
 416              group = [];
 417            }
 418            wasType = type;
 419            group.push(x);
 420          }
 421          if (group.length !== 0) {
 422            r.push(group);
 423          }
 424          return r;
 425        }
 426      };
 427      var foldl = function (xs, f, acc) {
 428        each(xs, function (x) {
 429          acc = f(acc, x);
 430        });
 431        return acc;
 432      };
 433      var find = function (xs, pred) {
 434        for (var i = 0, len = xs.length; i < len; i++) {
 435          var x = xs[i];
 436          if (pred(x, i, xs)) {
 437            return Option.some(x);
 438          }
 439        }
 440        return Option.none();
 441      };
 442      var push = Array.prototype.push;
 443      var flatten = function (xs) {
 444        var r = [];
 445        for (var i = 0, len = xs.length; i < len; ++i) {
 446          if (!isArray(xs[i])) {
 447            throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
 448          }
 449          push.apply(r, xs[i]);
 450        }
 451        return r;
 452      };
 453      var bind = function (xs, f) {
 454        var output = map(xs, f);
 455        return flatten(output);
 456      };
 457      var reverse = function (xs) {
 458        var r = slice.call(xs, 0);
 459        r.reverse();
 460        return r;
 461      };
 462      var head = function (xs) {
 463        return xs.length === 0 ? Option.none() : Option.some(xs[0]);
 464      };
 465      var last = function (xs) {
 466        return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]);
 467      };
 468      var from$1 = isFunction(Array.from) ? Array.from : function (x) {
 469        return slice.call(x);
 470      };
 471  
 472      var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
 473  
 474      var path = function (parts, scope) {
 475        var o = scope !== undefined && scope !== null ? scope : Global;
 476        for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
 477          o = o[parts[i]];
 478        }
 479        return o;
 480      };
 481      var resolve = function (p, scope) {
 482        var parts = p.split('.');
 483        return path(parts, scope);
 484      };
 485  
 486      var unsafe = function (name, scope) {
 487        return resolve(name, scope);
 488      };
 489      var getOrDie = function (name, scope) {
 490        var actual = unsafe(name, scope);
 491        if (actual === undefined || actual === null) {
 492          throw new Error(name + ' not available on this browser');
 493        }
 494        return actual;
 495      };
 496      var Global$1 = { getOrDie: getOrDie };
 497  
 498      var htmlElement = function (scope) {
 499        return Global$1.getOrDie('HTMLElement', scope);
 500      };
 501      var isPrototypeOf = function (x) {
 502        var scope = resolve('ownerDocument.defaultView', x);
 503        return htmlElement(scope).prototype.isPrototypeOf(x);
 504      };
 505      var HTMLElement = { isPrototypeOf: isPrototypeOf };
 506  
 507      var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
 508  
 509      var getParentList = function (editor) {
 510        var selectionStart = editor.selection.getStart(true);
 511        return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart));
 512      };
 513      var isParentListSelected = function (parentList, selectedBlocks) {
 514        return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
 515      };
 516      var findSubLists = function (parentList) {
 517        return global$5.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm) {
 518          return NodeType.isListNode(elm);
 519        });
 520      };
 521      var getSelectedSubLists = function (editor) {
 522        var parentList = getParentList(editor);
 523        var selectedBlocks = editor.selection.getSelectedBlocks();
 524        if (isParentListSelected(parentList, selectedBlocks)) {
 525          return findSubLists(parentList);
 526        } else {
 527          return global$5.grep(selectedBlocks, function (elm) {
 528            return NodeType.isListNode(elm) && parentList !== elm;
 529          });
 530        }
 531      };
 532      var findParentListItemsNodes = function (editor, elms) {
 533        var listItemsElms = global$5.map(elms, function (elm) {
 534          var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm));
 535          return parentLi ? parentLi : elm;
 536        });
 537        return global$7.unique(listItemsElms);
 538      };
 539      var getSelectedListItems = function (editor) {
 540        var selectedBlocks = editor.selection.getSelectedBlocks();
 541        return global$5.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) {
 542          return NodeType.isListItemNode(block);
 543        });
 544      };
 545      var getSelectedDlItems = function (editor) {
 546        return filter(getSelectedListItems(editor), NodeType.isDlItemNode);
 547      };
 548      var getClosestListRootElm = function (editor, elm) {
 549        var parentTableCell = editor.dom.getParents(elm, 'TD,TH');
 550        var root = parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
 551        return root;
 552      };
 553      var findLastParentListNode = function (editor, elm) {
 554        var parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListRootElm(editor, elm));
 555        return last(parentLists);
 556      };
 557      var getSelectedLists = function (editor) {
 558        var firstList = findLastParentListNode(editor, editor.selection.getStart());
 559        var subsequentLists = filter(editor.selection.getSelectedBlocks(), NodeType.isOlUlNode);
 560        return firstList.toArray().concat(subsequentLists);
 561      };
 562      var getSelectedListRoots = function (editor) {
 563        var selectedLists = getSelectedLists(editor);
 564        return getUniqueListRoots(editor, selectedLists);
 565      };
 566      var getUniqueListRoots = function (editor, lists) {
 567        var listRoots = map(lists, function (list) {
 568          return findLastParentListNode(editor, list).getOr(list);
 569        });
 570        return global$7.unique(listRoots);
 571      };
 572      var isList = function (editor) {
 573        var list = getParentList(editor);
 574        return HTMLElement.isPrototypeOf(list);
 575      };
 576      var Selection = {
 577        isList: isList,
 578        getParentList: getParentList,
 579        getSelectedSubLists: getSelectedSubLists,
 580        getSelectedListItems: getSelectedListItems,
 581        getClosestListRootElm: getClosestListRootElm,
 582        getSelectedDlItems: getSelectedDlItems,
 583        getSelectedListRoots: getSelectedListRoots
 584      };
 585  
 586      var fromHtml = function (html, scope) {
 587        var doc = scope || domGlobals.document;
 588        var div = doc.createElement('div');
 589        div.innerHTML = html;
 590        if (!div.hasChildNodes() || div.childNodes.length > 1) {
 591          domGlobals.console.error('HTML does not have a single root node', html);
 592          throw new Error('HTML must have a single root node');
 593        }
 594        return fromDom(div.childNodes[0]);
 595      };
 596      var fromTag = function (tag, scope) {
 597        var doc = scope || domGlobals.document;
 598        var node = doc.createElement(tag);
 599        return fromDom(node);
 600      };
 601      var fromText = function (text, scope) {
 602        var doc = scope || domGlobals.document;
 603        var node = doc.createTextNode(text);
 604        return fromDom(node);
 605      };
 606      var fromDom = function (node) {
 607        if (node === null || node === undefined) {
 608          throw new Error('Node cannot be null or undefined');
 609        }
 610        return { dom: constant(node) };
 611      };
 612      var fromPoint = function (docElm, x, y) {
 613        var doc = docElm.dom();
 614        return Option.from(doc.elementFromPoint(x, y)).map(fromDom);
 615      };
 616      var Element = {
 617        fromHtml: fromHtml,
 618        fromTag: fromTag,
 619        fromText: fromText,
 620        fromDom: fromDom,
 621        fromPoint: fromPoint
 622      };
 623  
 624      var liftN = function (arr, f) {
 625        var r = [];
 626        for (var i = 0; i < arr.length; i++) {
 627          var x = arr[i];
 628          if (x.isSome()) {
 629            r.push(x.getOrDie());
 630          } else {
 631            return Option.none();
 632          }
 633        }
 634        return Option.some(f.apply(null, r));
 635      };
 636  
 637      var fromElements = function (elements, scope) {
 638        var doc = scope || domGlobals.document;
 639        var fragment = doc.createDocumentFragment();
 640        each(elements, function (element) {
 641          fragment.appendChild(element.dom());
 642        });
 643        return Element.fromDom(fragment);
 644      };
 645  
 646      var Immutable = function () {
 647        var fields = [];
 648        for (var _i = 0; _i < arguments.length; _i++) {
 649          fields[_i] = arguments[_i];
 650        }
 651        return function () {
 652          var values = [];
 653          for (var _i = 0; _i < arguments.length; _i++) {
 654            values[_i] = arguments[_i];
 655          }
 656          if (fields.length !== values.length) {
 657            throw new Error('Wrong number of arguments to struct. Expected "[' + fields.length + ']", got ' + values.length + ' arguments');
 658          }
 659          var struct = {};
 660          each(fields, function (name, i) {
 661            struct[name] = constant(values[i]);
 662          });
 663          return struct;
 664        };
 665      };
 666  
 667      var keys = Object.keys;
 668      var each$1 = function (obj, f) {
 669        var props = keys(obj);
 670        for (var k = 0, len = props.length; k < len; k++) {
 671          var i = props[k];
 672          var x = obj[i];
 673          f(x, i, obj);
 674        }
 675      };
 676  
 677      var node = function () {
 678        var f = Global$1.getOrDie('Node');
 679        return f;
 680      };
 681      var compareDocumentPosition = function (a, b, match) {
 682        return (a.compareDocumentPosition(b) & match) !== 0;
 683      };
 684      var documentPositionPreceding = function (a, b) {
 685        return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_PRECEDING);
 686      };
 687      var documentPositionContainedBy = function (a, b) {
 688        return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_CONTAINED_BY);
 689      };
 690      var Node = {
 691        documentPositionPreceding: documentPositionPreceding,
 692        documentPositionContainedBy: documentPositionContainedBy
 693      };
 694  
 695      var cached = function (f) {
 696        var called = false;
 697        var r;
 698        return function () {
 699          var args = [];
 700          for (var _i = 0; _i < arguments.length; _i++) {
 701            args[_i] = arguments[_i];
 702          }
 703          if (!called) {
 704            called = true;
 705            r = f.apply(null, args);
 706          }
 707          return r;
 708        };
 709      };
 710  
 711      var firstMatch = function (regexes, s) {
 712        for (var i = 0; i < regexes.length; i++) {
 713          var x = regexes[i];
 714          if (x.test(s)) {
 715            return x;
 716          }
 717        }
 718        return undefined;
 719      };
 720      var find$1 = function (regexes, agent) {
 721        var r = firstMatch(regexes, agent);
 722        if (!r) {
 723          return {
 724            major: 0,
 725            minor: 0
 726          };
 727        }
 728        var group = function (i) {
 729          return Number(agent.replace(r, '$' + i));
 730        };
 731        return nu(group(1), group(2));
 732      };
 733      var detect = function (versionRegexes, agent) {
 734        var cleanedAgent = String(agent).toLowerCase();
 735        if (versionRegexes.length === 0) {
 736          return unknown();
 737        }
 738        return find$1(versionRegexes, cleanedAgent);
 739      };
 740      var unknown = function () {
 741        return nu(0, 0);
 742      };
 743      var nu = function (major, minor) {
 744        return {
 745          major: major,
 746          minor: minor
 747        };
 748      };
 749      var Version = {
 750        nu: nu,
 751        detect: detect,
 752        unknown: unknown
 753      };
 754  
 755      var edge = 'Edge';
 756      var chrome = 'Chrome';
 757      var ie = 'IE';
 758      var opera = 'Opera';
 759      var firefox = 'Firefox';
 760      var safari = 'Safari';
 761      var isBrowser = function (name, current) {
 762        return function () {
 763          return current === name;
 764        };
 765      };
 766      var unknown$1 = function () {
 767        return nu$1({
 768          current: undefined,
 769          version: Version.unknown()
 770        });
 771      };
 772      var nu$1 = function (info) {
 773        var current = info.current;
 774        var version = info.version;
 775        return {
 776          current: current,
 777          version: version,
 778          isEdge: isBrowser(edge, current),
 779          isChrome: isBrowser(chrome, current),
 780          isIE: isBrowser(ie, current),
 781          isOpera: isBrowser(opera, current),
 782          isFirefox: isBrowser(firefox, current),
 783          isSafari: isBrowser(safari, current)
 784        };
 785      };
 786      var Browser = {
 787        unknown: unknown$1,
 788        nu: nu$1,
 789        edge: constant(edge),
 790        chrome: constant(chrome),
 791        ie: constant(ie),
 792        opera: constant(opera),
 793        firefox: constant(firefox),
 794        safari: constant(safari)
 795      };
 796  
 797      var windows = 'Windows';
 798      var ios = 'iOS';
 799      var android = 'Android';
 800      var linux = 'Linux';
 801      var osx = 'OSX';
 802      var solaris = 'Solaris';
 803      var freebsd = 'FreeBSD';
 804      var isOS = function (name, current) {
 805        return function () {
 806          return current === name;
 807        };
 808      };
 809      var unknown$2 = function () {
 810        return nu$2({
 811          current: undefined,
 812          version: Version.unknown()
 813        });
 814      };
 815      var nu$2 = function (info) {
 816        var current = info.current;
 817        var version = info.version;
 818        return {
 819          current: current,
 820          version: version,
 821          isWindows: isOS(windows, current),
 822          isiOS: isOS(ios, current),
 823          isAndroid: isOS(android, current),
 824          isOSX: isOS(osx, current),
 825          isLinux: isOS(linux, current),
 826          isSolaris: isOS(solaris, current),
 827          isFreeBSD: isOS(freebsd, current)
 828        };
 829      };
 830      var OperatingSystem = {
 831        unknown: unknown$2,
 832        nu: nu$2,
 833        windows: constant(windows),
 834        ios: constant(ios),
 835        android: constant(android),
 836        linux: constant(linux),
 837        osx: constant(osx),
 838        solaris: constant(solaris),
 839        freebsd: constant(freebsd)
 840      };
 841  
 842      var DeviceType = function (os, browser, userAgent) {
 843        var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
 844        var isiPhone = os.isiOS() && !isiPad;
 845        var isAndroid3 = os.isAndroid() && os.version.major === 3;
 846        var isAndroid4 = os.isAndroid() && os.version.major === 4;
 847        var isTablet = isiPad || isAndroid3 || isAndroid4 && /mobile/i.test(userAgent) === true;
 848        var isTouch = os.isiOS() || os.isAndroid();
 849        var isPhone = isTouch && !isTablet;
 850        var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
 851        return {
 852          isiPad: constant(isiPad),
 853          isiPhone: constant(isiPhone),
 854          isTablet: constant(isTablet),
 855          isPhone: constant(isPhone),
 856          isTouch: constant(isTouch),
 857          isAndroid: os.isAndroid,
 858          isiOS: os.isiOS,
 859          isWebView: constant(iOSwebview)
 860        };
 861      };
 862  
 863      var detect$1 = function (candidates, userAgent) {
 864        var agent = String(userAgent).toLowerCase();
 865        return find(candidates, function (candidate) {
 866          return candidate.search(agent);
 867        });
 868      };
 869      var detectBrowser = function (browsers, userAgent) {
 870        return detect$1(browsers, userAgent).map(function (browser) {
 871          var version = Version.detect(browser.versionRegexes, userAgent);
 872          return {
 873            current: browser.name,
 874            version: version
 875          };
 876        });
 877      };
 878      var detectOs = function (oses, userAgent) {
 879        return detect$1(oses, userAgent).map(function (os) {
 880          var version = Version.detect(os.versionRegexes, userAgent);
 881          return {
 882            current: os.name,
 883            version: version
 884          };
 885        });
 886      };
 887      var UaString = {
 888        detectBrowser: detectBrowser,
 889        detectOs: detectOs
 890      };
 891  
 892      var contains = function (str, substr) {
 893        return str.indexOf(substr) !== -1;
 894      };
 895  
 896      var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
 897      var checkContains = function (target) {
 898        return function (uastring) {
 899          return contains(uastring, target);
 900        };
 901      };
 902      var browsers = [
 903        {
 904          name: 'Edge',
 905          versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
 906          search: function (uastring) {
 907            return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
 908          }
 909        },
 910        {
 911          name: 'Chrome',
 912          versionRegexes: [
 913            /.*?chrome\/([0-9]+)\.([0-9]+).*/,
 914            normalVersionRegex
 915          ],
 916          search: function (uastring) {
 917            return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
 918          }
 919        },
 920        {
 921          name: 'IE',
 922          versionRegexes: [
 923            /.*?msie\ ?([0-9]+)\.([0-9]+).*/,
 924            /.*?rv:([0-9]+)\.([0-9]+).*/
 925          ],
 926          search: function (uastring) {
 927            return contains(uastring, 'msie') || contains(uastring, 'trident');
 928          }
 929        },
 930        {
 931          name: 'Opera',
 932          versionRegexes: [
 933            normalVersionRegex,
 934            /.*?opera\/([0-9]+)\.([0-9]+).*/
 935          ],
 936          search: checkContains('opera')
 937        },
 938        {
 939          name: 'Firefox',
 940          versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
 941          search: checkContains('firefox')
 942        },
 943        {
 944          name: 'Safari',
 945          versionRegexes: [
 946            normalVersionRegex,
 947            /.*?cpu os ([0-9]+)_([0-9]+).*/
 948          ],
 949          search: function (uastring) {
 950            return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
 951          }
 952        }
 953      ];
 954      var oses = [
 955        {
 956          name: 'Windows',
 957          search: checkContains('win'),
 958          versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
 959        },
 960        {
 961          name: 'iOS',
 962          search: function (uastring) {
 963            return contains(uastring, 'iphone') || contains(uastring, 'ipad');
 964          },
 965          versionRegexes: [
 966            /.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
 967            /.*cpu os ([0-9]+)_([0-9]+).*/,
 968            /.*cpu iphone os ([0-9]+)_([0-9]+).*/
 969          ]
 970        },
 971        {
 972          name: 'Android',
 973          search: checkContains('android'),
 974          versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
 975        },
 976        {
 977          name: 'OSX',
 978          search: checkContains('os x'),
 979          versionRegexes: [/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]
 980        },
 981        {
 982          name: 'Linux',
 983          search: checkContains('linux'),
 984          versionRegexes: []
 985        },
 986        {
 987          name: 'Solaris',
 988          search: checkContains('sunos'),
 989          versionRegexes: []
 990        },
 991        {
 992          name: 'FreeBSD',
 993          search: checkContains('freebsd'),
 994          versionRegexes: []
 995        }
 996      ];
 997      var PlatformInfo = {
 998        browsers: constant(browsers),
 999        oses: constant(oses)
1000      };
1001  
1002      var detect$2 = function (userAgent) {
1003        var browsers = PlatformInfo.browsers();
1004        var oses = PlatformInfo.oses();
1005        var browser = UaString.detectBrowser(browsers, userAgent).fold(Browser.unknown, Browser.nu);
1006        var os = UaString.detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
1007        var deviceType = DeviceType(os, browser, userAgent);
1008        return {
1009          browser: browser,
1010          os: os,
1011          deviceType: deviceType
1012        };
1013      };
1014      var PlatformDetection = { detect: detect$2 };
1015  
1016      var detect$3 = cached(function () {
1017        var userAgent = domGlobals.navigator.userAgent;
1018        return PlatformDetection.detect(userAgent);
1019      });
1020      var PlatformDetection$1 = { detect: detect$3 };
1021  
1022      var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE;
1023      var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE;
1024      var COMMENT = domGlobals.Node.COMMENT_NODE;
1025      var DOCUMENT = domGlobals.Node.DOCUMENT_NODE;
1026      var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE;
1027      var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE;
1028      var ELEMENT = domGlobals.Node.ELEMENT_NODE;
1029      var TEXT = domGlobals.Node.TEXT_NODE;
1030      var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE;
1031      var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE;
1032      var ENTITY = domGlobals.Node.ENTITY_NODE;
1033      var NOTATION = domGlobals.Node.NOTATION_NODE;
1034  
1035      var ELEMENT$1 = ELEMENT;
1036      var is = function (element, selector) {
1037        var dom = element.dom();
1038        if (dom.nodeType !== ELEMENT$1) {
1039          return false;
1040        } else {
1041          var elem = dom;
1042          if (elem.matches !== undefined) {
1043            return elem.matches(selector);
1044          } else if (elem.msMatchesSelector !== undefined) {
1045            return elem.msMatchesSelector(selector);
1046          } else if (elem.webkitMatchesSelector !== undefined) {
1047            return elem.webkitMatchesSelector(selector);
1048          } else if (elem.mozMatchesSelector !== undefined) {
1049            return elem.mozMatchesSelector(selector);
1050          } else {
1051            throw new Error('Browser lacks native selectors');
1052          }
1053        }
1054      };
1055  
1056      var eq = function (e1, e2) {
1057        return e1.dom() === e2.dom();
1058      };
1059      var regularContains = function (e1, e2) {
1060        var d1 = e1.dom();
1061        var d2 = e2.dom();
1062        return d1 === d2 ? false : d1.contains(d2);
1063      };
1064      var ieContains = function (e1, e2) {
1065        return Node.documentPositionContainedBy(e1.dom(), e2.dom());
1066      };
1067      var browser = PlatformDetection$1.detect().browser;
1068      var contains$1 = browser.isIE() ? ieContains : regularContains;
1069      var is$1 = is;
1070  
1071      var parent = function (element) {
1072        return Option.from(element.dom().parentNode).map(Element.fromDom);
1073      };
1074      var children = function (element) {
1075        return map(element.dom().childNodes, Element.fromDom);
1076      };
1077      var child = function (element, index) {
1078        var cs = element.dom().childNodes;
1079        return Option.from(cs[index]).map(Element.fromDom);
1080      };
1081      var firstChild = function (element) {
1082        return child(element, 0);
1083      };
1084      var lastChild = function (element) {
1085        return child(element, element.dom().childNodes.length - 1);
1086      };
1087      var spot = Immutable('element', 'offset');
1088  
1089      var before = function (marker, element) {
1090        var parent$1 = parent(marker);
1091        parent$1.each(function (v) {
1092          v.dom().insertBefore(element.dom(), marker.dom());
1093        });
1094      };
1095      var append = function (parent, element) {
1096        parent.dom().appendChild(element.dom());
1097      };
1098  
1099      var before$1 = function (marker, elements) {
1100        each(elements, function (x) {
1101          before(marker, x);
1102        });
1103      };
1104      var append$1 = function (parent, elements) {
1105        each(elements, function (x) {
1106          append(parent, x);
1107        });
1108      };
1109  
1110      var remove = function (element) {
1111        var dom = element.dom();
1112        if (dom.parentNode !== null) {
1113          dom.parentNode.removeChild(dom);
1114        }
1115      };
1116  
1117      var name = function (element) {
1118        var r = element.dom().nodeName;
1119        return r.toLowerCase();
1120      };
1121      var type = function (element) {
1122        return element.dom().nodeType;
1123      };
1124      var isType$1 = function (t) {
1125        return function (element) {
1126          return type(element) === t;
1127        };
1128      };
1129      var isElement = isType$1(ELEMENT);
1130  
1131      var rawSet = function (dom, key, value) {
1132        if (isString(value) || isBoolean(value) || isNumber(value)) {
1133          dom.setAttribute(key, value + '');
1134        } else {
1135          domGlobals.console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom);
1136          throw new Error('Attribute value was not simple');
1137        }
1138      };
1139      var setAll = function (element, attrs) {
1140        var dom = element.dom();
1141        each$1(attrs, function (v, k) {
1142          rawSet(dom, k, v);
1143        });
1144      };
1145      var clone = function (element) {
1146        return foldl(element.dom().attributes, function (acc, attr) {
1147          acc[attr.name] = attr.value;
1148          return acc;
1149        }, {});
1150      };
1151  
1152      var isSupported = function (dom) {
1153        return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
1154      };
1155  
1156      var internalSet = function (dom, property, value) {
1157        if (!isString(value)) {
1158          domGlobals.console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
1159          throw new Error('CSS value must be a string: ' + value);
1160        }
1161        if (isSupported(dom)) {
1162          dom.style.setProperty(property, value);
1163        }
1164      };
1165      var set = function (element, property, value) {
1166        var dom = element.dom();
1167        internalSet(dom, property, value);
1168      };
1169  
1170      var clone$1 = function (original, isDeep) {
1171        return Element.fromDom(original.dom().cloneNode(isDeep));
1172      };
1173      var deep = function (original) {
1174        return clone$1(original, true);
1175      };
1176      var shallowAs = function (original, tag) {
1177        var nu = Element.fromTag(tag);
1178        var attributes = clone(original);
1179        setAll(nu, attributes);
1180        return nu;
1181      };
1182      var mutate = function (original, tag) {
1183        var nu = shallowAs(original, tag);
1184        before(original, nu);
1185        var children$1 = children(original);
1186        append$1(nu, children$1);
1187        remove(original);
1188        return nu;
1189      };
1190  
1191      var joinSegment = function (parent, child) {
1192        append(parent.item, child.list);
1193      };
1194      var joinSegments = function (segments) {
1195        for (var i = 1; i < segments.length; i++) {
1196          joinSegment(segments[i - 1], segments[i]);
1197        }
1198      };
1199      var appendSegments = function (head$1, tail) {
1200        liftN([
1201          last(head$1),
1202          head(tail)
1203        ], joinSegment);
1204      };
1205      var createSegment = function (scope, listType) {
1206        var segment = {
1207          list: Element.fromTag(listType, scope),
1208          item: Element.fromTag('li', scope)
1209        };
1210        append(segment.list, segment.item);
1211        return segment;
1212      };
1213      var createSegments = function (scope, entry, size) {
1214        var segments = [];
1215        for (var i = 0; i < size; i++) {
1216          segments.push(createSegment(scope, entry.listType));
1217        }
1218        return segments;
1219      };
1220      var populateSegments = function (segments, entry) {
1221        for (var i = 0; i < segments.length - 1; i++) {
1222          set(segments[i].item, 'list-style-type', 'none');
1223        }
1224        last(segments).each(function (segment) {
1225          setAll(segment.list, entry.listAttributes);
1226          setAll(segment.item, entry.itemAttributes);
1227          append$1(segment.item, entry.content);
1228        });
1229      };
1230      var normalizeSegment = function (segment, entry) {
1231        if (name(segment.list) !== entry.listType) {
1232          segment.list = mutate(segment.list, entry.listType);
1233        }
1234        setAll(segment.list, entry.listAttributes);
1235      };
1236      var createItem = function (scope, attr, content) {
1237        var item = Element.fromTag('li', scope);
1238        setAll(item, attr);
1239        append$1(item, content);
1240        return item;
1241      };
1242      var appendItem = function (segment, item) {
1243        append(segment.list, item);
1244        segment.item = item;
1245      };
1246      var writeShallow = function (scope, cast, entry) {
1247        var newCast = cast.slice(0, entry.depth);
1248        last(newCast).each(function (segment) {
1249          var item = createItem(scope, entry.itemAttributes, entry.content);
1250          appendItem(segment, item);
1251          normalizeSegment(segment, entry);
1252        });
1253        return newCast;
1254      };
1255      var writeDeep = function (scope, cast, entry) {
1256        var segments = createSegments(scope, entry, entry.depth - cast.length);
1257        joinSegments(segments);
1258        populateSegments(segments, entry);
1259        appendSegments(cast, segments);
1260        return cast.concat(segments);
1261      };
1262      var composeList = function (scope, entries) {
1263        var cast = foldl(entries, function (cast, entry) {
1264          return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
1265        }, []);
1266        return head(cast).map(function (segment) {
1267          return segment.list;
1268        });
1269      };
1270  
1271      var isList$1 = function (el) {
1272        return is$1(el, 'OL,UL');
1273      };
1274      var hasFirstChildList = function (el) {
1275        return firstChild(el).map(isList$1).getOr(false);
1276      };
1277      var hasLastChildList = function (el) {
1278        return lastChild(el).map(isList$1).getOr(false);
1279      };
1280  
1281      var isIndented = function (entry) {
1282        return entry.depth > 0;
1283      };
1284      var isSelected = function (entry) {
1285        return entry.isSelected;
1286      };
1287      var cloneItemContent = function (li) {
1288        var children$1 = children(li);
1289        var content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
1290        return map(content, deep);
1291      };
1292      var createEntry = function (li, depth, isSelected) {
1293        return parent(li).filter(isElement).map(function (list) {
1294          return {
1295            depth: depth,
1296            isSelected: isSelected,
1297            content: cloneItemContent(li),
1298            itemAttributes: clone(li),
1299            listAttributes: clone(list),
1300            listType: name(list)
1301          };
1302        });
1303      };
1304  
1305      var indentEntry = function (indentation, entry) {
1306        switch (indentation) {
1307        case 'Indent':
1308          entry.depth++;
1309          break;
1310        case 'Outdent':
1311          entry.depth--;
1312          break;
1313        case 'Flatten':
1314          entry.depth = 0;
1315        }
1316      };
1317  
1318      var hasOwnProperty = Object.prototype.hasOwnProperty;
1319      var shallow = function (old, nu) {
1320        return nu;
1321      };
1322      var baseMerge = function (merger) {
1323        return function () {
1324          var objects = new Array(arguments.length);
1325          for (var i = 0; i < objects.length; i++) {
1326            objects[i] = arguments[i];
1327          }
1328          if (objects.length === 0) {
1329            throw new Error('Can\'t merge zero objects');
1330          }
1331          var ret = {};
1332          for (var j = 0; j < objects.length; j++) {
1333            var curObject = objects[j];
1334            for (var key in curObject) {
1335              if (hasOwnProperty.call(curObject, key)) {
1336                ret[key] = merger(ret[key], curObject[key]);
1337              }
1338            }
1339          }
1340          return ret;
1341        };
1342      };
1343      var merge = baseMerge(shallow);
1344  
1345      var cloneListProperties = function (target, source) {
1346        target.listType = source.listType;
1347        target.listAttributes = merge({}, source.listAttributes);
1348      };
1349      var previousSiblingEntry = function (entries, start) {
1350        var depth = entries[start].depth;
1351        for (var i = start - 1; i >= 0; i--) {
1352          if (entries[i].depth === depth) {
1353            return Option.some(entries[i]);
1354          }
1355          if (entries[i].depth < depth) {
1356            break;
1357          }
1358        }
1359        return Option.none();
1360      };
1361      var normalizeEntries = function (entries) {
1362        each(entries, function (entry, i) {
1363          previousSiblingEntry(entries, i).each(function (matchingEntry) {
1364            cloneListProperties(entry, matchingEntry);
1365          });
1366        });
1367      };
1368  
1369      var Cell = function (initial) {
1370        var value = initial;
1371        var get = function () {
1372          return value;
1373        };
1374        var set = function (v) {
1375          value = v;
1376        };
1377        var clone = function () {
1378          return Cell(get());
1379        };
1380        return {
1381          get: get,
1382          set: set,
1383          clone: clone
1384        };
1385      };
1386  
1387      var parseItem = function (depth, itemSelection, selectionState, item) {
1388        return firstChild(item).filter(isList$1).fold(function () {
1389          itemSelection.each(function (selection) {
1390            if (eq(selection.start, item)) {
1391              selectionState.set(true);
1392            }
1393          });
1394          var currentItemEntry = createEntry(item, depth, selectionState.get());
1395          itemSelection.each(function (selection) {
1396            if (eq(selection.end, item)) {
1397              selectionState.set(false);
1398            }
1399          });
1400          var childListEntries = lastChild(item).filter(isList$1).map(function (list) {
1401            return parseList(depth, itemSelection, selectionState, list);
1402          }).getOr([]);
1403          return currentItemEntry.toArray().concat(childListEntries);
1404        }, function (list) {
1405          return parseList(depth, itemSelection, selectionState, list);
1406        });
1407      };
1408      var parseList = function (depth, itemSelection, selectionState, list) {
1409        return bind(children(list), function (element) {
1410          var parser = isList$1(element) ? parseList : parseItem;
1411          var newDepth = depth + 1;
1412          return parser(newDepth, itemSelection, selectionState, element);
1413        });
1414      };
1415      var parseLists = function (lists, itemSelection) {
1416        var selectionState = Cell(false);
1417        var initialDepth = 0;
1418        return map(lists, function (list) {
1419          return {
1420            sourceList: list,
1421            entries: parseList(initialDepth, itemSelection, selectionState, list)
1422          };
1423        });
1424      };
1425  
1426      var global$8 = tinymce.util.Tools.resolve('tinymce.Env');
1427  
1428      var createTextBlock = function (editor, contentNode) {
1429        var dom = editor.dom;
1430        var blockElements = editor.schema.getBlockElements();
1431        var fragment = dom.createFragment();
1432        var node, textBlock, blockName, hasContentNode;
1433        if (editor.settings.forced_root_block) {
1434          blockName = editor.settings.forced_root_block;
1435        }
1436        if (blockName) {
1437          textBlock = dom.create(blockName);
1438          if (textBlock.tagName === editor.settings.forced_root_block) {
1439            dom.setAttribs(textBlock, editor.settings.forced_root_block_attrs);
1440          }
1441          if (!NodeType.isBlock(contentNode.firstChild, blockElements)) {
1442            fragment.appendChild(textBlock);
1443          }
1444        }
1445        if (contentNode) {
1446          while (node = contentNode.firstChild) {
1447            var nodeName = node.nodeName;
1448            if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) {
1449              hasContentNode = true;
1450            }
1451            if (NodeType.isBlock(node, blockElements)) {
1452              fragment.appendChild(node);
1453              textBlock = null;
1454            } else {
1455              if (blockName) {
1456                if (!textBlock) {
1457                  textBlock = dom.create(blockName);
1458                  fragment.appendChild(textBlock);
1459                }
1460                textBlock.appendChild(node);
1461              } else {
1462                fragment.appendChild(node);
1463              }
1464            }
1465          }
1466        }
1467        if (!editor.settings.forced_root_block) {
1468          fragment.appendChild(dom.create('br'));
1469        } else {
1470          if (!hasContentNode && (!global$8.ie || global$8.ie > 10)) {
1471            textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' }));
1472          }
1473        }
1474        return fragment;
1475      };
1476  
1477      var outdentedComposer = function (editor, entries) {
1478        return map(entries, function (entry) {
1479          var content = fromElements(entry.content);
1480          return Element.fromDom(createTextBlock(editor, content.dom()));
1481        });
1482      };
1483      var indentedComposer = function (editor, entries) {
1484        normalizeEntries(entries);
1485        return composeList(editor.contentDocument, entries).toArray();
1486      };
1487      var composeEntries = function (editor, entries) {
1488        return bind(groupBy(entries, isIndented), function (entries) {
1489          var groupIsIndented = head(entries).map(isIndented).getOr(false);
1490          return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
1491        });
1492      };
1493      var indentSelectedEntries = function (entries, indentation) {
1494        each(filter(entries, isSelected), function (entry) {
1495          return indentEntry(indentation, entry);
1496        });
1497      };
1498      var getItemSelection = function (editor) {
1499        var selectedListItems = map(Selection.getSelectedListItems(editor), Element.fromDom);
1500        return liftN([
1501          find(selectedListItems, not(hasFirstChildList)),
1502          find(reverse(selectedListItems), not(hasFirstChildList))
1503        ], function (start, end) {
1504          return {
1505            start: start,
1506            end: end
1507          };
1508        });
1509      };
1510      var listsIndentation = function (editor, lists, indentation) {
1511        var entrySets = parseLists(lists, getItemSelection(editor));
1512        each(entrySets, function (entrySet) {
1513          indentSelectedEntries(entrySet.entries, indentation);
1514          before$1(entrySet.sourceList, composeEntries(editor, entrySet.entries));
1515          remove(entrySet.sourceList);
1516        });
1517      };
1518  
1519      var DOM$1 = global$6.DOM;
1520      var splitList = function (editor, ul, li) {
1521        var tmpRng, fragment, bookmarks, node, newBlock;
1522        var removeAndKeepBookmarks = function (targetNode) {
1523          global$5.each(bookmarks, function (node) {
1524            targetNode.parentNode.insertBefore(node, li.parentNode);
1525          });
1526          DOM$1.remove(targetNode);
1527        };
1528        bookmarks = DOM$1.select('span[data-mce-type="bookmark"]', ul);
1529        newBlock = createTextBlock(editor, li);
1530        tmpRng = DOM$1.createRng();
1531        tmpRng.setStartAfter(li);
1532        tmpRng.setEndAfter(ul);
1533        fragment = tmpRng.extractContents();
1534        for (node = fragment.firstChild; node; node = node.firstChild) {
1535          if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) {
1536            DOM$1.remove(node);
1537            break;
1538          }
1539        }
1540        if (!editor.dom.isEmpty(fragment)) {
1541          DOM$1.insertAfter(fragment, ul);
1542        }
1543        DOM$1.insertAfter(newBlock, ul);
1544        if (NodeType.isEmpty(editor.dom, li.parentNode)) {
1545          removeAndKeepBookmarks(li.parentNode);
1546        }
1547        DOM$1.remove(li);
1548        if (NodeType.isEmpty(editor.dom, ul)) {
1549          DOM$1.remove(ul);
1550        }
1551      };
1552      var SplitList = { splitList: splitList };
1553  
1554      var outdentDlItem = function (editor, item) {
1555        if (is$1(item, 'dd')) {
1556          mutate(item, 'dt');
1557        } else if (is$1(item, 'dt')) {
1558          parent(item).each(function (dl) {
1559            return SplitList.splitList(editor, dl.dom(), item.dom());
1560          });
1561        }
1562      };
1563      var indentDlItem = function (item) {
1564        if (is$1(item, 'dt')) {
1565          mutate(item, 'dd');
1566        }
1567      };
1568      var dlIndentation = function (editor, indentation, dlItems) {
1569        if (indentation === 'Indent') {
1570          each(dlItems, indentDlItem);
1571        } else {
1572          each(dlItems, function (item) {
1573            return outdentDlItem(editor, item);
1574          });
1575        }
1576      };
1577  
1578      var selectionIndentation = function (editor, indentation) {
1579        var lists = map(Selection.getSelectedListRoots(editor), Element.fromDom);
1580        var dlItems = map(Selection.getSelectedDlItems(editor), Element.fromDom);
1581        var isHandled = false;
1582        if (lists.length || dlItems.length) {
1583          var bookmark = editor.selection.getBookmark();
1584          listsIndentation(editor, lists, indentation);
1585          dlIndentation(editor, indentation, dlItems);
1586          editor.selection.moveToBookmark(bookmark);
1587          editor.selection.setRng(Range.normalizeRange(editor.selection.getRng()));
1588          editor.nodeChanged();
1589          isHandled = true;
1590        }
1591        return isHandled;
1592      };
1593      var indentListSelection = function (editor) {
1594        return selectionIndentation(editor, 'Indent');
1595      };
1596      var outdentListSelection = function (editor) {
1597        return selectionIndentation(editor, 'Outdent');
1598      };
1599      var flattenListSelection = function (editor) {
1600        return selectionIndentation(editor, 'Flatten');
1601      };
1602  
1603      var updateListStyle = function (dom, el, detail) {
1604        var type = detail['list-style-type'] ? detail['list-style-type'] : null;
1605        dom.setStyle(el, 'list-style-type', type);
1606      };
1607      var setAttribs = function (elm, attrs) {
1608        global$5.each(attrs, function (value, key) {
1609          elm.setAttribute(key, value);
1610        });
1611      };
1612      var updateListAttrs = function (dom, el, detail) {
1613        setAttribs(el, detail['list-attributes']);
1614        global$5.each(dom.select('li', el), function (li) {
1615          setAttribs(li, detail['list-item-attributes']);
1616        });
1617      };
1618      var updateListWithDetails = function (dom, el, detail) {
1619        updateListStyle(dom, el, detail);
1620        updateListAttrs(dom, el, detail);
1621      };
1622      var removeStyles = function (dom, element, styles) {
1623        global$5.each(styles, function (style) {
1624          var _a;
1625          return dom.setStyle(element, (_a = {}, _a[style] = '', _a));
1626        });
1627      };
1628      var getEndPointNode = function (editor, rng, start, root) {
1629        var container, offset;
1630        container = rng[start ? 'startContainer' : 'endContainer'];
1631        offset = rng[start ? 'startOffset' : 'endOffset'];
1632        if (container.nodeType === 1) {
1633          container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
1634        }
1635        if (!start && NodeType.isBr(container.nextSibling)) {
1636          container = container.nextSibling;
1637        }
1638        while (container.parentNode !== root) {
1639          if (NodeType.isTextBlock(editor, container)) {
1640            return container;
1641          }
1642          if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
1643            return container;
1644          }
1645          container = container.parentNode;
1646        }
1647        return container;
1648      };
1649      var getSelectedTextBlocks = function (editor, rng, root) {
1650        var textBlocks = [], dom = editor.dom;
1651        var startNode = getEndPointNode(editor, rng, true, root);
1652        var endNode = getEndPointNode(editor, rng, false, root);
1653        var block;
1654        var siblings = [];
1655        for (var node = startNode; node; node = node.nextSibling) {
1656          siblings.push(node);
1657          if (node === endNode) {
1658            break;
1659          }
1660        }
1661        global$5.each(siblings, function (node) {
1662          if (NodeType.isTextBlock(editor, node)) {
1663            textBlocks.push(node);
1664            block = null;
1665            return;
1666          }
1667          if (dom.isBlock(node) || NodeType.isBr(node)) {
1668            if (NodeType.isBr(node)) {
1669              dom.remove(node);
1670            }
1671            block = null;
1672            return;
1673          }
1674          var nextSibling = node.nextSibling;
1675          if (global$4.isBookmarkNode(node)) {
1676            if (NodeType.isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) {
1677              block = null;
1678              return;
1679            }
1680          }
1681          if (!block) {
1682            block = dom.create('p');
1683            node.parentNode.insertBefore(block, node);
1684            textBlocks.push(block);
1685          }
1686          block.appendChild(node);
1687        });
1688        return textBlocks;
1689      };
1690      var hasCompatibleStyle = function (dom, sib, detail) {
1691        var sibStyle = dom.getStyle(sib, 'list-style-type');
1692        var detailStyle = detail ? detail['list-style-type'] : '';
1693        detailStyle = detailStyle === null ? '' : detailStyle;
1694        return sibStyle === detailStyle;
1695      };
1696      var applyList = function (editor, listName, detail) {
1697        if (detail === void 0) {
1698          detail = {};
1699        }
1700        var rng = editor.selection.getRng(true);
1701        var bookmark;
1702        var listItemName = 'LI';
1703        var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
1704        var dom = editor.dom;
1705        if (dom.getContentEditable(editor.selection.getNode()) === 'false') {
1706          return;
1707        }
1708        listName = listName.toUpperCase();
1709        if (listName === 'DL') {
1710          listItemName = 'DT';
1711        }
1712        bookmark = Bookmark.createBookmark(rng);
1713        global$5.each(getSelectedTextBlocks(editor, rng, root), function (block) {
1714          var listBlock, sibling;
1715          sibling = block.previousSibling;
1716          if (sibling && NodeType.isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) {
1717            listBlock = sibling;
1718            block = dom.rename(block, listItemName);
1719            sibling.appendChild(block);
1720          } else {
1721            listBlock = dom.create(listName);
1722            block.parentNode.insertBefore(listBlock, block);
1723            listBlock.appendChild(block);
1724            block = dom.rename(block, listItemName);
1725          }
1726          removeStyles(dom, block, [
1727            'margin',
1728            'margin-right',
1729            'margin-bottom',
1730            'margin-left',
1731            'margin-top',
1732            'padding',
1733            'padding-right',
1734            'padding-bottom',
1735            'padding-left',
1736            'padding-top'
1737          ]);
1738          updateListWithDetails(dom, listBlock, detail);
1739          mergeWithAdjacentLists(editor.dom, listBlock);
1740        });
1741        editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1742      };
1743      var isValidLists = function (list1, list2) {
1744        return list1 && list2 && NodeType.isListNode(list1) && list1.nodeName === list2.nodeName;
1745      };
1746      var hasSameListStyle = function (dom, list1, list2) {
1747        var targetStyle = dom.getStyle(list1, 'list-style-type', true);
1748        var style = dom.getStyle(list2, 'list-style-type', true);
1749        return targetStyle === style;
1750      };
1751      var hasSameClasses = function (elm1, elm2) {
1752        return elm1.className === elm2.className;
1753      };
1754      var shouldMerge = function (dom, list1, list2) {
1755        return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
1756      };
1757      var mergeWithAdjacentLists = function (dom, listBlock) {
1758        var sibling, node;
1759        sibling = listBlock.nextSibling;
1760        if (shouldMerge(dom, listBlock, sibling)) {
1761          while (node = sibling.firstChild) {
1762            listBlock.appendChild(node);
1763          }
1764          dom.remove(sibling);
1765        }
1766        sibling = listBlock.previousSibling;
1767        if (shouldMerge(dom, listBlock, sibling)) {
1768          while (node = sibling.lastChild) {
1769            listBlock.insertBefore(node, listBlock.firstChild);
1770          }
1771          dom.remove(sibling);
1772        }
1773      };
1774      var updateList = function (dom, list, listName, detail) {
1775        if (list.nodeName !== listName) {
1776          var newList = dom.rename(list, listName);
1777          updateListWithDetails(dom, newList, detail);
1778        } else {
1779          updateListWithDetails(dom, list, detail);
1780        }
1781      };
1782      var toggleMultipleLists = function (editor, parentList, lists, listName, detail) {
1783        if (parentList.nodeName === listName && !hasListStyleDetail(detail)) {
1784          flattenListSelection(editor);
1785        } else {
1786          var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
1787          global$5.each([parentList].concat(lists), function (elm) {
1788            updateList(editor.dom, elm, listName, detail);
1789          });
1790          editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1791        }
1792      };
1793      var hasListStyleDetail = function (detail) {
1794        return 'list-style-type' in detail;
1795      };
1796      var toggleSingleList = function (editor, parentList, listName, detail) {
1797        if (parentList === editor.getBody()) {
1798          return;
1799        }
1800        if (parentList) {
1801          if (parentList.nodeName === listName && !hasListStyleDetail(detail)) {
1802            flattenListSelection(editor);
1803          } else {
1804            var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
1805            updateListWithDetails(editor.dom, parentList, detail);
1806            mergeWithAdjacentLists(editor.dom, editor.dom.rename(parentList, listName));
1807            editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1808          }
1809        } else {
1810          applyList(editor, listName, detail);
1811        }
1812      };
1813      var toggleList = function (editor, listName, detail) {
1814        var parentList = Selection.getParentList(editor);
1815        var selectedSubLists = Selection.getSelectedSubLists(editor);
1816        detail = detail ? detail : {};
1817        if (parentList && selectedSubLists.length > 0) {
1818          toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail);
1819        } else {
1820          toggleSingleList(editor, parentList, listName, detail);
1821        }
1822      };
1823      var ToggleList = {
1824        toggleList: toggleList,
1825        mergeWithAdjacentLists: mergeWithAdjacentLists
1826      };
1827  
1828      var DOM$2 = global$6.DOM;
1829      var normalizeList = function (dom, ul) {
1830        var sibling;
1831        var parentNode = ul.parentNode;
1832        if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) {
1833          sibling = parentNode.previousSibling;
1834          if (sibling && sibling.nodeName === 'LI') {
1835            sibling.appendChild(ul);
1836            if (NodeType.isEmpty(dom, parentNode)) {
1837              DOM$2.remove(parentNode);
1838            }
1839          } else {
1840            DOM$2.setStyle(parentNode, 'listStyleType', 'none');
1841          }
1842        }
1843        if (NodeType.isListNode(parentNode)) {
1844          sibling = parentNode.previousSibling;
1845          if (sibling && sibling.nodeName === 'LI') {
1846            sibling.appendChild(ul);
1847          }
1848        }
1849      };
1850      var normalizeLists = function (dom, element) {
1851        global$5.each(global$5.grep(dom.select('ol,ul', element)), function (ul) {
1852          normalizeList(dom, ul);
1853        });
1854      };
1855      var NormalizeLists = {
1856        normalizeList: normalizeList,
1857        normalizeLists: normalizeLists
1858      };
1859  
1860      var findNextCaretContainer = function (editor, rng, isForward, root) {
1861        var node = rng.startContainer;
1862        var offset = rng.startOffset;
1863        var nonEmptyBlocks, walker;
1864        if (node.nodeType === 3 && (isForward ? offset < node.data.length : offset > 0)) {
1865          return node;
1866        }
1867        nonEmptyBlocks = editor.schema.getNonEmptyElements();
1868        if (node.nodeType === 1) {
1869          node = global$1.getNode(node, offset);
1870        }
1871        walker = new global$2(node, root);
1872        if (isForward) {
1873          if (NodeType.isBogusBr(editor.dom, node)) {
1874            walker.next();
1875          }
1876        }
1877        while (node = walker[isForward ? 'next' : 'prev2']()) {
1878          if (node.nodeName === 'LI' && !node.hasChildNodes()) {
1879            return node;
1880          }
1881          if (nonEmptyBlocks[node.nodeName]) {
1882            return node;
1883          }
1884          if (node.nodeType === 3 && node.data.length > 0) {
1885            return node;
1886          }
1887        }
1888      };
1889      var hasOnlyOneBlockChild = function (dom, elm) {
1890        var childNodes = elm.childNodes;
1891        return childNodes.length === 1 && !NodeType.isListNode(childNodes[0]) && dom.isBlock(childNodes[0]);
1892      };
1893      var unwrapSingleBlockChild = function (dom, elm) {
1894        if (hasOnlyOneBlockChild(dom, elm)) {
1895          dom.remove(elm.firstChild, true);
1896        }
1897      };
1898      var moveChildren = function (dom, fromElm, toElm) {
1899        var node, targetElm;
1900        targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
1901        unwrapSingleBlockChild(dom, fromElm);
1902        if (!NodeType.isEmpty(dom, fromElm, true)) {
1903          while (node = fromElm.firstChild) {
1904            targetElm.appendChild(node);
1905          }
1906        }
1907      };
1908      var mergeLiElements = function (dom, fromElm, toElm) {
1909        var node, listNode;
1910        var ul = fromElm.parentNode;
1911        if (!NodeType.isChildOfBody(dom, fromElm) || !NodeType.isChildOfBody(dom, toElm)) {
1912          return;
1913        }
1914        if (NodeType.isListNode(toElm.lastChild)) {
1915          listNode = toElm.lastChild;
1916        }
1917        if (ul === toElm.lastChild) {
1918          if (NodeType.isBr(ul.previousSibling)) {
1919            dom.remove(ul.previousSibling);
1920          }
1921        }
1922        node = toElm.lastChild;
1923        if (node && NodeType.isBr(node) && fromElm.hasChildNodes()) {
1924          dom.remove(node);
1925        }
1926        if (NodeType.isEmpty(dom, toElm, true)) {
1927          dom.$(toElm).empty();
1928        }
1929        moveChildren(dom, fromElm, toElm);
1930        if (listNode) {
1931          toElm.appendChild(listNode);
1932        }
1933        var contains = contains$1(Element.fromDom(toElm), Element.fromDom(fromElm));
1934        var nestedLists = contains ? dom.getParents(fromElm, NodeType.isListNode, toElm) : [];
1935        dom.remove(fromElm);
1936        each(nestedLists, function (list) {
1937          if (NodeType.isEmpty(dom, list) && list !== dom.getRoot()) {
1938            dom.remove(list);
1939          }
1940        });
1941      };
1942      var mergeIntoEmptyLi = function (editor, fromLi, toLi) {
1943        editor.dom.$(toLi).empty();
1944        mergeLiElements(editor.dom, fromLi, toLi);
1945        editor.selection.setCursorLocation(toLi);
1946      };
1947      var mergeForward = function (editor, rng, fromLi, toLi) {
1948        var dom = editor.dom;
1949        if (dom.isEmpty(toLi)) {
1950          mergeIntoEmptyLi(editor, fromLi, toLi);
1951        } else {
1952          var bookmark = Bookmark.createBookmark(rng);
1953          mergeLiElements(dom, fromLi, toLi);
1954          editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
1955        }
1956      };
1957      var mergeBackward = function (editor, rng, fromLi, toLi) {
1958        var bookmark = Bookmark.createBookmark(rng);
1959        mergeLiElements(editor.dom, fromLi, toLi);
1960        var resolvedBookmark = Bookmark.resolveBookmark(bookmark);
1961        editor.selection.setRng(resolvedBookmark);
1962      };
1963      var backspaceDeleteFromListToListCaret = function (editor, isForward) {
1964        var dom = editor.dom, selection = editor.selection;
1965        var selectionStartElm = selection.getStart();
1966        var root = Selection.getClosestListRootElm(editor, selectionStartElm);
1967        var li = dom.getParent(selection.getStart(), 'LI', root);
1968        var ul, rng, otherLi;
1969        if (li) {
1970          ul = li.parentNode;
1971          if (ul === editor.getBody() && NodeType.isEmpty(dom, ul)) {
1972            return true;
1973          }
1974          rng = Range.normalizeRange(selection.getRng(true));
1975          otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1976          if (otherLi && otherLi !== li) {
1977            if (isForward) {
1978              mergeForward(editor, rng, otherLi, li);
1979            } else {
1980              mergeBackward(editor, rng, li, otherLi);
1981            }
1982            return true;
1983          } else if (!otherLi) {
1984            if (!isForward) {
1985              flattenListSelection(editor);
1986              return true;
1987            }
1988          }
1989        }
1990        return false;
1991      };
1992      var removeBlock = function (dom, block, root) {
1993        var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
1994        dom.remove(block);
1995        if (parentBlock && dom.isEmpty(parentBlock)) {
1996          dom.remove(parentBlock);
1997        }
1998      };
1999      var backspaceDeleteIntoListCaret = function (editor, isForward) {
2000        var dom = editor.dom;
2001        var selectionStartElm = editor.selection.getStart();
2002        var root = Selection.getClosestListRootElm(editor, selectionStartElm);
2003        var block = dom.getParent(selectionStartElm, dom.isBlock, root);
2004        if (block && dom.isEmpty(block)) {
2005          var rng = Range.normalizeRange(editor.selection.getRng(true));
2006          var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
2007          if (otherLi_1) {
2008            editor.undoManager.transact(function () {
2009              removeBlock(dom, block, root);
2010              ToggleList.mergeWithAdjacentLists(dom, otherLi_1.parentNode);
2011              editor.selection.select(otherLi_1, true);
2012              editor.selection.collapse(isForward);
2013            });
2014            return true;
2015          }
2016        }
2017        return false;
2018      };
2019      var backspaceDeleteCaret = function (editor, isForward) {
2020        return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
2021      };
2022      var backspaceDeleteRange = function (editor) {
2023        var selectionStartElm = editor.selection.getStart();
2024        var root = Selection.getClosestListRootElm(editor, selectionStartElm);
2025        var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root);
2026        if (startListParent || Selection.getSelectedListItems(editor).length > 0) {
2027          editor.undoManager.transact(function () {
2028            editor.execCommand('Delete');
2029            NormalizeLists.normalizeLists(editor.dom, editor.getBody());
2030          });
2031          return true;
2032        }
2033        return false;
2034      };
2035      var backspaceDelete = function (editor, isForward) {
2036        return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor);
2037      };
2038      var setup = function (editor) {
2039        editor.on('keydown', function (e) {
2040          if (e.keyCode === global$3.BACKSPACE) {
2041            if (backspaceDelete(editor, false)) {
2042              e.preventDefault();
2043            }
2044          } else if (e.keyCode === global$3.DELETE) {
2045            if (backspaceDelete(editor, true)) {
2046              e.preventDefault();
2047            }
2048          }
2049        });
2050      };
2051      var Delete = {
2052        setup: setup,
2053        backspaceDelete: backspaceDelete
2054      };
2055  
2056      var get = function (editor) {
2057        return {
2058          backspaceDelete: function (isForward) {
2059            Delete.backspaceDelete(editor, isForward);
2060          }
2061        };
2062      };
2063      var Api = { get: get };
2064  
2065      var queryListCommandState = function (editor, listName) {
2066        return function () {
2067          var parentList = editor.dom.getParent(editor.selection.getStart(), 'UL,OL,DL');
2068          return parentList && parentList.nodeName === listName;
2069        };
2070      };
2071      var register = function (editor) {
2072        editor.on('BeforeExecCommand', function (e) {
2073          var cmd = e.command.toLowerCase();
2074          if (cmd === 'indent') {
2075            indentListSelection(editor);
2076          } else if (cmd === 'outdent') {
2077            outdentListSelection(editor);
2078          }
2079        });
2080        editor.addCommand('InsertUnorderedList', function (ui, detail) {
2081          ToggleList.toggleList(editor, 'UL', detail);
2082        });
2083        editor.addCommand('InsertOrderedList', function (ui, detail) {
2084          ToggleList.toggleList(editor, 'OL', detail);
2085        });
2086        editor.addCommand('InsertDefinitionList', function (ui, detail) {
2087          ToggleList.toggleList(editor, 'DL', detail);
2088        });
2089        editor.addCommand('RemoveList', function () {
2090          flattenListSelection(editor);
2091        });
2092        editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL'));
2093        editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL'));
2094        editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL'));
2095      };
2096      var Commands = { register: register };
2097  
2098      var shouldIndentOnTab = function (editor) {
2099        return editor.getParam('lists_indent_on_tab', true);
2100      };
2101      var Settings = { shouldIndentOnTab: shouldIndentOnTab };
2102  
2103      var setupTabKey = function (editor) {
2104        editor.on('keydown', function (e) {
2105          if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) {
2106            return;
2107          }
2108          editor.undoManager.transact(function () {
2109            if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) {
2110              e.preventDefault();
2111            }
2112          });
2113        });
2114      };
2115      var setup$1 = function (editor) {
2116        if (Settings.shouldIndentOnTab(editor)) {
2117          setupTabKey(editor);
2118        }
2119        Delete.setup(editor);
2120      };
2121      var Keyboard = { setup: setup$1 };
2122  
2123      var findIndex = function (list, predicate) {
2124        for (var index = 0; index < list.length; index++) {
2125          var element = list[index];
2126          if (predicate(element)) {
2127            return index;
2128          }
2129        }
2130        return -1;
2131      };
2132      var listState = function (editor, listName) {
2133        return function (e) {
2134          var ctrl = e.control;
2135          editor.on('NodeChange', function (e) {
2136            var tableCellIndex = findIndex(e.parents, NodeType.isTableCellNode);
2137            var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;
2138            var lists = global$5.grep(parents, NodeType.isListNode);
2139            ctrl.active(lists.length > 0 && lists[0].nodeName === listName);
2140          });
2141        };
2142      };
2143      var register$1 = function (editor) {
2144        var hasPlugin = function (editor, plugin) {
2145          var plugins = editor.settings.plugins ? editor.settings.plugins : '';
2146          return global$5.inArray(plugins.split(/[ ,]/), plugin) !== -1;
2147        };
2148        if (!hasPlugin(editor, 'advlist')) {
2149          editor.addButton('numlist', {
2150            active: false,
2151            title: 'Numbered list',
2152            cmd: 'InsertOrderedList',
2153            onPostRender: listState(editor, 'OL')
2154          });
2155          editor.addButton('bullist', {
2156            active: false,
2157            title: 'Bullet list',
2158            cmd: 'InsertUnorderedList',
2159            onPostRender: listState(editor, 'UL')
2160          });
2161        }
2162        editor.addButton('indent', {
2163          icon: 'indent',
2164          title: 'Increase indent',
2165          cmd: 'Indent'
2166        });
2167      };
2168      var Buttons = { register: register$1 };
2169  
2170      global.add('lists', function (editor) {
2171        Keyboard.setup(editor);
2172        Buttons.register(editor);
2173        Commands.register(editor);
2174        return Api.get(editor);
2175      });
2176      function Plugin () {
2177      }
2178  
2179      return Plugin;
2180  
2181  }(window));
2182  })();


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