add clearSearch command

This commit is contained in:
Chrissi2812 2019-05-29 12:25:33 +02:00
parent d3514c3d36
commit a42d0113e0
No known key found for this signature in database
GPG Key ID: B4B82C7E618271DA
2 changed files with 10 additions and 0 deletions

View File

@ -123,6 +123,7 @@
v-model="searchTerm"
>
<button @click="editor.commands.find(searchTerm)">Find</button>
<button @click="editor.commands.clearSearch()">Clear</button>
</div>
</span>

View File

@ -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) : []