Open revidee opened 1 year ago
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days
Still the same issue present in the most recent releases
Again, still present in the latest release.
Updated Codesandbox: https://codesandbox.io/s/nice-http-8hsz3m
Quarterly bump. Still relevant, as described. Tested with 2.1.11 https://codesandbox.io/s/crazy-mccarthy-y6s7w7
Again, more than 6 months later, this is still the case.
What’s the bug you are facing?
Description An InputRule matching
/./
, i.e. any single character should trigger for each added character. It does, but the range in the handler is incorrect. Therange.from
andrange.to
is always the same.Bonus Bug, probably a followup: When doing CTRL+A and then typing a single character, the matched range of the InputRule includes the complete document (from: 1, to: doc.length) - however, since everything was selected beforehand, there is nothing left in this range, making the range effectively invalid.
My Best guess: The input rule adds the inserted item as a 'fake' addition to the editor's text content. The input rule matcher matches and returns a range. The range's 'to' field exceeds the editor state's valid range and is being limited.
Real World Use case To replace content based on some input. This is used in a project to replace any valid Emoji-Unicode-Sequence with an EmojiNode. For that, the range of the matched handler shall be replaced with a NodeView. However, due to the range being incorrect, this causes no replacement, rather a simple addition.
Which browser was this experienced in? Are any special extensions installed?
Chrome, Firefox, StarterKit + Custom-but-minimal-Extension with a custom InputRule matching anything (
/./
).How can we reproduce the bug on our side?
Alternatively, take a look at the Codesandbox.
Can you provide a CodeSandbox?
https://codesandbox.io/s/still-cdn-qjtljj
What did you expect to happen?
state
of the InputRule's handler should include the state WITH the appended character. I.e. it should represent the state in which the Rule matched.state.doc.textBetween(range.from, range.to)
should return the matched character(s)Anything to add? (optional)
Tested & Broken on Version
beta.209
andbeta.218
.Did you update your dependencies?
Are you sponsoring us?