OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
665 stars 94 forks source link

[Word API] Document.compare: possible ways to obtain filePath for the documents to compare? #4616

Closed isadovskiy-numatic closed 1 month ago

isadovskiy-numatic commented 1 month ago

Hello.

I'm looking at the new Word.Document.compare() API, which is currently in preview (https://learn.microsoft.com/en-us/javascript/api/word/word.document?view=word-js-preview#word-word-document-compare-member(1)) and got a question about possible ways to work with.

It compares current document to another one, referenced by filePath argument. However it's not clear, what are the possible options to obtain the path to another document within Word Add-in?

If document is on local drive, JS API does allow to obtain the path to. So it's not an option.

Seems like API works with the documents from the web and I can specify URL as a filePath? But I was not able to use Data URLs as a filePath. Is it a bug or expected behavior?

In my scenario, I need to generate the new document dynamically and then compare it to the currently opened one. Is there a way to do it without temporary storing this newly generated document to the web?

Thanks

isabela-dominguez commented 1 month ago

Thank you for sharing this issue @isadovskiy-numatic . Connecting you with @wangyun-microsoft who may be able to help.

isadovskiy-numatic commented 1 month ago

Thanks, @isabela-dominguez.

@wangyun-microsoft , for me, the main question at the moment - if it's expected to use data URLs with the document.compare() API? If it's expected to work - seems like it's a bug (because currently I was not able to get it works).

If data urls are not expected to work, I'm looking for advices/suggestions - how to compare currently document to another one, which is dynamically generated.

YijunMS commented 1 month ago

@isadovskiy-numatic Thanks for reaching us.

Yes, filePath can refer to an online Word Document. For example, if the document is hosted on SharePoint, then you can get the valid url from your SharePoint Site (in "Detail" of the document, there should be a "Path" Tab, which allows you to copy its absolute path).

isadovskiy-numatic commented 1 month ago

Is it possible to compare dynamically generated documents, without the necessity to upload them temporary to the remote web storage? Do data urls are expected to work in the future with the compare() api?

YijunMS commented 1 month ago

@isadovskiy-numatic Currently compare Api expects to take Url to a web Document or file path to a local document. For the scenario you mentioned, I guess a good way may be to allow directly providing the document data (for example, as a Base64 string) instead of using its Url or File Path. In this case, we may need to develop a new Api (for example, compareBase64) that takes those parameters. I think @wangyun-microsoft and @stevefengjin can help to specify the details of this scenario.

isadovskiy-numatic commented 1 month ago

Thanks, @YijunMS.

Does it worth to expect new API like the proposed compareBase64 by the end of this year?

stevefengjin commented 1 month ago

Hi @isadovskiy-numatic , could you please provide your contact information in this form: https://forms.office.com/r/QayRq1FVEb (to be protected vs posting here in GitHub)? We'd like to schedule a follow up meeting to deep dive the scenario and your requirements. Please be informed this Compare API is in preview, and we don't have any committed ETA for updating this API or creating a new API, but your feedback will certainly help us understand the issues in depth then make necessary improvement.

isadovskiy-numatic commented 1 month ago

Thanks for response, @stevefengjin. I filled the provided form.

arashd commented 2 weeks ago

I have the exact same question (https://github.com/OfficeDev/office-js/issues/4740) Can I expect to get updates by subscribing to this issue? Is there a URL where I can track the results of your follow-up meeting?

YijunMS commented 2 weeks ago

@arashd Thanks for reaching us, please see the reply in your original GitHub thread.