mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +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:
1 parent
5691ea5ae3
commit
ac1f68a447
1 file changed
+23
@@ -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