Do you want to: Suggest a feature / Report a bug / Ask a how-to question
For feature suggestions, describe the result you would like to achieve in detail:
For bug reports, provide the steps to reproduce and if possible a minimal demo of the problem:
Document Server version:8.3.3
Additional information:
Any relevant details about the situation. You can also attach images and videofile to the post (or to place them to external storage)
您好,
您指的是哪个编辑器?文档编辑器还是表格编辑器?
您目前是如何实现这一操作的?
另外,请更新到最新的 9.0.3 版本并在该版本中检查一下。
用9.0.0.168试了一次,出现了另外的问题。代码如下:
(function () {
window.Asc.plugin.init = function () {
const delBtn = document.querySelector(‘.delete_para’);
delBtn.addEventListener(‘click’, function () {
Asc.plugin.callCommand(function() {
const oDocument = Api.GetDocument()
const allParagraphs = oDocument.GetAllParagraphs();
console.log(allParagraphs.map(p => p.GetText()));
for (let i = allParagraphs.length - 1; i >= 0; i–) {
const paragraph = allParagraphs[i];
const oText = paragraph.GetText();
if (oText.includes(‘【’) || oText.includes(‘】’)) {
paragraph.Delete();
console.log(Deleted paragraph: ${oText});
}
}
console.log(oDocument.GetAllParagraphs().map(p => p.GetText()));
});
});
}
})();
上图左边是删除之前的文本,右边是删除后的结果。
删除"【】"段落之后,单元格中剩余段落消失了,重新获取段落,打印还能看到内容,刷新后隐藏的段落正常渲染。
在8.3.3版本下相同操作会导致文档卡死,将Delete方法换成ReplaceByElement方法替换一个空段落,会出现上述相同问题。
请提供测试时候使用的原文档
Example Document.docx (26.4 KB)
在9.0.0.168下还发现了另一个问题,使用如下文档:
new.docx (26.0 KB)
Asc.plugin.callCommand(function() {
const oDocument = Api.GetDocument()
const oRange = oDocument.GetRangeBySelect();
const bookmarks = oDocument.GetAllBookmarksNames();
for (let i = 0; i < bookmarks.length; i++) {
const iRange = oDocument.GetBookmarkRange(bookmarks[i]);
const range = oRange.IntersectWith(iRange)
console.log(range)
}
});
使用IntersectWith这个API报错,看源码发现这块有空指针:
您好,
不好意思回复晚了。
我们把问题拆开来讨论,每个话题只讨论一个问题,其他问题请单独提出。
其次,我们只为最新版本(9.0.4)提供技术支持,请您先更新到该版本并检查这些问题是否仍然能重现。
关于最初的问题,请您提供完整的插件(包括 code.js、index.html 等)以便进行测试 - 如果在最新版本中该问题仍然存在。

