6 ms·
That does indeed work. You do need to override Node component and if you want to have even more changes - all of those would have to be located within that cust
by Ronsenshi 10y ago
That does indeed work. You do need to override Node component and if you want to have even more changes - all of those would have to be located within that custom component.
I haven't really thought much about API or possible implementation for Marks for Nodes. My thoughts generally revolve around the idea that blocks should have extensible styling via Schema in the same way you can add custom Marks in your Schema. You should be able to change styling of the nodes within the Schema instead of overriding block simply because of the alignment or some other minor style.
- ianstormtaylor 10y agoThat makes sense. And you can do that with Slate! Since the components are all React components you can use the same types of extending patterns you'd use in React. In this case you'd probably use a higher-order component (HOC) that handles adding to the `style` property based on the node's data. And then you could wrap all of your other blocks with it... quote_block: alignment(QuoteBlock), code_block: alignment(CodeBlock), ... One of the things I started with was making sure that components are just React components, so that all of the patterns that the React ecosystem brings can be used with Slate.