Files
BlueRoseNote/.obsidian/plugins/pane-relief/main.js

6 lines
39 KiB
JavaScript
Raw Normal View History

2026-05-06 17:32:44 +08:00
var se=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var Fe=(a,r)=>{for(var e in r)se(a,e,{get:r[e],enumerable:!0})},Ve=(a,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ie(r))!Ae.call(a,o)&&o!==e&&se(a,o,{get:()=>r[o],enumerable:!(t=Re(r,o))||t.enumerable});return a};var De=a=>Ve(se({},"__esModule",{value:!0}),a);var Ke={};Fe(Ke,{default:()=>ne,leafName:()=>b,splitName:()=>ae});module.exports=De(Ke);var C=require("obsidian");var E=typeof queueMicrotask=="function"?queueMicrotask:(a=>r=>a.then(r))(Promise.resolve());function ce(a){return a&&typeof a=="object"?JSON.parse(JSON.stringify(a)):a}function M(a,r,e){let t=a.classList.contains(r);return e=e!=null?e:!t,e!==t&&(e?a.classList.add(r):a.classList.remove(r)),e}var f;(a=>Object.assign(a,require("obsidian")))(f||(f={}));var le="use.me",pe="use.factory",O,j,de=function(){return Object.defineProperties(a(),{this:{get(){if(O)return O;throw new TypeError("No current context")}},me:{value:le},factory:{value:pe}});function a(o){let i=new Map;i.prev=o;let n=Object.assign(o?c=>{let l=i.get(c);if(!l){for(let y=i.prev;y;y=y.prev)if(l=y.get(c)){l=Object.assign(Object.assign({},l),{s:l.s||1});break}l=l||{s:2,v:e},i.set(c,l)}let u,h,m;for(;;)switch(l.s){case 0:return O===n&&j&&j.push(c),l.v;case 1:if(u=l.d,!u||s(()=>u.k.every(y=>n(y)===u.c(y)))){l.s=0;break}l.v=u.f;case 2:l.s=4;try{r(i,c,0,s(h=l.v,c,m=[])),m.length&&(l.d={c:n,f:h,k:m});break}catch(y){l.s=3,l.v=y,l.d=null}case 3:throw l.v;case 4:throw new Error(`Factory ${String(l.v)} didn't resolve ${String(c)}`)}}:c=>de.this(c),{def(c,l){return r(i,c,2,l),n},set(c,l){return r(i,c,1,l),n},fork(c){let l=a(i);return c!=null?l(c):l}});return o?n.use=n:n;function s(c,l,u){let h=O,m=j;try{return O=n,j=u,c(l)}finally{O=h,j=m}}}function r(o,i,n,s){if(o.has(i)){let c=o.get(i);if(!c.s)throw new Error(`Already read: ${String(i)}`);c.s=n,c.v=s,c.d=null}else o.set(i,{s:n,v:s})}function e(o){if(typeof o[le]=="function")return o[le](o);if(t(o))return typeof o.prototype[pe]=="function"?o.prototype[pe]():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 Ne,V=(a=>(a.service=function(r){return a(G).addChild(r),a.this},a.plugin=function(r){if(!F)Ne=r.app,F=a.fork(),F.set(f.Plugin,r),F.set(r.constructor,r),r.addChild(F.use(G));else if(r!==F.use(f.Plugin))throw new TypeError("use.plugin() called on multiple plugins");return F},a.def(f.Plugin,()=>{throw new Error("Plugin not created yet")}),a.def(f.App,()=>a(f.Plugin).app),a))(de),F;var k=class extends f.Component{constructor(){super(...arguments);this.use=V.service(this)}},G=class extends f.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?E(()=>super.addChild(e)):super.addChild(e)),e}};function Q(a,r){E(()=>a.removeChild(r))}function ye(a,r){let e=new f.Component;e.onload=()=>{Q(a,e),a=null,r()},a.addChild(e)}function d(a,r){let e=Object.keys(r).map(t=>Oe(a,t,r[t]));return e.length===1?e[0]:function(){e.forEach(t=>t())}}function Oe(a,r,e){let t=a[r],o=a.hasOwnProperty(r),i=e(t);return t&&Object.setPrototypeOf(i,t),Object.setPrototypeOf(n,i),a[r]=n,s;function n(...c){return i===t&&a[r]===n&&s(),i.apply(this,c)}function s(){a[r]===n&&(o?a[r]=t:delete a[r]),i!==t&&(i=t,Object.setPrototypeOf(n,t||Function))}}function X(a,r,e){return t[a]=a,t;function t(...o){return(r[a]===a?r:e).apply(this,o)}}function _(a){let r=app.workspace;switch(a==null?void 0:a.getRoot()){case r.rootSplit:case r.floatingSplit:case r.leftSplit:case r.rightSplit:return!0;default:return!1}}function D(a,r){if(!a)return!1;if(typeof a=="function"&&(r=a,a=app.workspace),r(a))return!0;if(a instanceof f.Workspace)return D(a.rootSplit,r)||D(a.float
.view-header-left > .view-header-nav-buttons > button:${this.dir<0?"first":"last"}-child,
.view-header > .view-header-nav-buttons > button:${this.dir<0?"first":"last"}-child`;this.register(We(this.owner.win.document.body,"contextmenu",t,(o,i)=>{let n=i.matchParent(".workspace-leaf"),s=this.owner.leaves().filter(c=>c.containerEl===n).pop();s&&(o.preventDefault(),o.stopImmediatePropagation(),this.openMenu(o,w.forLeaf(s)))},{capture:!0})),(0,g.requireApiVersion)("1.8")&&this.register(We(this.owner.win.document.body,"auxclick",t,o=>{o.button===2&&o.stopImmediatePropagation()},{capture:!0}))}onunload(){K(this.containerEl,this.oldLabel),this.count.detach(),this.containerEl.toggleClass("mod-active",!1)}setCount(e){this.count.textContent=""+(e||"")}setHistory(e=w.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),K(t,o.length?this.oldLabel+`
`+oe(o[0]).title:`No ${this.kind} history`),t.toggleClass("mod-active",o.length>0)}openMenu(e,t=this.history){var n;let o=t[this.dir<0?"lookBehind":"lookAhead"]();if(!o.length)return;let i=new g.Menu;(n=i.setUseNativeMenu)==null||n.call(i,!1),i.dom.addClass("pane-relief-history-menu"),i.dom.on("mousedown",".menu-item",s=>{s.stopPropagation()},!0),o.map(oe).forEach((s,c)=>this.menuItem(s,c,i,t)),i.showAtPosition({x:e.clientX,y:e.clientY+20}),i.register(d(app.workspace,{setActiveLeaf(s){return function(c,...l){if(!c.containerEl.matchParent(".hover-editor"))return s.call(this,c,...l)}}})),this.owner.historyIsOpen=!0,i.onHide(()=>{this.owner.historyIsOpen=!1,this.owner.display()})}menuItem(e,t,o,i){let{dir:n,kind:s}=this;o.addItem(u=>{c(u),e.file&&l(u.dom)});return;function c(u,h=""){u.setIcon(e.icon).setTitle(h+e.title).onClick(m=>{if(g.Keymap.isModEvent(m))if(i.leaf){app.workspace.duplicateLeaf(i.leaf,g.Keymap.isModEvent(m)).then(y=>{w.forLeaf(y).go((t+1)*n,!0)});return}else i=i.cloneTo(app.workspace.getLeaf(g.Keymap.isModEvent(m)));i.go((t+1)*n,!0)})}function l(u){u.addEventListener("mouseover",h=>{app.workspace.trigger("hover-link",{event:h,source:ge.hoverSource,hoverParent:o.dom,targetEl:u,linktext:e.file.path})}),u.setAttr("draggable","true"),u.addEventListener("dragstart",h=>{let m=app.dragManager,y=m.dragFile(h,e.file);m.onDragStart(h,y)}),u.addEventListener("dragend",h=>o.hide()),u.addEventListener("contextmenu",h=>{let m=new g.Menu;m.addItem(y=>c(y,`Go ${s} to `)).addSeparator(),app.workspace.trigger("file-menu",m,e.file,"link-context-menu"),m.showAtPosition({x:h.clientX,y:h.clientY}),h.stopPropagation()},!0)}}},H=ge;H.hoverSource="pane-relief:history-menu";function oe(a){var c,l,u,h,m;let{viewState:{type:r,state:e},eState:t,path:o,raw:i}=a,n=o&&app.vault.getAbstractFileByPath(o),s={icon:(c=i==null?void 0:i.icon)!=null?c:"",title:(l=i==null?void 0:i.title)!=null?l:"",file:n,type:r,state:e,eState:t};return Me[r]?[s.icon,s.title]=Me[r]:o&&!n?[s.icon,s.title]=["trash","Missing file "+o]:n instanceof g.TFile&&(s.icon=(u=$e[r])!=null?u:"document",r==="markdown"&&e.mode==="preview"&&(s.icon="lines-of-text"),s.title=n?n.basename+(n.extension!=="md"?"."+n.extension:""):"No file",r==="media-view"&&!n&&(s.title=(m=(h=e.info)==null?void 0:h.filename)!=null?m:s.title)),app.workspace.trigger("pane-relief:format-history-item",s),s}function We(a,r,e,t,o){return a.on(r,e,t,o),()=>a.off(r,e,t,o)}function K(a,r){r?a.setAttribute("aria-label",r||void 0):a.removeAttribute("aria-label")}var re=class extends k{constructor(){super(...arguments);this.setting=new W(this,"pane-relief:focus-lock").of(app.workspace);this.plugin=this.use(I.Plugin);this.statusEl=this.plugin.addStatusBarItem();this.iconEl=this.statusEl.createSpan("pane-relief-focus-lock icon",e=>{e.setAttribute("aria-label-position","top"),e.setAttribute("aria-label-delay","0"),e.setAttribute("data-tooltip-position","top")});this.isLocked=null;this.installed=!1}onload(){this.registerDomEvent(this.iconEl,"click",()=>this.toggle()),ee(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(d(app.workspace,{setActiveLeaf(t){return function(o,...i){var n,s;if(!e.isLocked||R(o))return t.call(this,o,...i);if(app.workspace.revealLeaf(o),!this.activeLeaf||!_(this.activeLeaf))return t.call(this,this.getLeaf(),...i);(((n=o.view)==null?void 0:n.getViewType())==="search"&&i[0]===!0||(s=i[0])!=null&&s.focus)&&o.setEphemeralState({focus:!0})}},revealLeaf(t){return function(o){let i=o.getContainer();if(!e.isLocked||R(o)||!i)return t.call(this,o);let n=d(i,{focus(){return function(){}}});try{return t.call(this,o)}finally{n()}}}})),this.register(d(I.WorkspaceLeaf.prototype,{canNavigate(t){return function(){return t.call(this)&&(!e.isLocked||R(this))}}})),this.register(d(app.internalPlugins.plugins["file-explorer"].instance,{init(t){return function(...i){try{return t.apply(this,i)}finally{e.blockFileExplorerReveal()}}}})),t
/* nosourcemap */