UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

852 lines (810 loc) 87 kB
/*! * jodit-pro - PRO Version of Jodit Editor * Author: Chupurnov Valerii <chupurnov@gmail.com> * Version: v4.9.27 * Url: https://xdsoft.net/jodit/pro/ * License(s): SEE LICENSE IN LICENSE.md */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(self, function() { return (self["webpackChunkjodit_pro"] = self["webpackChunkjodit_pro"] || []).push([[984],{ /***/ 2868: /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ _: function() { return /* binding */ _instanceof1; } /* harmony export */ }); function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } } function _instanceof1(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else return _instanceof(left, right); } /***/ }), /***/ 29528: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ colorPicker: function() { return /* binding */ colorPicker; } /* harmony export */ }); /* harmony import */ var _swc_helpers_call_super__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80294); /* harmony import */ var _swc_helpers_class_call_check__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(20616); /* harmony import */ var _swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(67709); /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(82749); /* harmony import */ var _swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18766); /* harmony import */ var _swc_helpers_wrap_native_super__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(23078); /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(31635); /* harmony import */ var _ui_input_color_input__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(45128); /* harmony import */ var jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(65478); /* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(2748); /* harmony import */ var jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(50911); /* harmony import */ var jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(2692); /*! * Jodit Editor PRO (https://xdsoft.net/jodit/) * See LICENSE.md in the project root for license information. * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/ */ var colorPicker = /*#__PURE__*/ function(Plugin) { "use strict"; (0,_swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__._)(colorPicker, Plugin); function colorPicker() { (0,_swc_helpers_class_call_check__WEBPACK_IMPORTED_MODULE_1__._)(this, colorPicker); var _this; _this = (0,_swc_helpers_call_super__WEBPACK_IMPORTED_MODULE_0__._)(this, colorPicker, arguments), /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "hasStyle", !jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_11__.JoditPro.fatMode); return _this; } (0,_swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__._)(colorPicker, [ { key: "afterInit", value: /** @override */ function afterInit(jodit) { jodit.e.on('afterGenerateColorPicker', this.onAfterGenerateColorPicker); } }, { key: "onAfterGenerateColorPicker", value: function onAfterGenerateColorPicker(ignore, extra, callback, color) { jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_9__.Dom.detach(extra); var ci = new _ui_input_color_input__WEBPACK_IMPORTED_MODULE_7__.ColorInput(this.j, { value: color || '#000', onChange: callback }); extra.appendChild(ci.container); } }, { key: "beforeDestruct", value: /** @override */ function beforeDestruct(jodit) { jodit.e.off('afterGenerateColorPicker', this.onAfterGenerateColorPicker); } } ]); return colorPicker; }((0,_swc_helpers_wrap_native_super__WEBPACK_IMPORTED_MODULE_5__._)(jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_10__.Plugin)); /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(colorPicker, "requires", [ 'license' ]); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_8__.autobind ], colorPicker.prototype, "onAfterGenerateColorPicker", null); jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_11__.JoditPro.plugins.add('color-picker', colorPicker); /***/ }), /***/ 45128: /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ColorInput: function() { return /* binding */ ColorInput; } /* harmony export */ }); /* harmony import */ var _swc_helpers_call_super__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80294); /* harmony import */ var _swc_helpers_class_call_check__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(20616); /* harmony import */ var _swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(67709); /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(82749); /* harmony import */ var _swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(18766); /* harmony import */ var _swc_helpers_instanceof__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2868); /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(31635); /* harmony import */ var a_color_picker__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(46146); /* harmony import */ var a_color_picker__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(a_color_picker__WEBPACK_IMPORTED_MODULE_7__); /* harmony import */ var jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(82758); /* harmony import */ var jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(65478); /* harmony import */ var jodit_esm_core_helpers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(21537); /* harmony import */ var jodit_esm_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(38837); /* harmony import */ var jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(67510); /* harmony import */ var jodit_esm_modules__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(41409); /*! * Jodit Editor PRO (https://xdsoft.net/jodit/) * See LICENSE.md in the project root for license information. * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/ */ var ColorInput = /*#__PURE__*/ function(UIInput) { "use strict"; (0,_swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__._)(ColorInput, UIInput); function ColorInput(jodit, options) { (0,_swc_helpers_class_call_check__WEBPACK_IMPORTED_MODULE_1__._)(this, ColorInput); var _this; _this = (0,_swc_helpers_call_super__WEBPACK_IMPORTED_MODULE_0__._)(this, ColorInput, [ jodit, options ]), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "trigger", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "popup", void 0); var popup = new jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_12__.Popup(jodit), parse = function parse(c) { return a_color_picker__WEBPACK_IMPORTED_MODULE_7__.parseColor(c, 'hex'); }; _this.popup = popup; _this.trigger = (0,jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_12__.Button)(_this.j, 'ok'); var wrapper = _this.getElm('wrapper'); (0,jodit_esm_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_11__.assert)(wrapper != null, 'wrapper element does not exist'); wrapper.appendChild(_this.trigger.container); _this.trigger.container.classList.add(_this.getFullElName('trigger')); _this.trigger.onAction(function() { var _this_state_onChange, _this_state; (_this_state_onChange = (_this_state = _this.state).onChange) === null || _this_state_onChange === void 0 ? void 0 : _this_state_onChange.call(_this_state, _this.value); popup.close(); }); popup.setMod('padding', false).setMod('max-height', false); var pickerElement = _this.j.create.div(_this.getFullElName('picker')); var picker = a_color_picker__WEBPACK_IMPORTED_MODULE_7__.createPicker(pickerElement, { paletteEditable: true, showAlpha: true, palette: 'PALETTE_MATERIAL_CHROME' }).on('change', function(picker, color) { if (!_this.isFocused) { _this.value = a_color_picker__WEBPACK_IMPORTED_MODULE_7__.parseColor(color || '', 'hex'); } }); _this.j.e.on(_this, 'change', function() { if (parse(_this.value) !== picker.color) { picker.color = _this.value; } }); popup.setContent(pickerElement); _this.j.e.on(_this.nativeInput, 'click', function() { popup.parentElement = _this; if ((0,_swc_helpers_instanceof__WEBPACK_IMPORTED_MODULE_5__._)(_this.jodit, jodit_esm_modules__WEBPACK_IMPORTED_MODULE_13__.Dialog)) { popup.setZIndex(_this.jodit.getZIndex() + 1); } popup.open(function() { return (0,jodit_esm_core_helpers__WEBPACK_IMPORTED_MODULE_10__.position)(_this.container); }); }); _this.onChangeValue(); _this.onChangeSelfValue(); return _this; } (0,_swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__._)(ColorInput, [ { key: "className", value: /** @override */ function className() { return 'ColorInput'; } }, { key: "afterSetMode", value: function afterSetMode(name, value) { if (name === 'slim' && value) { this.nativeInput.setAttribute('readonly', 'true'); } } }, { key: "onChangeSelfValue", value: function onChangeSelfValue() { this.nativeInput.style.backgroundColor = this.value; } }, { key: "onEscKeyDown", value: function onEscKeyDown(e) { if (e.key === jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_8__.KEY_ESC) { var _this_popup; (_this_popup = this.popup) === null || _this_popup === void 0 ? void 0 : _this_popup.close(); } } } ]); return ColorInput; }(jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_12__.UIInput); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':change') ], ColorInput.prototype, "onChangeSelfValue", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)('nativeInput:keydown') ], ColorInput.prototype, "onEscKeyDown", null); ColorInput = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_6__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_9__.component ], ColorInput); /***/ }), /***/ 46146: /***/ (function(module, exports, __webpack_require__) { /* module decorator */ module = __webpack_require__.nmd(module); var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return !!right[Symbol.hasInstance](left); } else { return left instanceof right; } } function _type_of(obj) { "@swc/helpers - typeof"; return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } /*! * a-color-picker (https://github.com/narsenico/a-color-picker) * * Copyright (c) 2017-2018, Gianfranco Caldi. * Released under the MIT License. */ !function(e1, t) { "object" == ( false ? 0 : _type_of(exports)) && "object" == ( false ? 0 : _type_of(module)) ? module.exports = t() : true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (t), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : 0; }("undefined" != typeof self ? self : this, function() { return function(e1) { var t = {}; function r(i) { if (t[i]) return t[i].exports; var o = t[i] = { i: i, l: !1, exports: {} }; return e1[i].call(o.exports, o, o.exports, r), o.l = !0, o.exports; } return r.m = e1, r.c = t, r.d = function(e1, t, i) { r.o(e1, t) || Object.defineProperty(e1, t, { enumerable: !0, get: i }); }, r.r = function(e1) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e1, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e1, "__esModule", { value: !0 }); }, r.t = function(e1, t) { if (1 & t && (e1 = r(e1)), 8 & t) return e1; if (4 & t && "object" == (typeof e1 === "undefined" ? "undefined" : _type_of(e1)) && e1 && e1.__esModule) return e1; var i = Object.create(null); if (r.r(i), Object.defineProperty(i, "default", { enumerable: !0, value: e1 }), 2 & t && "string" != typeof e1) for(var o in e1)r.d(i, o, (function(t) { return e1[t]; }).bind(null, o)); return i; }, r.n = function(e1) { var t = e1 && e1.__esModule ? function() { return e1.default; } : function() { return e1; }; return r.d(t, "a", t), t; }, r.o = function(e1, t) { return Object.prototype.hasOwnProperty.call(e1, t); }, r.p = "", r(r.s = 1); }([ function(e1, t, r) { "use strict"; /*! * is-plain-object <https://github.com/jonschlinkert/is-plain-object> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ var i = r(3); function o(e1) { return !0 === i(e1) && "[object Object]" === Object.prototype.toString.call(e1); } e1.exports = function(e1) { var t, _$r; return !1 !== o(e1) && "function" == typeof (t = e1.constructor) && !1 !== o(_$r = t.prototype) && !1 !== _$r.hasOwnProperty("isPrototypeOf"); }; }, function(e1, t, r) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.VERSION = t.PALETTE_MATERIAL_CHROME = t.PALETTE_MATERIAL_500 = t.COLOR_NAMES = t.getLuminance = t.intToRgb = t.rgbToInt = t.rgbToHsv = t.rgbToHsl = t.hslToRgb = t.rgbToHex = t.parseColor = t.parseColorToHsla = t.parseColorToHsl = t.parseColorToRgba = t.parseColorToRgb = t.from = t.createPicker = void 0; var i = function() { function e1(e1, t) { for(var _$r = 0; _$r < t.length; _$r++){ var i = t[_$r]; i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e1, i.key, i); } } return function(t, r, i) { return r && e1(t.prototype, r), i && e1(t, i), t; }; }(), o = function o(e1, t) { if (Array.isArray(e1)) return e1; if (Symbol.iterator in Object(e1)) return function(e1, t) { var _$r = [], i = !0, o = !1, n = void 0; try { for(var s, a = e1[Symbol.iterator](); !(i = (s = a.next()).done) && (_$r.push(s.value), !t || _$r.length !== t); i = !0); } catch (e1) { o = !0, n = e1; } finally{ try { !i && a.return && a.return(); } finally{ if (o) throw n; } } return _$r; }(e1, t); throw new TypeError("Invalid attempt to destructure non-iterable instance"); }, n = r(2), s = l(r(0)), a = l(r(4)); function l(e1) { return e1 && e1.__esModule ? e1 : { default: e1 }; } function c(e1, t) { if (!_instanceof(e1, t)) throw new TypeError("Cannot call a class as a function"); } function u(e1) { if (Array.isArray(e1)) { for(var _$t = 0, _$r = Array(e1.length); _$t < e1.length; _$t++)_$r[_$t] = e1[_$t]; return _$r; } return Array.from(e1); } /*! * a-color-picker * https://github.com/narsenico/a-color-picker * * Copyright (c) 2017-2019, Gianfranco Caldi. * Released under the MIT License. */ var h = "undefined" != typeof window && window.navigator.userAgent.indexOf("Edge") > -1, p = "undefined" != typeof window && window.navigator.userAgent.indexOf("rv:") > -1, d = { id: null, attachTo: "body", showHSL: !0, showRGB: !0, showHEX: !0, showAlpha: !1, color: "#ff0000", palette: null, paletteEditable: !1, useAlphaInPalette: "auto", slBarSize: [ 232, 150 ], hueBarSize: [ 150, 11 ], alphaBarSize: [ 150, 11 ] }, f = "COLOR", g = "RGBA_USER", b = "HSLA_USER"; function v(e1, t, r) { return e1 ? _instanceof(e1, HTMLElement) ? e1 : _instanceof(e1, NodeList) ? e1[0] : "string" == typeof e1 ? document.querySelector(e1) : e1.jquery ? e1.get(0) : r ? t : null : t; } function m(e1) { var _$t = e1.getContext("2d"), _$r = +e1.width, i = +e1.height, s = _$t.createLinearGradient(1, 1, 1, i - 1); return s.addColorStop(0, "white"), s.addColorStop(1, "black"), { setHue: function setHue(e1) { var o = _$t.createLinearGradient(1, 0, _$r - 1, 0); o.addColorStop(0, "hsla(" + e1 + ", 100%, 50%, 0)"), o.addColorStop(1, "hsla(" + e1 + ", 100%, 50%, 1)"), _$t.fillStyle = s, _$t.fillRect(0, 0, _$r, i), _$t.fillStyle = o, _$t.globalCompositeOperation = "multiply", _$t.fillRect(0, 0, _$r, i), _$t.globalCompositeOperation = "source-over"; }, grabColor: function grabColor(e1, r) { return _$t.getImageData(e1, r, 1, 1).data; }, findColor: function findColor(e1, t, s) { var a = (0, n.rgbToHsv)(e1, t, s), _$l = o(a, 3), c = _$l[1], u = _$l[2]; return [ c * _$r, i - u * i ]; } }; } function A(e1, t, r) { return null === e1 ? t : /^\s*$/.test(e1) ? r : !!/true|yes|1/i.test(e1) || !/false|no|0/i.test(e1) && t; } function y(e1, t, r) { if (null === e1) return t; if (/^\s*$/.test(e1)) return r; var i = e1.split(",").map(Number); return 2 === i.length && i[0] && i[1] ? i : t; } var k = function() { function e1(t, r) { if (c(this, e1), r ? (t = v(t), this.options = Object.assign({}, d, r)) : t && (0, s.default)(t) ? (this.options = Object.assign({}, d, t), t = v(this.options.attachTo)) : (this.options = Object.assign({}, d), t = v((0, n.nvl)(t, this.options.attachTo))), !t) throw new Error("Container not found: " + this.options.attachTo); !function(e1, t) { var _$r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "acp-"; if (t.hasAttribute(_$r + "show-hsl") && (e1.showHSL = A(t.getAttribute(_$r + "show-hsl"), d.showHSL, !0)), t.hasAttribute(_$r + "show-rgb") && (e1.showRGB = A(t.getAttribute(_$r + "show-rgb"), d.showRGB, !0)), t.hasAttribute(_$r + "show-hex") && (e1.showHEX = A(t.getAttribute(_$r + "show-hex"), d.showHEX, !0)), t.hasAttribute(_$r + "show-alpha") && (e1.showAlpha = A(t.getAttribute(_$r + "show-alpha"), d.showAlpha, !0)), t.hasAttribute(_$r + "palette-editable") && (e1.paletteEditable = A(t.getAttribute(_$r + "palette-editable"), d.paletteEditable, !0)), t.hasAttribute(_$r + "sl-bar-size") && (e1.slBarSize = y(t.getAttribute(_$r + "sl-bar-size"), d.slBarSize, [ 232, 150 ])), t.hasAttribute(_$r + "hue-bar-size") && (e1.hueBarSize = y(t.getAttribute(_$r + "hue-bar-size"), d.hueBarSize, [ 150, 11 ]), e1.alphaBarSize = e1.hueBarSize), t.hasAttribute(_$r + "palette")) { var i = t.getAttribute(_$r + "palette"); switch(i){ case "PALETTE_MATERIAL_500": e1.palette = n.PALETTE_MATERIAL_500; break; case "PALETTE_MATERIAL_CHROME": case "": e1.palette = n.PALETTE_MATERIAL_CHROME; break; default: e1.palette = i.split(/[;|]/); } } t.hasAttribute(_$r + "color") && (e1.color = t.getAttribute(_$r + "color")); }(this.options, t), this.H = 0, this.S = 0, this.L = 0, this.R = 0, this.G = 0, this.B = 0, this.A = 1, this.palette = {}, this.element = document.createElement("div"), this.options.id && (this.element.id = this.options.id), this.element.className = "a-color-picker", this.element.innerHTML = a.default, t.appendChild(this.element); var i = this.element.querySelector(".a-color-picker-h"); this.setupHueCanvas(i), this.hueBarHelper = m(i), this.huePointer = this.element.querySelector(".a-color-picker-h+.a-color-picker-dot"); var o = this.element.querySelector(".a-color-picker-sl"); this.setupSlCanvas(o), this.slBarHelper = m(o), this.slPointer = this.element.querySelector(".a-color-picker-sl+.a-color-picker-dot"), this.preview = this.element.querySelector(".a-color-picker-preview"), this.setupClipboard(this.preview.querySelector(".a-color-picker-clipbaord")), this.options.showHSL ? (this.setupInput(this.inputH = this.element.querySelector(".a-color-picker-hsl>input[nameref=H]")), this.setupInput(this.inputS = this.element.querySelector(".a-color-picker-hsl>input[nameref=S]")), this.setupInput(this.inputL = this.element.querySelector(".a-color-picker-hsl>input[nameref=L]"))) : this.element.querySelector(".a-color-picker-hsl").remove(), this.options.showRGB ? (this.setupInput(this.inputR = this.element.querySelector(".a-color-picker-rgb>input[nameref=R]")), this.setupInput(this.inputG = this.element.querySelector(".a-color-picker-rgb>input[nameref=G]")), this.setupInput(this.inputB = this.element.querySelector(".a-color-picker-rgb>input[nameref=B]"))) : this.element.querySelector(".a-color-picker-rgb").remove(), this.options.showHEX ? this.setupInput(this.inputRGBHEX = this.element.querySelector("input[nameref=RGBHEX]")) : this.element.querySelector(".a-color-picker-rgbhex").remove(), this.options.paletteEditable || this.options.palette && this.options.palette.length > 0 ? this.setPalette(this.paletteRow = this.element.querySelector(".a-color-picker-palette")) : (this.paletteRow = this.element.querySelector(".a-color-picker-palette"), this.paletteRow.remove()), this.options.showAlpha ? (this.setupAlphaCanvas(this.element.querySelector(".a-color-picker-a")), this.alphaPointer = this.element.querySelector(".a-color-picker-a+.a-color-picker-dot")) : this.element.querySelector(".a-color-picker-alpha").remove(), this.element.style.width = this.options.slBarSize[0] + "px", this.onValueChanged(f, this.options.color); } return i(e1, [ { key: "setupHueCanvas", value: function value(e1) { var _$t = this; e1.width = this.options.hueBarSize[0], e1.height = this.options.hueBarSize[1]; for(var _$r = e1.getContext("2d"), i = _$r.createLinearGradient(0, 0, this.options.hueBarSize[0], 0), o = 0; o <= 1; o += 1 / 360)i.addColorStop(o, "hsl(" + 360 * o + ", 100%, 50%)"); _$r.fillStyle = i, _$r.fillRect(0, 0, this.options.hueBarSize[0], this.options.hueBarSize[1]); var s = function s(r) { var i = (0, n.limit)(r.clientX - e1.getBoundingClientRect().left, 0, _$t.options.hueBarSize[0]), o = Math.round(360 * i / _$t.options.hueBarSize[0]); _$t.huePointer.style.left = i - 7 + "px", _$t.onValueChanged("H", o); }, a = function e1() { document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", e1); }; e1.addEventListener("mousedown", function(e1) { s(e1), document.addEventListener("mousemove", s), document.addEventListener("mouseup", a); }); } }, { key: "setupSlCanvas", value: function value(e1) { var _$t = this; e1.width = this.options.slBarSize[0], e1.height = this.options.slBarSize[1]; var _$r = function r(r) { var i = (0, n.limit)(r.clientX - e1.getBoundingClientRect().left, 0, _$t.options.slBarSize[0] - 1), o = (0, n.limit)(r.clientY - e1.getBoundingClientRect().top, 0, _$t.options.slBarSize[1] - 1), s = _$t.slBarHelper.grabColor(i, o); _$t.slPointer.style.left = i - 7 + "px", _$t.slPointer.style.top = o - 7 + "px", _$t.onValueChanged("RGB", s); }, i = function e1() { document.removeEventListener("mousemove", _$r), document.removeEventListener("mouseup", e1); }; e1.addEventListener("mousedown", function(e1) { _$r(e1), document.addEventListener("mousemove", _$r), document.addEventListener("mouseup", i); }); } }, { key: "setupAlphaCanvas", value: function value(e1) { var _$t = this; e1.width = this.options.alphaBarSize[0], e1.height = this.options.alphaBarSize[1]; var _$r = e1.getContext("2d"), i = _$r.createLinearGradient(0, 0, e1.width - 1, 0); i.addColorStop(0, "hsla(0, 0%, 50%, 0)"), i.addColorStop(1, "hsla(0, 0%, 50%, 1)"), _$r.fillStyle = i, _$r.fillRect(0, 0, this.options.alphaBarSize[0], this.options.alphaBarSize[1]); var o = function o(r) { var i = (0, n.limit)(r.clientX - e1.getBoundingClientRect().left, 0, _$t.options.alphaBarSize[0]), o = +(i / _$t.options.alphaBarSize[0]).toFixed(2); _$t.alphaPointer.style.left = i - 7 + "px", _$t.onValueChanged("ALPHA", o); }, s = function e1() { document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", e1); }; e1.addEventListener("mousedown", function(e1) { o(e1), document.addEventListener("mousemove", o), document.addEventListener("mouseup", s); }); } }, { key: "setupInput", value: function value(e1) { var _$t = this, _$r = +e1.min, i = +e1.max, o = e1.getAttribute("nameref"); e1.hasAttribute("select-on-focus") && e1.addEventListener("focus", function() { e1.select(); }), "text" === e1.type ? e1.addEventListener("change", function() { _$t.onValueChanged(o, e1.value); }) : ((h || p) && e1.addEventListener("keydown", function(s) { "Up" === s.key ? (e1.value = (0, n.limit)(+e1.value + 1, _$r, i), _$t.onValueChanged(o, e1.value), s.returnValue = !1) : "Down" === s.key && (e1.value = (0, n.limit)(+e1.value - 1, _$r, i), _$t.onValueChanged(o, e1.value), s.returnValue = !1); }), e1.addEventListener("change", function() { var s = +e1.value; _$t.onValueChanged(o, (0, n.limit)(s, _$r, i)); })); } }, { key: "setupClipboard", value: function value(e1) { var _$t = this; e1.title = "click to copy", e1.addEventListener("click", function() { e1.value = (0, n.parseColor)([ _$t.R, _$t.G, _$t.B, _$t.A ], "hexcss4"), e1.select(), document.execCommand("copy"); }); } }, { key: "setPalette", value: function value(e1) { var _$t = this, _$r = "auto" === this.options.useAlphaInPalette ? this.options.showAlpha : this.options.useAlphaInPalette, i = null; switch(this.options.palette){ case "PALETTE_MATERIAL_500": i = n.PALETTE_MATERIAL_500; break; case "PALETTE_MATERIAL_CHROME": i = n.PALETTE_MATERIAL_CHROME; break; default: i = (0, n.ensureArray)(this.options.palette); } if (this.options.paletteEditable || i.length > 0) { var o = function o(r, i, o) { var n = e1.querySelector('.a-color-picker-palette-color[data-color="' + r + '"]') || document.createElement("div"); n.className = "a-color-picker-palette-color", n.style.backgroundColor = r, n.setAttribute("data-color", r), n.title = r, e1.insertBefore(n, i), _$t.palette[r] = !0, o && _$t.onPaletteColorAdd(r); }, s = function s(r, i) { r ? (e1.removeChild(r), _$t.palette[r.getAttribute("data-color")] = !1, i && _$t.onPaletteColorRemove(r.getAttribute("data-color"))) : (e1.querySelectorAll(".a-color-picker-palette-color[data-color]").forEach(function(t) { e1.removeChild(t); }), Object.keys(_$t.palette).forEach(function(e1) { _$t.palette[e1] = !1; }), i && _$t.onPaletteColorRemove()); }; if (i.map(function(e1) { return (0, n.parseColor)(e1, _$r ? "rgbcss4" : "hex"); }).filter(function(e1) { return !!e1; }).forEach(function(e1) { return o(e1); }), this.options.paletteEditable) { var a = document.createElement("div"); a.className = "a-color-picker-palette-color a-color-picker-palette-add", a.innerHTML = "+", e1.appendChild(a), e1.addEventListener("click", function(e1) { /a-color-picker-palette-add/.test(e1.target.className) ? e1.shiftKey ? s(null, !0) : o(_$r ? (0, n.parseColor)([ _$t.R, _$t.G, _$t.B, _$t.A ], "rgbcss4") : (0, n.rgbToHex)(_$t.R, _$t.G, _$t.B), e1.target, !0) : /a-color-picker-palette-color/.test(e1.target.className) && (e1.shiftKey ? s(e1.target, !0) : _$t.onValueChanged(f, e1.target.getAttribute("data-color"))); }); } else e1.addEventListener("click", function(e1) { /a-color-picker-palette-color/.test(e1.target.className) && _$t.onValueChanged(f, e1.target.getAttribute("data-color")); }); } else e1.style.display = "none"; } }, { key: "updatePalette", value: function value(e1) { this.paletteRow.innerHTML = "", this.palette = {}, this.paletteRow.parentElement || this.element.appendChild(this.paletteRow), this.options.palette = e1, this.setPalette(this.paletteRow); } }, { key: "onValueChanged", value: function value(e1, t) { var _$r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : { silent: !1 }; switch(e1){ case "H": this.H = t; var i = (0, n.hslToRgb)(this.H, this.S, this.L), s = o(i, 3); this.R = s[0], this.G = s[1], this.B = s[2], this.slBarHelper.setHue(t), this.updatePointerH(this.H), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B), this.updateInputRGBHEX(this.R, this.G, this.B); break; case "S": this.S = t; var a = (0, n.hslToRgb)(this.H, this.S, this.L), _$l = o(a, 3); this.R = _$l[0], this.G = _$l[1], this.B = _$l[2], this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B), this.updateInputRGBHEX(this.R, this.G, this.B); break; case "L": this.L = t; var c = (0, n.hslToRgb)(this.H, this.S, this.L), u = o(c, 3); this.R = u[0], this.G = u[1], this.B = u[2], this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B), this.updateInputRGBHEX(this.R, this.G, this.B); break; case "R": this.R = t; var h = (0, n.rgbToHsl)(this.R, this.G, this.B), p = o(h, 3); this.H = p[0], this.S = p[1], this.L = p[2], this.slBarHelper.setHue(this.H), this.updatePointerH(this.H), this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGBHEX(this.R, this.G, this.B); break; case "G": this.G = t; var d = (0, n.rgbToHsl)(this.R, this.G, this.B), v = o(d, 3); this.H = v[0], this.S = v[1], this.L = v[2], this.slBarHelper.setHue(this.H), this.updatePointerH(this.H), this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGBHEX(this.R, this.G, this.B); break; case "B": this.B = t; var m = (0, n.rgbToHsl)(this.R, this.G, this.B), A = o(m, 3); this.H = A[0], this.S = A[1], this.L = A[2], this.slBarHelper.setHue(this.H), this.updatePointerH(this.H), this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGBHEX(this.R, this.G, this.B); break; case "RGB": var y = o(t, 3); this.R = y[0], this.G = y[1], this.B = y[2]; var k = (0, n.rgbToHsl)(this.R, this.G, this.B), F = o(k, 3); this.H = F[0], this.S = F[1], this.L = F[2], this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B), this.updateInputRGBHEX(this.R, this.G, this.B); break; case g: var _$E = o(t, 4); this.R = _$E[0], this.G = _$E[1], this.B = _$E[2], this.A = _$E[3]; var H = (0, n.rgbToHsl)(this.R, this.G, this.B), B = o(H, 3); this.H = B[0], this.S = B[1], this.L = B[2], this.slBarHelper.setHue(this.H), this.updatePointerH(this.H), this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B), this.updateInputRGBHEX(this.R, this.G, this.B), this.updatePointerA(this.A); break; case b: var R = o(t, 4); this.H = R[0], this.S = R[1], this.L = R[2], this.A = R[3]; var C = (0, n.hslToRgb)(this.H, this.S, this.L), S = o(C, 3); this.R = S[0], this.G = S[1], this.B = S[2], this.slBarHelper.setHue(this.H), this.updatePointerH(this.H), this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B), this.updateInputRGBHEX(this.R, this.G, this.B), this.updatePointerA(this.A); break; case "RGBHEX": var L = (0, n.cssColorToRgb)(t) || [ this.R, this.G, this.B ], w = o(L, 3); this.R = w[0], this.G = w[1], this.B = w[2]; var T = (0, n.rgbToHsl)(this.R, this.G, this.B), x = o(T, 3); this.H = x[0], this.S = x[1], this.L = x[2], this.slBarHelper.setHue(this.H), this.updatePointerH(this.H), this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B); break; case f: var G = (0, n.parseColor)(t, "rgba") || [ 0, 0, 0, 1 ], I = o(G, 4); this.R = I[0], this.G = I[1], this.B = I[2], this.A = I[3]; var P = (0, n.rgbToHsl)(this.R, this.G, this.B), D = o(P, 3); this.H = D[0], this.S = D[1], this.L = D[2], this.slBarHelper.setHue(this.H), this.updatePointerH(this.H), this.updatePointerSL(this.H, this.S, this.L), this.updateInputHSL(this.H, this.S, this.L), this.updateInputRGB(this.R, this.G, this.B), this.updateInputRGBHEX(this.R, this.G, this.B), this.updatePointerA(this.A); break; case "ALPHA": this.A = t; } 1 === this.A ? this.preview.style.backgroundColor = "rgb(" + this.R + "," + this.G + "," + this.B + ")" : this.preview.style.backgroundColor = "rgba(" + this.R + "," + this.G + "," + this.B + "," + this.A + ")", _$r && _$r.silent || this.onchange && this.onchange(this.preview.style.backgroundColor); } }, { key: "onPaletteColorAdd", value: function value(e1) { this.oncoloradd && this.oncoloradd(e1); } }, { key: "onPaletteColorRemove", value: function value(e1) { this.oncolorremove && this.oncolorremove(e1); } }, { key: "updateInputHSL", value: function value(e1, t, r) { this.options.showHSL && (this.inputH.value = e1, this.inputS.value = t, this.inputL.value = r); } }, { key: "updateInputRGB", value: function value(e1, t, r) { this.options.showRGB && (this.inputR.value = e1, this.inputG.value = t, this.inputB.value = r); } }, { key: "updateInputRGBHEX", value: function value(e1, t, r) { this.options.showHEX && (this.inputRGBHEX.value = (0, n.rgbToHex)(e1, t, r)); } }, { key: "updatePointerH", value: function value(e1) { var _$t = this.options.hueBarSize[0] * e1 / 360; this.huePointer.style.left = _$t - 7 + "px"; } }, { key: "updatePointerSL", value: function value(e1, t, r) { var i = (0, n.hslToRgb)(e1, t, r), s = o(i, 3), a = s[0], _$l = s[1], c = s[2], u = this.slBarHelper.findColor(a, _$l, c), h = o(u, 2), p = h[0], d = h[1]; p >= 0 && (this.slPointer.style.left = p - 7 + "px", this.slPointer.style.top = d - 7 + "px"); } }, { key: "updatePointerA", value: function value(e1) { if (this.options.showAlpha) { var _$t = this.options.alphaBarSize[0] * e1; this.alphaPointer.style.left = _$t - 7 + "px"; } } } ]), e1; }(), F = function() { function e1(t) { c(this, e1), this.name = t, this.listeners = []; } return i(e1, [ { key: "on", value: function value(e1) { e1 && this.listeners.push(e1); } }, { key: "off", value: function value(e1) { this.listeners = e1 ? this.listeners.filter(function(t) { return t !== e1; }) : []; } }, { key: "emit", value: function value(e1, t) { for(var _$r = this.listeners.slice(0), i = 0; i < _$r.length; i++)_$r[i].apply(t, e1); } } ]), e1; }(); function E(e1, t) { var _$r = new k(e1, t), i = { change: new F("change"), coloradd: new F("coloradd"), colorremove: new F("colorremove") }, s = !0, a = {}, _$l = { get element () { return _$r.element; }, get rgb () { return [ _$r.R, _$r.G, _$r.B ]; }, set rgb (e){ var _$t = o(e, 3), i1 = _$t[0], s1 = _$t[1], a1 = _$t[2], _$l1 = [ (0, n.limit)(i1, 0, 255), (0, n.limit)(s1, 0, 255), (0, n.limit)(a1, 0, 255) ]; i1 = _$l1[0], s1 = _$l1[1], a1 = _$l1[2], _$r.onValueChanged(g, [ i1, s1, a1, 1 ]); }, get hsl () { return [ _$r.H, _$r.S, _$r.L ]; }, set hsl (e){ var _$t1 = o(e, 3), i2 = _$t1[0], s2 = _$t1[1], a2 = _$t1[2], _$l2 = [ (0, n.limit)(i2, 0, 360), (0, n.limit)(s2, 0, 100), (0, n.limit)(a2, 0, 100) ]; i2 = _$l2[0], s2 = _$l2[1], a2 = _$l2[2], _$r.onValueChanged(b, [ i2, s2, a2, 1 ]); }, get rgbhex () { return this.all.hex; }, get rgba () { return [ _$r.R, _$r.G,