Merge view for CodeMirror
  • TypeScript 100%
Find a file
2026-04-15 11:35:43 +02:00
src Never drop chunks after the last updated range 2026-03-11 09:46:11 +01:00
test Never drop chunks after the last updated range 2026-03-11 09:46:11 +01:00
.gitignore Initial commit 2022-10-27 17:07:49 +02:00
.npmignore Initial commit 2022-10-27 17:07:49 +02:00
CHANGELOG.md Mark version 6.12.1 2026-03-11 09:50:40 +01:00
LICENSE Update maintainer email 2023-01-24 08:20:09 +01:00
package.json Update github links 2026-04-15 11:35:43 +02:00
README.md Update github links 2026-04-15 11:35:43 +02:00

@codemirror/merge NPM version

[ WEBSITE | DOCS | ISSUES | FORUM | CHANGELOG ]

This package implements a merge interface for the CodeMirror code editor.

The project page has more information, a number of examples and the documentation.

This code is released under an MIT license.

We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.

Usage

A split merge view can be created like this:

import {MergeView} from "@codemirror/merge"
import {EditorView, basicSetup} from "codemirror"
import {EditorState} from "@codemirror/state"

let doc = `one
two
three
four
five`

const view = new MergeView({
  a: {
    doc,
    extensions: basicSetup
  },
  b: {
    doc: doc.replace(/t/g, "T") + "\nSix",
    extensions: [
      basicSetup,
      EditorView.editable.of(false),
      EditorState.readOnly.of(true)
    ]
  },
  parent: document.body
})

Or a unified view like this:

import {EditorView, basicSetup} from "codemirror"
import {unifiedMergeView} from "@codemirror/merge"

const view = new EditorView({
  parent: document.body,
  doc: "one\ntwo\nthree\nfour",
  extensions: [
    basicSetup,
    unifiedMergeView({
      original: "one\n...\nfour"
    })
  ]
})