UNPKG

@liveblocks/react-ui

Version:

A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.

27 lines (24 loc) 878 B
import { Element, Node, Transforms } from 'slate'; function withNormalize(editor) { const { normalizeNode } = editor; editor.normalizeNode = (entry) => { const [node, path] = entry; if (Element.isElement(node) && node.type === "paragraph") { for (const [child, childPath] of Node.children(editor, path)) { if (Element.isElement(child) && !editor.isInline(child)) { Transforms.unwrapNodes(editor, { at: childPath }); return; } } } if (Element.isElement(node) && (node.type === "auto-link" || node.type === "custom-link")) { if (node.children.length === 0 || node.children.length === 1 && node.children[0]?.text === "") { Transforms.removeNodes(editor, { at: path }); } } normalizeNode(entry); }; return editor; } export { withNormalize }; //# sourceMappingURL=normalize.js.map