antosdk-apps/Booklet/build/debug/main.js

6 lines
245 KiB
JavaScript
Raw Normal View History

2020-07-10 14:01:52 +02:00
var e;(function(){var e,t,r,n,a,i,o,s;(e=class extends this.OS.application.BaseApplication{constructor(e){super("Booklet",e)}main(){return this.tree=this.find("toc-ui"),this.currentToc=void 0,this.dirty=!1,this.emux=!1,this.on("treeselect",e=>{var t;return t=e.data.item.data,this.currentToc===t||void 0===t||0===t.treepath?this.reloadEditor():(t.treepath=t.path,this.load(t).then(()=>this.open(t)).catch(e=>(t.loaded=!0,this.open(t),this.error(__("Error when loading '{0}': {1}",t.text,e.toString()),e))))}),this.tree.ondragndrop=e=>this.dndhandle(e),this.initEditor(),this.resizeContent(),this.tree.contextmenuHandle=(e,t)=>{var r;if(r=this.contextMenu())return t.items=r,t.onmenuselect=e=>this[e.data.item.data.dataid](),t.show(e)},this.editor.codemirror.on("change",()=>{if(!this.emux&&this.currentToc)return this.currentToc.descFile.dirty=!0,this.dirty=!0})}newChapter(){var e;return this.currentToc&&"Book"===this.currentToc.type?(e=new r(this.book),this.displayToc(),e.treepath=e.path):this.error(__("No book selected"))}newSection(){var e;return this.currentToc&&"Chapter"===this.currentToc.type?(e=new o(this.currentToc),this.displayToc(),e.treepath=e.path):this.error(__("No chapter selected"))}newFile(){var e;return this.currentToc&&"Section"===this.currentToc.type?(e=new a(this.currentToc),this.displayToc(),e.treepath=e.path):this.error(__("No section selected"))}delete(){var e;return this.currentToc?(e=()=>(this.currentToc=void 0,this.displayToc(),this.reloadEditor()),this.currentToc.remove().then(()=>(this.notify(__("Entrie deleted")),e())).catch(t=>(this.error(t.toString(),t),e()))):this.error(__("No entrie select"))}goUp(){if(this.currentToc&&"Book"!==this.currentToc.type)return this.currentToc.parent.up(this.currentToc),this.displayToc()}goDown(){if(this.currentToc&&"Book"!==this.currentToc.type)return this.currentToc.parent.down(this.currentToc),this.displayToc()}load(e){return new Promise((t,r)=>e.loaded?t():e.descFile.meta().then(n=>e.descFile.read().then(r=>(e.descFile.cache=r,e.loaded=!0,e.descFile.dirty=!1,t())).catch((function(e){return r(__e(e))}))).catch((function(e){return r(__e(e))})))}dndhandle(e){var t,r;if(e&&e.data&&(t=e.data.from.data,r=e.data.to.data,t&&r&&"Book"!==t.type&&"Chapter"!==t.type&&t.parent!==r.parent&&t.parent!==r))return r.type===t.type&&(r=r.parent),r.type===t.parent.type?t.parent.removeChild(t).then(()=>(r.add(t),this.displayToc())):void 0}upload(){if(this.currentToc&&"File"!==this.currentToc.type)return this.currentToc.path.asFileHandle().upload().then(()=>this.notify(__("File uploaded"))).catch(e=>this.error(__("Unable to upload file {0}",e.toString()),e))}contextMenu(){if(this.currentToc)switch(this.currentToc.type){case"Book":return[{text:__("New chapter"),dataid:"newChapter"},{text:__("Delete book"),dataid:"delete"},{text:__("Upload media"),dataid:"upload"}];case"Chapter":return[{text:__("New section"),dataid:"newSection"},{text:__("Delete chapter"),dataid:"delete"},{text:__("Go up"),dataid:"goUp"},{text:__("Go down"),dataid:"goDown"},{text:__("Upload media"),dataid:"upload"}];case"Section":return[{text:__("New file"),dataid:"newFile"},{text:__("Delete section"),dataid:"delete"},{text:__("Go up"),dataid:"goUp"},{text:__("Go down"),dataid:"goDown"},{text:__("Upload media"),dataid:"upload"}];case"File":return[{text:__("Delete file"),dataid:"delete"},{text:__("Go up"),dataid:"goUp"},{text:__("Go down"),dataid:"goDown"}]}}shareFile(e,t){return this.openDialog("FileDialog",{title:__("Select a file"),mimes:e}).then(e=>e.file.path.asFileHandle().publish().then((function(e){return t(e.result)})).catch(e=>this.error(__("Cannot export file for embedding to text"),e))).catch(e=>this.error(e.toString(),e))}initEditor(){var e;return e=this.find("markarea"),this.container=this.find("mycontainer"),this.previewOn=!1,this.editormux=!1,this.editor=new SimpleMDE({element:e,autoDownloadFontAwesome:!1,autofocus:!0,tabSize:4,indentWithTabs:!0,toolbar:["bold","italic","heading","|","quote","code","unordered-list","ordered-list","|","link","image","table","horizontal-rule",{name:"shared image",className:"fa f
2019-11-30 23:04:36 +01:00
/*
object-assign
(c) Sindre Sorhus
@license MIT
2020-07-10 14:01:52 +02:00
*/var n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function o(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,s,l=o(e),u=1;u<arguments.length;u++){for(var c in r=Object(arguments[u]))a.call(r,c)&&(l[c]=r[c]);if(n){s=n(r);for(var h=0;h<s.length;h++)i.call(r,s[h])&&(l[s[h]]=r[s[h]])}}return l}},function(e,t){e.exports={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"}}},function(e,t,r){"use strict";t.a={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","":"ắ","":"ằ","":"ẵ","ǎ":"ǎ","â":"â","":"ấ","":"ầ","":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","":"ḃ","ć":"ć","č":"č","ĉ":"ĉ","ċ":"ċ","ď":"ď","":"ḋ","é":"é","è":"è","ë":"ë","":"ẽ","ē":"ē","":"ḗ","":"ḕ","ĕ":"ĕ","ě":"ě","ê":"ê","ế":"ế","":"ề","":"ễ","ė":"ė","":"ḟ","ǵ":"ǵ","":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","":"ḧ","ȟ":"ȟ","ĥ":"ĥ","":"ḣ","í":"í","ì":"ì","ï":"ï","":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","":"ḱ","ǩ":"ǩ","ĺ":"ĺ","ľ":"ľ","ḿ":"ḿ","":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","":"ṅ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","":"ṍ","":"ṏ","ȭ":"ȭ","ō":"ō","":"ṓ","":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","":"ố","":"ồ","":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","":"ṕ","":"ṗ","ŕ":"ŕ","ř":"ř","":"ṙ","ś":"ś","":"ṥ","š":"š","":"ṧ","ŝ":"ŝ","":"ṡ","":"ẗ","ť":"ť","":"ṫ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","":"ṹ","ū":"ū","":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","":"ṽ","":"ẃ","":"ẁ","":"ẅ","ŵ":"ŵ","":"ẇ","":"ẘ","":"ẍ","":"ẋ","ý":"ý","":"ỳ","ÿ":"ÿ","":"ỹ","ȳ":"ȳ","ŷ":"ŷ","":"ẏ","":"ẙ","ź":"ź","ž":"ž","":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","":"Ắ","":"Ằ","":"Ẵ","Ǎ":"Ǎ","Â":"Â","":"Ấ","":"Ầ","":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","":"Ḃ","Ć":"Ć","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ď":"Ď","":"Ḋ","É":"É","È":"È","Ë":"Ë","":"Ẽ","Ē":"Ē","":"Ḗ","":"Ḕ","Ĕ":"Ĕ","Ě":"Ě","Ê":"Ê","":"Ế","":"Ề","":"Ễ","Ė":"Ė","":"Ḟ","Ǵ":"Ǵ","":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","":"Ḣ","Í":"Í","Ì":"Ì","Ï":"Ï","":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","":"Ḱ","Ǩ":"Ǩ","Ĺ":"Ĺ","Ľ":"Ľ","":"Ḿ","":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","":"Ṅ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","":"Ṍ","":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","":"Ṓ","":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","":"Ố","":"Ồ","":"Ỗ","Ȯ":"