This commit is contained in:
Vanessa 2022-06-27 23:17:10 +08:00
parent e1b45b40e5
commit 1d1f46892f
3 changed files with 30 additions and 15 deletions

View file

@ -189,7 +189,10 @@ export class Search extends Model {
size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,
}, getResponse => {
onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);
this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`).scrollIntoView();
const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`)
if (matchElement) {
matchElement.scrollIntoView();
}
});
} else {
this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, {
@ -201,7 +204,10 @@ export class Search extends Model {
breadcrumbDocName: true,
},
after: () => {
this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`).scrollIntoView();
const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`)
if (matchElement) {
matchElement.scrollIntoView();
}
}
});
}

View file

@ -648,7 +648,10 @@ const getArticle = (options: {
breadcrumbDocName: true
},
after: () => {
protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`).scrollIntoView();
const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`)
if (matchElement) {
matchElement.scrollIntoView();
}
}
});
} else {
@ -661,7 +664,10 @@ const getArticle = (options: {
size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,
}, getResponse => {
onGet(getResponse, protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL]);
protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`).scrollIntoView();
const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`)
if (matchElement) {
matchElement.scrollIntoView();
}
});
}
});