Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xranx OpenContext Tiptap CodeBlockComponent

From Leeroopedia
Knowledge Sources
Domains Editor, React
Last Updated 2026-10-24 00:00 GMT

Overview

Tiptap NodeView component for code blocks with a language selector dropdown, language alias normalization, and highlight.js decorations.

Description

The CodeBlockComponent.jsx in src/ui/src/editor/tiptap/ is a React NodeView component for the Tiptap code block node. It renders a language dropdown with 27 language options and alias normalization (e.g., js→javascript, py→python). When the editor is editable and a raw language differs from its normalized form, it auto-updates the node attribute. The component uses NodeViewWrapper and NodeViewContent from @tiptap/react.

Usage

Import this component and register it as the NodeView for the code block extension in the Tiptap editor configuration.

Code Reference

Source Location

Signature

function TiptapCodeBlockComponent({ node, updateAttributes, editor })
export default memo(TiptapCodeBlockComponent);

Import

import TiptapCodeBlockComponent from './editor/tiptap/CodeBlockComponent';

I/O Contract

Inputs

Name Type Required Description
node object Yes Tiptap node with attrs.language
updateAttributes Function Yes Tiptap attribute updater
editor Editor Yes Tiptap editor instance

Usage Examples

Registering with CodeBlock Extension

import CodeBlock from '@tiptap/extension-code-block';
import TiptapCodeBlockComponent from './editor/tiptap/CodeBlockComponent';

const CustomCodeBlock = CodeBlock.extend({
  addNodeView() {
    return ReactNodeViewRenderer(TiptapCodeBlockComponent);
  }
});

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment