| 302 | } |
| 303 | |
| 304 | func (p *accessiblePrompter) MarkdownEditor(prompt, defaultValue string, blankAllowed bool) (string, error) { |
| 305 | var result string |
| 306 | skipOption := "skip" |
| 307 | launchOption := "launch" |
| 308 | options := []huh.Option[string]{ |
| 309 | huh.NewOption(fmt.Sprintf("Launch %s", surveyext.EditorName(p.editorCmd)), launchOption), |
| 310 | } |
| 311 | if blankAllowed { |
| 312 | options = append(options, huh.NewOption("Skip", skipOption)) |
| 313 | } |
| 314 | |
| 315 | form := p.newForm( |
| 316 | huh.NewGroup( |
| 317 | huh.NewSelect[string](). |
| 318 | Title(prompt). |
| 319 | Options(options...). |
| 320 | Value(&result), |
| 321 | ), |
| 322 | ) |
| 323 | |
| 324 | if err := form.Run(); err != nil { |
| 325 | return "", err |
| 326 | } |
| 327 | |
| 328 | if result == skipOption { |
| 329 | return "", nil |
| 330 | } |
| 331 | |
| 332 | // launchOption was selected |
| 333 | text, err := surveyext.Edit(p.editorCmd, "*.md", defaultValue, p.stdin, p.stdout, p.stderr) |
| 334 | if err != nil { |
| 335 | return "", err |
| 336 | } |
| 337 | |
| 338 | return text, nil |
| 339 | } |
| 340 | |
| 341 | func (p *accessiblePrompter) MultiSelectWithSearch(prompt, searchPrompt string, defaultValues, persistentValues []string, searchFunc func(string) MultiSelectSearchResult) ([]string, error) { |
| 342 | return multiSelectWithSearch(p, prompt, searchPrompt, defaultValues, persistentValues, searchFunc) |