react-codemirror icon indicating copy to clipboard operation
react-codemirror copied to clipboard

Question: Is there any way to control the line number and gutters's showing or hiding?

Open lililo111 opened this issue 3 years ago • 7 comments

There is a scene: I need to hide the editor's line number and gutters, but I don't know how to do with it. If anyone could help will be thankful!

lililo111 avatar May 17 '22 09:05 lililo111

@lililo111 Another official gutter example, you can refer to it.

Gutter: https://codemirror.net/6/examples/gutter/ Example: Zebra Stripes: https://codemirror.net/6/examples/zebra/

jaywcjlove avatar May 21 '22 20:05 jaywcjlove

@jaywcjlove hi, can you please provide an example for react-codemirror? by default, react-codemirror has gutter enabled whereas in the examples you've given are about adding gutters by enabling extensions

tkp-richard avatar Jun 19 '22 04:06 tkp-richard

https://github.com/uiwjs/react-codemirror/blob/29d584077e1f9dc7dad3ebbc4acad9b3d86440ef/core/src/index.tsx#L28-L32

@tkp-richard

jaywcjlove avatar Jun 19 '22 05:06 jaywcjlove

i see. i thought basic setup would mean the barebones instead of the other way around. thanks for the help!

tkp-richard avatar Jun 19 '22 05:06 tkp-richard

@tkp-richard I am extending the API

export interface BasicSetupOptions {
  lineNumbers?: boolean;
  highlightActiveLineGutter?: boolean;
  highlightSpecialChars?: boolean;
  history?: boolean;
  foldGutter?: boolean;
  drawSelection?: boolean;
  dropCursor?: boolean;
  allowMultipleSelections?: boolean;
  indentOnInput?: boolean;
  syntaxHighlighting?: boolean;
  bracketMatching?: boolean;
  closeBrackets?: boolean;
  autocompletion?: boolean;
  rectangularSelection?: boolean;
  crosshairCursor?: boolean;
  highlightActiveLine?: boolean;
  highlightSelectionMatches?: boolean;
}

jaywcjlove avatar Jun 19 '22 05:06 jaywcjlove

that's awesome!

tkp-richard avatar Jun 19 '22 05:06 tkp-richard

@lililo111 @tkp-richard Example: https://codesandbox.io/embed/react-codemirror-example-codemirror-6-forked-hctv1g?fontsize=14&hidenavigation=1&theme=dark

<CodeMirror
  value="console.log('hello world!');"
  height="200px"
  theme="dark"
  basicSetup={{
+    lineNumbers: false
  }}
  extensions={[javascript({ jsx: true })]}
  onChange={(value, viewUpdate) => {
    console.log("value:", value);
  }}
/>

jaywcjlove avatar Jun 19 '22 06:06 jaywcjlove