UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

872 lines (845 loc) 80.9 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],{ /***/ 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_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82749); /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31635); /* harmony import */ var _ui_input_color_input__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(45128); /* harmony import */ var jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(65478); /* harmony import */ var jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2748); /* harmony import */ var jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(50911); /* harmony import */ var jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_6__ = __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/ */ class colorPicker extends jodit_esm_core_plugin__WEBPACK_IMPORTED_MODULE_5__.Plugin { /** @override */ afterInit(jodit) { jodit.e.on('afterGenerateColorPicker', this.onAfterGenerateColorPicker); } onAfterGenerateColorPicker(ignore, extra, callback, color) { jodit_esm_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.detach(extra); const ci = new _ui_input_color_input__WEBPACK_IMPORTED_MODULE_2__.ColorInput(this.j, { value: color || '#000', onChange: callback }); extra.appendChild(ci.container); } /** @override */ beforeDestruct(jodit) { jodit.e.off('afterGenerateColorPicker', this.onAfterGenerateColorPicker); } constructor(...args){ super(...args), /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "hasStyle", !jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_6__.JoditPro.fatMode); } } /** @override */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(colorPicker, "requires", [ 'license' ]); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_3__.autobind ], colorPicker.prototype, "onAfterGenerateColorPicker", null); jodit_pro_jodit_pro__WEBPACK_IMPORTED_MODULE_6__.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_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82749); /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31635); /* harmony import */ var a_color_picker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(46146); /* harmony import */ var a_color_picker__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(a_color_picker__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(82758); /* harmony import */ var jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65478); /* harmony import */ var jodit_esm_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(21537); /* harmony import */ var jodit_esm_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(38837); /* harmony import */ var jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(67510); /* harmony import */ var jodit_esm_modules__WEBPACK_IMPORTED_MODULE_8__ = __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/ */ class ColorInput extends jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_7__.UIInput { /** @override */ className() { return 'ColorInput'; } afterSetMode(name, value) { if (name === 'slim' && value) { this.nativeInput.setAttribute('readonly', 'true'); } } onChangeSelfValue() { this.nativeInput.style.backgroundColor = this.value; } onEscKeyDown(e) { if (e.key === jodit_esm_core_constants__WEBPACK_IMPORTED_MODULE_3__.KEY_ESC) { var _this_popup; (_this_popup = this.popup) === null || _this_popup === void 0 ? void 0 : _this_popup.close(); } } /** @override */ constructor(jodit, options){ super(jodit, options), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "trigger", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "popup", void 0); const popup = new jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_7__.Popup(jodit), parse = (c)=>a_color_picker__WEBPACK_IMPORTED_MODULE_2__.parseColor(c, 'hex'); this.popup = popup; this.trigger = (0,jodit_esm_core_ui__WEBPACK_IMPORTED_MODULE_7__.Button)(this.j, 'ok'); const wrapper = this.getElm('wrapper'); (0,jodit_esm_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_6__.assert)(wrapper != null, 'wrapper element does not exist'); wrapper.appendChild(this.trigger.container); this.trigger.container.classList.add(this.getFullElName('trigger')); this.trigger.onAction(()=>{ 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); const pickerElement = this.j.create.div(this.getFullElName('picker')); const picker = a_color_picker__WEBPACK_IMPORTED_MODULE_2__.createPicker(pickerElement, { paletteEditable: true, showAlpha: true, palette: 'PALETTE_MATERIAL_CHROME' }).on('change', (picker, color)=>{ if (!this.isFocused) { this.value = a_color_picker__WEBPACK_IMPORTED_MODULE_2__.parseColor(color || '', 'hex'); } }); this.j.e.on(this, 'change', ()=>{ if (parse(this.value) !== picker.color) { picker.color = this.value; } }); popup.setContent(pickerElement); this.j.e.on(this.nativeInput, 'click', ()=>{ popup.parentElement = this; if (this.jodit instanceof jodit_esm_modules__WEBPACK_IMPORTED_MODULE_8__.Dialog) { popup.setZIndex(this.jodit.getZIndex() + 1); } popup.open(()=>(0,jodit_esm_core_helpers__WEBPACK_IMPORTED_MODULE_5__.position)(this.container)); }); this.onChangeValue(); this.onChangeSelfValue(); } } (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)(':change') ], ColorInput.prototype, "onChangeSelfValue", null); (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([ (0,jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.watch)('nativeInput:keydown') ], ColorInput.prototype, "onEscKeyDown", null); ColorInput = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([ jodit_esm_core_decorators__WEBPACK_IMPORTED_MODULE_4__.component ], ColorInput); /***/ }), /***/ 46146: /***/ (function(module) { /*! * a-color-picker (https://github.com/narsenico/a-color-picker) * * Copyright (c) 2017-2018, Gianfranco Caldi. * Released under the MIT License. */ !function(e1, t) { true ? module.exports = t() : 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 && 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(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 (!(e1 instanceof 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 ? e1 instanceof HTMLElement ? e1 : e1 instanceof 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(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(e1, r) { return t.getImageData(e1, r, 1, 1).data; }, findColor: function(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(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(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(e1) { var t = this; e1.width = this.options.slBarSize[0], e1.height = this.options.slBarSize[1]; var r = function(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(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(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(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(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(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(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(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(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(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(e1) { this.oncoloradd && this.oncoloradd(e1); } }, { key: "onPaletteColorRemove", value: function(e1) { this.oncolorremove && this.oncolorremove(e1); } }, { key: "updateInputHSL", value: function(e1, t, r) { this.options.showHSL && (this.inputH.value = e1, this.inputS.value = t, this.inputL.value = r); } }, { key: "updateInputRGB", value: function(e1, t, r) { this.options.showRGB && (this.inputR.value = e1, this.inputG.value = t, this.inputB.value = r); } }, { key: "updateInputRGBHEX", value: function(e1, t, r) { this.options.showHEX && (this.inputRGBHEX.value = (0, n.rgbToHex)(e1, t, r)); } }, { key: "updatePointerH", value: function(e1) { var t = this.options.hueBarSize[0] * e1 / 360; this.huePointer.style.left = t - 7 + "px"; } }, { key: "updatePointerSL", value: function(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(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(e1) { e1 && this.listeners.push(e1); } }, { key: "off", value: function(e1) { this.listeners = e1 ? this.listeners.filter(function(t) { return t !== e1; }) : []; } }, { key: "emit", value: function(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 t1 = o(e, 3), i1 = t1[0], s1 = t1[1], a1 = t1[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 t2 = o(e, 3), i2 = t2[0], s2 = t2[1], a2 = t2[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, r.B, r.A ]; }, set rgba (e){ var t3 = o(e, 4), i3 = t3[0], s3 = t3[1], a3 = t3[2], l3 = t3[3], c = [ (0, n.limit)(i3, 0, 255), (0, n.limit)(s3, 0, 255), (0, n.limit)(a3, 0, 255), (0, n.limit)(l3, 0, 1) ]; i3 = c[0], s3 = c[1], a3 = c[2], l3 = c[3], r.onValueChanged(g, [ i3, s3, a3, l3 ]); }, get hsla () { return [ r.H, r.S, r.L, r.A ]; }, set hsla (e){ var t4 = o(e, 4), i4 = t4[0], s4 = t4[1], a4 = t4[2], l4 = t4[3], c1 = [ (0, n.limit)(i4, 0, 360), (0, n.limit)(s4, 0, 100), (0, n.limit)(a4, 0, 100), (0, n.limit)(l4, 0, 1) ]; i4 = c1[0], s4 = c1[1], a4 = c1[2], l4 = c1[3], r.onValueChanged(b, [ i4, s4, a4, l4 ]); }, get color () { return this.all.toString(); }, set color (e){ r.onValueChanged(f, e); }, setColor: function(e1) { var t = arguments.length > 1 && void 0 !== arguments[1] && arguments[1]; r.onValueChanged(f, e1, { silent: t }); }, get all () { if (s) { var e2 = [ r.R, r.G, r.B, r.A ], t5 = r.A < 1 ? "rgba(" + r.R + "," + r.G + "," + r.B + "," + r.A + ")" : n.rgbToHex.apply(void 0, e2); (a = (0, n.parseColor)(e2, a)).toString = function() { return t5; }, s = !1; } return Object.assign({}, a); }, get onchange () { return i.change && i.change.listeners[0]; }, set onchange (e){ this.off("change").on("change", e); }, get oncoloradd () { return i.coloradd && i.coloradd.listeners[0]; }, set oncoloradd (e){ this.off("coloradd").on("coloradd", e); }, get oncolorremove () { return i.colorremove && i.colorremove.listeners[0]; }, set oncolorremove (e){ this.off("colorremove").on("colorremove", e); }, get palette () { return Object.keys(r.palette).filter(function(e1) { return r.palette[e1]; }); }, set palette (e){ r.updatePalette(e); }, show: function() { r.element.classList.remove("hidden"); }, hide: function() { r.element.classList.add("hidden"); }, toggle: function() { r.element.classList.toggle("hidden"); }, on: function(e1, t) { return e1 && i[e1] && i[e1].on(t), this; }, off: function(e1, t) { return e1 && i[e1] && i[e1].off(t), this; }, destroy: function() { i.change.off(), i.coloradd.off(), i.colorremove.off(), r.element.remove(), i = null, r = null; } }; return r.onchange = function() { for(var e1 = arguments.length, t = Array(e1), r = 0; r < e1; r++)t[r] = arguments[r]; s = !0, i.change.emit([ l ].concat(t), l); }, r.oncoloradd = function() { for(var e1 = arguments.length, t = Array(e1), r = 0; r < e1; r++)t[r] = arguments[r]; i.coloradd.emit([ l ].concat(t), l); }, r.oncolorremove = function() { for(var e1 = arguments.length, t = Array(e1), r = 0; r < e1; r++)t[r] = arguments[r];