一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
43 行
1.3 KiB
TypeScript
43 行
1.3 KiB
TypeScript
// Platform-agnostic text helpers for config search (desktop + mobile).
|
|
export const normalizeQuery = (query: string): string => {
|
|
return query.trim().toLowerCase();
|
|
};
|
|
|
|
export const hasNormalizedQuery = (query: string): boolean => {
|
|
return !!normalizeQuery(query);
|
|
};
|
|
|
|
export const toSearchText = (input: string|string[]|null|undefined): string => {
|
|
if (Array.isArray(input)) return input.join('\n');
|
|
if (typeof input === 'string') return input;
|
|
return '';
|
|
};
|
|
|
|
export const equalsNormalizedQuery = (query: string, value: string): boolean => {
|
|
const normalizedQuery = normalizeQuery(query);
|
|
if (!normalizedQuery) return false;
|
|
|
|
return normalizeQuery(value) === normalizedQuery;
|
|
};
|
|
|
|
export const includesNormalizedQuery = (query: string, value: string): boolean => {
|
|
const normalizedQuery = normalizeQuery(query);
|
|
if (!normalizedQuery) return false;
|
|
|
|
return normalizeQuery(value).includes(normalizedQuery);
|
|
};
|
|
|
|
// Shared visibility predicate used by UI integration layers.
|
|
export const shouldShowBySearch = (
|
|
query: string,
|
|
sectionTitle: string,
|
|
relatedText: string|string[]|null|undefined,
|
|
): boolean => {
|
|
if (!hasNormalizedQuery(query)) return false;
|
|
|
|
return (
|
|
includesNormalizedQuery(query, sectionTitle)
|
|
|| includesNormalizedQuery(query, toSearchText(relatedText))
|
|
);
|
|
};
|