mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-01 19:15:01 +02:00
Desktop: Improved local search by highlighting even partial matches
This commit is contained in:
parent
26aae9eea5
commit
3f540da31b
@ -6,7 +6,7 @@ const Search = require('lib/models/Search.js');
|
|||||||
const { time } = require('lib/time-utils.js');
|
const { time } = require('lib/time-utils.js');
|
||||||
const Setting = require('lib/models/Setting.js');
|
const Setting = require('lib/models/Setting.js');
|
||||||
const { IconButton } = require('./IconButton.min.js');
|
const { IconButton } = require('./IconButton.min.js');
|
||||||
const { urlDecode, escapeHtml } = require('lib/string-utils');
|
const { urlDecode, escapeHtml, pregQuote } = require('lib/string-utils');
|
||||||
const Toolbar = require('./Toolbar.min.js');
|
const Toolbar = require('./Toolbar.min.js');
|
||||||
const TagList = require('./TagList.min.js');
|
const TagList = require('./TagList.min.js');
|
||||||
const { connect } = require('react-redux');
|
const { connect } = require('react-redux');
|
||||||
@ -1588,7 +1588,11 @@ class NoteTextComponent extends React.Component {
|
|||||||
const markerOptions = {};
|
const markerOptions = {};
|
||||||
|
|
||||||
if (this.state.showLocalSearch) {
|
if (this.state.showLocalSearch) {
|
||||||
keywords = [this.state.localSearch.query];
|
keywords = [{
|
||||||
|
type: 'text',
|
||||||
|
value: this.state.localSearch.query,
|
||||||
|
accuracy: 'partially',
|
||||||
|
}]
|
||||||
markerOptions.selectedIndex = this.state.localSearch.selectedIndex;
|
markerOptions.selectedIndex = this.state.localSearch.selectedIndex;
|
||||||
} else {
|
} else {
|
||||||
const search = BaseModel.byId(this.props.searches, this.props.selectedSearchId);
|
const search = BaseModel.byId(this.props.searches, this.props.selectedSearchId);
|
||||||
|
@ -257,15 +257,22 @@
|
|||||||
for (let i = 0; i < keywords.length; i++) {
|
for (let i = 0; i < keywords.length; i++) {
|
||||||
const keyword = keywords[i];
|
const keyword = keywords[i];
|
||||||
|
|
||||||
|
if (typeof keyword === 'string') {
|
||||||
|
keyword = {
|
||||||
|
type: 'text',
|
||||||
|
value: keyword,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (keyword.type === 'regex') {
|
if (keyword.type === 'regex') {
|
||||||
mark_.markRegExp(new RegExp(keyword.value, 'gmi'), {
|
mark_.markRegExp(new RegExp(keyword.value, 'gmi'), {
|
||||||
each: onEachElement,
|
each: onEachElement,
|
||||||
acrossElements: true,
|
acrossElements: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mark_.mark([keyword], {
|
mark_.mark([keyword.value], {
|
||||||
each: onEachElement,
|
each: onEachElement,
|
||||||
accuracy: 'exactly',
|
accuracy: keyword.accuracy ? keyword.accuracy : 'exactly',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user