1
0
wiki/.obsidian/plugins/obsidian-excalidraw-plugin/main.js

5 lines
6.4 MiB
JavaScript
Raw Normal View History

2024-10-12 17:50:12 +08:00
"use strict";var obsidian_module=require("obsidian"),state=require("@codemirror/state"),view=require("@codemirror/view");var LZString=function(){var r=String.fromCharCode,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={};function t(r,o){if(!e[r]){e[r]={};for(var n=0;n<r.length;n++)e[r][r.charAt(n)]=n}return e[r][o]}var i={compressToBase64:function(r){if(null==r)return"";var n=i._compress(r,6,function(r){return o.charAt(r)});switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(r){return null==r?"":""==r?null:i._decompress(r.length,32,function(n){return t(o,r.charAt(n))})},compressToUTF16:function(o){return null==o?"":i._compress(o,15,function(o){return r(o+32)})+" "},decompressFromUTF16:function(r){return null==r?"":""==r?null:i._decompress(r.length,16384,function(o){return r.charCodeAt(o)-32})},compressToUint8Array:function(r){for(var o=i.compress(r),n=new Uint8Array(2*o.length),e=0,t=o.length;e<t;e++){var s=o.charCodeAt(e);n[2*e]=s>>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null==o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;e<t;e++)n[e]=256*o[2*e]+o[2*e+1];var s=[];return n.forEach(function(o){s.push(r(o))}),i.decompress(s.join(""))},compressToEncodedURIComponent:function(r){return null==r?"":i._compress(r,6,function(r){return n.charAt(r)})},decompressFromEncodedURIComponent:function(r){return null==r?"":""==r?null:(r=r.replace(/ /g,"+"),i._decompress(r.length,32,function(o){return t(n,r.charAt(o))}))},compress:function(o){return i._compress(o,16,function(o){return r(o)})},_compress:function(r,o,n){if(null==r)return"";var e,t,i,s={},u={},a="",p="",c="",l=2,f=3,h=2,d=[],m=0,v=0;for(i=0;i<r.length;i+=1)if(a=r.charAt(i),Object.prototype.hasOwnProperty.call(s,a)||(s[a]=f++,u[a]=!0),p=c+a,Object.prototype.hasOwnProperty.call(s,p))c=p;else{if(Object.prototype.hasOwnProperty.call(u,c)){if(c.charCodeAt(0)<256){for(e=0;e<h;e++)m<<=1,v==o-1?(v=0,d.push(n(m)),m=0):v++;for(t=c.charCodeAt(0),e=0;e<8;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;e<h;e++)m=m<<1|t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=c.charCodeAt(0),e=0;e<16;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++),s[p]=f++,c=String(a)}if(""!==c){if(Object.prototype.hasOwnProperty.call(u,c)){if(c.charCodeAt(0)<256){for(e=0;e<h;e++)m<<=1,v==o-1?(v=0,d.push(n(m)),m=0):v++;for(t=c.charCodeAt(0),e=0;e<8;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;e<h;e++)m=m<<1|t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=c.charCodeAt(0),e=0;e<16;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==o-1){d.push(n(m));break}v++}return d.join("")},decompress:function(r){return null==r?"":""==r?null:i._decompress(r.length,32768,function(o){return r.charCodeAt(o)})},_decompress:function(o,n,e){var t,i,s,u,a,p,c,l=[],f=4,h=4,d=3,m="",v=[],g={val:e(0),position:n,index:1};for(t=0;t<3;t+=1)l[t]=t;for(s=0,a=Math.pow(2,2),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;switch(s){case 0:for(s=0,a=Math.pow(2,8),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 1:for(s=0,a=Math.pow(2,16),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 2:return""}for(l[3]=c,i=c,v.push(c);;){if(g.index>o)return"";for(s=0,a=Math.pow(2,d),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.i
2024-10-14 16:48:38 +08:00
let EXCALIDRAW_PACKAGES = LZString.decompressFromBase64("PQKhCgAIUgBAbAlgYwKYDsDOrICVUCGyALlDAE6EkB0ADuQPYAmAriYg+tQLaJcBWmMmUgBhBrQCe5RAHMAFsUgAKZAEpIAMSKoARgwYBrADSQAkumTVIBdE0iJimGwDMXiJAWKpM1YdEgAFXlEZ0wGFnI0SGRmHFDIJDQsVHsWO1RySGJ5HABZM0DElAxsSBcIuwd0bNyRABkzUQBRADkAZWbyj3ianJxGBiUmREoSBnJJSAYXWoTwyOjiSlQ/aGBwZRd09k5lNQBvAHIWMsxllGIjgG4tneIOdFVjAA9DgCIGXX5UEneAXkBxEktFQM0gqBetAmTgAZLD3ukmKh3OhUu8AIRAkFg2bcZgseCoAD8L2UkOh5CcagAXO9tpYHpwAdjQeDkajUPCOXxVgRuExiTy0coANrvCkwzDvAC6r1p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LUwFBBSGIMkE8NYLMIcNCnxGINx2CO0IUIcMDlx0kGIKTBMMoPzAdwmGMGPANFCDyEqG8FxRDRv2jHP37HQGTVOVOU0AmDQAAFVdx9xkMY5+47Q8IMByjUBTl8AfFUAm4GiQ1nwYYw9WiyiKiej5ZejvBGjL9mjB5DgiZ2pExWUaBzJMA5B0BjA1xcJrgOx3whghgcQdtMBdQSBxBuBoQ0QZwtidiRwG5AZgdxjh1IN+jG1J4aUQxqxJltYK9HR3jx4C44wsQXQvlMZe9QV5DsBiAJjUBlBqBYTaRshAEfAbAagaVphZh20cB/In9dAiRnB5UwJ9xphlVyhBsOwQh5oFUNFoUUTIUlBwQMSEUZACAcSfA6FfJwB
2024-10-12 17:50:12 +08:00
let {react, reactDOM, excalidrawLib} = window.eval.call(window, `(function() {${EXCALIDRAW_PACKAGES};return {react: React, reactDOM: ReactDOM, excalidrawLib: ExcalidrawLib};})();`);
2024-10-14 16:48:38 +08:00
let PLUGIN_VERSION="2.5.2";;function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var obsidian_module__namespace=_interopNamespace(obsidian_module),React__namespace=_interopNamespace(React);let random$1=e=>crypto.getRandomValues(new Uint8Array(e)),customRandom=(e,t,n)=>{let r=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*r*t/e.length);return(a=t)=>{let o="";for(;;){let t=n(i),s=i;for(;s--;)if(o+=e[t[s]&r]||"",o.length===a)return o}}},customAlphabet=(e,t=21)=>customRandom(e,t,random$1),nanoid$1=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce(((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")),""),EXCALIDRAW_PLUGIN=null;const setExcalidrawPlugin=e=>{EXCALIDRAW_PLUGIN=e},THEME={LIGHT:"light",DARK:"dark"},MD_EXCALIDRAW="# Excalidraw Data",MD_TEXTELEMENTS="## Text Elements",MD_ELEMENTLINKS="## Element Links",MD_EMBEDFILES="## Embedded Files",MD_DRAWING="## Drawing",MD_EX_SECTIONS=[MD_EXCALIDRAW,MD_TEXTELEMENTS,MD_ELEMENTLINKS,MD_EMBEDFILES,MD_DRAWING],ERROR_IFRAME_CONVERSION_CANCELED="iframe conversion canceled",LOCALE=obsidian_module.moment.locale(),obsidianToExcalidrawMap={en:"en-US",af:"af-ZA",am:"am-ET",ar:"ar-SA",eu:"eu-ES",be:"be-BY",bg:"bg-BG",bn:"bn-BD",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",el:"el-GR",eo:"eo-EO",es:"es-ES",fa:"fa-IR","fi-fi":"fi-FI",fr:"fr-FR",gl:"gl-ES",he:"he-IL",hi:"hi-IN",hu:"hu-HU",id:"id-ID",it:"it-IT",ja:"ja-JP",ko:"ko-KR",lv:"lv-LV",ml:"ml-IN",ms:"ms-MY",nl:"nl-NL",no:"nb-NO",oc:"oc-FR",pl:"pl-PL",pt:"pt-PT","pt-BR":"pt-BR",ro:"ro-RO",ru:"ru-RU",sr:"sr-RS",se:"sv-SE",sk:"sk-SK",sq:"sq-AL",ta:"ta-IN",te:"te-IN",th:"th-TH",tr:"tr-TR",uk:"uk-UA",ur:"ur-PK",vi:"vi-VN",zh:"zh-CN","zh-TW":"zh-TW"},{sceneCoordsToViewportCoords:sceneCoordsToViewportCoords,viewportCoordsToSceneCoords:viewportCoordsToSceneCoords,determineFocusDistance:determineFocusDistance,intersectElementWithLine:intersectElementWithLine,getCommonBoundingBox:getCommonBoundingBox,getMaximumGroups:getMaximumGroups,measureText:measureText,getLineHeight:getLineHeight,wrapText:wrapText,getFontString:getFontString,getBoundTextMaxWidth:getBoundTextMaxWidth,exportToSvg:exportToSvg,exportToBlob:exportToBlob,mutateElement:mutateElement,restore:restore,mermaidToExcalidraw:mermaidToExcalidraw,getFontFamilyString:getFontFamilyString,getContainerElement:getContainerElement,refreshTextDimensions:refreshTextDimensions,getCSSFontDefinition:getCSSFontDefinition}=excalidrawLib,FONTS_STYLE_ID="excalidraw-custom-fonts";function JSON_parse(e){return JSON.parse(e.replaceAll("&#91;","["))}/Mac|iPod|iPhone|iPad/.test(window.navigator.platform);const DEVICE={isDesktop:!document.body.hasClass("is-tablet")&&!document.body.hasClass("is-mobile"),isPhone:document.body.hasClass("is-phone"),isTablet:document.body.hasClass("is-tablet"),isMobile:document.body.hasClass("is-mobile"),isLinux:document.body.hasClass("mod-linux")&&!document.body.hasClass("is-android"),isMacOS:document.body.hasClass("mod-macos")&&!document.body.hasClass("is-ios"),isWindows:document.body.hasClass("mod-windows"),isIOS:document.body.hasClass("is-ios"),isAndroid:document.body.hasClass("is-android")},ROOTELEMENTSIZE=(()=>{const e=document.createElement("div");e.style.fontSize="1rem",e.style.display="none",document.body.appendChild(e);const t=getComputedStyle(e),n=parseFloat(t.fontSize);return document.body.removeChild(e),n})(),nanoid=customAlphabet("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",8),KEYCODE={ESC:27},ROUNDNESS={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},THEME_FILTER="invert(100%) hue-rotate(180deg) saturate(1.25)",GITHUB_RELEASES="https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/",URLFETCHTIMEOUT=3e3,PLUGIN_ID="obsidian-excalidraw-plugin",SCRIPT_INSTALL_CODEBLOCK="excalidraw-script-install",SCRIPT_INSTALL_FOLDER="Downloaded",fileid=customAlp