Office-js: [Word] content control adds new line

Created on 19 Dec 2018  路  6Comments  路  Source: OfficeDev/office-js

Expected Behavior

Content should stay identical when adding content control, and when replacing ooxml with it's own ooxml.

Current Behavior

Extra line is added with header, paragraph. No extra line gets added when just a few words are selected.

Steps to Reproduce, or Live Example

Word.run(async (context) =>
{
    const serviceNameRange = context.document.getSelection();
    const cc = serviceNameRange.insertContentControl();

    let ooxml = cc.getOoxml();

    await context.sync();

    cc.insertOoxml(ooxml.value, "Replace");

    return context.sync();
})
.catch((error) =>
{
    console.log("Error: " + error + JSON.stringify(error.debugInfo));
});

Context

Users can not rely on functionality with this bug in place, because they have to fix layout after use.

Your Environment

  • Platform PC desktop
  • Host Word
  • Office version number: 365
  • Operating System: Win 10
  • Browser (if using Office Online): ______

Useful logs

bug-contentcontrol-header

Word product bug

All 6 comments

@rvanlaak can you please share the specific build your are using for Word? And I am asking this because we fixed this issue (long time ago) and it should not be adding a new line.

We are using Word version 1803, which should be the latest version? https://docs.microsoft.com/en-us/officeupdates/update-history-office365-proplus-by-date

image

Is there actually a way for us to write automated tests for this? As in, how can we write functional integration tests for our Word addin?

Are there by any chance some mock test helpers for methods like Office.context.document.getFileAsync and Office.context.document.getSelectedDataAsync?

Any update on this bug report?

this is effectively a regression, it used to be fixed. we are tracking with 3451201

notice 3451201 is resolved by design.

@grangeryy could you elaborate a bit more on that?

We are preparing for putting lots of effort in migrating our "find and replace" macros to office-js. If the API design changed in a way that is offers us more flexibility as before that would be of great help 馃挭

Was this page helpful?
0 / 5 - 0 ratings