OfficeDev/office-js

Using setSelectedDataAsync on multiple lines will result in different format

Opened this issue · 1 comments

Your Environment

  • Platform: PC desktop and Office on the web
  • Host: Outlook web and "New Outlook"
  • Operating System: Windows
  • Browser (if using Office on the web): Edge

Expected behavior

When using setSelectedDataAsync with text Coercion Type the inserted text should match surrounding text.

Current behavior

The inserted text has a different formatting compared to the surrounding text

Steps to reproduce

Select multiple lines when composing an Email.
Use the function blow to replace the selected text.

Office.context.mailbox.item?.body.setSelectedDataAsync(
  "Text to insert",
  {
    coercionType: Office.CoercionType.Text,
  }
);

Example

The issue is demonstrated in this video, where you can see the different formatting.
https://github.com/OfficeDev/office-js/assets/68271198/d31ff563-4615-435d-9f1e-2ce90a0702fc

Provide additional details

If you only select one line of text it will have to correct formatting, it's only an issue when selecting multiple lines.
It seems when selecting multiple lines the text is put outside the

where it supposedly should be.
image

Context

We have a live application where we can modify text for the user, and right now we are getting negative feedback because this is breaking the formatting of the email when they use this functionality.

Thanks for reporting. We have put this issue in our backlog but unfortunately we donot have any timelines to share at this point.
Internal tracking id: 4623257