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

basic-setup - expose extension config options #663

Closed
x1unix opened this issue Jun 21, 2024 · 3 comments
Closed

basic-setup - expose extension config options #663

x1unix opened this issue Jun 21, 2024 · 3 comments

Comments

@x1unix
Copy link
Contributor

x1unix commented Jun 21, 2024

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
Copy link
Member

@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
Copy link
Contributor Author

x1unix commented Jun 23, 2024

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

@jaywcjlove
Copy link
Member

@x1unix You can give it a try.

if (options.lineNumbers !== false) extensions.push(lineNumbers());

export interface BasicSetupOptions extends MinimalSetupOptions {
lineNumbers?: boolean;
highlightActiveLineGutter?: boolean;
foldGutter?: boolean;
dropCursor?: boolean;
allowMultipleSelections?: boolean;
indentOnInput?: boolean;
bracketMatching?: boolean;
closeBrackets?: boolean;
autocompletion?: boolean;
rectangularSelection?: boolean;
crosshairCursor?: boolean;
highlightActiveLine?: boolean;
highlightSelectionMatches?: boolean;
closeBracketsKeymap?: boolean;
searchKeymap?: boolean;
foldKeymap?: boolean;
completionKeymap?: boolean;
lintKeymap?: boolean;
/**
* Facet for overriding the unit by which indentation happens. Should be a string consisting either entirely of spaces or entirely of tabs. When not set, this defaults to 2 spaces
* https://codemirror.net/docs/ref/#language.indentUnit
* @default 2
*/
tabSize?: number;
}

export interface MinimalSetupOptions {
highlightSpecialChars?: boolean;
history?: boolean;
drawSelection?: boolean;
syntaxHighlighting?: boolean;
defaultKeymap?: boolean;
historyKeymap?: boolean;
}

@x1unix x1unix closed this as completed Jun 25, 2024
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