mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-30 12:15:16 +01:00
🎨 搜索定位
This commit is contained in:
parent
1b3d9c1d69
commit
860ea7442a
4 changed files with 18 additions and 13 deletions
|
|
@ -187,7 +187,7 @@ export class Search extends Model {
|
|||
mode: foldResponse.data ? 0 : 3,
|
||||
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]);
|
||||
onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_HL, Constants.CB_GET_HTML]);
|
||||
const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`);
|
||||
if (matchElement) {
|
||||
matchElement.scrollIntoView();
|
||||
|
|
@ -196,17 +196,19 @@ export class Search extends Model {
|
|||
} else {
|
||||
this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, {
|
||||
blockId: id,
|
||||
action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],
|
||||
action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML],
|
||||
key: value,
|
||||
render: {
|
||||
gutter: true,
|
||||
breadcrumbDocName: true,
|
||||
},
|
||||
after: () => {
|
||||
const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`);
|
||||
if (matchElement) {
|
||||
matchElement.scrollIntoView();
|
||||
}
|
||||
setTimeout(() => {
|
||||
const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`);
|
||||
if (matchElement) {
|
||||
matchElement.scrollIntoView();
|
||||
}
|
||||
}, Constants.TIMEOUT_SEARCH);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -643,17 +643,19 @@ const getArticle = (options: {
|
|||
if (!protyle) {
|
||||
protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, {
|
||||
blockId: options.id,
|
||||
action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT],
|
||||
action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML],
|
||||
key: options.k,
|
||||
render: {
|
||||
gutter: true,
|
||||
breadcrumbDocName: true
|
||||
},
|
||||
after: () => {
|
||||
const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`);
|
||||
if (matchElement) {
|
||||
matchElement.scrollIntoView();
|
||||
}
|
||||
setTimeout(() => {
|
||||
const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`);
|
||||
if (matchElement) {
|
||||
matchElement.scrollIntoView();
|
||||
}
|
||||
}, Constants.TIMEOUT_SEARCH);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
@ -665,7 +667,7 @@ const getArticle = (options: {
|
|||
mode: foldResponse.data ? 0 : 3,
|
||||
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]);
|
||||
onGet(getResponse, protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_HL, Constants.CB_GET_HTML]);
|
||||
const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`);
|
||||
if (matchElement) {
|
||||
matchElement.scrollIntoView();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue