javascript - Why is docx library generating invalid doc file when creating a different copy of the node? - Stack Overflow

I am trying to build a library using docx. And I wanted to implement plugin architecture. So, the data

I am trying to build a library using docx. And I wanted to implement plugin architecture. So, the data provided by plugin should work well with the eco-system.

But strangely, when I compare the data with JSON.stringify, the same data when created directly using docx library instance in the app works but the same data geenrated in some other library using the docx library does not work.

Initially I had no clue. But I just tested out this

// this is the simplified code
new Documnet({
   sections: [
    children: {
       Object.assign({}, new Paragraph("some text"));
    }
  ]
})

If you don't use Object.assign, it works well. But it created corrupted document when I used Object.assign.

When I compared the working and non-working files, I noted that the corrupt file had <rootKey>w:r</rootKey> in document.xml in place of <w:r><w:t xml:space="preserve">some text here</w:t></w:r>.

Also check out this issue -

I tried going through the codebase but didn't find any obvious reason. Can anyone help with this please.

Here's the exact code - .ts#L106

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744789430a4593824.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信