Skip to content

Commit 1ecd8d2

Browse files
committed
Merge branch 'main' of https://github.com/NotePlan/plugins
2 parents f30cfca + 6cc2117 commit 1ecd8d2

File tree

7 files changed

+48
-24
lines changed

7 files changed

+48
-24
lines changed

helpers/__tests__/dateTime.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ beforeAll(() => {
1414
global.DataStore = DataStore
1515
global.Editor = Editor
1616
global.NotePlan = new NotePlan()
17-
DataStore.settings['_logLevel'] = 'DEBUG' // change this to DEBUG to get more logging, or 'none' for quiet
17+
DataStore.settings['_logLevel'] = 'none' // change this to DEBUG to get more logging, or 'none' for quiet
1818
})
1919

2020
const PLUGIN_NAME = `📙 ${colors.yellow('helpers/dateTime')}`
@@ -98,8 +98,8 @@ describe(`${PLUGIN_NAME}`, () => {
9898
})
9999

100100
/*
101-
* findOverdueDatesInString()
102-
*/
101+
* findOverdueDatesInString()
102+
*/
103103
describe('findOverdueDatesInString()' /* function */, () => {
104104
test('should find no date in line with no overdue', () => {
105105
const result = dt.findOverdueDatesInString('>2922-01-01')
@@ -189,8 +189,8 @@ describe(`${PLUGIN_NAME}`, () => {
189189
})
190190

191191
/*
192-
* isDailyDateStr()
193-
*/
192+
* isDailyDateStr()
193+
*/
194194
describe('isDailyDateStr()', () => {
195195
test('false for empty string', () => {
196196
const result = dt.isDailyDateStr('')
@@ -219,8 +219,8 @@ describe(`${PLUGIN_NAME}`, () => {
219219
})
220220

221221
/*
222-
* isYearlyDateStr()
223-
*/
222+
* isYearlyDateStr()
223+
*/
224224
describe('isYearlyDateStr()', () => {
225225
test('should find a bare Year', () => {
226226
const result = dt.isYearlyDateStr('2022')

helpers/__tests__/paragraph.test.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ beforeAll(() => {
1010
global.DataStore = DataStore
1111
global.Editor = Editor
1212
global.NotePlan = NotePlan
13-
DataStore.settings['_logLevel'] = 'DEBUG' //change this to DEBUG to get more logging. Or 'none' to get none.
13+
DataStore.settings['_logLevel'] = 'none' //change this to DEBUG to get more logging. Or 'none' to get none.
1414
})
1515

1616
beforeEach(() => {
@@ -42,7 +42,9 @@ describe('paragraph.js', () => {
4242
expect(result).toEqual('Something about and')
4343
})
4444
test('should remove all types', () => {
45-
const result = p.stripAllURIsAndNoteLinks('Something about http://www.tennis.org/ and [Wimbledon](https://www.wimbledon.org/) and [[link with#tag]] and [[link without that tag]]')
45+
const result = p.stripAllURIsAndNoteLinks(
46+
'Something about http://www.tennis.org/ and [Wimbledon](https://www.wimbledon.org/) and [[link with#tag]] and [[link without that tag]]',
47+
)
4648
expect(result).toEqual('Something about and Wimbledon and and')
4749
})
4850
test('should remove all URIs and note links', () => {
@@ -195,7 +197,10 @@ describe('paragraph.js', () => {
195197
expect(result).toEqual(false)
196198
})
197199
test('should return false when term is not in any part of input string', () => {
198-
const result = p.isTermInEventLinkHiddenPart('Home', 'This is a work event: ![📅](2022-05-06 07:15:::6qr6nbulhd7k3aakvf61atfsrd@google.com:::NA:::Work event with @Bob:::#1BADF8)')
200+
const result = p.isTermInEventLinkHiddenPart(
201+
'Home',
202+
'This is a work event: ![📅](2022-05-06 07:15:::6qr6nbulhd7k3aakvf61atfsrd@google.com:::NA:::Work event with @Bob:::#1BADF8)',
203+
)
199204
expect(result).toEqual(false)
200205
})
201206
test('should return false when term is within datetime part of an event link', () => {

helpers/userInput.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,22 @@ export async function chooseOptionWithModifiers<T, TDefault = T>(
133133
* @param {Array<TCommandBarOptionObject>} options - array of options to display
134134
* @param {boolean} allowCreate - add an option to create a new item (default: false)
135135
* @returns {Promise<{value: T, label: string, index: number, keyModifiers: Array<string>}>} - Promise resolving to the result
136-
* see CommandBar.showOptions for more info
136+
* Sends back the object that was chosen, plus an index of the chosen option and keyModifiers array
137137
*/
138138
export async function chooseOptionWithModifiersV2(
139139
message: string,
140-
options: Array<TCommandBarOptionObject>,
140+
options: Array<{ ...TCommandBarOptionObject, label?: string }>,
141141
additionalCreateNewOption?: TCommandBarOptionObject,
142-
): Promise<{ index: number, keyModifiers: Array<string>, label: string, value: string }> {
142+
): Promise<{ index: number, keyModifiers: Array<string>, label?: string, ...TCommandBarOptionObject, text?: string, value?: string }> {
143143
logDebug('userInput / chooseOptionWithModifiersV2()', `About to showOptions with ${options.length} options & prompt: "${message}"`)
144144

145+
// label field is used elsewhere, but @eduardme made showOptions use text instead, so we map it back to label
146+
if (Array.isArray(options) && options.length > 0 && options[0].label && !options[0].text) {
147+
options.forEach((option, i) => {
148+
options[i] = { ...option, text: option.label ?? option.text } // $FlowFixMe[incompatible-type]
149+
})
150+
}
151+
145152
// Add the "Add new item" option at the start, if given
146153
const displayOptions = options.slice()
147154
if (additionalCreateNewOption) {
@@ -150,7 +157,9 @@ export async function chooseOptionWithModifiersV2(
150157
logDebug('userInput / chooseOptionWithModifiersV2()', `displayOptions: ${displayOptions.length} options`)
151158

152159
// Use newer CommandBar.showOptions() from v3.18
153-
const { index, keyModifiers } = await CommandBar.showOptions(displayOptions, message)
160+
const result = await CommandBar.showOptions(displayOptions, message)
161+
const { index, keyModifiers } = result
162+
clo(result, `chooseOptionWithModifiersV2 chosen result (${typeof result})`)
154163

155164
// Check if the user selected "Add new item"
156165
if (additionalCreateNewOption && index === 0) {
@@ -160,13 +169,14 @@ export async function chooseOptionWithModifiersV2(
160169
return {
161170
value: result,
162171
label: result,
172+
text: result,
163173
index: -1, // -1 indicates a custom entry
164174
keyModifiers: keyModifiers || [],
165175
}
166176
}
167177
}
168178

169-
return { value: displayOptions[index].text ?? '', label: displayOptions[index].text ?? '', index, keyModifiers }
179+
return { ...displayOptions[index], index, keyModifiers }
170180
}
171181

172182
/**

np.CallbackURLs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
See Plugin [README](https://github.com/NotePlan/plugins/blob/main/np.CallbackURLs/README.md) for details on available commands and use cases.
66

7+
## [1.9.1] - 2025-08-19 @dwertheimer
8+
9+
- Fix bug in wizard when using showOptions()
10+
711
## [1.9.0] - 2025-08-18 @dwertheimer
812

913
- Fix template runner wizard bug

np.CallbackURLs/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"noteplan.minAppVersion-NOTE": "Includes folder view picker",
66
"plugin.id": "np.CallbackURLs",
77
"plugin.name": "🔗 Link Creator",
8-
"plugin.version": "1.9.0",
9-
"plugin.lastUpdateInfo": "1.9.0: Added folder view picker to wizard",
8+
"plugin.version": "1.9.1",
9+
"plugin.lastUpdateInfo": "1.9.1: Added folder view picker to wizard",
1010
"plugin.description": "Interactively helps you form links/x-callback-urls (and also Template Tags with runPlugin commands) to perform actions from within NotePlan or between other applications and NotePlan.",
1111
"plugin.author": "dwertheimer",
1212
"plugin.dependencies": [],

np.CallbackURLs/src/NPOpenFolders.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,20 @@ async function selectFolder(folderOptions: Array<Object>): Promise<Object | null
9595
* @param {Array<Object>} views - Array of named views for the folder
9696
* @returns {Array<Object>} Array of view option objects
9797
*/
98-
function createViewOptions(views: Array<Object>): Array<TCommandBarOptionObject> {
99-
let viewOptions: Array<TCommandBarOptionObject> = []
98+
function createViewOptions(views: Array<Object>): Array<Object> {
99+
let viewOptions: Array<Object> = []
100100

101101
// If there are named views, add them as options
102102
if (views && views.length > 0) {
103103
viewOptions = views.map((view: Object) => ({
104-
label: `${view.name}`,
104+
text: `${view.name}`,
105105
value: view.name,
106106
shortDescription: `(${view.layout})`,
107107
}))
108108
}
109109

110110
// Always add option to open folder view default
111-
viewOptions.unshift({ label: '< Open the folder view default >', value: '_folder_', shortDescription: 'Default folder view' })
111+
viewOptions.unshift({ text: '< Open the folder view default >', value: '_folder_', shortDescription: 'Default folder view' })
112112

113113
clo(viewOptions, `createViewOptions: viewOptions`)
114114
return viewOptions
@@ -127,8 +127,13 @@ async function selectView(viewOptions: Array<Object>, selectedFolder: string): P
127127
if (viewOptions.length === 1) {
128128
return viewOptions[0].value
129129
}
130-
131-
return await chooseOption(`Choose a view for '${selectedFolder}'`, viewOptions, '')
130+
clo(viewOptions, `selectView viewOptions`)
131+
const responseObj = await chooseOptionWithModifiersV2(`Choose a view for '${selectedFolder}'`, viewOptions)
132+
if (responseObj) {
133+
clo(responseObj, `selectView responseObj`)
134+
return responseObj.value
135+
}
136+
return ''
132137
}
133138

134139
/**

np.Templating/__tests__/web-api-tests.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe(`${PLUGIN_NAME} - ${section('Web API Tests')}`, () => {
4343
global.console = new CustomConsole(process.stdout, process.stderr, simpleFormatter)
4444
global.NotePlan = new NotePlan()
4545
global.DataStore = DataStore
46-
DataStore.settings['_logLevel'] = 'DEBUG'
46+
DataStore.settings['_logLevel'] = 'none'
4747
global.Editor = Editor
4848

4949
// Set up global fetch to use node-fetch

0 commit comments

Comments
 (0)