🎈 Welcome to the Marketplace — Explore and discover the ecosystem around DatoCMS, and share your own work with the community!

Extended Structured Text

Extends Structured text fields to add additional marks and block styles

This is a Community Plugin! Learn how create your own plugin, or copy and remix existing ones in our documentation

Extended Structured Text

This is a DatoCMS plugin designed to extend the default structured text marks and block styles.

Custom Marks

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 }) =&gt; {
const marks = {
strikethrough: (props) =&gt; <s />,
superscript: (props) =&gt; <sup />,
highlight: (props) =&gt; <mark />,
strong: (props) =&gt; <strong />,
subscript: (props) =&gt; <sub />,
underline: (props) =&gt; <u />,
emphasis: (props) =&gt; <em />,
code: (props) =&gt; <code />,
small: (props) =&gt; <small />,
};
node.marks?.forEach((mark) =&gt; (children = marks[mark]({ children })));
return <span>{children}</span>;
});

Custom Block Style

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 }) =&gt;
node.style === 'blockquote' ? (
<blockquote>
{children}
</blockquote>
) : (
<p>{children}</p>
)
);

Alignment

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.

Subscribe to our newsletter! 📥
One update per month. All the latest news and sneak peeks directly in your inbox.
support@datocms.com ©2024 Dato srl, all rights reserved P.IVA 06969620480