mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-28 20:38:49 +01:00
This commit is contained in:
parent
81950fa52d
commit
cee6d444d7
1 changed files with 16 additions and 6 deletions
|
|
@ -1105,15 +1105,25 @@ export const getArticle = (options: {
|
|||
const contentRect = options.edit.protyle.contentElement.getBoundingClientRect();
|
||||
if (isSupportCSSHL()) {
|
||||
searchMarkRender(options.edit.protyle, getResponse.data.keywords, options.id, () => {
|
||||
if (options.edit.protyle.highlight.ranges.length > 0 && options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex]) {
|
||||
if (!options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex].toString()) {
|
||||
highlightById(options.edit.protyle, options.id);
|
||||
const highlightKeys = () => {
|
||||
if (options.edit.protyle.highlight.ranges.length > 0 && options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex]) {
|
||||
if (!options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex].toString()) {
|
||||
highlightById(options.edit.protyle, options.id);
|
||||
} else {
|
||||
options.edit.protyle.contentElement.scrollTop = options.edit.protyle.contentElement.scrollTop + options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex].getBoundingClientRect().top - contentRect.top - contentRect.height / 2;
|
||||
}
|
||||
} else {
|
||||
options.edit.protyle.contentElement.scrollTop = options.edit.protyle.contentElement.scrollTop + options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex].getBoundingClientRect().top - contentRect.top - contentRect.height / 2;
|
||||
highlightById(options.edit.protyle, options.id);
|
||||
}
|
||||
} else {
|
||||
highlightById(options.edit.protyle, options.id);
|
||||
}
|
||||
highlightKeys();
|
||||
const observer = new ResizeObserver(() => {
|
||||
highlightKeys();
|
||||
});
|
||||
observer.observe(options.edit.protyle.wysiwyg.element);
|
||||
setTimeout(() => {
|
||||
observer.disconnect();
|
||||
}, Constants.TIMEOUT_COUNT);
|
||||
});
|
||||
} else {
|
||||
const matchElements = options.edit.protyle.wysiwyg.element.querySelectorAll('span[data-type~="search-mark"]');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue