aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor/SearchPanel.ts
blob: b63d5eed4c8df08072f841b5cc09cdcf11f55669 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */

import {
  type EditorView,
  type Panel,
  runScopeHandlers,
} from '@codemirror/view';

import type SearchPanelStore from './SearchPanelStore';

export default class SearchPanel implements Panel {
  readonly dom: HTMLDivElement;

  constructor(view: EditorView, store: SearchPanelStore) {
    this.dom = document.createElement('div');
    this.dom.id = store.id;
    this.dom.className = store.panelClass;
    this.dom.addEventListener(
      'keydown',
      (event) => {
        if (runScopeHandlers(view, event, 'search-panel')) {
          event.preventDefault();
        }
      },
      {
        capture: true,
      },
    );
  }

  get top(): boolean {
    return true;
  }
}