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
+450 -219

No files matched your search

+1 -1
View File
@@ -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 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