From a42d0113e02b8bb4685fd9b00dcec82710d95638 Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Wed, 29 May 2019 12:25:33 +0200 Subject: [PATCH] add clearSearch command --- examples/Components/Routes/Search/index.vue | 1 + packages/tiptap-extensions/src/extensions/Search.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/examples/Components/Routes/Search/index.vue b/examples/Components/Routes/Search/index.vue index 4974ad796..6c2bd4a70 100644 --- a/examples/Components/Routes/Search/index.vue +++ b/examples/Components/Routes/Search/index.vue @@ -123,6 +123,7 @@ v-model="searchTerm" > + diff --git a/packages/tiptap-extensions/src/extensions/Search.js b/packages/tiptap-extensions/src/extensions/Search.js index e76c5e3be..6b026767d 100644 --- a/packages/tiptap-extensions/src/extensions/Search.js +++ b/packages/tiptap-extensions/src/extensions/Search.js @@ -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) : []