Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@tiptap/extension-code-block-lowlight
Advanced tools
@tiptap/extension-code-block-lowlight is an extension for the Tiptap editor that provides syntax highlighting for code blocks using the Lowlight library. It allows developers to easily integrate code block syntax highlighting into their Tiptap-based rich text editors.
Basic Code Block with Syntax Highlighting
This code sample demonstrates how to set up a Tiptap editor with the CodeBlockLowlight extension to enable syntax highlighting for JavaScript code blocks.
const { Editor } = require('@tiptap/core');
const CodeBlockLowlight = require('@tiptap/extension-code-block-lowlight');
const lowlight = require('lowlight');
const editor = new Editor({
extensions: [
CodeBlockLowlight.configure({ lowlight })
],
content: '<pre><code class="language-js">console.log("Hello, world!")</code></pre>'
});
Custom Language Support
This code sample shows how to register a custom language (XML in this case) with Lowlight and use it in the Tiptap editor for syntax highlighting.
const { Editor } = require('@tiptap/core');
const CodeBlockLowlight = require('@tiptap/extension-code-block-lowlight');
const lowlight = require('lowlight');
const xml = require('highlight.js/lib/languages/xml');
lowlight.registerLanguage('xml', xml);
const editor = new Editor({
extensions: [
CodeBlockLowlight.configure({ lowlight })
],
content: '<pre><code class="language-xml"><note><to>Tove</to></note></code></pre>'
});
Dynamic Language Switching
This code sample demonstrates how to dynamically change the language of a code block in the Tiptap editor using the CodeBlockLowlight extension.
const { Editor } = require('@tiptap/core');
const CodeBlockLowlight = require('@tiptap/extension-code-block-lowlight');
const lowlight = require('lowlight');
const editor = new Editor({
extensions: [
CodeBlockLowlight.configure({ lowlight })
],
content: '<pre><code class="language-js">console.log("Hello, world!")</code></pre>'
});
// Dynamically change the language of a code block
editor.commands.setCodeBlockLanguage('language-python');
Prism is a lightweight, extensible syntax highlighter. It is a popular choice for syntax highlighting in web applications and can be used with various editors. Unlike @tiptap/extension-code-block-lowlight, Prism is not specifically designed for Tiptap but can be integrated with it.
Highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. Similar to Lowlight, it supports a wide range of languages and is highly configurable. It can be used with Tiptap through custom extensions.
CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code and comes with built-in syntax highlighting. While it is a full-fledged code editor, it can be integrated with Tiptap for advanced code editing features.
Tiptap is a headless wrapper around ProseMirror – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as New York Times, The Guardian or Atlassian.
Documentation can be found on the Tiptap website.
Tiptap is open sourced software licensed under the MIT license.
FAQs
code block extension for tiptap
The npm package @tiptap/extension-code-block-lowlight receives a total of 145,882 weekly downloads. As such, @tiptap/extension-code-block-lowlight popularity was classified as popular.
We found that @tiptap/extension-code-block-lowlight demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.