mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 02:59:01 +08:00
add clearSearch command
This commit is contained in:
parent
d3514c3d36
commit
a42d0113e0
@ -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) : []
|
||||
|
Loading…
Reference in New Issue
Block a user