chore: Simplify state machine implementation of prosemirror prompt input #7154
+710
−620
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.
In this PR I'm reducing the API surface of the state machine and move most of the events related to
value and mentions changes out of it. Hopefully this makes the state machine easier to understand
and to work with.
Now the state machine exposes an
document.update
event whose payload is a function that gets passedthe current editor state and returns a transaction. Note however that these changes actions are still
tested toghether with the state machine in
promptInput.test.ts
. I think it's important to have oneplace to test all the expected behavior of the prompt input.
The main reason behind this change is that the current implementation is very much driven by the current
API the
PromptInput
component exposes. But going forward we might change/reduce/expand this API.Ideally the state machine won't have to be changed for that.
In an upcoming PR I plan to refactor the mentions menu implementation to be more generic to better
support menu items that are not
ContextItem
s.Test plan
Unit test