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