fix decoration not updating if searching and doc changes

This commit is contained in:
Chrissi2812 2019-05-29 11:05:18 +02:00
parent 036d853378
commit 87995cb93c
No known key found for this signature in database
GPG Key ID: B4B82C7E618271DA

View File

@ -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)