FFLOW 0.3.1: settings redesigned as collapsible flow cards

This commit is contained in:
olivier committed 2026-10-25 18:06:35 -04:00
1 parent 8553b7c75a
commit 157e5e018a
6 files changed
+394 -163

No files matched your search

+8
View File
@@ -1,3 +1,9 @@
---
status: done
cssclasses:
- st-done
archived: true
---
# FFLOW roadmap # FFLOW roadmap
## Next ## Next
@@ -7,6 +13,8 @@
## Done ## Done
- 0.3.1 — Settings redesigned: collapsible flow cards with a step summary, one row of labelled fields, steps as a table with their "also sets" properties.
- 0.3.0 — Everything is a flow. Ordered flows: steps with "also sets" effects on any property (cssclasses included), undone when leaving the step; symbol and next/previous hotkeys apply the same thing. Open flows: vault values, single or list. Old settings migrated. - 0.3.0 — Everything is a flow. Ordered flows: steps with "also sets" effects on any property (cssclasses included), undone when leaving the step; symbol and next/previous hotkeys apply the same thing. Open flows: vault values, single or list. Old settings migrated.
- 0.2.0 — Flows with per-step cssclasses and next/previous commands, separate from triggers. - 0.2.0 — Flows with per-step cssclasses and next/previous commands, separate from triggers.
- 0.1.0 — Triggers: symbol → property, open (vault) or fixed list, single value or list. - 0.1.0 — Triggers: symbol → property, open (vault) or fixed list, single value or list.
+1 -1
View File
@@ -2,4 +2,4 @@
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
*/ */
var A=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var H=(n,s)=>{for(var e in s)A(n,e,{get:s[e],enumerable:!0})},W=(n,s,e,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of j(s))!K.call(n,o)&&o!==e&&A(n,o,{get:()=>s[o],enumerable:!(t=$(s,o))||t.enumerable});return n};var q=n=>W(A({},"__esModule",{value:!0}),n);var J={};H(J,{default:()=>T});module.exports=q(J);var R=require("obsidian");var M=require("obsidian");var N=require("obsidian");async function v(n,s,e){let t=n.workspace.getActiveViewOfType(N.MarkdownView);(t==null?void 0:t.file)===s&&await t.save(),await n.fileManager.processFrontMatter(s,e)}function I(n,s,e,t){if(!t){n[s]=e;return}let o=L(n[s],s);o.includes(e)||o.push(e),n[s]=o}function F(n,s,e,t){var a;s[e.property]=t;let o=e.steps.find(l=>l.value===t),i=new Map,r=l=>{let d=i.get(l);return d===void 0&&i.set(l,d=_(n,s,l)),d},p=l=>l.property!==""&&l.property!==e.property;for(let l of e.steps)if(l!==o)for(let d of l.effects.filter(p)){let u=d.property;if(r(u)){let c=new Set(B(d.value)),m=L(s[u],u).filter(y=>!c.has(y));m.length?s[u]=m:delete s[u]}else u in s&&String(s[u])===String(D(d.value))&&delete s[u]}for(let l of(a=o==null?void 0:o.effects.filter(p))!=null?a:[]){let d=l.property;if(r(d)){let u=L(s[d],d);for(let c of B(l.value))u.includes(c)||u.push(c);u.length&&(s[d]=u)}else s[d]=D(l.value)}}function _(n,s,e){if(["cssclasses","tags","aliases"].includes(e)||Array.isArray(s[e]))return!0;let t=Reflect.get(n,"metadataTypeManager");if(!t||typeof t!="object"||!("getPropertyInfo"in t)||typeof t.getPropertyInfo!="function")return!1;let o=t.getPropertyInfo(e),i=o&&typeof o=="object"&&"widget"in o?o.widget:null;return i==="multitext"||i==="tags"||i==="aliases"}function L(n,s){return Array.isArray(n)?n.map(String):n==null||n===""?[]:s==="cssclasses"?String(n).split(/[\s,]+/).filter(Boolean):[String(n)]}function B(n){return n.split(",").map(s=>s.trim()).filter(Boolean)}function D(n){let s=n.trim();return s===""?null:s==="true"||s==="false"?s==="true":/^-?\d+(\.\d+)?$/.test(s)?Number(s):s}var S=class{constructor(s){this.plugin=s;this.registered=[]}sync(){for(let s of this.registered)this.plugin.removeCommand(s);this.registered=[];for(let s of this.plugin.settings.flows)s.kind==="ordered"&&(this.add(s,1,"next","next step"),this.add(s,-1,"previous","previous step"))}add(s,e,t,o){let i=`flow-${s.id}-${t}`;this.registered.push(i),this.plugin.addCommand({id:i,name:`${s.name||s.property||"Unnamed flow"}: ${o}`,checkCallback:r=>{let p=this.plugin.app.workspace.getActiveFile();return!p||p.extension!=="md"||!s.property||!s.steps.some(a=>a.value)?!1:(r||G(this.plugin,p,s,e),!0)}})}};async function G(n,s,e,t){let o=e.steps.filter(r=>r.value),i="";try{await v(n.app,s,r=>{let p=o.findIndex(l=>l.value===String(r[e.property])),a=p===-1?0:p+t;if(a<0||a>=o.length){if(!e.loop){i=`${e.property}: already at the ${t===1?"last":"first"} step`;return}a=(a+o.length)%o.length}F(n.app,r,e,o[a].value),i=`${e.property}: ${o[a].value}`}),new M.Notice(i)}catch(r){console.error("FFLOW: could not move flow step",r),new M.Notice(`FFLOW: could not set "${e.property}". See console.`)}}function f(n){return{id:Date.now().toString(36)+Math.random().toString(36).slice(2,6),name:"",symbol:"",property:"",kind:"ordered",valueMode:"single",loop:!1,steps:[],...n}}function U(){return{flows:[f({name:"Type",symbol:"@",property:"type",kind:"open"})]}}var b=["#","[","/",":"];function h(n,s,e){return n===""?null:[...n].length!==1?"Use exactly one character.":/[\p{L}\p{N}\s]/u.test(n)?"Letters, digits and spaces are not allowed.":b.includes(n)?`"${n}" is reserved (${b.join(" ")}).`:s.some((t,o)=>o!==e&&t.symbol===n)?`"${n}" is already used by another flow.`:null}function O(n){var o,i;if(!n||typeof n!="object")return U();if("flows"in n&&!("rules"in n)&&Array.isArray(n.flows))return{flows:n.flows.map(r=>f(r))};let s=n,e=(o=s.rules)!=null?o:[],t=((i=s.flows)!=null?i:[]).map(r=>{var p,a;return f({id:r.id,name:r.name,property:r.property,loop:r.loop,symbol:(a=(p=e.find(l=>l.source==="flow"&&l.flowId===r.id))==null?void 0:p.symbol)!=null?a:"",steps:r.steps.map(l=>({value:l.value,effects:l.cssclass.trim()?[{property:"cssclasses",value:l.cssclass.trim().split(/\s+/).join(", ")}]:[]}))})});for(let r of e)r.source==="open"&&t.push(f({name:r.property,symbol:r.symbol,property:r.property,kind:"open",valueMode:r.valueMode})),r.source==="finite"&&t.push(f({name:r.property,symbol:r.symbol,property:r.property,steps:r.values.map(p=>({value:p,effects:[]}))}));return{flows:t}}var g=require("obsidian");var x=class extends g.PluginSettingTab{constructor(e,t){super(e,t);this.plugin=t;this.save=()=>this.plugin.saveSettings()}async saveAndRedraw(){await this.save(),this.display()}display(){let{containerEl:e}=this,t=this.plugin.settings.flows;e.empty(),new g.Setting(e).setHeading().setName("Flows").setDesc(`Type a flow's symbol at the start of a word and pick a value: the text disappears Line truncated var P=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(n,s)=>{for(var t in s)P(n,t,{get:s[t],enumerable:!0})},Z=(n,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of J(s))!Q.call(n,o)&&o!==t&&P(n,o,{get:()=>s[o],enumerable:!(e=G(s,o))||e.enumerable});return n};var ee=n=>Z(P({},"__esModule",{value:!0}),n);var re={};X(re,{default:()=>M});module.exports=ee(re);var U=require("obsidian");var I=require("obsidian");var H=require("obsidian");async function b(n,s,t){let e=n.workspace.getActiveViewOfType(H.MarkdownView);(e==null?void 0:e.file)===s&&await e.save(),await n.fileManager.processFrontMatter(s,t)}function K(n,s,t,e){if(!e){n[s]=t;return}let o=V(n[s],s);o.includes(t)||o.push(t),n[s]=o}function x(n,s,t,e){var p;s[t.property]=e;let o=t.steps.find(l=>l.value===e),r=new Map,i=l=>{let d=r.get(l);return d===void 0&&r.set(l,d=te(n,s,l)),d},a=l=>l.property!==""&&l.property!==t.property;for(let l of t.steps)if(l!==o)for(let d of l.effects.filter(a)){let c=d.property;if(i(c)){let m=new Set($(d.value)),g=V(s[c],c).filter(h=>!m.has(h));g.length?s[c]=g:delete s[c]}else c in s&&String(s[c])===String(j(d.value))&&delete s[c]}for(let l of(p=o==null?void 0:o.effects.filter(a))!=null?p:[]){let d=l.property;if(i(d)){let c=V(s[d],d);for(let m of $(l.value))c.includes(m)||c.push(m);c.length&&(s[d]=c)}else s[d]=j(l.value)}}function te(n,s,t){if(["cssclasses","tags","aliases"].includes(t)||Array.isArray(s[t]))return!0;let e=Reflect.get(n,"metadataTypeManager");if(!e||typeof e!="object"||!("getPropertyInfo"in e)||typeof e.getPropertyInfo!="function")return!1;let o=e.getPropertyInfo(t),r=o&&typeof o=="object"&&"widget"in o?o.widget:null;return r==="multitext"||r==="tags"||r==="aliases"}function V(n,s){return Array.isArray(n)?n.map(String):n==null||n===""?[]:s==="cssclasses"?String(n).split(/[\s,]+/).filter(Boolean):[String(n)]}function $(n){return n.split(",").map(s=>s.trim()).filter(Boolean)}function j(n){let s=n.trim();return s===""?null:s==="true"||s==="false"?s==="true":/^-?\d+(\.\d+)?$/.test(s)?Number(s):s}var C=class{constructor(s){this.plugin=s;this.registered=[]}sync(){for(let s of this.registered)this.plugin.removeCommand(s);this.registered=[];for(let s of this.plugin.settings.flows)s.kind==="ordered"&&(this.add(s,1,"next","next step"),this.add(s,-1,"previous","previous step"))}add(s,t,e,o){let r=`flow-${s.id}-${e}`;this.registered.push(r),this.plugin.addCommand({id:r,name:`${s.name||s.property||"Unnamed flow"}: ${o}`,checkCallback:i=>{let a=this.plugin.app.workspace.getActiveFile();return!a||a.extension!=="md"||!s.property||!s.steps.some(p=>p.value)?!1:(i||se(this.plugin,a,s,t),!0)}})}};async function se(n,s,t,e){let o=t.steps.filter(i=>i.value),r="";try{await b(n.app,s,i=>{let a=o.findIndex(l=>l.value===String(i[t.property])),p=a===-1?0:a+e;if(p<0||p>=o.length){if(!t.loop){r=`${t.property}: already at the ${e===1?"last":"first"} step`;return}p=(p+o.length)%o.length}x(n.app,i,t,o[p].value),r=`${t.property}: ${o[p].value}`}),new I.Notice(r)}catch(i){console.error("FFLOW: could not move flow step",i),new I.Notice(`FFLOW: could not set "${t.property}". See console.`)}}function v(n){return{id:Date.now().toString(36)+Math.random().toString(36).slice(2,6),name:"",symbol:"",property:"",kind:"ordered",valueMode:"single",loop:!1,steps:[],...n}}function ne(){return{flows:[v({name:"Type",symbol:"@",property:"type",kind:"open"})]}}var k=["#","[","/",":"];function S(n,s,t){return n===""?null:[...n].length!==1?"Use exactly one character.":/[\p{L}\p{N}\s]/u.test(n)?"Letters, digits and spaces are not allowed.":k.includes(n)?`"${n}" is reserved (${k.join(" ")}).`:s.some((e,o)=>o!==t&&e.symbol===n)?`"${n}" is already used by another flow.`:null}function W(n){var o,r;if(!n||typeof n!="object")return ne();if("flows"in n&&!("rules"in n)&&Array.isArray(n.flows))return{flows:n.flows.map(i=>v(i))};let s=n,t=(o=s.rules)!=null?o:[],e=((r=s.flows)!=null?r:[]).map(i=>{var a,p;return v({id:i.id,name:i.name,property:i.property,loop:i.loop,symbol:(p=(a=t.find(l=>l.source==="flow"&&l.flowId===i.id))==null?void 0:a.symbol)!=null?p:"",steps:i.steps.map(l=>({value:l.value,effects:l.cssclass.trim()?[{property:"cssclasses",value:l.cssclass.trim().split(/\s+/).join(", ")}]:[]}))})});for(let i of t)i.source==="open"&&e.push(v({name:i.property,symbol:i.symbol,property:i.property,kind:"open",valueMode:i.valueMode})),i.source==="finite"&&e.push(v({name:i.property,symbol:i.symbol,property:i.property,steps:i.values.map(a=>({value:a,effects:[]}))}));return{flows:e}}var u=require("obsidian");var E=class extends u.PluginSettingTab{constructor(t,e){super(t,e);this.plugin=e;this.expanded=new Set;this.save=()=>this.plugin.saveSettings()}async saveAndRedraw(){await this.save(),this.display()}display(){let{containerEl:t}=this,e=this.plugin.settings.flows;t.empty(),new u.Setting(t).setHeading().setName("Flows").setDesc("Type a flow's symbol at the start of a word to pLine truncated
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"id": "fflow", "id": "fflow",
"name": "FFLOW", "name": "FFLOW",
"version": "0.3.0", "version": "0.3.1",
"minAppVersion": "1.11.0", "minAppVersion": "1.11.0",
"description": "Frontmatter Flow: type a trigger symbol (like @) to autocomplete and set a frontmatter property.", "description": "Frontmatter Flow: type a trigger symbol (like @) to autocomplete and set a frontmatter property.",
"author": "Olivier Legendre", "author": "Olivier Legendre",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "fflow", "name": "fflow",
"version": "0.3.0", "version": "0.3.1",
"description": "Frontmatter Flow: set properties from the editor with trigger symbols.", "description": "Frontmatter Flow: set properties from the editor with trigger symbols.",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
+155 -139
View File
@@ -1,8 +1,22 @@
import { App, PluginSettingTab, SearchComponent, Setting, SettingGroup } from "obsidian"; import {
App,
DropdownComponent,
ExtraButtonComponent,
PluginSettingTab,
SearchComponent,
setIcon,
Setting,
setTooltip,
TextComponent,
ToggleComponent,
} from "obsidian";
import type FflowPlugin from "./main"; import type FflowPlugin from "./main";
import { BLOCKED_SYMBOLS, Flow, FlowKind, FlowStep, newFlow, symbolError, ValueMode } from "./settings"; import { BLOCKED_SYMBOLS, Flow, FlowKind, FlowStep, newFlow, symbolError, ValueMode } from "./settings";
export class FflowSettingTab extends PluginSettingTab { export class FflowSettingTab extends PluginSettingTab {
/** Flows shown open. Kept across redraws, not saved: every visit starts with compact cards. */
private expanded = new Set<string>();
constructor(app: App, private plugin: FflowPlugin) { constructor(app: App, private plugin: FflowPlugin) {
super(app, plugin); super(app, plugin);
} }
@@ -23,222 +37,216 @@ export class FflowSettingTab extends PluginSettingTab {
new Setting(containerEl) new Setting(containerEl)
.setHeading() .setHeading()
.setName("Flows") .setName("Flows")
.setDesc( .setDesc("Type a flow's symbol at the start of a word to pick a value. Ordered flows also get next/previous step commands.")
`Type a flow's symbol at the start of a word and pick a value: the text disappears, the property is set, and the step's other properties are applied. Ordered flows get “next step” and “previous step” commands for hotkeys. Reserved symbols: ${BLOCKED_SYMBOLS.join(" ")}`,
)
.addButton((b) => b.setButtonText("Hotkeys").onClick(() => this.openHotkeys())) .addButton((b) => b.setButtonText("Hotkeys").onClick(() => this.openHotkeys()))
.addButton((b) => .addButton((b) =>
b.setButtonText("Add flow").onClick(async () => { b
flows.push(newFlow({ steps: [{ value: "", effects: [] }] })); .setButtonText("Add flow")
.setCta()
.onClick(async () => {
const flow = newFlow({ steps: [{ value: "", effects: [] }] });
flows.push(flow);
this.expanded.add(flow.id);
await this.saveAndRedraw(); await this.saveAndRedraw();
}), }),
); );
flows.forEach((flow, index) => this.renderFlow(flow, index)); const list = containerEl.createDiv({ cls: "fflow-list" });
flows.forEach((flow, index) => this.renderFlow(list, flow, index));
if (flows.length === 0) list.createDiv({ cls: "fflow-empty", text: "No flows yet." });
} }
private renderFlow(flow: Flow, index: number): void { private renderFlow(parent: HTMLElement, flow: Flow, index: number): void {
const flows = this.plugin.settings.flows; const flows = this.plugin.settings.flows;
const card = parent.createDiv({ cls: "fflow-card" });
card.toggleClass("is-collapsed", !this.expanded.has(flow.id));
const title = createFragment(); // Header: always visible, toggles the body.
const badge = title.createSpan({ cls: "fflow-badge" }); const header = card.createDiv({ cls: "fflow-card-header" });
const name = title.createSpan(); setIcon(header.createSpan({ cls: "fflow-chevron" }), "chevron-right");
const updateTitle = () => { const badge = header.createSpan({ cls: "fflow-badge" });
const title = header.createSpan({ cls: "fflow-title" });
const summary = header.createSpan({ cls: "fflow-summary" });
const updateHeader = () => {
badge.setText(flow.symbol); badge.setText(flow.symbol);
badge.toggle(flow.symbol !== ""); badge.toggle(flow.symbol !== "");
name.setText(flow.name || flow.property || "New flow"); title.setText(flow.name || flow.property || "New flow");
const values = flow.steps.map((s) => s.value).filter(Boolean);
summary.setText(
[flow.property, flow.kind === "open" ? "open list" : values.join(" → ") || "no steps"].filter(Boolean).join(" · "),
);
}; };
updateTitle(); updateHeader();
header.addEventListener("click", () => {
const group = new SettingGroup(this.containerEl).setHeading(title).addClass("fflow-group"); const open = !this.expanded.has(flow.id);
group.addExtraButton((b) => if (open) this.expanded.add(flow.id);
b else this.expanded.delete(flow.id);
.setIcon("trash") card.toggleClass("is-collapsed", !open);
});
const remove = new ExtraButtonComponent(header.createDiv({ cls: "fflow-header-actions" }))
.setIcon("trash-2")
.setTooltip("Delete flow") .setTooltip("Delete flow")
.onClick(async () => { .onClick(async () => {
flows.splice(index, 1); flows.splice(index, 1);
this.expanded.delete(flow.id);
await this.saveAndRedraw(); await this.saveAndRedraw();
}), });
); remove.extraSettingsEl.addEventListener("click", (e) => e.stopPropagation());
group.addSetting((s) => const body = card.createDiv({ cls: "fflow-card-body" });
s
.setName("Name") // Identity: one compact row of labelled fields.
.setDesc(flow.kind === "ordered" ? "Labels the hotkey commands." : "For your reference.") const fields = body.createDiv({ cls: "fflow-fields" });
.addText((t) => const field = (label: string, cls = "") => {
t const el = fields.createDiv({ cls: `fflow-field ${cls}` });
el.createDiv({ cls: "fflow-label", text: label });
return el;
};
new TextComponent(field("Name", "is-wide"))
.setPlaceholder("Status") .setPlaceholder("Status")
.setValue(flow.name) .setValue(flow.name)
.onChange(async (value) => { .onChange(async (value) => {
flow.name = value; flow.name = value;
updateTitle(); updateHeader();
await this.save(); await this.save();
}), });
),
);
group.addSetting((s) => { const symbolField = field("Symbol", "is-narrow");
s.setName("Symbol").setDesc("Optional. One character, not a letter or digit."); const symbol = new TextComponent(symbolField).setPlaceholder("—").setValue(flow.symbol);
const error = s.descEl.createDiv({ cls: "fflow-error" }); symbol.inputEl.addClass("fflow-symbol");
error.setText(symbolError(flow.symbol, flows, index) ?? ""); setTooltip(symbol.inputEl, `Optional. One character, not a letter or digit. Reserved: ${BLOCKED_SYMBOLS.join(" ")}`);
s.addText((t) => { const error = body.createDiv({ cls: "fflow-error", text: symbolError(flow.symbol, flows, index) ?? "" });
t.setPlaceholder("@").setValue(flow.symbol); symbol.onChange(async (value) => {
t.inputEl.addClass("fflow-symbol");
t.onChange(async (value) => {
const problem = symbolError(value, flows, index); const problem = symbolError(value, flows, index);
error.setText(problem ?? ""); error.setText(problem ?? "");
symbol.inputEl.toggleClass("is-invalid", problem !== null);
// Invalid input stays in the field but is never saved. // Invalid input stays in the field but is never saved.
if (problem) return; if (problem) return;
flow.symbol = value; flow.symbol = value;
updateTitle(); updateHeader();
await this.save(); await this.save();
}); });
});
});
group.addSetting((s) => { new TextComponent(field("Property", "is-wide"))
s.setName("Property")
.setDesc(
flow.kind === "ordered"
? "Ordered: the steps below, in order. Each step can set other properties."
: "Open: every value already used in the vault; new values allowed. No steps or hotkeys.",
)
.addText((t) =>
t
.setPlaceholder("status") .setPlaceholder("status")
.setValue(flow.property) .setValue(flow.property)
.onChange(async (value) => { .onChange(async (value) => {
flow.property = value.trim(); flow.property = value.trim();
updateTitle(); updateHeader();
await this.save(); await this.save();
}), });
)
.addDropdown((d) => new DropdownComponent(field("Kind"))
d
.addOptions({ ordered: "Ordered list", open: "Open (vault)" }) .addOptions({ ordered: "Ordered list", open: "Open (vault)" })
.setValue(flow.kind) .setValue(flow.kind)
.onChange(async (value) => { .onChange(async (value) => {
flow.kind = value as FlowKind; flow.kind = value as FlowKind;
await this.saveAndRedraw(); await this.saveAndRedraw();
}), });
);
if (flow.kind === "open") { if (flow.kind === "open") {
s.addDropdown((d) => new DropdownComponent(field("Values"))
d
.addOptions({ single: "Single value", list: "List" }) .addOptions({ single: "Single value", list: "List" })
.setValue(flow.valueMode) .setValue(flow.valueMode)
.onChange(async (value) => { .onChange(async (value) => {
flow.valueMode = value as ValueMode; flow.valueMode = value as ValueMode;
await this.save(); await this.save();
}),
);
}
}); });
body.createDiv({
cls: "fflow-hint",
text: "Suggests every value already used for this property in the vault. New values are allowed. No steps or hotkeys.",
});
return;
}
if (flow.kind === "open") return; new ToggleComponent(field("Loop", "is-toggle"))
.setValue(flow.loop)
group.addSetting((s) => .setTooltip("After the last step, “next” goes back to the first")
s .onChange(async (value) => {
.setName("Loop")
.setDesc("After the last step, “next” goes back to the first.")
.addToggle((t) =>
t.setValue(flow.loop).onChange(async (value) => {
flow.loop = value; flow.loop = value;
await this.save(); await this.save();
}), });
),
);
flow.steps.forEach((step, i) => this.renderStep(group, flow, step, i)); const steps = body.createDiv({ cls: "fflow-steps" });
const head = steps.createDiv({ cls: "fflow-step-row fflow-steps-head" });
head.createSpan();
head.createSpan({ text: "Value" });
head.createSpan({ text: "Also sets" });
flow.steps.forEach((step, i) => this.renderStep(steps, flow, step, i, updateHeader));
group.addSetting((s) => addLink(body.createDiv({ cls: "fflow-add-step" }), "Add step", async () => {
s.addButton((b) =>
b.setButtonText("Add step").onClick(async () => {
flow.steps.push({ value: "", effects: [] }); flow.steps.push({ value: "", effects: [] });
await this.saveAndRedraw(); await this.saveAndRedraw();
}), });
),
);
} }
private renderStep(group: SettingGroup, flow: Flow, step: FlowStep, i: number): void { private renderStep(parent: HTMLElement, flow: Flow, step: FlowStep, i: number, updateHeader: () => void): void {
group.addSetting((s) => { const row = parent.createDiv({ cls: "fflow-step-row" });
s.setName(`Step ${i + 1}`).setClass("fflow-step"); row.createSpan({ cls: "fflow-step-num", text: String(i + 1) });
s.addText((t) =>
t new TextComponent(row.createDiv({ cls: "fflow-step-value" }))
.setPlaceholder("value") .setPlaceholder("value")
.setValue(step.value) .setValue(step.value)
.onChange(async (value) => { .onChange(async (value) => {
step.value = value.trim(); step.value = value.trim();
updateHeader();
await this.save(); await this.save();
}),
);
s.addExtraButton((b) =>
b
.setIcon("list-plus")
.setTooltip("Also set a property")
.onClick(async () => {
step.effects.push({ property: "", value: "" });
await this.saveAndRedraw();
}),
);
const move = async (to: number) => {
flow.steps.splice(to, 0, ...flow.steps.splice(i, 1));
await this.saveAndRedraw();
};
s.addExtraButton((b) => b.setIcon("arrow-up").setTooltip("Move up").setDisabled(i === 0).onClick(() => move(i - 1)));
s.addExtraButton((b) =>
b
.setIcon("arrow-down")
.setTooltip("Move down")
.setDisabled(i === flow.steps.length - 1)
.onClick(() => move(i + 1)),
);
s.addExtraButton((b) =>
b
.setIcon("x")
.setTooltip("Remove step")
.onClick(async () => {
flow.steps.splice(i, 1);
await this.saveAndRedraw();
}),
);
}); });
step.effects.forEach((effect, j) => const effects = row.createDiv({ cls: "fflow-effects" });
group.addSetting((s) => step.effects.forEach((effect, j) => {
s const line = effects.createDiv({ cls: "fflow-effect" });
.setClass("fflow-effect") new TextComponent(line)
.setDesc(j === 0 ? "Also sets" : "")
.addText((t) =>
t
.setPlaceholder("property") .setPlaceholder("property")
.setValue(effect.property) .setValue(effect.property)
.onChange(async (value) => { .onChange(async (value) => {
effect.property = value.trim(); effect.property = value.trim();
await this.save(); await this.save();
}), });
) line.createSpan({ cls: "fflow-equals", text: "=" });
.addText((t) => new TextComponent(line)
t
.setPlaceholder("value (lists: a, b)") .setPlaceholder("value (lists: a, b)")
.setValue(effect.value) .setValue(effect.value)
.onChange(async (value) => { .onChange(async (value) => {
effect.value = value; effect.value = value;
await this.save(); await this.save();
}), });
) new ExtraButtonComponent(line)
.addExtraButton((b) => .setIcon("minus")
b .setTooltip("Remove this property")
.setIcon("x")
.setTooltip("Remove property")
.onClick(async () => { .onClick(async () => {
step.effects.splice(j, 1); step.effects.splice(j, 1);
await this.saveAndRedraw(); await this.saveAndRedraw();
}), });
), });
), addLink(effects, "property", async () => {
); step.effects.push({ property: "", value: "" });
await this.saveAndRedraw();
});
const actions = row.createDiv({ cls: "fflow-step-actions" });
const move = async (to: number) => {
flow.steps.splice(to, 0, ...flow.steps.splice(i, 1));
await this.saveAndRedraw();
};
new ExtraButtonComponent(actions)
.setIcon("arrow-up")
.setTooltip("Move up")
.setDisabled(i === 0)
.onClick(() => move(i - 1));
new ExtraButtonComponent(actions)
.setIcon("arrow-down")
.setTooltip("Move down")
.setDisabled(i === flow.steps.length - 1)
.onClick(() => move(i + 1));
new ExtraButtonComponent(actions)
.setIcon("trash-2")
.setTooltip("Delete step")
.onClick(async () => {
flow.steps.splice(i, 1);
await this.saveAndRedraw();
});
} }
/** Opens Settings → Hotkeys filtered on this plugin. `app.setting` and the tab's search box are internal API: probe before use. */ /** Opens Settings → Hotkeys filtered on this plugin. `app.setting` and the tab's search box are internal API: probe before use. */
@@ -252,3 +260,11 @@ export class FflowSettingTab extends PluginSettingTab {
search.inputEl.dispatchEvent(new Event("input")); search.inputEl.dispatchEvent(new Event("input"));
} }
} }
/** A quiet "+ label" button, used for adding steps and properties. */
function addLink(parent: HTMLElement, label: string, onClick: () => Promise<void>): void {
const button = parent.createEl("button", { cls: "fflow-add clickable-icon" });
setIcon(button.createSpan(), "plus");
button.createSpan({ text: label });
button.addEventListener("click", () => void onClick());
}
+228 -21
View File
@@ -1,47 +1,254 @@
.fflow-error { /* ---------- Settings: flow cards ---------- */
color: var(--text-error);
.fflow-list {
display: flex;
flex-direction: column;
gap: var(--size-4-3);
margin-top: var(--size-4-2);
} }
.fflow-error:empty { .fflow-empty {
color: var(--text-muted);
padding: var(--size-4-4);
text-align: center;
border: 1px dashed var(--background-modifier-border);
border-radius: var(--radius-l);
}
.fflow-card {
border: 1px solid var(--background-modifier-border);
border-radius: var(--radius-l);
background: var(--background-primary-alt);
overflow: hidden;
}
.fflow-card-header {
display: flex;
align-items: center;
gap: var(--size-4-2);
padding: var(--size-4-2) var(--size-4-3);
cursor: pointer;
user-select: none;
}
.fflow-card-header:hover {
background: var(--background-modifier-hover);
}
.fflow-chevron {
display: flex;
color: var(--text-faint);
transition: transform 120ms ease;
transform: rotate(90deg);
}
.fflow-card.is-collapsed .fflow-chevron {
transform: none;
}
.fflow-badge {
font-family: var(--font-monospace);
font-size: var(--font-ui-small);
min-width: 1.6em;
text-align: center;
padding: 0 0.35em;
border-radius: var(--radius-s);
background: var(--interactive-accent);
color: var(--text-on-accent);
}
.fflow-title {
font-weight: var(--font-semibold);
white-space: nowrap;
}
.fflow-summary {
flex: 1;
min-width: 0;
color: var(--text-muted);
font-size: var(--font-ui-small);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.fflow-header-actions {
display: flex;
}
.fflow-card-body {
padding: var(--size-4-3) var(--size-4-4) var(--size-4-4);
border-top: 1px solid var(--background-modifier-border);
background: var(--background-primary);
}
.fflow-card.is-collapsed .fflow-card-body {
display: none; display: none;
} }
/* Identity row: labelled fields side by side, wrapping on narrow windows. */
.fflow-fields {
display: flex;
flex-wrap: wrap;
gap: var(--size-4-3);
align-items: flex-end;
}
.fflow-field {
display: flex;
flex-direction: column;
gap: var(--size-2-2);
}
.fflow-field.is-wide {
flex: 1 1 9em;
}
.fflow-field.is-wide input {
width: 100%;
}
.fflow-field.is-toggle .checkbox-container {
margin: var(--size-2-2) 0;
}
.fflow-label {
font-size: var(--font-ui-smaller);
color: var(--text-muted);
}
.fflow-symbol { .fflow-symbol {
width: 3em; width: 3em;
text-align: center; text-align: center;
font-family: var(--font-monospace); font-family: var(--font-monospace);
} }
.fflow-badge { .fflow-symbol.is-invalid {
font-family: var(--font-monospace); border-color: var(--text-error);
background: var(--background-modifier-hover);
border-radius: var(--radius-s);
padding: 0 0.4em;
margin-right: 0.5em;
} }
.fflow-step .setting-item-control input[type="text"] { .fflow-error {
width: 14em; color: var(--text-error);
font-size: var(--font-ui-small);
margin-top: var(--size-2-3);
} }
/* Properties set by a step: indented, no separator line, so they read as part of the step above. */ .fflow-error:empty {
.setting-items > .setting-item.fflow-effect {
padding-top: 0;
padding-left: 2.5em;
}
.setting-items > .setting-item.fflow-effect::before {
display: none; display: none;
} }
.fflow-effect .setting-item-description { .fflow-hint {
margin-top: var(--size-4-3);
color: var(--text-muted);
font-size: var(--font-ui-small);
}
/* Steps: number | value | properties it also sets | actions. */
.fflow-steps {
margin-top: var(--size-4-4);
display: flex;
flex-direction: column;
}
.fflow-step-row {
display: grid;
grid-template-columns: 1.5em minmax(8em, 12em) 1fr auto;
gap: var(--size-4-2) var(--size-4-3);
align-items: start;
padding: var(--size-4-2) 0;
border-top: 1px solid var(--background-modifier-border);
}
.fflow-steps-head {
border-top: none;
padding-bottom: 0;
font-size: var(--font-ui-smaller);
color: var(--text-muted);
}
.fflow-step-num {
color: var(--text-faint);
font-variant-numeric: tabular-nums;
text-align: right;
line-height: var(--input-height);
}
.fflow-step-value input {
width: 100%;
font-weight: var(--font-medium);
}
.fflow-effects {
display: flex;
flex-direction: column;
gap: var(--size-2-3);
min-width: 0;
}
.fflow-effect {
display: flex;
align-items: center;
gap: var(--size-2-3);
}
.fflow-effect input {
flex: 1;
min-width: 0;
font-size: var(--font-ui-small);
}
.fflow-equals {
color: var(--text-faint); color: var(--text-faint);
} }
.fflow-effect .setting-item-control input[type="text"] { button.fflow-add {
width: 11em; align-self: flex-start;
display: flex;
align-items: center;
gap: var(--size-2-2);
height: var(--input-height);
padding: 0 var(--size-2-3);
font-size: var(--font-ui-small);
color: var(--text-muted);
background: none;
box-shadow: none;
} }
button.fflow-add:hover {
color: var(--text-normal);
}
.fflow-add svg {
width: var(--icon-xs);
height: var(--icon-xs);
}
/* Row actions stay quiet until the row is hovered or focused. */
.fflow-step-actions {
display: flex;
align-items: center;
height: var(--input-height);
opacity: 0.35;
transition: opacity 120ms ease;
}
.fflow-step-row:hover .fflow-step-actions,
.fflow-step-row:focus-within .fflow-step-actions {
opacity: 1;
}
.fflow-effect .clickable-icon {
color: var(--text-faint);
padding: var(--size-2-1);
}
.fflow-add-step {
margin-top: var(--size-2-3);
padding-left: calc(1.5em + var(--size-4-3));
}
/* ---------- Editor suggestions ---------- */
.fflow-suggestion { .fflow-suggestion {
display: flex; display: flex;
gap: var(--size-4-2); gap: var(--size-4-2);