Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating the Query Editror #105

Open
hco opened this issue Jan 20, 2025 · 1 comment
Open

Integrating the Query Editror #105

hco opened this issue Jan 20, 2025 · 1 comment

Comments

@hco
Copy link

hco commented Jan 20, 2025

Hey there 👋 ,
I'm currently integrating jora into my application.
I'd like to have a editor with syntax highlighting and preferably even code completion, so I had a look if I could integrate the query editor into my application, without integrating everything from discovery, but I failed to find a way.

Is that possible? 🤔
Can you give me a few pointers on how to achieve this? Or do you know if someone else did this? Then I could have a look how they achieved it.

@lahmatiy
Copy link
Member

@hco You can use the QueryEditor class from the Discovery package:

import { views } from '@discoveryjs/discovery';

const { QueryEditor } = views;
const queryEditor = new QueryEditor();

This class is a wrapper around CodeMirror and is loosely coupled with Discovery itself. However, it’s not intended for use outside of Discovery, so you may need to create your own wrapper and adjust the styles as needed.

I’ve experimented with integrating Discovery as a widget, which you can find here: https://observablehq.com/d/a46b8ad842d5f687 (just updated to the latest Discovery.js version). The widget injects an editor with suggestions (there’s a known issue with the popup display). See the struct function for details:

Image

I plan to add this as a view in Discovery and make it easier to integrate outside of Discovery. However, this has a low priority, and there’s no ETA at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants