/*! * 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(o){var t={};function r(n){if(t[n])return t[n].exports;var e=t[n]={i:n,l:!1,exports:{}};return o[n].call(e.exports,e,e.exports,r),e.l=!0,e.exports}r.m=o,r.c=t,r.d=function(n,e,o){r.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:o})},r.r=function(n){Object.defineProperty(n,"__esModule",{value:!0})},r.n=function(n){var e=n&&n.__esModule?function(){return n["default"]}:function(){return n};return r.d(e,"a",e),e},r.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},r.p="",r(r.s="./src/js/plugins/directionality/plugin.js")}({"./src/js/plugins/directionality/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 global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');\n\n var setDir = function (editor, dir) {\n var dom = editor.dom;\n var curDir;\n var blocks = editor.selection.getSelectedBlocks();\n if (blocks.length) {\n curDir = dom.getAttrib(blocks[0], 'dir');\n global$1.each(blocks, function (block) {\n if (!dom.getParent(block.parentNode, '*[dir=\"' + dir + '\"]', dom.getRoot())) {\n dom.setAttrib(block, 'dir', curDir !== dir ? dir : null);\n }\n });\n editor.nodeChanged();\n }\n };\n\n var register = function (editor) {\n editor.addCommand('mceDirectionLTR', function () {\n setDir(editor, 'ltr');\n });\n editor.addCommand('mceDirectionRTL', function () {\n setDir(editor, 'rtl');\n });\n };\n\n var noop = function () {\n };\n var compose1 = function (fbc, fab) {\n return function (a) {\n return fbc(fab(a));\n };\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 isSimpleType = function (type) {\n return function (value) {\n return typeof value === type;\n };\n };\n var isNullable = function (a) {\n return a === null || a === undefined;\n };\n var isNonNullable = function (a) {\n return !isNullable(a);\n };\n var isFunction = isSimpleType('function');\n\n var isSupported = function (dom) {\n return dom.style !== undefined && isFunction(dom.style.getPropertyValue);\n };\n\n var fromHtml = function (html, scope) {\n var doc = scope || document;\n var div = doc.createElement('div');\n div.innerHTML = html;\n if (!div.hasChildNodes() || div.childNodes.length > 1) {\n console.error('HTML does not have a single root node', html);\n throw new Error('HTML must have a single root node');\n }\n return fromDom(div.childNodes[0]);\n };\n var fromTag = function (tag, scope) {\n var doc = scope || document;\n var node = doc.createElement(tag);\n return fromDom(node);\n };\n var fromText = function (text, scope) {\n var doc = scope || document;\n var node = doc.createTextNode(text);\n return fromDom(node);\n };\n var fromDom = function (node) {\n if (node === null || node === undefined) {\n throw new Error('Node cannot be null or undefined');\n }\n return { dom: node };\n };\n var fromPoint = function (docElm, x, y) {\n return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);\n };\n var SugarElement = {\n fromHtml: fromHtml,\n fromTag: fromTag,\n fromText: fromText,\n fromDom: fromDom,\n fromPoint: fromPoint\n };\n\n var Global = typeof window !== 'undefined' ? window : Function('return this;')();\n\n var DOCUMENT = 9;\n var DOCUMENT_FRAGMENT = 11;\n var TEXT = 3;\n\n var type = function (element) {\n return element.dom.nodeType;\n };\n var isType = function (t) {\n return function (element) {\n return type(element) === t;\n };\n };\n var isText = isType(TEXT);\n var isDocument = isType(DOCUMENT);\n var isDocumentFragment = isType(DOCUMENT_FRAGMENT);\n\n var owner = function (element) {\n return SugarElement.fromDom(element.dom.ownerDocument);\n };\n var documentOrOwner = function (dos) {\n return isDocument(dos) ? dos : owner(dos);\n };\n\n var isShadowRoot = function (dos) {\n return isDocumentFragment(dos) && isNonNullable(dos.dom.host);\n };\n var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);\n var getRootNode = supported ? function (e) {\n return SugarElement.fromDom(e.dom.getRootNode());\n } : documentOrOwner;\n var getShadowRoot = function (e) {\n var r = getRootNode(e);\n return isShadowRoot(r) ? Optional.some(r) : Optional.none();\n };\n var getShadowHost = function (e) {\n return SugarElement.fromDom(e.dom.host);\n };\n\n var inBody = function (element) {\n var dom = isText(element) ? element.dom.parentNode : element.dom;\n if (dom === undefined || dom === null || dom.ownerDocument === null) {\n return false;\n }\n var doc = dom.ownerDocument;\n return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {\n return doc.body.contains(dom);\n }, compose1(inBody, getShadowHost));\n };\n\n var get = function (element, property) {\n var dom = element.dom;\n var styles = window.getComputedStyle(dom);\n var r = styles.getPropertyValue(property);\n return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;\n };\n var getUnsafeProperty = function (dom, property) {\n return isSupported(dom) ? dom.style.getPropertyValue(property) : '';\n };\n\n var getDirection = function (element) {\n return get(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';\n };\n\n var getNodeChangeHandler = function (editor, dir) {\n return function (api) {\n var nodeChangeHandler = function (e) {\n var element = SugarElement.fromDom(e.element);\n api.setActive(getDirection(element) === dir);\n };\n editor.on('NodeChange', nodeChangeHandler);\n return function () {\n return editor.off('NodeChange', nodeChangeHandler);\n };\n };\n };\n var register$1 = function (editor) {\n editor.ui.registry.addToggleButton('ltr', {\n tooltip: 'Left to right',\n icon: 'ltr',\n onAction: function () {\n return editor.execCommand('mceDirectionLTR');\n },\n onSetup: getNodeChangeHandler(editor, 'ltr')\n });\n editor.ui.registry.addToggleButton('rtl', {\n tooltip: 'Right to left',\n icon: 'rtl',\n onAction: function () {\n return editor.execCommand('mceDirectionRTL');\n },\n onSetup: getNodeChangeHandler(editor, 'rtl')\n });\n };\n\n function Plugin () {\n global.add('directionality', function (editor) {\n register(editor);\n register$1(editor);\n });\n }\n\n Plugin();\n\n}());\n\n\n//# sourceURL=webpack:///./src/js/plugins/directionality/plugin.js?")}});