vault backup: 2025-08-10 15:31:01

This commit is contained in:
CrazyJasonwell committed 2025-08-10 15:31:01 +08:00
1 parent 5464b54e15
commit 84bbe657c6
6 files changed
+59 -4

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@
"contentTemplate": "# {{{title}}}\n\n{{{description}}}\n\n{{{article_title}}} //文章内容标题\n{{{content}}} //文章正文\n\n\n[Read in Cubox]({{{cubox_url}}}) \n[Read Original]({{{url}}}) \n\n---\n\n{{#highlights.length}}\n## Annotations \n\n{{#highlights}}\n> {{{text}}} \n\n{{#note}}\n{{{note}}}\n{{/note}}\n[Link️]({{{cubox_url}}}) \n\n{{/highlights}}\n{{/highlights.length}}",
"highlightInContent": true,
"dateFormat": "yyyy-MM-dd",
"lastSyncTime": 1754808428611,
"lastSyncTime": 1754810187601,
"lastSyncCardId": "7350452026397950547",
"lastCardUpdateTime": "2025-08-09T15:46:52.780+0800",
"syncing": false
+34
View File
@@ -0,0 +1,34 @@
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source visit the plugins github repository (https://github.com/Vinzent03/obsidian-advanced-uri)
*/
var ze=Object.create;var Y=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Ue=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Ne=(a,n)=>()=>(n||a((n={exports:{}}).exports,n),n.exports),We=(a,n)=>{for(var e in n)Y(a,e,{get:n[e],enumerable:!0})},fe=(a,n,e,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of De(n))!He.call(a,i)&&i!==e&&Y(a,i,{get:()=>n[i],enumerable:!(t=Le(n,i))||t.enumerable});return a};var Be=(a,n,e)=>(e=a!=null?ze(Ue(a)):{},fe(n||!a||!a.__esModule?Y(e,"default",{value:a,enumerable:!0}):e,a)),$e=a=>fe(Y({},"__esModule",{value:!0}),a);var ge=Ne((H,ae)=>{(function(n,e){typeof H=="object"&&typeof ae=="object"?ae.exports=e():typeof define=="function"&&define.amd?define([],e):typeof H=="object"?H.feather=e():n.feather=e()})(typeof self!="undefined"?self:H,function(){return function(a){var n={};function e(t){if(n[t])return n[t].exports;var i=n[t]={i:t,l:!1,exports:{}};return a[t].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=a,e.c=n,e.d=function(t,i,o){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:o})},e.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},e.p="",e(e.s=0)}({"./dist/icons.json":function(a){a.exports={activity:'<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>',airplay:'<path d="M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1"></path><polygon points="12 15 17 21 7 21 12 15"></polygon>',"alert-circle":'<circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line>',"alert-octagon":'<polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"></polygon><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line>',"alert-triangle":'<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line>',"align-center":'<line x1="18" y1="10" x2="6" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="18" y1="18" x2="6" y2="18"></line>',"align-justify":'<line x1="21" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="21" y1="18" x2="3" y2="18"></line>',"align-left":'<line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line>',"align-right":'<line x1="21" y1="10" x2="7" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="21" y1="18" x2="7" y2="18"></line>',anchor:'<circle cx="12" cy="5" r="3"></circle><line x1="12" y1="22" x2="12" y2="8"></line><path d="M5 12H2a10 10 0 0 0 20 0h-3"></path>',aperture:'<circle cx="12" cy="12" r="10"></circle><line x1="14.31" y1="8" x2="20.05" y2="17.94"></line><line x1="9.69" y1="8" x2="21.17" y2="8"></line><line x1="7.38" y1="12" x2="13.12" y2="2.06"></line><line x1="9.69" y1="16" x2="3.95" y2="6.06"></line><line x1="14.31" y1="16" x2="2.83" y2="16"></line><line x1="16.62" y1="12" x2="10.88" y2="21.94"></line>',archive:'<polyline points="21 8 21 21 3 21 3 8"></polyline><rect x="1" y="3" width="22" height="5"></rect><line x1="10" y1="12" x2="14" y2="12"></line>',"arrow-down-circle":'<circle cx="12" cy="12" r="10"></circle><polyline points="8 12 12 16 16 12"></polyline><line x1="12" y1="8" x2="12" y2="16"></line>',"arrow-down-left":'<line x1="17" y1="7" x2="7" y2="17"></line><polyline points="17 17 7 17 7 7"></polyline>',"arrow-down-right":'<line x1="7" y1="7" x2="17" y2="17"></line><polyline points="17 7 17 17 7 17"></polyline>',"arrow-down":'<line x1="12" y1="5" x2="12" y2="19"></line><polyline points="19 12 12 19 5 12"></polyline>',"arrow-left-circle":'<circle cx="12" cy="12" r="10"></circle><polyline points="12 8 8 12 12 16"></polyline><line x1="16" y1="12" x2="8" y2="12"></line>',"arrow-left":'<line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline>',"arrow-right-circle":'<circle cx="12" cy="12" r="10"></circle><polyline points="12 16 16 12 12 8"></polyline><line x1="8" y1="12" x2="16" y2="12"></line>',"arrow-right":'<line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline>',"arrow-up-circle":'<circle cx="12" cy="12" r="10"></circle><polyline points="16 12 12 8 8 12"></polyline><line x1="12" y1="16" x2="12" y2="8"></line>',"arrow-up-left":'<line x1="17" y1="17" x2="7" y2="7"></line><polyline points="7 17 7 7 17 7"></polyline>',"arrow-up-right":'<line x1="7" y1="17" x2="17" y2="7"></line><polylineLine truncated
`:" ";return n.replaceRange(`${s}^${l}`,o),l}static shouldInsertAfter(n){if(n.type)return["blockquote","code","table","heading","comment","footnoteDefinition"].includes(n.type)}static getBlockId(n){let e=n.workspace.getActiveViewOfType(xe.MarkdownView);if(e){let t=e.editor,i=e.file,o=this.getBlock(n,t,i);if(o)return this.getIdOfBlock(t,o)}}};var me={openFileOnWrite:!0,openDailyInNewPane:!1,openFileOnWriteInNewPane:!1,openFileWithoutWriteInNewPane:!1,idField:"id",useUID:!1,addFilepathWhenUsingUID:!1,allowEval:!1,includeVaultName:!0,vaultParam:"name"};var ve=require("obsidian");function je(a){let n=a.internalPlugins.plugins["daily-notes"];if(n&&n.enabled)return!0}function Ge(...a){let n=[];for(let t=0,i=a.length;t<i;t++)n=n.concat(a[t].split("/"));let e=[];for(let t=0,i=n.length;t<i;t++){let o=n[t];!o||o==="."||e.push(o)}return n[0]===""&&e.unshift(""),e.join("/")}async function we(a,n){let{format:e,folder:t}=n.internalPlugins.getEnabledPluginById("daily-notes").options,i=a.format(e);return i.endsWith(".md")||(i+=".md"),(0,ve.normalizePath)(Ge(t,i))}var v=require("obsidian");var be=require("obsidian"),L=class extends be.SuggestModal{constructor(e,t){super(e.app);this.file=t;this.modes=[null,"overwrite","append","prepend"];this.plugin=e,this.setPlaceholder("Type your data to be written to the file or leave it empty to just open it")}getSuggestions(e){e==""&&(e=null);let t=[];for(let i of this.modes)if(!(i==="overwrite"&&!e)){let o;e?i?o=`Write "${e}" in ${i} mode`:o=`Write "${e}"`:i?o=`Open in ${i} mode`:o="Open",t.push({data:e,display:o,mode:i,func:()=>{this.file?this.plugin.tools.copyURI({filepath:this.file,data:e,mode:i}):this.plugin.tools.copyURI({daily:"true",data:e,mode:i})}})}return t}renderSuggestion(e,t){t.innerText=e.display}onChooseSuggestion(e,t){e.func()}};var Me=require("obsidian"),R=class extends Me.FuzzySuggestModal{constructor(e,t,i=!0){super(e.app);this.placeHolder=t;this.allowNoFile=i;this.plugin=e,this.setPlaceholder(this.placeHolder)}getItems(){let e=[];this.allowNoFile&&e.push({display:"<Don't specify a file>",source:void 0});let t=this.app.workspace.getActiveFile();return t&&e.push({display:"<Current file>",source:t.path}),[...e,...this.app.vault.getFiles().map(i=>({display:i.path,source:i.path}))]}getItemText(e){return e.display}onChooseItem(e,t){}};var Ae=require("obsidian");function se(a){return a.viewmode?{state:{mode:a.viewmode,source:a.viewmode=="source"}}:void 0}function W(a){return navigator.clipboard.writeText(a)}function J(a,n){var o;let e=(o=n.parent)==null?void 0:o.path,t=e==="/"?"":e,i=n.name;for(let l=1;l<100;l++){let s=N(i),r=t+(t==""?"":"/")+s+` ${l}.md`;if(!(a.vault.getAbstractFileByPath(r)!==null))return r}}function Ie(a,n){let e=new URL(a.vault.getResourcePath(n));return e.host="localhosthostlocal",e.protocol="file",e.search="",e.pathname=decodeURIComponent(e.pathname),e.toString().replace("/localhosthostlocal/","/")}function re(a,n,e){var l,s;let t=a.metadataCache.getFileCache(n),i=t.sections,o=(l=t.headings)==null?void 0:l.find(r=>r.heading===e);if(o){let r=i.findIndex(u=>u.type==="heading"&&u.position.start.line===o.position.start.line),c=i.slice(r+1),d=c==null?void 0:c.findIndex(u=>u.type==="heading");return{lastLine:((s=c[(d!==-1?d:c.length)-1])!=null?s:i[r]).position.end.line+1,firstLine:i[r].position.end.line+1}}else new Ae.Notice("Can't find heading")}var D=class extends Error{constructor(e,t,i){super(e);this.name="KeyPathError",this.errKey=t,i&&(this.cause=i)}};function Fe(a){let{originalObject:n,key:e,data:t}=a;if(e.startsWith("[")&&e.endsWith("]")){let i=e.substring(1,e.length-1).split(","),o=n;for(let l=0;l<i.length;l++){let s=i[l],r;if(o instanceof Array){if(r=parseInt(s),Number.isNaN(r)&&(r=o.find(p=>p==s)),r===void 0)throw new D(`Failed to resolve or convert "${s}" to a valid array index.`,s);r=Math.min(r,o.length),r=Math.max(r,-1)}if(l==i.length-1){o instanceof Array?r===-1?o.unshift(t):o[r]=t:o[s]=t;return}let d=!Number.isNaN(parseInt(i[l+1]))?[]:{};try{o instanceof Array?r>=o.length?(o.push(d),o=d):r===-1?(o.unshift(d),o=d):o=o[Math.max(r,0)]:o[s]===void 0?(o[s]=d,o=d):o=o[s]}catch(p){throw new D(`Failed to resolve "${s}" as a valid object key`,s,p)}}}else n[e]=t}function Pe(a){let{obj:n,key:e}=a;if(e.startsWith("[")&&e.endsWith("]")){let t=e.substring(1,e.length-1).split(","),i=n;for(let o of t)if(i instanceof Array){let l=parseInt(o);Number.isNaN(l)?i=i.find(s=>s==o):i=i[l]}else if(i&&typeof i=="object")i=i[o];else return;return i}else return n?n[e]:void 0}var B=class{constructor(n){this.plugin=n;this.app=this.plugin.app}get tools(){return this.plugin.tools}handlePluginManagement(n){if(n["enable-plugin"]){let e=n["enable-plugin"];e in this.app.plugins.manifests&&!this.app.plugins.getPlugin(e)?(this.app.plugins.enablePluginAndSave(e),new v.Notice(`Enabled ${e}`)):this.app.internalPlugins.plugins[e]&&(this.app.internalPlugins.plugins[e].enable(!0),new v.Notice(`Enabled ${e}`))}else if(n["disable-plugin"]){let e=n["disable-plugin"];this.app.plugins.ge Line truncated
${r.message}`):new v.Notice("Failed to update frontmatter, check console for more details")}});return}W(Pe({obj:i,key:e}))}handleWorkspace(n){let e=this.app.internalPlugins.getEnabledPluginById("workspaces");if(!e)new v.Notice("Workspaces plugin is not enabled"),this.plugin.failure(n);else{if(n.saveworkspace=="true"){let t=e.activeWorkspace;e.saveWorkspace(t),new v.Notice(`Saved current workspace to ${t}`)}n.clipboard&&n.clipboard!="false"?this.tools.copyURI({workspace:e.activeWorkspace}):n.workspace!=null&&e.loadWorkspace(n.workspace),this.plugin.success(n)}}async handleCommand(n){if(n.filepath)if(n.mode){if(n.mode=="new"){let t=this.app.metadataCache.getFirstLinkpathDest(n.filepath,"/");t instanceof v.TFile&&(n.filepath=J(this.app,t))}await this.plugin.open({file:n.filepath,mode:"source",parameters:n});let e=this.app.workspace.getActiveViewOfType(v.MarkdownView);if(e){let t=e.editor,i=t.getValue();if(n.mode==="append"){t.setValue(i+`
`);let o=t.lineCount();t.setCursor({ch:0,line:o})}else n.mode==="prepend"?(t.setValue(`
`+i),t.setCursor({ch:0,line:0})):n.mode==="overwrite"&&t.setValue("")}}else n.line!=null||n.column!=null||n.offset!=null?(await this.plugin.open({file:n.filepath,mode:"source",parameters:n}),await this.plugin.setCursorInLine(n)):await this.plugin.open({file:n.filepath,setting:this.plugin.settings.openFileWithoutWriteInNewPane,parameters:n});else(n.openmode||n.viewmode)&&await this.plugin.open({parameters:n});if(n.commandid)this.app.commands.executeCommandById(n.commandid);else if(n.commandname){let e=this.app.commands.commands;for(let t in e)if(e[t].name===n.commandname){e[t].callback?await e[t].callback():e[t].checkCallback(!1);break}}if(n.confirm&&n.confirm!="false"){await new Promise(t=>setTimeout(t,750));let e=document.querySelector(".mod-cta:not([style*='display: none'])");e.click instanceof Function&&e.click()}this.plugin.success(n)}async handleEval(n){if(n.filepath)if(n.mode){if(n.mode=="new"){let t=this.app.metadataCache.getFirstLinkpathDest(n.filepath,"/");t instanceof v.TFile&&(n.filepath=J(this.app,t))}await this.plugin.open({file:n.filepath,mode:"source",parameters:n});let e=this.app.workspace.getActiveViewOfType(v.MarkdownView);if(e){let t=e.editor,i=t.getValue();if(n.mode==="append"){t.setValue(i+`
`);let o=t.lineCount();t.setCursor({ch:0,line:o})}else n.mode==="prepend"?(t.setValue(`
`+i),t.setCursor({ch:0,line:0})):n.mode==="overwrite"&&t.setValue("")}}else n.line!=null||n.column!=null||n.offset!=null?(await this.plugin.open({file:n.filepath,mode:"source",parameters:n}),await this.plugin.setCursorInLine(n)):await this.plugin.open({file:n.filepath,setting:this.plugin.settings.openFileWithoutWriteInNewPane,parameters:n});this.plugin.settings.allowEval?((0,eval)(n.eval),this.plugin.success(n)):(new v.Notice("Eval is not allowed. Please enable it in the settings."),this.plugin.failure(n))}async handleDoesFileExist(n){let e=await this.app.vault.adapter.exists(n.filepath);W((e?1:0).toString()),this.plugin.success(n)}async handleSearchAndReplace(n){let e;if(n.filepath){let t=this.app.vault.getAbstractFileByPath(n.filepath);t instanceof v.TFile&&(e=t)}else e=this.app.workspace.getActiveFile();if(e){let t=await this.app.vault.read(e);if(n.searchregex)try{let[,,i,o]=n.searchregex.match(/(\/?)(.+)\1([a-z]*)/i),l=new RegExp(i,o);t=t.replace(l,n.replace),this.plugin.success(n)}catch(i){new v.Notice(`Can't parse ${n.searchregex} as RegEx`),this.plugin.failure(n)}else t=t.replaceAll(n.search,n.replace),this.plugin.success(n);await this.plugin.writeAndOpenFile(e.path,t,n)}else new v.Notice("Cannot find file"),this.plugin.failure(n)}async handleSearch(n){n.filepath&&await this.plugin.open({file:n.filepath,parameters:n});let e=this.app.workspace.getActiveViewOfType(v.FileView);e.currentMode.showSearch();let t=e.currentMode.search;t.searchInputEl.value=n.search,t.searchInputEl.dispatchEvent(new Event("input"))}async handleWrite(n,e=!1){var i;let t;if(n.filepath?t=this.app.vault.getAbstractFileByPath(n.filepath):t=this.app.workspace.getActiveFile(),n.filepath||t){let o,l=(i=n.filepath)!=null?i:t.path;n.mode==="overwrite"?(o=await this.plugin.writeAndOpenFile(l,n.data,n),this.plugin.success(n)):n.mode==="prepend"?(t instanceof v.TFile?o=await this.plugin.prepend(t,n):o=await this.plugin.prepend(l,n),this.plugin.success(n)):n.mode==="append"?(t instanceof v.TFile?o=await this.plugin.append(t,n):o=await this.plugin.append(l,n),this.plugin.success(n)):n.mode==="new"?t instanceof v.TFile?(o=await this.plugin.writeAndOpenFile(J(this.app,t),n.data,n),this.plugin.hookSuccess(n,o)):(o=await this.plugin.writeAndOpenFile(l,n.data,n),this.plugin.hookSuccess(n,o)):!e&&t instanceof v.TFile?(new v.Notice("File already exists"),this.plugin.openExistingFileAndSetCursor(t.path,n),this.plugin.failure(n)):(o=await this.plugin.writeAndOpenFile(l,n.data,n),this.plugin.success(n)),n.uid&&this.tools.writeUIDToFile(o,n.uid)}else new v.Notice("Cannot find file"),this.plugin.failure(n)}async handleOpen(n){if(n.heading!=null){await this.plugin.open({file:n.filepath+"#"+n.heading,setting:this.plugin.settings.openFileWithoutWriteInNewPane,parameters:n});let e=this.app.workspace.getActiveViewOfType(v.MarkdownView);if(!e)return;let i=this.app.metadataCache.getFileCache(e.file).headings.find(o=>o.heading===n.heading);e.editor.focus(),e.editor.setCursor({line:i.position.start.line+1,ch:0})}else if(n.block!=null){await this.plugin.open({file:n.filepath+"#^"+n.block,setting:this.plugin.settings.openFileWithoutWriteInNewPane,parameters:n});let e=this.app.workspace.getActiveViewOfType(v.MarkdownView);if(!e)return;let i=this.app.metadataCache.getFileCache(e.file).blocks[n.block.toLowerCase()];e.editor.focus(),i&&e.editor.setCursor({line:i.position.start.line,ch:0})}else await this.plugin.open({file:n.filepath,setting:this.plugin.settings.openFileWithoutWriteInNewPane,parameters:n}),(n.line!=null||n.column!=null||n.offset!=null)&&await this.plugin.setCursorInLine(n);if(n.mode!=null&&await this.plugin.setCursor(n),n.uid){let e=this.app.workspace.getActiveViewOfType(v.MarkdownView);this.tools.writeUIDToFile(e.file,n.uid)}this.plugin.success(n)}async handleOpenBlock(n){let e=this.tools.getFileFromBlockID(n.block);e&&await this.plugin.chooseHandler({...n,filepath:e.path},!1)}handleCopyFileURI(n,e){let t=this.app.workspace.getActiveViewOfType(v.FileView);if(!(!t&&!e)){if(t instanceof v.MarkdownView){let i=t.editor.getCursor(),o=this.app.metadataCache.getFileCache(t.file);if(o.headings){for(let l of o.headings)if(l.position.start.line<=i.line&&l.position.end.line>=i.line){this.tools.copyURI({filepath:t.file.path,heading:l.heading});return}}if(o.blocks)for(let l of Object.keys(o.blocks)){let s=o.blocks[l];if(s.position.start.line<=i.line&&s.position.end.line>=i.line){this.tools.copyURI({filepath:t.file.path,block:s.id});return}}}if(n){let i=e!=null?e:this.app.workspace.getActiveFile();if(!i){new v.Notice("No file opened");return}this.tools.copyURI({filepath:i.path})}else{let i=new R(this.plugin,"Choose a file",!1);i.open(),i.onChooseItem=(o,l)=>{new L(this.plugin,o.source).open()}}}}handleOpenSettings(n){if(this.app.setting.containerEl.parentElement===null&&this.app.setting.open(),n.settingid=="plugin-browser"?(this.app.setting.openTabById("community-plugins"),this.app.setting.activeTab.containerEl.find(".mod-cta").click()):n.settingid=="theme-browse Line truncated
`),s=`${this.plugin.settings.idField}:`;if(o)l.unshift("---"),l.unshift(`${s} ${e}`),l.unshift("---");else{let d=l.findIndex(p=>p.startsWith(s));d!=-1?l[d]=`${s} ${e}`:l.splice(1,0,`${s} ${e}`)}let r=l.join(`
`);return await this.app.vault.modify(n,r),e}async getUIDFromFile(n){var i;let e=(i=this.app.metadataCache.getFileCache(n))!=null?i:await new Promise(o=>{let l=this.app.metadataCache.on("changed",s=>{if(s.path==n.path){let r=this.app.metadataCache.getFileCache(n);this.app.metadataCache.offref(l),o(r)}})}),t=(0,V.parseFrontMatterEntry)(e.frontmatter,this.plugin.settings.idField);return t!=null?t instanceof Array?t[0]:t:await this.writeUIDToFile(n,de())}async generateURI(n){let e="obsidian://adv-uri",t="",i=this.app.vault.getAbstractFileByPath(n.filepath);this.settings.includeVaultName&&(t+="?vault=",this.settings.vaultParam=="id"&&this.app.appId?t+=encodeURIComponent(this.app.appId):t+=encodeURIComponent(this.app.vault.getName())),this.settings.useUID&&i instanceof V.TFile&&i.extension=="md"&&(this.settings.addFilepathWhenUsingUID||(n.filepath=void 0),n.uid=await this.getUIDFromFile(i));let o=Object.keys(n).filter(l=>n[l]).sort((l,s)=>{let r=["filepath","filename","uid","daily"],c=["data","eval"];return r.includes(l)?-1:r.includes(s)||c.includes(l)?1:c.includes(s)?-1:0});for(let l of o)n[l]!=null&&(t+=t?"&":"?",t+=`${l}=${encodeURIComponent(n[l])}`);return t.endsWith("%20")&&(t+="&"),e+t}async copyURI(n){let e=await this.generateURI(n);await W(e),new V.Notice("Advanced URI copied to your clipboard")}getFileFromUID(n){var i;let e=this.app.vault.getMarkdownFiles(),t=this.settings.idField;for(let o of e){let l=(0,V.parseFrontMatterEntry)((i=this.app.metadataCache.getFileCache(o))==null?void 0:i.frontmatter,t);if(l instanceof Array){if(l.contains(n))return o}else if(l==n)return o}}getFileFromBlockID(n){var t,i;let e=this.app.vault.getMarkdownFiles();n=n.toLowerCase();for(let o of e)if(((i=(t=this.app.metadataCache.getFileCache(o))==null?void 0:t.blocks)==null?void 0:i[n])!=null)return o}};var ie=require("obsidian"),ne=class extends ie.FuzzySuggestModal{constructor(e){super(e.app);this.plugin=e,this.setPlaceholder("Choose a workspace")}getItems(){let e=this.app.internalPlugins.getEnabledPluginById("workspaces");if(!e)new ie.Notice("Workspaces plugin is not enabled");else return Object.keys(e.workspaces)}getItemText(e){return e}onChooseItem(e,t){this.plugin.tools.copyURI({workspace:e})}};var oe=class extends w.Plugin{constructor(){super(...arguments);this.handlers=new B(this);this.tools=new $(this)}async onload(){await this.loadSettings(),this.addSettingTab(new _(this.app,this)),this.addCommand({id:"copy-uri-current-file",name:"Copy URI for file with options",callback:()=>this.handlers.handleCopyFileURI(!1)}),this.addCommand({id:"copy-uri-current-file-simple",name:"Copy URI for current file",callback:()=>this.handlers.handleCopyFileURI(!0)}),this.addCommand({id:"copy-uri-daily",name:"Copy URI for daily note",callback:()=>new L(this).open()}),this.addCommand({id:"copy-uri-search-and-replace",name:"Copy URI for search and replace",callback:()=>{let e=new R(this,"Used file for search and replace");e.open(),e.onChooseItem=t=>{let i=new q(this);i.open(),i.onChooseSuggestion=o=>{new X(this,o,t==null?void 0:t.source).open()}}}}),this.addCommand({id:"copy-uri-command",name:"Copy URI for command",callback:()=>{let e=new R(this,"Select a file to be opened before executing the command");e.open(),e.onChooseItem=t=>{new Q(this,t==null?void 0:t.source).open()}}}),this.addCommand({id:"copy-uri-block",name:"Copy URI for current block",checkCallback:e=>{let t=this.app.workspace.getActiveViewOfType(w.MarkdownView);if(e)return t!=null;let i=Z.getBlockId(this.app);i&&this.tools.copyURI({filepath:t.file.path,block:i})}}),this.addCommand({id:"copy-uri-workspace",name:"Copy URI for workspace",callback:()=>{new ne(this).open()}}),this.addCommand({id:"copy-uri-canvas-node",name:"Copy URI for selected canvas nodes",checkCallback:e=>{let t=this.app.workspace.activeLeaf.view;if(e)return t.getViewType()==="canvas"&&t.canvas.selection.size>0;if(t.getViewType()!=="canvas")return!1;let i=t,o=[];i.canvas.selection.forEach(l=>{o.push(l.id)}),this.tools.copyURI({canvasnodes:o.join(","),filepath:t.file.path})}}),this.addCommand({id:"copy-uri-canvas-viewport",name:"Copy URI for current canvas viewport",checkCallback:e=>{let t=this.app.workspace.activeLeaf.view;if(e)return t.getViewType()==="canvas";if(t.getViewType()!=="canvas")return!1;let o=t.canvas,l=o.tx.toFixed(0),s=o.ty.toFixed(0),r=o.tZoom.toFixed(3);this.tools.copyURI({filepath:t.file.path,canvasviewport:`${l},${s},${r}`})}}),this.registerObsidianProtocolHandler("advanced-uri",async e=>{let t=e;for(let i in t)t[i]=decodeURIComponent(t[i]);this.onUriCall(t)}),this.registerObsidianProtocolHandler("adv-uri",async e=>{let t=e;this.onUriCall(t)}),this.registerObsidianProtocolHandler("hook-get-advanced-uri",async e=>{let t=e;for(let o in t)t[o]=decodeURIComponent(t[o]);let i=this.app.workspace.getActiveFile();i?this.hookSuccess(t,i):this.failure(t,{errorMessage:"No file opened"})}),this.registerEvent(this.app.workspace.on("file-menu",(e,t,i)=>{(i==="more-options"||i==="tab-header"||i=="file-explor Line truncated
`),d;if(t.heading){let p=re(this.app,e,t.heading);if(d=p==null?void 0:p.lastLine,d===void 0)return;p.firstLine==p.lastLine&&t.separator&&(t.separator=`
`+t.separator)}else t.line?d=Number(t.line):d=c.length;d=Math.max(1,d),c[d-1]=((l=c[d-1])!=null?l:"")+((s=t.separator)!=null?s:`
`)+t.data,o=c.join(`
`)}else i=e,o=t.data;return this.writeAndOpenFile(i,o,t)}async prepend(e,t){var l,s,r;let i,o;if(e instanceof w.TFile){i=e.path;let c=await this.app.vault.read(e),d=this.app.metadataCache.getFileCache(e),p=c.split(`
`),h;if(t.heading){if(h=(l=re(this.app,e,t.heading))==null?void 0:l.firstLine,h===void 0)return;h+=1}else t.line?h=Number(t.line):d.frontmatterPosition?h=d.frontmatterPosition.end.line+2:h=1;h=Math.max(1,h),p[h-1]=`${t.data}${(s=t.separator)!=null?s:`
`}${(r=p[h-1])!=null?r:""}`,o=p.join(`
`)}else i=e,o=t.data;return this.writeAndOpenFile(i,o,t)}async writeAndOpenFile(e,t,i){let o=this.app.vault.getAbstractFileByPath(e);if(o instanceof w.TFile)await this.app.vault.modify(o,t);else{let l=e.split("/"),s=l.slice(0,l.length-1).join("/");l.length>1&&!(this.app.vault.getAbstractFileByPath(s)instanceof w.TFolder)&&await this.app.vault.createFolder(s),/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/.test(t)?await this.app.vault.createBinary(e,(0,w.base64ToArrayBuffer)(t)):await this.app.vault.create(e,t)}return this.openExistingFileAndSetCursor(e,i),this.app.vault.getAbstractFileByPath(e)}async openExistingFileAndSetCursor(e,t){t.openmode!="silent"&&this.settings.openFileOnWrite&&(await this.open({file:e,setting:this.settings.openFileOnWriteInNewPane,parameters:t}),(t.line!=null||t.column!=null||t.offset!=null)&&await this.setCursorInLine(t))}async open({file:e,setting:t,parameters:i,supportPopover:o,mode:l}){var r;let s;if(i.openmode=="popover"&&(o==null||o)){let c=this.app.plugins.plugins["obsidian-hover-editor"];c||(new w.Notice("Cannot find Hover Editor plugin. Please file an issue."),this.failure(i)),await new Promise(d=>{s=c.spawnPopover(void 0,()=>{this.app.workspace.setActiveLeaf(s,{focus:!0}),d()})})}else{let c=t;if(i.newpane!==void 0&&(c=i.newpane=="true"),i.openmode!==void 0&&(i.openmode=="true"||i.openmode=="false"?c=i.openmode=="true":i.openmode=="popover"?c=!1:w.Platform.isMobile&&i.openmode=="window"||(c=i.openmode)),c=="silent")return;if(w.Platform.isMobileApp&&c=="window"&&(c=!0),e!=null){let d=!1;isBoolean(c)&&this.app.workspace.iterateAllLeaves(p=>{var h;if(((h=p.view.file)==null?void 0:h.path)===i.filepath){if(d&&p.width==0)return;d=!0,this.app.workspace.setActiveLeaf(p,{focus:!0}),s=p}})}s||(s=this.app.workspace.getLeaf(c),this.app.workspace.setActiveLeaf(s,{focus:!0}))}if(e instanceof w.TFile?await s.openFile(e):e!=null&&await this.app.workspace.openLinkText(e,"/",!1,l!=null?{state:{mode:l}}:se(i)),s.view instanceof w.MarkdownView){let c=s.getViewState();l!=null?c.state.mode=l:c.state={...c.state,...(r=se(i))==null?void 0:r.state},await s.setViewState(c)}return s}async setCursor(e){let t=this.app.workspace.getActiveViewOfType(w.MarkdownView);if(!t)return;let i=e.mode,o=t.editor,l=t.leaf.getViewState();if(l.state.mode="source",i==="append"){let s=o.lastLine(),r=o.getLine(s).length;await t.leaf.setViewState(l,{focus:!0}),o.setCursor({ch:r,line:s})}else i==="prepend"&&(await t.leaf.setViewState(l,{focus:!0}),o.setCursor({ch:0,line:0}));await new Promise(s=>setTimeout(s,10)),e.viewmode=="preview"&&(l.state.mode="preview",await t.leaf.setViewState(l))}async setCursorInLine(e){let t=this.app.workspace.getActiveViewOfType(w.MarkdownView);if(!t)return;let i=t.leaf.getViewState(),o=e.line!=null?Number(e.line):void 0,l=e.column?Number(e.column):void 0;i.state.mode="source",await t.leaf.setViewState(i);let s,r;if(e.offset!=null){let c=t.editor.offsetToPos(Number(e.offset));s=c.line,r=c.ch}else{s=o!=null?Math.min(o-1,t.editor.lineCount()-1):t.editor.getCursor().line;let c=t.editor.getLine(s).length-1;r=Math.min(l-1,c)}t.editor.focus(),t.editor.setCursor({line:s,ch:r}),t.editor.scrollIntoView({from:{line:s,ch:r},to:{line:s,ch:r}},!0),await new Promise(c=>setTimeout(c,10)),e.viewmode=="preview"&&(i.state.mode="preview",await t.leaf.setViewState(i))}async loadSettings(){this.settings=Object.assign(me,await this.loadData())}async saveSettings(){await this.saveData(this.settings)}};
//! All of these methods are taken from https://www.npmjs.com/package/obsidian-daily-notes-interface.
/*! Bundled license information:
feather-icons/dist/feather.js:
(*!
Copyright (c) 2016 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*)
*/
/* nosourcemap */
+11
View File
@@ -0,0 +1,11 @@
{
"id": "obsidian-advanced-uri",
"name": "Advanced URI",
"description": "Advanced modes for Obsidian URI",
"isDesktopOnly": false,
"js": "main.js",
"fundingUrl": "https://ko-fi.com/vinzent",
"version": "1.45.0",
"author": "Vinzent",
"authorUrl": "https://github.com/Vinzent03"
}