2020-09-15 12:40:06 +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
|
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={"á":"á","à":"à","ä":"ä","ǟ":"ǟ","ã":"ã","ā":"ā","ă":"ă","ắ":"ắ","ằ":"ằ","ẵ":"ẵ","ǎ":"ǎ","â":"â","ấ":"ấ","ầ":"ầ","ẫ":"ẫ","ȧ":"ȧ","ǡ":"ǡ","å":"å","ǻ":"ǻ","ḃ":"ḃ","ć":"ć","č":"č","ĉ":"ĉ","ċ":"ċ","ď":"ď","ḋ":"ḋ","é":"é","è":"è","ë":"ë","ẽ":"ẽ","ē":"ē","ḗ":"ḗ","ḕ":"ḕ","ĕ":"ĕ","ě":"ě","ê":"ê","ế":"ế","ề":"ề","ễ":"ễ","ė":"ė","ḟ":"ḟ","ǵ":"ǵ","ḡ":"ḡ","ğ":"ğ","ǧ":"ǧ","ĝ":"ĝ","ġ":"ġ","ḧ":"ḧ","ȟ":"ȟ","ĥ":"ĥ","ḣ":"ḣ","í":"í","ì":"ì","ï":"ï","ḯ":"ḯ","ĩ":"ĩ","ī":"ī","ĭ":"ĭ","ǐ":"ǐ","î":"î","ǰ":"ǰ","ĵ":"ĵ","ḱ":"ḱ","ǩ":"ǩ","ĺ":"ĺ","ľ":"ľ","ḿ":"ḿ","ṁ":"ṁ","ń":"ń","ǹ":"ǹ","ñ":"ñ","ň":"ň","ṅ":"ṅ","ó":"ó","ò":"ò","ö":"ö","ȫ":"ȫ","õ":"õ","ṍ":"ṍ","ṏ":"ṏ","ȭ":"ȭ","ō":"ō","ṓ":"ṓ","ṑ":"ṑ","ŏ":"ŏ","ǒ":"ǒ","ô":"ô","ố":"ố","ồ":"ồ","ỗ":"ỗ","ȯ":"ȯ","ȱ":"ȱ","ő":"ő","ṕ":"ṕ","ṗ":"ṗ","ŕ":"ŕ","ř":"ř","ṙ":"ṙ","ś":"ś","ṥ":"ṥ","š":"š","ṧ":"ṧ","ŝ":"ŝ","ṡ":"ṡ","ẗ":"ẗ","ť":"ť","ṫ":"ṫ","ú":"ú","ù":"ù","ü":"ü","ǘ":"ǘ","ǜ":"ǜ","ǖ":"ǖ","ǚ":"ǚ","ũ":"ũ","ṹ":"ṹ","ū":"ū","ṻ":"ṻ","ŭ":"ŭ","ǔ":"ǔ","û":"û","ů":"ů","ű":"ű","ṽ":"ṽ","ẃ":"ẃ","ẁ":"ẁ","ẅ":"ẅ","ŵ":"ŵ","ẇ":"ẇ","ẘ":"ẘ","ẍ":"ẍ","ẋ":"ẋ","ý":"ý","ỳ":"ỳ","ÿ":"ÿ","ỹ":"ỹ","ȳ":"ȳ","ŷ":"ŷ","ẏ":"ẏ","ẙ":"ẙ","ź":"ź","ž":"ž","ẑ":"ẑ","ż":"ż","Á":"Á","À":"À","Ä":"Ä","Ǟ":"Ǟ","Ã":"Ã","Ā":"Ā","Ă":"Ă","Ắ":"Ắ","Ằ":"Ằ","Ẵ":"Ẵ","Ǎ":"Ǎ","Â":"Â","Ấ":"Ấ","Ầ":"Ầ","Ẫ":"Ẫ","Ȧ":"Ȧ","Ǡ":"Ǡ","Å":"Å","Ǻ":"Ǻ","Ḃ":"Ḃ","Ć":"Ć","Č":"Č","Ĉ":"Ĉ","Ċ":"Ċ","Ď":"Ď","Ḋ":"Ḋ","É":"É","È":"È","Ë":"Ë","Ẽ":"Ẽ","Ē":"Ē","Ḗ":"Ḗ","Ḕ":"Ḕ","Ĕ":"Ĕ","Ě":"Ě","Ê":"Ê","Ế":"Ế","Ề":"Ề","Ễ":"Ễ","Ė":"Ė","Ḟ":"Ḟ","Ǵ":"Ǵ","Ḡ":"Ḡ","Ğ":"Ğ","Ǧ":"Ǧ","Ĝ":"Ĝ","Ġ":"Ġ","Ḧ":"Ḧ","Ȟ":"Ȟ","Ĥ":"Ĥ","Ḣ":"Ḣ","Í":"Í","Ì":"Ì","Ï":"Ï","Ḯ":"Ḯ","Ĩ":"Ĩ","Ī":"Ī","Ĭ":"Ĭ","Ǐ":"Ǐ","Î":"Î","İ":"İ","Ĵ":"Ĵ","Ḱ":"Ḱ","Ǩ":"Ǩ","Ĺ":"Ĺ","Ľ":"Ľ","Ḿ":"Ḿ","Ṁ":"Ṁ","Ń":"Ń","Ǹ":"Ǹ","Ñ":"Ñ","Ň":"Ň","Ṅ":"Ṅ","Ó":"Ó","Ò":"Ò","Ö":"Ö","Ȫ":"Ȫ","Õ":"Õ","Ṍ":"Ṍ","Ṏ":"Ṏ","Ȭ":"Ȭ","Ō":"Ō","Ṓ":"Ṓ","Ṑ":"Ṑ","Ŏ":"Ŏ","Ǒ":"Ǒ","Ô":"Ô","Ố":"Ố","Ồ":"Ồ","Ỗ":"Ỗ","Ȯ":"
|