diff --git a/wax-prosemirror-components/src/components/findAndReplace/ExandedFindAndReplaceComponent.js b/wax-prosemirror-components/src/components/findAndReplace/ExandedFindAndReplaceComponent.js index c0fd8ec97022a54508b98041bb8397a1995a6165..2c2d20d121f7f779e3be4d3cb1ceb78aa2cc1406 100644 --- a/wax-prosemirror-components/src/components/findAndReplace/ExandedFindAndReplaceComponent.js +++ b/wax-prosemirror-components/src/components/findAndReplace/ExandedFindAndReplaceComponent.js @@ -1,6 +1,6 @@ /* eslint react/prop-types: 0 */ -import React from 'react'; +import React, { useState, useRef } from 'react'; import styled from 'styled-components'; import { grid, th } from '@pubsweet/ui-toolkit'; import Icon from '../../helpers/Icon'; @@ -109,11 +109,17 @@ const PreviousNextContainer = styled.div` } `; -const ExandedFindAndReplaceComponent = ({ close }) => { +const ExandedFindAndReplaceComponent = ({ close, nonExpandedText }) => { + const searchRef = useRef(null); + const replaceRef = useRef(null); + const [searchValue, setsearchValue] = useState(nonExpandedText); const closeFind = () => { close(); }; + const onChangeSearchInput = () => {}; + const onChangeReplaceInput = () => {}; + const replace = () => {}; const replaceAll = () => {}; @@ -126,9 +132,20 @@ const ExandedFindAndReplaceComponent = ({ close }) => { </CloseWrapper> </TitleContainer> <InputLabel>Find</InputLabel> - <FindReplaceInput type="text" placeholder="Something is this doc" /> + <FindReplaceInput + type="text" + ref={searchRef} + placeholder="Something is this doc" + value={searchValue} + onChange={onChangeSearchInput} + /> <InputLabel>Replace with</InputLabel> - <FindReplaceInput type="text" placeholder="Replace phrase" /> + <FindReplaceInput + type="text" + ref={replaceRef} + placeholder="Replace text" + onChange={onChangeReplaceInput} + /> <CheckBoxWrapper> <CheckBox name="case-sensitive" label="Case Sensitive" /> </CheckBoxWrapper> diff --git a/wax-prosemirror-components/src/components/findAndReplace/FindAndReplaceComponent.js b/wax-prosemirror-components/src/components/findAndReplace/FindAndReplaceComponent.js index baf9eb0dae938740811c32ca7a358cb760b91e76..2a36e0ed115c6ab4d094510d05345d29e8e5cb4e 100644 --- a/wax-prosemirror-components/src/components/findAndReplace/FindAndReplaceComponent.js +++ b/wax-prosemirror-components/src/components/findAndReplace/FindAndReplaceComponent.js @@ -5,17 +5,26 @@ import ExandedFindAndReplaceComponent from './ExandedFindAndReplaceComponent'; const FindAndReplaceComponent = ({ close }) => { const [isExpanded, setExpanded] = useState(false); - + const [nonExpandedText, SetnonExpandedText] = useState(''); const expand = () => { setExpanded(true); }; - const getNonExpandedText = () => {}; + const getNonExpandedText = searcString => { + SetnonExpandedText(searcString); + }; return isExpanded ? ( - <ExandedFindAndReplaceComponent close={close} previousText="" /> + <ExandedFindAndReplaceComponent + close={close} + nonExpandedText={nonExpandedText} + /> ) : ( - <FindComponent close={close} expand={expand} /> + <FindComponent + close={close} + expand={expand} + setPreviousSearcValue={getNonExpandedText} + /> ); }; diff --git a/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js b/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js index d647f05df68be5fb4d8117b32e3c757807e39fc4..32b11ec5a5d972c626a5f61fcc032a4f1b5db4f6 100644 --- a/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js +++ b/wax-prosemirror-components/src/components/findAndReplace/FindComponent.js @@ -71,7 +71,7 @@ const CloseWrapper = styled.div` const ExpandedWrapper = styled.div``; -const FindComponent = ({ close, expand }) => { +const FindComponent = ({ close, expand, setPreviousSearcValue }) => { const { app, view: { main }, @@ -157,6 +157,7 @@ const FindComponent = ({ close, expand }) => { const showExpanded = () => { expand(); + setPreviousSearcValue(searchValue); }; return (