Spaces:
Runtime error
Runtime error
(function e(t,r,n){function a(o,s){if(!r[o]){if(!t[o]){var u=typeof require=="function"&&require;if(!s&&u)return u(o,!0);if(i)return i(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return a(r?r:e)},c,c.exports,e,t,r,n)}return r[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<n.length;o++)a(n[o]);return a})({1:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var n=e("./utils");var a="data-markdownx-upload-urls-path",i="data-markdownx-urls-path",o="data-markdownx-editor-resizable",s="data-markdownx-latency",u=500,l="Invalid response",c="0.3",d="1";var f={inhibitDefault:function(e){e.preventDefault();e.stopPropagation();return e},onDragEnter:function(e){e.dataTransfer.dropEffect="copy";return f.inhibitDefault(e)}};var p={keys:{TAB:"Tab",DUPLICATE:"d",UNINDENT:"[",INDENT:"]"},handlers:{applyTab:function(e){return e.value.substring(0,e.start)+(e.value.substring(e.start,e.end).match(/\n/gm)===null?"\t"+e.value.substring(e.start):e.value.substring(e.start,e.end).replace(/^/gm,"\t")+e.value.substring(e.end))},removeTab:function(e){var t=null,r=(e.value.substring(e.start,e.end).match(/\n/g)||[]).length;if(e.start===e.end){e.start=e.start>0&&e.value[e.start-1].match(/\t/)!==null?e.start-1:e.start;t=e.value.substring(e.start).replace("\t","")}else if(!r){t=e.value.substring(e.start).replace("\t","")}else{t=e.value.substring(e.start,e.end).replace(/^\t/gm,"")+e.value.substring(e.end)}return e.value.substring(0,e.start)+t},_multiLineIndentation:function(e){var t=new RegExp("(?:\n|.){0,"+e.end+"}(^.*$)","m").exec(e.value)[1];return e.value.substring(e.value.indexOf(new RegExp("(?:\n|.){0,"+e.start+"}(^.*$)","m").exec(e.value)[1]),e.value.indexOf(t)?e.value.indexOf(t)+t.length:e.end)},applyIndentation:function(e){if(e.start===e.end){var t=new RegExp("(?:\n|.){0,"+e.start+"}(^.+$)","m").exec(e.value)[1];return e.value.replace(t,"\t"+t)}var r=this._multiLineIndentation({start:e.start,end:e.end,value:e.value});return e.value.replace(r,r.replace(/(^.+$)\n*/gim,"\t$&"))},removeIndentation:function(e){if(e.start===e.end){var t=new RegExp("(?:\n|.){0,"+e.start+"}(^\t.+$)","m").exec(e.value)[1];return e.value.replace(t,t.substring(1))}var r=this._multiLineIndentation({start:e.start,end:e.end,value:e.value});return e.value.replace(r,r.replace(/^\t(.+)\n*$/gim,"$1"))},applyDuplication:function(e){if(e.start!==e.end)return e.value.substring(0,e.start)+e.value.substring(e.start,e.end)+(~e.value.charAt(e.start-1).indexOf("\n")||~e.value.charAt(e.start).indexOf("\n")?"\n":"")+e.value.substring(e.start,e.end)+e.value.substring(e.end);var t=new RegExp("(?:.|\n){0,160}(^.*$)","m"),r="";e.value.replace(t,function(e,t){return r+=t});return e.value.replace(r,r+"\n"+r)}},hub:function(e){switch(e.key){case this.keys.TAB:return e.shiftKey?this.handlers.removeTab:this.handlers.applyTab;case this.keys.DUPLICATE:return e.ctrlKey||e.metaKey?this.handlers.applyDuplication:false;case this.keys.INDENT:return e.ctrlKey||e.metaKey?this.handlers.applyIndentation:false;case this.keys.UNINDENT:return e.ctrlKey||e.metaKey?this.handlers.removeIndentation:false;default:return false}}};function v(e){return Math.max(parseInt(window.getComputedStyle(e).height),parseInt(e.style.height)||0)}function m(e){if(e.scrollTop)e.style.height=e.scrollTop+v(e)+"px";return e}var h=function(e,t,r){var v=this;var h={editor:t,preview:r,parent:e,_latency:null,_editorIsResizable:null};var g=function(){v.timeout=null;var e={object:document,listeners:[{type:"drop",capture:false,listener:f.inhibitDefault},{type:"dragover",capture:false,listener:f.inhibitDefault},{type:"dragenter",capture:false,listener:f.inhibitDefault},{type:"dragleave",capture:false,listener:f.inhibitDefault}]},t={object:h.editor,listeners:[{type:"drop",capture:false,listener:x},{type:"input",capture:true,listener:b},{type:"keydown",capture:true,listener:w},{type:"dragover",capture:false,listener:f.onDragEnter},{type:"dragenter",capture:false,listener:f.onDragEnter},{type:"dragleave",capture:false,listener:f.inhibitDefault},{type:"compositionstart",capture:true,listener:w}]};n.mountEvents(t,e);h.editor.setAttribute("data-markdownx-init","");h.editor.style.transition="opacity 1s ease";h.editor.style.webkitTransition="opacity 1s ease";h._latency=Math.max(parseInt(h.editor.getAttribute(s))||0,u);h._editorIsResizable=(h.editor.getAttribute(o).match(/true/i)||[]).length>0&&h.editor.offsetHeight>0&&h.editor.offsetWidth>0;T();n.triggerCustomEvent("markdownx.init")};var y=function(){clearTimeout(v.timeout);v.timeout=setTimeout(T,h._latency)};var b=function(){h.editor=h._editorIsResizable?m(h.editor):h.editor;return y()};var x=function(e){if(e.dataTransfer&&e.dataTransfer.files.length)Object.keys(e.dataTransfer.files).map(function(t){return E(e.dataTransfer.files[t])});f.inhibitDefault(e)};var w=function(e){var t=p.hub(e);if(typeof t!="function")return false;f.inhibitDefault(e);var r=h.editor.selectionStart;h.editor.value=t({start:h.editor.selectionStart,end:h.editor.selectionEnd,value:h.editor.value});y();h.editor.focus();h.editor.selectionEnd=h.editor.selectionStart=r;return false};var E=function(e){h.editor.style.opacity=c;var t=new n.Request(h.editor.getAttribute(a),n.preparePostData({image:e}));t.success=function(e){var t=JSON.parse(e);if(t.image_code){k(t.image_code);n.triggerCustomEvent("markdownx.fileUploadEnd",h.parent,[t])}else if(t.image_path){k('');n.triggerCustomEvent("markdownx.fileUploadEnd",h.parent,[t])}else{console.error(l,t);n.triggerCustomEvent("markdownx.fileUploadError",h.parent,[t]);k(l)}h.editor.style.opacity=d};t.error=function(e){console.error(e);h.editor.style.opacity=d};return t.send()};var T=function(){var e=new n.Request(h.editor.getAttribute(i),n.preparePostData({content:h.editor.value}));e.success=function(e){h.preview.innerHTML=e;h.editor=m(h.editor);n.triggerCustomEvent("markdownx.update",h.parent,[e])};e.error=function(e){console.error(e);n.triggerCustomEvent("markdownx.updateError",h.parent,[e])};return e.send()};var k=function(e){h.editor.value=""+h.editor.value.substring(0,h.editor.selectionStart)+e+(""+h.editor.value.substring(h.editor.selectionEnd));h.editor.selectionStart=h.editor.selectionEnd=h.editor.selectionStart+e.length;n.triggerEvent(h.editor,"keyup");b()};g()};r.MarkdownX=h;(function(e,t){e=e||"docReady";t=t||window;var r=[],n=false,a=false;var i=function(){if(!n){n=true;r.map(function(e){return e.fn.call(window,e.ctx)});r=[]}};var o=function(){return document.readyState==="complete"?i():null};t[e]=function(e,t){if(n){setTimeout(function(){return e(t)},1);return}else{r.push({fn:e,ctx:t})}if(document.readyState==="complete"){setTimeout(i,1)}else if(!a){document.addEventListener("DOMContentLoaded",i,false);window.addEventListener("load",i,false);a=true}}})("docReady",window);docReady(function(){var e=document.getElementsByClassName("markdownx");return Object.keys(e).map(function(t){var r=e[t],n=r.querySelector(".markdownx-editor"),a=r.querySelector(".markdownx-preview");if(!n.hasAttribute("data-markdownx-init"))return new h(r,n,a)})})},{"./utils":2}],2:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});function n(e){if(document.cookie&&document.cookie.length){var t=document.cookie.split(";").filter(function(t){return t.indexOf(e+"=")!==-1})[0];try{return decodeURIComponent(t.trim().substring(e.length+1))}catch(t){if(t instanceof TypeError){console.info('No cookie with key "'+e+'". Wrong name?');return null}throw t}}return null}r.getCookie=n;function a(){var e=[];for(var t=0;t<arguments.length;t++){e[t]=arguments[t]}if(e[0].constructor==Array)return e[0].slice().map(function(t,r){return e.map(function(e){return e[r]})});var r=e.map(function(e){return Object.keys(e).map(function(t){return e[t]})});return r[0].slice().map(function(e,t){return r.map(function(e){return e[t]})})}r.zip=a;function i(){var e=[];for(var t=0;t<arguments.length;t++){e[t]=arguments[t]}return e.map(function(e){return e.listeners.map(function(t){return e.object.addEventListener(t.type,t.listener,t.capture)})})}r.mountEvents=i;function o(e,t){if(t===void 0){t=true}var r=new FormData;if(t){var a=n("csrftoken");if(!a)a=document.querySelector("input[name='csrfmiddlewaretoken']").value;r.append("csrfmiddlewaretoken",a)}Object.keys(e).map(function(t){return r.append(t,e[t])});return r}r.preparePostData=o;function s(){if("XMLHttpRequest"in window)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}alert("Your browser belongs to history!");throw new TypeError("This browser does not support AJAX requests.")}var u=function(){function e(e,t){this.xhr=s();this.url=e;this.data=t}e.prototype.progress=function(e){if(e.lengthComputable)console.log(e.loaded/e.total*100+"% uploaded")};e.prototype.error=function(e){console.error(e)};e.prototype.success=function(e){console.info(e)};e.prototype.send=function(){var e=this;var t=this.success,r=this.error,n=this.progress;this.xhr.open("POST",this.url,true);this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");this.xhr.upload.onprogress=function(e){return n(e)};this.xhr.onerror=function(t){r(e.xhr.responseText)};this.xhr.onload=function(r){var n=null;if(e.xhr.readyState==XMLHttpRequest.DONE){if(!e.xhr.responseType||e.xhr.responseType==="text"){n=e.xhr.responseText}else if(e.xhr.responseType==="document"){n=e.xhr.responseXML}else{n=e.xhr.response}}t(n)};this.xhr.send(this.data)};return e}();r.Request=u;function l(e,t){var r=document.createEvent("HTMLEvents");r.initEvent(t,false,true);e.dispatchEvent(r)}r.triggerEvent=l;function c(e,t,r){if(t===void 0){t=document}if(r===void 0){r=null}var n=new CustomEvent(e,{detail:r});t.dispatchEvent(n)}r.triggerCustomEvent=c;function d(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}t.map(function(t){if(e.classList)e.classList.add(t);else{var r=e.className.split(" ");if(r.indexOf(t)<0)r.push(t);e.className=r.join(" ")}})}r.addClass=d;function f(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}t.map(function(t){if(e.classList)e.classList.remove(t);else{var r=e.className.split(" "),n=r.indexOf(t);if(n>-1)r.splice(n,1);e.className=r.join(" ")}})}r.removeClass=f},{}]},{},[1]); |