Skip to content

Conversation

@gordonbrander
Copy link
Contributor

@gordonbrander gordonbrander commented Oct 4, 2024

@gordonbrander
Copy link
Contributor Author

Experimented with stubbing in https://github.com/curvenote/editor/tree/main/packages/prosemirror-autocomplete.

Problems

  • typing-trigger-based. If you copy/paste the literal text into the editor, you don't trigger the decorations.
  • Seeming bug with decorations (should end at space, but don't)

We build up plugin state once and then use it for rendering, as well as
(soon) looking up active suggestion.
@gordonbrander
Copy link
Contributor Author

Progress:

  • Tested out a few 3p typeahead plugins. Most are 7 years stale / have issues around microinteractions. E.g. they don't stop matching hashtag after space, or don't re-parse when copy/pasting. But these plugins are also pretty simple. I'm using them as reference points for the plugin I started work on earlier.
  • Build up suggestion state on transaction update. We capture ranges of suggestions in text within the plugin model, and then use this model for both the view and decorations. This avoids having to traverse the doc multiple times.
  • Call onSuggest callback when a suggestion is active.
  • Bring in https://floating-ui.com/ to help place suggestions

@gordonbrander
Copy link
Contributor Author

It's a basic proof of concept, but it's working.
This will encourage us to write the menu layer using lit html /
stateless rendering.
this will mean we have to track with scrolling
Reducer gets access to view (state) and msg. It returns a boolean
indicating whether editor should prevent default action.
...and destroy editor on disconnected. This ties editor lifecycle to
component internals lifecycle.
Also switch to ReactiveElement. We don't want Lit's render() method,
since we manage the editor's creation and destruction ourselves.
This allows menu to track with scrolling.
Store is wired to component and keeper of state. We'll use this to
coordinate between the stateless lit world and the stateful ProseMirror
world.
Component takes an anchor viewport position and an open state and
positions itself using absolute strategy.
@gordonbrander gordonbrander marked this pull request as ready for review October 16, 2024 16:20
@gordonbrander gordonbrander merged commit e5e1684 into main Oct 16, 2024
@gordonbrander gordonbrander deleted the 2024-10-04-prosemirror-component branch October 16, 2024 16:21
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.

Prosemirror component

2 participants