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

grapesjs-custom-code-monaco-editor

v1.0.12

Published

GrapesJS component for the embed of custom code with Monaco Editor integration

Downloads

137

Readme

GrapesJS Custom Code with Monaco Editor

This plugin adds the possibility to embed custom code using the powerful Monaco Editor (the same editor that powers VS Code)

Features

  • Zero External Dependencies - Monaco Editor loads automatically from CDN
  • Instant Setup - Just add the plugin to GrapesJS and you're ready to go
  • No Manual Configuration - Monaco Editor initializes seamlessly
  • Single Package - Everything you need in one plugin
  • Rich Syntax Highlighting - Support for HTML, CSS, JavaScript, TypeScript, and many more languages
  • IntelliSense - Intelligent code completion, parameter info, quick info, and member lists
  • Themes - Multiple built-in themes (VS Dark, VS Light, High Contrast)
  • Advanced Editing - Multi-cursor support, find and replace, code folding, and more
  • Performance - Optimized for large files and better rendering performance
  • Accessibility - Better screen reader support and keyboard navigation

Requires GrapesJS v0.14.25 or higher

Quick Start

// That's it! Monaco Editor loads automatically
grapesjs.init({
  container: '#gjs',
  plugins: ['grapesjs-custom-code-monaco-editor']
});

Summary

  • Plugin name: grapesjs-custom-code-monaco-editor
  • Components
    • custom-code
  • Blocks
    • custom-code
  • Commands
    • custom-code:open-modal

Options

|Option|Description|Default| |-|-|- | blockCustomCode | Object to extend the default custom code block, eg. { label: 'Custom Code', category: 'Extra', ... }. Pass a falsy value to avoid adding the block | {} | | propsCustomCode | Object to extend the default custom code properties, eg. { name: 'Custom Code', components: '<span>Initial content</span>' ... } | {} | | toolbarBtnCustomCode | Object to extend the default component's toolbar button for the code, eg. { label: '</>', attributes: { title: 'Open custom code' } }. Pass a falsy value to avoid adding the button | {} | | placeholderScript | Content to show when the custom code contains <script> | Check the source | | modalTitle | Title for the modal | Insert your code | | codeViewOptions | Legacy: Additional options for backward compatibility | {} | | monacoOptions | New: Monaco Editor specific options (see below) | { theme: 'vs-dark', language: 'html', ... } | | monacoLoaderOptions | New: Monaco Editor loading configuration | { version: '0.54.0' } | | buttonLabel | Label for the default save button | Save | | commandCustomCode | Object to extend the default custom code command, eg. { getPreContent: () => '<div>Paste here</div>' } Check the source to see all available methods | {} |

Monaco Editor Options

The monacoOptions object accepts all Monaco Editor configuration options:

|Option|Description|Default| |-|-|- | theme | Editor theme: 'vs', 'vs-dark', 'hc-black' | 'vs-dark' | | language | Language mode: 'html', 'css', 'javascript', 'typescript', etc. | 'html' | | readOnly | Whether the editor is read-only | false | | minimap.enabled | Show/hide minimap | false | | lineNumbers | Show line numbers: 'on', 'off', 'relative', 'interval' | 'on' | | wordWrap | Word wrap: 'on', 'off', 'wordWrapColumn', 'bounded' | 'on' | | fontSize | Font size in pixels | 14 | | tabSize | Tab size in spaces | 2 | | automaticLayout | Automatically resize editor | true | | scrollBeyondLastLine | Allow scrolling beyond last line | false |

For complete Monaco Editor options, see the Monaco Editor API documentation.

Monaco Loader Options

The monacoLoaderOptions object controls how Monaco Editor is loaded:

|Option|Description|Default| |-|-|- | version | Monaco Editor version to load from CDN | '0.54.0' | | baseUrl | Custom CDN base URL for Monaco Editor | https://unpkg.com/monaco-editor@{version}/min/vs |

Example:

{
  monacoLoaderOptions: {
    version: '0.50.0',  // Use specific version
    baseUrl: 'https://cdn.jsdelivr.net/npm/[email protected]/min/vs'  // Custom CDN
  }
}

Download

  • CDN
    • https://unpkg.com/grapesjs-custom-code-monaco-editor
  • NPM
    • npm i grapesjs-custom-code-monaco-editor
  • GIT
    • git clone https://github.com/GrapesJS/components-custom-code.git

Usage

CDN Usage (with Monaco Editor)

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/[email protected]/min/vs/loader.js"></script>
<script src="path/to/grapesjs-custom-code-monaco-editor.min.js"></script>

<div id="gjs"></div>

<script type="text/javascript">
  // Configure Monaco Editor
  require.config({ paths: { 'vs': 'https://unpkg.com/[email protected]/min/vs' }});
  
  require(['vs/editor/editor.main'], function() {
    var editor = grapesjs.init({
        container : '#gjs',
        ...
        plugins: ['grapesjs-custom-code-monaco-editor'],
        pluginsOpts: {
          'grapesjs-custom-code-monaco-editor': {
            modalTitle: 'Edit Code with Monaco Editor',
            monacoOptions: {
              theme: 'vs-dark',
              language: 'html',
              readOnly: false,
              minimap: { enabled: true },
              lineNumbers: 'on',
              wordWrap: 'on',
              fontSize: 14,
              tabSize: 2
            }
          }
        }
    });
  });
</script>

ES6/Module Usage

import GrapesJS from 'grapejs';
import customCodePlugin from 'grapesjs-custom-code-monaco-editor';
import * as monaco from 'monaco-editor';

// Configure Monaco Editor (if using webpack/bundler)
self.MonacoEnvironment = {
  getWorkerUrl: function (moduleId, label) {
    if (label === 'json') {
      return './json.worker.js';
    }
    if (label === 'css' || label === 'scss' || label === 'less') {
      return './css.worker.js';
    }
    if (label === 'html' || label === 'handlebars' || label === 'razor') {
      return './html.worker.js';
    }
    if (label === 'typescript' || label === 'javascript') {
      return './ts.worker.js';
    }
    return './editor.worker.js';
  }
};

GrapesJS.init({
 container : '#gjs',
 ...
 plugins: [
   customCodePlugin
 ],
 pluginsOpts: {
   [customCodePlugin]: {
     modalTitle: 'Edit Code with Monaco Editor',
     monacoOptions: {
       theme: 'vs-dark',
       language: 'html',
       readOnly: false,
       minimap: { enabled: true },
       lineNumbers: 'on',
       wordWrap: 'on',
       fontSize: 14,
       tabSize: 2,
       automaticLayout: true,
       scrollBeyondLastLine: false
     }
   }
 }
});

Development

Clone the repository

$ git clone https://github.com/GrapesJS/components-custom-code.git
$ cd grapesjs-custom-code-monaco-editor

Install dependencies

$ npm i

Start the dev server

$ npm start

License

BSD 3-Clause