Open JamieMair opened 2 months ago
Hi @JamieMair Thanks for reporting this issue. we'll take a look and report back if we have a suggestion for you.
Hi @JamieMair we do some investigations, methods like context.document.onParagraphAdded.add, their parameters should be an async method, otherwise it will hit error. you can modify this, if it is not useful, you can provide us existingIds. Thanks
Changing the event handlers to async should fix that error, but the problem still persists if that fix is made. I have changed the original example to fix this.
Hi @JamieMair we'll take a look and report back if we have a suggestion for you.
@JamieMair , thanks for reporting this.
It seems there's something wrong with the codes you pasted:
Will you please confirm whether that's expected?
@xiruatms Thanks for picking up on this. Yes it is an error in the code pasted, but the underlying error still persists.
Provide required information needed to triage your issue
Sometimes when the document is edited quickly (such as multiple copy and paste by the user), the events for paragraphs added/changed or removed are not executed at all.
Example code to reproduce:
Connect the
checkForMissedEvents
function up to a button in a Word Add In. Open a document and then add some text to use for editing. Edit the text by copy pasting paragraphs / deleting text etc. Copy a paragraph and paste multiple times very quickly in succession. Triggering thecheckForMissedEvents
should see if any updates were missed by the events by printing to the console.Your Environment
Expected behavior
No events for onParagraphAdded, onParagraphDeleted or onParagraphChanged should ever be missed. They can be delayed, but they should fire eventually.
Current behavior
Some events are missed when the document is edited quickly. Especially with copy and paste.
Steps to reproduce
checkForMissedEvents
function when clicked.Link to live example(s)
Script Lab did not work for me.
Provide additional details
n/a
Context
The Word Add In I am trying to create needs access to the text of the entire document to process statistics. In order to not slow down the user's machine by running the update on the entire text every time a change is made, we re-designed the system to work by only updating the stats based on changed to paragraphs which reduces the impact on the user. This works for light editing of the text, but only if the events correctly fire on the Word side. No events can be missed, or the statistics will be incorrect.