Select 不再突出显示 iPad 上的文本(单词)

Select no longer highlighting text on iPad (word)

在我的加载项中,我们通过对段落或段落内的搜索结果调用 select 来导航文档。在 iOS 的最新版本 Word 中:2.0.2 (170415) 文档滚动到文档的正确部分,但文本不再突出显示。这在以前发布的 word 版本中有效。

奇怪的是,如果我打开搜索栏,然后浏览我的文档,文本会按预期突出显示。

  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));
            }
        });
}

非常感谢您报告此事。实际上这是一种倒退。范围被选中但未着色。我们将在下一次更新中推送修复。