@rspress-theme-anatole/theme-default 0.7.56 → 0.7.57
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/dist/bundle.js +127 -43
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -324,6 +324,7 @@ function useLocaleSiteData() {
|
|
|
324
324
|
nextPageText: themeConfig.nextPageText,
|
|
325
325
|
sourceCodeText: themeConfig.sourceCodeText,
|
|
326
326
|
searchPlaceholderText: themeConfig.searchPlaceholderText,
|
|
327
|
+
searchDidYouMeanText: themeConfig.searchDidYouMeanText,
|
|
327
328
|
searchNoResultsText: themeConfig.searchNoResultsText,
|
|
328
329
|
searchSuggestedQueryText: themeConfig.searchSuggestedQueryText,
|
|
329
330
|
overview: themeConfig.overview
|
|
@@ -412,6 +413,13 @@ function markLockedSidebarItems(items, userContext) {
|
|
|
412
413
|
if ('items' in item && Array.isArray(item.items)) {
|
|
413
414
|
const markedItems = markLockedSidebarItems(item.items, userContext);
|
|
414
415
|
nextItem = { ...nextItem, items: markedItems };
|
|
416
|
+
// If group has no direct lock but all navigable children are locked, propagate lock upward
|
|
417
|
+
if (!locked && !nextItem.locked && 'items' in nextItem && nextItem.items.length > 0) {
|
|
418
|
+
const navigableChildren = nextItem.items.filter(child => child && !('dividerType' in child));
|
|
419
|
+
if (navigableChildren.length > 0 && navigableChildren.every(child => child.locked === true)) {
|
|
420
|
+
nextItem = { ...nextItem, locked: true };
|
|
421
|
+
}
|
|
422
|
+
}
|
|
415
423
|
}
|
|
416
424
|
return nextItem;
|
|
417
425
|
}).filter(Boolean);
|
|
@@ -6576,11 +6584,37 @@ function SuggestItem({ suggestion, query, closeSearch, isCurrent, setCurrentSugg
|
|
|
6576
6584
|
});
|
|
6577
6585
|
};
|
|
6578
6586
|
|
|
6587
|
+
const SUGGESTION_PREFIX_TOKEN = '__KB_SUGGESTION__';
|
|
6588
|
+
const SUGGESTION_SUFFIX_TOKEN = '__KB_SUGGESTION_END__';
|
|
6589
|
+
const parseGatewaySuggestion = (statement) => {
|
|
6590
|
+
if (!statement || 'string' != typeof statement) return {
|
|
6591
|
+
suggestionText: '',
|
|
6592
|
+
statementText: statement || ''
|
|
6593
|
+
};
|
|
6594
|
+
const prefixIndex = statement.indexOf(SUGGESTION_PREFIX_TOKEN);
|
|
6595
|
+
if (prefixIndex < 0) return {
|
|
6596
|
+
suggestionText: '',
|
|
6597
|
+
statementText: statement
|
|
6598
|
+
};
|
|
6599
|
+
const contentStart = prefixIndex + SUGGESTION_PREFIX_TOKEN.length;
|
|
6600
|
+
const suffixIndex = statement.indexOf(SUGGESTION_SUFFIX_TOKEN, contentStart);
|
|
6601
|
+
if (suffixIndex < 0) return {
|
|
6602
|
+
suggestionText: '',
|
|
6603
|
+
statementText: statement
|
|
6604
|
+
};
|
|
6605
|
+
const suggestionText = statement.slice(contentStart, suffixIndex).trim();
|
|
6606
|
+
const statementText = (statement.slice(0, prefixIndex) + ' ' + statement.slice(suffixIndex + SUGGESTION_SUFFIX_TOKEN.length)).trim();
|
|
6607
|
+
return {
|
|
6608
|
+
suggestionText,
|
|
6609
|
+
statementText
|
|
6610
|
+
};
|
|
6611
|
+
};
|
|
6579
6612
|
const renderStatementMatch = () => {
|
|
6580
6613
|
if ('content' !== suggestion.type) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {});
|
|
6614
|
+
const parsed = parseGatewaySuggestion(suggestion.statement || '');
|
|
6581
6615
|
return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
6582
6616
|
className: "text-sm text-gray-light w-full",
|
|
6583
|
-
children: getHighlightedFragments(suggestion.statement)
|
|
6617
|
+
children: getHighlightedFragments(parsed.statementText || suggestion.statement || '')
|
|
6584
6618
|
});
|
|
6585
6619
|
};
|
|
6586
6620
|
const renderLink = () => {
|
|
@@ -6722,7 +6756,10 @@ const SEARCH_PREWARM_EVENT = 'rspress-search-prewarm';
|
|
|
6722
6756
|
const useDebounce = (cb) => {
|
|
6723
6757
|
const cbRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(cb);
|
|
6724
6758
|
cbRef.current = cb;
|
|
6725
|
-
|
|
6759
|
+
// 300ms debounce: only fire after the user stops typing for 300ms.
|
|
6760
|
+
const debounced = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((0, __WEBPACK_EXTERNAL_MODULE_lodash_es_18c59938__.debounce)((...args) => cbRef.current(...args), 300), []);
|
|
6761
|
+
// Cancel any pending debounced call on unmount to prevent stale gateway requests.
|
|
6762
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => () => debounced.cancel(), [debounced]);
|
|
6726
6763
|
return debounced;
|
|
6727
6764
|
};
|
|
6728
6765
|
function SearchPanel({ focused, setFocused }) {
|
|
@@ -6757,7 +6794,7 @@ function SearchPanel({ focused, setFocused }) {
|
|
|
6757
6794
|
}
|
|
6758
6795
|
};
|
|
6759
6796
|
const { siteData, page: { lang, version, frontmatter, routePath } } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)();
|
|
6760
|
-
const { searchPlaceholderText = 'Search Docs', scopedSearchPrefixText = 'Search in', searchingText = 'Searching...' } = useLocaleSiteData();
|
|
6797
|
+
const { searchPlaceholderText = 'Search Docs', searchDidYouMeanText = 'Did you mean', scopedSearchPrefixText = 'Search in', searchingText = 'Searching...' } = useLocaleSiteData();
|
|
6761
6798
|
const { search, title: siteTitle, base } = siteData;
|
|
6762
6799
|
const versionedSearch = search && 'remote' !== search.mode && search.versioned;
|
|
6763
6800
|
const DEFAULT_RESULT = [
|
|
@@ -7153,12 +7190,7 @@ function SearchPanel({ focused, setFocused }) {
|
|
|
7153
7190
|
|
|
7154
7191
|
if (defaultSearchResult) localResult.push(...defaultSearchResult);
|
|
7155
7192
|
|
|
7156
|
-
//
|
|
7157
|
-
if ('onSearch' in __WEBPACK_EXTERNAL_MODULE_virtual_search_hooks_9d01d01f__) {
|
|
7158
|
-
const key = 'onSearch';
|
|
7159
|
-
await __WEBPACK_EXTERNAL_MODULE_virtual_search_hooks_9d01d01f__[key](newQuery, localResult, searchScope);
|
|
7160
|
-
}
|
|
7161
|
-
|
|
7193
|
+
// Keep a single onSearch invocation per debounced query.
|
|
7162
7194
|
if ('afterSearch' in __WEBPACK_EXTERNAL_MODULE_virtual_search_hooks_9d01d01f__) {
|
|
7163
7195
|
const key = 'afterSearch';
|
|
7164
7196
|
await __WEBPACK_EXTERNAL_MODULE_virtual_search_hooks_9d01d01f__[key](newQuery, localResult);
|
|
@@ -7210,6 +7242,44 @@ function SearchPanel({ focused, setFocused }) {
|
|
|
7210
7242
|
}, item.group))
|
|
7211
7243
|
});
|
|
7212
7244
|
};
|
|
7245
|
+
const SUGGESTION_PREFIX_TOKEN = '__KB_SUGGESTION__';
|
|
7246
|
+
const SUGGESTION_SUFFIX_TOKEN = '__KB_SUGGESTION_END__';
|
|
7247
|
+
const parseGatewaySuggestion = (statement) => {
|
|
7248
|
+
if (!statement || 'string' != typeof statement) return {
|
|
7249
|
+
suggestionText: '',
|
|
7250
|
+
statementText: statement || ''
|
|
7251
|
+
};
|
|
7252
|
+
const prefixIndex = statement.indexOf(SUGGESTION_PREFIX_TOKEN);
|
|
7253
|
+
if (prefixIndex < 0) return {
|
|
7254
|
+
suggestionText: '',
|
|
7255
|
+
statementText: statement
|
|
7256
|
+
};
|
|
7257
|
+
const contentStart = prefixIndex + SUGGESTION_PREFIX_TOKEN.length;
|
|
7258
|
+
const suffixIndex = statement.indexOf(SUGGESTION_SUFFIX_TOKEN, contentStart);
|
|
7259
|
+
if (suffixIndex < 0) return {
|
|
7260
|
+
suggestionText: '',
|
|
7261
|
+
statementText: statement
|
|
7262
|
+
};
|
|
7263
|
+
const suggestionText = statement.slice(contentStart, suffixIndex).trim();
|
|
7264
|
+
const statementText = (statement.slice(0, prefixIndex) + ' ' + statement.slice(suffixIndex + SUGGESTION_SUFFIX_TOKEN.length)).trim();
|
|
7265
|
+
return {
|
|
7266
|
+
suggestionText,
|
|
7267
|
+
statementText
|
|
7268
|
+
};
|
|
7269
|
+
};
|
|
7270
|
+
const extractSuggestionText = (suggestions) => {
|
|
7271
|
+
for (const item of suggestions || []) {
|
|
7272
|
+
if ('content' !== item?.type) continue;
|
|
7273
|
+
const parsed = parseGatewaySuggestion(item.statement || '');
|
|
7274
|
+
if (parsed.suggestionText) return parsed.suggestionText;
|
|
7275
|
+
}
|
|
7276
|
+
return '';
|
|
7277
|
+
};
|
|
7278
|
+
const getGatewaySuggestionText = () => {
|
|
7279
|
+
if ('undefined' == typeof window) return '';
|
|
7280
|
+
const suggestion = window.__KB_GATEWAY_SUGGESTION__;
|
|
7281
|
+
return 'string' == typeof suggestion ? suggestion.trim() : '';
|
|
7282
|
+
};
|
|
7213
7283
|
const renderSearchResultItem = (suggestionList, query, isSearching) => {
|
|
7214
7284
|
if (isSearching) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
7215
7285
|
className: "flex flex-col items-center",
|
|
@@ -7227,43 +7297,57 @@ function SearchPanel({ focused, setFocused }) {
|
|
|
7227
7297
|
if (0 === suggestionList.length && 'inited' === initStatus) return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(NoSearchResult, {
|
|
7228
7298
|
query: query
|
|
7229
7299
|
});
|
|
7300
|
+
const suggestionText = getGatewaySuggestionText();
|
|
7230
7301
|
const normalizedSuggestions = normalizeSuggestions(suggestionList);
|
|
7231
7302
|
let accumulateIndex = -1;
|
|
7232
|
-
return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7303
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
|
|
7304
|
+
children: [
|
|
7305
|
+
suggestionText ? (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
|
|
7306
|
+
className: "kb-search-suggestion-banner",
|
|
7307
|
+
children: [
|
|
7308
|
+
searchDidYouMeanText,
|
|
7309
|
+
" \"",
|
|
7310
|
+
suggestionText,
|
|
7311
|
+
"\"?"
|
|
7312
|
+
]
|
|
7313
|
+
}) : null,
|
|
7314
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", {
|
|
7315
|
+
className: Search_index_module.suggestList,
|
|
7316
|
+
children: Object.keys(normalizedSuggestions).map((group) => {
|
|
7317
|
+
const groupSuggestions = normalizedSuggestions[group] || [];
|
|
7318
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("li", {
|
|
7319
|
+
children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", {
|
|
7320
|
+
// className: "pb-2",
|
|
7321
|
+
children: groupSuggestions.map((suggestion) => {
|
|
7322
|
+
accumulateIndex++;
|
|
7323
|
+
const suggestionIndex = accumulateIndex;
|
|
7324
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(SuggestItem, {
|
|
7325
|
+
suggestion: suggestion,
|
|
7326
|
+
query: query,
|
|
7327
|
+
isCurrent: suggestionIndex === currentSuggestionIndex,
|
|
7328
|
+
setCurrentSuggestionIndex: (event) => {
|
|
7329
|
+
if (mousePositionRef.current.pageX === event.pageX && mousePositionRef.current.pageY === event.pageY) return;
|
|
7330
|
+
setCanScroll(false);
|
|
7331
|
+
setCurrentSuggestionIndex(suggestionIndex);
|
|
7332
|
+
},
|
|
7333
|
+
onMouseMove: (event) => {
|
|
7334
|
+
mousePositionRef.current = {
|
|
7335
|
+
pageX: event.pageX,
|
|
7336
|
+
pageY: event.pageY
|
|
7337
|
+
};
|
|
7338
|
+
},
|
|
7339
|
+
closeSearch: () => {
|
|
7340
|
+
clearSearchState();
|
|
7341
|
+
},
|
|
7342
|
+
inCurrentDocIndex: 0 === resultTabIndex,
|
|
7343
|
+
scrollTo: scrollTo
|
|
7344
|
+
}, `${suggestion.title}-${suggestionIndex}`);
|
|
7345
|
+
})
|
|
7346
|
+
})
|
|
7347
|
+
}, group);
|
|
7264
7348
|
})
|
|
7265
|
-
}
|
|
7266
|
-
|
|
7349
|
+
})
|
|
7350
|
+
]
|
|
7267
7351
|
});
|
|
7268
7352
|
};
|
|
7269
7353
|
const getScopedPlaceholder = () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress-theme-anatole/theme-default",
|
|
3
3
|
"author": "Anatole Tong",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.57",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.css",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"types": "./dist/bundle.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@mdx-js/react": "2.3.0",
|
|
24
|
-
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.7.
|
|
25
|
-
"@rspress-theme-anatole/shared": "0.7.
|
|
24
|
+
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.7.57",
|
|
25
|
+
"@rspress-theme-anatole/shared": "0.7.57",
|
|
26
26
|
"@rspress/runtime": "1.43.8",
|
|
27
27
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
28
28
|
"copy-to-clipboard": "^3.3.3",
|