You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
Desktop: Toggle Editor rather than setting split mode on search (#3561)
This commit is contained in:
@@ -392,16 +392,6 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.searchMarkers !== previousSearchMarkers || renderedBody !== previousRenderedBody) {
|
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
|
// SEARCHHACK
|
||||||
// TODO: remove this options hack when aceeditor is removed
|
// TODO: remove this options hack when aceeditor is removed
|
||||||
// Currently the webviewRef will send out an ipcMessage to set the results count
|
// 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);
|
webviewRef.current.wrappedInstance.send('setMarkers', props.searchMarkers.keywords, options);
|
||||||
// SEARCHHACK
|
// SEARCHHACK
|
||||||
if (editorRef.current) {
|
if (editorRef.current) {
|
||||||
|
|
||||||
const matches = editorRef.current.setMarkers(props.searchMarkers.keywords, props.searchMarkers.options);
|
const matches = editorRef.current.setMarkers(props.searchMarkers.keywords, props.searchMarkers.options);
|
||||||
|
|
||||||
|
// 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);
|
props.setLocalSearchResultCount(matches);
|
||||||
|
} else {
|
||||||
|
props.setLocalSearchResultCount(-1);
|
||||||
|
}
|
||||||
|
// end SEARCHHACK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [props.searchMarkers, props.setLocalSearchResultCount, renderedBody]);
|
}, [props.searchMarkers, props.setLocalSearchResultCount, renderedBody]);
|
||||||
|
@@ -148,6 +148,21 @@ class NoteSearchBarComponent extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
) : null;
|
) : 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 (
|
return (
|
||||||
<div style={this.props.style}>
|
<div style={this.props.style}>
|
||||||
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
|
||||||
@@ -161,9 +176,10 @@ class NoteSearchBarComponent extends React.Component {
|
|||||||
type="text"
|
type="text"
|
||||||
style={{ width: 200, marginRight: 5, backgroundColor: this.backgroundColor, color: theme.color }}
|
style={{ width: 200, marginRight: 5, backgroundColor: this.backgroundColor, color: theme.color }}
|
||||||
/>
|
/>
|
||||||
{nextButton}
|
{allowScrolling ? nextButton : null}
|
||||||
{previousButton}
|
{allowScrolling ? previousButton : null}
|
||||||
{matchesFoundString}
|
{allowScrolling ? matchesFoundString : null}
|
||||||
|
{!allowScrolling ? viewerWarning : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user