( app: App, plugin: QuickAdd, )
| 238 | } |
| 239 | |
| 240 | async function pickTemplate( |
| 241 | app: App, |
| 242 | plugin: QuickAdd, |
| 243 | ): Promise<TemplatePickerItem | null> { |
| 244 | const items = buildTemplatePickerItems( |
| 245 | plugin.settings.choices, |
| 246 | plugin.getTemplateFiles().map((file) => file.path), |
| 247 | ); |
| 248 | |
| 249 | if (items.length === 0) { |
| 250 | new Notice( |
| 251 | "QuickAdd: No Template choices or template files found. Create a Template choice or set the template folder path in settings.", |
| 252 | ); |
| 253 | return null; |
| 254 | } |
| 255 | |
| 256 | try { |
| 257 | return await GenericSuggester.Suggest( |
| 258 | app, |
| 259 | items.map(templatePickerItemLabel), |
| 260 | items, |
| 261 | "Apply template to note", |
| 262 | ); |
| 263 | } catch (error) { |
| 264 | if (isCancellationError(error)) return null; |
| 265 | throw error; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | async function pickInsertMode( |
| 270 | app: App, |
no test coverage detected