Skip to content

Commit

Permalink
upgrade obsidian, audit, fix scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
kevboh committed Jan 20, 2024
1 parent b756326 commit c8c7d79
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 57 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "longform",
"name": "Longform",
"version": "2.0.5",
"version": "2.0.6",
"minAppVersion": "1.0",
"description": "Write novels, screenplays, and other long projects in Obsidian.",
"author": "Kevin Barrett",
Expand Down
56 changes: 28 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "longform",
"version": "2.0.5",
"version": "2.0.6",
"description": "Write novels, screenplays, and other long projects in Obsidian (https://obsidian.md).",
"main": "main.js",
"scripts": {
Expand Down
57 changes: 30 additions & 27 deletions src/view/explorer/ExplorerPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TAbstractFile,
WorkspaceLeaf,
type PaneType,
Scope,
} from "obsidian";
import type { CompileStatus, Workflow } from "src/compile";
import { compile, CompileStepKind } from "src/compile";
Expand All @@ -27,6 +28,7 @@ export const VIEW_TYPE_LONGFORM_EXPLORER = "VIEW_TYPE_LONGFORM_EXPLORER";
export class ExplorerPane extends ItemView {
private explorerView: ExplorerView;
private undoManager = new UndoManager();
private scope: Scope;

constructor(leaf: WorkspaceLeaf) {
super(leaf);
Expand All @@ -45,34 +47,31 @@ export class ExplorerPane extends ItemView {
}

async onOpen(): Promise<void> {
this.registerScopeEvent(
this.app.scope.register(
["Mod"],
"z",
(evt: KeyboardEvent, ctx: KeymapContext) => {
const activePane = app.workspace.getActiveViewOfType(ExplorerPane);
if (activePane === this) {
this.undoManager.send("undo", evt, ctx);
return false;
}
return true;
this.scope = new Scope(this.app.scope);
this.scope.register(
["Mod"],
"z",
(evt: KeyboardEvent, ctx: KeymapContext) => {
const activePane = this.app.workspace.getActiveViewOfType(ExplorerPane);
if (activePane === this) {
this.undoManager.send("undo", evt, ctx);
return false;
}
)
return true;
}
);

this.registerScopeEvent(
this.app.scope.register(
["Mod", "Shift"],
"z",
(evt: KeyboardEvent, ctx: KeymapContext) => {
const activePane = app.workspace.getActiveViewOfType(ExplorerPane);
if (activePane === this) {
this.undoManager.send("redo", evt, ctx);
return false;
}
return true;
this.scope.register(
["Mod", "Shift"],
"z",
(evt: KeyboardEvent, ctx: KeymapContext) => {
const activePane = this.app.workspace.getActiveViewOfType(ExplorerPane);
if (activePane === this) {
this.undoManager.send("redo", evt, ctx);
return false;
}
)
return true;
}
);

const context = new Map();
Expand Down Expand Up @@ -175,7 +174,7 @@ export class ExplorerPane extends ItemView {
return;
}
const menu = new Menu();
menu.addSeparator()
menu.addSeparator();
menu.addItem((item) => {
item.setTitle("Rename");
item.setIcon("pencil");
Expand Down Expand Up @@ -208,8 +207,12 @@ export class ExplorerPane extends ItemView {
menu.addItem((item) => {
item.setTitle("Ignore note in Longform");
item.setIcon("minus-circle");
item.onClick(() => ignoreScene(file.name.endsWith('.md') ? file.name.slice(0, -3) : file.name));
})
item.onClick(() =>
ignoreScene(
file.name.endsWith(".md") ? file.name.slice(0, -3) : file.name
)
);
});
// Triggering this event lets other apps insert menu items
// including Obsidian, giving us lots of stuff for free.
this.app.workspace.trigger("file-menu", menu, file, "longform");
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"2.0.6": "1.3.5",
"2.0.5": "1.1.9",
"2.0.4": "1.1.9",
"2.0.3": "1.1.9",
Expand Down

0 comments on commit c8c7d79

Please sign in to comment.