之前没发生 现在经常出现的报错

阅读次数 68

"type":"edit","name":"edit_blocking","cmd":"deleteTextForSel","cooperCount":1,"isSessionSlow":false,"isCoreTypo":false,"subDocType":0

3 Answers

您好,可否详细描述下复现过程,以便我们更好的排查问题

const inlineShapes = await _this.instance.Application.ActiveDocument.InlineShapes const htmlCode = imguu await inlineShapes.AddPicture({ FileName: htmlCode,
LinkToFile: false,
SaveWithDocument: false
})
await _this.instance.Application.ActiveDocument.ActiveWindow.Selection.MoveDown()
const DocumentRange = await _this.instance.Application.ActiveDocument.GetDocumentRange()
const End = await DocumentRange.End
const Range = await _this.instance.Application.ActiveDocument.Range.SetRange(End - 9, End - 9)
setTimeout(async() => {
await Range.PasteHtml({ HTML: _this.globalHtml })
_this.initBtnStatus() // 重置按钮状态
}, 1000)
我使用时 先插入一个图片
然后再将一大段html通过 pasteHTML放进去
大多时候会成功 不成功时 就是因为这个报错

不好意思刚才问题产生原因描述错了 先插入图 再通过pasteHTML 偶尔会出现 TypeError: Cannot read property 'glyphGroupInfo' of null 这个问题

wps实例已有内容 我删除全部内容 当内容比较多时会出现 type":"edit","name":"edit_blocking","cmd":"deleteTextForSel","cooperCount":1,"isSessionSlow":false,"isCoreTypo":false,"subDocType":0 这个问题 而且这个问题是最近才出现的 删除代码如下
const DocumentRange = await this.instance.Application.ActiveDocument.GetDocumentRange()
const End = await DocumentRange.End - 9
const selection = await this.instance.Application.ActiveDocument.ActiveWindow.Selection
const range = await selection.Range
await range.SetRange(0, End)
await this.instance.Application.ActiveDocument.ActiveWindow.Selection.Delete(1)