Skip to content

Commit

Permalink
改进在代码块内搜索文本 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
TCOTC committed Mar 29, 2024
1 parent 3a3b6c1 commit 3af8d16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "siyuan-plugin-hsr-mdzz2048-fork",
"author": "TCOTC",
"url": "https://github.com/TCOTC/siyuan-plugin-hsr-mdzz2048-fork",
"version": "0.3.3",
"version": "0.3.4",
"minAppVersion": "2.9.8",
"backends": ["windows", "linux", "darwin"],
"frontends": ["desktop", "browser-desktop"],
Expand Down
7 changes: 5 additions & 2 deletions src/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,11 @@ function highlightHitResult(value: string, change: boolean) { // 搜索并高亮
function scroollIntoRanges(index: number) {
const ranges = resultRange.value as Range[]
const range = ranges[index]
const parent = range.commonAncestorContainer.parentElement
parent.scrollIntoView({ behavior: 'smooth', block: "center" })
// const parent = range.commonAncestorContainer.parentElement
// parent.scrollIntoView({ behavior: 'smooth', block: "center" })
// 改为获取range元素本身
const rangeElement = range.parentElement
rangeElement.scrollIntoView({ behavior: 'smooth', block: "center" })
CSS.highlights.set("search-focus", new Highlight(range))
}
Expand Down

0 comments on commit 3af8d16

Please sign in to comment.