jodit-pro
Version:
PRO Version of Jodit Editor
8 lines • 8.44 kB
JavaScript
/*!
* 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(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[736],{6183:function(t,e,o){"use strict";o.d(e,{UIBackupList:function(){return h}});var i=o(82749),s=o(31635),n=o(38512),a=o(82758),r=o(65478),c=o(21537),l=o(67510);class h extends l.UIGroup{className(){return"UIBackupList"}createContainer(t){let e=super.createContainer(t);return(0,c.attr)(e,"tabIndex","-1"),e}build(t){this.clear(),t.forEach((t,e)=>{let o=new n.UIBackupItem(this.jodit,t);this.append(o),this.j.e.on(o.container,"focus",()=>this.onSelect(e)).on(o.container,"click",()=>this.onSelect(e)).on(o.container,"dblclick",()=>this.onChoose(e))}),this.currentSelection=0,this.onChangeCurrentSelection(void 0,-1,0)}onChangeCurrentSelection(t,e,o){this.elements[e]?.setMod("active",!1),this.elements[o]?.setMod("active",!0),this.elements[o]?.focus(),this.j.e.fire(this,"select",this.elements[o].data)}onSelect(t){this.currentSelection=t}onChoose(t){this.j.e.fire(this,"choose",this.elements[t??this.currentSelection].data)}selectNext(){this.currentSelection+1<=this.elements.length-1?this.currentSelection+=1:this.currentSelection=0}selectPrevious(){this.currentSelection-1>=0?this.currentSelection-=1:this.currentSelection=this.elements.length-1}constructor(t){super(t),(0,i._)(this,"elements",[]),(0,i._)(this,"currentSelection",-1),t.e.on(this.container,"keydown",t=>{switch(t.key){case a.KEY_ENTER:t.preventDefault(),t.stopPropagation(),this.onChoose(this.currentSelection);break;case a.KEY_DOWN:this.selectNext();break;case a.KEY_UP:this.selectPrevious()}})}}(0,s.__decorate)([(0,r.watch)("currentSelection")],h.prototype,"onChangeCurrentSelection",null),(0,s.__decorate)([r.autobind],h.prototype,"onSelect",null),(0,s.__decorate)([r.autobind],h.prototype,"onChoose",null),h=(0,s.__decorate)([r.component],h)},29243:function(t,e,o){"use strict";o.d(e,{DefaultStorage:function(){return s}});var i=o(82749);class s{async add(t){if(!t.html.trim().length)return!1;let e=this.jodit.storage.get(this.key)||[];return!e.find(e=>e.html===t.html)&&(e.unshift(t),e.length>this.jodit.o.backup.limit&&(e.length=this.jodit.o.backup.limit),this.jodit.storage.set(this.key,e),!1)}items(){return Promise.resolve(this.jodit.storage.get(this.key)||[])}clear(){return this.jodit.storage.delete(this.key),Promise.resolve(!1)}constructor(t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"key",void 0),this.jodit=t,this.key="backup.default.storage"}}},29402:function(t,e,o){"use strict";o.r(e)},38512:function(t,e,o){"use strict";o.d(e,{UIBackupItem:function(){return a}});var i=o(82749),s=o(21537),n=o(67510);class a extends n.UIElement{className(){return"UIBackupItem"}formatDate(t){let e=new Date,o=(0,s.isString)(t)?new Date(t):t,i=(e.getTime()-o.getTime())/1e3;return(0,s.isFunction)(this.j.o.backup.formatDate)?this.j.o.backup.formatDate(o):i<.2?this.j.i18n("Current"):i<60?this.j.i18n("Less minute"):i<=3600?this.j.i18n("%s minutes ago",Math.floor(i/60)):i<=86400?this.j.i18n("%s hours ago",Math.floor(i/3600)):`${o.toDateString()} ${o.toLocaleTimeString()}`}focus(){this.container.focus()}constructor(t,e){super(t),(0,i._)(this,"data",void 0),this.data=e,this.container.innerHTML=this.formatDate(e.created),(0,s.attr)(this.container,"tabIndex",0)}}},57056:function(t,e,o){"use strict";var i=o(68583),s=o.n(i),n=o(29402),a=o(6441),r=o(580),c=o(12153);a.Config.prototype.backup={interval:30,limit:50,dialogWidth:700,hotkeys:["ctrl+shift+b","cmd+shift+b"]},a.Config.prototype.controls.backup={store:{command:"saveBackup",text:"Save backup now"},restore:{tooltip:"Restore",list:["backup.store"],exec(t){t.execCommand("openBackupDialog")}}},c.Icon.set("restore",s()),(0,r.extendLang)(n)},61328:function(t,e,o){"use strict";o.r(e),o.d(e,{backup:function(){return u}});var i=o(82749),s=o(31635);o(57056);var n=o(29243),a=o(64262),r=o(65478),c=o(50911),l=o(67510),h=o(2692);class u extends c.Plugin{afterInit(t){t.registerCommand("saveBackup",this.onSaveBackup).registerCommand("openBackupDialog",{exec:this.onOpenBackupDialog,hotkeys:t.o.backup.hotkeys});let e=()=>{this.timeout=t.async.setTimeout(()=>{this.onSaveBackup(),e()},1e3*t.o.backup.interval)};e(),t.e.on(this.__box,"choose",this.onSelectItem).on(t.ow,"beforeunload.backup",()=>{this.onSaveBackup()})}prepareDialog(){this.__dialog||(this.__dialog=this.j.dlg({minWidth:this.j.o.backup.dialogWidth,buttons:["fullsize","dialog.close"]}).setContent(this.__box.container)),this.__dialog.setHeader(this.jodit.i18n("Restore")),this.addButtonsToDialog()}onSaveBackup(){this.__storage.add({created:new Date,html:this.j.value})}async onOpenBackupDialog(){this.prepareDialog();let{__dialog:t}=this;if(!t)return;t.open().setModal(!0);let e=await this.__storage.items();this.__box.build([{created:new Date,html:this.j.value},...e]),t.calcAutoSize(),t.setPosition()}onSelectItem(t){this.__dialog?.close(),this.j.value=t.html,this.j.s.focus()}addButtonsToDialog(){let{jodit:t}=this,e=(0,l.Button)(t,{name:"ok",tabIndex:0,variant:"primary",text:"Ok"}),o=(0,l.Button)(t,{variant:"secondary",tabIndex:0,text:"Cancel"}),i=(0,l.Button)(t,{name:"clear",tabIndex:0,variant:"secondary",text:"Remove all"});e.onAction(()=>{this.__box.chooseSelected()}),o.onAction(()=>{this.__dialog?.close()}),i.onAction(()=>{t.confirm("Are you sure?",void 0,t=>{t&&(this.__storage.clear(),this.__dialog?.close())})});let s=new l.UIBlock(t,[i,o,e]);s.container.style.margin="0",s.container.style.justifyContent="flex-end",s.container.style.width="100%",this.__dialog?.setFooter(s)}beforeDestruct(){let{j:t}=this;t.async.clearTimeout(this.timeout),t.e.off(this.__box,"choose",this.onSelectItem).off(t.ow,"beforeunload.backup"),this.__box.destruct(),this.__dialog?.destruct()}constructor(...t){super(...t),(0,i._)(this,"hasStyle",!h.JoditPro.fatMode),(0,i._)(this,"buttons",[{name:"backup.restore",group:"history"}]),(0,i._)(this,"__box",new a.UIBackupBox(this.j)),(0,i._)(this,"__dialog",null),(0,i._)(this,"__storage",this.jodit.o.backup.remoteStore??new n.DefaultStorage(this.jodit)),(0,i._)(this,"timeout",0)}}(0,i._)(u,"requires",["license"]),(0,s.__decorate)([r.autobind],u.prototype,"onSaveBackup",null),(0,s.__decorate)([r.autobind],u.prototype,"onOpenBackupDialog",null),(0,s.__decorate)([r.autobind],u.prototype,"onSelectItem",null),h.JoditPro.plugins.add("backup",u)},64262:function(t,e,o){"use strict";o.d(e,{UIBackupBox:function(){return c}});var i=o(82749),s=o(31635),n=o(6183),a=o(65478),r=o(48538);class c extends r.UIElement{className(){return"UIBackupBox"}build(t){this.preview.innerHTML="",this.list.build(t)}destruct(){return this.j.e.off(this.list,"select",this.onSelectItem),this.list.destruct(),super.destruct()}onSelectItem(t){this.latestSelected=t,this.preview.innerHTML=t.html||`<div class="${this.getFullElName("empty")}">${this.j.i18n("Empty")}</div>`}onChooseItem(t){this.j.e.fire(this,"choose",t)}chooseSelected(){this.onChooseItem(this.latestSelected)}constructor(t){super(t),(0,i._)(this,"list",new n.UIBackupList(this.j)),(0,i._)(this,"preview",this.j.c.div(this.getFullElName("preview"))),(0,i._)(this,"latestSelected",void 0),this.container.appendChild(this.list.container),this.container.appendChild(this.preview),this.list.container.classList.add(this.getFullElName("list")),t.e.on(this.list,"select",this.onSelectItem).on(this.list,"choose",this.onChooseItem)}}(0,s.__decorate)([a.autobind],c.prototype,"onSelectItem",null),(0,s.__decorate)([a.autobind],c.prototype,"onChooseItem",null),c=(0,s.__decorate)([a.component],c)},68583:function(t){t.exports='<?xml version="1.0" ?><svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"><title/><g id="Upload"><path d="M16,26h8V50a2,2,0,0,0,2,2H38a2,2,0,0,0,2-2V26h8a2,2,0,0,0,1.4946-3.3291l-16-18a2,2,0,0,0-2.9892,0l-16,18A2,2,0,0,0,16,26ZM32,9.0107,43.5464,22H38a2,2,0,0,0-2,2V48H28V24a2,2,0,0,0-2-2H20.4536Z"/><path d="M53,42a2,2,0,0,0-2,2V54a2.0023,2.0023,0,0,1-2,2H15a2.0023,2.0023,0,0,1-2-2V44a2,2,0,0,0-4,0V54a6.0066,6.0066,0,0,0,6,6H49a6.0066,6.0066,0,0,0,6-6V44A2,2,0,0,0,53,42Z"/></g></svg>'}},function(t){return t(t.s=61328)}])});