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.

1 lines 1.77 kB
{"version":3,"file":"is-empty.cjs","sources":["../../../src/slate/utils/is-empty.ts"],"sourcesContent":["import type { Descendant } from \"slate\";\nimport { Editor as SlateEditor } from \"slate\";\n\nimport { isEmptyString } from \"./is-empty-string\";\nimport { isText } from \"./is-text\";\n\nexport function isEmpty(editor: SlateEditor, children: Descendant[]) {\n // Check if all blocks are empty, stopping at the first non-empty block\n for (const child of children) {\n if (isText(child)) {\n // Non-empty text\n if (!isEmptyString(child.text)) {\n return false;\n }\n } else if (child.type === \"paragraph\") {\n // Non-empty paragraph\n if (\n child.children.length > 1 ||\n (child.children[0] &&\n !(isText(child.children[0]) && isEmptyString(child.children[0].text)))\n ) {\n return false;\n }\n } else {\n // Non-empty other block\n if (!SlateEditor.isEmpty(editor, child)) {\n return false;\n }\n }\n }\n\n return true;\n}\n"],"names":["isText","isEmptyString","SlateEditor"],"mappings":";;;;;;AAMgB,SAAA,OAAA,CAAQ,QAAqB,QAAwB,EAAA;AAEnE,EAAA,KAAA,MAAW,SAAS,QAAU,EAAA;AAC5B,IAAI,IAAAA,aAAA,CAAO,KAAK,CAAG,EAAA;AAEjB,MAAA,IAAI,CAACC,2BAAA,CAAc,KAAM,CAAA,IAAI,CAAG,EAAA;AAC9B,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF,MAAA,IAAW,KAAM,CAAA,IAAA,KAAS,WAAa,EAAA;AAErC,MAAA,IACE,MAAM,QAAS,CAAA,MAAA,GAAS,KACvB,KAAM,CAAA,QAAA,CAAS,MACd,EAAED,aAAA,CAAO,KAAM,CAAA,QAAA,CAAS,EAAE,CAAK,IAAAC,2BAAA,CAAc,MAAM,QAAS,CAAA,CAAA,CAAA,CAAG,IAAI,CACrE,CAAA,EAAA;AACA,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACK,MAAA;AAEL,MAAA,IAAI,CAACC,YAAA,CAAY,OAAQ,CAAA,MAAA,EAAQ,KAAK,CAAG,EAAA;AACvC,QAAO,OAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF;AAAA,GACF;AAEA,EAAO,OAAA,IAAA,CAAA;AACT;;;;"}