/*! * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.7.0 (2021-02-10) * */ !function(t){var r={};function o(n){if(r[n])return r[n].exports;var e=r[n]={i:n,l:!1,exports:{}};return t[n].call(e.exports,e,e.exports,o),e.l=!0,e.exports}o.m=t,o.c=r,o.d=function(n,e,t){o.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:t})},o.r=function(n){Object.defineProperty(n,"__esModule",{value:!0})},o.n=function(n){var e=n&&n.__esModule?function(){return n["default"]}:function(){return n};return o.d(e,"a",e),e},o.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},o.p="",o(o.s="./src/js/plugins/advlist/plugin.js")}({"./src/js/plugins/advlist/plugin.js":function(module,exports){eval("/**\n * Copyright (c) Tiny Technologies, Inc. All rights reserved.\n * Licensed under the LGPL or a commercial license.\n * For LGPL see License.txt in the project root for license information.\n * For commercial licenses see https://www.tiny.cloud/\n *\n * Version: 5.7.0 (2021-02-10)\n */\n (function () {\n 'use strict';\n\n var global = tinymce.util.Tools.resolve('tinymce.PluginManager');\n\n var applyListFormat = function (editor, listName, styleValue) {\n var cmd = listName === 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList';\n editor.execCommand(cmd, false, styleValue === false ? null : { 'list-style-type': styleValue });\n };\n\n var register = function (editor) {\n editor.addCommand('ApplyUnorderedListStyle', function (ui, value) {\n applyListFormat(editor, 'UL', value['list-style-type']);\n });\n editor.addCommand('ApplyOrderedListStyle', function (ui, value) {\n applyListFormat(editor, 'OL', value['list-style-type']);\n });\n };\n\n var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');\n\n var getNumberStyles = function (editor) {\n var styles = editor.getParam('advlist_number_styles', 'default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman');\n return styles ? styles.split(/[ ,]/) : [];\n };\n var getBulletStyles = function (editor) {\n var styles = editor.getParam('advlist_bullet_styles', 'default,circle,square');\n return styles ? styles.split(/[ ,]/) : [];\n };\n\n var noop = function () {\n };\n var constant = function (value) {\n return function () {\n return value;\n };\n };\n var never = constant(false);\n var always = constant(true);\n\n var none = function () {\n return NONE;\n };\n var NONE = function () {\n var eq = function (o) {\n return o.isNone();\n };\n var call = function (thunk) {\n return thunk();\n };\n var id = function (n) {\n return n;\n };\n var me = {\n fold: function (n, _s) {\n return n();\n },\n is: never,\n isSome: never,\n isNone: always,\n getOr: id,\n getOrThunk: call,\n getOrDie: function (msg) {\n throw new Error(msg || 'error: getOrDie called on none.');\n },\n getOrNull: constant(null),\n getOrUndefined: constant(undefined),\n or: id,\n orThunk: call,\n map: none,\n each: noop,\n bind: none,\n exists: never,\n forall: always,\n filter: none,\n equals: eq,\n equals_: eq,\n toArray: function () {\n return [];\n },\n toString: constant('none()')\n };\n return me;\n }();\n var some = function (a) {\n var constant_a = constant(a);\n var self = function () {\n return me;\n };\n var bind = function (f) {\n return f(a);\n };\n var me = {\n fold: function (n, s) {\n return s(a);\n },\n is: function (v) {\n return a === v;\n },\n isSome: always,\n isNone: never,\n getOr: constant_a,\n getOrThunk: constant_a,\n getOrDie: constant_a,\n getOrNull: constant_a,\n getOrUndefined: constant_a,\n or: self,\n orThunk: self,\n map: function (f) {\n return some(f(a));\n },\n each: function (f) {\n f(a);\n },\n bind: bind,\n exists: bind,\n forall: bind,\n filter: function (f) {\n return f(a) ? me : NONE;\n },\n toArray: function () {\n return [a];\n },\n toString: function () {\n return 'some(' + a + ')';\n },\n equals: function (o) {\n return o.is(a);\n },\n equals_: function (o, elementEq) {\n return o.fold(never, function (b) {\n return elementEq(a, b);\n });\n }\n };\n return me;\n };\n var from = function (value) {\n return value === null || value === undefined ? NONE : some(value);\n };\n var Optional = {\n some: some,\n none: none,\n from: from\n };\n\n var isChildOfBody = function (editor, elm) {\n return editor.$.contains(editor.getBody(), elm);\n };\n var isTableCellNode = function (node) {\n return node && /^(TH|TD)$/.test(node.nodeName);\n };\n var isListNode = function (editor) {\n return function (node) {\n return node && /^(OL|UL|DL)$/.test(node.nodeName) && isChildOfBody(editor, node);\n };\n };\n var getSelectedStyleType = function (editor) {\n var listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');\n var style = editor.dom.getStyle(listElm, 'listStyleType');\n return Optional.from(style);\n };\n\n var findIndex = function (list, predicate) {\n for (var index = 0; index < list.length; index++) {\n var element = list[index];\n if (predicate(element)) {\n return index;\n }\n }\n return -1;\n };\n var styleValueToText = function (styleValue) {\n return styleValue.replace(/\\-/g, ' ').replace(/\\b\\w/g, function (chr) {\n return chr.toUpperCase();\n });\n };\n var isWithinList = function (editor, e, nodeName) {\n var tableCellIndex = findIndex(e.parents, isTableCellNode);\n var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;\n var lists = global$1.grep(parents, isListNode(editor));\n return lists.length > 0 && lists[0].nodeName === nodeName;\n };\n var addSplitButton = function (editor, id, tooltip, cmd, nodeName, styles) {\n editor.ui.registry.addSplitButton(id, {\n tooltip: tooltip,\n icon: nodeName === 'OL' ? 'ordered-list' : 'unordered-list',\n presets: 'listpreview',\n columns: 3,\n fetch: function (callback) {\n var items = global$1.map(styles, function (styleValue) {\n var iconStyle = nodeName === 'OL' ? 'num' : 'bull';\n var iconName = styleValue === 'disc' || styleValue === 'decimal' ? 'default' : styleValue;\n var itemValue = styleValue === 'default' ? '' : styleValue;\n var displayText = styleValueToText(styleValue);\n return {\n type: 'choiceitem',\n value: itemValue,\n icon: 'list-' + iconStyle + '-' + iconName,\n text: displayText\n };\n });\n callback(items);\n },\n onAction: function () {\n return editor.execCommand(cmd);\n },\n onItemAction: function (_splitButtonApi, value) {\n applyListFormat(editor, nodeName, value);\n },\n select: function (value) {\n var listStyleType = getSelectedStyleType(editor);\n return listStyleType.map(function (listStyle) {\n return value === listStyle;\n }).getOr(false);\n },\n onSetup: function (api) {\n var nodeChangeHandler = function (e) {\n api.setActive(isWithinList(editor, e, nodeName));\n };\n editor.on('NodeChange', nodeChangeHandler);\n return function () {\n return editor.off('NodeChange', nodeChangeHandler);\n };\n }\n });\n };\n var addButton = function (editor, id, tooltip, cmd, nodeName, _styles) {\n editor.ui.registry.addToggleButton(id, {\n active: false,\n tooltip: tooltip,\n icon: nodeName === 'OL' ? 'ordered-list' : 'unordered-list',\n onSetup: function (api) {\n var nodeChangeHandler = function (e) {\n api.setActive(isWithinList(editor, e, nodeName));\n };\n editor.on('NodeChange', nodeChangeHandler);\n return function () {\n return editor.off('NodeChange', nodeChangeHandler);\n };\n },\n onAction: function () {\n return editor.execCommand(cmd);\n }\n });\n };\n var addControl = function (editor, id, tooltip, cmd, nodeName, styles) {\n if (styles.length > 1) {\n addSplitButton(editor, id, tooltip, cmd, nodeName, styles);\n } else {\n addButton(editor, id, tooltip, cmd, nodeName);\n }\n };\n var register$1 = function (editor) {\n addControl(editor, 'numlist', 'Numbered list', 'InsertOrderedList', 'OL', getNumberStyles(editor));\n addControl(editor, 'bullist', 'Bullet list', 'InsertUnorderedList', 'UL', getBulletStyles(editor));\n };\n\n function Plugin () {\n global.add('advlist', function (editor) {\n if (editor.hasPlugin('lists')) {\n register$1(editor);\n register(editor);\n } else {\n console.error('Please use the Lists plugin together with the Advanced List plugin.');\n }\n });\n }\n\n Plugin();\n\n}());\n\n\n//# sourceURL=webpack:///./src/js/plugins/advlist/plugin.js?")}});