handleNodes.ts 560 B

1234567891011121314151617181920212223
  1. import {
  2. Paragraph,
  3. TextRun,
  4. HeadingLevel,
  5. ParagraphChild
  6. } from "docx"
  7. // 本模块主要用于复杂文本标签结构,从中提取#text节点,Element依然由handleElement处理
  8. export const handleNodes = (nodes: NodeListOf<ChildNode>): ParagraphChild[] => {
  9. const paragraphChildList: ParagraphChild[] = []
  10. nodes.forEach((n) => {
  11. if (n.nodeType === 3) {
  12. // TEXT节点
  13. } else if (n.nodeType === 1) {
  14. // ELEMENT节点
  15. }
  16. })
  17. return new Paragraph({
  18. children: [new TextRun()],
  19. spacing: { after: 200 },
  20. })
  21. }