Implementation:0xranx OpenContext IdeaRefBlock
| Knowledge Sources | |
|---|---|
| Domains | Editor, Cross_Referencing |
| Last Updated | 2026-10-24 12:00 GMT |
Overview
Concrete tool for rendering idea thread references as visual blocks within the Tiptap markdown editor, displaying thread entries with timeline styling.
Description
The IdeaRefBlock is a Tiptap custom Node that renders `oc://idea/` references as visual reference blocks in the document editor. It is an atom node (non-editable, but selectable) that displays:
- A thread header with entry count and date
- A timeline of entries with AI/user visual distinction
- Each entry's content, images, and relative timestamps
- Inline rendering of `oc://doc/` and `oc://idea/` references within entries as reference cards
The node attributes are: `threadId`, `date`, and `entries` (a JSON-encoded array of entry objects).
The `renderHTML` method produces a `div.idea-ref` element with `data-thread-id`, `data-date`, and `data-entries` attributes. The rendering logic includes timeline lines, colored balls (AI vs user), and reference card components for embedded links.
Usage
- Document editing: When users insert idea references into documents, the Tiptap editor renders them as visual blocks.
- Cross-referencing: Displays idea thread content inline within documents for context.
- Editor integration: Registered as a Tiptap extension in the TiptapMarkdown editor.
Code Reference
Source Location
- Repository: OpenContext
- File: src/ui/src/editor/tiptap/IdeaRefBlock.js
- File (URL builder): src/ui/src/utils/ideaRef.js
Signature
import { Node } from '@tiptap/core';
const IdeaRefBlock = Node.create({
name: 'ideaRefBlock',
group: 'block',
atom: true,
selectable: true,
draggable: false,
addAttributes() {
return {
threadId: { default: '' },
date: { default: '' },
entries: { default: '[]' },
};
},
parseHTML() {
return [{
tag: 'div.idea-ref',
getAttrs: (node) => ({
threadId: node.getAttribute('data-thread-id') || '',
date: node.getAttribute('data-date') || '',
entries: node.getAttribute('data-entries') || '[]',
}),
}];
},
renderHTML({ node }) { ... },
});
Import
import { IdeaRefBlock } from './editor/tiptap/IdeaRefBlock';
// Register with Tiptap editor:
const editor = new Editor({
extensions: [
StarterKit,
IdeaRefBlock,
// ... other extensions
],
});
I/O Contract
Node Attributes
| Name | Type | Default | Description |
|---|---|---|---|
| threadId | string | Idea thread ID | |
| date | string | Thread date | |
| entries | string | '[]' | JSON-encoded array of entry objects |
Entry Object (within entries JSON)
| Name | Type | Description |
|---|---|---|
| entry.id | string | Entry UUID |
| entry.content | string | Entry text content |
| entry.createdAt | string | ISO timestamp |
| entry.isAI | boolean | Whether AI-generated |
| entry.images | string[] | Base64 image data |
Usage Examples =
Register in Tiptap Editor
import { useEditor } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import { IdeaRefBlock } from './editor/tiptap/IdeaRefBlock';
function MyEditor() {
const editor = useEditor({
extensions: [StarterKit, IdeaRefBlock],
content: '<div class="idea-ref" data-thread-id="abc-123" data-date="2025-12-11" data-entries="[]"></div>',
});
return <EditorContent editor={editor} />;
}
Rendered HTML Structure
<!-- The IdeaRefBlock renders as: -->
<div class="idea-ref not-prose" data-idea-href="oc://idea/abc-123?date=2025-12-11"
data-thread-id="abc-123" data-date="2025-12-11" data-entries="[...]">
<div class="entry-row">
<div class="left-col">
<span class="line-top"></span>
<span class="line-bottom"></span>
<span class="ball user"></span>
</div>
<div class="entry-right">
<div class="entry-header">
<div class="entry-body">
<div class="entry-text">Entry content here...</div>
</div>
<div class="entry-meta">2 hours ago</div>
</div>
</div>
</div>
<!-- More entries... -->
</div>