NotePlan / plugins

The main NotePlan repository, which contains the source code for all NotePlan plugins. If a release entry has been created, it will be available for installation from within NotePlan application.
MIT License
168 stars 58 forks source link

Add CommandBar input callback function to modify the list of options as the user types - JavaScript API #38

Open BorisAnthony opened 3 years ago

BorisAnthony commented 3 years ago

name: Feature request about: Suggest an idea for this project title: 'Template plugin - dynamic input commands' labels: '' assignees: ''


Is your feature request related to a problem? Please describe. Invoking the Templates plugin commands, things that NotePlan "knows" about (date/time, mentions) are not offered as automatic/dynamic options

Describe the solution you'd like When invoking Templates plugin commands /nn or /it, if I select a template that is confiogure to ask for inputs like date or "who with", for example the Meeting Notes template, I would expect to not have to type the date or the @name of someone in my mentions list, but rather to have choices for selection, e.g.: Date in several standard formals (could be a _configuration option), for "who with", if I type "@", load my mentions list to select from.

🙏🏼

jgclark commented 3 years ago

Interesting suggestion, @BorisAnthony. It triggers me to ask @EduardMe whether he'd consider adding more specialised input dialogs. I'd already been thinking that a date picker would be helpful in a couple of plugins, including (as you suggest) meeting templates. I do use the existing command bar mechanism as a date picker, but it's not very user-friendly.

EduardMe commented 3 years ago

Good point. There is already a date picker in NotePlan, so why not access it through a plugin! But it probably needs to be embedded into the Command Bar, so it looks also nice. The date picker we got in the Swift code is actually written in an embeddable way. I’ll add this to the list!

The mention list could be loaded into the Command Bar through the plugin. Though, I think there is no interface yet to get all already scanned @ and # tags.

dwertheimer commented 3 years ago

Also, we would need the combination optionChooser+Input CommandBar that I asked for awhile back (so you can type @eduard and see what tags are there,  but if it's not there, you just keep typing text).

On Tue, Aug 03, 2021 at 10:22 AM, Eduard Metzger < @.*** > wrote:

Good point. There is already a date picker in NotePlan, so why not access it through a plugin! But it probably needs to be embedded into the Command Bar, so it looks also nice. The date picker we got in the Swift code is actually written in an embeddable way. I’ll add this to the list!

The mention list could be loaded into the Command Bar through the plugin. Though, I think there is no interface yet to get all already scanned @ and

tags.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub ( https://github.com/NotePlan/plugins/issues/38#issuecomment-892024498 ) , or unsubscribe ( https://github.com/notifications/unsubscribe-auth/ACEI6VAHKZR2LDNGOZMOUB3T3AQWBANCNFSM5BOKVNJQ ).

EduardMe commented 3 years ago

Got it, the .showOptions command should also accept “custom input” by the user, not just an item from the list (optionally, probably indicated with a flag in the function).

On Tue 3. Aug 2021 at 14:00, David Wertheimer @.***> wrote:

Also, we would need the combination optionChooser+Input CommandBar that I asked for awhile back (so you can type @eduard and see what tags are there, but if it's not there, you just keep typing text).

On Tue, Aug 03, 2021 at 10:22 AM, Eduard Metzger < @.*** > wrote:

Good point. There is already a date picker in NotePlan, so why not access it through a plugin! But it probably needs to be embedded into the Command Bar, so it looks also nice. The date picker we got in the Swift code is actually written in an embeddable way. I’ll add this to the list!

The mention list could be loaded into the Command Bar through the plugin. Though, I think there is no interface yet to get all already scanned @ and

tags.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub ( https://github.com/NotePlan/plugins/issues/38#issuecomment-892024498 ) , or unsubscribe (

https://github.com/notifications/unsubscribe-auth/ACEI6VAHKZR2LDNGOZMOUB3T3AQWBANCNFSM5BOKVNJQ ).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NotePlan/plugins/issues/38#issuecomment-892088088, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZCAYQ7FHG3PMH4BFD7Z4DT3A4DHANCNFSM5BOKVNJQ .

dwertheimer commented 3 years ago

Yes. Perfect.

On Wed, Aug 04, 2021 at 7:19 AM, Eduard Metzger @.***> wrote:

Got it, the .showOptions command should also accept “custom input” by the user, not just an item from the list (optionally, probably indicated with a flag in the function).

On Tue 3. Aug 2021 at 14:00, David Wertheimer @.***> wrote:

Also, we would need the combination optionChooser+Input CommandBar that I asked for awhile back (so you can type @eduard and see what tags are there, but if it's not there, you just keep typing text).

On Tue, Aug 03, 2021 at 10:22 AM, Eduard Metzger < @.*** > wrote:

Good point. There is already a date picker in NotePlan, so why not access it through a plugin! But it probably needs to be embedded into the Command Bar, so it looks also nice. The date picker we got in the Swift code is actually written in an embeddable way. I’ll add this to the list!

The mention list could be loaded into the Command Bar through the plugin. Though, I think there is no interface yet to get all already scanned @ and

tags.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub ( https://github.com/NotePlan/plugins/issues/38#issuecomment-892024498 ) , or unsubscribe (

https://github.com/notifications/unsubscribe-auth/ ACEI6VAHKZR2LDNGOZMOUB3T3AQWBANCNFSM5BOKVNJQ ).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NotePlan/plugins/issues/38#issuecomment-892088088, or unsubscribe https://github.com/notifications/unsubscribe-auth/ AAZCAYQ7FHG3PMH4BFD7Z4DT3A4DHANCNFSM5BOKVNJQ .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/NotePlan/plugins/issues/38#issuecomment-892699212, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEI6VEP76RWQIJOJCZGBZ3T3FD6LANCNFSM5BOKVNJQ .

EduardMe commented 3 years ago

Thanks for assigning it, I think this is a good place to collect enhancement request. I just have a clarification question. There are three ideas around this topic:

  1. Date picker
  2. Accept custom input in showOptions using a flag
  3. On Discord (I think) we talked about an idea to have a callback variable in the showInput function, so the plugin could change the displayed options real-time while the user is typing.

These 3 are all separate things? Or shall we merge 2. And 3.? Maybe even 1.?

mikeerickson commented 3 years ago

Ok, now we are getting into UI needs (outside of command bar) and my interest is piqued! So, the question is, are the various UI components available to plug-ins? @EduardMe @jgclark

jgclark commented 3 years ago

Thanks for picking this up: obviously feel free to fork this off to several other issues if you wish. These are my longer suggestions for requirements, with most important (to me) first:

Date Picker For me it would be ideal to have a top area where I can time in natural language "3 months", "in 2 weeks" etc, and a lower area with the more normal kind of calendar view. If the top part is used, then the lower view updates.

Updating comment We can currently use @% (or something) to update the second line in the display of the CommandBar as I type. I'd like to be able to pass a function that will update when the input string updates. If this arrived before the date picker I'd use it to allow me to write relative dates ("2 weeks") and for the actual date to be displayed as a confirmation.

Folder Picker I've written a slightly nicer function that shows an indented list of folders to pick from, but that could in time be a nicer native UI element.

Input Validator Pass some function to the CommandBar to continually validate the text typed so far. Or more simply, define the type that needs to be returned (e.g. integer, real, ISO Date).

Tag and Mention Pickers Someone asked on Discord recently for a way to choose between @mentions as part a meeting template. I could imagine this wants to be a multi-select. Ditto for hashtags.

dwertheimer commented 3 years ago

+1 for this! This would be a more generalized form of what I proposed with passing a function as submitText (or what Jonathan proposed for a validate). Allowing JavaScript middleware/plugins would be amazing. We can start with submitText but think about how to generalize this capability.

On Wed, Aug 18, 2021 at 3:01 PM Mike Erickson @.***> wrote:

Ok, now we are getting into UI needs (outside of command bar) and my interest is piqued! So, the question is, are the various UI components available to plug-ins? @EduardMe https://github.com/EduardMe @jgclark https://github.com/jgclark

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/NotePlan/plugins/issues/38#issuecomment-901427737, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEI6VBUXXN75URUSI4C5Q3T5QNTRANCNFSM5BOKVNJQ .

EduardMe commented 3 years ago

@jgclark Thanks for the list! I think we can start with a callback function while the user types to: A) modify the options or comment and B) validate the input and possibly more, like when the user types “#” we could show a list of tags automatically, if “@“, the mentions, etc. So the options are dynamic.

Date picker is a bit more tricky, need to integrate the existing date picker somehow into the command bar.

EduardMe commented 3 years ago

Ok, I have created new issues for #55 (Date Picker) and #56 (Folder Picker) and changed this one to be the Issue for the callback func which could handle changing comment and as validator.

One point which is not 100% clear to me is:

Tag and Mention Pickers Someone asked on Discord recently for a way to choose between @mentions as part a meeting template. I could imagine this wants to be a multi-select. Ditto for hashtags.

This could be already achieved with a simple list using CommandBar.showOptions? Or do you mean to add an API to get all available hashtags/mentions (since NotePlan already scanned them)? Not sure if I added it already.

jgclark commented 3 years ago

Thanks. I also had that @mentions request in mind here. Yes, multi-select would be required, and that would be non-trivial once you have more than 10 or so existing mentions. Because of the way I use @completed(), @due() etc., I have more than 300 mentions :-(

However, I think the Evernote model for picking tags to apply to a note might help us: you can start typing and it narrows down a list that you can select from, and then immediately start typing characters for a second one. NP of course does this already in the editor, so perhaps it's a matter of making that available in a variant of the CommandBar?

On Fri, 20 Aug 2021 at 16:01, Eduard Metzger @.***> wrote:

Ok, I have created new issues for #55 https://github.com/NotePlan/plugins/issues/55 (Date Picker) and #56 https://github.com/NotePlan/plugins/issues/56 (Folder Picker) and changed this one to be the Issue for the callback func which could handle changing comment and as validator.

One point which is not 100% clear to me is:

Tag and Mention Pickers Someone asked on Discord recently for a way to choose between @mentions as part a meeting template. I could imagine this wants to be a multi-select. Ditto for hashtags.

This could be already achieved with a simple list using CommandBar.showOptions? Or do you mean to add an API to get all available hashtags/mentions (since NotePlan already scanned them)? Not sure if I added it already.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NotePlan/plugins/issues/38#issuecomment-902756879, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYESWRLHHIPVNNCXQRWCTT5ZU5NANCNFSM5BOKVNJQ .

-- -- Jonathan

EduardMe commented 3 years ago

Just to clarify this point. You mean selecting multiple tags using a auto-completion? Right now one you can load all tags and let the user choose one with fuzzy search. But the user can‘t add a custom tag, only choose from the existing (that‘s one problem). And if I got you right, you would like to start typing and auto-completing a second tag in the same command bar input?

jgclark commented 3 years ago

I think in priority order:

  1. single-select from fuzzy search
  2. single-select from fuzzy search, but also allow user to type an entirely new tag and it is accepted (I think Evernote allows this)
  3. multi-select from fuzzy search (like Evernote allows when adding tags to a note)
  4. multi-select from fuzzy search, but also allow user to type an entirely new tag and it is accepted (I think like Evernote also allows) This to be applied to @mentions and #hashtags. The second would be my suggested default behaviour, with others available via two boolean parameters.

On Thu, 2 Sept 2021 at 15:15, Eduard Metzger @.***> wrote:

Just to clarify this point. You mean selecting multiple tags using a auto-completion? Right now one you can load all tags and let the user choose one with fuzzy search. But the user can‘t add a custom tag, only choose from the existing (that‘s one problem). And if I got you right, you would like to start typing and auto-completing a second tag in the same command bar input?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NotePlan/plugins/issues/38#issuecomment-911733059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYESSQVCRAYXYE2346RUDT76BIPANCNFSM5BOKVNJQ .

-- -- Jonathan

EduardMe commented 3 years ago

Sorry for the late reply! Now I understand, multi-selecting, like multiple tags makes sense. Right now it’s limited to one tag. Have added it to our list.

dwertheimer commented 2 years ago

@jgclark @EduardMe has cherry-picked the intermediate validator piece of this, but maybe you can create separate cards on the project board for the other requirements: #55 (Date Picker) and #56 (Folder Picker)