Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@tiptap/extension-code-block
Advanced tools
@tiptap/extension-code-block is an extension for the Tiptap editor that allows you to add and manage code blocks within your rich text editor. It provides functionality for syntax highlighting, code formatting, and more, making it easier to work with code snippets in a text editor.
Basic Code Block
This feature allows you to add a basic code block to your Tiptap editor. The code sample shows how to import and use the CodeBlock extension in a Tiptap editor instance.
import { CodeBlock } from '@tiptap/extension-code-block';
const editor = new Editor({
extensions: [
CodeBlock,
],
});
Syntax Highlighting
This feature enables syntax highlighting for code blocks. The code sample demonstrates how to configure the CodeBlock extension with the 'lowlight' library to provide syntax highlighting.
import { CodeBlock } from '@tiptap/extension-code-block';
import { lowlight } from 'lowlight';
const editor = new Editor({
extensions: [
CodeBlock.configure({
lowlight,
}),
],
});
Custom Language Support
This feature allows you to add support for custom languages in your code blocks. The code sample shows how to register a custom language (JavaScript in this case) with the 'lowlight' library and configure the CodeBlock extension to use it.
import { CodeBlock } from '@tiptap/extension-code-block';
import { lowlight } from 'lowlight';
import javascript from 'highlight.js/lib/languages/javascript';
lowlight.registerLanguage('javascript', javascript);
const editor = new Editor({
extensions: [
CodeBlock.configure({
lowlight,
}),
],
});
Prism is a lightweight, extensible syntax highlighter. It is a standalone library that can be used to highlight code blocks in any web application. Compared to @tiptap/extension-code-block, Prism is more focused on syntax highlighting and does not provide rich text editing capabilities.
Highlight.js is a popular library for syntax highlighting. It automatically detects the language of the code block and applies the appropriate highlighting. While it is similar to the syntax highlighting feature of @tiptap/extension-code-block, Highlight.js is a standalone library and does not integrate with rich text editors like Tiptap.
CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code and comes with a wide range of features including syntax highlighting, autocompletion, and more. Unlike @tiptap/extension-code-block, CodeMirror is a full-fledged code editor rather than an extension for a rich text editor.
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 receives a total of 810,432 weekly downloads. As such, @tiptap/extension-code-block popularity was classified as popular.
We found that @tiptap/extension-code-block 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.