16 lines
37 KiB
JavaScript
16 lines
37 KiB
JavaScript
"use strict";var e=require("obsidian");
|
|
/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */function t(e,t,s,i){return new(s||(s=Promise))((function(n,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function d(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,d)}l((i=i.apply(e,t||[])).next())}))}function s(e,t,s){var i=void 0===t?null:t,n=function(e,t){var s=atob(e);if(t){for(var i=new Uint8Array(s.length),n=0,a=s.length;n<a;++n)i[n]=s.charCodeAt(n);return String.fromCharCode.apply(null,new Uint16Array(i.buffer))}return s}(e,void 0!==s&&s),a=n.indexOf("\n",10)+1,o=n.substring(a)+(i?"//# sourceMappingURL="+i:""),d=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(d)}var i,n,a,o,d=(i="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7dmFyIGU9InVuZGVmaW5lZCIhPXR5cGVvZ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7Y29uc3QgZT1vLnNwbGl0KCJ8fCIpLm1hcCgoZT0+ZS50cmltKCkpKTthPW4uZmlsdGVyKChyPT5lLnNvbWUoKGU9PnIudGV4dC5pbmNsdWRlcyhlKSkpKSl9ZWxzZSIiIT09byYmKGE9dC5leHBvcnRzLmdvKG8sbix7a2V5OiJ0ZXh0In0pLm1hcCgoZT0+ZS5vYmopKSk7cmV0dXJuIGkubGVuZ3RoJiYoYT1hLmZpbHRlcigoZT0+ZnVuY3Rpb24oZSxyKXtmb3IobGV0IG49MDtuPHIubGVuZ3RoO24rPTEpe2NvbnN0IG89cltuXTtmb3IobGV0IHI9MDtyPGUubGVuZ3RoO3IrPTEpe2NvbnN0IG49ZVtyXTtpZihuPT09bylyZXR1cm4hMDtjb25zdCB0PWAke299L2A7aWYobi5zdGFydHNXaXRoKHQpKXJldHVybiEwfX1yZXR1cm4hMX0oZS50YWdzLGkpKSkpLHNlbGYucG9zdE1lc3NhZ2UoYSl9fSgpOwoK",n=null,a=!1,function(e){return o=o||s(i,n,a),new Worker(o,e)});class l{constructor(e=[]){this.map=new Map,e.forEach((e=>this.map.set(e.value(),e)))}has(e){return this.map.has(e.value())}add(e){return this.delete(e),this.map.set(e.value(),e)}addAll(e){e.forEach((e=>this.add(e)))}delete(e){this.map.delete(e.value())}values(){return Array.from(this.map.values())}valuesByLastAdd(){return Array.from(this.map.values()).reverse()}}class h{constructor(e,t,s=[]){this.id=e,this.text=t,this.tags=s}value(){return this.id}}class c{constructor(e,t,s,i){this.app=e,this.prevItems=t,this.recentAbovePinned=s.settings.recentAbovePinned,this.plugin=s,this.palette=i,this.allItems=[],this.pinnedItems=[],this.initialized=!1,this.hiddenIds=[],this.keymapHandlers=[]}getTitleText(){return this.titleText}getEmptyStateText(){return this.emptyStateText}getInstructions(){return[]}checkInitialized(){if(!this.initialized)throw new Error("This adapter has not been initialized")}initialize(){this.initialized=!0}mount(){}unmount(){this.keymapHandlers.forEach((e=>this.palette.scope.unregister(e))),this.keymapHandlers=[]}cleanQuery(e){return e}getPinnedItems(){return this.checkInitialized(),this.pinnedItems}getItems(){return this.checkInitialized(),this.allItems}getPrevItems(){return this.prevItems}getSortedItems(){const e=new l(this.getItems()),t=this.recentAbovePinned?this.getPrevItems().values():this.getPinnedItems();return[this.recentAbovePinned?this.getPinnedItems():this.getPrevItems().values(),t].forEach((t=>{t.forEach((t=>{e.has(t)&&e.add(t)}))})),e.valuesByLastAdd()}toggleHideId(e){return t(this,void 0,void 0,(function*(){this.hiddenIds.includes(e)?this.hiddenIds=this.hiddenIds.filter((t=>e!==t)):this.hiddenIds.push(e),this.plugin.settings[this.hiddenIdsSettingsKey]=this.hiddenIds,yield this.plugin.saveSettings(),yield this.plugin.loadSettings(),this.palette.updateSuggestions()}))}}class m{constructor(e,t,s,i=[],n=200){this.app=e,this.id=t,this.name=s,this.commandIds=i,this.delay=n}addCommand(e){this.commandIds.push(e)}removeCommand(e){this.commandIds=this.commandIds.filter((t=>t===e))}commandIsAvailable(e){const t=this.app.commands.findCommand(e);return!t.checkCallback||t.checkCallback(!0)}callAllCommands(){return t(this,void 0,void 0,(function*(){const t=new e.Notice(`Running "${this.name}"...`,1e4);for(let e=0;e<this.commandIds.length;e+=1){const s=this.commandIds[e],i=this.app.commands.findCommand(s);if(!this.commandIsAvailable(s)){t.setMessage(`Error: "${i.name}" cannot be used in this context. The macro is stopping.`);break}t.setMessage(`Running "${i.name}"`),this.app.commands.executeCommandById(s),yield new Promise((e=>{setTimeout(e,this.delay)}))}return t.hide(),new e.Notice(`Successfully ran "${this.name}"`),!0}))}checkCallback(e){return e?this.commandIsAvailable(this.commandIds[0]):(this.callAllCommands(),null)}}const r=new Set(["Alt","Ctrl","Mod","Shift"]),p={Mod:"Ctrl +",Ctrl:"Ctrl +",Meta:"Win +",Alt:"Alt +",Shift:"Shift +",Hyper:"Caps +"},u={Mod:"⌘",Ctrl:"^",Meta:"⌘",Alt:"⌥",Shift:"⇧",Hyper:"⇪"},g={TAB:"↹",ENTER:"↵",ARROWLEFT:"←",ARROWRIGHT:"→",ARROWUP:"↑",ARROWDOWN:"↓",BACKSPACE:"⌫",ESC:"Esc"};var y;function Z(t,s){let i=e.Platform.isMacOS?u:p;"mac"===s.hotkeyStyle?i=u:"windows"===s.hotkeyStyle&&(i=p);const n=[];var a;s.hyperKeyOverride&&(4===(a=t.modifiers).length&&a.every((e=>r.has(e))))?n.push(i.Hyper):t.modifiers.forEach((e=>{n.push(i[e])}));const o=t.key.toUpperCase();return n.push(g[o]||o),n.join(" ")}function b(e){return e.name}function S(t,s){const i=t.getCache(s);if(!i)return[];const n=(i.tags||[]).map((e=>e.tag)),a=e.parseFrontMatterTags(i.frontmatter)||[],o=n.concat(a),d=e.parseFrontMatterAliases(i.frontmatter)||[];return[new h(s,s,o),...d.map((e=>new h(`${e}:${s}`,e,o)))]}!function(e){e[e.Commands=0]="Commands",e[e.Files=1]="Files",e[e.Tags=2]="Tags"}(y||(y={}));class T extends e.FuzzySuggestModal{constructor(e,t){super(e),this.getItemText=b,this.callback=t}getItems(){return Object.values(this.app.commands.commands)}onChooseItem(e){this.callback(e)}}class W extends c{constructor(){super(...arguments),this.COMMAND_PLUGIN_NAME_SEPARATOR=": "}initialize(){super.initialize(),this.titleText="Better Command Palette: Commands",this.emptyStateText="No matching commands.",this.hiddenIds=this.plugin.settings.hiddenCommands,this.hiddenIdsSettingsKey="hiddenCommands",this.allItems=this.app.commands.listCommands().sort(((e,t)=>t.name.localeCompare(e.name))).map((e=>new h(e.id,e.name)));const e=this.app.internalPlugins.getPluginById("command-palette").instance.options.pinned||[];this.pinnedItems=e.reduce(((e,t)=>{const s=this.app.commands.findCommand(t);return s&&e.push(new h(t,s.name)),e}),[]).reverse()}mount(){this.keymapHandlers=[this.palette.scope.register(["Mod"],this.plugin.settings.fileSearchHotkey,(()=>this.palette.changeActionType(y.Files))),this.palette.scope.register(["Mod"],this.plugin.settings.tagSearchHotkey,(()=>this.palette.changeActionType(y.Tags)))]}getInstructions(){return[{command:Z({modifiers:[],key:"ENTER"},this.plugin.settings),purpose:"Run command"},{command:Z({modifiers:["Mod"],key:this.plugin.settings.fileSearchHotkey},this.plugin.settings),purpose:"Search Files"},{command:Z({modifiers:["Mod"],key:this.plugin.settings.tagSearchHotkey},this.plugin.settings),purpose:"Search Tags"}]}renderSuggestion(t,s,i){const n=this.app.commands.findCommand(t.id),a=this.app.hotkeyManager.getHotkeys(n.id),o=this.app.hotkeyManager.getDefaultHotkeys(n.id),d=a||o||[];if(this.getPinnedItems().find((e=>e.id===t.id))){const t=i.querySelector(".suggestion-flair");e.setIcon(t,"filled-pin",13),t.ariaLabel="Pinned",t.onClickEvent((()=>{}))}let{text:l}=t,h="";if(l.includes(this.COMMAND_PLUGIN_NAME_SEPARATOR)){const e=l.split(this.COMMAND_PLUGIN_NAME_SEPARATOR);h=e.shift(),l=e.join(this.COMMAND_PLUGIN_NAME_SEPARATOR)}s.createEl("span",{cls:"suggestion-title",text:l}),h&&this.plugin.settings.showPluginName&&s.createEl("span",{cls:"suggestion-note",text:h}),d.forEach((e=>{i.createEl("kbd",{cls:"suggestion-hotkey",text:Z(e,this.plugin.settings)})}))}onChooseSuggestion(e){return t(this,void 0,void 0,(function*(){this.getPrevItems().add(e),this.app.commands.executeCommandById(e.id)}))}}class v extends c{initialize(){super.initialize(),this.titleText="Better Command Palette: Files",this.emptyStateText="No matching files.",this.fileSearchPrefix=this.plugin.settings.fileSearchPrefix,this.hiddenIds=this.plugin.settings.hiddenFiles,this.hiddenIdsSettingsKey="hiddenFiles",this.allItems=[],this.unresolvedItems=new l,this.app.metadataCache.getCachedFiles().forEach((e=>{if(this.plugin.settings.fileTypeExclusion.some((t=>e.endsWith(`.${t}`))))return;const t=S(this.app.metadataCache,e);this.allItems=this.allItems.concat(t),Object.keys(this.app.metadataCache.unresolvedLinks[e]||{}).forEach((e=>this.unresolvedItems.add(new h(e,e))))})),this.allItems=this.allItems.concat(Array.from(this.unresolvedItems.values())).reverse(),[...this.app.workspace.getLastOpenFiles()].reverse().forEach((e=>{const t=S(this.app.metadataCache,e);t[0]&&this.prevItems.add(t[0])}))}mount(){this.keymapHandlers=[this.palette.scope.register(["Mod"],this.plugin.settings.commandSearchHotkey,(()=>this.palette.changeActionType(y.Commands))),this.palette.scope.register(["Mod"],this.plugin.settings.tagSearchHotkey,(()=>this.palette.changeActionType(y.Tags)))]}getInstructions(){const{openInNewTabMod:e,createNewFileMod:t}=this.plugin.settings;return[{command:Z({modifiers:[],key:"ENTER"},this.plugin.settings),purpose:"Open file"},{command:Z({modifiers:[e],key:"ENTER"},this.plugin.settings),purpose:"Open file in new pane"},{command:Z({modifiers:[t],key:"ENTER"},this.plugin.settings),purpose:"Create file"},{command:Z({modifiers:["Mod"],key:this.plugin.settings.commandSearchHotkey},this.plugin.settings),purpose:"Search Commands"},{command:Z({modifiers:["Mod"],key:this.plugin.settings.tagSearchHotkey},this.plugin.settings),purpose:"Search Tags"}]}cleanQuery(e){return e.replace(this.fileSearchPrefix,"")}renderSuggestion(t,s){let i=t.text;this.plugin.settings.displayOnlyNotesNames&&(i=t.text.split("/").pop()),this.plugin.settings.hideMdExtension&&i.endsWith(".md")&&(i=i.slice(0,-3));const n=s.createEl("div",{cls:"suggestion-title",text:i});if(this.unresolvedItems.has(t)&&n.addClass("unresolved"),t.id.includes(":")){n.createEl("span",{cls:"suggestion-name",text:t.text}).ariaLabel="Alias",e.setIcon(n,"right-arrow-with-tail");const[,s]=t.id.split(":");n.createEl("span",{cls:"suggestion-note",text:s})}s.createEl("div",{cls:"suggestion-note",text:`${t.tags.join(" ")}`})}onChooseSuggestion(s,i){return t(this,void 0,void 0,(function*(){let n=s&&s.id;if(s)n.includes(":")&&([,n]=n.split(":"));else{n=i.target.value.replace(this.fileSearchPrefix,"")}const a=yield function(s,i){return t(this,void 0,void 0,(function*(){let t=s.metadataCache.getFirstLinkpathDest(i,"");if(!t){const n=e.normalizePath(`${i}.md`),a=n.split("/").slice(0,-1).join("/");try{yield s.vault.createFolder(a)}catch(e){}t=yield s.vault.create(n,"")}return t}))}(this.app,n);a&&this.getPrevItems().add(s||new h(a.path,a.path)),function(e,t,s,i){const n="Shift"===t.openInNewTabMod?i.shiftKey:i.metaKey||i.ctrlKey;e.workspace.openLinkText(s.path,s.path,n)}(this.app,this.plugin.settings,a,i)}))}}class x extends c{initialize(){super.initialize(),this.hiddenIds=this.plugin.settings.hiddenTags,this.hiddenIdsSettingsKey="hiddenTags",this.tagSearchPrefix=this.plugin.settings.tagSearchPrefix,this.titleText="Better Command Palette: Tags",this.emptyStateText="No matching tags.",this.allItems=Object.entries(this.app.metadataCache.getTags()).map((([e,t])=>new h(e,e,[t])))}mount(){this.keymapHandlers=[this.palette.scope.register(["Mod"],this.plugin.settings.commandSearchHotkey,(()=>this.palette.changeActionType(y.Commands))),this.palette.scope.register(["Mod"],this.plugin.settings.fileSearchHotkey,(()=>this.palette.changeActionType(y.Files)))]}getInstructions(){return[{command:Z({modifiers:[],key:"ENTER"},this.plugin.settings),purpose:"See file usage"},{command:Z({modifiers:["Mod"],key:this.plugin.settings.commandSearchHotkey},this.plugin.settings),purpose:"Search Commands"},{command:Z({modifiers:["Mod"],key:this.plugin.settings.fileSearchHotkey},this.plugin.settings),purpose:"Search Files"}]}cleanQuery(e){return e.replace(this.tagSearchPrefix,"")}renderSuggestion(e,t,s){t.createEl("span",{cls:"suggestion-content",text:e.text});const i=parseInt(e.tags[0],10);s.createEl("span",{cls:"suggestion-flair",text:`Found in ${i} file${1===i?"":"s"}`})}onChooseSuggestion(e){return t(this,void 0,void 0,(function*(){this.getPrevItems().add(e),this.palette.open(),this.palette.setQuery(`${this.plugin.settings.fileSearchPrefix}@${e.text}`,1)}))}}class P extends e.SuggestModal{constructor(e,t,s,i,n,a=""){super(e),this.toggleHiddenItems=()=>{this.showHiddenItems=!this.showHiddenItems,this.updateSuggestions()},this.fileSearchPrefix=i.settings.fileSearchPrefix,this.tagSearchPrefix=i.settings.tagSearchPrefix,this.suggestionLimit=i.settings.suggestionLimit,this.initialInputValue=a,this.plugin=i,this.modalEl.addClass("better-command-palette"),this.setPlaceholder("Select a command"),this.commandAdapter=new W(e,t,i,this),this.fileAdapter=new v(e,new l,i,this),this.tagAdapter=new x(e,s,i,this),this.suggestionsWorker=n,this.suggestionsWorker.onmessage=e=>this.receivedSuggestions(e),this.modalTitleEl=createEl("p",{cls:"better-command-palette-title"}),this.updateActionType(),this.modalEl.insertBefore(this.modalTitleEl,this.modalEl.firstChild),this.hiddenItemsHeaderEl=createEl("p","hidden-items-header"),this.showHiddenItems=!1,this.hiddenItemsHeaderEl.onClickEvent(this.toggleHiddenItems),this.modalEl.insertBefore(this.hiddenItemsHeaderEl,this.resultContainerEl),this.setScopes(i)}close(e){super.close(),e&&e.preventDefault()}setScopes(e){const t=t=>{const s=t.target;e.settings.closeWithBackspace&&""===s.value&&this.close(t)},{openInNewTabMod:s,createNewFileMod:i}=e.settings;this.scope.register([],"Backspace",(e=>{t(e)})),this.scope.register(["Mod"],"Backspace",(e=>{t(e)})),this.scope.register([i],"Enter",(e=>{this.actionType===y.Files&&(this.currentAdapter.onChooseSuggestion(null,e),this.close(e))})),this.scope.register([i,s],"Enter",(e=>{this.actionType===y.Files&&(this.currentAdapter.onChooseSuggestion(null,e),this.close(e))})),this.scope.register([s],"Enter",(e=>{if(this.actionType===y.Files&&this.currentSuggestions.length){const t=document.querySelector(".better-command-palette .prompt-results"),s=document.querySelector(".better-command-palette .is-selected"),i=Array.from(t.children).indexOf(s);this.currentAdapter.onChooseSuggestion(this.currentSuggestions[i],e),this.close(e)}})),this.scope.register(["Mod"],"I",this.toggleHiddenItems)}onOpen(){super.onOpen(),this.initialInputValue&&this.setQuery(this.initialInputValue)}changeActionType(e){let t="";e===y.Files?t=this.plugin.settings.fileSearchPrefix:e===y.Tags&&(t=this.plugin.settings.tagSearchPrefix);const s=this.inputEl.value,i=this.currentAdapter.cleanQuery(s);this.inputEl.value=t+i,this.updateSuggestions()}setQuery(e,t=-1){this.inputEl.value=e,t>-1&&this.inputEl.setSelectionRange(t,t),this.updateSuggestions()}updateActionType(){var e;const t=this.inputEl.value;let s,i;t.startsWith(this.fileSearchPrefix)?(i=y.Files,s=this.fileAdapter,this.modalEl.setAttribute("palette-mode","files")):t.startsWith(this.tagSearchPrefix)?(i=y.Tags,s=this.tagAdapter,this.modalEl.setAttribute("palette-mode","tags")):(i=y.Commands,s=this.commandAdapter,this.modalEl.setAttribute("palette-mode","commands")),i!==this.actionType&&(null===(e=this.currentAdapter)||void 0===e||e.unmount(),this.currentAdapter=s,this.currentAdapter.mount()),this.currentAdapter.initialized||this.currentAdapter.initialize();const n=i!==this.actionType;return this.actionType=i,n&&(this.updateEmptyStateText(),this.updateTitleText(),this.updateInstructions(),this.currentSuggestions=this.currentAdapter.getSortedItems().slice(0,this.suggestionLimit)),n}updateTitleText(){this.plugin.settings.showPluginName?this.modalTitleEl.setText(this.currentAdapter.getTitleText()):this.modalTitleEl.setText("")}updateEmptyStateText(){this.emptyStateText=this.currentAdapter.getEmptyStateText()}updateInstructions(){Array.from(this.modalEl.getElementsByClassName("prompt-instructions")).forEach((e=>{this.modalEl.removeChild(e)})),this.setInstructions([...this.currentAdapter.getInstructions(),{command:Z({modifiers:[],key:"ESC"},this.plugin.settings),purpose:"Close palette"},{command:Z({modifiers:["Mod"],key:"I"},this.plugin.settings),purpose:"Toggle Hidden Items"}])}getItems(){return this.currentAdapter.getSortedItems()}receivedSuggestions(e){const t=[];let s=0;for(let i=0;i<e.data.length&&t.length<this.suggestionLimit+s;i+=1)t.push(e.data[i]),this.currentAdapter.hiddenIds.includes(e.data[i].id)&&(s+=1);const i=t.map((e=>new h(e.id,e.text,e.tags))),n=this.currentAdapter.getPrevItems();i.sort(((e,t)=>+n.has(t)-+n.has(e))),this.currentSuggestions=i,this.limit=this.currentSuggestions.length,this.updateSuggestions()}getSuggestionsAsync(e){const t=this.getItems();this.suggestionsWorker.postMessage({query:e,items:t})}getSuggestions(e){this.updateActionType();const t=e!==this.lastQuery;this.lastQuery=e;const s=this.currentAdapter.cleanQuery(e.trim());t&&this.getSuggestionsAsync(s);const i=this.currentSuggestions.filter((e=>!this.currentAdapter.hiddenIds.includes(e.id))),n=this.currentSuggestions.length-i.length;return this.updateHiddenItemCountHeader(n),this.showHiddenItems?this.currentSuggestions:i}updateHiddenItemCountHeader(e){if(this.hiddenItemsHeaderEl.empty(),0!==e){const t=`${this.showHiddenItems?"Hide":"Show"} hidden items (${e})`;this.hiddenItemsHeaderEl.setText(t)}}renderSuggestion(t,s){s.addClass("mod-complex");const i=this.currentAdapter.hiddenIds.includes(t.id);i&&s.addClass("hidden");const n=s.createEl("span","suggestion-content"),a=s.createEl("span","suggestion-aux"),o=a.createEl("span","suggestion-flair");!function(e,t,s,i){i.has(t)&&(s.addClass("recent"),s.createEl("span",{cls:"suggestion-note",text:e.recentlyUsedText}))}(this.plugin.settings,t,n,this.currentAdapter.getPrevItems()),e.setIcon(o,"cross",13),o.ariaLabel=i?"Click to Unhide":"Click to Hide",o.setAttr("data-id",t.id),o.onClickEvent((e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this.currentAdapter.toggleHideId(t.getAttr("data-id"))})),this.currentAdapter.renderSuggestion(t,n,a)}onChooseSuggestion(e,s){return t(this,void 0,void 0,(function*(){this.currentAdapter.onChooseSuggestion(e,s)}))}}const f={closeWithBackspace:!0,showPluginName:!0,fileSearchPrefix:"/",tagSearchPrefix:"#",commandSearchHotkey:"p",fileSearchHotkey:"o",tagSearchHotkey:"t",suggestionLimit:50,recentAbovePinned:!1,hyperKeyOverride:!1,displayOnlyNotesNames:!1,hideMdExtension:!1,recentlyUsedText:"(recently used)",macros:[],hotkeyStyle:"auto",createNewFileMod:"Mod",openInNewTabMod:"Shift",hiddenCommands:[],hiddenFiles:[],hiddenTags:[],fileTypeExclusion:[]};class I extends e.PluginSettingTab{constructor(e,t){super(e,t),this.plugin=t}display(){this.containerEl.empty(),this.displayBasicSettings(),this.displayMacroSettings()}displayBasicSettings(){const{containerEl:s}=this,{settings:i}=this.plugin;s.empty(),s.createEl("h2",{text:"Better Command Palette Settings"}),new e.Setting(s).setName("Close on Backspace").setDesc("Close the palette when there is no text and backspace is pressed").addToggle((e=>e.setValue(i.closeWithBackspace).onChange((e=>t(this,void 0,void 0,(function*(){i.closeWithBackspace=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Show Plugin Name").setDesc("Show the plugin name in the command palette").addToggle((e=>e.setValue(i.showPluginName).onChange((e=>t(this,void 0,void 0,(function*(){i.showPluginName=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Recent above Pinned").setDesc("Sorts the suggestion so that the recently used items show before pinned items.").addToggle((e=>e.setValue(i.recentAbovePinned).onChange((e=>t(this,void 0,void 0,(function*(){i.recentAbovePinned=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Caps Lock Hyper Key Hotkey Override").setDesc('For those users who have use a "Hyper Key", enabling this maps the icons "⌥ ^ ⌘ ⇧" to the caps lock icon "⇪" ').addToggle((e=>e.setValue(i.hyperKeyOverride).onChange((e=>t(this,void 0,void 0,(function*(){i.hyperKeyOverride=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Use shift to create files and cmd/CTRL to open in new tab").setDesc("By default cmd/ctrl is used to create files and shift is used to open in new tab. This setting reverses that to mimic the behavior of the standard quick switcher.").addToggle((e=>e.setValue("Shift"===i.createNewFileMod).onChange((e=>t(this,void 0,void 0,(function*(){i.createNewFileMod=e?"Shift":"Mod",i.openInNewTabMod=e?"Mod":"Shift",yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Display only notes' names").setDesc("If enabled, only notes names will be displayed in Quick Switcher mode instead of their full path.").addToggle((e=>e.setValue(i.displayOnlyNotesNames).onChange((e=>t(this,void 0,void 0,(function*(){i.displayOnlyNotesNames=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Hide .md extensions").setDesc("If enabled, Markdown notes will be displayed without their .md extension in Quick Switcher mode").addToggle((e=>e.setValue(i.hideMdExtension).onChange((e=>t(this,void 0,void 0,(function*(){i.hideMdExtension=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Recently used text").setDesc("This text will be displayed next to recently used items").addText((e=>e.setValue(i.recentlyUsedText).onChange((e=>t(this,void 0,void 0,(function*(){i.recentlyUsedText=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("File Type Exclusions").setDesc('A comma separated list of file extensions (ex: "pdf,jpg,png") that should not be shown when searching files.').addText((e=>e.setValue(i.fileTypeExclusion.join(",")).onChange((e=>t(this,void 0,void 0,(function*(){const t=e.split(",").map((e=>e.trim()));i.fileTypeExclusion=t,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("File Search Prefix").setDesc("The prefix used to tell the palette you want to search files").addText((e=>e.setValue(i.fileSearchPrefix).onChange((e=>t(this,void 0,void 0,(function*(){i.fileSearchPrefix=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Tag Search Prefix").setDesc("The prefix used to tell the palette you want to search tags").addText((e=>e.setValue(i.tagSearchPrefix).onChange((e=>t(this,void 0,void 0,(function*(){i.tagSearchPrefix=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Command Search Hotkey").setDesc("The hotkey used to switch to command search while using the command palette.").addText((e=>e.setValue(i.commandSearchHotkey).onChange((e=>t(this,void 0,void 0,(function*(){i.commandSearchHotkey=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("File Search Hotkey").setDesc("The hotkey used to switch to file search while using the command palette.").addText((e=>e.setValue(i.fileSearchHotkey).onChange((e=>t(this,void 0,void 0,(function*(){i.fileSearchHotkey=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Tag Search Hotkey").setDesc("The hotkey used to switch to tag search while using the command palette.").addText((e=>e.setValue(i.tagSearchHotkey).onChange((e=>t(this,void 0,void 0,(function*(){i.tagSearchHotkey=e,yield this.plugin.saveSettings()}))))));const n={10:"10",20:"20",50:"50",100:"100",200:"200",500:"500",1e3:"1000"};new e.Setting(s).setName("Suggestion Limit").setDesc("The number of items that will be in the suggestion list of the palette. Really high numbers can affect performance").addDropdown((e=>e.addOptions(n).setValue(i.suggestionLimit.toString()).onChange((e=>t(this,void 0,void 0,(function*(){i.suggestionLimit=parseInt(e,10),yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Hotkey Modifier Style").setDesc("Allows autodetecting of hotkey modifier or forcing to Mac or Windows").addDropdown((e=>e.addOptions({auto:"Auto Detect",mac:"Force Mac Hotkeys",windows:"Force Windows Hotkeys"}).setValue(i.hotkeyStyle).onChange((e=>t(this,void 0,void 0,(function*(){i.hotkeyStyle=e,yield this.plugin.saveSettings()})))))),new e.Setting(s).setName("Add new macro").setDesc("Create a new grouping of commands that can be run together").addButton((e=>e.setButtonText("+").onClick((()=>t(this,void 0,void 0,(function*(){i.macros.push({name:`Macro ${i.macros.length+1}`,commandIds:[],delay:200}),yield this.plugin.saveSettings(),this.display()}))))))}displayMacroSettings(){const{containerEl:s}=this,{settings:i}=this.plugin;i.macros.forEach(((n,a)=>{const o=new e.Setting(s).setClass("macro-setting").setName(`Macro #${a+1}`).addButton((e=>e.setButtonText("Delete Macro").onClick((()=>t(this,void 0,void 0,(function*(){i.macros.splice(a,1),yield this.plugin.saveSettings(),this.display()})))))),d=o.settingEl.createEl("div","macro-main-settings");d.createEl("label",{text:"Macro Name"}),d.createEl("input",{cls:"name-input",type:"text",value:n.name}).on("change",".name-input",(e=>t(this,void 0,void 0,(function*(){const t=e.target;i.macros[a]=Object.assign(Object.assign({},n),{name:t.value}),yield this.plugin.saveSettings()})))),d.createEl("label",{text:"Delay (ms)"}),d.createEl("input",{cls:"delay-input",type:"number",value:n.delay.toString()}).on("change",".delay-input",(e=>t(this,void 0,void 0,(function*(){const t=e.target.value;i.macros[a].delay=parseInt(t,10),yield this.plugin.saveSettings()})))),d.createEl("label",{text:"Add a new Command to the macro"}),d.createEl("button",{text:"Add Command"}).onClickEvent((()=>t(this,void 0,void 0,(function*(){new T(this.app,(e=>t(this,void 0,void 0,(function*(){i.macros[a].commandIds.push(e.id),yield this.plugin.saveSettings(),this.display()})))).open()})))),n.commandIds.forEach(((s,n)=>{const d=this.app.commands.findCommand(s),l=o.settingEl.createEl("div","macro-command"),h=l.createEl("button",`delete-command-${n}`);l.createEl("p",{text:`${n+1}: ${d.name}`,cls:"command"}),e.setIcon(h,"trash"),h.onClickEvent((()=>t(this,void 0,void 0,(function*(){i.macros[a].commandIds.splice(n,1),yield this.plugin.saveSettings(),this.display()}))))}))}))}}class X extends e.Plugin{onload(){return t(this,void 0,void 0,(function*(){console.log("Loading plugin: Better Command Palette"),yield this.loadSettings(),this.prevCommands=new l,this.prevTags=new l,this.suggestionsWorker=new d({}),this.addCommand({id:"open-better-commmand-palette",name:"Open better command palette",hotkeys:[{modifiers:["Mod","Shift"],key:"p"}],callback:()=>{new P(this.app,this.prevCommands,this.prevTags,this,this.suggestionsWorker).open()}}),this.addCommand({id:"open-better-commmand-palette-file-search",name:"Open better command palette: File Search",hotkeys:[],callback:()=>{new P(this.app,this.prevCommands,this.prevTags,this,this.suggestionsWorker,this.settings.fileSearchPrefix).open()}}),this.addCommand({id:"open-better-commmand-palette-tag-search",name:"Open better command palette: Tag Search",hotkeys:[],callback:()=>{new P(this.app,this.prevCommands,this.prevTags,this,this.suggestionsWorker,this.settings.tagSearchPrefix).open()}}),this.addSettingTab(new I(this.app,this))}))}onunload(){this.suggestionsWorker.terminate()}loadMacroCommands(){this.settings.macros.forEach(((e,t)=>{if(!e.name||!e.commandIds.length)return;const s=new m(this.app,`obsidian-better-command-palette-macro-${t}`,e.name,e.commandIds,e.delay);this.addCommand(s),this.prevCommands&&(this.prevCommands=this.prevCommands.values().reduce(((e,t)=>(t.id===s.id&&t.text!==s.name||e.add(t),e)),new l))}))}deleteMacroCommands(){Object.keys(this.app.commands.commands).filter((e=>e.includes("obsidian-better-command-palette-macro-"))).forEach((e=>{this.app.commands.removeCommand(e)}))}loadSettings(){return t(this,void 0,void 0,(function*(){this.settings=Object.assign(Object.assign({},f),yield this.loadData()),this.loadMacroCommands()}))}saveSettings(){return t(this,void 0,void 0,(function*(){this.deleteMacroCommands(),yield this.saveData(this.settings),this.loadMacroCommands()}))}}module.exports=X;
|