问
通过doc.Range不断的向文档写入的同时,用户再尾部编辑中文在windows有问题
使用扩展项的方式用下面代码向wps文档不断的写入字符的同时,用户在文档后面输入中文时,中文字会往前面跳。linux系统下正常。请问有具体的解决方案吗?
var doc = window.Application.ActiveDocument
if (!doc) return
var currentText = doc.Range().Text || ''
var marker = "[正在转写...]"
// alert(currentText)
var insertPos = currentText.indexOf(marker)
// 若存在 "[正在转写...]" 标记,则在其前面写入;否则追加到文档末尾
if (insertPos === -1) {
insertPos = currentText.length
}
// Application.ScreenUpdating = false
doc.Range(insertPos, insertPos).InsertAfter(text)