Here's 2 articles on building a SQL editor.
- https://arctype.com/blog/sql-query-editor-switch/
- https://arctype.com/blog/indexeddb-localstorage/
Disclaimer: I wrote the 2nd one. My general takeaway is that it gets interesting quickly as the amount of text edited increases.