mirror of
https://github.com/laurent22/joplin.git
synced 2025-02-16 19:47:40 +02:00
Desktop: Toggle Editor rather than setting split mode on search (#3561)
This commit is contained in:
parent
baea44cbd6
commit
bab29cd582
@ -392,16 +392,6 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
||||
|
||||
useEffect(() => {
|
||||
if (props.searchMarkers !== previousSearchMarkers || renderedBody !== previousRenderedBody) {
|
||||
// Force both viewers to be visible during search
|
||||
// This view should only change when the search terms change, this means the user
|
||||
// is always presented with the currently highlighted text, but can revert
|
||||
// to the viewer if they only want to scroll through matches
|
||||
if (!props.visiblePanes.includes('editor') && props.searchMarkers !== previousSearchMarkers) {
|
||||
props.dispatch({
|
||||
type: 'NOTE_VISIBLE_PANES_SET',
|
||||
panes: ['editor', 'viewer'],
|
||||
});
|
||||
}
|
||||
// SEARCHHACK
|
||||
// TODO: remove this options hack when aceeditor is removed
|
||||
// Currently the webviewRef will send out an ipcMessage to set the results count
|
||||
@ -421,9 +411,17 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
||||
webviewRef.current.wrappedInstance.send('setMarkers', props.searchMarkers.keywords, options);
|
||||
// SEARCHHACK
|
||||
if (editorRef.current) {
|
||||
|
||||
const matches = editorRef.current.setMarkers(props.searchMarkers.keywords, props.searchMarkers.options);
|
||||
props.setLocalSearchResultCount(matches);
|
||||
|
||||
// SEARCHHACK
|
||||
// TODO: when aceeditor is removed then this check will be performed in the NoteSearchbar
|
||||
// End the if statement can be removed in favor of simply returning matches
|
||||
if (props.visiblePanes.includes('editor')) {
|
||||
props.setLocalSearchResultCount(matches);
|
||||
} else {
|
||||
props.setLocalSearchResultCount(-1);
|
||||
}
|
||||
// end SEARCHHACK
|
||||
}
|
||||
}
|
||||
}, [props.searchMarkers, props.setLocalSearchResultCount, renderedBody]);
|
||||
|
@ -148,6 +148,21 @@ class NoteSearchBarComponent extends React.Component {
|
||||
</div>
|
||||
) : null;
|
||||
|
||||
// Currently searching in the viewer does not support jumping between matches
|
||||
// So we explicitly disable those commands when only the viewer is open (this is
|
||||
// currently signaled by results count being set to -1, but once Ace editor is removed
|
||||
// we can observe the visible panes directly).
|
||||
// SEARCHHACK
|
||||
// TODO: remove the props.resultCount check here and replace it by checking visible panes directly
|
||||
const allowScrolling = this.props.resultCount !== -1;
|
||||
// end SEARCHHACK
|
||||
|
||||
const viewerWarning = (
|
||||
<div style={textStyle}>
|
||||
{'Jumping between matches is not available in the viewer, please toggle the editor'}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div style={this.props.style}>
|
||||
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
||||
@ -161,9 +176,10 @@ class NoteSearchBarComponent extends React.Component {
|
||||
type="text"
|
||||
style={{ width: 200, marginRight: 5, backgroundColor: this.backgroundColor, color: theme.color }}
|
||||
/>
|
||||
{nextButton}
|
||||
{previousButton}
|
||||
{matchesFoundString}
|
||||
{allowScrolling ? nextButton : null}
|
||||
{allowScrolling ? previousButton : null}
|
||||
{allowScrolling ? matchesFoundString : null}
|
||||
{!allowScrolling ? viewerWarning : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user