tijiao
This commit is contained in:
@@ -1058,6 +1058,9 @@ export default {
|
||||
.join(','); // 以逗号连接索引
|
||||
|
||||
return emptyContentIndexes;
|
||||
},
|
||||
escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
},
|
||||
highlightText(text, annotations) {
|
||||
if (!this.isPreview) {
|
||||
@@ -1069,8 +1072,9 @@ export default {
|
||||
if (annotation.content == '') {
|
||||
return tempText;
|
||||
}
|
||||
const escapedContent = this.escapeRegExp(annotation.content); // 转义正则表达式中的特殊字符
|
||||
const placeholder = `{{remark_placeholder_${index}}}`; // 占位符
|
||||
const regExp = new RegExp(`(${annotation.content})`, 'gi'); // 全局匹配批注内容
|
||||
const regExp = new RegExp(`(${escapedContent})`, 'gi'); // 全局匹配批注内容
|
||||
|
||||
// 如果批注内容存在,替换成占位符
|
||||
if (tempText.includes(annotation.content)) {
|
||||
@@ -1105,7 +1109,6 @@ export default {
|
||||
</span>
|
||||
`;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 3. 返回处理后的文本
|
||||
@@ -1115,6 +1118,7 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getCommentsData() {
|
||||
if (!this.isPreview) {
|
||||
this.clearHighlight();
|
||||
|
||||
Reference in New Issue
Block a user