FFLOW 0.4.0: {{date}}/{{time}} tokens with moment formats in step values
This commit is contained in:
1 parent
157e5e018a
commit
f5992e4539
8 files changed
+68
-20
No files matched your search
@@ -2,4 +2,4 @@
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
*/
|
||||
|
||||
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
|
||||
var P=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ie=(s,n)=>{for(var t in n)P(s,t,{get:n[t],enumerable:!0})},re=(s,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of se(n))!oe.call(s,o)&&o!==t&&P(s,o,{get:()=>n[o],enumerable:!(e=ne(n,o))||e.enumerable});return s};var ae=s=>re(P({},"__esModule",{value:!0}),s);var ge={};ie(ge,{default:()=>L});module.exports=ae(ge);var Z=require("obsidian");var I=require("obsidian");var U=require("obsidian");var R=require("obsidian"),Y=String.raw`\{\{(date|time)(?::([^}]*))?\}\}`,le={date:"YYYY-MM-DD",time:"HH:mm"},K=(s,n)=>(n==null?void 0:n.trim())||le[s];function V(s){let n=(0,R.moment)();return s.replace(new RegExp(Y,"g"),(t,e,o)=>n.format(K(e,o)))}function _(s,n){let t=new RegExp(Y,"g"),e=[],o="^",a=0;for(let r=t.exec(s);r;r=t.exec(s))o+=j(s.slice(a,r.index))+"(.+?)",e.push(K(r[1],r[2])),a=r.index+r[0].length;if(e.length===0)return s===n;let i=new RegExp(o+j(s.slice(a))+"$").exec(n);return i!==null&&e.every((r,l)=>(0,R.moment)(i[l+1],r,!0).isValid())}function j(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function x(s,n,t){let e=s.workspace.getActiveViewOfType(U.MarkdownView);(e==null?void 0:e.file)===n&&await e.save(),await s.fileManager.processFrontMatter(n,t)}function z(s,n,t,e){if(!e){s[n]=t;return}let o=O(s[n],n);o.includes(t)||o.push(t),s[n]=o}function b(s,n,t,e){var l;n[t.property]=e;let o=t.steps.find(p=>p.value===e),a=new Map,i=p=>{let d=a.get(p);return d===void 0&&a.set(p,d=pe(s,n,p)),d},r=p=>p.property!==""&&p.property!==t.property;for(let p of t.steps)if(p!==o)for(let d of p.effects.filter(r)){let c=d.property;if(i(c)){let h=W(d.value),g=O(n[c],c).filter(v=>!h.some(w=>q(w,v)));g.length?n[c]=g:delete n[c]}else c in n&&q(d.value,n[c])&&delete n[c]}for(let p of(l=o==null?void 0:o.effects.filter(r))!=null?l:[]){let d=p.property;if(i(d)){let c=O(n[d],d);for(let h of W(p.value).map(V))c.includes(h)||c.push(h);c.length&&(n[d]=c)}else n[d]=G(V(p.value))}}function pe(s,n,t){if(["cssclasses","tags","aliases"].includes(t)||Array.isArray(n[t]))return!0;let e=Reflect.get(s,"metadataTypeManager");if(!e||typeof e!="object"||!("getPropertyInfo"in e)||typeof e.getPropertyInfo!="function")return!1;let o=e.getPropertyInfo(t),a=o&&typeof o=="object"&&"widget"in o?o.widget:null;return a==="multitext"||a==="tags"||a==="aliases"}function O(s,n){return Array.isArray(s)?s.map(String):s==null||s===""?[]:n==="cssclasses"?String(s).split(/[\s,]+/).filter(Boolean):[String(s)]}function W(s){return s.split(/,(?![^{]*\}\})/).map(n=>n.trim()).filter(Boolean)}function q(s,n){let t=s.trim();return String(G(t))===String(n)||_(t,String(n))}function G(s){let n=s.trim();return n===""?null:n==="true"||n==="false"?n==="true":/^-?\d+(\.\d+)?$/.test(n)?Number(n):n}var C=class{constructor(n){this.plugin=n;this.registered=[]}sync(){for(let n of this.registered)this.plugin.removeCommand(n);this.registered=[];for(let n of this.plugin.settings.flows)n.kind==="ordered"&&(this.add(n,1,"next","next step"),this.add(n,-1,"previous","previous step"))}add(n,t,e,o){let a=`flow-${n.id}-${e}`;this.registered.push(a),this.plugin.addCommand({id:a,name:`${n.name||n.property||"Unnamed flow"}: ${o}`,checkCallback:i=>{let r=this.plugin.app.workspace.getActiveFile();return!r||r.extension!=="md"||!n.property||!n.steps.some(l=>l.value)?!1:(i||ce(this.plugin,r,n,t),!0)}})}};async function ce(s,n,t,e){let o=t.steps.filter(i=>i.value),a="";try{await x(s.app,n,i=>{let r=o.findIndex(p=>p.value===String(i[t.property])),l=r===-1?0:r+e;if(l<0||l>=o.length){if(!t.loop){a=`${t.property}: already at the ${e===1?"last":"first"} step`;return}l=(l+o.length)%o.length}b(s.app,i,t,o[l].value),a=`${t.property}: ${o[l].value}`}),new I.Notice(a)}catch(i){console.error("FFLOW: could not move flow step",i),new I.Notice(`FFLOW: could not set "${t.property}". See console.`)}}function y(s){return{id:Date.now().toString(36)+Math.random().toString(36).slice(2,6),name:"",symbol:"",property:"",kind:"ordered",valueMode:"single",loop:!1,steps:[],...s}}function ue(){return{flows:[y({name:"Type",symbol:"@",property:"type",kind:"open"})]}}var E=["#","[","/",":"];function S(s,n,t){return s===""?null:[...s].length!==1?"Use exactly one character.":/[\p{L}\p{N}\s]/u.test(s)?"Letters, digits and spaces are not allowed.":E.includes(s)?`"${s}" is reserved (${E.join(" ")}).`:n.some((e,o)=>o!==t&&e.symbol===s)?`"${s}" is already used by another flow.`:null}function J(s){var o,a;if(!s||typeof s!="object")return ue();if("flows"in s&&!("rules"in s)&&Array.isArray(s.flows))return{flows:s.flows.map(i=>y(i))};let n=s,t=(o=n.rules)!=null?o:[],e=((a=n.flows)!=null?a:[]).map(i=>{var r,l;return y({id:i.id,name:i.name,property:i.property,loop:i.loop,symbol:(l=(r=t.find(p=>p.source==="flow"&&p.flowId===i.id))==null?void 0:r.symbol)!=null?l:"",steps:i.steps.map(p=>({value:p.value,effects:p.cssclass.trim()?[{property:"cssclasses",value:p.cssclass.trim().split(/Line truncated
|
||||
Reference in new issue
Block a user