[ Index ]

PHP Cross Reference of WordPress

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


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1