fastmail / Squire

The rich text editor for arbitrary HTML.
MIT License
4.77k stars 406 forks source link

Invalid `setKeyHandler` `key` parameter type #441

Closed ioanmo226 closed 11 months ago

ioanmo226 commented 1 year ago

Although the first parameter for squire.setKeyHandler should be string, it's showing up as a number. and displays type error image https://github.com/fastmail/Squire/blob/311b8ee39e6c9a3dabb961baa54a6dfce438a17c/source/Editor.ts#L121C1-L121C1 https://github.com/fastmail/Squire/blob/311b8ee39e6c9a3dabb961baa54a6dfce438a17c/source/Editor.ts#L252C14-L252C14

neilj commented 1 year ago

Re-initializing squire-rte

Looking at the proposed change, it looks like you are calling new Squire(...) multiple times on the same root node? You should only ever have one active Squire instance managing the same DOM content, or you're going to have problems. Make sure you do editor.destroy() on the old instance before creating the new one and you should be fine.

Although the first parameter for squire.setKeyHandler should be string, it's showing up as a number.

Yes, this is an error in the types. (For future, please create separate issues for separate things — that one we should fix).

ioanmo226 commented 1 year ago

Yep, you're right. I forgot the destroy function. Once I destroyed the old instance and created a new one, everything worked fine. Thank you. I've updated the issue title, description, and submitted a new PR.