What is the difference between a FlatFragment and a TextFragment


I’m looking at the node/document structure and the reference guide and the implementation and I can’t quite figure out what’s the difference between the two since a TextFragment can just as well contains arbitrary nodes (e.g. an image Node in the demo) as well as TextNodes. What would be a 1-2 sentence definition of a FlatFragment vs. a TextFragment?

Note that I’m doing anything in particular with either, just browsing the code and trying to figure out how things work.

Thanks! Boris

Ok, I guess I could see in the code the static method that constructs a TextFragment from an array of nodes if there is at least one text node in the array (i.e. ‘node.isText==true’). So there is some more complicated logic based on that. What is it that makes it special? A confusing aspect is that TextFragment.slice will always return a TextFragment even if the slice contains only non-text nodes.

This was an implementation detail that consumers of the API didn’t need to worry about. It’s also gone in the current master branch, since in the new position scheme every fragment has variable-size children.

Oh, ok, great then, I will just pull the latest then. Thanks! I understood it was an implementation detail, but I think making an effort to understand the implementation would help me :smile: