mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
Escape key clears search highlights in documents (#11847)
When navigating to a document from search results, the search term is highlighted via FindAndReplace but the popover is not open, so there was no way to dismiss the highlights. This adds an Escape key binding to the FindAndReplace extension that clears highlights when active. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,29 @@ export default class FindAndReplaceExtension extends Extension {
|
||||
};
|
||||
}
|
||||
|
||||
keys(): Record<string, Command> {
|
||||
return {
|
||||
Escape: (state, dispatch) => {
|
||||
if (!this.searchTerm) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (params.has("q")) {
|
||||
params.delete("q");
|
||||
const search = params.toString();
|
||||
window.history.replaceState(
|
||||
window.history.state,
|
||||
"",
|
||||
window.location.pathname + (search ? `?${search}` : "")
|
||||
);
|
||||
}
|
||||
|
||||
return this.clear()(state, dispatch);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public commands() {
|
||||
return {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user