+/*
+ * This function is a custom normalization function to allow nested lists within list item elements.
+ * Original taken from https://github.com/facebook/lexical/blob/6e10210fd1e113ccfafdc999b1d896733c5c5bea/packages/lexical-list/src/LexicalListNode.ts#L284-L303
+ * With modifications made.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ * MIT license
+ */
+function $normalizeChildren(nodes: Array<LexicalNode>): Array<ListItemNode> {
+ const normalizedListItems: Array<ListItemNode> = [];
+
+ for (const node of nodes) {
+ if ($isListItemNode(node)) {
+ normalizedListItems.push(node);
+ } else {
+ normalizedListItems.push($wrapInListItem(node));
+ }
+ }
+
+ return normalizedListItems;
+}
+
+function $wrapInListItem(node: LexicalNode): ListItemNode {
+ const listItemWrapper = $createCustomListItemNode();
+ return listItemWrapper.append(node);
+}
+