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