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

Word Online ignores Word styles with insertHtml #2483

Open barisbikmaz opened 2 years ago

barisbikmaz commented 2 years ago

Word Online ignores Word styles with insertHtml

When you insert html in Word or Mac, custom Word classes are mapped to Word font styles.

As an example when you insert an html like: <p class=MsoTitle>My Title</p> This paragraph gets the Word Title style after insertion.

On Word Online these classes are ignored.

Word-Styles

Your Environment

Expected behavior

Word Online should apply custom Word classes as Word font styles.

Current behavior

Word Online ignores Word font styles.

Steps to reproduce

  1. Select the gist example
  2. Run it on Word Windows App
  3. Run it on Word Online
  4. See that the "Title" style is not applied in Online

Link to live example(s)

Gist Example

Provide additional details

The MsoTitle class is mapped to "Title" style in Word.

Context

We have an app which inserts html contents into Word. These contents do not look the same in Online and Word PC or MAC. It would be a great step to support these classes so that we can easily create HTML Contents that work in all Word hosts the same and uses Word styles.

RuizhiSunMS commented 2 years ago

Hello @barisbikmaz Thanks for your submit. We colleague reproduced this issue successfully and create an ADO with id of #5909484 to track. Sorry for having no explicit timeline for now but further updates will be committed here if we have.

penglongzhaochina commented 2 years ago

Thanks for reporting, I just tried copy/paste the paragraph from rich client to word online directly. it also can't show correctly as well. so that's an issue of word online and expected behavior for API.Pls contact online team by feedback to report this issue.

barisbikmaz commented 2 years ago

@penglongzhaochina I can't reproduce what you said.

Copy Word Styles2

penglongzhaochina commented 2 years ago

Hi, @barisbikmaz , follow this step. 1. run the script insert html in the word(not online). 2. Copy the inserted html from rich client word to word online. 3. check the style. The first picture is in the rich client. The second picture is in the word online. image


image

barisbikmaz commented 2 years ago

I realized that you have to apply the styles first in Word for PC. Then it works Copy Word Styles 3

monominia commented 10 months ago

Hey, any update on this bug? Do we get a timeline on it?

debasish1996 commented 9 months ago

facing issues with insertHtml on word online. the same piece of code is working in word native but not in word online.

Any update on this bug?