add clearSearch command
This commit is contained in:
@@ -123,6 +123,7 @@
|
||||
v-model="searchTerm"
|
||||
>
|
||||
<button @click="editor.commands.find(searchTerm)">Find</button>
|
||||
<button @click="editor.commands.clearSearch()">Clear</button>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ export default class Search extends Extension {
|
||||
commands() {
|
||||
return {
|
||||
find: attrs => this.find(attrs),
|
||||
clearSearch: () => this.clear(),
|
||||
toggleSearch: () => this.toggleSearch(),
|
||||
}
|
||||
}
|
||||
@@ -111,6 +112,14 @@ export default class Search extends Extension {
|
||||
}
|
||||
}
|
||||
|
||||
clear() {
|
||||
return ({ tr }, dispatch) => {
|
||||
this.searchTerm = null
|
||||
|
||||
dispatch(tr)
|
||||
}
|
||||
}
|
||||
|
||||
createDeco(doc) {
|
||||
this._search(doc)
|
||||
return this.decorations ? DecorationSet.create(doc, this.decorations) : []
|
||||
|
||||
Reference in New Issue
Block a user