mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Search engine: Improved support for JA, KO, ZH scripts
This commit is contained in:
parent
384ca09842
commit
8dc0b34fdc
@ -284,7 +284,7 @@ class NoteListComponent extends React.Component {
|
||||
acrossElements: true,
|
||||
});
|
||||
} else {
|
||||
mark.mark([w], {
|
||||
mark.mark([w.value], {
|
||||
accuracy: 'exactly',
|
||||
});
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ const Search = require('lib/models/Search.js');
|
||||
const { time } = require('lib/time-utils.js');
|
||||
const Setting = require('lib/models/Setting.js');
|
||||
const { IconButton } = require('./IconButton.min.js');
|
||||
const { urlDecode, escapeHtml, pregQuote } = require('lib/string-utils');
|
||||
const { urlDecode, escapeHtml, pregQuote, scriptType } = require('lib/string-utils');
|
||||
const Toolbar = require('./Toolbar.min.js');
|
||||
const TagList = require('./TagList.min.js');
|
||||
const { connect } = require('react-redux');
|
||||
@ -734,7 +734,7 @@ class NoteTextComponent extends React.Component {
|
||||
webviewReady: true,
|
||||
});
|
||||
|
||||
// if (Setting.value('env') === 'dev') this.webview_.openDevTools();
|
||||
if (Setting.value('env') === 'dev') this.webview_.openDevTools();
|
||||
}
|
||||
|
||||
webview_ref(element) {
|
||||
|
@ -231,6 +231,8 @@
|
||||
// TODO: It should highlight Russian
|
||||
// TODO: not working - "oue*" doesn't highlight "ouéé"
|
||||
// TODO: Search engine support to mobile app (sync tables)
|
||||
// TODO: Update everywhere that uses allParsedQueryTerms to support new format
|
||||
// TODO: Add support for scriptType on mobile and CLI
|
||||
|
||||
if (!mark_) {
|
||||
mark_ = new Mark(document.getElementById('content'), {
|
||||
@ -261,7 +263,7 @@
|
||||
}
|
||||
|
||||
for (let i = 0; i < keywords.length; i++) {
|
||||
const keyword = keywords[i];
|
||||
let keyword = keywords[i];
|
||||
|
||||
if (typeof keyword === 'string') {
|
||||
keyword = {
|
||||
@ -270,15 +272,22 @@
|
||||
};
|
||||
}
|
||||
|
||||
const isBasicSearch = ['ja', 'zh', 'ko'].indexOf(keyword.scriptType) >= 0;
|
||||
|
||||
if (keyword.type === 'regex') {
|
||||
mark_.markRegExp(new RegExp('\\b' + keyword.value + '\\b', 'gmi'), {
|
||||
let regexString = '\\b' + keyword.value + '\\b';
|
||||
if (isBasicSearch) regexString = keyword.value;
|
||||
|
||||
mark_.markRegExp(new RegExp(regexString, 'gmi'), {
|
||||
each: onEachElement,
|
||||
acrossElements: true,
|
||||
});
|
||||
} else {
|
||||
let accuracy = keyword.accuracy ? keyword.accuracy : 'exactly';
|
||||
if (isBasicSearch) accuracy = 'partially';
|
||||
mark_.mark([keyword.value], {
|
||||
each: onEachElement,
|
||||
accuracy: keyword.accuracy ? keyword.accuracy : 'exactly',
|
||||
accuracy: accuracy,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +298,9 @@ class SearchEngine {
|
||||
}
|
||||
|
||||
if (term.indexOf('*') >= 0) {
|
||||
terms[col][i] = { type: 'regex', value: this.queryTermToRegex(term) };
|
||||
terms[col][i] = { type: 'regex', value: this.queryTermToRegex(term), scriptType: scriptType(term) };
|
||||
} else {
|
||||
terms[col][i] = { type: 'text', value: term, scriptType: scriptType(term) };
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user