New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@calumk/editorjs-codecup

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@calumk/editorjs-codecup

Codecup, for EditorJS

latest
Source
npmnpm
Version
1.3.0
Version published
Weekly downloads
313
-50.24%
Maintainers
0
Weekly downloads
 
Created
Source

EditorJs - CodeCup

NPM

npm i @calumk/editorjs-codecup

JS

https://cdn.jsdelivr.net/npm/@calumk/editorjs-codecup@latest

About

This is an EditorJs wrapper for CodeCup - A lovely lightweight zero-dep code formatter

It was built to be an improvement on :

Demo

Demo

Built with:

Installation / Use

import EditorJS from '@editorjs/editorjs';
import editorjsCodecup from '@calumk/editorjs-codecup';

var editor = new EditorJS({
  // ...
  tools: {
    ...
    code : editorjsCodecup
  },
});

Language Selection

The plugin provides two ways to handle language selection:

  • Free-form Language Input: By default (when no languages are configured), users can enter any valid Prism.js language key through a text input.

  • Predefined Language Dropdown: When you provide a languages configuration, users can select from a predefined list of languages through a dropdown menu.

You can configure the language selection behavior using these options:

Predefined Languages

Provide a custom mapping of Prism.js language keys to their display names:

var editor = new EditorJS({
  // ...
  tools: {
    code: {
      class: editorJsCodeCup,
      config: {
        languages: { 
          javascript: "JavaScript",
          python: "Python",
          java: "Java",
          cpp: "C++",
          csharp: "C#",
          go: "Go",
          none: "Plain Text",
        }
      } 
    }
  },
});

Force Show Language Input

If you want to allow both predefined language selection AND free-form language input, use the forceShowLanguageInput option:

var editor = new EditorJS({
  // ...
  tools: {
    code: {
      class: editorJsCodeCup,
      config: {
        languages: { 
          javascript: "JavaScript",
          python: "Python",
          // ... other languages
        },
        forceShowLanguageInput: true // Shows both dropdown and language input
      } 
    }
  },
});

Refer to Prism.js supported languages for the available language mappings.

Data Format

The data imported/exported from the block is as follows:

NameDescription
codeThe code that is displayed in the editor, with line breaks
language (optional)The programming language
showlinenumbers (optional)Will show/hide the line numbers (Default true)
showCopyButton (optional)Will show/hide the copy button (Default true)

Since language and linenumbers are optional, existing code blocks can safley use this plugin

Contributing

@calumk

@keertyverma

FAQs

Package last updated on 09 Mar 2025

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