import { CloseOutlined } from '@ant-design/icons'; import { Button, Input } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; export const FindAndReplace = (props: any) => { const { open, callback, editor, find, replace, replaceAll, highlightRanges, getNum, setFindSelection, searchText, replaceText } = props; const [visible, setVisible] = useState(false); const [thisSearch, setSearch] = useState(''); const [thisReplace, setReplace] = useState(''); const searchTextRef = useRef(null); const replaceTextRef = useRef(null); useEffect(() => { setVisible(open); }, [open]); const countFind = () => { const first = highlightRanges.length === 0 ? 0 : getNum() + 1; const last = highlightRanges.length; const display = first.toString() + '/' + last.toString(); return {display}; }; const countFindDisplay = countFind(); return (
查找
{ setSearch(e.target.value); searchText(e.target.value); }} suffix={countFindDisplay} >
替换
{ setReplace(e.target.value); replaceText(e.target.value); }} >
); };