Giter Site home page Giter Site logo

Comments (4)

JuaneloJuanelo avatar JuaneloJuanelo commented on August 23, 2024 1

@NickAtk btw this was a known issue and was fixed and will be available soon.
This is the code that i tried in the updated build and it just replaces the text. Tried it in a list context and also works ok. (just replaces the text without modifying the list format). Would be great if you can share the HTML and the OOXML you are trying to insert to verify it. thanks!

`

   function replaceWithHTML() {
    Word.run(function (ctx) {
        var myRange = ctx.document.getSelection().insertHtml("<b>some bold text!</b>", "replace");
        return ctx.sync();
    });

}

  function replaceWithText() {
                  Word.run(function (ctx) {
                     var myRange = ctx.document.getSelection().insertText("This is the Text!", "replace");
                        return ctx.sync();
                      });
}


function replaceWithOOXML() {
    Word.run(function (ctx) {
        var myRange = ctx.document.getSelection().insertOoxml("<w:p xmlns:w='http://schemas.microsoft.com/office/word/2003/wordml'><w:r><w:rPr><w:b/><w:b-cs/><w:color w:val='FF0000'/><w:sz w:val='28'/><w:sz-cs w:val='28'/></w:rPr><w:t>Hello world (this should be bold, red, size 14).</w:t></w:r></w:p>", "replace");
        return ctx.sync();
    });


}

`

from office-js-docs.

MIchaelMainer avatar MIchaelMainer commented on August 23, 2024

Thank you @NickAtk for reporting this issue. Does this occur with any OOXML you insert into the paragraph that is part of a bulleted list?

@JuaneloJuanelo

from office-js-docs.

NickAtk avatar NickAtk commented on August 23, 2024

The sort of thing I am doing is simple replacement of some text with some other text. However even if the text is unchanged it happens. Every time. Very consistent.

I have tried OOXML with (and without) the numbering.xml data (relationship http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering) which I haven't altered from what Word gives me (except removing the mc:Ignorable attribute).

Word appears to change the information in the numbering.xml data in a way that doesn't preserve the appearance of the paragraph.

from office-js-docs.

JuaneloJuanelo avatar JuaneloJuanelo commented on August 23, 2024

@NickAtk thanks for reporting this. I have a quick question, if you are just replacing text why not use insertText method? or why is it that you need OOXML or HTML ? thanks!

from office-js-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.