Skip to content

Why doesn't Typewriter use Svelte to render the text content? #61

Answered by jacwright
jacwright asked this question in Q&A
Discussion options

You must be logged in to vote

I wanted to use Svelte. I thought it would be perfect. However, I couldn't get around certain problems in a cross-browser compatible way that didn't hurt text composition and auto-complete with mobile devices.

The Details

An empty paragraph needs to have a <br> tag in it to keep it from collapsing to 0px-height. Typewriter needs to add this <br> in, and can do so with Svelte. However, in contenteditable, if you place the cursor in the paragraph and type a letter, the <br> is removed from the DOM and a text node is created. Listening to a mutation observer or input event you can read the change from the DOM and update the data model of the editor, then Svelte will update the paragraph to m…

Replies: 1 comment

Comment options

jacwright
Feb 2, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by jacwright
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant