jodit-pro
Version:
PRO Version of Jodit Editor
2 lines (1 loc) • 2.27 kB
JavaScript
var m=Object.defineProperty;var u=(a,e)=>m(a,"name",{value:e,configurable:!0});var l,f=function(a,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,o);else for(var s=a.length-1;s>=0;s--)(n=a[s])&&(i=(r<3?n(i):r>3?n(e,t,i):n(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i};import*as d from"a-color-picker";import{KEY_ESC as v}from"jodit/esm/core/constants.js";import{component as C,watch as g}from"jodit/esm/core/decorators/index.js";import{position as E}from"jodit/esm/core/helpers/index.js";import{assert as I}from"jodit/esm/core/helpers/utils/assert.js";import{Button as w,Popup as _,UIInput as j}from"jodit/esm/core/ui/index.js";import{Dialog as x}from"jodit/esm/modules/index.js";let c=(l=class extends j{className(){return"ColorInput"}constructor(e,t){super(e,t);const o=new _(e),r=u(p=>d.parseColor(p,"hex"),"parse");this.popup=o,this.trigger=w(this.j,"ok");const i=this.getElm("wrapper");I(i!=null,"wrapper element does not exist"),i.appendChild(this.trigger.container),this.trigger.container.classList.add(this.getFullElName("trigger")),this.trigger.onAction(()=>{var p,h;(h=(p=this.state).onChange)===null||h===void 0||h.call(p,this.value),o.close()}),o.setMod("padding",!1).setMod("max-height",!1);const n=this.j.create.div(this.getFullElName("picker")),s=d.createPicker(n,{paletteEditable:!0,showAlpha:!0,palette:"PALETTE_MATERIAL_CHROME"}).on("change",(p,h)=>{this.isFocused||(this.value=d.parseColor(h||"","hex"))});this.j.e.on(this,"change",()=>{r(this.value)!==s.color&&(s.color=this.value)}),o.setContent(n),this.j.e.on(this.nativeInput,"click",()=>{o.parentElement=this,this.jodit instanceof x&&o.setZIndex(this.jodit.getZIndex()+1),o.open(()=>E(this.container))}),this.onChangeValue(),this.onChangeSelfValue()}afterSetMode(e,t){e==="slim"&&t&&this.nativeInput.setAttribute("readonly","true")}onChangeSelfValue(){this.nativeInput.style.backgroundColor=this.value}onEscKeyDown(e){var t;e.key===v&&((t=this.popup)===null||t===void 0||t.close())}},u(l,"ColorInput"),l);f([g(":change")],c.prototype,"onChangeSelfValue",null),f([g("nativeInput:keydown")],c.prototype,"onEscKeyDown",null),c=f([C],c);export{c as ColorInput};