tijiao
This commit is contained in:
@@ -1059,6 +1059,9 @@ export default {
|
||||
|
||||
return emptyContentIndexes;
|
||||
},
|
||||
escapeRegExp(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
},
|
||||
highlightText(text, annotations) {
|
||||
if (!this.isPreview) {
|
||||
let tempText = text;
|
||||
@@ -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)) {
|
||||
@@ -1104,8 +1108,7 @@ export default {
|
||||
</span>
|
||||
</span>
|
||||
`;
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// 3. 返回处理后的文本
|
||||
@@ -1113,7 +1116,8 @@ export default {
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
getCommentsData() {
|
||||
if (!this.isPreview) {
|
||||
|
||||
Reference in New Issue
Block a user