UNPKG

design-comuni-plone-theme

Version:
24 lines (21 loc) 547 B
import { serializeNodesToText } from '@plone/volto-slate/editor/render'; /* Used to verify if slate text blocks are empty */ export const checkRichTextHasContent = (text) => { if (text?.[0]?.children) { return serializeNodesToText(text?.[0]?.children || [])?.length > 0; } return false; }; /* Convert string to Slate value */ export const stringToSlate = (text) => [ { type: 'p', children: [{ text: text || '' }], }, ]; export const toSlateValue = (value) => typeof value === 'string' ? stringToSlate(value) : value;