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 CodeBlockElement

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

Overview

⚠ DEPRECATED: Plate editor code block UI component with language selection dropdown, copy-to-clipboard, and delete actions. Only imported by the dead PlateMarkdown component. See Heuristic:0xranx_OpenContext_Warning_Deprecated_Plate_Editor.

Description

The CodeBlockElement component in src/ui/src/editor/components/ is a memoized React component that renders a custom code block with a toolbar header containing a language dropdown (from LANG_OPTIONS), a copy button, and a delete button. It uses ReactEditor.findPath to locate the element and editor.tf.setNodes to update the lang attribute. Copy uses writeClipboardText with a 2-second copied state indicator. Delete removes the node and inserts an empty paragraph.

Usage

Import this component in PlateMarkdown.jsx as the render component for code block nodes.

Code Reference

Source Location

Signature

const CodeBlockElement = memo((props) => {
  // props: { attributes, children, element }
})
export default CodeBlockElement;

Import

import CodeBlockElement from './editor/components/CodeBlockElement';

I/O Contract

Inputs

Name Type Required Description
attributes object Yes Plate element attributes
children ReactNode Yes Code content
element object Yes Slate element with lang property

Usage Examples

Register as Plate Plugin Component

import CodeBlockElement from './editor/components/CodeBlockElement';

// In Plate plugin config:
[KEYS.codeBlock, {
  node: { isVoid: false },
  render: { element: CodeBlockElement },
}]

Related Pages

Page Connections

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