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
671 stars 95 forks source link

insertOoxml for Word does not work on WOPI host (CSPP) #4640

Closed aeturneus closed 2 months ago

aeturneus commented 3 months ago

We have created a Word add-in which works fine in desktop and O365, but fails in the WOPI word editor provided by CSPP (the Microsoft Cloud Storage Partner Program)

Issue previously reported here has returned: https://github.com/OfficeDev/office-js/issues/2893#issuecomment-2205963904

In our environment, these lines of code:

  public async applyDOMChanges() {
    const serializedDOM = this.serialize(this.dom);

    await Word.run(async (context) => {
      context.document.body.insertOoxml(serializedDOM, "Replace");

      await context.sync();
    });
  }

Result in this error:

{ "code": "NotAllowed", "message": "The action isn't supported by Word in a browser. Check the OfficeExtension.Error.debugInfo for more information.", "errorLocation": "Body.insertOoxml", "statement": "var insertOoxml = body.insertOoxml(...);", "surroundingStatements": [ "var root = context.root;", "var body = root.body;", "// Instantiate {body}", "// >>>>>", "var insertOoxml = body.insertOoxml(...);", "// <<<<<", "// Instantiate {insertOoxml}" ], "fullStatements": [ "Please enable config.extendedErrorLogging to see full statements." ] }

Your Environment

Expected behavior

The Ooxml should be inserted as happens with desktop and O365.

Current behavior

The text is not inserted and an error is logged in the console.

Steps to reproduce

  1. Use the sample code attached with the WOPI editor provided by CSPP (sample code provided by @nickmckenna) https://github.com/OfficeDev/office-js/files/9754057/Ooxml.Bug.Demo.zip
  2. Click the "Insert OOXML" button
  3. Note that text is not inserted
  4. Note that the error appears in the console

Link to live example(s)

  1. download sample code attached
  2. alternatively, use our production application test account (I will provide credentials if requested)

Context

This bug prevents our production application from being used in WOPI, limiting our ability to deploy this tool to thousands of lawyers across Canada and the United States - it's a critical use case for us.

microsoft-github-policy-service[bot] commented 3 months ago

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

aeturneus commented 2 months ago

@xiruatms the insert OOXML function now works, sort of

However, numbering styles in the document do not work - when the insertion occurs, the numbering styles are not applied

Further, when the document is initially opened, no numbering is visible, and numbering only appears after any change is made to the document (e.g. inserting a space)

I don't know if these issues are related. However, I will open a new issue to better track these problems.

aeturneus commented 2 months ago

@xiruatms new issue posted here https://github.com/OfficeDev/office-js/issues/4698

xiruatms commented 2 months ago

@aeturneus , thanks for your confirmation. If the insert ooxml is working now, I'll close this issue. Our experts are working extensively on #4698