Modify Text interface to be compatible with "universal syntax tree" (unist)
See original GitHub issueProblem The unified ecosystem provides a vast amount of utility functions for tree traversal, transformation and validation. It also supports easy parsing of html and markdown out of the box. We (and I can image others too) would love to leverage those tools in combination with slate. However both trees are not compatible: Slate expects leaf nodes of the following shape:
interface Text {
text: string
}
while leaf (literal) nodes defined in unist have the following shape:
interface Literal {
type: "text",
value: string
}
Solution
As you can see the only incompatibility is the name of the value key text
vs value
(And just renaming that across slate does the trick)
Context In my fork I have a version of slate that is fully compatible with unist-style trees. I was just wondering if support for this is something you’re interested in and if I should therefore put the work into a PR. It would most definitely result in a breaking change so I can understand if you don’t.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:11 (5 by maintainers)
Top GitHub Comments
I personally am a fan of this change (not sure how others on the core slate team feel), though it’s a breaking change and it would have significant impact on users that persist slate documents.
I can see a couple of paths towards getting this to work, assuming this is a change that the Slate team wants to support:
I think if we followed my proposed approach we could make it work, along with your note. Interested in raising a PR?