Open AlbertMarashi opened 2 years ago
bump
@dummdidumm could we get a look at implementing this for 5.0?
ie <svelte:node type="comment|text" value="...">
This seems super niche, and solvable in userland already. Can you elaborate on why this would be useful?
@Rich-Harris it's extremely useful when building contenteditable
editors, in order to attach various properties to the node for tracking. This could be achieved with either a #comment
or #text
node.
When solved in userland, it involves wrapping the text in an element in order to get access to the text Text Node.
However, I will close as I no longer need this as I am not working on that project anymore
I need something like this again
Describe the problem
Having the ability to bind to text or comment nodes would be valuable for people developing CMS tools, page builders and other content-editing related projects.
Related issues:
https://github.com/sveltejs/svelte/issues/4544
Describe the proposed solution
Ability to bind to a special svelte element type such as
<svelte:text>
or<svelte:comment>
or the proposed<svelte:element tag="#text">
Text Nodes are a valid Node in HTML, and come with all the properties and methods that people will find valuable to be able to bind to, such as
.after()
.nextSibling
.parentNode
and so on.Editors like Prose mirror attach metadata to nodes in order to count cursor offsets and lengths, and being able to do this would be valuable.
Alternatives considered
Creating a useless element and binding to that in order to get to the text node, eg:
Importance
#text
nodes, useful for page-builders, without needing to wrap in a useless element which may affect content-flow.