From 87995cb93c46b358b589a16cccbba488c96dd05e Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Wed, 29 May 2019 11:05:18 +0200 Subject: [PATCH] fix decoration not updating if searching and doc changes --- packages/tiptap-extensions/src/extensions/Search.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/tiptap-extensions/src/extensions/Search.js b/packages/tiptap-extensions/src/extensions/Search.js index 2603968e9..0ccbb9e38 100644 --- a/packages/tiptap-extensions/src/extensions/Search.js +++ b/packages/tiptap-extensions/src/extensions/Search.js @@ -99,17 +99,16 @@ export default class Search extends Extension { } find(searchTerm) { - return ({ doc, tr }, dispatch) => { + return ({ tr }, dispatch) => { this.options.searching = true this.searchTerm = searchTerm - this._search(doc) - dispatch(tr) } } createDeco(doc) { + this._search(doc) return this.decorations ? DecorationSet.create(doc, this.decorations) : [] } @@ -117,7 +116,7 @@ export default class Search extends Extension { return [ new Plugin({ state: { - init: (_, { doc }) => this.createDeco(doc), + init() { return DecorationSet.empty }, apply: (tr, old) => { if (this.options.searching) { return this.createDeco(tr.doc)