UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 2.52 kB
var y=Object.defineProperty;var h=(d,t)=>y(d,"name",{value:t,configurable:!0});var c=function(d,t,e,s){var r=arguments.length,i=r<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(d,t,e,s);else for(var n=d.length-1;n>=0;n--)(o=d[n])&&(i=(r<3?o(i):r>3?o(t,e,i):o(t,e))||i);return r>3&&i&&Object.defineProperty(t,e,i),i};import"./config.js";import{UIKeyboard as _}from"./ui/keyboard/keyboard.js";import{Config as b}from"jodit/esm/config.js";import{autobind as p}from"jodit/esm/core/decorators/index.js";import{isString as f}from"jodit/esm/core/helpers/checker/index.js";import{Plugin as g}from"jodit/esm/core/plugin/index.js";import{UISelect as v}from"jodit/esm/core/ui/index.js";import{Dialog as C}from"jodit/esm/modules/index.js";import{JoditPro as m}from"../../jodit-pro.js";const u=class u extends g{constructor(t){super(t),this.hasStyle=!m.fatMode,this.buttons=[{group:"insert",name:"keyboard"}];const{extraKeyButtons:e,extraKeyGroup:s}=t.o.keyboard;e.length&&e.forEach((r,i)=>{const o=f(r)?r:r.key,n=f(r)||!r.hotkeys?[`ctrl+${i+1}`]:r.hotkeys;t.registerButton({name:`extraKeyboardButtons.${o}`,group:s});const{extraKeyboardButtons:l}=b.defaultOptions.controls;l[o]={name:o,tooltip:o,args:[o],hotkeys:n,command:"insertChar"}})}afterInit(t){t.registerCommand("toggleKeyboard",this.toggleKeyboard).registerCommand("insertChar",this.insertChar),t.e.on("isKeyboardOpened",()=>{var e;return(e=this.__keyboard)===null||e===void 0?void 0:e.isOpened})}insertChar(t,e,s){this.j.s.insertNode(this.j.createInside.text(s))}toggleKeyboard(){if(!this.__keyboard){this.__keyboard=new C({toolbarButtonSize:"tiny"});const t=new _(this.j);this.__keyboard.setMod("slim",!0).setMod("adaptive",!1).setContent(t);const{showLayoutSwitcher:e,layoutSwitchList:s,layoutList:r}=this.j.o.keyboard;if(e){const i=new v(this.__keyboard,{value:t.state.currentLayout,options:s.map(o=>{var n,l;return{text:(l=(n=r[o])===null||n===void 0?void 0:n.title)!==null&&l!==void 0?l:o,value:o}}),onChange(o){t.state.currentLayout=o}});i.setMod("size","tiny").setMod("width","auto").setMod("variant","outline"),this.__keyboard.setHeader(i)}}this.__keyboard.isOpened?this.__keyboard.close():this.__keyboard.open()}beforeDestruct(t){var e;(e=this.__keyboard)===null||e===void 0||e.destruct()}};h(u,"keyboard");let a=u;a.requires=["license"],c([p],a.prototype,"insertChar",null),c([p],a.prototype,"toggleKeyboard",null),m.plugins.add("keyboard",a);export{a as keyboard};