···11+export class Editor {
22+ constructor() {
33+ let root = document.createElement('editor-container')
44+ let elem1 = document.createElement('div')
55+ let elem2 = document.createElement('div')
66+ let elem3 = document.createElement('textarea')
77+88+ root.append(elem1)
99+ elem1.append(elem2, elem3)
1010+ root.tabIndex=-1
1111+ elem1.tabIndex=-1
1212+ this.root = root
1313+ this.overlay = elem2
1414+ this.textarea = elem3
1515+1616+ let lock = false
1717+ let missed = true
1818+ this.textarea.addEventListener('input', e=>{
1919+ if (lock) {
2020+ missed = true
2121+ return
2222+ }
2323+ lock = true
2424+ this.update()
2525+ setTimeout(()=>{
2626+ lock = false
2727+ if (missed)
2828+ this.update()
2929+ })
3030+ }, {passive: true})
3131+ }
3232+ update() {
3333+ let text = this.textarea.value
3434+ this.overlay.textContent = text
3535+ }
3636+ reset_textarea(text="") {
3737+ this.textarea.value = text
3838+ this.update()
3939+ }
4040+}
4141+/*ugh i'm so tired.. no work today..*/
+10
final.txt
···11+ok so, the components:
22+33+- post rendering (trivial)
44+- composer 1:
55+ - plaintext -> facets
66+ - highlight parsed segments in editor
77+88+so, our parser needs to output 2 things:
99+ - {text,facets} (though, while typing, we only need to fully compute the grapheme length of the text)
1010+ - list of spans to highlight in the input