
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
@bomdi/codebox
Advanced tools
Code syntax highlighting tool for Editor.js
Install the package via NPM
npm i @bomdi/codebox
Add to your module/application
import CodeBox from '@bomdi/codebox';
OR
const CodeBox = require('@bomdi/codebox');
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/cdn-release@9.18.1/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
}
},
}
...
});
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.
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/cdn-release@9.18.1/build/styles/atom-one-dark.min.css"
}
}
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/cdn-release@9.18.1/build/styles/atom-one-dark.min.css"
}
};
const CodeBlock = () => CodeBoxOutput(data);
export default CodeBlock;
Dev Juju
FAQs
Code syntax highlighting tool for Editor.js
The npm package @bomdi/codebox receives a total of 765 weekly downloads. As such, @bomdi/codebox popularity was classified as not popular.
We found that @bomdi/codebox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.