From 7f2d191c6720e2f034d3cc92027bea5f66e90c8e Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 3 May 2023 00:11:28 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/8152 --- app/src/asset/anno.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/asset/anno.ts b/app/src/asset/anno.ts index 35423eb3d..e3639b7d3 100644 --- a/app/src/asset/anno.ts +++ b/app/src/asset/anno.ts @@ -320,11 +320,14 @@ const getHightlightCoordsByRange = (pdf: any, color: string) => { if (item.tagName === "BR" && item.previousElementSibling && item.nextElementSibling) { const previousText = item.previousElementSibling.textContent; const nextText = item.nextElementSibling.textContent; - if (previousText.endsWith("-") && /^[A-Za-z]$/.test(previousText.substring(previousText.length - 2, previousText.length - 1)) && + if (/^[A-Za-z]$/.test(previousText.substring(previousText.length - 2, previousText.length - 1)) && /^[A-Za-z]$/.test(nextText.substring(0, 1))) { - item.previousElementSibling.textContent = previousText.substring(0, previousText.length - 1); - } else { - item.insertAdjacentText("afterend", " "); + if (previousText.endsWith("-")) { + item.previousElementSibling.textContent = previousText.substring(0, previousText.length - 1); + } else { + // 中文情况不能添加 https://github.com/siyuan-note/siyuan/issues/8152 + item.insertAdjacentText("afterend", " "); + } } } });