add option to disable regex searches

This commit is contained in:
Chrissi2812 2019-05-29 11:25:26 +02:00
parent 0476d35599
commit 0e5aa7f116
No known key found for this signature in database
GPG Key ID: B4B82C7E618271DA
2 changed files with 5 additions and 2 deletions

View File

@ -175,7 +175,9 @@ export default {
new HardBreak(), new HardBreak(),
new Heading({ levels: [1, 2, 3] }), new Heading({ levels: [1, 2, 3] }),
new HorizontalRule(), new HorizontalRule(),
new Search(), new Search({
disableRegex: false,
}),
new ListItem(), new ListItem(),
new OrderedList(), new OrderedList(),
new TodoItem(), new TodoItem(),

View File

@ -24,6 +24,7 @@ export default class Search extends Extension {
findClass: 'find', findClass: 'find',
searching: false, searching: false,
caseSensitive: false, caseSensitive: false,
disableRegex: true,
} }
} }
@ -103,7 +104,7 @@ export default class Search extends Extension {
find(searchTerm) { find(searchTerm) {
return ({ tr }, dispatch) => { return ({ tr }, dispatch) => {
this.options.searching = true this.options.searching = true
this.searchTerm = searchTerm this.searchTerm = (this.options.disableRegex) ? searchTerm.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') : searchTerm
dispatch(tr) dispatch(tr)
} }