You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Handle order as third SMARTBLOCK parameter
* Enhance SMARTBLOCK command documentation and handler to support order parameter in the format `order=value`. Update examples to reflect new usage and improve argument parsing for page names and order specification.
* Refactor order parameter handling in SMARTBLOCK command to improve argument parsing. Use regex for order extraction and validate numeric values, ensuring robust title extraction from page names.
* 1.10.0
Copy file name to clipboardExpand all lines: docs/050-command-reference.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1098,11 +1098,16 @@ To set the default text of `embed`, set a variable named the same as the name of
1098
1098
1099
1099
1. The workflow name
1100
1100
2. An optional page name to execute the workflow on another page. The command will return a block reference to the other page if this parameter is set.
1101
+
3. When the second parameter is set, you may optionally pass an additional parameter in the format `order=value` to specify the order of the new block on that page. The value can be a number (0 to insert at the first position) or `last` to append to the end of the page.
Copy file name to clipboardExpand all lines: src/utils/core.ts
+66-18Lines changed: 66 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -1766,28 +1766,70 @@ export const COMMANDS: {
1766
1766
},
1767
1767
{
1768
1768
text: "SMARTBLOCK",
1769
-
help: "Runs another SmartBlock\n\n1. SmartBlock name\n\n2. Optional page name or ref to execute the workflow remotely",
1769
+
help: "Runs another SmartBlock\n\n1. SmartBlock name\n\n2. Optional page name or ref to execute the workflow remotely\n\n3. Optional order for the new block when running remotely in the format order=value (use a number or 'last' to append to the end)",
1770
1770
handler: (inputName="", ...pageNameOrUid)=>{
1771
1771
constsrcUid=getCleanCustomWorkflows().find(
1772
1772
({ name })=>name===inputName.trim()
1773
1773
)?.uid;
1774
1774
if(srcUid){
1775
1775
if(pageNameOrUid.length){
1776
-
consttitle=extractTag(pageNameOrUid.join(","));
1777
-
consttargetUid=getUidFromText(title);
1778
-
return(
1779
-
targetUid ? Promise.resolve(targetUid) : createPage({ title })
1780
-
).then((targetUid)=>{
1781
-
constparentContext={ ...smartBlocksContext};
1782
-
returnsbBomb({
1783
-
srcUid,
1784
-
target: {uid: targetUid,isParent: true},
1785
-
variables: smartBlocksContext.variables,
1786
-
}).then((uid)=>{
1787
-
resetContext(parentContext);
1788
-
returnuid ? `((${uid}))` : "";
1776
+
// Parse arguments to handle page name with potential order parameter
1777
+
lettitle: string;
1778
+
letorder: number|"last"|undefined;
1779
+
1780
+
if(pageNameOrUid.length===1){
1781
+
// Single argument - assume it is a page name
1782
+
constarg=pageNameOrUid[0];
1783
+
title=extractTag(arg);
1784
+
}else{
1785
+
// Multiple arguments - last one might be order=value
0 commit comments