@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.
1 lines • 1.6 kB
Source Map (JSON)
{"version":3,"file":"normalize.cjs","sources":["../../../../src/primitives/slate/plugins/normalize.ts"],"sourcesContent":["import type { Editor as SlateEditor } from \"slate\";\nimport {\n Element as SlateElement,\n Node as SlateNode,\n Transforms as SlateTransforms,\n} from \"slate\";\n\nexport function withNormalize(editor: SlateEditor) {\n const { normalizeNode } = editor;\n\n editor.normalizeNode = (entry) => {\n const [node, path] = entry;\n\n // Paragraphs should only contain inline elements\n if (SlateElement.isElement(node) && node.type === \"paragraph\") {\n for (const [child, childPath] of SlateNode.children(editor, path)) {\n if (SlateElement.isElement(child) && !editor.isInline(child)) {\n SlateTransforms.unwrapNodes(editor, { at: childPath });\n return;\n }\n }\n }\n\n normalizeNode(entry);\n };\n\n return editor;\n}\n"],"names":["SlateElement","SlateNode","SlateTransforms"],"mappings":";;;;AAOO,SAAS,cAAc,MAAqB,EAAA;AACjD,EAAM,MAAA,EAAE,eAAkB,GAAA,MAAA,CAAA;AAE1B,EAAO,MAAA,CAAA,aAAA,GAAgB,CAAC,KAAU,KAAA;AAChC,IAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,KAAA,CAAA;AAGrB,IAAA,IAAIA,cAAa,SAAU,CAAA,IAAI,CAAK,IAAA,IAAA,CAAK,SAAS,WAAa,EAAA;AAC7D,MAAW,KAAA,MAAA,CAAC,OAAO,SAAS,CAAA,IAAKC,WAAU,QAAS,CAAA,MAAA,EAAQ,IAAI,CAAG,EAAA;AACjE,QAAI,IAAAD,aAAA,CAAa,UAAU,KAAK,CAAA,IAAK,CAAC,MAAO,CAAA,QAAA,CAAS,KAAK,CAAG,EAAA;AAC5D,UAAAE,gBAAA,CAAgB,WAAY,CAAA,MAAA,EAAQ,EAAE,EAAA,EAAI,WAAW,CAAA,CAAA;AACrD,UAAA,OAAA;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEA,IAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,GACrB,CAAA;AAEA,EAAO,OAAA,MAAA,CAAA;AACT;;;;"}