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

@kelche/codebox

v2.0.1

Published

A fork from dev-juju/Codebox Code syntax highlighting tool for Editor.js

Downloads

8

Readme

CodeBox

This is a Fork of the original codebase. It now supports ReadOnly mode from editor js.

Code syntax highlighting tool for Editor.js

Setup

Install the package via NPM

npm i @kelche/codebox

Add to your module/application

import CodeBox from '@kelche/codebox';
OR
const CodeBox = require('@kelche/codebox');

Usage

Add CodeBox tools property of the CodeX Editor initial config.

const CodexEditor = require('@editorjs/editorjs');

let editor = new CodexEditor({
  ...

  tools: {
    ...
    codeBox: {
      class: CodeBox,
      config: {
        themeURL: 'https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/dracula.min.css', // Optional
        themeName: 'atom-one-dark', // Optional
        useDefaultTheme: 'light' // Optional. This also determines the background color of the language select drop-down
      }
    },
  }

  ...
});

Config Params

All parameters are optional

| Field | Type | Description | | ------------------ | -------- | ------------------------------| | themeURL | string | URL pointing to CSS file that can be used by highlight.js. This could also point o your own custom CSS syntax file. If themeURL is provided, themeName and useDefaultTheme will be ignored | | themeName | string | Any one of the accepted theme names used by highlight.js. Only the name is required, not the full URL (example "a11y-dark"). If themeName is provided, useDefaultTheme will be ignored | | useDefaultTheme | string | CodeBox has 2 default themes - 1 light and 1 dark. You can specify what default should be applied by passing the string 'light' or 'dark' to this parameter. Note that setting themeURL or themeName overrides this setting for the main code block, however, the background of the language select element/dropdown menu is set by this value |

If no parameters are specified, CodeBox defaults to a dark theme.

Output data

CodeBox returns the following data

{
  "type": "codeBox",
  "data": {
    "code": "consttest = newTest();.codeBoxTextArea{\n  width: 100%;\n  min-height: 30px;\n  padding: 10px;\n  border-radius: 2px 2px 2px 0;\n  border: none !important;\n  outline: none !important;\n  font: 14px monospace;\n}\n\n.codeBoxSelectDiv{\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-start;\n  align-items: flex-start;\n  position: relative;\n}",
    "language": "css",
    "theme": "https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/atom-one-dark.min.css"
  }
}

Render saved data as component

If you use react, you can pass your saved data to the library editorjs-react-renderer to render a code block component

import { CodeBoxOutput } from 'editorjs-react-renderer';

const data = {
  "type": "codeBox",
  "data": {
    "code": ".codeBoxTextArea{\n  width: 100%;\n  min-height: 30px;\n  padding: 10px;\n  border-radius: 2px 2px 2px 0;\n  border: none !important;\n  outline: none !important;\n  font: 14px monospace;\n}\n\n.codeBoxSelectDiv{\n  display: flex;\n  flex-direction: column;\n  justify-content: flex-start;\n  align-items: flex-start;\n  position: relative;\n}",
    "language": "css",
    "theme": "https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/atom-one-dark.min.css"
  }
};

const CodeBlock = () => CodeBoxOutput(data);

export default CodeBlock;

Author

Dev Juju

Contact Us

Learn