From addebc6b68b3fe3afbd74bdb0296a500f35bd69c Mon Sep 17 00:00:00 2001 From: Johan Vromans Date: Tue, 6 Oct 2026 11:56:59 +0200 Subject: [PATCH 1/5] Placeholders can now ask the user for a value to substitute. This makes it possible to quickly add larger pieces of text where some parts are dynamic. --- quick-commands/CHANGELOG.md | 6 ++++ quick-commands/README.md | 46 ++++++++++++++++--------------- quick-commands/info.json | 2 +- quick-commands/quick-commands.qml | 29 +++++++++++++++---- 4 files changed, 55 insertions(+), 28 deletions(-) diff --git a/quick-commands/CHANGELOG.md b/quick-commands/CHANGELOG.md index 116cb0c..889305d 100644 --- a/quick-commands/CHANGELOG.md +++ b/quick-commands/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.3.2 - 2026-10-06 + +- Placeholders can now ask the user for a value to substitute. This + makes it possible to quickly add larger pieces of text where some + parts are dynamic. + ## 0.3.1 - 2026-10-04 - `\u`_XXXX_ will complete to the Unicode character whose code point is diff --git a/quick-commands/README.md b/quick-commands/README.md index b598039..40be029 100644 --- a/quick-commands/README.md +++ b/quick-commands/README.md @@ -55,28 +55,30 @@ smile smile\u263a\nand again In the completions you can use a number of _placeholders_ to obtain substitutions for actual date and time values (table adapted from [QOwnNotes](https://www.qownnotes.org/scripting/methods-and-objects.html#formatting-dates-and-times): -| Placeholder | Meaning | Example | -| :----------- | :---------------------|:-------------- | -| `{yyyy}` | Year with four digits | 2026 | -| `{yy}` | Year with two digits | 26 | -| `{MM}` | Month with leading zero | 09 | -| `{M}` | Month without leading zero | 9 | -| `{MMM}` | Abbreviated localized month name | Sep | -| `{MMMM}` | Full localized month name | September | -| `{dd}` | Day with leading zero | 05 | -| `{d}` | Day without leading zero | 5 | -| `{ddd}` | Abbreviated localized day name | Tue | -| `{dddd}` | Full localized day name | Tuesday | -| `{HH}` | Hour (0-23) with leading zero | 07 | -| `{hh}` | Hour with leading zero (1-12 with AP) | 07 | -| `{mm}` | Minute with leading zero | 04 | -| `{ss}` | Second with leading zero | 09 | -| `{AP}` / `{ap}` | AM/PM or am/pm | AM | -| `{w}` | ISO week number without leadign zero | 5 | -| `{ww}` | ISO week number with leadign zero | 05 | -| `{LC:locale}` | Use the given locale | `{LC:nl_NL}`| -| `{+:offset}` | Offsets the date to the future | `{+:1D}` | -| `{-:offset}` | Offsets the date to the past | `{-:1D}` | +| Placeholder | Meaning | Example | +|:------------------|:--------------------------------------|:--------------------------| +| `{yyyy}` | Year with four digits | 2026 | +| `{yy}` | Year with two digits | 26 | +| `{MM}` | Month with leading zero | 09 | +| `{M}` | Month without leading zero | 9 | +| `{MMM}` | Abbreviated localized month name | Sep | +| `{MMMM}` | Full localized month name | September | +| `{dd}` | Day with leading zero | 05 | +| `{d}` | Day without leading zero | 5 | +| `{ddd}` | Abbreviated localized day name | Tue | +| `{dddd}` | Full localized day name | Tuesday | +| `{HH}` | Hour (0-23) with leading zero | 07 | +| `{hh}` | Hour with leading zero (1-12 with AP) | 07 | +| `{mm}` | Minute with leading zero | 04 | +| `{ss}` | Second with leading zero | 09 | +| `{AP}` / `{ap}` | AM/PM or am/pm | AM | +| `{w}` | ISO week number without leadign zero | 5 | +| `{ww}` | ISO week number with leadign zero | 05 | +| `{LC:locale}` | Use the given locale | `{LC:nl_NL}` | +| `{+:offset}` | Offsets the date to the future | `{+:1D}` | +| `{-:offset}` | Offsets the date to the past | `{-:1D}` | +| `{input:msg}` | Asks the user for an answer to _msg_. | `{input:What colour}` | +| `{input:msg:def}` | Same, but with a default value. | `{input:What colour:red}` | The date offsets may be a number of days, as shown above, or a number of milliseconds. `1D` is equivalent to `86400000`. diff --git a/quick-commands/info.json b/quick-commands/info.json index a0e4495..aab3feb 100644 --- a/quick-commands/info.json +++ b/quick-commands/info.json @@ -4,7 +4,7 @@ "script": "quick-commands.qml", "authors": ["@LockeBirdsey","@sciurius"], "platforms": ["linux", "macos", "windows"], - "version": "0.3.1", + "version": "0.3.2", "minAppVersion": "25.4.1", "description": "Short commands to help with repetive and/or annoying things to write frequently such as timestamps.\n\nEach command starts with a backslash (\\) and a single word for the command. Select the autocomplete option you desire and the command text will be replace.\n\nDefault commands are: today, tomorrow, yesterday, now, week.\n\nCustom commands can also be specified. Each line starts with the command name followed by one or more replacement values separated by spaces. Enclose multi-word values in double quotes, for example: myname \"Firstname Lastname\". Date and time values can be substituted with {dd}, {MM} and so on.\n\nReplacement values may have escaped newlines \"\\n\" and Unicode characters in the form \"\\uXXXX\".", "resources": ["command-parser.js"] diff --git a/quick-commands/quick-commands.qml b/quick-commands/quick-commands.qml index a85198e..8674393 100644 --- a/quick-commands/quick-commands.qml +++ b/quick-commands/quick-commands.qml @@ -174,10 +174,10 @@ Script { // script.log("x:" + x); if ( x.length == 2 ) { // ctrl:value - let ctrl = x[0]; - let value = x[1]; + const ctrl = x[0].toLowerCase(); + const value = x[1]; - if ( ctrl.toLowerCase() == "lc" ) { + if ( ctrl == "lc" ) { // Set a locale for substitutions. locale = Qt.locale(value); script.log("locale:" + locale); @@ -186,7 +186,7 @@ Script { if ( ctrl == "+" || ctrl == "-" ) { // Date offset, millisecs or nnD. - let now = new Date().getTime(); + const now = new Date().getTime(); if ( value.endsWith("D") ) { value = parseInt(value) * 24*60*60*1000; } @@ -197,8 +197,27 @@ Script { //script.log("date " + date); continue; } + + if ( ctrl == 'input' ) { + result += + script.inputDialogGetText("Query", value, "" ); + continue; + } } - console.error("Invalid substitution control: " + m[0]); + + else if ( x.length == 3 ) { // ctrl:value:arg + const ctrl = x[0].toLowerCase(); + const value = x[1]; + const arg = x[2]; + + if ( ctrl == 'input' ) { + result += + script.inputDialogGetText("Query", value, arg ); + continue; + } + } + + console.error("Invalid substitution control: " + m[i]); continue; // makes sense? } // Perform the substition. From 6ca89b415af8a2590eddd9502f44f47f576ab4be Mon Sep 17 00:00:00 2001 From: Johan Vromans Date: Tue, 6 Oct 2026 12:02:34 +0200 Subject: [PATCH 2/5] Revert "Placeholders can now ask the user for a value to substitute." This reverts commit addebc6b68b3fe3afbd74bdb0296a500f35bd69c. --- quick-commands/CHANGELOG.md | 6 ---- quick-commands/README.md | 46 +++++++++++++++---------------- quick-commands/info.json | 2 +- quick-commands/quick-commands.qml | 29 ++++--------------- 4 files changed, 28 insertions(+), 55 deletions(-) diff --git a/quick-commands/CHANGELOG.md b/quick-commands/CHANGELOG.md index 889305d..116cb0c 100644 --- a/quick-commands/CHANGELOG.md +++ b/quick-commands/CHANGELOG.md @@ -1,11 +1,5 @@ # Changelog -## 0.3.2 - 2026-10-06 - -- Placeholders can now ask the user for a value to substitute. This - makes it possible to quickly add larger pieces of text where some - parts are dynamic. - ## 0.3.1 - 2026-10-04 - `\u`_XXXX_ will complete to the Unicode character whose code point is diff --git a/quick-commands/README.md b/quick-commands/README.md index 40be029..b598039 100644 --- a/quick-commands/README.md +++ b/quick-commands/README.md @@ -55,30 +55,28 @@ smile smile\u263a\nand again In the completions you can use a number of _placeholders_ to obtain substitutions for actual date and time values (table adapted from [QOwnNotes](https://www.qownnotes.org/scripting/methods-and-objects.html#formatting-dates-and-times): -| Placeholder | Meaning | Example | -|:------------------|:--------------------------------------|:--------------------------| -| `{yyyy}` | Year with four digits | 2026 | -| `{yy}` | Year with two digits | 26 | -| `{MM}` | Month with leading zero | 09 | -| `{M}` | Month without leading zero | 9 | -| `{MMM}` | Abbreviated localized month name | Sep | -| `{MMMM}` | Full localized month name | September | -| `{dd}` | Day with leading zero | 05 | -| `{d}` | Day without leading zero | 5 | -| `{ddd}` | Abbreviated localized day name | Tue | -| `{dddd}` | Full localized day name | Tuesday | -| `{HH}` | Hour (0-23) with leading zero | 07 | -| `{hh}` | Hour with leading zero (1-12 with AP) | 07 | -| `{mm}` | Minute with leading zero | 04 | -| `{ss}` | Second with leading zero | 09 | -| `{AP}` / `{ap}` | AM/PM or am/pm | AM | -| `{w}` | ISO week number without leadign zero | 5 | -| `{ww}` | ISO week number with leadign zero | 05 | -| `{LC:locale}` | Use the given locale | `{LC:nl_NL}` | -| `{+:offset}` | Offsets the date to the future | `{+:1D}` | -| `{-:offset}` | Offsets the date to the past | `{-:1D}` | -| `{input:msg}` | Asks the user for an answer to _msg_. | `{input:What colour}` | -| `{input:msg:def}` | Same, but with a default value. | `{input:What colour:red}` | +| Placeholder | Meaning | Example | +| :----------- | :---------------------|:-------------- | +| `{yyyy}` | Year with four digits | 2026 | +| `{yy}` | Year with two digits | 26 | +| `{MM}` | Month with leading zero | 09 | +| `{M}` | Month without leading zero | 9 | +| `{MMM}` | Abbreviated localized month name | Sep | +| `{MMMM}` | Full localized month name | September | +| `{dd}` | Day with leading zero | 05 | +| `{d}` | Day without leading zero | 5 | +| `{ddd}` | Abbreviated localized day name | Tue | +| `{dddd}` | Full localized day name | Tuesday | +| `{HH}` | Hour (0-23) with leading zero | 07 | +| `{hh}` | Hour with leading zero (1-12 with AP) | 07 | +| `{mm}` | Minute with leading zero | 04 | +| `{ss}` | Second with leading zero | 09 | +| `{AP}` / `{ap}` | AM/PM or am/pm | AM | +| `{w}` | ISO week number without leadign zero | 5 | +| `{ww}` | ISO week number with leadign zero | 05 | +| `{LC:locale}` | Use the given locale | `{LC:nl_NL}`| +| `{+:offset}` | Offsets the date to the future | `{+:1D}` | +| `{-:offset}` | Offsets the date to the past | `{-:1D}` | The date offsets may be a number of days, as shown above, or a number of milliseconds. `1D` is equivalent to `86400000`. diff --git a/quick-commands/info.json b/quick-commands/info.json index aab3feb..a0e4495 100644 --- a/quick-commands/info.json +++ b/quick-commands/info.json @@ -4,7 +4,7 @@ "script": "quick-commands.qml", "authors": ["@LockeBirdsey","@sciurius"], "platforms": ["linux", "macos", "windows"], - "version": "0.3.2", + "version": "0.3.1", "minAppVersion": "25.4.1", "description": "Short commands to help with repetive and/or annoying things to write frequently such as timestamps.\n\nEach command starts with a backslash (\\) and a single word for the command. Select the autocomplete option you desire and the command text will be replace.\n\nDefault commands are: today, tomorrow, yesterday, now, week.\n\nCustom commands can also be specified. Each line starts with the command name followed by one or more replacement values separated by spaces. Enclose multi-word values in double quotes, for example: myname \"Firstname Lastname\". Date and time values can be substituted with {dd}, {MM} and so on.\n\nReplacement values may have escaped newlines \"\\n\" and Unicode characters in the form \"\\uXXXX\".", "resources": ["command-parser.js"] diff --git a/quick-commands/quick-commands.qml b/quick-commands/quick-commands.qml index 8674393..a85198e 100644 --- a/quick-commands/quick-commands.qml +++ b/quick-commands/quick-commands.qml @@ -174,10 +174,10 @@ Script { // script.log("x:" + x); if ( x.length == 2 ) { // ctrl:value - const ctrl = x[0].toLowerCase(); - const value = x[1]; + let ctrl = x[0]; + let value = x[1]; - if ( ctrl == "lc" ) { + if ( ctrl.toLowerCase() == "lc" ) { // Set a locale for substitutions. locale = Qt.locale(value); script.log("locale:" + locale); @@ -186,7 +186,7 @@ Script { if ( ctrl == "+" || ctrl == "-" ) { // Date offset, millisecs or nnD. - const now = new Date().getTime(); + let now = new Date().getTime(); if ( value.endsWith("D") ) { value = parseInt(value) * 24*60*60*1000; } @@ -197,27 +197,8 @@ Script { //script.log("date " + date); continue; } - - if ( ctrl == 'input' ) { - result += - script.inputDialogGetText("Query", value, "" ); - continue; - } } - - else if ( x.length == 3 ) { // ctrl:value:arg - const ctrl = x[0].toLowerCase(); - const value = x[1]; - const arg = x[2]; - - if ( ctrl == 'input' ) { - result += - script.inputDialogGetText("Query", value, arg ); - continue; - } - } - - console.error("Invalid substitution control: " + m[i]); + console.error("Invalid substitution control: " + m[0]); continue; // makes sense? } // Perform the substition. From 67ef336ef7b589450a075331276771173f09cd62 Mon Sep 17 00:00:00 2001 From: Johan Vromans Date: Tue, 6 Oct 2026 12:03:40 +0200 Subject: [PATCH 3/5] Placeholders can now ask the user for a value to substitute. This makes it possible to quickly add larger pieces of text where some parts are dynamic. --- quick-commands/CHANGELOG.md | 6 ++++ quick-commands/README.md | 46 ++++++++++++++++--------------- quick-commands/info.json | 2 +- quick-commands/quick-commands.qml | 29 +++++++++++++++---- 4 files changed, 55 insertions(+), 28 deletions(-) diff --git a/quick-commands/CHANGELOG.md b/quick-commands/CHANGELOG.md index 116cb0c..889305d 100644 --- a/quick-commands/CHANGELOG.md +++ b/quick-commands/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.3.2 - 2026-10-06 + +- Placeholders can now ask the user for a value to substitute. This + makes it possible to quickly add larger pieces of text where some + parts are dynamic. + ## 0.3.1 - 2026-10-04 - `\u`_XXXX_ will complete to the Unicode character whose code point is diff --git a/quick-commands/README.md b/quick-commands/README.md index b598039..40be029 100644 --- a/quick-commands/README.md +++ b/quick-commands/README.md @@ -55,28 +55,30 @@ smile smile\u263a\nand again In the completions you can use a number of _placeholders_ to obtain substitutions for actual date and time values (table adapted from [QOwnNotes](https://www.qownnotes.org/scripting/methods-and-objects.html#formatting-dates-and-times): -| Placeholder | Meaning | Example | -| :----------- | :---------------------|:-------------- | -| `{yyyy}` | Year with four digits | 2026 | -| `{yy}` | Year with two digits | 26 | -| `{MM}` | Month with leading zero | 09 | -| `{M}` | Month without leading zero | 9 | -| `{MMM}` | Abbreviated localized month name | Sep | -| `{MMMM}` | Full localized month name | September | -| `{dd}` | Day with leading zero | 05 | -| `{d}` | Day without leading zero | 5 | -| `{ddd}` | Abbreviated localized day name | Tue | -| `{dddd}` | Full localized day name | Tuesday | -| `{HH}` | Hour (0-23) with leading zero | 07 | -| `{hh}` | Hour with leading zero (1-12 with AP) | 07 | -| `{mm}` | Minute with leading zero | 04 | -| `{ss}` | Second with leading zero | 09 | -| `{AP}` / `{ap}` | AM/PM or am/pm | AM | -| `{w}` | ISO week number without leadign zero | 5 | -| `{ww}` | ISO week number with leadign zero | 05 | -| `{LC:locale}` | Use the given locale | `{LC:nl_NL}`| -| `{+:offset}` | Offsets the date to the future | `{+:1D}` | -| `{-:offset}` | Offsets the date to the past | `{-:1D}` | +| Placeholder | Meaning | Example | +|:------------------|:--------------------------------------|:--------------------------| +| `{yyyy}` | Year with four digits | 2026 | +| `{yy}` | Year with two digits | 26 | +| `{MM}` | Month with leading zero | 09 | +| `{M}` | Month without leading zero | 9 | +| `{MMM}` | Abbreviated localized month name | Sep | +| `{MMMM}` | Full localized month name | September | +| `{dd}` | Day with leading zero | 05 | +| `{d}` | Day without leading zero | 5 | +| `{ddd}` | Abbreviated localized day name | Tue | +| `{dddd}` | Full localized day name | Tuesday | +| `{HH}` | Hour (0-23) with leading zero | 07 | +| `{hh}` | Hour with leading zero (1-12 with AP) | 07 | +| `{mm}` | Minute with leading zero | 04 | +| `{ss}` | Second with leading zero | 09 | +| `{AP}` / `{ap}` | AM/PM or am/pm | AM | +| `{w}` | ISO week number without leadign zero | 5 | +| `{ww}` | ISO week number with leadign zero | 05 | +| `{LC:locale}` | Use the given locale | `{LC:nl_NL}` | +| `{+:offset}` | Offsets the date to the future | `{+:1D}` | +| `{-:offset}` | Offsets the date to the past | `{-:1D}` | +| `{input:msg}` | Asks the user for an answer to _msg_. | `{input:What colour}` | +| `{input:msg:def}` | Same, but with a default value. | `{input:What colour:red}` | The date offsets may be a number of days, as shown above, or a number of milliseconds. `1D` is equivalent to `86400000`. diff --git a/quick-commands/info.json b/quick-commands/info.json index a0e4495..aab3feb 100644 --- a/quick-commands/info.json +++ b/quick-commands/info.json @@ -4,7 +4,7 @@ "script": "quick-commands.qml", "authors": ["@LockeBirdsey","@sciurius"], "platforms": ["linux", "macos", "windows"], - "version": "0.3.1", + "version": "0.3.2", "minAppVersion": "25.4.1", "description": "Short commands to help with repetive and/or annoying things to write frequently such as timestamps.\n\nEach command starts with a backslash (\\) and a single word for the command. Select the autocomplete option you desire and the command text will be replace.\n\nDefault commands are: today, tomorrow, yesterday, now, week.\n\nCustom commands can also be specified. Each line starts with the command name followed by one or more replacement values separated by spaces. Enclose multi-word values in double quotes, for example: myname \"Firstname Lastname\". Date and time values can be substituted with {dd}, {MM} and so on.\n\nReplacement values may have escaped newlines \"\\n\" and Unicode characters in the form \"\\uXXXX\".", "resources": ["command-parser.js"] diff --git a/quick-commands/quick-commands.qml b/quick-commands/quick-commands.qml index a85198e..8674393 100644 --- a/quick-commands/quick-commands.qml +++ b/quick-commands/quick-commands.qml @@ -174,10 +174,10 @@ Script { // script.log("x:" + x); if ( x.length == 2 ) { // ctrl:value - let ctrl = x[0]; - let value = x[1]; + const ctrl = x[0].toLowerCase(); + const value = x[1]; - if ( ctrl.toLowerCase() == "lc" ) { + if ( ctrl == "lc" ) { // Set a locale for substitutions. locale = Qt.locale(value); script.log("locale:" + locale); @@ -186,7 +186,7 @@ Script { if ( ctrl == "+" || ctrl == "-" ) { // Date offset, millisecs or nnD. - let now = new Date().getTime(); + const now = new Date().getTime(); if ( value.endsWith("D") ) { value = parseInt(value) * 24*60*60*1000; } @@ -197,8 +197,27 @@ Script { //script.log("date " + date); continue; } + + if ( ctrl == 'input' ) { + result += + script.inputDialogGetText("Query", value, "" ); + continue; + } } - console.error("Invalid substitution control: " + m[0]); + + else if ( x.length == 3 ) { // ctrl:value:arg + const ctrl = x[0].toLowerCase(); + const value = x[1]; + const arg = x[2]; + + if ( ctrl == 'input' ) { + result += + script.inputDialogGetText("Query", value, arg ); + continue; + } + } + + console.error("Invalid substitution control: " + m[i]); continue; // makes sense? } // Perform the substition. From aba443e8cca5c44f1a6b44a25d9e970dfb56da79 Mon Sep 17 00:00:00 2001 From: Johan Vromans Date: Tue, 6 Oct 2026 14:01:12 +0200 Subject: [PATCH 4/5] Fix type error. --- quick-commands/quick-commands.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-commands/quick-commands.qml b/quick-commands/quick-commands.qml index 8674393..342cd61 100644 --- a/quick-commands/quick-commands.qml +++ b/quick-commands/quick-commands.qml @@ -175,7 +175,7 @@ Script { if ( x.length == 2 ) { // ctrl:value const ctrl = x[0].toLowerCase(); - const value = x[1]; + let value = x[1]; if ( ctrl == "lc" ) { // Set a locale for substitutions. From 6c5b9ac8ae4d5f43e518273d86c12584612db47c Mon Sep 17 00:00:00 2001 From: Johan Vromans Date: Tue, 6 Oct 2026 14:06:03 +0200 Subject: [PATCH 5/5] Fix date offset. --- quick-commands/quick-commands.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-commands/quick-commands.qml b/quick-commands/quick-commands.qml index 342cd61..a6249be 100644 --- a/quick-commands/quick-commands.qml +++ b/quick-commands/quick-commands.qml @@ -193,7 +193,7 @@ Script { else { value = parseInt(value); } - date = new Date( now + value ); + date = new Date( ctrl == "+" ? now + value : now - value ); //script.log("date " + date); continue; }