jodit-pro
Version:
PRO Version of Jodit Editor
8 lines • 10.2 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 n=e();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[736],{6183:function(t,e,n){"use strict";n.d(e,{UIBackupList:function(){return _}});var o=n(80294),i=n(20616),a=n(67709),r=n(82749),s=n(54816),c=n(84669),u=n(18766),l=n(31635),h=n(38512),d=n(82758),f=n(65478),p=n(21537),_=function(t){function e(t){var n;return(0,i._)(this,e),n=(0,o._)(this,e,[t]),(0,r._)(n,"elements",[]),(0,r._)(n,"currentSelection",-1),t.e.on(n.container,"keydown",function(t){switch(t.key){case d.KEY_ENTER:t.preventDefault(),t.stopPropagation(),n.onChoose(n.currentSelection);break;case d.KEY_DOWN:n.selectNext();break;case d.KEY_UP:n.selectPrevious()}}),n}return(0,u._)(e,t),(0,a._)(e,[{key:"className",value:function(){return"UIBackupList"}},{key:"createContainer",value:function(t){var n=(0,s._)((0,c._)(e.prototype),"createContainer",this).call(this,t);return(0,p.attr)(n,"tabIndex","-1"),n}},{key:"build",value:function(t){var e=this;this.clear(),t.forEach(function(t,n){var o=new h.UIBackupItem(e.jodit,t);e.append(o),e.j.e.on(o.container,"focus",function(){return e.onSelect(n)}).on(o.container,"click",function(){return e.onSelect(n)}).on(o.container,"dblclick",function(){return e.onChoose(n)})}),this.currentSelection=0,this.onChangeCurrentSelection(void 0,-1,0)}},{key:"onChangeCurrentSelection",value:function(t,e,n){var o,i,a;null==(o=this.elements[e])||o.setMod("active",!1),null==(i=this.elements[n])||i.setMod("active",!0),null==(a=this.elements[n])||a.focus(),this.j.e.fire(this,"select",this.elements[n].data)}},{key:"onSelect",value:function(t){this.currentSelection=t}},{key:"onChoose",value:function(t){this.j.e.fire(this,"choose",this.elements[null!=t?t:this.currentSelection].data)}},{key:"selectNext",value:function(){this.currentSelection+1<=this.elements.length-1?this.currentSelection+=1:this.currentSelection=0}},{key:"selectPrevious",value:function(){this.currentSelection-1>=0?this.currentSelection-=1:this.currentSelection=this.elements.length-1}}]),e}(n(67510).UIGroup);(0,l.__decorate)([(0,f.watch)("currentSelection")],_.prototype,"onChangeCurrentSelection",null),(0,l.__decorate)([f.autobind],_.prototype,"onSelect",null),(0,l.__decorate)([f.autobind],_.prototype,"onChoose",null),_=(0,l.__decorate)([f.component],_)},29243:function(t,e,n){"use strict";n.d(e,{DefaultStorage:function(){return c}});var o=n(77688),i=n(20616),a=n(67709),r=n(82749),s=n(62361),c=function(){function t(e){(0,i._)(this,t),(0,r._)(this,"jodit",void 0),(0,r._)(this,"key",void 0),this.jodit=e,this.key="backup.default.storage"}return(0,a._)(t,[{key:"add",value:function(t){return(0,o._)(function(){var e;return(0,s._)(this,function(n){return!t.html.trim().length||(e=this.jodit.storage.get(this.key)||[]).find(function(e){return 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)),[2,!1]})}).call(this)}},{key:"items",value:function(){return Promise.resolve(this.jodit.storage.get(this.key)||[])}},{key:"clear",value:function(){return this.jodit.storage.delete(this.key),Promise.resolve(!1)}}]),t}()},29402:function(t,e,n){"use strict";n.r(e)},38512:function(t,e,n){"use strict";n.d(e,{UIBackupItem:function(){return u}});var o=n(80294),i=n(20616),a=n(67709),r=n(82749),s=n(18766),c=n(21537),u=function(t){function e(t,n){var a;return(0,i._)(this,e),a=(0,o._)(this,e,[t]),(0,r._)(a,"data",void 0),a.data=n,a.container.innerHTML=a.formatDate(n.created),(0,c.attr)(a.container,"tabIndex",0),a}return(0,s._)(e,t),(0,a._)(e,[{key:"className",value:function(){return"UIBackupItem"}},{key:"formatDate",value:function(t){var e=new Date,n=(0,c.isString)(t)?new Date(t):t,o=(e.getTime()-n.getTime())/1e3;return(0,c.isFunction)(this.j.o.backup.formatDate)?this.j.o.backup.formatDate(n):o<.2?this.j.i18n("Current"):o<60?this.j.i18n("Less minute"):o<=3600?this.j.i18n("%s minutes ago",Math.floor(o/60)):o<=86400?this.j.i18n("%s hours ago",Math.floor(o/3600)):"".concat(n.toDateString()," ").concat(n.toLocaleTimeString())}},{key:"focus",value:function(){this.container.focus()}}]),e}(n(67510).UIElement)},57056:function(t,e,n){"use strict";var o=n(68583),i=n.n(o),a=n(29402),r=n(6441),s=n(580),c=n(12153);r.Config.prototype.backup={interval:30,limit:50,dialogWidth:700,hotkeys:["ctrl+shift+b","cmd+shift+b"]},r.Config.prototype.controls.backup={store:{command:"saveBackup",text:"Save backup now"},restore:{tooltip:"Restore",list:["backup.store"],exec:function(t){t.execCommand("openBackupDialog")}}},c.Icon.set("restore",i()),(0,s.extendLang)(a)},61328:function(t,e,n){"use strict";n.r(e),n.d(e,{backup:function(){return g}});var o=n(77688),i=n(80294),a=n(20616),r=n(67709),s=n(82749),c=n(18766),u=n(94899),l=n(23078),h=n(31635),d=n(62361);n(57056);var f=n(29243),p=n(64262),_=n(65478),v=n(50911),k=n(67510),m=n(2692),g=function(t){function e(){var t,n;return(0,a._)(this,e),t=(0,i._)(this,e,arguments),(0,s._)(t,"hasStyle",!m.JoditPro.fatMode),(0,s._)(t,"buttons",[{name:"backup.restore",group:"history"}]),(0,s._)(t,"__box",new p.UIBackupBox(t.j)),(0,s._)(t,"__dialog",null),(0,s._)(t,"__storage",null!=(n=t.jodit.o.backup.remoteStore)?n:new f.DefaultStorage(t.jodit)),(0,s._)(t,"timeout",0),t}return(0,c._)(e,t),(0,r._)(e,[{key:"afterInit",value:function(t){var e=this;t.registerCommand("saveBackup",this.onSaveBackup).registerCommand("openBackupDialog",{exec:this.onOpenBackupDialog,hotkeys:t.o.backup.hotkeys});var n=function(){e.timeout=t.async.setTimeout(function(){e.onSaveBackup(),n()},1e3*t.o.backup.interval)};n(),t.e.on(this.__box,"choose",this.onSelectItem).on(t.ow,"beforeunload.backup",function(){e.onSaveBackup()})}},{key:"prepareDialog",value:function(){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()}},{key:"onSaveBackup",value:function(){this.__storage.add({created:new Date,html:this.j.value})}},{key:"onOpenBackupDialog",value:function(){return(0,o._)(function(){var t,e;return(0,d._)(this,function(n){switch(n.label){case 0:if(this.prepareDialog(),!(t=this.__dialog))return[2];return t.open().setModal(!0),[4,this.__storage.items()];case 1:return e=n.sent(),this.__box.build([{created:new Date,html:this.j.value}].concat((0,u._)(e))),t.calcAutoSize(),t.setPosition(),[2]}})}).call(this)}},{key:"onSelectItem",value:function(t){var e;null==(e=this.__dialog)||e.close(),this.j.value=t.html,this.j.s.focus()}},{key:"addButtonsToDialog",value:function(){var t,e=this,n=this.jodit,o=(0,k.Button)(n,{name:"ok",tabIndex:0,variant:"primary",text:"Ok"}),i=(0,k.Button)(n,{variant:"secondary",tabIndex:0,text:"Cancel"}),a=(0,k.Button)(n,{name:"clear",tabIndex:0,variant:"secondary",text:"Remove all"});o.onAction(function(){e.__box.chooseSelected()}),i.onAction(function(){var t;null==(t=e.__dialog)||t.close()}),a.onAction(function(){n.confirm("Are you sure?",void 0,function(t){if(t){var n;e.__storage.clear(),null==(n=e.__dialog)||n.close()}})});var r=new k.UIBlock(n,[a,i,o]);r.container.style.margin="0",r.container.style.justifyContent="flex-end",r.container.style.width="100%",null==(t=this.__dialog)||t.setFooter(r)}},{key:"beforeDestruct",value:function(){var t,e=this.j;e.async.clearTimeout(this.timeout),e.e.off(this.__box,"choose",this.onSelectItem).off(e.ow,"beforeunload.backup"),this.__box.destruct(),null==(t=this.__dialog)||t.destruct()}}]),e}((0,l._)(v.Plugin));(0,s._)(g,"requires",["license"]),(0,h.__decorate)([_.autobind],g.prototype,"onSaveBackup",null),(0,h.__decorate)([_.autobind],g.prototype,"onOpenBackupDialog",null),(0,h.__decorate)([_.autobind],g.prototype,"onSelectItem",null),m.JoditPro.plugins.add("backup",g)},64262:function(t,e,n){"use strict";n.d(e,{UIBackupBox:function(){return f}});var o=n(80294),i=n(20616),a=n(67709),r=n(82749),s=n(54816),c=n(84669),u=n(18766),l=n(31635),h=n(6183),d=n(65478),f=function(t){function e(t){var n;return(0,i._)(this,e),n=(0,o._)(this,e,[t]),(0,r._)(n,"list",new h.UIBackupList(n.j)),(0,r._)(n,"preview",n.j.c.div(n.getFullElName("preview"))),(0,r._)(n,"latestSelected",void 0),n.container.appendChild(n.list.container),n.container.appendChild(n.preview),n.list.container.classList.add(n.getFullElName("list")),t.e.on(n.list,"select",n.onSelectItem).on(n.list,"choose",n.onChooseItem),n}return(0,u._)(e,t),(0,a._)(e,[{key:"className",value:function(){return"UIBackupBox"}},{key:"build",value:function(t){this.preview.innerHTML="",this.list.build(t)}},{key:"destruct",value:function(){return this.j.e.off(this.list,"select",this.onSelectItem),this.list.destruct(),(0,s._)((0,c._)(e.prototype),"destruct",this).call(this)}},{key:"onSelectItem",value:function(t){this.latestSelected=t,this.preview.innerHTML=t.html||'<div class="'.concat(this.getFullElName("empty"),'">').concat(this.j.i18n("Empty"),"</div>")}},{key:"onChooseItem",value:function(t){this.j.e.fire(this,"choose",t)}},{key:"chooseSelected",value:function(){this.onChooseItem(this.latestSelected)}}]),e}(n(48538).UIElement);(0,l.__decorate)([d.autobind],f.prototype,"onSelectItem",null),(0,l.__decorate)([d.autobind],f.prototype,"onChooseItem",null),f=(0,l.__decorate)([d.component],f)},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)}])});