prosemirror-codemirror-6
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ProseMirror + CodeMirror 6

Based on the example from https://prosemirror.net/examples/codemirror/. This is just an example setup and might not be very reusable. Use this to get something up-and-running quickly.

Tests NPM Version

Getting Started

npm i prosemirror-codemirror-6

Usage

import { EditorView } from 'prosemirror-view';
import { EditorState } from 'prosemirror-state';
import { Schema } from 'prosemirror-model';
import { nodes as basicNodes, marks } from 'prosemirror-schema-basic';
import { CodeMirrorView, node as codeMirrorNode } from 'prosemirror-codemirror-6';
import { minimalSetup } from 'codemirror';
import { javascript } from '@codemirror/lang-javascript';

const nodes = {
  ...basicNodes,
  code_mirror: codeMirrorNode,
};

const schema = new Schema({
  nodes,
  marks,
});

const editor = new EditorView(element, {
  state: EditorState.create({
    schema,
  }),
  nodeViews: {
    code_mirror: (node, view, getPos) =>
      new CodeMirrorView({
        node,
        view,
        getPos,
        cmOptions: {
          extensions: [minimalSetup, javascript()],
        },
      }),
  },
});

Contributing

Install the dependencies

npm install

Start the development server

npm run dev

Related Links

Readme

Keywords

none

Package Sidebar

Install

npm i prosemirror-codemirror-6

Weekly Downloads

116

Version

1.0.1

License

MIT

Unpacked Size

12.6 kB

Total Files

11

Last publish

Collaborators

  • sibiraj-s