diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-08-17 21:43:29 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-08-17 21:43:29 +0200 |
commit | bb900e1bd40a6b7efd7a538114d985ea7f7e3e88 (patch) | |
tree | bb15a937ade92313dc654a640bc1de925442eff2 /subprojects/frontend/src/editor/SearchPanel.ts | |
parent | refactor(frondend): improve editor store and theme (diff) | |
download | refinery-bb900e1bd40a6b7efd7a538114d985ea7f7e3e88.tar.gz refinery-bb900e1bd40a6b7efd7a538114d985ea7f7e3e88.tar.zst refinery-bb900e1bd40a6b7efd7a538114d985ea7f7e3e88.zip |
feat(frontend): custom search panel
Also improves editor styling (to enable panel styling).
Diffstat (limited to 'subprojects/frontend/src/editor/SearchPanel.ts')
-rw-r--r-- | subprojects/frontend/src/editor/SearchPanel.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/subprojects/frontend/src/editor/SearchPanel.ts b/subprojects/frontend/src/editor/SearchPanel.ts new file mode 100644 index 00000000..c9df41b7 --- /dev/null +++ b/subprojects/frontend/src/editor/SearchPanel.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { | ||
2 | type EditorView, | ||
3 | type Panel, | ||
4 | runScopeHandlers, | ||
5 | } from '@codemirror/view'; | ||
6 | |||
7 | import type SearchPanelStore from './SearchPanelStore'; | ||
8 | |||
9 | export default class SearchPanel implements Panel { | ||
10 | readonly dom: HTMLDivElement; | ||
11 | |||
12 | constructor(view: EditorView, store: SearchPanelStore) { | ||
13 | this.dom = document.createElement('div'); | ||
14 | this.dom.id = store.id; | ||
15 | this.dom.className = store.panelClass; | ||
16 | this.dom.addEventListener( | ||
17 | 'keydown', | ||
18 | (event) => { | ||
19 | if (runScopeHandlers(view, event, 'search-panel')) { | ||
20 | event.preventDefault(); | ||
21 | } | ||
22 | }, | ||
23 | { | ||
24 | capture: true, | ||
25 | }, | ||
26 | ); | ||
27 | } | ||
28 | |||
29 | get top(): boolean { | ||
30 | return true; | ||
31 | } | ||
32 | } | ||