即使在将文档保存到SharePoint之前,context.document.saved属性也会过早更新

时间:2017-02-27 11:05:56

标签: office-js

我有一个查询reg context.document.saved属性 https://dev.office.com/reference/add-ins/word/document?product=word

Repro步骤 - 步骤1)使用此处的代码段创建Word任务窗格地址 -

 function getDataFromSelection() {
        Office.context.document.getSelectedDataAsync(Office.CoercionType.Text,
            function (result) {
                if (result.status === Office.AsyncResultStatus.Succeeded) {

                    Word.run(function (context) {

                        var thisDocument = context.document;

                        // Queue a commmand to load the document save state (on the saved property).
                        context.load(thisDocument, 'saved');

                        return context.sync().then(function () {


                            app.showNotification('The saved state right now is:', '"' + thisDocument.saved + '"'); 

                        });
                    })

                } else {

                  //  do nothing
                }
            }
        );

第2步 - 在任何SP网站上托管docx文件 第3步 - 单击它并在Word客户端应用程序中打开它(Word 2016) 第4步 - 将加载项加载到Word上(使用https://dev.office.com/docs/add-ins/testing/create-a-network-shared-folder-catalog-for-task-pane-and-content-add-ins) 第5步 - 你的插件应该加载正常 步骤6 - 在文档中进行一些更改,当您单击按钮时,保存的属性显示为false 步骤7 - 现在点击Word中的Save按钮,立即再次点击addin按钮检查保存的属性。即使在将文档上载到SharePoint之前,您也会看到addin saved属性变为TRUE

期望 - 文档实际保存到SP后,保存的属性应为true。

当前行为 - 我觉得保存的属性立即设置为true是不正确的。

如果以上是设计,有没有更好的方法来知道文档已成功保存,目前我们依赖于保存的属性。

0 个答案:

没有答案