-
-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
897b749
commit ed0c5a4
Showing
6 changed files
with
32 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const addP2Li = (listElement: Element) => { | ||
listElement.querySelectorAll("li").forEach((liElement: HTMLElement) => { | ||
let tempNodes = []; | ||
let node = liElement.firstChild as HTMLElement; | ||
while (node) { | ||
if (node.nodeType === 3) { | ||
tempNodes.push(node); | ||
} else if (node.tagName !== "UL" && node.tagName !== "OL" && | ||
node.tagName !== "BLOCKQUOTE" && node.tagName !== "P") { | ||
tempNodes.push(node); | ||
} else if (tempNodes.length > 0) { | ||
const pElement = document.createElement("p"); | ||
tempNodes.forEach((nodeItem) => { | ||
pElement.appendChild(nodeItem); | ||
}); | ||
node.insertAdjacentElement('beforebegin', pElement) | ||
tempNodes = []; | ||
} | ||
|
||
node = node.nextSibling as HTMLElement; | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters