Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWS-263: Supersearch pills #1172

Closed
wants to merge 6 commits into from

Conversation

jesperengstrom
Copy link
Contributor

@jesperengstrom jesperengstrom commented Nov 19, 2024

Description

An early draft to discuss if this could be a way to pursue or will end up in a world of pain.

I've created a plugin with widget decorations that iterates the node tree and, upon finding a qualifier, breaks down its parts and passes them to a svelte component (pretty much like before).

The new thing here is that the component essentially steals the focus from codeMirror and lets us type the value from there, and then updates it back to cm.

This aims to solve for example:

  • typing inside pills
  • Typing Astrid Lindgren but treating it as "Astrid Lindgren" (adding quotes that we can later hide)
  • Prevent editing values that are display labels
  • etc

... maybe this can all be done within codemirror, but would propbaby require many different decorations etc for different parts.

... Also, the term 'qualifier' is now being hardcoded into supersearch. Maybe it's reasonable that we require other languages to use this term?

@johanbissemattsson
Copy link
Contributor

johanbissemattsson commented Nov 19, 2024

Interesting approach! I have to think about it some more!

If we can get achieve the expected user experience behaviours (e.g. allowing the cursor to jump left out of the decoration when pressing left inside the escaped decoration) then it could absolutely work.

... maybe this can all be done within codemirror, but would propbaby require many different decorations etc for different parts.

Would we really need so many different decorations?

I'm thinking we could maybe (perhaps with some wishful thinking) get by with only two decorations/components for the qualifiers: QualifierKey (always atomic) and QualiferValue (sometimes atomic, sometimes not, depending on the value). They could be pretty flexible using props (as the passed data should be enough to decide how they should be rendered)?

Or would we also need a specific decorator for atomic qualifier values (e.g. QualifierLinkedValue or something similar...? 🤔 We could however still use the same component for it if that's the case.

TransactionFilters could maybe be used to automatically inject (invisble?) quotation marks when adding a new qualifier key enabling typing Astrid Lindgren but treating it as "Astrid Lindgren". So when I type hasTitle: it automatically becomes hasTitle:"" and moves the cursor one step ahead to the inside of the quotation marks. And it either stays a string or becomes a linked resource depending on if the user decides to add a qualifer from one of the supplied suggestions / autocomplete items.

@jesperengstrom
Copy link
Contributor Author

Thanks for the feedback! Continuing to work with this today to see if it can meet the requirements...

@jesperengstrom
Copy link
Contributor Author

Replaced by #1176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants