# monaco-marker-data-provider

> Provide Monaco marker data in a similar way as other integrations

Latest version **1.2.5** (published 2026-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install monaco-marker-data-provider
pnpm add monaco-marker-data-provider
yarn add monaco-marker-data-provider
bun add monaco-marker-data-provider
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.2.5 |
| Published | 2026-01-02 |
| First published | 2022-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 18 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4 |
| Author | Remco Haszing |
| Maintainers | remcohaszing |
| Keywords | diagnostics, monaco, monaco-editor, marker-data |

## Links

- npm: https://www.npmjs.com/package/monaco-marker-data-provider
- Repository: https://github.com/remcohaszing/monaco-marker-data-provider
- Homepage: https://github.com/remcohaszing/monaco-marker-data-provider#readme
- Issues: https://github.com/remcohaszing/monaco-marker-data-provider/issues
- Funding: https://github.com/sponsors/remcohaszing
- npm.io page: https://npm.io/package/monaco-marker-data-provider

## Dependencies (1)

- [monaco-types](https://npm.io/package/monaco-types.md) ^0.1.0

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 1.2.5 (latest) — 2026-01-02
- 1.2.4 — 2024-10-11
- 1.2.3 — 2024-06-28
- 1.2.2 — 2024-04-16
- 1.2.1 — 2024-04-16
- 1.1.1 — 2022-08-18
- 1.1.0 — 2022-05-27
- 1.0.0 — 2022-04-07

## README

# Monaco marker data provider

[![ci workflow](https://github.com/remcohaszing/monaco-marker-data-provider/actions/workflows/ci.yaml/badge.svg)](https://github.com/remcohaszing/monaco-marker-data-provider/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/remcohaszing/monaco-marker-data-provider/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/monaco-marker-data-provider)
[![npm version](https://img.shields.io/npm/v/monaco-marker-data-provider)](https://www.npmjs.com/package/monaco-marker-data-provider)
[![npm downloads](https://img.shields.io/npm/dm/monaco-marker-data-provider)](https://www.npmjs.com/package/monaco-marker-data-provider)

Provider marker data for Monaco models.

## Table of Contents

- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
  - [`registerMarkerDataProvider(monaco, languageId, provider)`](#registermarkerdataprovidermonaco-languageid-provider)
- [Types](#types)
  - [`MarkerDataProvider`](#markerdataprovider)
  - [`MarkerDataProviderInstance`](#markerdataproviderinstance)
- [License](#license)

## Introduction

Monaco editor supports marker data to highlight parts of a document using squiggly lines. This is
analogous to diagnostics in the language server protocol. Monaco editor itself only supports this
through the `editor.setModelMarkers` function. This allows users to set marker data even if a file
isn’t open. This is useful for situations where a change in one file may lead to a marker data
change in another. However, in many cases models don’t depend on each other to determine marker
data. This is where `monaco-marker-data-provider` comes in. It exposes an API to set model markers
using a provider, in a similar fashion as other Monaco providers.

## Installation

This project has a peer dependency on `monaco-editor`. It’s recommended to add it explicitly.

```sh
npm install monaco-editor monaco-marker-data-provider
```

## Usage

```typescript
import * as monaco from 'monaco-editor'
import { registerMarkerDataProvider } from 'monaco-marker-data-provider'

import { myCustomValidator } from './myCustomValidator'

registerMarkerDataProvider(monaco, 'plaintext', {
  owner: 'my-custom-markers',

  provideMarkerData(model) {
    return myCustomValidator(model.getValue())
  }
})
```

## API

### `registerMarkerDataProvider(monaco, languageId, provider)`

This function returns a disposable.

#### Options

- `monaco`: The `monaco-editor` module instance.
- `languageId` (`string`): The language id to register the provider for.
- `provider` (`MarkerDataProvider`): The object which provides Monaco marker data.

#### Returns

A [`MarkerDataProviderInstance`](#markerdataproviderinstance) instance

## Types

### `MarkerDataProvider`

An object with the following properties:

- `owner`: A unique string to determine the owner of the marker data. This may be used to retrieve
  the marker data using `editor.getModelMarkers(owner)`.
- `provideMarkerData`: A function which provides marker data for the given model. It must return
  `null`, `undefined`, a list of marker data, or a promise that returns those values.
- `doReset`: An optional function to perform a reset after a model has been removed.

### `MarkerDataProviderInstance`

A disposable with the following properties:

- `revalidate`: A function to revalidate all models.

## License

[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)

---
_Source: https://npm.io/package/monaco-marker-data-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
