diff --git a/ROADMAP.md b/ROADMAP.md index a45f280..dfce80d 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,3 +1,9 @@ +--- +status: done +cssclasses: + - st-done +archived: true +--- # FFLOW roadmap ## Next @@ -7,6 +13,8 @@ ## 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.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. + diff --git a/main.js b/main.js index 2db428b..ddd6e15 100644 --- a/main.js +++ b/main.js @@ -2,4 +2,4 @@ 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, the property is set, and the step's other properties are applied. Ordered flows get \u201Cnext step\u201D and \u201Cprevious step\u201D commands for hotkeys. Reserved symbols: ${b.join(" ")}`).addButton(o=>o.setButtonText("Hotkeys").onClick(()=>this.openHotkeys())).addButton(o=>o.setButtonText("Add flow").onClick(async()=>{t.push(f({steps:[{value:"",effects:[]}]})),await this.saveAndRedraw()})),t.forEach((o,i)=>this.renderFlow(o,i))}renderFlow(e,t){let o=this.plugin.settings.flows,i=createFragment(),r=i.createSpan({cls:"fflow-badge"}),p=i.createSpan(),a=()=>{r.setText(e.symbol),r.toggle(e.symbol!==""),p.setText(e.name||e.property||"New flow")};a();let l=new g.SettingGroup(this.containerEl).setHeading(i).addClass("fflow-group");l.addExtraButton(d=>d.setIcon("trash").setTooltip("Delete flow").onClick(async()=>{o.splice(t,1),await this.saveAndRedraw()})),l.addSetting(d=>d.setName("Name").setDesc(e.kind==="ordered"?"Labels the hotkey commands.":"For your reference.").addText(u=>u.setPlaceholder("Status").setValue(e.name).onChange(async c=>{e.name=c,a(),await this.save()}))),l.addSetting(d=>{var c;d.setName("Symbol").setDesc("Optional. One character, not a letter or digit.");let u=d.descEl.createDiv({cls:"fflow-error"});u.setText((c=h(e.symbol,o,t))!=null?c:""),d.addText(m=>{m.setPlaceholder("@").setValue(e.symbol),m.inputEl.addClass("fflow-symbol"),m.onChange(async y=>{let w=h(y,o,t);u.setText(w!=null?w:""),!w&&(e.symbol=y,a(),await this.save())})})}),l.addSetting(d=>{d.setName("Property").setDesc(e.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(u=>u.setPlaceholder("status").setValue(e.property).onChange(async c=>{e.property=c.trim(),a(),await this.save()})).addDropdown(u=>u.addOptions({ordered:"Ordered list",open:"Open (vault)"}).setValue(e.kind).onChange(async c=>{e.kind=c,await this.saveAndRedraw()})),e.kind==="open"&&d.addDropdown(u=>u.addOptions({single:"Single value",list:"List"}).setValue(e.valueMode).onChange(async c=>{e.valueMode=c,await this.save()}))}),e.kind!=="open"&&(l.addSetting(d=>d.setName("Loop").setDesc("After the last step, \u201Cnext\u201D goes back to the first.").addToggle(u=>u.setValue(e.loop).onChange(async c=>{e.loop=c,await this.save()}))),e.steps.forEach((d,u)=>this.renderStep(l,e,d,u)),l.addSetting(d=>d.addButton(u=>u.setButtonText("Add step").onClick(async()=>{e.steps.push({value:"",effects:[]}),await this.saveAndRedraw()}))))}renderStep(e,t,o,i){e.addSetting(r=>{r.setName(`Step ${i+1}`).setClass("fflow-step"),r.addText(a=>a.setPlaceholder("value").setValue(o.value).onChange(async l=>{o.value=l.trim(),await this.save()})),r.addExtraButton(a=>a.setIcon("list-plus").setTooltip("Also set a property").onClick(async()=>{o.effects.push({property:"",value:""}),await this.saveAndRedraw()}));let p=async a=>{t.steps.splice(a,0,...t.steps.splice(i,1)),await this.saveAndRedraw()};r.addExtraButton(a=>a.setIcon("arrow-up").setTooltip("Move up").setDisabled(i===0).onClick(()=>p(i-1))),r.addExtraButton(a=>a.setIcon("arrow-down").setTooltip("Move down").setDisabled(i===t.steps.length-1).onClick(()=>p(i+1))),r.addExtraButton(a=>a.setIcon("x").setTooltip("Remove step").onClick(async()=>{t.steps.splice(i,1),await this.saveAndRedraw()}))}),o.effects.forEach((r,p)=>e.addSetting(a=>a.setClass("fflow-effect").setDesc(p===0?"Also sets":"").addText(l=>l.setPlaceholder("property").setValue(r.property).onChange(async d=>{r.property=d.trim(),await this.save()})).addText(l=>l.setPlaceholder("value (lists: a, b)").setValue(r.value).onChange(async d=>{r.value=d,await this.save()})).addExtraButton(l=>l.setIcon("x").setTooltip("Remove property").onClick(async()=>{o.effects.splice(p,1),await this.saveAndRedraw()}))))}openHotkeys(){let e=Reflect.get(this.app,"setting");if(!e||typeof e!="object"||!("openTabById"in e)||typeof e.openTabById!="function")return;let t=e.openTabById("hotkeys"),o=t&&typeof t=="object"&&"searchComponent"in t?t.searchComponent:null;o instanceof g.SearchComponent&&(o.setValue(this.plugin.manifest.name),o.inputEl.dispatchEvent(new Event("input")))}};var E=require("obsidian");var C=class{constructor(s){this.app=s;this.cache=new Map}invalidate(){this.cache.clear()}get(s){var t,o,i;let e=this.cache.get(s);if(e)return e;e=new Map;for(let r of this.app.vault.getMarkdownFiles()){let p=(o=(t=this.app.metadataCache.getFileCache(r))==null?void 0:t.frontmatter)==null?void 0:o[s];for(let a of new Set(V(p)))e.set(a,((i=e.get(a))!=null?i:0)+1)}return this.cache.set(s,e),e}};function V(n){return Array.isArray(n)?n.flatMap(V):typeof n=="string"?n.trim()?[n.trim()]:[]:typeof n=="number"||typeof n=="boolean"?[String(n)]:[]}var P=n=>n!==void 0&&/\s/.test(n),k=class extends E.EditorSuggest{constructor(e,t,o){super(e);this.plugin=t;this.index=o;this.flow=null}onTrigger(e,t,o){let i=t.getLine(e.line).slice(0,e.ch),r=i.length;for(;r>0&&!P(i[r-1]);)r--;let p=i.slice(r);if(!p)return null;let a=this.plugin.settings.flows,l=a.findIndex(u=>u.symbol!==""&&u.symbol===p[0]),d=a[l];return!d||!d.property||h(d.symbol,a,l)||Y(t,e.line)||z(t,e.line,i.slice(0,r))?null:(this.flow=d,{start:{line:e.line,ch:r},end:e,query:p.slice(1)})}getSuggestions(e){let t=this.flow;if(!t)return[];let o=e.query.toLowerCase(),i=t.kind==="ordered"?t.steps.filter(p=>p.value).map(p=>({value:p.value,isNew:!1})):[...this.index.get(t.property)].sort((p,a)=>a[1]-p[1]||p[0].localeCompare(a[0])).map(([p,a])=>({value:p,count:a,isNew:!1})),r=i.filter(p=>p.value.toLowerCase().includes(o));return r.sort((p,a)=>+!p.value.toLowerCase().startsWith(o)-+!a.value.toLowerCase().startsWith(o)),t.kind==="open"&&o&&!i.some(p=>p.value.toLowerCase()===o)&&r.push({value:e.query,isNew:!0}),r}renderSuggestion(e,t){if(t.addClass("fflow-suggestion"),e.isNew){t.createSpan({cls:"fflow-new",text:"New: "}),t.createSpan({text:e.value});return}t.createSpan({text:e.value}),e.count!==void 0&&t.createSpan({cls:"fflow-count",text:String(e.count)})}selectSuggestion(e,t){let o=this.context,i=this.flow;!o||!i||this.apply(o,i,e.value)}async apply(e,t,o){let{editor:i,file:r,start:p}=e,a=i.getLine(p.line),l=e.end.ch;for(;l{t.kind==="ordered"?F(this.app,d,t,o):I(d,t.property,o,t.valueMode==="list")})}catch(d){console.error("FFLOW: could not update frontmatter",d),new E.Notice(`FFLOW: could not set "${t.property}". See console.`)}}};function Y(n,s){if(n.getLine(0)!=="---")return!1;for(let e=1;et.invalidate())),this.registerEvent(this.app.metadataCache.on("deleted",()=>t.invalidate())),this.registerEditorSuggest(new k(this.app,this,t)),this.flowCommands.sync(),this.addSettingTab(new x(this.app,this))}async saveSettings(){await this.saveData(this.settings),this.flowCommands.sync()}}; +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 pick a value. Ordered flows also get next/previous step commands.").addButton(r=>r.setButtonText("Hotkeys").onClick(()=>this.openHotkeys())).addButton(r=>r.setButtonText("Add flow").setCta().onClick(async()=>{let i=v({steps:[{value:"",effects:[]}]});e.push(i),this.expanded.add(i.id),await this.saveAndRedraw()}));let o=t.createDiv({cls:"fflow-list"});e.forEach((r,i)=>this.renderFlow(o,r,i)),e.length===0&&o.createDiv({cls:"fflow-empty",text:"No flows yet."})}renderFlow(t,e,o){var R;let r=this.plugin.settings.flows,i=t.createDiv({cls:"fflow-card"});i.toggleClass("is-collapsed",!this.expanded.has(e.id));let a=i.createDiv({cls:"fflow-card-header"});(0,u.setIcon)(a.createSpan({cls:"fflow-chevron"}),"chevron-right");let p=a.createSpan({cls:"fflow-badge"}),l=a.createSpan({cls:"fflow-title"}),d=a.createSpan({cls:"fflow-summary"}),c=()=>{p.setText(e.symbol),p.toggle(e.symbol!==""),l.setText(e.name||e.property||"New flow");let f=e.steps.map(w=>w.value).filter(Boolean);d.setText([e.property,e.kind==="open"?"open list":f.join(" \u2192 ")||"no steps"].filter(Boolean).join(" \xB7 "))};c(),a.addEventListener("click",()=>{let f=!this.expanded.has(e.id);f?this.expanded.add(e.id):this.expanded.delete(e.id),i.toggleClass("is-collapsed",!f)}),new u.ExtraButtonComponent(a.createDiv({cls:"fflow-header-actions"})).setIcon("trash-2").setTooltip("Delete flow").onClick(async()=>{r.splice(o,1),this.expanded.delete(e.id),await this.saveAndRedraw()}).extraSettingsEl.addEventListener("click",f=>f.stopPropagation());let g=i.createDiv({cls:"fflow-card-body"}),h=g.createDiv({cls:"fflow-fields"}),y=(f,w="")=>{let B=h.createDiv({cls:`fflow-field ${w}`});return B.createDiv({cls:"fflow-label",text:f}),B};new u.TextComponent(y("Name","is-wide")).setPlaceholder("Status").setValue(e.name).onChange(async f=>{e.name=f,c(),await this.save()});let Y=y("Symbol","is-narrow"),F=new u.TextComponent(Y).setPlaceholder("\u2014").setValue(e.symbol);F.inputEl.addClass("fflow-symbol"),(0,u.setTooltip)(F.inputEl,`Optional. One character, not a letter or digit. Reserved: ${k.join(" ")}`);let z=g.createDiv({cls:"fflow-error",text:(R=S(e.symbol,r,o))!=null?R:""});if(F.onChange(async f=>{let w=S(f,r,o);z.setText(w!=null?w:""),F.inputEl.toggleClass("is-invalid",w!==null),!w&&(e.symbol=f,c(),await this.save())}),new u.TextComponent(y("Property","is-wide")).setPlaceholder("status").setValue(e.property).onChange(async f=>{e.property=f.trim(),c(),await this.save()}),new u.DropdownComponent(y("Kind")).addOptions({ordered:"Ordered list",open:"Open (vault)"}).setValue(e.kind).onChange(async f=>{e.kind=f,await this.saveAndRedraw()}),e.kind==="open"){new u.DropdownComponent(y("Values")).addOptions({single:"Single value",list:"List"}).setValue(e.valueMode).onChange(async f=>{e.valueMode=f,await this.save()}),g.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}new u.ToggleComponent(y("Loop","is-toggle")).setValue(e.loop).setTooltip("After the last step, \u201Cnext\u201D goes back to the first").onChange(async f=>{e.loop=f,await this.save()});let O=g.createDiv({cls:"fflow-steps"}),A=O.createDiv({cls:"fflow-step-row fflow-steps-head"});A.createSpan(),A.createSpan({text:"Value"}),A.createSpan({text:"Also sets"}),e.steps.forEach((f,w)=>this.renderStep(O,e,f,w,c)),q(g.createDiv({cls:"fflow-add-step"}),"Add step",async()=>{e.steps.push({value:"",effects:[]}),await this.saveAndRedraw()})}renderStep(t,e,o,r,i){let a=t.createDiv({cls:"fflow-step-row"});a.createSpan({cls:"fflow-step-num",text:String(r+1)}),new u.TextComponent(a.createDiv({cls:"fflow-step-value"})).setPlaceholder("value").setValue(o.value).onChange(async c=>{o.value=c.trim(),i(),await this.save()});let p=a.createDiv({cls:"fflow-effects"});o.effects.forEach((c,m)=>{let g=p.createDiv({cls:"fflow-effect"});new u.TextComponent(g).setPlaceholder("property").setValue(c.property).onChange(async h=>{c.property=h.trim(),await this.save()}),g.createSpan({cls:"fflow-equals",text:"="}),new u.TextComponent(g).setPlaceholder("value (lists: a, b)").setValue(c.value).onChange(async h=>{c.value=h,await this.save()}),new u.ExtraButtonComponent(g).setIcon("minus").setTooltip("Remove this property").onClick(async()=>{o.effects.splice(m,1),await this.saveAndRedraw()})}),q(p,"property",async()=>{o.effects.push({property:"",value:""}),await this.saveAndRedraw()});let l=a.createDiv({cls:"fflow-step-actions"}),d=async c=>{e.steps.splice(c,0,...e.steps.splice(r,1)),await this.saveAndRedraw()};new u.ExtraButtonComponent(l).setIcon("arrow-up").setTooltip("Move up").setDisabled(r===0).onClick(()=>d(r-1)),new u.ExtraButtonComponent(l).setIcon("arrow-down").setTooltip("Move down").setDisabled(r===e.steps.length-1).onClick(()=>d(r+1)),new u.ExtraButtonComponent(l).setIcon("trash-2").setTooltip("Delete step").onClick(async()=>{e.steps.splice(r,1),await this.saveAndRedraw()})}openHotkeys(){let t=Reflect.get(this.app,"setting");if(!t||typeof t!="object"||!("openTabById"in t)||typeof t.openTabById!="function")return;let e=t.openTabById("hotkeys"),o=e&&typeof e=="object"&&"searchComponent"in e?e.searchComponent:null;o instanceof u.SearchComponent&&(o.setValue(this.plugin.manifest.name),o.inputEl.dispatchEvent(new Event("input")))}};function q(n,s,t){let e=n.createEl("button",{cls:"fflow-add clickable-icon"});(0,u.setIcon)(e.createSpan(),"plus"),e.createSpan({text:s}),e.addEventListener("click",()=>void t())}var D=require("obsidian");var L=class{constructor(s){this.app=s;this.cache=new Map}invalidate(){this.cache.clear()}get(s){var e,o,r;let t=this.cache.get(s);if(t)return t;t=new Map;for(let i of this.app.vault.getMarkdownFiles()){let a=(o=(e=this.app.metadataCache.getFileCache(i))==null?void 0:e.frontmatter)==null?void 0:o[s];for(let p of new Set(_(a)))t.set(p,((r=t.get(p))!=null?r:0)+1)}return this.cache.set(s,t),t}};function _(n){return Array.isArray(n)?n.flatMap(_):typeof n=="string"?n.trim()?[n.trim()]:[]:typeof n=="number"||typeof n=="boolean"?[String(n)]:[]}var N=n=>n!==void 0&&/\s/.test(n),T=class extends D.EditorSuggest{constructor(t,e,o){super(t);this.plugin=e;this.index=o;this.flow=null}onTrigger(t,e,o){let r=e.getLine(t.line).slice(0,t.ch),i=r.length;for(;i>0&&!N(r[i-1]);)i--;let a=r.slice(i);if(!a)return null;let p=this.plugin.settings.flows,l=p.findIndex(c=>c.symbol!==""&&c.symbol===a[0]),d=p[l];return!d||!d.property||S(d.symbol,p,l)||oe(e,t.line)||ie(e,t.line,r.slice(0,i))?null:(this.flow=d,{start:{line:t.line,ch:i},end:t,query:a.slice(1)})}getSuggestions(t){let e=this.flow;if(!e)return[];let o=t.query.toLowerCase(),r=e.kind==="ordered"?e.steps.filter(a=>a.value).map(a=>({value:a.value,isNew:!1})):[...this.index.get(e.property)].sort((a,p)=>p[1]-a[1]||a[0].localeCompare(p[0])).map(([a,p])=>({value:a,count:p,isNew:!1})),i=r.filter(a=>a.value.toLowerCase().includes(o));return i.sort((a,p)=>+!a.value.toLowerCase().startsWith(o)-+!p.value.toLowerCase().startsWith(o)),e.kind==="open"&&o&&!r.some(a=>a.value.toLowerCase()===o)&&i.push({value:t.query,isNew:!0}),i}renderSuggestion(t,e){if(e.addClass("fflow-suggestion"),t.isNew){e.createSpan({cls:"fflow-new",text:"New: "}),e.createSpan({text:t.value});return}e.createSpan({text:t.value}),t.count!==void 0&&e.createSpan({cls:"fflow-count",text:String(t.count)})}selectSuggestion(t,e){let o=this.context,r=this.flow;!o||!r||this.apply(o,r,t.value)}async apply(t,e,o){let{editor:r,file:i,start:a}=t,p=r.getLine(a.line),l=t.end.ch;for(;l{e.kind==="ordered"?x(this.app,d,e,o):K(d,e.property,o,e.valueMode==="list")})}catch(d){console.error("FFLOW: could not update frontmatter",d),new D.Notice(`FFLOW: could not set "${e.property}". See console.`)}}};function oe(n,s){if(n.getLine(0)!=="---")return!1;for(let t=1;te.invalidate())),this.registerEvent(this.app.metadataCache.on("deleted",()=>e.invalidate())),this.registerEditorSuggest(new T(this.app,this,e)),this.flowCommands.sync(),this.addSettingTab(new E(this.app,this))}async saveSettings(){await this.saveData(this.settings),this.flowCommands.sync()}}; diff --git a/manifest.json b/manifest.json index f83ac24..cf1201f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "fflow", "name": "FFLOW", - "version": "0.3.0", + "version": "0.3.1", "minAppVersion": "1.11.0", "description": "Frontmatter Flow: type a trigger symbol (like @) to autocomplete and set a frontmatter property.", "author": "Olivier Legendre", diff --git a/package.json b/package.json index d6316f9..4110bd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fflow", - "version": "0.3.0", + "version": "0.3.1", "description": "Frontmatter Flow: set properties from the editor with trigger symbols.", "main": "main.js", "scripts": { diff --git a/src/settings-tab.ts b/src/settings-tab.ts index bcd0523..86f8402 100644 --- a/src/settings-tab.ts +++ b/src/settings-tab.ts @@ -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 { BLOCKED_SYMBOLS, Flow, FlowKind, FlowStep, newFlow, symbolError, ValueMode } from "./settings"; export class FflowSettingTab extends PluginSettingTab { + /** Flows shown open. Kept across redraws, not saved: every visit starts with compact cards. */ + private expanded = new Set(); + constructor(app: App, private plugin: FflowPlugin) { super(app, plugin); } @@ -23,222 +37,216 @@ export class FflowSettingTab extends PluginSettingTab { new Setting(containerEl) .setHeading() .setName("Flows") - .setDesc( - `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(" ")}`, - ) + .setDesc("Type a flow's symbol at the start of a word to pick a value. Ordered flows also get next/previous step commands.") .addButton((b) => b.setButtonText("Hotkeys").onClick(() => this.openHotkeys())) .addButton((b) => - b.setButtonText("Add flow").onClick(async () => { - flows.push(newFlow({ steps: [{ value: "", effects: [] }] })); - await this.saveAndRedraw(); - }), + b + .setButtonText("Add flow") + .setCta() + .onClick(async () => { + const flow = newFlow({ steps: [{ value: "", effects: [] }] }); + flows.push(flow); + this.expanded.add(flow.id); + 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 card = parent.createDiv({ cls: "fflow-card" }); + card.toggleClass("is-collapsed", !this.expanded.has(flow.id)); - const title = createFragment(); - const badge = title.createSpan({ cls: "fflow-badge" }); - const name = title.createSpan(); - const updateTitle = () => { + // Header: always visible, toggles the body. + const header = card.createDiv({ cls: "fflow-card-header" }); + setIcon(header.createSpan({ cls: "fflow-chevron" }), "chevron-right"); + 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.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 open = !this.expanded.has(flow.id); + if (open) this.expanded.add(flow.id); + else this.expanded.delete(flow.id); + card.toggleClass("is-collapsed", !open); + }); + const remove = new ExtraButtonComponent(header.createDiv({ cls: "fflow-header-actions" })) + .setIcon("trash-2") + .setTooltip("Delete flow") + .onClick(async () => { + flows.splice(index, 1); + this.expanded.delete(flow.id); + await this.saveAndRedraw(); + }); + remove.extraSettingsEl.addEventListener("click", (e) => e.stopPropagation()); - const group = new SettingGroup(this.containerEl).setHeading(title).addClass("fflow-group"); - group.addExtraButton((b) => - b - .setIcon("trash") - .setTooltip("Delete flow") - .onClick(async () => { - flows.splice(index, 1); - await this.saveAndRedraw(); - }), - ); + const body = card.createDiv({ cls: "fflow-card-body" }); - group.addSetting((s) => - s - .setName("Name") - .setDesc(flow.kind === "ordered" ? "Labels the hotkey commands." : "For your reference.") - .addText((t) => - t - .setPlaceholder("Status") - .setValue(flow.name) - .onChange(async (value) => { - flow.name = value; - updateTitle(); - await this.save(); - }), - ), - ); + // Identity: one compact row of labelled fields. + const fields = body.createDiv({ cls: "fflow-fields" }); + const field = (label: string, cls = "") => { + const el = fields.createDiv({ cls: `fflow-field ${cls}` }); + el.createDiv({ cls: "fflow-label", text: label }); + return el; + }; - group.addSetting((s) => { - s.setName("Symbol").setDesc("Optional. One character, not a letter or digit."); - const error = s.descEl.createDiv({ cls: "fflow-error" }); - error.setText(symbolError(flow.symbol, flows, index) ?? ""); - s.addText((t) => { - t.setPlaceholder("@").setValue(flow.symbol); - t.inputEl.addClass("fflow-symbol"); - t.onChange(async (value) => { - const problem = symbolError(value, flows, index); - error.setText(problem ?? ""); - // Invalid input stays in the field but is never saved. - if (problem) return; - flow.symbol = value; - updateTitle(); + new TextComponent(field("Name", "is-wide")) + .setPlaceholder("Status") + .setValue(flow.name) + .onChange(async (value) => { + flow.name = value; + updateHeader(); + await this.save(); + }); + + const symbolField = field("Symbol", "is-narrow"); + const symbol = new TextComponent(symbolField).setPlaceholder("—").setValue(flow.symbol); + symbol.inputEl.addClass("fflow-symbol"); + setTooltip(symbol.inputEl, `Optional. One character, not a letter or digit. Reserved: ${BLOCKED_SYMBOLS.join(" ")}`); + const error = body.createDiv({ cls: "fflow-error", text: symbolError(flow.symbol, flows, index) ?? "" }); + symbol.onChange(async (value) => { + const problem = symbolError(value, flows, index); + error.setText(problem ?? ""); + symbol.inputEl.toggleClass("is-invalid", problem !== null); + // Invalid input stays in the field but is never saved. + if (problem) return; + flow.symbol = value; + updateHeader(); + await this.save(); + }); + + new TextComponent(field("Property", "is-wide")) + .setPlaceholder("status") + .setValue(flow.property) + .onChange(async (value) => { + flow.property = value.trim(); + updateHeader(); + await this.save(); + }); + + new DropdownComponent(field("Kind")) + .addOptions({ ordered: "Ordered list", open: "Open (vault)" }) + .setValue(flow.kind) + .onChange(async (value) => { + flow.kind = value as FlowKind; + await this.saveAndRedraw(); + }); + + if (flow.kind === "open") { + new DropdownComponent(field("Values")) + .addOptions({ single: "Single value", list: "List" }) + .setValue(flow.valueMode) + .onChange(async (value) => { + flow.valueMode = value as ValueMode; 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; + } + + new ToggleComponent(field("Loop", "is-toggle")) + .setValue(flow.loop) + .setTooltip("After the last step, “next” goes back to the first") + .onChange(async (value) => { + flow.loop = value; + await this.save(); + }); + + 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)); + + addLink(body.createDiv({ cls: "fflow-add-step" }), "Add step", async () => { + flow.steps.push({ value: "", effects: [] }); + await this.saveAndRedraw(); }); - - group.addSetting((s) => { - 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") - .setValue(flow.property) - .onChange(async (value) => { - flow.property = value.trim(); - updateTitle(); - await this.save(); - }), - ) - .addDropdown((d) => - d - .addOptions({ ordered: "Ordered list", open: "Open (vault)" }) - .setValue(flow.kind) - .onChange(async (value) => { - flow.kind = value as FlowKind; - await this.saveAndRedraw(); - }), - ); - if (flow.kind === "open") { - s.addDropdown((d) => - d - .addOptions({ single: "Single value", list: "List" }) - .setValue(flow.valueMode) - .onChange(async (value) => { - flow.valueMode = value as ValueMode; - await this.save(); - }), - ); - } - }); - - if (flow.kind === "open") return; - - group.addSetting((s) => - s - .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; - await this.save(); - }), - ), - ); - - flow.steps.forEach((step, i) => this.renderStep(group, flow, step, i)); - - group.addSetting((s) => - s.addButton((b) => - b.setButtonText("Add step").onClick(async () => { - flow.steps.push({ value: "", effects: [] }); - await this.saveAndRedraw(); - }), - ), - ); } - private renderStep(group: SettingGroup, flow: Flow, step: FlowStep, i: number): void { - group.addSetting((s) => { - s.setName(`Step ${i + 1}`).setClass("fflow-step"); - s.addText((t) => - t - .setPlaceholder("value") - .setValue(step.value) - .onChange(async (value) => { - step.value = value.trim(); - 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(); - }), - ); + private renderStep(parent: HTMLElement, flow: Flow, step: FlowStep, i: number, updateHeader: () => void): void { + const row = parent.createDiv({ cls: "fflow-step-row" }); + row.createSpan({ cls: "fflow-step-num", text: String(i + 1) }); + + new TextComponent(row.createDiv({ cls: "fflow-step-value" })) + .setPlaceholder("value") + .setValue(step.value) + .onChange(async (value) => { + step.value = value.trim(); + updateHeader(); + await this.save(); + }); + + const effects = row.createDiv({ cls: "fflow-effects" }); + step.effects.forEach((effect, j) => { + const line = effects.createDiv({ cls: "fflow-effect" }); + new TextComponent(line) + .setPlaceholder("property") + .setValue(effect.property) + .onChange(async (value) => { + effect.property = value.trim(); + await this.save(); + }); + line.createSpan({ cls: "fflow-equals", text: "=" }); + new TextComponent(line) + .setPlaceholder("value (lists: a, b)") + .setValue(effect.value) + .onChange(async (value) => { + effect.value = value; + await this.save(); + }); + new ExtraButtonComponent(line) + .setIcon("minus") + .setTooltip("Remove this property") + .onClick(async () => { + step.effects.splice(j, 1); + await this.saveAndRedraw(); + }); + }); + addLink(effects, "property", async () => { + step.effects.push({ property: "", value: "" }); + await this.saveAndRedraw(); }); - step.effects.forEach((effect, j) => - group.addSetting((s) => - s - .setClass("fflow-effect") - .setDesc(j === 0 ? "Also sets" : "") - .addText((t) => - t - .setPlaceholder("property") - .setValue(effect.property) - .onChange(async (value) => { - effect.property = value.trim(); - await this.save(); - }), - ) - .addText((t) => - t - .setPlaceholder("value (lists: a, b)") - .setValue(effect.value) - .onChange(async (value) => { - effect.value = value; - await this.save(); - }), - ) - .addExtraButton((b) => - b - .setIcon("x") - .setTooltip("Remove property") - .onClick(async () => { - step.effects.splice(j, 1); - 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. */ @@ -252,3 +260,11 @@ export class FflowSettingTab extends PluginSettingTab { 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 { + const button = parent.createEl("button", { cls: "fflow-add clickable-icon" }); + setIcon(button.createSpan(), "plus"); + button.createSpan({ text: label }); + button.addEventListener("click", () => void onClick()); +} diff --git a/styles.css b/styles.css index ef4de9f..61ddfad 100644 --- a/styles.css +++ b/styles.css @@ -1,47 +1,254 @@ -.fflow-error { - color: var(--text-error); +/* ---------- Settings: flow cards ---------- */ + +.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; } +/* 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 { width: 3em; text-align: center; font-family: var(--font-monospace); } -.fflow-badge { - font-family: var(--font-monospace); - background: var(--background-modifier-hover); - border-radius: var(--radius-s); - padding: 0 0.4em; - margin-right: 0.5em; +.fflow-symbol.is-invalid { + border-color: var(--text-error); } -.fflow-step .setting-item-control input[type="text"] { - width: 14em; +.fflow-error { + 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. */ -.setting-items > .setting-item.fflow-effect { - padding-top: 0; - padding-left: 2.5em; -} - -.setting-items > .setting-item.fflow-effect::before { +.fflow-error:empty { 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); } -.fflow-effect .setting-item-control input[type="text"] { - width: 11em; +button.fflow-add { + 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 { display: flex; gap: var(--size-4-2);