Select no longer highlighting text on iPad (word)

你。 提交于 2019-12-11 06:14:04

问题


In my add-in we navigate the document by calling select on either a paragraph or a search result from inside a paragraph. In the newest version of Word for iOS : 2.0.2 (170415) the document is scrolling to the correct part of the document but the text is no longer highlighting. This was working in the previous released version of word.

Oddly the text does highlight as expected if i open the search bar, and then navigate around my document.

  public SelectTextInstance(text: string, paragraphIndex: number, textInstance: number) {
    Word.run(function (context) {

        // Create a proxy object for the paragraphs collection.
        var paragraphs = context.document.body.paragraphs;

        context.load(paragraphs, 'text,font');

        return context.sync().then(function () {

            if (paragraphIndex == -1) {//currently would occur for items that are inside of tables.
                return;
            }

            var paragraph = paragraphs.items[paragraphIndex];

            return context.sync().then(function () {
                var ranges = null;
                //256 is the maximum length for a search item.  Longer than this and we just have to select the paragraph.
                if (text != undefined && text != null && text.length <= 256) {
                    ranges = paragraph.search(text, { matchCase: true, ignoreSpace: true});
                    context.load(ranges, 'text');
                }
                return context.sync().then(function () {
                    if (ranges == null || ranges.items.length == 0) {
                        paragraph.select();
                    }
                    else {
                        //select the paragraph rather than overflow - something bad happened somewhere, so we'll fall back to highlighting the paragraph.
                        if (ranges.items.length <= textInstance) {
                            paragraph.select();
                        } else {
                            ranges.items[textInstance].select();
                        }
                    }
                    return context.sync().then(function () {

                    });

                });
            });
        });
    })
        .catch(function (error) {
            console.log('Error: ' + JSON.stringify(error));
            if (error instanceof OfficeExtension.Error) {
                console.log('Debug info: ' + JSON.stringify(error.debugInfo));
            }
        });
}

回答1:


Thanks so much for reporting this. Effectively this is a regression. The range is selected but not colored. We will push the fix for the next update.



来源:https://stackoverflow.com/questions/43613951/select-no-longer-highlighting-text-on-ipad-word

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!