npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

codemirror-merge-alpinex

v6.10.5

Published

A diff/merge view for CodeMirror

Downloads

19

Readme

@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"
    })
  ]
})

Fork

This Fork fixes undo/redo operation using (invertedEffects pattern)[https://codemirror.net/examples/inverted-effect/]

What's Been Implemented

  1. New StateEffect for Accept Operations acceptChunkEffect: A new StateEffect that tracks chunk accept operations with proper position mapping Stores chunk boundaries, original document state, and the changes being applied
  2. Inverted Effects for Undo Support undoableChunkOperations: Uses invertedEffects.of() to define how accept operations can be undone When undoing an accept operation, it restores the original document state
  3. Updated Accept/Reject Functions acceptChunk: Now uses the acceptChunkEffect instead of directly updating the original document rejectChunk: Remains largely the same since document changes are already undoable by CodeMirror's built-in undo system
  4. Enhanced State Management Updated the originalDoc state field to handle the new accept effects Modified the computeChunks function to properly recompute diffs when accept effects are applied Added the inverted effects extension to the unifiedMergeView extension

How It Works

Accept Operation:

When a user clicks "Accept" on a chunk, it creates an acceptChunkEffect This effect updates the original document and is automatically tracked by the history system The inverse operation (restoring the previous original document state) is stored for undo

Reject Operation:

Directly modifies the current document content (reverting to original) Uses CodeMirror's built-in undo mechanism since it's just a document change

Undo Support:

Undo Accept: Restores the original document to its previous state before the accept Undo Reject: Uses standard document undo to restore the content that was rejected