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
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 944,559 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
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.