Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monaco-marker-data-provider

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monaco-marker-data-provider

Provide Monaco marker data in a similar way as other integrations

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
110K
decreased by-35.28%
Maintainers
1
Weekly downloads
 
Created
Source

Monaco marker data provider

ci workflow npm version npm downloads

Provider marker data for Monaco models.

Table of Contents

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.

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

Usage

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 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 © Remco Haszing

Keywords

FAQs

Package last updated on 16 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc