Is there a way to have a minimal setup, because switching to v6 has increased the total bundle size by 50kB (total is now 850kB)
Maybe it’s possible to replace basicSetup and ‘codemirror’ dependency by other things and lower the size.
I don’t need features like autocompletion, if that can help
If not, it’s not much an issue, no worry
import { useEffect, useState, useRef } from 'react';
import { basicSetup } from 'codemirror';
import { EditorView, keymap } from '@codemirror/view';
import { indentWithTab } from '@codemirror/commands';
function Editor({ value, onChange, placeholder, ...props }) {
const ref = useRef();
useEffect(() => {
new EditorView({
doc: value || placeholder,
extensions: [
basicSetup,
EditorView.lineWrapping,
keymap.of([indentWithTab]),
EditorView.updateListener.of(({ state }) => {
onChange(state.doc.text?.join('\n'));
}),
// + possibly javascript() or markdown() extensions
],
parent: ref.current
});
}, []);
return <div ref={ref} {...props} />;
}