You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-24 23:26:50 +02:00
Electron: Resolves #144, Resolves #311: Highlight search results and search in real time. Associated Ctrl+F with searching.
This commit is contained in:
@ -260,7 +260,7 @@ class BaseApplication {
|
||||
const newState = store.getState();
|
||||
let refreshNotes = false;
|
||||
|
||||
if (action.type == 'FOLDER_SELECT' || action.type === 'FOLDER_DELETE') {
|
||||
if (action.type == 'FOLDER_SELECT' || action.type === 'FOLDER_DELETE' || (action.type === 'SEARCH_UPDATE' && newState.notesParentType === 'Folder')) {
|
||||
Setting.setValue('activeFolderId', newState.selectedFolderId);
|
||||
this.currentFolder_ = newState.selectedFolderId ? await Folder.load(newState.selectedFolderId) : null;
|
||||
refreshNotes = true;
|
||||
|
@ -3,6 +3,7 @@ const Entities = require('html-entities').AllHtmlEntities;
|
||||
const htmlentities = (new Entities()).encode;
|
||||
const Resource = require('lib/models/Resource.js');
|
||||
const ModelCache = require('lib/ModelCache');
|
||||
const ObjectUtils = require('lib/ObjectUtils');
|
||||
const { shim } = require('lib/shim.js');
|
||||
const md5 = require('md5');
|
||||
const MdToHtml_Katex = require('lib/MdToHtml_Katex');
|
||||
@ -336,14 +337,16 @@ class MdToHtml {
|
||||
|
||||
// Insert the extra CSS at the top of the HTML
|
||||
|
||||
const temp = ['<style>'];
|
||||
for (let n in extraCssBlocks) {
|
||||
if (!extraCssBlocks.hasOwnProperty(n)) continue;
|
||||
temp.push(extraCssBlocks[n]);
|
||||
}
|
||||
temp.push('</style>');
|
||||
if (!ObjectUtils.isEmpty(extraCssBlocks)) {
|
||||
const temp = ['<style>'];
|
||||
for (let n in extraCssBlocks) {
|
||||
if (!extraCssBlocks.hasOwnProperty(n)) continue;
|
||||
temp.push(extraCssBlocks[n]);
|
||||
}
|
||||
temp.push('</style>');
|
||||
|
||||
output = temp.concat(output);
|
||||
output = temp.concat(output);
|
||||
}
|
||||
|
||||
return output.join('');
|
||||
}
|
||||
|
@ -53,4 +53,9 @@ ObjectUtils.convertValuesToFunctions = function(o) {
|
||||
return output;
|
||||
}
|
||||
|
||||
ObjectUtils.isEmpty = function(o) {
|
||||
if (!o) return true;
|
||||
return Object.keys(o).length === 0 && o.constructor === Object;
|
||||
}
|
||||
|
||||
module.exports = ObjectUtils;
|
23
ReactNativeClient/lib/models/Search.js
Normal file
23
ReactNativeClient/lib/models/Search.js
Normal file
@ -0,0 +1,23 @@
|
||||
const BaseModel = require('lib/BaseModel.js');
|
||||
const Note = require('lib/models/Note.js');
|
||||
|
||||
class Search extends BaseModel {
|
||||
|
||||
static tableName() {
|
||||
throw new Error('Not using database');
|
||||
}
|
||||
|
||||
static modelType() {
|
||||
return BaseModel.TYPE_SEARCH;
|
||||
}
|
||||
|
||||
static keywords(query) {
|
||||
let output = query.trim();
|
||||
output = output.split(/[\s\t\n]+/);
|
||||
output = output.filter(o => !!o);
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Search;
|
@ -426,11 +426,35 @@ const reducer = (state = defaultState, action) => {
|
||||
case 'SEARCH_ADD':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
let searches = newState.searches.slice();
|
||||
var searches = newState.searches.slice();
|
||||
searches.push(action.search);
|
||||
newState.searches = searches;
|
||||
break;
|
||||
|
||||
case 'SEARCH_UPDATE':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
var searches = newState.searches.slice();
|
||||
var found = false;
|
||||
for (let i = 0; i < searches.length; i++) {
|
||||
if (searches[i].id === action.search.id) {
|
||||
searches[i] = Object.assign({}, action.search);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) searches.push(action.search);
|
||||
|
||||
if (!action.search.query_pattern) {
|
||||
newState.notesParentType = defaultNotesParentType(state, 'Search');
|
||||
} else {
|
||||
newState.notesParentType = 'Search';
|
||||
}
|
||||
|
||||
newState.searches = searches;
|
||||
break;
|
||||
|
||||
case 'SEARCH_DELETE':
|
||||
|
||||
newState = handleItemDelete(state, action);
|
||||
|
Reference in New Issue
Block a user