4 lines
36 KiB
JavaScript
4 lines
36 KiB
JavaScript
|
var le=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Oe=Object.prototype.hasOwnProperty;var Ve=(n,r)=>{for(var e in r)le(n,e,{get:r[e],enumerable:!0})},ze=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Fe(r))!Oe.call(n,o)&&o!==e&&le(n,o,{get:()=>r[o],enumerable:!(t=De(r,o))||t.enumerable});return n};var $e=n=>ze(le({},"__esModule",{value:!0}),n);var Ge={};Ve(Ge,{default:()=>ce,leafName:()=>k,splitName:()=>se});module.exports=$e(Ge);var E=require("obsidian");var A=require("obsidian");var pe=Symbol.for("v1.to-use.peak-dev.org"),fe=Symbol.for("v1.factory.to-use.peak-dev.org"),F,K,w=function(){return Object.defineProperties(n(),{this:{get(){if(F)return F;throw new TypeError("No current context")}},me:{value:pe},factory:{value:fe}});function n(o){let i=new Map;i.prev=o;let a=Object.assign(o?s=>{let l=i.get(s);if(!l){for(let g=i.prev;g;g=g.prev)if(l=g.get(s)){l=Object.assign(Object.assign({},l),{s:l.s||1});break}l=l||{s:2,v:e},i.set(s,l)}let u,m,d;for(;;)switch(l.s){case 0:return F===a&&K&&K.push(s),l.v;case 1:if(u=l.d,!u||c(()=>u.k.every(g=>a(g)===u.c(g)))){l.s=0;break}l.v=u.f;case 2:l.s=4;try{r(i,s,0,c(m=l.v,s,d=[])),d.length&&(l.d={c:a,f:m,k:d});break}catch(g){l.s=3,l.v=g,l.d=null}case 3:throw l.v;case 4:throw new Error(`Factory ${String(l.v)} didn't resolve ${String(s)}`)}}:s=>w.this(s),{def(s,l){return r(i,s,2,l),a},set(s,l){return r(i,s,1,l),a},fork(s){let l=n(i);return s!=null?l(s):l}});return o?a.use=a:a;function c(s,l,u){let m=F,d=K;try{return F=a,K=u,s(l)}finally{F=m,K=d}}}function r(o,i,a,c){if(o.has(i)){let s=o.get(i);if(!s.s)throw new Error(`Already read: ${String(i)}`);s.s=a,s.v=c,s.d=null}else o.set(i,{s:a,v:c})}function e(o){if(typeof o[pe]=="function")return o[pe](o);if(t(o))return typeof o.prototype[fe]=="function"?o.prototype[fe]():new o;throw new ReferenceError(`No config for ${String(o)}`)}function t(o){return typeof o=="function"&&o.prototype!==void 0&&(Object.getPrototypeOf(o.prototype)!==Object.prototype||Object.getOwnPropertyNames(o.prototype).length>1||o.toString().startsWith("class"))}}();var ke,b=(ke=window.queueMicrotask)!=null?ke:(n=>r=>n.then(r))(Promise.resolve());w.def(A.Plugin,()=>{throw new Error("Plugin not created yet")});var v=class extends A.Component{constructor(){super(...arguments);this.use=w.service(this)}};w.service=function(n){return w(G).addChild(n),w.this};w.plugin=function(n){let r=w.fork().set(A.Plugin,n).set(n.constructor,n);return n.addChild(r.use(G)),r};var G=class extends A.Component{constructor(){super(...arguments);this.children=new Set([this])}onload(){this.loaded=!0}onunload(){this.loaded=!1,this.children.clear()}addChild(e){return this.children.has(e)||(this.children.add(e),this.loaded?b(()=>super.addChild(e)):super.addChild(e)),e}};function X(n,r){n._loaded&&n.removeChild(r)}function be(n,r){let e=new A.Component;e.onload=()=>{X(n,e),r()},n.addChild(e)}function f(n,r){let e=Object.keys(r).map(t=>je(n,t,r[t]));return e.length===1?e[0]:function(){e.forEach(t=>t())}}function je(n,r,e){let t=n[r],o=n.hasOwnProperty(r),i=e(t);return t&&Object.setPrototypeOf(i,t),Object.setPrototypeOf(a,i),n[r]=a,c;function a(...s){return i===t&&n[r]===a&&c(),i.apply(this,s)}function c(){n[r]===a&&(o?n[r]=t:delete n[r]),i!==t&&(i=t,Object.setPrototypeOf(a,t||Function))}}function Y(n,r,e){return t[n]=n,t;function t(...o){return(r[n]===n?r:e).apply(this,o)}}var J=require("obsidian");var Z=require("obsidian");function Q(n){let r=app.workspace;switch(n==null?void 0:n.getRoot()){case r.rootSplit:case r.floatingSplit:case r.leftSplit:case r.rightSplit:return!0;default:return!1}}function I(n,r){if(!n)return!1;if(typeof n=="function"&&(r=n,n=app.workspace),r(n))return!0;if(n instanceof Z.Workspace)return I(n.rootSplit,r)||I(n.floatingSplit,r)||I(n.leftSplit,r)||I(n.rightSplit,r);if(n instanceof Z.WorkspaceParent){for(let e of n.children)if(I(e,r))return!0}return!1}function ue(n){return n&&typeof n=="object"?JSON.parse(JSON.stringify(n)):n}var P=class{constructor(r,e,t,o){this.key=e;this.defaultValue=t;this.owner=o;this.st
|
||
|
.view-header > .view-header-nav-buttons > button:${this.dir<0?"first":"last"}-child`,(t,o)=>{let i=o.matchParent(".workspace-leaf"),a=this.owner.leaves().filter(c=>c.containerEl===i).pop();!a||(t.preventDefault(),t.stopImmediatePropagation(),this.openMenu(t,h.forLeaf(a)))},{capture:!0}))}onunload(){$(this.containerEl,this.oldLabel),this.count.detach(),this.containerEl.toggleClass("mod-active",!1)}setCount(e){this.count.textContent=""+(e||"")}setHistory(e=h.current()){this.updateDisplay(this.history=e)}updateDisplay(e,t=this.containerEl){let o=e[this.dir<0?"lookBehind":"lookAhead"]();t===this.containerEl&&this.setCount(o.length),$(t,o.length?this.oldLabel+`
|
||
|
`+ie(o[0]).title:`No ${this.kind} history`),t.toggleClass("mod-active",o.length>0)}openMenu(e,t=this.history){var a;let o=t[this.dir<0?"lookBehind":"lookAhead"]();if(!o.length)return;let i=new y.Menu;(a=i.setUseNativeMenu)==null||a.call(i,!1),i.dom.addClass("pane-relief-history-menu"),i.dom.on("mousedown",".menu-item",c=>{c.stopPropagation()},!0),o.map(ie).forEach((c,s)=>this.menuItem(c,s,i,t)),i.showAtPosition({x:e.clientX,y:e.clientY+20}),i.register(f(app.workspace,{setActiveLeaf(c){return function(s,l,u){if(!s.containerEl.matchParent(".hover-editor"))return c.call(this,s,l,u)}}})),this.owner.historyIsOpen=!0,i.onHide(()=>{this.owner.historyIsOpen=!1,this.owner.display()})}menuItem(e,t,o,i){let{dir:a,kind:c}=this;o.addItem(u=>{s(u),e.file&&l(u.dom)});return;function s(u,m=""){u.setIcon(e.icon).setTitle(m+e.title).onClick(d=>{if(y.Keymap.isModEvent(d))if(T&&i.leaf){app.workspace.duplicateLeaf(i.leaf,y.Keymap.isModEvent(d)).then(g=>{h.forLeaf(g).go((t+1)*a,!0)});return}else i=i.cloneTo(app.workspace.getLeaf(y.Keymap.isModEvent(d)));i.go((t+1)*a,!0)})}function l(u){u.addEventListener("mouseover",m=>{app.workspace.trigger("hover-link",{event:m,source:ye.hoverSource,hoverParent:o.dom,targetEl:u,linktext:e.file.path})}),u.setAttr("draggable","true"),u.addEventListener("dragstart",m=>{let d=app.dragManager,g=d.dragFile(m,e.file);d.onDragStart(m,g)}),u.addEventListener("dragend",m=>o.hide()),u.addEventListener("contextmenu",m=>{let d=new y.Menu;d.addItem(g=>s(g,`Go ${c} to `)).addSeparator(),app.workspace.trigger("file-menu",d,e.file,"link-context-menu"),d.showAtPosition({x:m.clientX,y:m.clientY}),m.stopPropagation()},!0)}}},M=ye;M.hoverSource="pane-relief:history-menu";function ie(n){var c,s,l;let{viewState:{type:r,state:e},eState:t,path:o}=n,i=o&&app.vault.getAbstractFileByPath(o),a={icon:"",title:"",file:i,type:r,state:e,eState:t};return Ne[r]?[a.icon,a.title]=Ne[r]:o&&!i?[a.icon,a.title]=["trash","Missing file "+o]:i instanceof y.TFile&&(a.icon=(c=Ue[r])!=null?c:"document",r==="markdown"&&e.mode==="preview"&&(a.icon="lines-of-text"),a.title=i?i.basename+(i.extension!=="md"?"."+i.extension:""):"No file",r==="media-view"&&!i&&(a.title=(l=(s=e.info)==null?void 0:s.filename)!=null?l:a.title)),app.workspace.trigger("pane-relief:format-history-item",a),a}function _e(n,r,e,t,o){return n.on(r,e,t,o),()=>n.off(r,e,t,o)}function $(n,r){r?n.setAttribute("aria-label",r||void 0):n.removeAttribute("aria-label")}var ne=class extends v{constructor(){super(...arguments);this.setting=new P(this,"pane-relief:focus-lock").of(app.workspace);this.plugin=this.use(H.Plugin);this.statusEl=this.plugin.addStatusBarItem();this.iconEl=this.statusEl.createSpan("pane-relief-focus-lock icon",e=>{e.setAttribute("aria-label-position","top")});this.isLocked=null;this.installed=!1}onload(){this.registerDomEvent(this.iconEl,"click",()=>this.toggle()),te(this.plugin,{[p("focus-lock","Toggle focus lock (Enable/disable sidebar focusing)")]:()=>()=>this.toggle()}),this.registerEvent(this.setting.onLoadWorkspace(this.onChange,this))}install(){this.installed=!0;let e=this;this.register(f(app.workspace,{setActiveLeaf(t){return function(o,i,a){if(!e.isLocked||_(o))return t.call(this,o,i,a);if(!this.activeLeaf||!Q(this.activeLeaf))return t.call(this,this.getLeaf(),i,a)}},revealLeaf(t){return function(o){let i=o.getContainer();if(!e.isLocked||_(o)||!i)return t.call(this,o);let a=f(i,{focus(){return function(){}}});try{return t.call(this,o)}finally{a()}}}})),this.register(f(H.WorkspaceLeaf.prototype,{canNavigate(t){return function(){return t.call(this)&&(!e.isLocked||_(this))}}})),this.register(f(app.internalPlugins.plugins["file-explorer"].instance,{init(t){return function(...i){try{return t.apply(this,i)}finally{e.blockFileExplorerReveal()}}}})),this.blockFileExplorerReveal()}blockFileExplorerReveal(){let e=this,t=app.commands.commands["file-explorer:reveal-active-file"];t&&this.register(f(t,{checkCallback(o){return function(...i){var a;if(e.isLocked){for(let c of app.workspace.getLeavesOfType("file-explorer"))if(!_(c)){let s=(a=c.view.dom)==null?void 0:a.navFileCont
|