14 lines
53 KiB
JavaScript
14 lines
53 KiB
JavaScript
|
|
||
|
/*
|
||
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
|
if you want to view the source, please visit the github repository of this plugin
|
||
|
*/
|
||
|
|
||
|
"use strict";var bt=Object.create;var se=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty;var xt=(i,e)=>{for(var n in e)se(i,n,{get:e[n],enumerable:!0})},Le=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of yt(e))!vt.call(i,o)&&o!==n&&se(i,o,{get:()=>e[o],enumerable:!(t=Ft(e,o))||t.enumerable});return i};var Ce=(i,e,n)=>(n=i!=null?bt(Et(i)):{},Le(e||!i||!i.__esModule?se(n,"default",{value:i,enumerable:!0}):n,i)),At=i=>Le(se({},"__esModule",{value:!0}),i);var Bt={};xt(Bt,{default:()=>Fe});module.exports=At(Bt);var u=require("obsidian");var _=require("obsidian");var G={actionDroppedFilesOnImport:"ASK_USER",actionPastedFilesOnImport:"ASK_USER",embedFilesOnImport:"ASK_USER",lastActionPastedFilesOnImport:"COPY",lastActionDroppedFilesOnImport:"COPY",lastEmbedFilesOnImport:"NO",multipleFilesImportType:"BULLETED",attachmentFolderLocation:"SUBFOLDER",attachmentFolderPath:"${notename} (attachments)",attachmentName:"${original}",dateFormat:"YYYY_MM_DDTHH_mm_ss",customDisplayText:!0,hideExtForDisplayText:!0,useSelectionForDisplayText:!0,autoRenameAttachmentFolder:!0,autoDeleteAttachmentFolder:!0,deleteAttachmentFolderWhenEmpty:!0,showDeleteMenu:!0,showDeleteMenuForEmbedded:!0,removeWikilinkOnFileDeletion:!0,confirmDeleteAttachmentFolder:!0,hideAttachmentFolders:!0,revealAttachment:!0,revealAttachmentExtExcluded:".md",openAttachmentExternal:!0,openAttachmentExternalExtExcluded:".md",logs:{},compatibility:"1.4.0"},{compatibility:Yt,attachmentFolderPath:jt,attachmentFolderLocation:Gt,...kt}=G,Me={...kt,relativeLocation:"SAME",folderPath:"${notename} (attachments)",linkFormat:"RELATIVE"};var K=(o=>(o.MOVE="MOVE",o.COPY="COPY",o.LINK="LINK",o.ASK_USER="ASK_USER",o))(K||{}),q=(t=>(t.YES="YES",t.NO="NO",t.ASK_USER="ASK_USER",t))(q||{}),Z=(t=>(t.BULLETED="BULLETED",t.NUMBERED="NUMBERED",t.INLINE="INLINE",t))(Z||{});var Ee={IMG:"image file",AUDIO:"audio file",VIDEO:"video file"};function Re(i){return i in Ee}function Ue(i){return typeof i!="object"||i===null?!1:"compatibility"in i&&i.compatibility===G.compatibility}function Ve(i){return typeof i=="boolean"}function ve(i){return i==="absolute"||i==="relative"||i==="shortest"}function Be(i){return i==="ROOT"||i==="CURRENT"||i==="FOLDER"||i==="SUBFOLDER"}function xe(i){if(typeof i!="object"||i===null||!("fileItems"in i))return!1;let e=i;return!(typeof e.fileItems!="object"||e.fileItems===null||!("fileBeingRenamed"in i))}function We(i){return typeof i!="object"||i===null?!1:!("compatibility"in i)}function Ke(i){return typeof i=="object"&&i!==null&&"setQuery"in i&&typeof i.setQuery=="function"}var ee=require("fs"),He=Ce(require("crypto"));var v=[];for(ae=0;ae<256;++ae)v.push((ae+256).toString(16).slice(1));var ae;function $e(i,e=0){return(v[i[e+0]]+v[i[e+1]]+v[i[e+2]]+v[i[e+3]]+"-"+v[i[e+4]]+v[i[e+5]]+"-"+v[i[e+6]]+v[i[e+7]]+"-"+v[i[e+8]]+v[i[e+9]]+"-"+v[i[e+10]]+v[i[e+11]]+v[i[e+12]]+v[i[e+13]]+v[i[e+14]]+v[i[e+15]]).toLowerCase()}var re,Dt=new Uint8Array(16);function Ae(){if(!re&&(re=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!re))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return re(Dt)}var _t=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ke={randomUUID:_t};function Pt(i,e,n){if(ke.randomUUID&&!e&&!i)return ke.randomUUID();i=i||{};var t=i.random||(i.rng||Ae)();if(t[6]=t[6]&15|64,t[8]=t[8]&63|128,e){n=n||0;for(var o=0;o<16;++o)e[n+o]=t[o];return e}return $e(t)}var le=Pt;var I=require("obsidian"),D=Ce(require("path"));function k(...i){return i.join("/")}function x(i){i=(0,I.normalizePath)(i);let e=i.lastIndexOf("/"),n=e!==-1?i.substring(0,e):"",t=e!==-1?i.substring(e+1):i,o=t.lastIndexOf("."),s=o!==-1?t.substring(0,o):t,a=o!==-1?t.substring(o):"";return{dir:n,base:t,filename:s,ext:a,path:i}}function Ye(i){i=(0,I.normalizePath)(i);let e=i.lastIndexOf("/"),n=e!==-1?i.substring(0,e):"",t=e!==-1?i.substring(e+1):i;return{dir:n,folde
|
||
|
`,c),n.setCursor({line:c.line+1,ch:0}));let r=e.length>1,h=e.map(async p=>{let w=p.path,b=await this.createAttachmentName(w,p,a),l=await te(this.app.vault,b),d=await Qe(this.vaultPath,w);if(d){if(l&&je(this.app.vault,d,b))return b;let F=new me(this,w,d,o.action);F.open();let y=await F.promise;if(y==null)return null;switch(y){case 2:return null;case 1:o.action="LINK";break;case 0:o.action="COPY";break}}if(l&&o.action!="LINK"){let F=new he(this,w,b);F.open();let y=await F.promise;if(y==null)return null;switch(y){case 0:break;case 1:b=ze(this.app.vault,b);break;case 2:return null}}try{switch(o.action){case"MOVE":return await Se.promises.rename(w,k(this.vaultPath,b)),b;case"COPY":return await Se.promises.copyFile(w,k(this.vaultPath,b)),b;case"LINK":default:return d}}catch(F){let y="Failed to process the file";return new u.Notice(y+"."),console.error(y+":",w,F),null}}),f=await Promise.all(h),g=0;if(f.forEach(p=>{p&&this.insertLinkToEditor(p,n,s.path,o,r?++g:void 0)}),g>0){let p="";switch(o.action){case"MOVE":p="Moved";break;case"COPY":p="Copied";break}new u.Notice(`${p} successfully ${g} files to the attachments folder.`)}}insertLinkToEditor(e,n,t,o,s){let a="",c="";if(s)switch(this.settings.multipleFilesImportType){case"BULLETED":a="- ",c=`
|
||
|
`;break;case"NUMBERED":a=`${s}. `,c=`
|
||
|
`;break;case"INLINE":s>1&&(a=`
|
||
|
|
||
|
`);break}let r=n.cm.state.selection.main,h=Xe(this.app.vault,e),f=h.name,g=(()=>{let E="";if(this.settings.customDisplayText&&(E=f+(this.settings.hideExtForDisplayText?"":h.extension)),!s&&this.settings.useSelectionForDisplayText){let oe=n.cm.state.doc.sliceString(r.from,r.to);oe.length>0&&(E=oe)}return E})(),p=this.app.fileManager.generateMarkdownLink(h,t,void 0,this.settings.customDisplayText?g:void 0),w=new RegExp("^(!)?(\\[[^\\]]*\\])(.*)$"),b=new RegExp("^(!)?(.*?)(|[^|]*)?$"),l=this.app.vault.getConfig("useMarkdownLinks"),d,F,y=!1;if(l){let E=p.match(w);d=p.length,F=p,E&&(d=1,F="["+g+"]"+E[3],y=!0)}else{let E=p.match(b);d=p.length,F=p,E&&(d=E[2].length,F=E[2]+(E[3]?E[3]:""),y=!0)}o.embed&&(a=a+"!");let R=a+F+c,J=n.getCursor("from"),j=n.getCursor("to");if(n.replaceRange(R,J,j),s==0)if(y){let E={line:j.line,ch:j.ch+d+a.length},oe={line:j.line,ch:E.ch+g.length};n.setSelection(E,oe)}else{let E={line:j.line,ch:j.ch+R.length};n.setCursor(E)}else{let E={line:J.line,ch:J.ch+R.length};n.setCursor(E)}}async open_attachments_folder_cb(){let e=this.app.workspace.getActiveFile();if(!e){console.error("Cannot open the attachment folder. The user must first select a markdown note.");return}let n=this.getAttachmentFolderOfMdNote(x(e.path));if(!ce(this.app.vault,n)){let o=new fe(this,n);if(o.open(),await o.promise==!1)return;await Te(this.app.vault,n)}let t=k(this.vaultPath,n);require("electron").remote.shell.openPath(O(t))}};
|
||
|
|
||
|
/* nosourcemap */
|