orcasvn-react-diagrams
v0.2.12
Published
Diagram editor library with a Konva-backed editor (`createDiagramEditor`) and an engine-only API (`createDiagramEngine`).
Readme
orcasvn-react-diagrams
Diagram editor library with a Konva-backed editor (createDiagramEditor) and an engine-only API (createDiagramEngine).
Install
npm install orcasvn-react-diagramsNode engine for this repository/toolchain: >=20.17.0 <21.0.0.
Quick Start
import { createDiagramEditor } from 'orcasvn-react-diagrams';
const editor = createDiagramEditor({
container: document.getElementById('diagram-root') as HTMLDivElement,
width: 960,
height: 600,
initialState: { elements: [], ports: [], links: [], texts: [] },
});
editor.addElement({
id: 'node-1',
position: { x: 80, y: 80 },
size: { width: 160, height: 100 },
shapeId: 'default',
});Release Highlights (v0.2.12)
- Includes all completed
v0.2.1throughv0.2.11work, plusv0.2.12updates. v0.2.12link labels via owned text:- create a link label with
addText({ ..., ownerId: linkId }) - link-owned text is stored midpoint-relative, so labels stay attached when the link reroutes or endpoints move
- no separate
LinkData.labelorLinkData.labelsfield is required
- create a link label with
v0.2.12link-created target port customization:createDiagramEditor({ onCreateLinkTargetPort })lets hosts shape auto-created destination ports for link-to-element completion- the callback runs for both pointer drag and programmatic
completeLinkToElement(...), inpreviewandcommitphases elementLinkConnectingremains the cancellation surface; the callback customizes the target-port draft only
API Docs
- Human-first docs index:
docs/INDEX.md - API contract:
docs/API_CONTRACT.md - State invariants:
docs/STATE_INVARIANTS.md - Integration:
docs/INTEGRATION_PLAYBOOK.md
Machine-readable docs shipped in npm package:
ai/manifest.jsonai/api-contract.jsonai/invariants.json
UNPKG examples:
https://unpkg.com/orcasvn-react-diagrams@<version>/ai/manifest.jsonhttps://unpkg.com/orcasvn-react-diagrams@<version>/docs/INDEX.md
Node subpath export:
orcasvn-react-diagrams/ai-manifest
External Drag And Drop
const world = editor.clientToWorld(
{ x: event.clientX, y: event.clientY },
stageContainer
);
editor.addElement({
id,
position: { x: world.x - width / 2, y: world.y - height / 2 },
size: { width, height },
shapeId,
});Scripts (Repository Development)
npm start: run demo app.npm run start-doc: serveanalysis/.npm test: run tests (watch mode).npm run typecheck: run TypeScript checks.npm run build: CRA build tobuild/.npm run rollup-build-lib: library build todist/.
