Saveasblob error with comments

Where is there comments in the document, calling saveAsBlob will cause a error: "t.replace is not a function"


9 Replies

DS Dhanush Sekar Syncfusion Team October 23, 2023 03:13 PM UTC

Hi Dugan,


We have tried to replicate the reported issue from our end. we could not reproduce the issue. could you please share the input word document and error screen shot? it will be helpful to validate further, and we will provide the solution as soon as possible.


Thanks,

Dhanush Sekar



DZ Dugan Zhang December 12, 2024 02:58 AM UTC


Image_3989_1733972227711


edit-online.js?v=20241212T015817:59

 Uncaught (in promise) TypeError: t.replace is not a function

    at t.writeStringInternal (stream-writer.js:144:12)

    at t.writeAttributeString (stream-writer.js:144:12)

    at i.serializeCommentInternal (keywords.js:342:40)

    at i.serializeComments (keywords.js:342:40)

    at i.serialize (keywords.js:342:40)

    at i.saveAsBlob (keywords.js:342:40)

    at keywords.js:342:40

    at i._execute (lib.min.js?v=RYxts_Z…SY2m3G_y5M:40:20832)

    at i._resolveFromExecutor (lib.min.js?v=RYxts_Z…SY2m3G_y5M:40:43502)

    at new i (lib.min.js?v=RYxts_Z…SY2m3G_y5M:40:35829)

    at i.saveAsBlob (keywords.js:342:40)

    at EditOnline.save (edit-online.js?v=20241212T015817:43:60)

    at t.evaluate (lib.min.js?v=RYxts_Z…SY2m3G_y5M:47:42300)

    at t.Listener.n.callSource (lib.min.js?v=RYxts_Z…Y2m3G_y5M:47:108360)

    at t.Listener.n.handleEvent (lib.min.js?v=RYxts_Z…Y2m3G_y5M:47:108513)

    at n.handleEvent (lib.min.js?v=RYxts_Z…SY2m3G_y5M:47:64046)



MA Mohammed Affan Saqib Hussain Syncfusion Team December 13, 2024 12:38 PM UTC

Hi Dugan Zhang,

We have tried to replicate the issue in the latest version(v28.1.33) but couldn't reproduce it. and we have attached the sample used to try to replicate the issue. Please use the attached sample to check this issue. If the issue persists, kindly share the sample used on your end or modify the attached sample to reproduce it and send it back. Thereby, we will analyze further and provide you with the appropriate solution at the earliest.

In the sample we have added a save button when clicked we use the saveAsBlob method and open the saved document in the Editor simultaneously.

Sample -  https://stackblitz.com/edit/2eekgc-tmxmwrgp?file=index.html,index.js

Regards,

Mohammed Affan C



DZ Dugan Zhang December 17, 2024 04:09 PM UTC

I have updated to latest version (28.1.33), While I can add comment initially, and save the document. But after reloading the document, and try to add second comment, try to save it cause an error just like before.

So when the document does not have any comments, you can add comments. Once the document already have comments, you cannot add new comment.

The error message: 

Unhandled rejection TypeError: t.replace is not a function at r.writeStringInternal (https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-file-utils.umd.min.js?v=20241217T155342:1:7931) at r.writeAttributeString (https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-file-utils.umd.min.js?v=20241217T155342:1:4038) at d.serializeCommentInternal (https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-documenteditor.umd.min.js?v=20241217T155342:1:2815590) at d.serializeComments (https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-documenteditor.umd.min.js?v=20241217T155342:1:2808467) at d.serialize (https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-documenteditor.umd.min.js?v=20241217T155342:1:2802684) at d.saveAsBlob (https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-documenteditor.umd.min.js?v=20241217T155342:1:2800724) at https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-documenteditor.umd.min.js?v=20241217T155342:1:3312842 at t._execute (https://elms-local-cms.runstraight.com:7001/lib/lib.min.js?v=RYxts_ZcRSMtfhSfWN9zZzgIEaQHYY4TFSY2m3G_y5M:40:20832) at i._resolveFromExecutor (https://elms-local-cms.runstraight.com:7001/lib/lib.min.js?v=RYxts_ZcRSMtfhSfWN9zZzgIEaQHYY4TFSY2m3G_y5M:40:43502) at new i (https://elms-local-cms.runstraight.com:7001/lib/lib.min.js?v=RYxts_ZcRSMtfhSfWN9zZzgIEaQHYY4TFSY2m3G_y5M:40:35829) at u.saveAsBlob (https://elms-local-cms.runstraight.com:7001/lib/syncfusion/ej2-documenteditor.umd.min.js?v=20241217T155342:1:3312755) at EditOnline.save (https://elms-local-cms.runstraight.com:7001/scripts/document/edit-online.js?v=20241217T155342:44:60) at t.evaluate (https://elms-local-cms.runstraight.com:7001/lib/lib.min.js?v=RYxts_ZcRSMtfhSfWN9zZzgIEaQHYY4TFSY2m3G_y5M:47:42300) at n.callSource (https://elms-local-cms.runstraight.com:7001/lib/lib.min.js?v=RYxts_ZcRSMtfhSfWN9zZzgIEaQHYY4TFSY2m3G_y5M:47:108360) at n.handleEvent (https://elms-local-cms.runstraight.com:7001/lib/lib.min.js?v=RYxts_ZcRSMtfhSfWN9zZzgIEaQHYY4TFSY2m3G_y5M:47:108513) at n.handleEvent (https://elms-local-cms.runstraight.com:7001/lib/lib.min.js?v=RYxts_ZcRSMtfhSfWN9zZzgIEaQHYY4TFSY2m3G_y5M:47:64046)



KM Kavitha Muralitharan Syncfusion Team December 19, 2024 10:54 AM UTC

Hi Dugan Zhang,


We were unable to reproduce the reported issue in our latest version (v28.1.35). We have attached the sample used to try to replicate the issue along with the replication video for your reference. Please use the attached sample and video to check this issue, and if the issue replication doesn't meet your exact replication, please share the exact replication steps as a video reference along with the error to investigate it further.


Sample: https://stackblitz.com/edit/2eekgc-zkuefamo?file=index.html,package.json


Regards,

Kavitha M


Attachment: Comment_Save_Reload_Demo_aa291f5d.zip


DZ Dugan Zhang December 19, 2024 02:12 PM UTC

If the document initially does not have comment, you can comment. But you load an existing document that has comments, you cannot save it. I have attached the screen shots of the document and error message when I click the save button.



Attachment: error_32ed3baa.zip


MA Mohammed Affan Saqib Hussain Syncfusion Team December 20, 2024 12:16 PM UTC

Hi Dugan Zhang,

We have tried to replicate the issue but couldn't reproduce it. and we have attached the sample used to try to replicate the issue.  We have also attached a video for you reference.

We opened a document with a comment, added another comment, saved it using the saveAsBlob method, and then reopened it in the Document Editor. We have also attached the code snippet we used for this process. Could you please confirm if this matches your approach? If the issue continues, please share your sample or modify the attached one to demonstrate the issue and return it to us. We will then conduct further analysis and provide you with a suitable solution as soon as possible.

If this issue occurs in a specific document, please share the document along with the steps for replication and a video demonstration. We will then conduct further analysis and provide you with a suitable solution as soon as possible.

NoteIf you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.

 

Sample -

https://stackblitz.com/edit/2eekgc-tmxmwrgp?file=index.html,index.js

 

 

Code Snippet:

 

container.documentEditor.saveAsBlob('Docx').then((blob) => {

    var file = new File([blob], "document.docx");

    container.documentEditor.open(file);

  });

Regards,

Mohammed Affan C


Attachment: SaveAsBlobComment_3a331b99.zip


DZ Dugan Zhang December 20, 2024 03:21 PM UTC

I trace through code, the error is in  XmlWriter.prototype.writeStringInternal, it try to do string replace on a date object.

The version that I have, is date object, the version in your example, the date is string value.



MA Mohammed Affan Saqib Hussain Syncfusion Team December 23, 2024 01:55 PM UTC

Hi Dugan Zhang,

We have reviewed the serialize method in the latest version and were unable to reproduce the reported issue. If this issue occurs in a specific document, we suspect it may be due to the content within the Word document you are using.

To accurately replicate the problem on our end, we need to examine the content of your input Word document. Could you please provide us with the document you used and share any console error details you encountered? This will enable us to conduct a thorough analysis and offer you the most suitable solution promptly.

Note: If your Word document contains any confidential information, please substitute it with dummy data before sharing. We only require your document to replicate the issue you are experiencing.

Regards,

Mohammed Affan C



Loader.
Up arrow icon