Skip to content
Snippets Groups Projects
Commit 36b800fd authored by chris's avatar chris
Browse files

next fix

parent fcec6474
No related branches found
No related tags found
1 merge request!231Connect funcionality
...@@ -147,7 +147,13 @@ const FindComponent = ({ ...@@ -147,7 +147,13 @@ const FindComponent = ({
findAndReplacePlugin.props.setSearchText(searchValue); findAndReplacePlugin.props.setSearchText(searchValue);
findAndReplacePlugin.props.setSearchMatchCase(matchCaseSearch); findAndReplacePlugin.props.setSearchMatchCase(matchCaseSearch);
counter = helpers.getMatchesByView(view, searchValue, matchCaseSearch); counter = helpers.getMatchesByView(view, searchValue, matchCaseSearch);
const results = helpers.getAllResultsByView(
view,
searchValue,
matchCaseSearch,
);
if (results.main) {
}
if (counter > 0) setCounterText(`1 of ${counter}`); if (counter > 0) setCounterText(`1 of ${counter}`);
if (searchRef.current === document.activeElement) { if (searchRef.current === document.activeElement) {
...@@ -177,6 +183,9 @@ const FindComponent = ({ ...@@ -177,6 +183,9 @@ const FindComponent = ({
}; };
const findNext = () => { const findNext = () => {
console.log('activeViewId', activeViewId);
lastActiveViewId = activeViewId;
lastSelection = view[activeViewId].state.selection;
const results = helpers.getAllResultsByView( const results = helpers.getAllResultsByView(
view, view,
searchValue, searchValue,
...@@ -197,8 +206,10 @@ const FindComponent = ({ ...@@ -197,8 +206,10 @@ const FindComponent = ({
), ),
); );
view[findViewWithMatches].focus(); view[findViewWithMatches].focus();
lastActiveViewId = findViewWithMatches; setTimeout(() => {
lastSelection = view[lastActiveViewId].state.selection; lastActiveViewId = findViewWithMatches;
lastSelection = view[lastActiveViewId].state.selection;
}, 50);
} }
const found = helpers.getClosestMatch( const found = helpers.getClosestMatch(
...@@ -223,29 +234,36 @@ const FindComponent = ({ ...@@ -223,29 +234,36 @@ const FindComponent = ({
lastSelection.from === found && lastSelection.from === found &&
position === resultsFrom[lastActiveViewId].length - 1 position === resultsFrom[lastActiveViewId].length - 1
) { ) {
console.log('hereee?');
/* End of results in notes move to main if results exist */ /* End of results in notes move to main if results exist */
if ( if (
notesIds.indexOf(lastActiveViewId) === notesIds.length - 1 && notesIds.indexOf(lastActiveViewId) === notesIds.length - 1 &&
results.main.length > 0 results.main.length > 0
) { ) {
lastSelection = view[activeViewId].state.selection; console.log('im main');
lastActiveViewId = activeViewId; setTimeout(() => {
lastActiveViewId = findViewWithMatches;
lastSelection = view[lastActiveViewId].state.selection;
}, 50);
helpers.moveToMatch(view, 'main', results, 0); helpers.moveToMatch(view, 'main', results, 0);
helpers.clearViewSelection(view, lastActiveViewId); helpers.clearViewSelection(view, lastActiveViewId);
} else { } else {
console.log('hohoho');
for (let i = 0; i < notesIds.length; i += 1) { for (let i = 0; i < notesIds.length; i += 1) {
if ( if (
results[notesIds[i]].length > 0 && results[notesIds[i]].length > 0 &&
notesIds[i] !== lastActiveViewId notesIds[i] !== lastActiveViewId
) { ) {
helpers.moveToMatch(view, notesIds[i], results, 0);
lastSelection = view[activeViewId].state.selection;
lastActiveViewId = activeViewId;
helpers.clearViewSelection(view, lastActiveViewId); helpers.clearViewSelection(view, lastActiveViewId);
helpers.moveToMatch(view, notesIds[i], results, 0);
break; break;
} }
} }
setTimeout(() => {
lastActiveViewId = findViewWithMatches;
lastSelection = view[lastActiveViewId].state.selection;
}, 50);
} }
} }
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment