jodit-pro 1.3.9 → 1.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/jodit.css +1 -1
- package/build/jodit.es5.css +2 -2
- package/build/jodit.es5.js +1 -1
- package/build/jodit.fat.css +1 -1
- package/build/jodit.fat.es5.css +1 -1
- package/build/jodit.fat.es5.js +1 -1
- package/build/jodit.fat.js +1 -1
- package/build/jodit.js +1 -1
- package/build/plugins/autocomplete/autocomplete.js +1 -1
- package/build/plugins/backup/backup.es5.js +1 -1
- package/build/plugins/backup/backup.js +1 -1
- package/build/plugins/button-generator/button-generator.es5.js +1 -1
- package/build/plugins/button-generator/button-generator.js +1 -1
- package/build/plugins/change-case/change-case.js +1 -1
- package/build/plugins/color-picker/color-picker.es5.js +1 -1
- package/build/plugins/color-picker/color-picker.js +1 -1
- package/build/plugins/emoji/emoji.js +1 -1
- package/build/plugins/export-docs/export-docs.es5.js +1 -1
- package/build/plugins/export-docs/export-docs.js +1 -1
- package/build/plugins/finder/finder.css +1 -1
- package/build/plugins/finder/finder.es5.css +1 -1
- package/build/plugins/finder/finder.es5.js +1 -1
- package/build/plugins/finder/finder.js +1 -1
- package/build/plugins/google-maps/google-maps.es5.js +1 -1
- package/build/plugins/google-maps/google-maps.js +1 -1
- package/build/plugins/google-search/google-search.js +1 -1
- package/build/plugins/highlight-signature/highlight-signature.js +1 -1
- package/build/plugins/iframe-editor/iframe-editor.js +1 -1
- package/build/plugins/keyboard/keyboard.js +1 -1
- package/build/plugins/page-break/page-break.js +1 -1
- package/build/plugins/paste-code/paste-code.js +1 -1
- package/build/plugins/paste-from-word/paste-from-word.es5.js +1 -1
- package/build/plugins/paste-from-word/paste-from-word.js +1 -1
- package/build/plugins/show-blocks/show-blocks.js +1 -1
- package/build/plugins/tune-block/tune-block.js +1 -1
- package/index.html +44 -23
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";((e,t)=>{if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var
|
|
1
|
+
"use strict";((e,t)=>{if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}})(self,(function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[633],{38096(e,t,o){o.r(t),o.d(t,{autocomplete:()=>f});var n=o(70655),s=o(16490),i=o(85119),r=o(41257),l=o(91037),u=o(35244),c=o(48823);class p extends c.u1{constructor(e,t){var o;super(e),this.item=t;const{container:n}=this;if((0,l.isFunction)(t.itemRenderer)){const e=t.itemRenderer(t);(0,l.isString)(e)?n.innerHTML=e:n.appendChild(e)}else n.innerText=null!==(o=t.title)&&void 0!==o?o:t.value}className(){return"AutocompleteItem"}}let a=class extends c.qe{constructor(){super(...arguments),this.elements=[],this.currentSelection=-1}className(){return"Autocomplete"}onChangeSelection(e,t){var o;null!=t&&(null===(o=this.elements[t])||void 0===o||o.setMod("active",!1)),this.elements[this.currentSelection].setMod("active",!0),this.elements[this.currentSelection].container.scrollIntoView(!1)}build(e){this.clear(),e.forEach(((e,t)=>{const o=new p(this.jodit,e);this.j.e.on(o.container,"mousedown touchstart",(e=>{e.preventDefault()})).on(o.container,"click",(()=>{this.currentSelection=t,this.select()})),this.append(o)})),this.currentSelection=0,this.onChangeSelection()}selectNext(){this.currentSelection+1>this.elements.length-1?this.currentSelection=0:this.currentSelection+=1}selectPrevious(){0>this.currentSelection-1?this.currentSelection=this.elements.length-1:this.currentSelection-=1}select(){this.j.e.fire("select.autocomplete",this.elements[this.currentSelection].item)}};(0,n.gn)([(0,r.watch)("currentSelection")],a.prototype,"onChangeSelection",null),a=(0,n.gn)([r.component],a);var d=o(11606),h=o(67996),m=o(44370);i.D.prototype.autocomplete={sources:[],maxItems:50,isMatchedQuery:(e,t)=>0===t.toLowerCase().indexOf(e.toLowerCase()),itemRenderer(e){var t;return null!==(t=e.title)&&void 0!==t?t:e.value},insertValueRenderer:e=>e.value+" "};class f extends s.S{constructor(){super(...arguments),this.requires=["enter","license"],this.hasStyle=!h.Jodit.fatMode,this.sources=[]}afterInit(e){this.popup=new u.Popup(e),this.popup.setMod("padding",!1),this.list=new a(e),this.popup.setContent(this.list.container),e.e.on("select.autocomplete",(t=>{let o=t.value;(0,l.isFunction)(t.insertValueRenderer)&&(o=t.insertValueRenderer(t)),u.Dom.isNode(o)||(o=e.createInside.fromHTML(o)),((e,t)=>{var o;const{startContainer:n,startOffset:s}=e;if(m.i.isText(n)){const i=null!==(o=n.nodeValue)&&void 0!==o?o:"",r=i.substr(0,s),l=i.substr(s),u=r.split(" ");u[u.length-1]="";const c=u.join(" ");n.nodeValue=c+l,e.setStart(n,c.length),e.insertNode(t)}})(e.s.range,o),this.j.s.setCursorAfter(o),this.popup.close()})).on("keydown.autocomplete",this.onKeyDown).on("keydown.autocomplete",this.onKeyControlDown,{top:!0}).on("beforeEnter.autocomplete",this.onEnter,{top:!0}).on("autocomplete.autocomplete",this.onAutoComplete).on("registerAutocompleteSource.autocomplete",this.registerAutocompleteSource)}registerAutocompleteSource(e){this.sources.push(e)}static isControlKey(e){return e===d.KEY_DOWN||e===d.KEY_UP||e===d.KEY_ENTER||e===d.KEY_TAB}async onKeyDown(e){var t,o;if(e.key===d.KEY_ESC)return void(this.popup.isOpened&&this.popup.close());const{s:n}=this.j;if(f.isControlKey(e.key)||!n.isInsideArea||!n.isCollapsed)return;const s=(null===(t=this.j.s.sel)||void 0===t?void 0:t.rangeCount)?null===(o=this.j.s.sel)||void 0===o?void 0:o.getRangeAt(0):null,i=s&&(e=>{var t,o,n,s;const{startContainer:i,startOffset:r}=e;if(m.i.isText(i))return null!==(o=null===(t=i.nodeValue)||void 0===t?void 0:t.substr(0,r))&&void 0!==o?o:"";const l=i.childNodes[r];if(!l)return"";if(m.i.isText(l))return null!==(n=l.nodeValue)&&void 0!==n?n:"";const u=m.i.findNotEmptyNeighbor(l,!0,i);return m.i.isText(u)&&null!==(s=l.nodeValue)&&void 0!==s?s:""})(s).split(" ").pop();if(i&&(0,l.trim)(i).length){const e=await this.onAutoComplete(i);if(e.length)return this.openPopup(e)}this.popup.isOpened&&this.popup.close()}onKeyControlDown(e){if(this.popup.isOpened&&f.isControlKey(e.key)){switch(e.key){case d.KEY_DOWN:this.list.selectNext();break;case d.KEY_UP:this.list.selectPrevious();break;case d.KEY_TAB:this.list.select()}return this.j.e.stopPropagation(e.type),!1}}onEnter(){if(this.popup.isOpened)return this.list.select(),!1}async onAutoComplete(e){const t=[];return await Promise.all(this.sources.concat(this.j.o.autocomplete.sources).map((async o=>{t.push(...await this.resolveFeed(e,o))}))),t}async resolveFeed(e,t,o){let n;if((0,l.isPromise)(t)&&(t=await t),(0,l.isFunction)(t))n=await t(e);else if((0,l.isArray)(t)){const o=t,{isMatchedQuery:s}=this.j.o.autocomplete;n=o.filter((t=>(0,l.isString)(t)?s(e,t):s(e,t.value))).map((e=>(0,l.isString)(e)?{title:e,value:e}:e))}else n=await this.resolveFeed(e,t.feed,t);if(n&&(0,l.isArray)(n)){const{itemRenderer:e,insertValueRenderer:t,maxItems:s}=this.j.o.autocomplete;return n=n.map((n=>{var s,i;return{itemRenderer:null!==(s=null==o?void 0:o.itemRenderer)&&void 0!==s?s:e,insertValueRenderer:null!==(i=null==o?void 0:o.insertValueRenderer)&&void 0!==i?i:t,...n}})),n.slice(0,s)}return[]}openPopup(e){this.list.build(e),this.popup.open((()=>this.j.s.range.getBoundingClientRect()))}beforeDestruct(e){e.e.off(this.list).off("keydown.autocomplete",this.onKeyDown).off("autocomplete.autocomplete",this.onAutoComplete).off(".autocomplete"),this.list.destruct(),this.popup.destruct()}}(0,n.gn)([r.autobind],f.prototype,"registerAutocompleteSource",null),(0,n.gn)([(0,r.debounce)()],f.prototype,"onKeyDown",null),(0,n.gn)([r.autobind],f.prototype,"onKeyControlDown",null),(0,n.gn)([r.autobind],f.prototype,"onEnter",null),(0,n.gn)([r.autobind],f.prototype,"onAutoComplete",null),(0,n.gn)([r.autobind],f.prototype,"resolveFeed",null),h.Jodit.plugins.add("autocomplete",f)},70655(e,t,o){function n(e,t,o,n){var s,i=arguments.length,r=3>i?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var l=e.length-1;l>=0;l--)(s=e[l])&&(r=(3>i?s(r):i>3?s(t,o,r):s(t,o))||r);return i>3&&r&&Object.defineProperty(t,o,r),r}o.d(t,{gn:()=>n})}},e=>e(e.s=38096)])}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!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 n in o)("object"==typeof exports?exports:t)[n]=o[n]}}(self,(function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[391],{48436:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.backup=void 0;var n=o(70655);o(98673);var i=o(16490),r=o(51078),a=o(
|
|
1
|
+
!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 n in o)("object"==typeof exports?exports:t)[n]=o[n]}}(self,(function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[391],{48436:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.backup=void 0;var n=o(70655);o(98673);var i=o(16490),r=o(51078),a=o(97770),s=o(78827),c=o(23112),u=o(97029),l=function(t){function e(){var e,o=this;return(o=t.apply(this,n.__spreadArray([],n.__read(arguments),!1))||this).requires=["license"],o.hasStyle=!u.Jodit.fatMode,o.buttons=[{name:"backup.restore",group:"history"}],o.__box=new a.UIBackupBox(o.j),o.__dialog=null,o.__storage=null!==(e=o.jodit.o.backup.remoteStore)&&void 0!==e?e:new r.DefaultStorage(o.jodit),o.timeout=0,o}return n.__extends(e,t),e.prototype.afterInit=function(t){var e=this;t.registerCommand("saveBackup",this.onSaveBackup).registerCommand("openBackupDialog",{exec:this.onOpenBackupDialog,hotkeys:t.o.backup.hotkeys});var o=function(){e.timeout=t.async.setTimeout((function(){e.onSaveBackup(),o()}),1e3*t.o.backup.interval)};o(),t.e.on(this.__box,"choose",this.onSelectItem).on(t.ow,"beforeunload.backup",(function(){e.onSaveBackup()}))},e.prototype.prepareDialog=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()},e.prototype.onSaveBackup=function(){this.__storage.add({created:new Date,html:this.j.value})},e.prototype.onOpenBackupDialog=function(){return n.__awaiter(this,void 0,Promise,(function(){var t,e;return n.__generator(this,(function(o){switch(o.label){case 0:return this.prepareDialog(),(t=this.__dialog)?(t.open().setModal(!0),[4,this.__storage.items()]):[2];case 1:return e=o.sent(),this.__box.build(n.__spreadArray([{created:new Date,html:this.j.value}],n.__read(e),!1)),t.calcAutoSize(),t.setPosition(),[2]}}))}))},e.prototype.onSelectItem=function(t){var e;null===(e=this.__dialog)||void 0===e||e.close(),this.j.value=t.html,this.j.s.focus()},e.prototype.addButtonsToDialog=function(){var t,e=this,o=this.jodit,n=(0,s.Button)(o,{name:"ok",tabIndex:0,variant:"primary",text:"Ok"}),i=(0,s.Button)(o,{variant:"secondary",tabIndex:0,text:"Cancel"}),r=(0,s.Button)(o,{name:"clear",tabIndex:0,variant:"secondary",text:"Remove all"});n.onAction((function(){e.__box.chooseSelected()})),i.onAction((function(){var t;null===(t=e.__dialog)||void 0===t||t.close()})),r.onAction((function(){o.confirm("Are you sure?",void 0,(function(t){var o;t&&(e.__storage.clear(),null===(o=e.__dialog)||void 0===o||o.close())}))}));var a=new s.UIBlock(o,[r,i,n]);a.container.style.margin="0",a.container.style.justifyContent="flex-end",a.container.style.width="100%",null===(t=this.__dialog)||void 0===t||t.setFooter(a)},e.prototype.beforeDestruct=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)||void 0===t||t.destruct()},n.__decorate([c.autobind],e.prototype,"onSaveBackup",null),n.__decorate([c.autobind],e.prototype,"onOpenBackupDialog",null),n.__decorate([c.autobind],e.prototype,"onSelectItem",null),e}(i.Plugin);e.backup=l,u.Jodit.plugins.add("backup",l)},98673:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=o(85119),i=o(59050),r=o(98740);n.Config.prototype.backup={interval:30,limit:50,dialogWidth:700,hotkeys:["ctrl+shift+b","cmd+shift+b"]},n.Config.prototype.controls.backup={store:{command:"saveBackup",text:"Save backup now"},restore:{tooltip:"Restore",list:["backup.store"],exec:function(t){t.execCommand("openBackupDialog")}}},i.Icon.set("restore",o(12240)),(0,r.extendLang)(o(27892))},27892:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},51078:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DefaultStorage=void 0;var n=o(70655),i=function(){function t(t){this.jodit=t,this.key="backup.default.storage"}return t.prototype.add=function(t){return n.__awaiter(this,void 0,Promise,(function(){var e;return n.__generator(this,(function(o){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]):[2,!1]}))}))},t.prototype.items=function(){return Promise.resolve(this.jodit.storage.get(this.key)||[])},t.prototype.clear=function(){return this.jodit.storage.delete(this.key),Promise.resolve(!1)},t}();e.DefaultStorage=i},97770:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UIBackupBox=void 0;var n=o(70655);o(5269);var i=o(23112),r=o(78827),a=o(16307),s=function(t){function e(e){var o=t.call(this,e)||this;return o.list=new a.UIBackupList(o.j),o.preview=o.j.c.div(o.getFullElName("preview")),o.container.appendChild(o.list.container),o.container.appendChild(o.preview),o.list.container.classList.add(o.getFullElName("list")),e.e.on(o.list,"select",o.onSelectItem).on(o.list,"choose",o.onChooseItem),o}return n.__extends(e,t),e.prototype.className=function(){return"UIBackupBox"},e.prototype.build=function(t){this.preview.innerHTML="",this.list.build(t)},e.prototype.destruct=function(){return this.j.e.off(this.list,"select",this.onSelectItem),this.list.destruct(),t.prototype.destruct.call(this)},e.prototype.onSelectItem=function(t){this.latestSelected=t,this.preview.innerHTML=t.html||'<div class="'.concat(this.getFullElName("empty"),'">').concat(this.j.i18n("Empty"),"</div>")},e.prototype.onChooseItem=function(t){this.j.e.fire(this,"choose",t)},e.prototype.chooseSelected=function(){this.onChooseItem(this.latestSelected)},n.__decorate([i.autobind],e.prototype,"onSelectItem",null),n.__decorate([i.autobind],e.prototype,"onChooseItem",null),n.__decorate([i.component],e)}(r.UIElement);e.UIBackupBox=s},86788:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UIBackupItem=void 0;var n=o(70655);o(25241);var i=o(78827),r=o(75204),a=function(t){function e(e,o){var n=t.call(this,e)||this;return n.data=o,n.container.innerHTML=n.formatDate(o.created),(0,r.attr)(n.container,"tabIndex",0),n}return n.__extends(e,t),e.prototype.className=function(){return"UIBackupItem"},e.prototype.formatDate=function(t){var e=new Date,o=(0,r.isString)(t)?new Date(t):t,n=(e.getTime()-o.getTime())/1e3;return(0,r.isFunction)(this.j.o.backup.formatDate)?this.j.o.backup.formatDate(o):.2>n?this.j.i18n("Current"):60>n?this.j.i18n("Less minute"):n>3600?n>86400?"".concat(o.toDateString()," ").concat(o.toLocaleTimeString()):this.j.i18n("%s hours ago",Math.floor(n/3600)):this.j.i18n("%s minutes ago",Math.floor(n/60))},e.prototype.focus=function(){this.container.focus()},e}(i.UIElement);e.UIBackupItem=a},16307:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UIBackupList=void 0;var n=o(70655),i=o(78827),r=o(23112),a=o(86788),s=o(11606),c=o(75204),u=function(t){function e(e){var o=t.call(this,e)||this;return o.elements=[],o.currentSelection=-1,e.e.on(o.container,"keydown",(function(t){switch(t.key){case s.KEY_ENTER:t.preventDefault(),t.stopPropagation(),o.onChoose(o.currentSelection);break;case s.KEY_DOWN:o.selectNext();break;case s.KEY_UP:o.selectPrevious()}})),o}return n.__extends(e,t),e.prototype.className=function(){return"UIBackupList"},e.prototype.createContainer=function(e){var o=t.prototype.createContainer.call(this,e);return(0,c.attr)(o,"tabIndex","-1"),o},e.prototype.build=function(t){var e=this;this.clear(),t.forEach((function(t,o){var n=new a.UIBackupItem(e.jodit,t);e.append(n),e.j.e.on(n.container,"focus",(function(){return e.onSelect(o)})).on(n.container,"click",(function(){return e.onSelect(o)})).on(n.container,"dblclick",(function(){return e.onChoose(o)}))})),this.currentSelection=0,this.onChangeCurrentSelection(void 0,-1,0)},e.prototype.onChangeCurrentSelection=function(t,e,o){var n,i,r;null===(n=this.elements[e])||void 0===n||n.setMod("active",!1),null===(i=this.elements[o])||void 0===i||i.setMod("active",!0),null===(r=this.elements[o])||void 0===r||r.focus(),this.j.e.fire(this,"select",this.elements[o].data)},e.prototype.onSelect=function(t){this.currentSelection=t},e.prototype.onChoose=function(t){this.j.e.fire(this,"choose",this.elements[null!=t?t:this.currentSelection].data)},e.prototype.selectNext=function(){this.currentSelection+1>this.elements.length-1?this.currentSelection=0:this.currentSelection+=1},e.prototype.selectPrevious=function(){0>this.currentSelection-1?this.currentSelection=this.elements.length-1:this.currentSelection-=1},n.__decorate([(0,r.watch)("currentSelection")],e.prototype,"onChangeCurrentSelection",null),n.__decorate([r.autobind],e.prototype,"onSelect",null),n.__decorate([r.autobind],e.prototype,"onChoose",null),n.__decorate([r.component],e)}(i.UIGroup);e.UIBackupList=u},12240: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>'},5269:function(t,e,o){"use strict";o.r(e)},25241:function(t,e,o){"use strict";o.r(e)}},function(t){return t(t.s=48436)}])}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
((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([[391],{
|
|
1
|
+
((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([[391],{62899(t,e,o){"use strict";o.r(e),o.d(e,{backup:()=>f});var i=o(70655),s=o(85119),n=o(59050),a=o(98740);s.D.prototype.backup={interval:30,limit:50,dialogWidth:700,hotkeys:["ctrl+shift+b","cmd+shift+b"]},s.D.prototype.controls.backup={store:{command:"saveBackup",text:"Save backup now"},restore:{tooltip:"Restore",list:["backup.store"],exec(t){t.execCommand("openBackupDialog")}}},n.J.set("restore",o(12240)),(0,a.xl)(o(27892));var r=o(16490);class l{constructor(t){this.jodit=t,this.key="backup.default.storage"}async add(t){if(!t.html.trim().length)return!1;const 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)}}var c=o(41257),h=o(48823),u=o(91037);class d extends h.u1{constructor(t,e){super(t),this.data=e,this.container.innerHTML=this.formatDate(e.created),(0,u.attr)(this.container,"tabIndex",0)}className(){return"UIBackupItem"}formatDate(t){const e=new Date,o=(0,u.isString)(t)?new Date(t):t,i=(e.getTime()-o.getTime())/1e3;return(0,u.isFunction)(this.j.o.backup.formatDate)?this.j.o.backup.formatDate(o):.2>i?this.j.i18n("Current"):60>i?this.j.i18n("Less minute"):i>3600?i>86400?`${o.toDateString()} ${o.toLocaleTimeString()}`:this.j.i18n("%s hours ago",Math.floor(i/3600)):this.j.i18n("%s minutes ago",Math.floor(i/60))}focus(){this.container.focus()}}var p=o(11606);let m=class extends h.qe{constructor(t){super(t),this.elements=[],this.currentSelection=-1,t.e.on(this.container,"keydown",(t=>{switch(t.key){case p.KEY_ENTER:t.preventDefault(),t.stopPropagation(),this.onChoose(this.currentSelection);break;case p.KEY_DOWN:this.selectNext();break;case p.KEY_UP:this.selectPrevious()}}))}className(){return"UIBackupList"}createContainer(t){const e=super.createContainer(t);return(0,u.attr)(e,"tabIndex","-1"),e}build(t){this.clear(),t.forEach(((t,e)=>{const o=new d(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){var i,s,n;null===(i=this.elements[e])||void 0===i||i.setMod("active",!1),null===(s=this.elements[o])||void 0===s||s.setMod("active",!0),null===(n=this.elements[o])||void 0===n||n.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[null!=t?t:this.currentSelection].data)}selectNext(){this.currentSelection+1>this.elements.length-1?this.currentSelection=0:this.currentSelection+=1}selectPrevious(){0>this.currentSelection-1?this.currentSelection=this.elements.length-1:this.currentSelection-=1}};(0,i.gn)([(0,c.watch)("currentSelection")],m.prototype,"onChangeCurrentSelection",null),(0,i.gn)([c.autobind],m.prototype,"onSelect",null),(0,i.gn)([c.autobind],m.prototype,"onChoose",null),m=(0,i.gn)([c.component],m);let g=class extends h.u1{constructor(t){super(t),this.list=new m(this.j),this.preview=this.j.c.div(this.getFullElName("preview")),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)}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)}};(0,i.gn)([c.autobind],g.prototype,"onSelectItem",null),(0,i.gn)([c.autobind],g.prototype,"onChooseItem",null),g=(0,i.gn)([c.component],g);var v=o(67996);class f extends r.S{constructor(){var t;super(...arguments),this.requires=["license"],this.hasStyle=!v.Jodit.fatMode,this.buttons=[{name:"backup.restore",group:"history"}],this.__box=new g(this.j),this.__dialog=null,this.__storage=null!==(t=this.jodit.o.backup.remoteStore)&&void 0!==t?t:new l(this.jodit),this.timeout=0}afterInit(t){t.registerCommand("saveBackup",this.onSaveBackup).registerCommand("openBackupDialog",{exec:this.onOpenBackupDialog,hotkeys:t.o.backup.hotkeys});const 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();const{__dialog:t}=this;if(!t)return;t.open().setModal(!0);const e=await this.__storage.items();this.__box.build([{created:new Date,html:this.j.value},...e]),t.calcAutoSize(),t.setPosition()}onSelectItem(t){var e;null===(e=this.__dialog)||void 0===e||e.close(),this.j.value=t.html,this.j.s.focus()}addButtonsToDialog(){var t;const{jodit:e}=this,o=(0,h.zx)(e,{name:"ok",tabIndex:0,variant:"primary",text:"Ok"}),i=(0,h.zx)(e,{variant:"secondary",tabIndex:0,text:"Cancel"}),s=(0,h.zx)(e,{name:"clear",tabIndex:0,variant:"secondary",text:"Remove all"});o.onAction((()=>{this.__box.chooseSelected()})),i.onAction((()=>{var t;null===(t=this.__dialog)||void 0===t||t.close()})),s.onAction((()=>{e.confirm("Are you sure?",void 0,(t=>{var e;t&&(this.__storage.clear(),null===(e=this.__dialog)||void 0===e||e.close())}))}));const n=new h.eC(e,[s,i,o]);n.container.style.margin="0",n.container.style.justifyContent="flex-end",n.container.style.width="100%",null===(t=this.__dialog)||void 0===t||t.setFooter(n)}beforeDestruct(){var t;const{j:e}=this;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)||void 0===t||t.destruct()}}(0,i.gn)([c.autobind],f.prototype,"onSaveBackup",null),(0,i.gn)([c.autobind],f.prototype,"onOpenBackupDialog",null),(0,i.gn)([c.autobind],f.prototype,"onSelectItem",null),v.Jodit.plugins.add("backup",f)},27892(t,e,o){"use strict";o.r(e)},70655(t,e,o){"use strict";function i(t,e,o,i){var s,n=arguments.length,a=3>n?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var r=t.length-1;r>=0;r--)(s=t[r])&&(a=(3>n?s(a):n>3?s(e,o,a):s(e,o))||a);return n>3&&a&&Object.defineProperty(e,o,a),a}o.d(e,{gn:()=>i})},12240(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>'}},t=>t(t.s=62899)])}));
|