diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index cf5812e71..b3ca26b36 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -180,10 +180,10 @@ class Protyle { }); } }); + if (mergedOptions.after) { + mergedOptions.after(this); + } }); - if (mergedOptions.after) { - mergedOptions.after(this); - } } public reload() { diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts index c40731b44..fe6d7c4d8 100644 --- a/app/src/search/spread.ts +++ b/app/src/search/spread.ts @@ -663,6 +663,9 @@ const getArticle = (options: { gutter: true, breadcrumbDocName: true }, + after: (protyle) => { + protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`).scrollIntoView(); + } }); } else { protyle.protyle.scroll.lastScrollTop = 0; @@ -674,6 +677,7 @@ const getArticle = (options: { size: options.folded ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, }, getResponse => { onGet(getResponse, protyle.protyle, options.folded ? [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(); }); } };