Skip to content

Commit

Permalink
Merge branch 'dev' into pr/accessibility/editor/announce-formatting-c…
Browse files Browse the repository at this point in the history
…hanges
  • Loading branch information
personalizedrefrigerator authored Nov 26, 2024
2 parents 03e57d3 + 13f71e7 commit 8817721
Show file tree
Hide file tree
Showing 11 changed files with 6,181 additions and 63 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Please see the [donation page](https://github.com/laurent22/joplin/blob/dev/read
# Sponsors

<!-- SPONSORS-ORG -->
<a href="https://seirei.ne.jp"><img title="Serei Network" width="256" src="https://joplinapp.org/images/sponsors/SeireiNetwork.png"/></a> <a href="https://www.hosting.de/nextcloud/?mtm_campaign=managed-nextcloud&amp;mtm_kwd=joplinapp&amp;mtm_source=joplinapp-webseite&amp;mtm_medium=banner"><img title="Hosting.de" width="256" src="https://joplinapp.org/images/sponsors/HostingDe.png"/></a> <a href="https://citricsheep.com"><img title="Citric Sheep" width="256" src="https://joplinapp.org/images/sponsors/CitricSheep.png"/></a> <a href="https://sorted.travel/?utm_source=joplinapp"><img title="Sorted Travel" width="256" src="https://joplinapp.org/images/sponsors/SortedTravel.png"/></a> <a href="https://celebian.com"><img title="Celebian" width="256" src="https://joplinapp.org/images/sponsors/Celebian.png"/></a> <a href="https://bestkru.com"><img title="BestKru" width="256" src="https://joplinapp.org/images/sponsors/BestKru.png"/></a> <a href="https://www.socialfollowers.uk/buy-tiktok-followers/"><img title="Social Followers" width="256" src="https://joplinapp.org/images/sponsors/SocialFollowers.png"/></a> <a href="https://stormlikes.com/"><img title="Stormlikes" width="256" src="https://joplinapp.org/images/sponsors/Stormlikes.png"/></a> <a href="https://route4me.com"><img title="Route4Me" width="256" src="https://joplinapp.org/images/sponsors/Route4Me.png"/></a> <a href="https://buyyoutubviews.com"><img title="BYTV" width="256" src="https://joplinapp.org/images/sponsors/BYTV.png"/></a> <a href="https://www.famegear.com"><img title="Famegear" width="256" src="https://joplinapp.org/images/sponsors/Famegear.png"/></a> <a href="https://casinoreviews.net"><img title="Casino Reviews" width="256" src="https://joplinapp.org/images/sponsors/CasinoReviews.png"/></a> <a href="https://useviral.com.br/"><img title="Comprar seguidores Instagram" width="256" src="https://joplinapp.org/images/sponsors/Useviral.png"/></a>
<a href="https://seirei.ne.jp"><img title="Serei Network" width="256" src="https://joplinapp.org/images/sponsors/SeireiNetwork.png"/></a> <a href="https://www.hosting.de/nextcloud/?mtm_campaign=managed-nextcloud&amp;mtm_kwd=joplinapp&amp;mtm_source=joplinapp-webseite&amp;mtm_medium=banner"><img title="Hosting.de" width="256" src="https://joplinapp.org/images/sponsors/HostingDe.png"/></a> <a href="https://citricsheep.com"><img title="Citric Sheep" width="256" src="https://joplinapp.org/images/sponsors/CitricSheep.png"/></a> <a href="https://sorted.travel/?utm_source=joplinapp"><img title="Sorted Travel" width="256" src="https://joplinapp.org/images/sponsors/SortedTravel.png"/></a> <a href="https://celebian.com"><img title="Celebian" width="256" src="https://joplinapp.org/images/sponsors/Celebian.png"/></a> <a href="https://bestkru.com"><img title="BestKru" width="256" src="https://joplinapp.org/images/sponsors/BestKru.png"/></a> <a href="https://www.socialfollowers.uk/buy-tiktok-followers/"><img title="Social Followers" width="256" src="https://joplinapp.org/images/sponsors/SocialFollowers.png"/></a> <a href="https://stormlikes.com/"><img title="Stormlikes" width="256" src="https://joplinapp.org/images/sponsors/Stormlikes.png"/></a> <a href="https://route4me.com"><img title="Route4Me" width="256" src="https://joplinapp.org/images/sponsors/Route4Me.png"/></a> <a href="https://buyyoutubviews.com"><img title="BYTV" width="256" src="https://joplinapp.org/images/sponsors/BYTV.png"/></a> <a href="https://casinoreviews.net"><img title="Casino Reviews" width="256" src="https://joplinapp.org/images/sponsors/CasinoReviews.png"/></a> <a href="https://useviral.com.br/"><img title="Comprar seguidores Instagram" width="256" src="https://joplinapp.org/images/sponsors/Useviral.png"/></a>
<!-- SPONSORS-ORG -->

* * *
Expand All @@ -40,11 +40,9 @@ Please see the [donation page](https://github.com/laurent22/joplin/blob/dev/read
| | | | |
| :---: | :---: | :---: | :---: |
| <img width="50" src="https://avatars2.githubusercontent.com/u/97193607?s=96&v=4"/></br>[Akhil-CM](https://github.com/Akhil-CM) | <img width="50" src="https://avatars2.githubusercontent.com/u/552452?s=96&v=4"/></br>[andypiper](https://github.com/andypiper) | <img width="50" src="https://avatars2.githubusercontent.com/u/215668?s=96&v=4"/></br>[avanderberg](https://github.com/avanderberg) | <img width="50" src="https://avatars2.githubusercontent.com/u/67130?s=96&v=4"/></br>[chr15m](https://github.com/chr15m) |
| <img width="50" src="https://avatars2.githubusercontent.com/u/2793530?s=96&v=4"/></br>[CyberXZT](https://github.com/CyberXZT) | <img width="50" src="https://avatars2.githubusercontent.com/u/1307332?s=96&v=4"/></br>[dbrandonjohnson](https://github.com/dbrandonjohnson) | <img width="50" src="https://avatars2.githubusercontent.com/u/14873877?s=96&v=4"/></br>[dchecks](https://github.com/dchecks) | <img width="50" src="https://avatars2.githubusercontent.com/u/56287?s=96&v=4"/></br>[fats](https://github.com/fats) |
| <img width="50" src="https://avatars2.githubusercontent.com/u/8030470?s=96&v=4"/></br>[Galliver7](https://github.com/Galliver7) | <img width="50" src="https://avatars2.githubusercontent.com/u/64712218?s=96&v=4"/></br>[Hegghammer](https://github.com/Hegghammer) | <img width="50" src="https://avatars2.githubusercontent.com/u/2583421?s=96&v=4"/></br>[jamesandariese](https://github.com/jamesandariese) | <img width="50" src="https://avatars2.githubusercontent.com/u/1310474?s=96&v=4"/></br>[jknowles](https://github.com/jknowles) |
| <img width="50" src="https://avatars2.githubusercontent.com/u/11947658?s=96&v=4"/></br>[KentBrockman](https://github.com/KentBrockman) | <img width="50" src="https://avatars2.githubusercontent.com/u/24908652?s=96&v=4"/></br>[konishi-t](https://github.com/konishi-t) | <img width="50" src="https://avatars2.githubusercontent.com/u/42319182?s=96&v=4"/></br>[marcdw1289](https://github.com/marcdw1289) | <img width="50" src="https://avatars2.githubusercontent.com/u/126279083?s=96&v=4"/></br>[matmoly](https://github.com/matmoly) |
| <img width="50" src="https://avatars2.githubusercontent.com/u/1788010?s=96&v=4"/></br>[maxtruxa](https://github.com/maxtruxa) | <img width="50" src="https://avatars2.githubusercontent.com/u/4560672?s=96&v=4"/></br>[mu88](https://github.com/mu88) | <img width="50" src="https://avatars2.githubusercontent.com/u/31054972?s=96&v=4"/></br>[saarantras](https://github.com/saarantras) | <img width="50" src="https://avatars2.githubusercontent.com/u/327998?s=96&v=4"/></br>[sif](https://github.com/sif) |
| <img width="50" src="https://avatars2.githubusercontent.com/u/765564?s=96&v=4"/></br>[taskcruncher](https://github.com/taskcruncher) | <img width="50" src="https://avatars2.githubusercontent.com/u/333944?s=96&v=4"/></br>[tateisu](https://github.com/tateisu) | | |
| <img width="50" src="https://avatars2.githubusercontent.com/u/8030470?s=96&v=4"/></br>[Galliver7](https://github.com/Galliver7) | <img width="50" src="https://avatars2.githubusercontent.com/u/64712218?s=96&v=4"/></br>[Hegghammer](https://github.com/Hegghammer) | <img width="50" src="https://avatars2.githubusercontent.com/u/11947658?s=96&v=4"/></br>[KentBrockman](https://github.com/KentBrockman) | <img width="50" src="https://avatars2.githubusercontent.com/u/42319182?s=96&v=4"/></br>[marcdw1289](https://github.com/marcdw1289) |
| <img width="50" src="https://avatars2.githubusercontent.com/u/126279083?s=96&v=4"/></br>[matmoly](https://github.com/matmoly) | <img width="50" src="https://avatars2.githubusercontent.com/u/1788010?s=96&v=4"/></br>[maxtruxa](https://github.com/maxtruxa) | <img width="50" src="https://avatars2.githubusercontent.com/u/327998?s=96&v=4"/></br>[sif](https://github.com/sif) | <img width="50" src="https://avatars2.githubusercontent.com/u/765564?s=96&v=4"/></br>[taskcruncher](https://github.com/taskcruncher) |
| | | | |
<!-- SPONSORS-GITHUB -->

# Community
Expand Down
20 changes: 13 additions & 7 deletions packages/app-desktop/plugins/GotoAnything.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Folder from '@joplin/lib/models/Folder';
import Note from '@joplin/lib/models/Note';
import ItemList from '../gui/ItemList';
import HelpButton from '../gui/HelpButton';
import { surroundKeywords, nextWhitespaceIndex, removeDiacritics } from '@joplin/lib/string-utils';
import { surroundKeywords, nextWhitespaceIndex, removeDiacritics, escapeRegExp, KeywordType } from '@joplin/lib/string-utils';
import { mergeOverlappingIntervals } from '@joplin/lib/ArrayUtils';
import markupLanguageUtils from '@joplin/lib/utils/markupLanguageUtils';
import focusEditorIfEditorCommand from '@joplin/lib/services/commands/focusEditorIfEditorCommand';
Expand Down Expand Up @@ -56,7 +56,7 @@ interface State {
query: string;
results: GotoAnythingSearchResult[];
selectedItemId: string;
keywords: string[];
keywords: (string | ComplexTerm)[];
listType: number;
showHelp: boolean;
resultsInBody: boolean;
Expand Down Expand Up @@ -376,9 +376,15 @@ class DialogComponent extends React.PureComponent<Props, State> {
results = results.filter(r => !!notesById[r.id])
.map(r => ({ ...r, title: notesById[r.id].title }));

const normalizedKeywords = (await this.keywords(searchQuery)).map(
({ valueRegex }: ComplexTerm) => new RegExp(removeDiacritics(valueRegex), 'ig'),
);
const keywordRegexes = (await this.keywords(searchQuery)).map(term => {
if (typeof term === 'string') {
return new RegExp(escapeRegExp(term), 'ig');
} else if (term.valueRegex) {
return new RegExp(removeDiacritics(term.valueRegex), 'ig');
} else {
return new RegExp(escapeRegExp(term.value), 'ig');
}
});

for (let i = 0; i < results.length; i++) {
const row = results[i];
Expand All @@ -393,7 +399,7 @@ class DialogComponent extends React.PureComponent<Props, State> {
const normalizedBody = removeDiacritics(body);

// Iterate over all matches in the body for each search keyword
for (const keywordRegex of normalizedKeywords) {
for (const keywordRegex of keywordRegexes) {
for (const match of normalizedBody.matchAll(keywordRegex)) {
// Populate 'indices' with [begin index, end index] of each note fragment
// Begins at the regex matching index, ends at the next whitespace after seeking 15 characters to the right
Expand Down Expand Up @@ -547,7 +553,7 @@ class DialogComponent extends React.PureComponent<Props, State> {

const wrapKeywordMatches = (unescapedContent: string) => {
return surroundKeywords(
this.state.keywords,
this.state.keywords as KeywordType,
unescapedContent,
`<span class="match-highlight" style="font-weight: bold; color: ${theme.searchMarkerColor}; background-color: ${theme.searchMarkerBackgroundColor}">`,
'</span>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import useQueuedAsyncEffect from '@joplin/lib/hooks/useQueuedAsyncEffect';
import { NoteEntity } from '@joplin/lib/services/database/types';
import SearchEngineUtils from '@joplin/lib/services/search/SearchEngineUtils';
import Note from '@joplin/lib/models/Note';
import SearchEngine from '@joplin/lib/services/search/SearchEngine';
import SearchEngine, { ComplexTerm } from '@joplin/lib/services/search/SearchEngine';
import { ProgressBar } from 'react-native-paper';
import shim from '@joplin/lib/shim';

interface Props {
query: string;
onHighlightedWordsChange: (highlightedWords: string[])=> void;
onHighlightedWordsChange: (highlightedWords: (ComplexTerm | string)[])=> void;

ftsEnabled: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import IconButton from '../../IconButton';
import SearchResults from './SearchResults';
import AccessibleView from '../../accessibility/AccessibleView';
import { ComplexTerm } from '@joplin/lib/services/search/SearchEngine';

interface Props {
themeId: number;
Expand Down Expand Up @@ -73,7 +74,7 @@ const SearchScreenComponent: React.FC<Props> = props => {
setQuery('');
}, []);

const onHighlightedWordsChange = useCallback((words: string[]) => {
const onHighlightedWordsChange = useCallback((words: (ComplexTerm | string)[]) => {
props.dispatch({
type: 'SET_HIGHLIGHTED',
words,
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/BaseApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SyncTargetAmazonS3 = require('./SyncTargetAmazonS3.js');
import EncryptionService from './services/e2ee/EncryptionService';
import ResourceFetcher from './services/ResourceFetcher';
import SearchEngineUtils from './services/search/SearchEngineUtils';
import SearchEngine, { ProcessResultsRow } from './services/search/SearchEngine';
import SearchEngine, { ComplexTerm, ProcessResultsRow } from './services/search/SearchEngine';
import RevisionService from './services/RevisionService';
import ResourceService from './services/ResourceService';
import DecryptionWorker from './services/DecryptionWorker';
Expand Down Expand Up @@ -240,7 +240,7 @@ export default class BaseApplication {
});

let notes: NoteEntity[] = [];
let highlightedWords: string[] = [];
let highlightedWords: (ComplexTerm | string)[] = [];
let searchResults: ProcessResultsRow[] = [];

if (parentId) {
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/models/settings/builtInMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ const builtInMetadata = (Setting: typeof SettingType) => {
advanced: true,

label: () => _('Plugin WebView debugging'),
description: () => _('Allows debugging mobile plugins. See %s for details.', 'https://https://joplinapp.org/help/api/references/mobile_plugin_debugging/'),
description: () => _('Allows debugging mobile plugins. See %s for details.', 'https://joplinapp.org/help/api/references/mobile_plugin_debugging/'),
},

'plugins.pluginSupportEnabled': {
Expand Down
22 changes: 15 additions & 7 deletions packages/lib/services/search/SearchEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,22 @@ export interface ComplexTerm {
}

export interface Terms {
// This `string | ComplexTerm` type that ends up propagating throughout the app is a bit of a
// mess, but it reflects how it was originally done in plain JS. Ideally it should be refactor
// to use a simple type.
_: (string | ComplexTerm)[];
title: (string | ComplexTerm)[];
body: (string | ComplexTerm)[];
}

export interface ParsedQuery {
termCount: number;
keys: string[];
terms: Terms; // text terms
allTerms: Term[];
any: boolean;
}

export default class SearchEngine {

public static instance_: SearchEngine = null;
Expand Down Expand Up @@ -521,7 +532,7 @@ export default class SearchEngine {
return regexString;
}

public async parseQuery(query: string) {
public async parseQuery(query: string): Promise<ParsedQuery> {

const trimQuotes = (str: string) => str.startsWith('"') ? str.substr(1, str.length - 2) : str;

Expand Down Expand Up @@ -606,14 +617,11 @@ export default class SearchEngine {
};
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
public allParsedQueryTerms(parsedQuery: any) {
public allParsedQueryTerms(parsedQuery: ParsedQuery) {
if (!parsedQuery || !parsedQuery.termCount) return [];

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
let output: any[] = [];
for (const col in parsedQuery.terms) {
if (!parsedQuery.terms.hasOwnProperty(col)) continue;
let output: typeof parsedQuery.terms._ = [];
for (const col of Object.keys(parsedQuery.terms) as (keyof Terms)[]) {
output = output.concat(parsedQuery.terms[col]);
}
return output;
Expand Down
4 changes: 4 additions & 0 deletions packages/lib/string-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export function removeDiacritics(str: string) {
return str;
}

export function escapeRegExp(keyword: string) {
return keyword.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}

export function wrap(text: string, indent: string, width: number) {
const wrap_ = require('word-wrap');

Expand Down
Loading

0 comments on commit 8817721

Please sign in to comment.