Gathering detailed insights and metrics for react-codemirror-merge
Gathering detailed insights and metrics for react-codemirror-merge
Gathering detailed insights and metrics for react-codemirror-merge
Gathering detailed insights and metrics for react-codemirror-merge
CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
npm install react-codemirror-merge
Typescript
Module System
Node Version
NPM Version
TypeScript (92.87%)
HTML (4.1%)
JavaScript (2.08%)
CSS (0.95%)
Total Downloads
488,373
Last Day
536
Last Week
11,925
Last Month
47,898
Last Year
364,685
MIT License
1,939 Stars
954 Commits
148 Forks
7 Watchers
11 Branches
58 Contributors
Updated on Jul 05, 2025
Minified
Minified + Gzipped
Latest Version
4.24.0
Package Id
react-codemirror-merge@4.24.0
Unpacked Size
58.13 kB
Size
9.31 kB
File Count
27
NPM Version
10.8.2
Node Version
20.19.2
Published on
Jul 05, 2025
Cumulative downloads
Total Downloads
Last Day
11.4%
536
Compared to previous day
Last Week
-15.4%
11,925
Compared to previous week
Last Month
23.9%
47,898
Compared to previous month
Last Year
196.9%
364,685
Compared to previous year
CodeMirror merge view for React.
1npm install react-codemirror-merge --save
1import CodeMirrorMerge from 'react-codemirror-merge'; 2import { EditorView } from 'codemirror'; 3import { EditorState } from '@codemirror/state'; 4 5const Original = CodeMirrorMerge.Original; 6const Modified = CodeMirrorMerge.Modified; 7let doc = `one 8two 9three 10four 11five`; 12 13export const Example = () => { 14 return ( 15 <CodeMirrorMerge orientation="b-a"> 16 <Original value={doc} /> 17 <Modified 18 value={doc.replace(/t/g, 'T') + 'Six'} 19 extensions={[EditorView.editable.of(false), EditorState.readOnly.of(true)]} 20 /> 21 </CodeMirrorMerge> 22 ); 23};
1import { useState } from 'react'; 2import CodeMirrorMerge from 'react-codemirror-merge'; 3import { EditorView } from 'codemirror'; 4import { EditorState } from '@codemirror/state'; 5 6const Original = CodeMirrorMerge.Original; 7const Modified = CodeMirrorMerge.Modified; 8let doc = `one 9two 10three 11four 12five`; 13 14export const Example = () => { 15 const [theme, setTheme] = useState('light'); 16 return ( 17 <CodeMirrorMerge orientation="b-a" theme={theme}> 18 <Original value={doc} /> 19 <Modified 20 value={doc.replace(/t/g, 'T') + 'Six'} 21 extensions={[EditorView.editable.of(false), EditorState.readOnly.of(true)]} 22 /> 23 </CodeMirrorMerge> 24 ); 25};
1import React, { useState } from 'react'; 2import CodeMirrorMerge from 'react-codemirror-merge'; 3import { EditorView } from '@codemirror/view'; 4import { javascript } from '@codemirror/lang-javascript'; 5import { githubLight, githubDark } from '@uiw/codemirror-theme-github'; 6 7const Original = CodeMirrorMerge.Original; 8const Modified = CodeMirrorMerge.Modified; 9let doc = `function examle() { 10 11}`; 12 13function Example() { 14 const [theme, setTheme] = useState('light'); 15 return ( 16 <div> 17 <CodeMirrorMerge theme={theme === 'light' ? githubLight : githubDark} orientation="a-b"> 18 <Original extensions={[javascript({ jsx: true }), EditorView.lineWrapping]} value={doc} /> 19 <Modified extensions={[EditorView.lineWrapping, javascript({ jsx: true })]} value={doc.replace(/e/g, 'T')} /> 20 </CodeMirrorMerge> 21 <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>Change Theme {theme}</button> 22 </div> 23 ); 24}
1import { Extension } from '@codemirror/state'; 2export interface CodeMirrorMergeRef extends InternalRef {} 3export interface CodeMirrorMergeProps extends React.HTMLAttributes<HTMLDivElement>, MergeConfig { 4 theme?: 'light' | 'dark' | 'none' | Extension; 5} 6 7interface MergeConfig { 8 /** 9 Controls whether editor A or editor B is shown first. Defaults 10 to `"a-b"`. 11 */ 12 orientation?: 'a-b' | 'b-a'; 13 /** 14 Controls whether revert controls are shown between changed 15 chunks. 16 */ 17 revertControls?: 'a-to-b' | 'b-to-a'; 18 /** 19 When given, this function is called to render the button to 20 revert a chunk. 21 */ 22 renderRevertControl?: () => HTMLElement; 23 /** 24 By default, the merge view will mark inserted and deleted text 25 in changed chunks. Set this to false to turn that off. 26 */ 27 highlightChanges?: boolean; 28 /** 29 Controls whether a gutter marker is shown next to changed lines. 30 */ 31 gutter?: boolean; 32 /** 33 When given, long stretches of unchanged text are collapsed. 34 `margin` gives the number of lines to leave visible after/before 35 a change (default is 3), and `minSize` gives the minimum amount 36 of collapsible lines that need to be present (defaults to 4). 37 */ 38 collapseUnchanged?: { 39 margin?: number; 40 minSize?: number; 41 }; 42}
1interface ModifiedProps extends Omit<DefaultExtensionsOptions, 'theme'> { 2 /** 3 The initial document. Defaults to an empty document. Can be 4 provided either as a plain string (which will be split into 5 lines according to the value of the [`lineSeparator` 6 facet](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)), or an instance of 7 the [`Text`](https://codemirror.net/6/docs/ref/#state.Text) class (which is what the state will use 8 to represent the document). 9 */ 10 value?: string | Text; 11 /** 12 The starting selection. Defaults to a cursor at the very start 13 of the document. 14 */ 15 selection?: 16 | EditorSelection 17 | { 18 anchor: number; 19 head?: number; 20 }; 21 /** 22 [Extension(s)](https://codemirror.net/6/docs/ref/#state.Extension) to associate with this state. 23 */ 24 extensions?: Extension; 25 /** Fired whenever a change occurs to the document. */ 26 onChange?(value: string, viewUpdate: ViewUpdate): void; 27} 28 29import { Extension } from '@codemirror/state'; 30import { BasicSetupOptions } from '@uiw/codemirror-extensions-basic-setup'; 31import { DefaultExtensionsOptions } from '@uiw/react-codemirror'; 32 33export interface DefaultExtensionsOptions { 34 indentWithTab?: boolean; 35 basicSetup?: boolean | BasicSetupOptions; 36 placeholder?: string | HTMLElement; 37 theme?: 'light' | 'dark' | 'none' | Extension; 38 readOnly?: boolean; 39 editable?: boolean; 40}
1interface OriginalProps extends Omit<DefaultExtensionsOptions, 'theme'> { 2 /** 3 The initial document. Defaults to an empty document. Can be 4 provided either as a plain string (which will be split into 5 lines according to the value of the [`lineSeparator` 6 facet](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)), or an instance of 7 the [`Text`](https://codemirror.net/6/docs/ref/#state.Text) class (which is what the state will use 8 to represent the document). 9 */ 10 value?: string | Text; 11 /** 12 The starting selection. Defaults to a cursor at the very start 13 of the document. 14 */ 15 selection?: 16 | EditorSelection 17 | { 18 anchor: number; 19 head?: number; 20 }; 21 /** 22 [Extension(s)](https://codemirror.net/6/docs/ref/#state.Extension) to associate with this state. 23 */ 24 extensions?: Extension; 25 /** Fired whenever a change occurs to the document. */ 26 onChange?(value: string, viewUpdate: ViewUpdate): void; 27} 28 29import { Extension } from '@codemirror/state'; 30import { BasicSetupOptions } from '@uiw/codemirror-extensions-basic-setup'; 31import { DefaultExtensionsOptions } from '@uiw/react-codemirror'; 32 33export interface DefaultExtensionsOptions { 34 indentWithTab?: boolean; 35 basicSetup?: boolean | BasicSetupOptions; 36 placeholder?: string | HTMLElement; 37 theme?: 'light' | 'dark' | 'none' | Extension; 38 readOnly?: boolean; 39 editable?: boolean; 40}
As always, thanks to our amazing contributors!
Made with github-action-contributors.
Licensed under the MIT License.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
12 commit(s) and 6 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 10/30 approved changesets -- score normalized to 3
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More