Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context.document.body.text differs depending on platform #5286

Open
pdoyon-Druide opened this issue Jan 17, 2025 · 5 comments
Open

context.document.body.text differs depending on platform #5286

pdoyon-Druide opened this issue Jan 17, 2025 · 5 comments
Assignees
Labels
Area: Word Issue related to Word add-ins Needs: attention 👋 Waiting on Microsoft to provide feedback Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs

Comments

@pdoyon-Druide
Copy link

pdoyon-Druide commented Jan 17, 2025

context.document.body.text does not always return the text displayed in the document with Word Online.

Your Environment

  • Platform : Office on the web
  • Host : Word
  • Office version number: Word online
  • Operating System: Window 10
  • Browser : Google Chrome

Expected behavior

The output of the “context.document.body.text” function should remain consistent across all platforms. At present, it displays the text visible in the document’s preview on both Windows and Mac computers. However, this behaviour does not necessarily hold true for Word Online.

Current behavior

When the "Simple Markup" option is selected in Word Online for displaying "Simple Markup" (Review > Markup View > Markup in margin), the deleted text appears in the "context.document.body.text" property , but it is not displayed in Word's document view.

Steps to reproduce

  1. Open a new document in Word online
  2. Add text : I eat an apples
  3. Enable change tracking -> Review > Track Changes > Just Mine
  4. Delete the 's' character at the end of the word "apples"
  5. Show marks in the margin -> Review > Markup view > Markup in margin (Simple Markup)
  6. Get the text with context.document.body.text

The result is -> I eat an apples.

Context

Our plug-in depends on the “context.document.body.text” method to search for text in a document. Unfortunately, this functionality does not work with Word Online when the “Simple Markup” option is enabled.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Jan 17, 2025
@Rick-Kirkham Rick-Kirkham added Needs: attention 👋 Waiting on Microsoft to provide feedback Area: Word Issue related to Word add-ins and removed Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP labels Jan 17, 2025
@guoms1 guoms1 added Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Jan 20, 2025
@guoms1
Copy link

guoms1 commented Jan 20, 2025

@pdoyon-Druide

Thank you for reporting this issue.

We have confirmed that while the context.document.body.text method works correctly in the Word desktop client, it returns deleted text in Word Online when the "Simple Markup" option is enabled, as you described.

We have logged this issue with the reference number #9698150 and have involved our development team for further review.

We apologize for any inconvenience this may cause and appreciate your patience.

Best regards,

@xiruatms
Copy link

@pdoyon-Druide , thanks for reporting this.

In this case (with "track changes" on), we recommend you to use another API to get the proper text: https://learn.microsoft.com/en-us/javascript/api/word/word.body?view=word-js-preview#word-word-body-getreviewedtext-member(1)

That is:
let text = body.getReviewedText(Word.ChangeTrackingVersion.current); await context.sync();

@xiruatms xiruatms added the Needs: author feedback Waiting for author (creator) of Issue to provide more info label Jan 20, 2025
@pdoyon-Druide
Copy link
Author

Thank you for your suggestion, but “body.getReviewedText(Word.ChangeTrackingVersion.current)” doesn’t quite fit our needs. This method returns text without deleted characters, which may differ from what is displayed in the document. Since our add-in relies on the “Range.search” function to find a specific range in the document, obtaining the text displayed in the document is essential.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Jan 20, 2025
@xiruatms
Copy link

@pdoyon-Druide , I'm not sure whether there're any misunderstanding here, but I can per your test cases. Please check the attachment

Image

@pdoyon-Druide
Copy link
Author

Sorry, I wasn't clear enough. With Word on line, when the “Markup on page” option is selected, the deleted characters appear in the document. However, they disappear when the “Simple Markup” option is activated. “body.getReviewedText(Word.ChangeTrackingVersion.current)” always provides text without deletions. Therefore, the result of this function does not always match to the text displayed in the document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Word Issue related to Word add-ins Needs: attention 👋 Waiting on Microsoft to provide feedback Status: in backlog Issue is being tracked in the backlog but timeline for resolution is unknown Type: product bug Bug in the Office Add-ins platform or Office JavaScript APIs
Projects
None yet
Development

No branches or pull requests

5 participants