Skip to content
Snippets Groups Projects
Commit 58941cde authored by chris's avatar chris
Browse files

feat(find and replace): group matches by view for previous/next

parent 5392ad26
No related branches found
No related tags found
1 merge request!215set id
......@@ -94,7 +94,7 @@ const Svg = styled.svg.attrs(() => ({
`;
const FindComponent = ({ close, expand, setPreviousSearcValue }) => {
const { app, view } = useContext(WaxContext);
const { app, view, activeViewId } = useContext(WaxContext);
const searchRef = useRef(null);
const [searchValue, setSearchValue] = useState('');
......@@ -162,12 +162,31 @@ const FindComponent = ({ close, expand, setPreviousSearcValue }) => {
searchRef.current.focus();
};
const getAllResultsByView = () => {
const allResults = {};
each(view, (singleView, viewId) => {
if (!allResults[viewId]) {
allResults[viewId] = helpers.findMatches(
singleView.state.doc,
searchValue,
matchCaseSearch,
);
}
});
return allResults;
};
const findNext = () => {
// console.log('next');
const results = getAllResultsByView();
const currentSelection = view[activeViewId].state.selection;
console.log(results, activeViewId, currentSelection);
};
const findPrevious = () => {
// console.log('previous');
const results = getAllResultsByView();
const currentSelection = view[activeViewId].state.selection;
console.log(results, activeViewId, currentSelection);
};
return (
......
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