@easyops-cn/docusaurus-search-local 0.48.1 → 0.48.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [0.48.3](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.48.2...v0.48.3) (2025-01-16)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * sync ssr the input value and focus state for SSR ([be7c125](https://github.com/easyops-cn/docusaurus-search-local/commit/be7c125d72f7274eabc8d377809cddfd85fb1db1))
11
+
12
+ ## [0.48.2](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.48.1...v0.48.2) (2025-01-16)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * excludes mobile toc button for search marks, fixes [#473](https://github.com/easyops-cn/docusaurus-search-local/issues/473) ([b8dd155](https://github.com/easyops-cn/docusaurus-search-local/commit/b8dd15559f22b7f914af8123ed7eaa60c0beac3b))
18
+
5
19
  ## [0.48.1](https://github.com/easyops-cn/docusaurus-search-local/compare/v0.48.0...v0.48.1) (2025-01-16)
6
20
 
7
21
 
@@ -255,7 +255,9 @@ export default function SearchBar({ handleSearchBarToggle, }) {
255
255
  const mark = new Mark(root);
256
256
  mark.unmark();
257
257
  if (keywords.length !== 0) {
258
- mark.mark(keywords);
258
+ mark.mark(keywords, {
259
+ exclude: [".theme-doc-toc-mobile > button"],
260
+ });
259
261
  }
260
262
  // Apply any keywords to the search input so that we can clear marks in case we loaded a page with a highlight in the url
261
263
  setInputValue(keywords.join(" "));
@@ -286,6 +288,23 @@ export default function SearchBar({ handleSearchBarToggle, }) {
286
288
  const isMac = isBrowser
287
289
  ? /mac/i.test(navigator.userAgentData?.platform ?? navigator.platform)
288
290
  : false;
291
+ // Sync the input value and focus state for SSR
292
+ useEffect(() => {
293
+ const searchBar = searchBarRef.current;
294
+ const domValue = searchBar?.value;
295
+ if (domValue) {
296
+ setInputValue(domValue);
297
+ }
298
+ if (searchBar && document.activeElement === searchBar) {
299
+ focusAfterIndexLoaded.current = true;
300
+ loadIndex();
301
+ setFocused(true);
302
+ handleSearchBarToggle?.(true);
303
+ }
304
+ },
305
+ // Only run this effect on mount
306
+ // eslint-disable-next-line react-hooks/exhaustive-deps
307
+ []);
289
308
  useEffect(() => {
290
309
  if (!searchBarShortcut) {
291
310
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyops-cn/docusaurus-search-local",
3
- "version": "0.48.1",
3
+ "version": "0.48.3",
4
4
  "description": "An offline/local search plugin for Docusaurus v3",
5
5
  "repository": {
6
6
  "type": "git",