diff --git a/public/dist/main.bundle.js b/public/dist/main.bundle.js index b3373b1..567ba70 100644 --- a/public/dist/main.bundle.js +++ b/public/dist/main.bundle.js @@ -7,4 +7,4 @@ var Docs=function(t){function e(e){for(var n,r,i=e[0],a=e[1],u=0,c=[];u0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.Library=e.Library||window,this.modules=this.findModules(document),this.initModules()}return i(t,[{key:"findModules",value:function(t){for(var e=[],n=t.querySelectorAll("[data-module]"),o=n.length-1;o>=0;o--)e.push.apply(e,r(this.extractModulesData(n[o])));return e}},{key:"extractModulesData",value:function(t){var e=this,n=[],r=t.dataset.module;return(r=r.replace(/\s+/," ")).split(" ").forEach(function(r,o){var i=new a({name:r,element:t,settings:e.getModuleSettings(t,o,r),moduleClass:e.Library[r]});n.push(i)}),n}},{key:"getModuleSettings",value:function(t,e,n){var r=t.querySelector('textarea[name="module-settings"]'),o=void 0;if(!r)return null;try{o=r.value.trim(),o=JSON.parse(o)}catch(t){return console.warn("Can not parse Module «"+n+"» settings because of: "+t),console.groupCollapsed(n+" settings"),console.log(o),console.groupEnd(),null}return Array.isArray(o)?o[e]?o[e]:null:0===e?o:(console.warn("Wrong settings format. For several Modules use an array instead of object."),null)}},{key:"initModules",value:function(){console.groupCollapsed("ModuleDispatcher"),this.modules.forEach(function(t){t.init()}),console.groupEnd()}}]),t}();e.default=u}]).default},function(t,e,n){window,t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1);e.default=r.default},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(a,u)}c((r=r.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=s?t?"":void 0:(i=u.charCodeAt(c))<55296||i>56319||c+1===s||(a=u.charCodeAt(c+1))<56320||a>57343?t?u.charAt(c):i:t?u.slice(c,c+2):a-56320+(i-55296<<10)+65536}}},function(t,e,n){t.exports=!n(4)&&!n(13)(function(){return 7!=Object.defineProperty(n(22)("div"),"a",{get:function(){return 7}}).a})},function(t,e,n){var r=n(3);t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e,n){},function(t,e){t.exports=function(t,e,n,r){if(!(t instanceof e)||void 0!==r&&r in t)throw TypeError(n+": incorrect invocation!");return t}},function(t,e,n){var r=n(7),o=n(34),i=n(35),a=n(2),u=n(16),c=n(36),s={},l={};(e=t.exports=function(t,e,n,f,p){var h,d,v,y,g=p?function(){return t}:c(t),m=r(n,f,e?2:1),w=0;if("function"!=typeof g)throw TypeError(t+" is not iterable!");if(i(g)){for(h=u(t.length);h>w;w++)if((y=e?m(a(d=t[w])[0],d[1]):m(t[w]))===s||y===l)return y}else for(v=g.call(t);!(d=v.next()).done;)if((y=o(v,m,d.value,e))===s||y===l)return y}).BREAK=s,e.RETURN=l},function(t,e,n){var r=n(2),o=n(8),i=n(1)("species");t.exports=function(t,e){var n,a=r(t).constructor;return void 0===a||null==(n=r(a)[i])?e:o(n)}},function(t,e){t.exports=function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},function(t,e,n){var r=n(0),o=n(25).set,i=r.MutationObserver||r.WebKitMutationObserver,a=r.process,u=r.Promise,c="process"==n(11)(a);t.exports=function(){var t,e,n,s=function(){var r,o;for(c&&(r=a.domain)&&r.exit();t;){o=t.fn,t=t.next;try{o()}catch(r){throw t?n():e=void 0,r}}e=void 0,r&&r.enter()};if(c)n=function(){a.nextTick(s)};else if(!i||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var l=u.resolve(void 0);n=function(){l.then(s)}}else n=function(){o.call(r,s)};else{var f=!0,p=document.createTextNode("");new i(s).observe(p,{characterData:!0}),n=function(){p.data=f=!f}}return function(r){var o={fn:r,next:void 0};e&&(e.next=o),t||(t=o,n()),e=o}}},function(t,e){t.exports=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}}},function(t,e,n){var r=n(0).navigator;t.exports=r&&r.userAgent||""},function(t,e,n){var r=n(2),o=n(3),i=n(26);t.exports=function(t,e){if(r(t),o(e)&&e.constructor===t)return e;var n=i.f(t);return(0,n.resolve)(e),n.promise}},function(t,e,n){var r=n(14);t.exports=function(t,e,n){for(var o in e)r(t,o,e[o],n);return t}},function(t,e,n){"use strict";var r=n(0),o=n(6),i=n(4),a=n(1)("species");t.exports=function(t){var e=r[t];i&&e&&!e[a]&&o.f(e,a,{configurable:!0,get:function(){return this}})}},function(t,e,n){"use strict";var r=n(2),o=n(16),i=n(54),a=n(55);n(56)("match",1,function(t,e,n,u){return[function(n){var r=t(this),o=null==n?void 0:n[e];return void 0!==o?o.call(n,r):new RegExp(n)[e](String(r))},function(t){var e=u(n,t,this);if(e.done)return e.value;var c=r(t),s=String(this);if(!c.global)return a(c,s);var l=c.unicode;c.lastIndex=0;for(var f,p=[],h=0;null!==(f=a(c,s));){var d=String(f[0]);p[h]=d,""===d&&(c.lastIndex=i(s,o(c.lastIndex),l)),h++}return 0===h?null:p}]})},function(t,e,n){"use strict";var r=n(39)(!0);t.exports=function(t,e,n){return e+(n?r(t,e).length:1)}},function(t,e,n){"use strict";var r=n(15),o=RegExp.prototype.exec;t.exports=function(t,e){var n=t.exec;if("function"==typeof n){var i=n.call(t,e);if("object"!=typeof i)throw new TypeError("RegExp exec method returned something other than an Object or null");return i}if("RegExp"!==r(t))throw new TypeError("RegExp#exec called on incompatible receiver");return o.call(t,e)}},function(t,e,n){"use strict";n(57);var r=n(14),o=n(10),i=n(13),a=n(17),u=n(1),c=n(27),s=u("species"),l=!i(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")}),f=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1]}();t.exports=function(t,e,n){var p=u(t),h=!i(function(){var e={};return e[p]=function(){return 7},7!=""[t](e)}),d=h?!i(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[s]=function(){return n}),n[p](""),!e}):void 0;if(!h||!d||"replace"===t&&!l||"split"===t&&!f){var v=/./[p],y=n(a,p,""[t],function(t,e,n,r,o){return e.exec===c?h&&!o?{done:!0,value:v.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),g=y[0],m=y[1];r(String.prototype,t,g),o(RegExp.prototype,p,2==e?function(t,e){return m.call(t,this,e)}:function(t){return m.call(t,this)})}}},function(t,e,n){"use strict";var r=n(27);n(9)({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r})},function(t,e,n){"use strict";var r=n(2);t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},function(t,e,n){"use strict";n.r(e);n(12),n(42);var r=n(29),o=n.n(r);n(24),n(53),n(28);function i(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function a(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var a=t.apply(e,n);function u(t){i(a,r,o,u,c,"next",t)}function c(t){i(a,r,o,u,c,"throw",t)}u(void 0)})}}function u(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;this.nodes.editorWrapper=document.getElementById("codex-editor"),e.page&&(this.page=e.page),this.loadEditor().then(function(e){t.editor=e}),this.nodes.saveButton=n.querySelector('[name="js-submit-save"]'),this.nodes.saveButton.addEventListener("click",function(){t.saveButtonClicked()}),this.nodes.removeButton=n.querySelector('[name="js-submit-remove"]'),this.nodes.removeButton&&this.nodes.removeButton.addEventListener("click",function(){window.confirm("Are you sure?")&&t.removeButtonClicked()}),this.nodes.parentIdSelector=n.querySelector('[name="parent"]'),this.nodes.putAboveIdSelector=n.querySelector('[name="above"]'),this.nodes.uriInput=n.querySelector('[name="uri-input"]')}},{key:"loadEditor",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.e(1).then(n.bind(null,105));case 2:return e=t.sent,r=e.default,o=this.page?{data:this.page.body}:{},t.abrupt("return",new r(o,{headerPlaceholder:"Enter a title"}));case 6:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"getData",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,n,r,o,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.editor.save();case 2:if(e=t.sent,n=e.blocks.length?e.blocks[0]:null,r=n&&"header"===n.type?n.data.text:null,o="",!this.nodes.uriInput||!this.nodes.uriInput.value){t.next=12;break}if(!this.nodes.uriInput.value.match(/^[a-z0-9'-]+$/i)){t.next=11;break}o=this.nodes.uriInput.value,t.next=12;break;case 11:throw new Error("Uri has unexpected characters");case 12:if(r){t.next=14;break}throw new Error("Entry should start with Header");case 14:return i=null,this.nodes.putAboveIdSelector&&(i=this.nodes.putAboveIdSelector.value),t.abrupt("return",{parent:this.nodes.parentIdSelector.value,putAbovePageId:i,uri:o,body:e});case 17:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"saveButtonClicked",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.getData();case 3:return e=t.sent,n=this.page?"/api/page/"+this.page._id:"/api/page",t.prev=5,t.next=8,fetch(n,{method:this.page?"POST":"PUT",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(e)});case 8:return r=t.sent,t.next=11,r.json();case 11:(r=t.sent).success?window.location.pathname=r.result.uri?r.result.uri:"/page/"+r.result._id:(alert(r.error),console.log("Validation failed:",r.error)),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(5),console.log("Saving request failed:",t.t0);case 18:t.next=24;break;case 20:t.prev=20,t.t1=t.catch(0),alert(t.t1),console.log("Saving error: ",t.t1);case 24:case"end":return t.stop()}},t,this,[[0,20],[5,15]])}));return function(){return t.apply(this,arguments)}}()},{key:"removeButtonClicked",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,e=this.page?"/api/page/"+this.page._id:"",t.next=4,fetch(e,{method:"DELETE"});case 4:return n=t.sent,t.next=7,n.json();case 7:(n=t.sent).success?n.result&&n.result._id?document.location="/page/"+n.result._id:document.location="/":(alert(n.error),console.log("Server fetch failed:",n.error)),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(0),console.log("Server fetch failed due to the:",t.t0);case 14:case"end":return t.stop()}},t,this,[[0,11]])}));return function(){return t.apply(this,arguments)}}()}])&&u(e.prototype,r),o&&u(e,o),t}();function s(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function l(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&arguments[1];this.codeStyler=this.createCodeStyling()}},{key:"createCodeStyling",value:function(){var t,e=(t=regeneratorRuntime.mark(function t(){var e,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.e(0).then(n.bind(null,106));case 2:return e=t.sent,r=e.default,t.abrupt("return",new r({selector:".block-code"}));case 5:case"end":return t.stop()}},t,this)}),function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){s(i,r,o,a,u,"next",t)}function u(t){s(i,r,o,a,u,"throw",t)}a(void 0)})});return function(){return e.apply(this,arguments)}}()}])&&l(e.prototype,r),o&&l(e,o),t}(),p=n(30),h=n.n(p);var d=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.misprints=new h.a({chatId:"XXXXXXXX"})};function v(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.Library=e.Library||window,this.modules=this.findModules(document),this.initModules()}return i(t,[{key:"findModules",value:function(t){for(var e=[],n=t.querySelectorAll("[data-module]"),o=n.length-1;o>=0;o--)e.push.apply(e,r(this.extractModulesData(n[o])));return e}},{key:"extractModulesData",value:function(t){var e=this,n=[],r=t.dataset.module;return(r=r.replace(/\s+/," ")).split(" ").forEach(function(r,o){var i=new a({name:r,element:t,settings:e.getModuleSettings(t,o,r),moduleClass:e.Library[r]});n.push(i)}),n}},{key:"getModuleSettings",value:function(t,e,n){var r=t.querySelector('textarea[name="module-settings"]'),o=void 0;if(!r)return null;try{o=r.value.trim(),o=JSON.parse(o)}catch(t){return console.warn("Can not parse Module «"+n+"» settings because of: "+t),console.groupCollapsed(n+" settings"),console.log(o),console.groupEnd(),null}return Array.isArray(o)?o[e]?o[e]:null:0===e?o:(console.warn("Wrong settings format. For several Modules use an array instead of object."),null)}},{key:"initModules",value:function(){console.groupCollapsed("ModuleDispatcher"),this.modules.forEach(function(t){t.init()}),console.groupEnd()}}]),t}();e.default=u}]).default},function(t,e,n){window,t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1);e.default=r.default},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(a,u)}c((r=r.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=s?t?"":void 0:(i=u.charCodeAt(c))<55296||i>56319||c+1===s||(a=u.charCodeAt(c+1))<56320||a>57343?t?u.charAt(c):i:t?u.slice(c,c+2):a-56320+(i-55296<<10)+65536}}},function(t,e,n){t.exports=!n(4)&&!n(13)(function(){return 7!=Object.defineProperty(n(22)("div"),"a",{get:function(){return 7}}).a})},function(t,e,n){var r=n(3);t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e,n){},function(t,e){t.exports=function(t,e,n,r){if(!(t instanceof e)||void 0!==r&&r in t)throw TypeError(n+": incorrect invocation!");return t}},function(t,e,n){var r=n(7),o=n(34),i=n(35),a=n(2),u=n(16),c=n(36),s={},l={};(e=t.exports=function(t,e,n,f,p){var h,d,v,y,g=p?function(){return t}:c(t),m=r(n,f,e?2:1),w=0;if("function"!=typeof g)throw TypeError(t+" is not iterable!");if(i(g)){for(h=u(t.length);h>w;w++)if((y=e?m(a(d=t[w])[0],d[1]):m(t[w]))===s||y===l)return y}else for(v=g.call(t);!(d=v.next()).done;)if((y=o(v,m,d.value,e))===s||y===l)return y}).BREAK=s,e.RETURN=l},function(t,e,n){var r=n(2),o=n(8),i=n(1)("species");t.exports=function(t,e){var n,a=r(t).constructor;return void 0===a||null==(n=r(a)[i])?e:o(n)}},function(t,e){t.exports=function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},function(t,e,n){var r=n(0),o=n(25).set,i=r.MutationObserver||r.WebKitMutationObserver,a=r.process,u=r.Promise,c="process"==n(11)(a);t.exports=function(){var t,e,n,s=function(){var r,o;for(c&&(r=a.domain)&&r.exit();t;){o=t.fn,t=t.next;try{o()}catch(r){throw t?n():e=void 0,r}}e=void 0,r&&r.enter()};if(c)n=function(){a.nextTick(s)};else if(!i||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var l=u.resolve(void 0);n=function(){l.then(s)}}else n=function(){o.call(r,s)};else{var f=!0,p=document.createTextNode("");new i(s).observe(p,{characterData:!0}),n=function(){p.data=f=!f}}return function(r){var o={fn:r,next:void 0};e&&(e.next=o),t||(t=o,n()),e=o}}},function(t,e){t.exports=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}}},function(t,e,n){var r=n(0).navigator;t.exports=r&&r.userAgent||""},function(t,e,n){var r=n(2),o=n(3),i=n(26);t.exports=function(t,e){if(r(t),o(e)&&e.constructor===t)return e;var n=i.f(t);return(0,n.resolve)(e),n.promise}},function(t,e,n){var r=n(14);t.exports=function(t,e,n){for(var o in e)r(t,o,e[o],n);return t}},function(t,e,n){"use strict";var r=n(0),o=n(6),i=n(4),a=n(1)("species");t.exports=function(t){var e=r[t];i&&e&&!e[a]&&o.f(e,a,{configurable:!0,get:function(){return this}})}},function(t,e,n){"use strict";var r=n(2),o=n(16),i=n(54),a=n(55);n(56)("match",1,function(t,e,n,u){return[function(n){var r=t(this),o=null==n?void 0:n[e];return void 0!==o?o.call(n,r):new RegExp(n)[e](String(r))},function(t){var e=u(n,t,this);if(e.done)return e.value;var c=r(t),s=String(this);if(!c.global)return a(c,s);var l=c.unicode;c.lastIndex=0;for(var f,p=[],h=0;null!==(f=a(c,s));){var d=String(f[0]);p[h]=d,""===d&&(c.lastIndex=i(s,o(c.lastIndex),l)),h++}return 0===h?null:p}]})},function(t,e,n){"use strict";var r=n(39)(!0);t.exports=function(t,e,n){return e+(n?r(t,e).length:1)}},function(t,e,n){"use strict";var r=n(15),o=RegExp.prototype.exec;t.exports=function(t,e){var n=t.exec;if("function"==typeof n){var i=n.call(t,e);if("object"!=typeof i)throw new TypeError("RegExp exec method returned something other than an Object or null");return i}if("RegExp"!==r(t))throw new TypeError("RegExp#exec called on incompatible receiver");return o.call(t,e)}},function(t,e,n){"use strict";n(57);var r=n(14),o=n(10),i=n(13),a=n(17),u=n(1),c=n(27),s=u("species"),l=!i(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")}),f=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1]}();t.exports=function(t,e,n){var p=u(t),h=!i(function(){var e={};return e[p]=function(){return 7},7!=""[t](e)}),d=h?!i(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null},"split"===t&&(n.constructor={},n.constructor[s]=function(){return n}),n[p](""),!e}):void 0;if(!h||!d||"replace"===t&&!l||"split"===t&&!f){var v=/./[p],y=n(a,p,""[t],function(t,e,n,r,o){return e.exec===c?h&&!o?{done:!0,value:v.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),g=y[0],m=y[1];r(String.prototype,t,g),o(RegExp.prototype,p,2==e?function(t,e){return m.call(t,this,e)}:function(t){return m.call(t,this)})}}},function(t,e,n){"use strict";var r=n(27);n(9)({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r})},function(t,e,n){"use strict";var r=n(2);t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},function(t,e,n){"use strict";n.r(e);n(12),n(42);var r=n(29),o=n.n(r);n(24),n(53),n(28);function i(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function a(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var a=t.apply(e,n);function u(t){i(a,r,o,u,c,"next",t)}function c(t){i(a,r,o,u,c,"throw",t)}u(void 0)})}}function u(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;this.nodes.editorWrapper=document.getElementById("codex-editor"),e.page&&(this.page=e.page),this.loadEditor().then(function(e){t.editor=e}),this.nodes.saveButton=n.querySelector('[name="js-submit-save"]'),this.nodes.saveButton.addEventListener("click",function(){t.saveButtonClicked()}),this.nodes.removeButton=n.querySelector('[name="js-submit-remove"]'),this.nodes.removeButton&&this.nodes.removeButton.addEventListener("click",function(){window.confirm("Are you sure?")&&t.removeButtonClicked()}),this.nodes.parentIdSelector=n.querySelector('[name="parent"]'),this.nodes.putAboveIdSelector=n.querySelector('[name="above"]'),this.nodes.uriInput=n.querySelector('[name="uri-input"]')}},{key:"loadEditor",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,r,o;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.e(1).then(n.bind(null,105));case 2:return e=t.sent,r=e.default,o=this.page?{data:this.page.body}:{},t.abrupt("return",new r(o,{headerPlaceholder:"Enter a title"}));case 6:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"getData",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,n,r,o,i;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.editor.save();case 2:if(e=t.sent,n=e.blocks.length?e.blocks[0]:null,r=n&&"header"===n.type?n.data.text:null,o="",!this.nodes.uriInput||!this.nodes.uriInput.value){t.next=12;break}if(!this.nodes.uriInput.value.match(/^[a-z0-9'-]+$/i)){t.next=11;break}o=this.nodes.uriInput.value,t.next=12;break;case 11:throw new Error("Uri has unexpected characters");case 12:if(r){t.next=14;break}throw new Error("Entry should start with Header");case 14:return i=null,this.nodes.putAboveIdSelector&&(i=this.nodes.putAboveIdSelector.value),t.abrupt("return",{parent:this.nodes.parentIdSelector.value,putAbovePageId:i,uri:o,body:e});case 17:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"saveButtonClicked",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,n,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.getData();case 3:return e=t.sent,n=this.page?"/api/page/"+this.page._id:"/api/page",t.prev=5,t.next=8,fetch(n,{method:this.page?"POST":"PUT",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(e)});case 8:return r=t.sent,t.next=11,r.json();case 11:(r=t.sent).success?window.location.pathname=r.result.uri?r.result.uri:"/page/"+r.result._id:(alert(r.error),console.log("Validation failed:",r.error)),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(5),console.log("Saving request failed:",t.t0);case 18:t.next=24;break;case 20:t.prev=20,t.t1=t.catch(0),alert(t.t1),console.log("Saving error: ",t.t1);case 24:case"end":return t.stop()}},t,this,[[0,20],[5,15]])}));return function(){return t.apply(this,arguments)}}()},{key:"removeButtonClicked",value:function(){var t=a(regeneratorRuntime.mark(function t(){var e,n;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,e=this.page?"/api/page/"+this.page._id:"",t.next=4,fetch(e,{method:"DELETE"});case 4:return n=t.sent,t.next=7,n.json();case 7:(n=t.sent).success?n.result&&n.result._id?document.location="/page/"+n.result._id:document.location="/":(alert(n.error),console.log("Server fetch failed:",n.error)),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(0),console.log("Server fetch failed due to the:",t.t0);case 14:case"end":return t.stop()}},t,this,[[0,11]])}));return function(){return t.apply(this,arguments)}}()}])&&u(e.prototype,r),o&&u(e,o),t}();function s(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function l(t,e){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0],arguments.length>1&&arguments[1];this.codeStyler=this.createCodeStyling()}},{key:"createCodeStyling",value:function(){var t,e=(t=regeneratorRuntime.mark(function t(){var e,r;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.e(0).then(n.bind(null,106));case 2:return e=t.sent,r=e.default,t.abrupt("return",new r({selector:".block-code"}));case 5:case"end":return t.stop()}},t,this)}),function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){s(i,r,o,a,u,"next",t)}function u(t){s(i,r,o,a,u,"throw",t)}a(void 0)})});return function(){return e.apply(this,arguments)}}()}])&&l(e.prototype,r),o&&l(e,o),t}(),p=n(30),h=n.n(p);var d=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.misprints=new h.a({chatId:window.config.chatId})};function v(t,e){for(var n=0;n + {% include "components/header.twig" with res.locals.isAuthorized %}