Basic Setup Extensions
Basic configuration for the CodeMirror6 code editor. This is the official basic-setup package fork, making configuration optional.
Install
npm install @uiw/codemirror-extensions-basic-setup --save
Usage
⚠️ Integrated into @uiw/react-codemirror package
import CodeMirror from '@uiw/react-codemirror';
function App() {
return (
<CodeMirror
value="console.log('hello world!');"
height="200px"
basicSetup={{
foldGutter: false,
dropCursor: false,
allowMultipleSelections: false,
indentOnInput: false,
}}
/>
);
}
export default App;
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { basicSetup, minimalSetup } from '@uiw/codemirror-extensions-basic-setup';
const state = EditorState.create({
doc: 'my source code',
extensions: [
basicSetup({
foldGutter: false,
dropCursor: false,
allowMultipleSelections: false,
indentOnInput: false,
}),
],
});
const view = new EditorView({
parent: document.querySelector('#editor'),
state,
});
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
- import { basicSetup, minimalSetup } from 'codemirror';
+ import { basicSetup, minimalSetup } from '@uiw/codemirror-extensions-basic-setup';
const state = EditorState.create({
doc: 'my source code',
extensions: [
- basicSetup
+ basicSetup({
+ foldGutter: false,
+ dropCursor: false,
+ })
],
});
const view = new EditorView({
parent: document.querySelector('#editor'),
state,
});
API
import { Extension } from '@codemirror/state';
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;
tabSize?: number;
}
export declare const basicSetup: (options?: BasicSetupOptions) => Extension[];
export interface MinimalSetupOptions {
highlightSpecialChars?: boolean;
history?: boolean;
drawSelection?: boolean;
syntaxHighlighting?: boolean;
defaultKeymap?: boolean;
historyKeymap?: boolean;
}
export declare const minimalSetup: (options?: MinimalSetupOptions) => Extension[];
Contributors
As always, thanks to our amazing contributors!
Made with github-action-contributors.
License
Licensed under the MIT License.