|
|
|
|
|
by evangow
2613 days ago
|
|
One area where the virtual DOM seems to be important is for rich text editors, where the VDOM can basically take the input, diff it using an immutable structure, then render it to properly structured HTML. An example use case where this would be valuable: a user hightlights text, bolds it, then highlights it again plus some more text, and bolds it. A naive approach would have: <b><b>This text is bolded</b> plus I bolded this</b> when what you want would simply be: <b>This text is bolded plus I bolded this</b> Libraries like DraftJS and SlateJS use immutable data structures to parse the input/formatting in the VDOM and reconcile them into "blocks" (basically javascript objects containing the formatting) that deduplicate formatting. The talk below on DraftJS is pretty good. https://www.youtube.com/watch?v=feUYwoLhE_4 What's the recommended way to handle a rich text application in Svelte? Is there anything like the above for Svelte? |
|