|
@@ -15,9 +15,14 @@ import {
|
|
|
getSearchQuery,
|
|
getSearchQuery,
|
|
|
SearchCursor,
|
|
SearchCursor,
|
|
|
} from '@codemirror/search'
|
|
} from '@codemirror/search'
|
|
|
-import { Button, ButtonGroup, FormControl, InputGroup } from 'react-bootstrap'
|
|
|
|
|
|
|
+import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
|
|
|
|
|
+import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
|
|
+import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
|
|
|
+import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
|
+import OLButtonGroup from '@/features/ui/components/ol/ol-button-group'
|
|
|
|
|
+import OLFormControl from '@/features/ui/components/ol/ol-form-control'
|
|
|
|
|
+import OLCloseButton from '@/features/ui/components/ol/ol-close-button'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
-import Tooltip from '../../../shared/components/tooltip'
|
|
|
|
|
import Icon from '../../../shared/components/icon'
|
|
import Icon from '../../../shared/components/icon'
|
|
|
import classnames from 'classnames'
|
|
import classnames from 'classnames'
|
|
|
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
|
|
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
|
|
@@ -226,14 +231,14 @@ const CodeMirrorSearchForm: FC = () => {
|
|
|
role="search"
|
|
role="search"
|
|
|
>
|
|
>
|
|
|
<div className="ol-cm-search-controls">
|
|
<div className="ol-cm-search-controls">
|
|
|
- <InputGroup
|
|
|
|
|
- bsSize="small"
|
|
|
|
|
|
|
+ <span
|
|
|
className={classnames('ol-cm-search-input-group', {
|
|
className={classnames('ol-cm-search-input-group', {
|
|
|
'ol-cm-search-input-error':
|
|
'ol-cm-search-input-error':
|
|
|
query.regexp && isInvalidRegExp(query.search),
|
|
query.regexp && isInvalidRegExp(query.search),
|
|
|
})}
|
|
})}
|
|
|
>
|
|
>
|
|
|
- <FormControl
|
|
|
|
|
|
|
+ <OLFormControl
|
|
|
|
|
+ ref={handleInputRef}
|
|
|
type="text"
|
|
type="text"
|
|
|
name="search"
|
|
name="search"
|
|
|
// IMPORTANT: CodeMirror uses this attribute to focus the input
|
|
// IMPORTANT: CodeMirror uses this attribute to focus the input
|
|
@@ -245,99 +250,90 @@ const CodeMirrorSearchForm: FC = () => {
|
|
|
onChange={handleChange}
|
|
onChange={handleChange}
|
|
|
onKeyDown={handleSearchKeyDown}
|
|
onKeyDown={handleSearchKeyDown}
|
|
|
className="ol-cm-search-form-input"
|
|
className="ol-cm-search-form-input"
|
|
|
- bsSize="small"
|
|
|
|
|
- inputRef={handleInputRef}
|
|
|
|
|
|
|
+ size="sm"
|
|
|
aria-label={t('search_command_find')}
|
|
aria-label={t('search_command_find')}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
- <InputGroup.Button>
|
|
|
|
|
- <Tooltip
|
|
|
|
|
- id="search-match-case"
|
|
|
|
|
- description={t('search_match_case')}
|
|
|
|
|
|
|
+ <OLTooltip
|
|
|
|
|
+ id="search-match-case"
|
|
|
|
|
+ description={t('search_match_case')}
|
|
|
|
|
+ >
|
|
|
|
|
+ <label
|
|
|
|
|
+ className={classnames(
|
|
|
|
|
+ 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
+ {
|
|
|
|
|
+ checked: query.caseSensitive,
|
|
|
|
|
+ focused: activeSearchOption === 'caseSensitive',
|
|
|
|
|
+ }
|
|
|
|
|
+ )}
|
|
|
|
|
+ htmlFor={caseSensitiveId}
|
|
|
|
|
+ aria-label={t('search_match_case')}
|
|
|
>
|
|
>
|
|
|
- <label
|
|
|
|
|
- className={classnames(
|
|
|
|
|
- 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
- {
|
|
|
|
|
- checked: query.caseSensitive,
|
|
|
|
|
- focused: activeSearchOption === 'caseSensitive',
|
|
|
|
|
- }
|
|
|
|
|
- )}
|
|
|
|
|
- htmlFor={caseSensitiveId}
|
|
|
|
|
- aria-label={t('search_match_case')}
|
|
|
|
|
- >
|
|
|
|
|
- Aa
|
|
|
|
|
- </label>
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
- </InputGroup.Button>
|
|
|
|
|
-
|
|
|
|
|
- <InputGroup.Button>
|
|
|
|
|
- <Tooltip id="search-regexp" description={t('search_regexp')}>
|
|
|
|
|
- <label
|
|
|
|
|
- className={classnames(
|
|
|
|
|
- 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
- {
|
|
|
|
|
- checked: query.regexp,
|
|
|
|
|
- focused: activeSearchOption === 'regexp',
|
|
|
|
|
- }
|
|
|
|
|
- )}
|
|
|
|
|
- htmlFor={regexpId}
|
|
|
|
|
- aria-label={t('search_regexp')}
|
|
|
|
|
- >
|
|
|
|
|
- [.*]
|
|
|
|
|
- </label>
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
- </InputGroup.Button>
|
|
|
|
|
-
|
|
|
|
|
- <InputGroup.Button>
|
|
|
|
|
- <Tooltip
|
|
|
|
|
- id="search-whole-word"
|
|
|
|
|
- description={t('search_whole_word')}
|
|
|
|
|
|
|
+ Aa
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </OLTooltip>
|
|
|
|
|
+
|
|
|
|
|
+ <OLTooltip id="search-regexp" description={t('search_regexp')}>
|
|
|
|
|
+ <label
|
|
|
|
|
+ className={classnames(
|
|
|
|
|
+ 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
+ {
|
|
|
|
|
+ checked: query.regexp,
|
|
|
|
|
+ focused: activeSearchOption === 'regexp',
|
|
|
|
|
+ }
|
|
|
|
|
+ )}
|
|
|
|
|
+ htmlFor={regexpId}
|
|
|
|
|
+ aria-label={t('search_regexp')}
|
|
|
>
|
|
>
|
|
|
- <label
|
|
|
|
|
- className={classnames(
|
|
|
|
|
- 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
- {
|
|
|
|
|
- checked: query.wholeWord,
|
|
|
|
|
- focused: activeSearchOption === 'wholeWord',
|
|
|
|
|
- }
|
|
|
|
|
- )}
|
|
|
|
|
- htmlFor={wholeWordId}
|
|
|
|
|
- aria-label={t('search_whole_word')}
|
|
|
|
|
- >
|
|
|
|
|
- W
|
|
|
|
|
- </label>
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
- </InputGroup.Button>
|
|
|
|
|
-
|
|
|
|
|
- <InputGroup.Button>
|
|
|
|
|
- <Tooltip
|
|
|
|
|
- id="search-within-selection"
|
|
|
|
|
- description={t('search_within_selection')}
|
|
|
|
|
|
|
+ [.*]
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </OLTooltip>
|
|
|
|
|
+
|
|
|
|
|
+ <OLTooltip
|
|
|
|
|
+ id="search-whole-word"
|
|
|
|
|
+ description={t('search_whole_word')}
|
|
|
|
|
+ >
|
|
|
|
|
+ <label
|
|
|
|
|
+ className={classnames(
|
|
|
|
|
+ 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
+ {
|
|
|
|
|
+ checked: query.wholeWord,
|
|
|
|
|
+ focused: activeSearchOption === 'wholeWord',
|
|
|
|
|
+ }
|
|
|
|
|
+ )}
|
|
|
|
|
+ htmlFor={wholeWordId}
|
|
|
|
|
+ aria-label={t('search_whole_word')}
|
|
|
|
|
+ >
|
|
|
|
|
+ W
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </OLTooltip>
|
|
|
|
|
+ <OLTooltip
|
|
|
|
|
+ id="search-within-selection"
|
|
|
|
|
+ description={t('search_within_selection')}
|
|
|
|
|
+ >
|
|
|
|
|
+ <label
|
|
|
|
|
+ className={classnames(
|
|
|
|
|
+ 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
+ {
|
|
|
|
|
+ checked: !!query.scope,
|
|
|
|
|
+ focused: activeSearchOption === 'withinSelection',
|
|
|
|
|
+ }
|
|
|
|
|
+ )}
|
|
|
|
|
+ htmlFor={withinSelectionId}
|
|
|
|
|
+ aria-label={t('search_within_selection')}
|
|
|
>
|
|
>
|
|
|
- <label
|
|
|
|
|
- className={classnames(
|
|
|
|
|
- 'btn btn-sm btn-default ol-cm-search-input-button',
|
|
|
|
|
- {
|
|
|
|
|
- checked: !!query.scope,
|
|
|
|
|
- focused: activeSearchOption === 'withinSelection',
|
|
|
|
|
- }
|
|
|
|
|
- )}
|
|
|
|
|
- htmlFor={withinSelectionId}
|
|
|
|
|
- aria-label={t('search_within_selection')}
|
|
|
|
|
- >
|
|
|
|
|
- <Icon type="align-left" fw />
|
|
|
|
|
- </label>
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
- </InputGroup.Button>
|
|
|
|
|
- </InputGroup>
|
|
|
|
|
|
|
+ <BootstrapVersionSwitcher
|
|
|
|
|
+ bs3={<Icon type="align-left" fw />}
|
|
|
|
|
+ bs5={<MaterialIcon type="format_align_left" />}
|
|
|
|
|
+ />
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </OLTooltip>
|
|
|
|
|
+ </span>
|
|
|
|
|
|
|
|
{showReplace && (
|
|
{showReplace && (
|
|
|
- <InputGroup
|
|
|
|
|
- bsSize="small"
|
|
|
|
|
- className="ol-cm-search-input-group ol-cm-search-replace-input"
|
|
|
|
|
- >
|
|
|
|
|
- <FormControl
|
|
|
|
|
|
|
+ <span className="ol-cm-search-input-group ol-cm-search-replace-input">
|
|
|
|
|
+ <OLFormControl
|
|
|
|
|
+ ref={handleReplaceRef}
|
|
|
type="text"
|
|
type="text"
|
|
|
name="replace"
|
|
name="replace"
|
|
|
placeholder={t('search_replace_with')}
|
|
placeholder={t('search_replace_with')}
|
|
@@ -346,11 +342,10 @@ const CodeMirrorSearchForm: FC = () => {
|
|
|
onChange={handleChange}
|
|
onChange={handleChange}
|
|
|
onKeyDown={handleReplaceKeyDown}
|
|
onKeyDown={handleReplaceKeyDown}
|
|
|
className="ol-cm-search-form-input"
|
|
className="ol-cm-search-form-input"
|
|
|
- bsSize="small"
|
|
|
|
|
- inputRef={handleReplaceRef}
|
|
|
|
|
|
|
+ size="sm"
|
|
|
aria-label={t('search_command_replace')}
|
|
aria-label={t('search_command_replace')}
|
|
|
/>
|
|
/>
|
|
|
- </InputGroup>
|
|
|
|
|
|
|
+ </span>
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
<div className="ol-cm-search-hidden-inputs">
|
|
<div className="ol-cm-search-hidden-inputs">
|
|
@@ -404,27 +399,51 @@ const CodeMirrorSearchForm: FC = () => {
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="ol-cm-search-form-group ol-cm-search-next-previous">
|
|
<div className="ol-cm-search-form-group ol-cm-search-next-previous">
|
|
|
- <ButtonGroup className="ol-cm-search-form-button-group">
|
|
|
|
|
- <Button
|
|
|
|
|
- type="button"
|
|
|
|
|
- bsSize="small"
|
|
|
|
|
|
|
+ <OLButtonGroup className="ol-cm-search-form-button-group">
|
|
|
|
|
+ <OLButton
|
|
|
|
|
+ variant="secondary"
|
|
|
|
|
+ size="sm"
|
|
|
onClick={() => findPrevious(view)}
|
|
onClick={() => findPrevious(view)}
|
|
|
>
|
|
>
|
|
|
- <Icon
|
|
|
|
|
- type="chevron-up"
|
|
|
|
|
- fw
|
|
|
|
|
- accessibilityLabel={t('search_previous')}
|
|
|
|
|
|
|
+ <BootstrapVersionSwitcher
|
|
|
|
|
+ bs3={
|
|
|
|
|
+ <Icon
|
|
|
|
|
+ type="chevron-up"
|
|
|
|
|
+ fw
|
|
|
|
|
+ accessibilityLabel={t('search_previous')}
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
|
|
+ bs5={
|
|
|
|
|
+ <MaterialIcon
|
|
|
|
|
+ type="keyboard_arrow_up"
|
|
|
|
|
+ accessibilityLabel={t('search_previous')}
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
/>
|
|
/>
|
|
|
- </Button>
|
|
|
|
|
|
|
+ </OLButton>
|
|
|
|
|
|
|
|
- <Button type="button" bsSize="small" onClick={() => findNext(view)}>
|
|
|
|
|
- <Icon
|
|
|
|
|
- type="chevron-down"
|
|
|
|
|
- fw
|
|
|
|
|
- accessibilityLabel={t('search_next')}
|
|
|
|
|
|
|
+ <OLButton
|
|
|
|
|
+ variant="secondary"
|
|
|
|
|
+ size="sm"
|
|
|
|
|
+ onClick={() => findNext(view)}
|
|
|
|
|
+ >
|
|
|
|
|
+ <BootstrapVersionSwitcher
|
|
|
|
|
+ bs3={
|
|
|
|
|
+ <Icon
|
|
|
|
|
+ type="chevron-down"
|
|
|
|
|
+ fw
|
|
|
|
|
+ accessibilityLabel={t('search_next')}
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
|
|
+ bs5={
|
|
|
|
|
+ <MaterialIcon
|
|
|
|
|
+ type="keyboard_arrow_down"
|
|
|
|
|
+ accessibilityLabel={t('search_next')}
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
/>
|
|
/>
|
|
|
- </Button>
|
|
|
|
|
- </ButtonGroup>
|
|
|
|
|
|
|
+ </OLButton>
|
|
|
|
|
+ </OLButtonGroup>
|
|
|
|
|
|
|
|
{position !== null && (
|
|
{position !== null && (
|
|
|
<div className="ol-cm-search-form-position">
|
|
<div className="ol-cm-search-form-position">
|
|
@@ -437,36 +456,29 @@ const CodeMirrorSearchForm: FC = () => {
|
|
|
|
|
|
|
|
{showReplace && (
|
|
{showReplace && (
|
|
|
<div className="ol-cm-search-form-group ol-cm-search-replace-buttons">
|
|
<div className="ol-cm-search-form-group ol-cm-search-replace-buttons">
|
|
|
- <Button
|
|
|
|
|
- type="button"
|
|
|
|
|
- bsSize="small"
|
|
|
|
|
|
|
+ <OLButton
|
|
|
|
|
+ variant="secondary"
|
|
|
|
|
+ size="sm"
|
|
|
onClick={() => replaceNext(view)}
|
|
onClick={() => replaceNext(view)}
|
|
|
>
|
|
>
|
|
|
{t('search_replace')}
|
|
{t('search_replace')}
|
|
|
- </Button>
|
|
|
|
|
|
|
+ </OLButton>
|
|
|
|
|
|
|
|
- <Button
|
|
|
|
|
- type="button"
|
|
|
|
|
- bsSize="small"
|
|
|
|
|
|
|
+ <OLButton
|
|
|
|
|
+ variant="secondary"
|
|
|
|
|
+ size="sm"
|
|
|
onClick={() => replaceAll(view)}
|
|
onClick={() => replaceAll(view)}
|
|
|
>
|
|
>
|
|
|
{t('search_replace_all')}
|
|
{t('search_replace_all')}
|
|
|
- </Button>
|
|
|
|
|
|
|
+ </OLButton>
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="ol-cm-search-form-close">
|
|
<div className="ol-cm-search-form-close">
|
|
|
- <Tooltip id="search-close" description={<>{t('close')} (Esc)</>}>
|
|
|
|
|
- <button
|
|
|
|
|
- className="close"
|
|
|
|
|
- onClick={() => closeSearchPanel(view)}
|
|
|
|
|
- type="button"
|
|
|
|
|
- aria-label={t('close')}
|
|
|
|
|
- >
|
|
|
|
|
- <span aria-hidden="true">×</span>
|
|
|
|
|
- </button>
|
|
|
|
|
- </Tooltip>
|
|
|
|
|
|
|
+ <OLTooltip id="search-close" description={<>{t('close')} (Esc)</>}>
|
|
|
|
|
+ <OLCloseButton onClick={() => closeSearchPanel(view)} />
|
|
|
|
|
+ </OLTooltip>
|
|
|
</div>
|
|
</div>
|
|
|
</form>
|
|
</form>
|
|
|
)
|
|
)
|