mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-06 02:17:49 +08:00
add option to disable regex searches
This commit is contained in:
parent
0476d35599
commit
0e5aa7f116
@ -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(),
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user