dolanmiu / docx

Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.

Home Page:https://docx.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

el.elements not iterable when patching comments

bituq opened this issue · comments

It is currently not possible to add comment references or comment ranges when patching a document. Am I missing something?

let children = changes.map((change, index) => {
  if (change.added) {
      return new docx.InsertedTextRun({
          text: change.value,
          id: index,
          author: "test",
          date,
      });
  } else if (change.removed) {
      return new docx.DeletedTextRun({
          text: change.value,
          id: index,
          author: "test",
          date,
      });
  } else {
      return new docx.TextRun({
          text: change.value,

      });
  }
});

patches[el.id] = {
  type: docx.PatchType.PARAGRAPH,
  children: [
      ...children,
      new CommentReference(Number(commentId))
  ]
}

error message:
TypeError: e.elements is not iterable