I’m looking at refactoring our widgets. Now they are overlays with absolute positioning, but putting them in the PM content flow will simplify things.
But when a widget has a textarea or input, I can’t focus and type there. The text goes to the previous PM position, even though the textarea has focus.
You are right. For my application that isn’t a problem because my editor is being used to build HTML content not data entry. Another issue I found in FF is that you sometimes get a NS_ERROR_FAILURE. It doesn’t affect anything and apparently has something to do with focus in FF.
That also made me wonder if text entered in input fields is even tracked by PM.
I found this quite old but related post.
I can focus and type anything in the textarea, but when I press delete or backspace, the editor content changes, which I am not sure is bug or not.
You’ll want to provide a stopEvent option for the widget. Also, onKeyPress (with capital letters) isn’t going to have any effect, and you want onkeydown anyway, because that’s the event that the editor handlers.
Furthermore, if you recreate your widget every time apply is called, that will indeed reset the textarea whenever something happens in the editor, so that’s probably not a good idea. Using a function, instead of a DOM node, when creating the decoration, and making sure you keep passing the exact same function value, can prevent this.
It seems that I have been ignoring this option before, although I used it in nodeviews.
Thank you for pointing out my mistake and the helpful instruction.