Skip to content

Commit

Permalink
Focus editor after creating a new note while in focus mode.
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan McQuen <[email protected]>
  • Loading branch information
ryanpcmcquen committed Nov 11, 2021
1 parent d9999fb commit cc961f4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
21 changes: 21 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class FocusMode extends Plugin {
this.app.workspace.rootSplit.containerEl.removeClass(
this.maximisedClass
);

// @ts-ignore
this.app.workspace.onLayoutChange();
}
Expand All @@ -71,6 +72,16 @@ export default class FocusMode extends Plugin {
!document.body.classList.contains(this.superFocusModeClass)
);

// @ts-ignore
this.app.on("active-leaf-change", () => {
// @ts-ignore
this.app.workspace.activeLeaf.view.editor.blur();
// @ts-ignore
this.app.workspace.activeLeaf.view.editor.focus();
// @ts-ignore
this.app.workspace.activeLeaf.view.editor.refresh();
});

// @ts-ignore
this.app.workspace.onLayoutChange();

Expand All @@ -90,6 +101,16 @@ export default class FocusMode extends Plugin {
!document.body.classList.contains(this.focusModeClass)
);

// @ts-ignore
this.app.on("active-leaf-change", () => {
// @ts-ignore
this.app.workspace.activeLeaf.view.editor.blur();
// @ts-ignore
this.app.workspace.activeLeaf.view.editor.focus();
// @ts-ignore
this.app.workspace.activeLeaf.view.editor.refresh();
});

this.storeSplitsValues();

this.collapseSplits();
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-focus-mode",
"name": "Focus Mode",
"version": "1.8.0",
"version": "1.8.1",
"minAppVersion": "0.9.12",
"description": "Add Focus Mode to Obsidian.",
"author": "ryanpcmcquen",
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-focus-mode",
"version": "1.8.0",
"version": "1.8.1",
"description": "Add Focus Mode to Obsidian.",
"main": "main.js",
"scripts": {
Expand All @@ -14,11 +14,11 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-typescript": "^8.2.1",
"@types/node": "^14.17.3",
"obsidian": "^0.12.5",
"rollup": "^2.52.2",
"tslib": "^2.3.0",
"typescript": "^4.3.4"
"@rollup/plugin-typescript": "^8.3.0",
"@types/node": "^14.17.33",
"obsidian": "^0.12.17",
"rollup": "^2.59.0",
"tslib": "^2.3.1",
"typescript": "^4.4.4"
}
}
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"1.8.1": "0.10.9",
"1.8.0": "0.9.12",
"1.7.1": "0.9.12",
"1.7.0": "0.9.12",
Expand Down

0 comments on commit cc961f4

Please sign in to comment.