Implementation:0xranx OpenContext CodeBlockElement
| 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
- Repository: 0xranx_OpenContext
- File: src/ui/src/editor/components/CodeBlockElement.jsx
- Lines: 1-187
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 },
}]