Socket
Socket
Sign inDemoInstall

@tiptap/extension-code-block-lowlight

Package Overview
Dependencies
Maintainers
4
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/extension-code-block-lowlight

code block extension for tiptap


Version published
Weekly downloads
140K
increased by0.22%
Maintainers
4
Weekly downloads
 
Created

Package description

What is @tiptap/extension-code-block-lowlight?

@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.

What are @tiptap/extension-code-block-lowlight's main functionalities?

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');

Other packages similar to @tiptap/extension-code-block-lowlight

Changelog

Source

2.2.6 (2024-04-06)

Bug Fixes

  • unexpected renderText() for contentful nodes (#3410) (d6c71a8)

Readme

Source

@tiptap/extension-code-block-lowlight

Version Downloads License Sponsor

Introduction

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.

Official Documentation

Documentation can be found on the Tiptap website.

License

Tiptap is open sourced software licensed under the MIT license.

Keywords

FAQs

Package last updated on 06 Apr 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc