Skip to content

Commit 40bb7af

Browse files
committed
Update API version and deps
1 parent ce54023 commit 40bb7af

File tree

5 files changed

+46
-39
lines changed

5 files changed

+46
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"@ophidian/build": "^1.0.1",
1010
"@ophidian/core": "git://github.com/ophidian-lib/core.git",
1111
"monkey-around": "^2.3.0",
12-
"obsidian": "0.15.4"
12+
"obsidian": "1.2.8"
1313
}
1414
}

pnpm-lock.yaml

Lines changed: 32 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/History.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export class HistoryManager extends Service {
275275
}));
276276

277277
this.registerEvent(store.onLoadItem((item, state) => {
278-
if (item instanceof WorkspaceLeaf && state[SERIAL_PROP]) {
278+
if (item instanceof WorkspaceLeaf && state && state[SERIAL_PROP]) {
279279
new History(item, state[SERIAL_PROP]).saveToNative();
280280
}
281281
}));
@@ -312,7 +312,7 @@ export class HistoryManager extends Service {
312312

313313
this.register(around(app.workspace, {
314314
// Monkeypatch: keep Obsidian from pushing history in setActiveLeaf
315-
setActiveLeaf(old) { return function setActiveLeaf(leaf, ...etc) {
315+
setActiveLeaf(old) { return function setActiveLeaf(leaf, ...etc: any[]) {
316316
const unsub = around(this, {
317317
recordHistory(old) { return function (leaf: WorkspaceLeaf, _push: boolean, ...args: any[]) {
318318
// Always update state in place

src/Navigator.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ declare global {
1212
declare module "obsidian" {
1313
interface Menu {
1414
dom: HTMLElement
15-
setUseNativeMenu?(flag: boolean): void; // 0.16 to force HTML menu
1615
}
1716
interface MenuItem {
1817
dom: HTMLElement
@@ -313,9 +312,9 @@ export class Navigator extends Component {
313312
menu.showAtPosition({x: evt.clientX, y: evt.clientY + 20});
314313
menu.register(around(app.workspace, {setActiveLeaf(old) {
315314
// Don't allow a hover editor to auto-focus, so you can mod-click without targeting it
316-
return function(leaf, pushHistory, focus) {
315+
return function(leaf, ...args: any[]) {
317316
if (leaf.containerEl.matchParent(".hover-editor")) return;
318-
return old.call(this, leaf, pushHistory, focus);
317+
return old.call(this, leaf, ...args);
319318
}
320319
}}));
321320
this.owner.historyIsOpen = true;
@@ -378,9 +377,9 @@ export class Navigator extends Component {
378377
}
379378

380379
export function formatState(entry: HistoryEntry): FileInfo {
381-
const {viewState: {type, state}, eState, path} = entry;
380+
const {viewState: {type, state}, eState, path, raw} = entry;
382381
const file = path && app.vault.getAbstractFileByPath(path) as TFile;
383-
const info = {icon: "", title: "", file, type, state, eState};
382+
const info = {icon: raw?.icon ?? "", title: raw?.title ?? "" , file, type, state, eState};
384383

385384
if (nonFileViews[type]) {
386385
[info.icon, info.title] = nonFileViews[type];

src/focus-lock.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { around } from "monkey-around";
22
import { Notice, Plugin, setIcon, Workspace, WorkspaceLeaf } from "obsidian";
3-
import { defer, isLeafAttached, LayoutSetting, Service } from "@ophidian/core";
3+
import { defer, isLeafAttached, LayoutSetting, Service, o } from "@ophidian/core";
44
import { addCommands, command } from "./commands";
55
import { setTooltip } from "./Navigator";
66

77
export class FocusLock extends Service {
88

9-
setting = new LayoutSetting<boolean, Workspace>(this, "pane-relief:focus-lock").of(app.workspace);
9+
setting = new LayoutSetting<boolean, o.Workspace>(this, "pane-relief:focus-lock").of(app.workspace);
1010

1111
plugin = this.use(Plugin);
1212
statusEl = this.plugin.addStatusBarItem();
@@ -31,11 +31,11 @@ export class FocusLock extends Service {
3131
const self = this;
3232
// wrap setActiveLeaf and canNavigate to prevent select/activate
3333
this.register(around(app.workspace, {
34-
setActiveLeaf(old) { return function(this: Workspace, leaf, pushHistory, focus) {
35-
if (!self.isLocked || isMain(leaf)) return old.call(this, leaf, pushHistory, focus);
34+
setActiveLeaf(old) { return function(this: Workspace, leaf, ...etc: any[]) {
35+
if (!self.isLocked || isMain(leaf)) return old.call(this, leaf, ...etc);
3636
// Handle the case where there was no prior active leaf
3737
if (!this.activeLeaf || !isLeafAttached(this.activeLeaf))
38-
return old.call(this, this.getLeaf(), pushHistory, focus);
38+
return old.call(this, this.getLeaf(), ...etc);
3939
}},
4040
revealLeaf(old) {
4141
return function(leaf: WorkspaceLeaf) {
@@ -98,7 +98,7 @@ export class FocusLock extends Service {
9898
}
9999
this.isLocked = shouldLock;
100100

101-
setIcon(this.iconEl, shouldLock ? "lucide-lock" : "lucide-unlock", 13);
101+
setIcon(this.iconEl, shouldLock ? "lucide-lock" : "lucide-unlock");
102102
setTooltip(this.iconEl, shouldLock ?
103103
"Sidebar focus disabled: click to enable" :
104104
"Sidebar focus enabled: click to disable"
@@ -120,7 +120,4 @@ declare module "obsidian" {
120120
interface WorkspaceLeaf {
121121
canNavigate(): boolean
122122
}
123-
interface Notice {
124-
noticeEl: HTMLDivElement
125-
}
126-
}
123+
}

0 commit comments

Comments
 (0)