Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/5213

Vanessa62cbcf63e5a2
diff --git a/app/src/asset/anno.ts b/app/src/asset/anno.ts
index a917ecd6f5..da5943f358 100644
--- a/app/src/asset/anno.ts
+++ b/app/src/asset/anno.ts
@@ -383,7 +383,19 @@ const getHightlightCoordsByRange = (pdf: any, color: string) => {
return;
}
const endIndex = parseInt(endPageElement.getAttribute("data-page-number")) - 1;
- const content = Lute.EscapeHTMLStr(range.toString());
+ // https://github.com/siyuan-note/siyuan/issues/5213
+ const rangeContents = range.cloneContents()
+ Array.from(rangeContents.children).forEach(item => {
+ if (item.tagName === "BR") {
+ const previousText = item.previousElementSibling.textContent
+ if (previousText.endsWith("-")) {
+ item.previousElementSibling.textContent = previousText.substring(0, previousText.length - 1)
+ } else {
+ item.insertAdjacentText("afterend", " ");
+ }
+ }
+ });
+ const content = Lute.EscapeHTMLStr(rangeContents.textContent);
const startPage = pdf.pdfViewer.getPageView(startIndex);
const startPageRect = startPage.canvas.getClientRects()[0];