This is a DatoCMS plugin designed to extend the default structured text marks and block styles.
This plugin adds support for the following marks: <small />
, <sub />
& <sup />
see customMarkRules on the StructuredText component exported from datocms-react
export const spanRule = renderNodeRule(isSpan, ({ ancestors, node, key }) => { const marks = { strikethrough: (props) => <s />, superscript: (props) => <sup />, highlight: (props) => <mark />, strong: (props) => <strong />, subscript: (props) => <sub />, underline: (props) => <u />, emphasis: (props) => <em />, code: (props) => <code />, small: (props) => <small />, };
node.marks?.forEach((mark) => (children = marks[mark]({ children })));
return <span>{children}</span>;});
It also adds in a block style for blockquote which you can use to output blockquote's instead of paragraph tags:
Add this to your application's code See: <https://github.com/datocms/react-datocms/blob/master/docs/structured-text.md#override-default-rendering-of-nodes>
export const paragraphRule = renderNodeRule( isParagraph, ({ ancestors, children, key, node }) => node.style === 'blockquote' ? ( <blockquote> {children} </blockquote> ) : ( <p>{children}</p> ));
We removed text alignment from this plugin as it makes much more sense being a block and we would encourage you to add text alignment as a custom block instead.