You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* - If the first child of an `li` has ONLY text content, take the text content, and flatten it into the list item. Subsequent siblings are carried over as is, as children of the list item.
11
-
* - e.g. `<li><h1>Hello</h1><p>World</p></li> -> <li>Hello<blockGroup><blockContainer><p>World</p></blockContainer></blockGroup></li>`
12
-
* - Else, take the content and insert it as children instead.
13
-
* - e.g. `<li><img src="url" /></li> -> <li><p></p><blockGroup><blockContainer><img src="url" /></blockContainer></blockGroup></li>`
14
-
*
15
-
* This ensures that a list item's content is always valid ProseMirror content. Smoothing over differences between how external HTML may be rendered, and how ProseMirror expects content to be structured.
19
+
* It turns out that fixing these edge cases requires a different approach, and
20
+
* a detailed write-up regarding this can be found here:
@@ -23,30 +29,17 @@ export function getListItemContent(
23
29
* The schema to use for parsing.
24
30
*/
25
31
schema: Schema,
26
-
/**
27
-
* The name of the list item node.
28
-
*/
29
-
name: string,
30
32
): Fragment{
31
-
/**
32
-
* To actually implement this algorithm, we need to leverage ProseMirror's "fitting" algorithm.
33
-
* Where, if content is parsed which doesn't fit into the current node, it will be moved into the parent node.
34
-
*
35
-
* This allows us to parse multiple pieces of content from within the list item (even though it normally would not match the list item's schema) and "throw" the excess content into the list item's children.
36
-
*
37
-
* The expected return value is a `Fragment` which contains the list item's content as the first element, and the children wrapped in a blockGroup node. Like so:
0 commit comments