Repository navigation
feat(web): search, find and replace #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4d58551
perf(web): start an engine step only when a parse slice still fits th…
SectionTN 8cb7da0
chore(web): a key count and the mean in the typing bench
SectionTN 26e5cbc
perf(web): keep a line's element when a key edits only that line
SectionTN 54a4deb
perf(web): skip moving the line cache when an edit stays inside one line
SectionTN 89f0ebf
perf(web): follow a horizontal caret reveal without drawing the frame…
SectionTN a5e4bff
perf(web): read the editor's box once per draw and the caret row only…
SectionTN 0ca13cd
feat(web): underlines, line backgrounds and gaps from the decorations…
SectionTN 5097303
fix(web): clear removed decorations even when decorationsRevision is old
SectionTN 8ea3e4e
fix(web): put the decorations on the view before its first draw
SectionTN 936dfdc
feat(web): search, find and replace with the scan sliced in the page …
SectionTN 1fcbd4f
test(web): check a sliced search scan against a second core's matches
SectionTN c980b0a
fix(example): reset the web find bar when the editor opens another file
SectionTN 3a3e13d
fix(example): give the web find bar's controls roles and names
SectionTN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; | ||
| import type { FindBarProps } from './types'; | ||
| import { useFind } from './useFind'; | ||
|
|
||
| // The find bar on the web: query, the three options, previous and next, replacement, replace and replace all. | ||
| export function FindBar({ scheme, editor, onStatus, onClose }: FindBarProps) { | ||
| const find = useFind(editor, onStatus); | ||
| const color = scheme === 'dark' ? '#e6edf3' : '#1f2328'; | ||
| const field = [styles.field, { color }]; | ||
| // An option passes its state as aria-pressed, which react-native-web forwards but React Native's types lack. | ||
| const button = (label: string, name: string, onPress: () => void, on?: boolean) => ( | ||
| <Pressable | ||
| onPress={onPress} | ||
| role="button" | ||
| aria-label={name} | ||
| {...((on === undefined ? {} : { 'aria-pressed': on }) as object)} | ||
| style={[styles.button, on && styles.on]} | ||
| > | ||
| <Text style={[styles.label, { color: on ? '#fff' : color }]}>{label}</Text> | ||
| </Pressable> | ||
| ); | ||
| const { index, count } = find.match; | ||
| return ( | ||
| <View style={styles.bar}> | ||
| <TextInput placeholder="Find" style={field} onChangeText={find.setQuery} autoFocus /> | ||
| <Text style={[styles.label, { color }]}> | ||
| {count ? `${index || '-'} of ${count}` : 'no results'} | ||
| </Text> | ||
| {button('.*', 'Regular expression', () => find.toggle('regex'), find.options.regex)} | ||
| {button('Aa', 'Match case', () => find.toggle('caseSensitive'), find.options.caseSensitive)} | ||
| {button('W', 'Whole word', () => find.toggle('wholeWord'), find.options.wholeWord)} | ||
| {button('prev', 'Previous match', find.previous)} | ||
| {button('next', 'Next match', find.next)} | ||
| <TextInput placeholder="Replace" style={field} onChangeText={find.setReplacement} /> | ||
| {button('replace', 'Replace', find.replaceOne)} | ||
| {button('all', 'Replace all', find.replaceAll)} | ||
| {button('close', 'Close find', onClose)} | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| bar: { flexDirection: 'row', flexWrap: 'wrap', gap: 6, padding: 8, alignItems: 'center' }, | ||
| field: { | ||
| minWidth: 120, | ||
| paddingHorizontal: 8, | ||
| paddingVertical: 4, | ||
| borderWidth: 1, | ||
| borderColor: '#8886', | ||
| borderRadius: 6, | ||
| }, | ||
| button: { paddingHorizontal: 8, paddingVertical: 4, borderRadius: 6, backgroundColor: '#8883' }, | ||
| on: { backgroundColor: '#0969da' }, | ||
| label: { fontSize: 13 }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.