mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
fix: Search term highlights missing (#12598)
This commit is contained in:
@@ -604,13 +604,26 @@ export default class FindAndReplaceExtension extends Extension<FindAndReplaceOpt
|
|||||||
return {
|
return {
|
||||||
update: (view) => {
|
update: (view) => {
|
||||||
const generation = pluginKey.getState(view.state) as number;
|
const generation = pluginKey.getState(view.state) as number;
|
||||||
if (generation !== lastGeneration) {
|
// Rebuild highlights when the results change (generation bump) or,
|
||||||
|
// while a search is active, on any view update. The CSS Custom
|
||||||
|
// Highlight API relies on static DOM ranges that become detached
|
||||||
|
// when the editor re-renders its DOM — e.g. content settling after
|
||||||
|
// sync when navigating from search results, collaboration cursors,
|
||||||
|
// or node views mounting — none of which bump the generation. This
|
||||||
|
// keeps the highlights tracking the live DOM, as decorations do.
|
||||||
|
if (generation !== lastGeneration || this.searchTerm) {
|
||||||
lastGeneration = generation;
|
lastGeneration = generation;
|
||||||
this.updateHighlights();
|
this.updateHighlights();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroy: () => {
|
destroy: () => {
|
||||||
this.clearHighlights();
|
// The highlight registry is global and keyed by fixed names, so
|
||||||
|
// only tear down highlights when this editor actually owns an
|
||||||
|
// active search — otherwise an unmounting editor could wipe the
|
||||||
|
// highlights another editor just set during a route transition.
|
||||||
|
if (this.searchTerm) {
|
||||||
|
this.clearHighlights();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user