(props)
| 63 | // We usually ignore changes to `value` to prevent unnecessary `view.setState` calls |
| 64 | externalValue: string |
| 65 | }> = (props) => { |
| 66 | let ref!: HTMLDivElement |
| 67 | onMount(() => { |
| 68 | const [theme] = useThemeContext() |
| 69 | const view = new EditorView({ |
| 70 | parent: ref, |
| 71 | }) |
| 72 | createEffect( |
| 73 | on(theme, (t) => { |
| 74 | view.setState(createEditorState(view, props.value, t, props.setValue)) |
| 75 | }), |
| 76 | ) |
| 77 | createEffect( |
| 78 | on( |
| 79 | () => props.externalValue, |
| 80 | (v) => { |
| 81 | view.setState(createEditorState(view, v, theme(), props.setValue)) |
| 82 | }, |
| 83 | ), |
| 84 | ) |
| 85 | onCleanup(() => { |
| 86 | view.destroy() |
| 87 | }) |
| 88 | }) |
| 89 | return <div class='query-editor max-h-40 flex-1 overflow-auto' ref={ref} /> |
| 90 | } |
| 91 | |
| 92 | export default QueryEditor |
| 93 |
nothing calls this directly
no test coverage detected