Implemented generic omnibar function. #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up of #73.
Please consider this as a proof-of-concept at the current stage: everything is up for debate in this implementation.
Documentation is also still missing from this PR - I'll add it if it goes through, after any required changes.
Since the API exposed by Surfingkeys is very limited (and it seems to become more limited on every release), and response times on PR also take their time, I've decided to add a new generic Omnibar implementation that exposes callbacks such as
autocomplete
,onEnter
(withshiftKey
andctrlKey
modifiers) andonResultClick
to customize the behaviour (which e.g. allows POST requests, custom autocomplete hooks, close/keep open on input behaviour etc.).It also provides a
multiline
mode to replace the default Omnibar input with a<textarea>
- useful for example for ChatGPT input.Two reference implementations are also provided in the comments:
<Shift+Enter>
) or search page opened upon<Enter>
.<Ctrl+Enter>
and the response text is copied on item click or when<Enter>
is pressed on a result.Note that, since many of those low-level APIs are no longer exposed by Surfingkeys, I've had to reinvent half of the wheel and do some DOM plumbing to add items and event handlers.
I'd also like to add dynamic favicons to the results (based on the domain name), but I'm not sure how to do it with the current API without bumping into CORS.
Closes: #73