FFLOW 0.3.0: everything is a flow; steps set any properties, symbol and hotkeys share them

This commit is contained in:
olivier committed 2026-10-25 18:03:02 -04:00
1 parent 68e390fb37
commit 8553b7c75a
12 files changed
+423 -335

No files matched your search

+6 -5
View File
@@ -1,11 +1,11 @@
import { Notice, TFile } from "obsidian";
import { setFlowStep, updateFrontmatter } from "./frontmatter";
import type FflowPlugin from "./main";
import { Flow, flowSteps } from "./settings";
import type { Flow } from "./settings";
type Direction = 1 | -1;
/** Re-registers the next/previous commands of every flow. Ids derive from the flow id, so hotkeys survive renames. */
/** Re-registers the next/previous commands of every ordered flow. Ids derive from the flow id, so hotkeys survive renames. */
export class FlowCommands {
private registered: string[] = [];
@@ -15,6 +15,7 @@ export class FlowCommands {
for (const id of this.registered) this.plugin.removeCommand(id);
this.registered = [];
for (const flow of this.plugin.settings.flows) {
if (flow.kind !== "ordered") continue;
this.add(flow, 1, "next", "next step");
this.add(flow, -1, "previous", "previous step");
}
@@ -28,7 +29,7 @@ export class FlowCommands {
name: `${flow.name || flow.property || "Unnamed flow"}: ${label}`,
checkCallback: (checking) => {
const file = this.plugin.app.workspace.getActiveFile();
if (!file || file.extension !== "md" || !flow.property || flowSteps(flow).length === 0) return false;
if (!file || file.extension !== "md" || !flow.property || !flow.steps.some((s) => s.value)) return false;
if (!checking) void moveStep(this.plugin, file, flow, direction);
return true;
},
@@ -37,7 +38,7 @@ export class FlowCommands {
}
async function moveStep(plugin: FflowPlugin, file: TFile, flow: Flow, direction: Direction): Promise<void> {
const steps = flowSteps(flow);
const steps = flow.steps.filter((s) => s.value);
let message = "";
try {
// Read the current value inside the update: the metadata cache can lag behind the editor.
@@ -52,7 +53,7 @@ async function moveStep(plugin: FflowPlugin, file: TFile, flow: Flow, direction:
}
target = (target + steps.length) % steps.length;
}
setFlowStep(fm, flow, steps[target].value);
setFlowStep(plugin.app, fm, flow, steps[target].value);
message = `${flow.property}: ${steps[target].value}`;
});
new Notice(message);