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 🙏

© 2024 – Pkg Stats / Ryan Hefner

monaco-theme-converter

v0.0.9

Published

An easy way to use vscode theme in monaco-editor.

Downloads

12

Readme

monaco-theme-converter

An easy way to use vscode theme in monaco-editor based on monaco-vscode-api.

Supported Language & Theme

Language

  • C
  • Go
  • C#
  • C++
  • CSS
  • PHP
  • Java
  • Rust
  • JSON
  • HTML
  • Python
  • JavaScript
  • TypeScript

Theme

  • VS
  • VS Dark
  • Moonlight
  • Ariake Dark
  • Vitesse Dark
  • Atom One Dark
  • Atom One Light

Usage

Basic Usage

Before

import * as monaco from 'monaco-editor'

const editor = monaco.editor.create(
  document.getElementById('app'),
  {
    language: 'javascript',
    value: 'function foo() {}',
    automaticLayout: true,
    minimap: {
      enabled: false,
    },
  },
)

After

In comparison to the native approach, apart from the distinction in calling the API to create an editor, there is another difference. createEditor supports the provision of a third parameter, which is used to specify the path for supplying language and theme resources. When you are using a specific language or theme, this library will fetch resources from the address you provided.

import createEditor from 'monaco-theme-converter'

const { editor, setTheme } = createEditor(
  document.getElementById('app'),
  {
    language: 'javascript',
    value: 'function foo() {}',
    automaticLayout: true,
    // rewrite types of theme that you can use to set default vscode theme
    theme: 'AtomOneDark',
    minimap: {
      enabled: false,
    },
  },
  {
    domain: 'danzzzz.netlify.app',
    path: '/resources',
  },
)

// or use setTheme API
setTheme('VSDark')

In the above code, you can see that the domain is danzzzz.netlify.app and the path is /resources. This indicates that when using the java(e.g.) language, resources will be fetched from

  • https://danzzzz.netlify.app/resources/java/java.configuration.json
  • https://danzzzz.netlify.app/resources/java/java.tmLanguage.json

For theme resource

  • https://danzzzz.netlify.app/resources/themes/theme-defaults~atom_one_dark.json

Where are these resources?

You can find tested resources in here, and you only need to upload the resources to your server, and when calling createEditor, pass in the server's domain name and resource path.

How to use other theme that not included in this library?

Step1

Open your Visual Studio Code, use Shift + command + p shortcut to open the command panel, select Developer: Generate Color Theme From Current Settings

Step2

After step1, you could see the current color settings, and remember to remove the comments,

Step3

Save the current color settings and name it like theme-defaults~[themeName].json and upload the file to your server like https://example.com/resources/themes/theme-defaults~[themeName].json

Step4

Using the customized theme named in step3

import createEditor, { ThemesEnum } from 'monaco-theme-converter'

const { setTheme } = createEditor(
  document.getElementById('app'),
  {
    // set customized theme as default theme
    theme: 'CustomTheme' as ThemesEnum
  },
  {
    domain: 'example.com',
    path: '/resources',
    themes: [
      {
        // theme file name on your server
        filename: [themeName],
        // Actually used when using setTheme
        theme: 'CustomTheme',
        baseTheme: 'vs-dark' | 'vs'
      },
      ...
    ]
  }
)

// or using setTheme API
// setTheme('CustomTheme' as ThemesEnum)

When you want to use your customized theme, you can use setTheme('CustomTheme') or to set CustomTheme as default theme in the second parameter.