-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
a beforeInsertText
function to accept/reject text insertion
#5050
Comments
We're happy to review and consider a PR for this. It should be pretty straightforward to add. Ping us on the Slack group if you need guidance. |
Hmm, I feel like this could be solved somehow with the current api as well 🤔 Not sure about the details yet, but especially on android, we can't assume that Also unrelated to that - limiting text input using |
Well what I could do is to prevent insertion on
Isn't try to "undo the DOM" too complicated? Could you please give some hint how to proceed this way? |
I'm sorry, I haven't explained it well enough 😅 We, by default, But, because we have the 'native' event handling, we add an implicit requirement to the behavior of the I hope that explains it well enough. If you want I can put a pr in for this - but it might take 1-2 weeks until I find the time to do so |
Thank you very much, now I have some little more clear view of what happen under the hood. Basically, I have to find a way to re-render element even if |
Same here |
Problem
I'm working on custom plugin which prevent text insertion under some conditions. I successfully do it by overriding
insertText
function and it works on slate "side" but, considering that text insertion "follow"beforeinput
event, the text is in any case inserted in DOM even ifinsertText
inserts nothingSolution
Considering that in
beforeinput
event some inputType are cancellable (i.e. for example insertText), it would be useful to have abeforeInsertText
function to cancel thebeforeinput
event (it should be called somewhere within theonDOMBeforeInput function
)The text was updated successfully, but these errors were encountered: