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

[Feature request]: migrate to react-codemirror #1212

Open
bpoulaindev opened this issue Dec 12, 2023 · 7 comments
Open

[Feature request]: migrate to react-codemirror #1212

bpoulaindev opened this issue Dec 12, 2023 · 7 comments

Comments

@bpoulaindev
Copy link
Contributor

Migrate to react-codemirror instead of codemirror
This would provide a react component, better suited for a react app instead of building the component through a function
The current component is 300+ lines long and is getting harder and harder to maintain
Linked issue : #1029

@Its-treason
Copy link
Member

Sounds like a good idea, this would also upgrade code-mirror to Version 6.

There are also some weird workarounds for code-mirror and Next.js Server-Side-Rendering:

function SafeHydrate({ children }) {
return <div suppressHydrationWarning>{typeof window === 'undefined' ? null : children}</div>;
}
function NoSsr({ children }) {
const SERVER_RENDERED = typeof navigator === 'undefined';
if (SERVER_RENDERED) {
return null;
}
return <>{children}</>;
}

const SERVER_RENDERED = typeof navigator === 'undefined' || global['PREVENT_CODEMIRROR_RENDER'] === true;
if (!SERVER_RENDERED) {
require('codemirror/mode/javascript/javascript');
require('codemirror/mode/xml/xml');
require('codemirror/mode/sparql/sparql');
require('codemirror/addon/comment/comment');
require('codemirror/addon/dialog/dialog');
require('codemirror/addon/edit/closebrackets');
require('codemirror/addon/edit/matchbrackets');
require('codemirror/addon/fold/brace-fold');
require('codemirror/addon/fold/foldgutter');
require('codemirror/addon/fold/xml-fold');
require('codemirror/addon/hint/javascript-hint');
require('codemirror/addon/hint/show-hint');
require('codemirror/addon/lint/lint');
require('codemirror/addon/lint/javascript-lint');
require('codemirror/addon/lint/json-lint');
require('codemirror/addon/mode/overlay');
require('codemirror/addon/scroll/simplescrollbars');
require('codemirror/addon/search/jump-to-line');
require('codemirror/addon/search/search');
require('codemirror/addon/search/searchcursor');
require('codemirror/keymap/sublime');
require('codemirror-graphql/hint');
require('codemirror-graphql/info');
require('codemirror-graphql/jump');
require('codemirror-graphql/lint');
require('codemirror-graphql/mode');
require('utils/codemirror/brunoVarInfo');
}

Maybe we can also think about moving from Next.js to Vite or something like this, because we are not using any Next.js features.

@bpoulaindev
Copy link
Contributor Author

You're right @Its-treason , Next JS is better suited for SSR and SEO optimization, Vite would be lighter and faster, hence its name

@bpoulaindev
Copy link
Contributor Author

I know the Typescript debate isn't settled yet, but i'de like to point out, this component would really benefit from having explicit types :
image

@bpoulaindev
Copy link
Contributor Author

Trying out something, the following basic code can already provide the following render :

image image

@bpoulaindev
Copy link
Contributor Author

Progress has been made :
image

Could use a bit more styling in the search component, about 20 themes are available, this isn't the definitive one for dark mode. We could also include, in the future, the possibility for users to switch between all of those 20 mods.

@dan1xk
Copy link
Contributor

dan1xk commented Jan 26, 2024

Is there a possibility for this feature to resolve this? #1347

@bpoulaindev
Copy link
Contributor Author

@dan1xk Absolutely, i ended up using Monaco Editor, here's the PR : Monaco Editor

@sanjai0py sanjai0py added the enhancement New feature or request label Jul 3, 2024
@helloanoop helloanoop added module-code and removed enhancement New feature or request labels Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants