0.0.14 • Published 9 months ago

@openctx/monaco-editor-extension v0.0.14

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
9 months ago

OpenCtx extension for Monaco Editor

The @openctx/monaco-editor-extension npm package implements a Monaco Editor extension that shows OpenCtx items on files.

Usage

Install it:

npm install @openctx/monaco-editor-extension @openctx/client

Set up an OpenCtx client:

import { createClient } from '@openctx/client'
import { createExtension, makeRange } from '@openctx/monaco-editor-extension'

// Set up a client.
const client = createClient({
  configuration: () =>
    Promise.resolve({
      enable: true,
      providers: {
        'https://openctx.org/npm/@openctx/provider-hello-world': true,
      },
    }),
  makeRange,
  logger: console.error,
})

// Now, get the editor object that refers to the Monaco editor you want to
// extend. Some code calls monaco.editor.create directly, and some code uses
// a wrapper around Monaco.
const editor: monaco.editor.IStandaloneCodeEditor = monaco.editor.create(/* ... */)

// Then create the extension and call it on the Monaco editor object.
const disposable = createExtension(client)(editor)

// Call disposable.dispose() when done to free resources.

Demo

Clone this repository and run pnpm run demo from this directory, then visit http://localhost:5901. See the demo/ dir for source code.

Development

0.0.14

9 months ago

0.0.13

10 months ago

0.0.12

10 months ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago