uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.63k stars 129 forks source link

basic-setup - expose extension config options #663

Closed x1unix closed 3 months ago

x1unix commented 3 months ago

A lot of extensions used in @uiw/codemirror-extensions-basic-setup support configuration, for example lineNumbers extension.

This is useful when some extra event handler needs to be defined for gutter or in any other customisation case. Can you please update BasicSetupOptions to accept them?

Thanks.

jaywcjlove commented 3 months ago

@x1unix I think the following method is simpler, won't increase complexity, and won't increase the size.

<CodeMirror
  value="console.log('hello world!');"
  height="200px"
  basicSetup={{
    lineNumbers: false
  }}
  extensions={[
    lineNumbers({
      ///...
    })
  ]}
/>
x1unix commented 3 months ago

@jaywcjlove will including extension that already present in basic setup work?

jaywcjlove commented 3 months ago

@x1unix You can give it a try. https://github.com/uiwjs/react-codemirror/blob/e94e34c1393c64610b5d1424ab730065d75a05ce/extensions/basic-setup/src/index.ts#L120

https://github.com/uiwjs/react-codemirror/blob/e94e34c1393c64610b5d1424ab730065d75a05ce/extensions/basic-setup/src/index.ts#L29-L55

https://github.com/uiwjs/react-codemirror/blob/e94e34c1393c64610b5d1424ab730065d75a05ce/extensions/basic-setup/src/index.ts#L144-L152