@pixerate/editor-react 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation-editor/index.cjs +192 -0
- package/dist/animation-editor/index.cjs.map +1 -0
- package/dist/animation-editor/index.d.cts +61 -0
- package/dist/animation-editor/index.d.ts +61 -0
- package/dist/animation-editor/index.js +162 -0
- package/dist/animation-editor/index.js.map +1 -0
- package/dist/canvas/index.cjs +515 -355
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +56 -3
- package/dist/canvas/index.d.ts +56 -3
- package/dist/canvas/index.js +176 -15
- package/dist/canvas/index.js.map +1 -1
- package/package.json +11 -3
package/dist/canvas/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { AgentPresence } from '@pixerate/editor/agent';
|
|
4
4
|
import * as _pixerate_editor_canvas from '@pixerate/editor/canvas';
|
|
5
|
-
import { CanvasNode, CanvasEdge, IncrementalLayoutOptions, XYPosition, GraphDifferences, Rect, CanvasLayoutOptions, Side, PlaceBesideOptions, getCenteredNodePosition, CanvasDockingCallbacks, DockStrategy, ExplodeNodeOptions, CollapseNodeOptions, ExplosionSnapshot, ArrangeHistoryTarget, SnapGuidesOptions, NodeRectOptions, AutoLayoutOptions, GuideLine, CanvasArrangeAction, ArrangeShortcutBinding, CanvasScenesOptions, CanvasViewport, CanvasScenesStore, CanvasScene, FitViewportOptions, FreehandTool, FreehandStrokeStyle, FreehandStroke, FreehandDrawOptions, ShapeDescription, AutoLayoutMeasure, CanvasTokenOptions, AnimationHistoryTarget, Clock, AnimationLoopMode, AnimatableProperty, CanvasComponentSyncOptions, CanvasComponentsController, DiagramLayoutOptions, MermaidFlowNode, MermaidFlowEdge, DiagramLayout } from '@pixerate/editor/canvas';
|
|
5
|
+
import { CanvasNode, CanvasEdge, IncrementalLayoutOptions, XYPosition, GraphDifferences, Rect, CanvasLayoutOptions, Side, PlaceBesideOptions, getCenteredNodePosition, CanvasDockingCallbacks, DockStrategy, ExplodeNodeOptions, CollapseNodeOptions, ExplosionSnapshot, ArrangeHistoryTarget, SnapGuidesOptions, NodeRectOptions, AutoLayoutOptions, GuideLine, CanvasArrangeAction, ArrangeShortcutBinding, CanvasScenesOptions, CanvasViewport, CanvasScenesStore, CanvasScene, FitViewportOptions, FreehandTool, FreehandStrokeStyle, FreehandStroke, FreehandDrawOptions, ShapeDescription, AutoLayoutMeasure, CanvasTokenOptions, AnimationHistoryTarget, Clock, AnimationLoopMode, AnimatableProperty, CanvasComponentSyncOptions, CanvasComponentsController, DiagramScene, DiagramLayoutOptions, DiagramSceneTheme, MermaidFlowNode, MermaidFlowEdge, DiagramLayout, DiagramSvgOptions } from '@pixerate/editor/canvas';
|
|
6
6
|
export { ANIMATABLE_PROPERTIES, ANIMATION_DATA_KEY, ANIMATION_EASING_LABELS, ANIMATION_EASING_PRESETS, ANIMATION_TIME_EPSILON, AUTO_LAYOUT_DATA_KEY, AddCanvasVariantOptions, AlignEdge, AnimatableProperty, AnimateNodeOptions, AnimationDocument, AnimationEasing, AnimationEasingPreset, AnimationEditError, AnimationEditErrorCode, AnimationFrame, AnimationHistoryTarget, AnimationKeyframe, AnimationKeyframeClipboard, AnimationLoopMode, AnimationMotionPath, AnimationOverrides, AnimationPlayer, AnimationPlayerOptions, AnimationPlayerState, AnimationTrack, AnimationValue, AnimationValueType, ArrangeShortcutBinding, AutoLayout, AutoLayoutAlignContent, AutoLayoutAlignCross, AutoLayoutAlignMain, AutoLayoutCellAlign, AutoLayoutChild, AutoLayoutConstraints, AutoLayoutGrid, AutoLayoutGridArea, AutoLayoutGridCell, AutoLayoutGridGeometry, AutoLayoutGridTrack, AutoLayoutHorizontalConstraint, AutoLayoutInsertTarget, AutoLayoutMeasure, AutoLayoutMode, AutoLayoutOptions, AutoLayoutPadding, AutoLayoutSize, AutoLayoutSizing, AutoLayoutSizingPair, AutoLayoutVerticalConstraint, BezierCommand, BezierPath, BezierPathInput, CANVAS_COMPONENT_DRAG_TYPE, CANVAS_GRADIENT_PRESETS, CANVAS_TOKEN_PROPERTIES, CHILD_LAYOUT_DATA_KEY, CONNECTION_LINE_TYPES, CSS_ANIMATION_PROPERTIES, CUBIC_BEZIER_PRESETS, CanvasAnimationController, CanvasAnimationControllerOptions, CanvasAnimationState, CanvasArrangeAction, CanvasAutoLayoutController, CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, CanvasComponentInfo, CanvasComponentPropertyDef, CanvasComponentPropertyField, CanvasComponentResult, CanvasComponentSetInfo, CanvasComponentSyncOptions, CanvasComponentsController, CanvasComponentsControllerOptions, CanvasConnectionLineType, CanvasDockingCallbacks, CanvasDrawControllerOptions, CanvasEdge, CanvasGradientDef, CanvasHeightOptions, CanvasInstanceInfo, CanvasLayoutOptions, CanvasLinearGradient, CanvasNode, CanvasNodeUpdate, CanvasRadialGradient, CanvasScene, CanvasScenesState, CanvasScenesStore, CanvasTokenBindingInfo, CanvasTokenOptions, CanvasTokenProperty, CanvasViewport, Clock, CollapseNodeOptions, CombineShapeNodesOptions, CombineShapeNodesRefusal, CombineShapeNodesResult, ConnectorSnap, ConnectorSnapTarget, CssAnimationExport, CssExportOptions, CubicBezierEasing, CubicSegment, DEFAULT_ARRANGE_SHORTCUTS, DirectionalDisplacementOptions, DisplacementDirection, DistributeAxis, DistributeMode, DividePathsResult, DockStrategy, EllipseShape, ExplodeNodeOptions, ExplosionSnapshot, FanOutTrajectoryOptions, FitCubicsOptions, FitPathDataOptions, FlattenOptions, FreehandStroke, FreehandStrokeStyle, FreehandTool, GradientStop, GraphDifferences, GuideIndex, GuideLine, IncrementalLayoutOptions, KeyframeDragState, KeyframePatch, KeyframeRef, KeyframeSnap, MAX_KEYFRAME_REFS, ManualClock, MeasureGuide, MeasureSelectionOptions, MeasureSelectionResult, MultiPolygon, NodeAnimation, NodeTransition, OffsetPathOptions, OffsetShapeNodesOptions, OklabColor, OutlineShapeStrokesOptions, OutlineStrokeOptions, PathBooleanResult, PathCommand, PathOperand, PathOperandInput, PathOpsOptions, PathShape, PlaceBesideOptions, Point, PolygonBooleanOperation, PolygonBooleanOptions, PolygonFillRule, PolygonInput, PolygonOperand, PolygonPiece, PolygonRing, PolygonToPathOptions, PolygonWithHoles, Position, RESIZE_HANDLES, Rect, RectShape, ReflowDisplacementOptions, RegularPolygonShape, ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, SetCanvasVariantPropertiesOptions, ShapeDescription, ShapeKind, ShapeNodePolygonOptions, ShapeOperation, ShapePaint, ShapePathEditOperation, ShapePathEditRefusal, ShapePathEditResult, ShapeRenderData, ShapeSize, Side, SizeDimension, SnapGuidesOptions, SnapNodeResizeOptions, SnapNodeResizeResult, SnapResizeOptions, SnapResizeResult, SnapResult, SpringEasing, StarShape, StrokeCap, StrokeJoin, StrokeToShapeNodeOptions, SvgGradientDef, SvgGradientStop, TOKEN_BINDINGS_DATA_KEY, TOKEN_MODES_DATA_KEY, TimelineKeyframe, TimelineRow, TrajectoryFunction, TrajectoryPoint, WebAnimationSpec, XYPosition, ZOrderOperation, addCanvasVariant, addKeyframesAtTime, alignNodes, angleToSvgLinearCoords, animateNode, applyAnimation, applyAnimationOverrides, applyConstraints, applyNodeUpdates, applyShapeCombination, applyShapeReplacement, bezierPathArea, bezierPathBounds, bezierPathLength, bezierPathPointAtLength, bezierPathSignedArea, bezierPathToSvg, bindCanvasComponentProperty, bindCanvasToken, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canOffsetShapeNodes, canOutlineShapeNodeStrokes, canvasHeight, centerNodes, centre, clampAnimationValue, clampLayoutSize, combineCanvasComponentsAsVariants, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, copyKeyframes, countPathSegments, createAnimationPlayer, createBezierTrajectory, createCanvasAnimationController, createCanvasAutoLayoutController, createCanvasComponent, createCanvasComponentsController, createCanvasDrawController, createCanvasInstance, createCanvasScenesStore, createDefaultStrokeStyle, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicBezierAt, cubicPointAt, cubicsToPathData, dashContours, defaultEasing, deleteKeyframes, detachCanvasInstance, detachTokenBindings, distanceToBezierPath, distributeNodes, dividePaths, dividePolygons, easingFromInfluence, easingLabel, easingToCss, ensureLayout, estimateCanvasHeight, estimateNodeSize, evaluateAnimation, evaluateEasing, evaluateTrack, excludePaths, exportCssAnimation, findConnectorSnap, findStrokesAtPoint, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatAnimationTime, formatOklab, getAbsolutePosition, getAnimatableProperty, getAnimatedProperties, getAnimatedValue, getAnimationDuration, getAnimationTrack, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getBindableTokenProperties, getCanvasComponentDragId, getCanvasTokenProperty, getCenteredNodePosition, getChildLayout, getComponentSourceId, getCssPropertyAnimations, getEffectiveTokenModes, getFlowChildren, getInstanceData, getInstanceStatus, getKeyframeTimes, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNextVariantValues, getNodeAnimation, getNodeOverrides, getNodeRect, getNodeShape, getNodeSize, getNodeTokenBindings, getNodeTokenModes, getResizingNodeRect, getShapeRenderData, getShapeSvg, getTimelineRows, getTimelineTicks, getTokenPropertyScope, getTokensForProperty, gradientToSvgDef, handlePoint, hasVisibleStroke, inferResizeHandle, inspectCanvasInstance, inspectNodeTokens, interpolateAnimationValue, intersectPaths, intersectPolygons, invertNodeUpdates, isAnimationEasing, isAnimationKeyframe, isAutoLayoutFrame, isCanvasComponent, isCanvasComponentSet, isCanvasGradient, isCanvasInstance, isCssExportExact, isEventFromTextInput, isKeyframeSelected, isLocked, isMeasureModifierHeld, isNodeAnimated, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasNode, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, listCanvasComponents, lockNodes, makeSizingCoherent, matchArrangeShortcut, matchSize, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, mixColorsOklab, moveKeyframes, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, normalizeBezierPath, normalizeKeyframes, offsetPath, offsetShapeNodes, oklabToRgb, oppositePosition, outlineShapeNodeStrokes, outlineStroke, overlaps, parseCanvasClipboardData, parseCanvasScenes, parseCssEasing, parseCssGradient, parseKeyframeClipboard, parseOklab, parseSvgPath, pasteKeyframes, pathBoolean, placeBeside, playWebAnimations, pointInBezierPath, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, pruneCanvasTokenModes, pushCanvasInstanceOverrides, readAnimatableValue, readNodeStyleProperty, readStyleSize, realClock, recordAnimationChanges, relayoutUpdates, remapPastedNodes, removeCanvasVariant, removeTrack, renameCanvasVariantProperty, renameCanvasVariantValue, reorderNodes, repositionNodesTo, resetCanvasInstanceOverrides, resizeHandleAxes, resolveCanvasGradient, resolveCanvasTokens, resolveEasing, resolvePadding, restoreCanvasMainComponent, revertShapeCombination, rgbToOklab, ringSignedArea, runMultiNodeTransition, sampleAnimationFrames, scaleKeyframes, serializeCanvasNodes, setCanvasComponentProperty, setCanvasInstanceProperties, setCanvasTokenMode, setCanvasVariantProperties, setKeyframe, setKeyframeEasing, setMotionPath, setTrackEnabled, shapeNodeToBezierPath, shapeNodeToPolygon, shapeToBezierPath, shapeToPolygon, sideToPosition, simplifyRing, snapKeyframeDelta, snapNodeDrag, snapNodeResize, snapResize, snapTimeToFrame, snapToGrid, springAt, streamlinePoints, strokeOutlineRings, strokePointsToPathData, strokeToShapeNode, subtractPaths, subtractPolygons, swapCanvasInstance, syncAllCanvasInstances, syncCanvasComponents, syncCanvasInstance, timeToX, toBezierPath, toWebAnimations, toggleLockNodes, transformBezierPath, unionPolygons, unitePaths, unlockNodes, updateKeyframe, withNodeAnimation, withStyleSize, wouldCreateComponentCycle, wrapAnimationTime, writeNodeStyleProperty, xToTime, xorPolygons } from '@pixerate/editor/canvas';
|
|
7
7
|
import { TokenState, TokenStore, TokenModeContext } from '@pixerate/editor/tokens';
|
|
8
8
|
import { DiagramControllerOptions, DiagramController, DiagramState, MermaidDocument, EditOp, DiagramActionResult, DiagramPlacement, PresenceClock, PresenceStore, DiagramDirector, PresenceState } from '@pixerate/editor/diagram';
|
|
@@ -766,9 +766,39 @@ interface CanvasInstanceInspectorProps<TNode extends CanvasNode = CanvasNode> {
|
|
|
766
766
|
*/
|
|
767
767
|
declare function CanvasInstanceInspector<TNode extends CanvasNode = CanvasNode>({ nodes, nodeId, components, onError, className }: CanvasInstanceInspectorProps<TNode>): React__default.JSX.Element | null;
|
|
768
768
|
|
|
769
|
+
interface MermaidFamilySceneProps {
|
|
770
|
+
/** The family's picture (`useMermaidDiagram().scene`, or `mermaidToScene`). */
|
|
771
|
+
scene: DiagramScene;
|
|
772
|
+
/** Room around the drawing in px (default 16). */
|
|
773
|
+
padding?: number;
|
|
774
|
+
/** Marks with a target get a pointer and report clicks (default true). */
|
|
775
|
+
interactive?: boolean;
|
|
776
|
+
/** A mark was clicked: its node, edge, group or `::title` target (null: the background). */
|
|
777
|
+
onSelect?: (target: string | null, event: React__default.MouseEvent) => void;
|
|
778
|
+
/** A mark was double-clicked (rename it with `diagramRenameOp`). */
|
|
779
|
+
onOpen?: (target: string, event: React__default.MouseEvent) => void;
|
|
780
|
+
/** Colour of selected marks' outline (default `var(--primary, #2563eb)`). */
|
|
781
|
+
selectionColor?: string;
|
|
782
|
+
/** Arrow head colour (default `var(--muted-foreground, #64748b)`). */
|
|
783
|
+
markerColor?: string;
|
|
784
|
+
className?: string;
|
|
785
|
+
style?: React__default.CSSProperties;
|
|
786
|
+
/** Accessible name (default: the family). */
|
|
787
|
+
title?: string;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Headless renderer for a Mermaid family drawn as its own picture (pie, Gantt, sequence,
|
|
791
|
+
* quadrant, timeline, journey, gitGraph, mindmap, C4, architecture, XY and radar charts):
|
|
792
|
+
* one SVG of the scene's marks, sized to the drawing. Clicking a mark selects its node,
|
|
793
|
+
* edge or group; double-clicking opens it for renaming.
|
|
794
|
+
*/
|
|
795
|
+
declare function MermaidFamilyScene({ scene, padding, interactive, onSelect, onOpen, selectionColor, markerColor, className, style, title }: MermaidFamilySceneProps): React__default.JSX.Element;
|
|
796
|
+
|
|
769
797
|
interface UseMermaidDiagramOptions extends DiagramControllerOptions {
|
|
770
798
|
/** Layout spacing and node measuring for new nodes (stored positions always win). */
|
|
771
799
|
layoutOptions?: DiagramLayoutOptions;
|
|
800
|
+
/** Colours for families drawn as scenes (default: the page's CSS colour variables). */
|
|
801
|
+
sceneTheme?: Partial<DiagramSceneTheme>;
|
|
772
802
|
}
|
|
773
803
|
type Placed = {
|
|
774
804
|
id: string;
|
|
@@ -788,6 +818,12 @@ interface UseMermaidDiagramResult {
|
|
|
788
818
|
nodes: MermaidFlowNode[];
|
|
789
819
|
edges: MermaidFlowEdge[];
|
|
790
820
|
layout: DiagramLayout;
|
|
821
|
+
/**
|
|
822
|
+
* The family's own picture (pie, Gantt, sequence, XY, radar…) with the selection marked;
|
|
823
|
+
* null for families drawn as nodes and edges (flowchart, state, class, ER) and text-only
|
|
824
|
+
* ones. Render it with `MermaidFamilyScene`.
|
|
825
|
+
*/
|
|
826
|
+
scene: DiagramScene | null;
|
|
791
827
|
apply: (ops: EditOp | EditOp[], label?: string) => DiagramActionResult;
|
|
792
828
|
/** Replaces the source; `clearHistory` when opening a different diagram. */
|
|
793
829
|
load: (source: string, options?: {
|
|
@@ -799,6 +835,8 @@ interface UseMermaidDiagramResult {
|
|
|
799
835
|
/** Removes nodes / groups (with their edges) and edges by id, as one undo step. */
|
|
800
836
|
remove: (ids: readonly string[]) => DiagramActionResult;
|
|
801
837
|
rename: (id: string, label: string) => DiagramActionResult;
|
|
838
|
+
/** Renames what a scene mark targets: the title (`::title`), a group, an edge or a node. */
|
|
839
|
+
renameTarget: (target: string, label: string) => DiagramActionResult | null;
|
|
802
840
|
select: (ids: readonly string[]) => void;
|
|
803
841
|
undo: () => void;
|
|
804
842
|
redo: () => void;
|
|
@@ -810,7 +848,9 @@ declare function useDiagramState(controller: DiagramController): DiagramState;
|
|
|
810
848
|
* one from options), lays it out and returns canvas nodes and edges with bound edits. Every
|
|
811
849
|
* edit rewrites only the statements it touches; positions go into `%% @pixerate`.
|
|
812
850
|
*/
|
|
813
|
-
declare function useMermaidDiagram(controllerOrOptions?: DiagramController | UseMermaidDiagramOptions
|
|
851
|
+
declare function useMermaidDiagram(controllerOrOptions?: DiagramController | UseMermaidDiagramOptions,
|
|
852
|
+
/** Layout and scene colours when passing a controller (options carry them otherwise). */
|
|
853
|
+
view?: Pick<UseMermaidDiagramOptions, 'layoutOptions' | 'sceneTheme'>): UseMermaidDiagramResult;
|
|
814
854
|
interface UseMermaidStreamOptions extends DiagramLayoutOptions {
|
|
815
855
|
/** True once the whole source has arrived (unconnected nodes are shown then). */
|
|
816
856
|
complete?: boolean;
|
|
@@ -868,6 +908,19 @@ declare function MermaidDiagramNode({ data, width, height, selected, className,
|
|
|
868
908
|
/** Headless Mermaid group (subgraph, composite state, namespace): a titled frame. Register as `mermaid-group`. */
|
|
869
909
|
declare function MermaidDiagramGroup({ data, selected, className, children }: MermaidDiagramNodeProps): React__default.JSX.Element | null;
|
|
870
910
|
|
|
911
|
+
interface MermaidThumbnailProps extends DiagramSvgOptions {
|
|
912
|
+
/** Mermaid text, or an already parsed document. */
|
|
913
|
+
source: string | MermaidDocument;
|
|
914
|
+
className?: string;
|
|
915
|
+
/** Shown for families that cannot be drawn here (sequence, Gantt, …) and empty diagrams. */
|
|
916
|
+
fallback?: React__default.ReactNode;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* A static preview of a flowchart, state, class or ER diagram (no canvas, no Mermaid runtime):
|
|
920
|
+
* `mermaidThumbnailSvg` fitted inside `maxWidth` × `maxHeight` (default 240 × 160).
|
|
921
|
+
*/
|
|
922
|
+
declare function MermaidThumbnail({ source, className, fallback, ...options }: MermaidThumbnailProps): React__default.JSX.Element;
|
|
923
|
+
|
|
871
924
|
interface UseDiagramDirectorOptions {
|
|
872
925
|
/** Where nodes are drawn now, e.g. `() => diagram.layout` from `useMermaidDiagram`. */
|
|
873
926
|
placement: () => DiagramPlacement;
|
|
@@ -902,4 +955,4 @@ interface DiagramPresenceLayerProps {
|
|
|
902
955
|
/** Agent cursors and their notes over a canvas, from a `PresenceStore` (see `DiagramDirector`). */
|
|
903
956
|
declare function DiagramPresenceLayer({ presence, viewport, className }: DiagramPresenceLayerProps): React__default.JSX.Element | null;
|
|
904
957
|
|
|
905
|
-
export { AgentPresenceLayer, type AgentPresenceLayerProps, AnimationTimeline, type AnimationTimelineProps, type CanvasAnimation, type CanvasArrange, type CanvasAutoLayout, type CanvasComponents, CanvasComponentsPanel, type CanvasComponentsPanelActions, type CanvasComponentsPanelProps, type CanvasDraw, type CanvasDrawActions, CanvasDrawLayer, type CanvasDrawLayerProps, type CanvasDrawState, type CanvasGraphTarget, CanvasGuidesLayer, type CanvasGuidesLayerProps, CanvasInstanceInspector, type CanvasInstanceInspectorActions, type CanvasInstanceInspectorProps, type CanvasMeasure, type CanvasScenes, type CanvasTokens, DiagramPresenceLayer, type DiagramPresenceLayerProps, MermaidDiagramGroup, MermaidDiagramNode, type MermaidDiagramNodeData, type MermaidDiagramNodeProps, ShapeNode, type ShapeNodeProps, TokenBindingPicker, type TokenBindingPickerProps, TokenModeSwitcher, type TokenModeSwitcherProps, type UseCanvasAnimationOptions, type UseCanvasArrangeOptions, type UseCanvasArrangeShortcutsOptions, type UseCanvasAutoLayoutOptions, type UseCanvasClipboardOptions, type UseCanvasComponentsOptions, type UseCanvasDockingOptions, type UseCanvasDrawOptions, type UseCanvasGraphOptions, type UseCanvasLayoutOptions, type UseCanvasMeasureOptions, type UseCanvasScenesOptions, type UseCanvasShortcutsOptions, type UseCanvasTokensOptions, type UseDiagramDirectorOptions, type UseMermaidDiagramOptions, type UseMermaidDiagramResult, type UseMermaidStreamOptions, type UseMermaidStreamResult, type UseStreamingCanvasOptions, mermaidNodeStyle, useCanvasAnimation, useCanvasArrange, useCanvasArrangeShortcuts, useCanvasAutoLayout, useCanvasClipboard, useCanvasComponents, useCanvasDocking, useCanvasDraw, useCanvasExplosion, useCanvasGraph, useCanvasLayout, useCanvasMeasure, useCanvasScenes, useCanvasShortcuts, useCanvasTokens, useDiagramDirector, useDiagramState, useMermaidDiagram, useMermaidStream, usePresenceState, useStreamingCanvas };
|
|
958
|
+
export { AgentPresenceLayer, type AgentPresenceLayerProps, AnimationTimeline, type AnimationTimelineProps, type CanvasAnimation, type CanvasArrange, type CanvasAutoLayout, type CanvasComponents, CanvasComponentsPanel, type CanvasComponentsPanelActions, type CanvasComponentsPanelProps, type CanvasDraw, type CanvasDrawActions, CanvasDrawLayer, type CanvasDrawLayerProps, type CanvasDrawState, type CanvasGraphTarget, CanvasGuidesLayer, type CanvasGuidesLayerProps, CanvasInstanceInspector, type CanvasInstanceInspectorActions, type CanvasInstanceInspectorProps, type CanvasMeasure, type CanvasScenes, type CanvasTokens, DiagramPresenceLayer, type DiagramPresenceLayerProps, MermaidDiagramGroup, MermaidDiagramNode, type MermaidDiagramNodeData, type MermaidDiagramNodeProps, MermaidFamilyScene, type MermaidFamilySceneProps, MermaidThumbnail, type MermaidThumbnailProps, ShapeNode, type ShapeNodeProps, TokenBindingPicker, type TokenBindingPickerProps, TokenModeSwitcher, type TokenModeSwitcherProps, type UseCanvasAnimationOptions, type UseCanvasArrangeOptions, type UseCanvasArrangeShortcutsOptions, type UseCanvasAutoLayoutOptions, type UseCanvasClipboardOptions, type UseCanvasComponentsOptions, type UseCanvasDockingOptions, type UseCanvasDrawOptions, type UseCanvasGraphOptions, type UseCanvasLayoutOptions, type UseCanvasMeasureOptions, type UseCanvasScenesOptions, type UseCanvasShortcutsOptions, type UseCanvasTokensOptions, type UseDiagramDirectorOptions, type UseMermaidDiagramOptions, type UseMermaidDiagramResult, type UseMermaidStreamOptions, type UseMermaidStreamResult, type UseStreamingCanvasOptions, mermaidNodeStyle, useCanvasAnimation, useCanvasArrange, useCanvasArrangeShortcuts, useCanvasAutoLayout, useCanvasClipboard, useCanvasComponents, useCanvasDocking, useCanvasDraw, useCanvasExplosion, useCanvasGraph, useCanvasLayout, useCanvasMeasure, useCanvasScenes, useCanvasShortcuts, useCanvasTokens, useDiagramDirector, useDiagramState, useMermaidDiagram, useMermaidStream, usePresenceState, useStreamingCanvas };
|
package/dist/canvas/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { AgentPresence } from '@pixerate/editor/agent';
|
|
4
4
|
import * as _pixerate_editor_canvas from '@pixerate/editor/canvas';
|
|
5
|
-
import { CanvasNode, CanvasEdge, IncrementalLayoutOptions, XYPosition, GraphDifferences, Rect, CanvasLayoutOptions, Side, PlaceBesideOptions, getCenteredNodePosition, CanvasDockingCallbacks, DockStrategy, ExplodeNodeOptions, CollapseNodeOptions, ExplosionSnapshot, ArrangeHistoryTarget, SnapGuidesOptions, NodeRectOptions, AutoLayoutOptions, GuideLine, CanvasArrangeAction, ArrangeShortcutBinding, CanvasScenesOptions, CanvasViewport, CanvasScenesStore, CanvasScene, FitViewportOptions, FreehandTool, FreehandStrokeStyle, FreehandStroke, FreehandDrawOptions, ShapeDescription, AutoLayoutMeasure, CanvasTokenOptions, AnimationHistoryTarget, Clock, AnimationLoopMode, AnimatableProperty, CanvasComponentSyncOptions, CanvasComponentsController, DiagramLayoutOptions, MermaidFlowNode, MermaidFlowEdge, DiagramLayout } from '@pixerate/editor/canvas';
|
|
5
|
+
import { CanvasNode, CanvasEdge, IncrementalLayoutOptions, XYPosition, GraphDifferences, Rect, CanvasLayoutOptions, Side, PlaceBesideOptions, getCenteredNodePosition, CanvasDockingCallbacks, DockStrategy, ExplodeNodeOptions, CollapseNodeOptions, ExplosionSnapshot, ArrangeHistoryTarget, SnapGuidesOptions, NodeRectOptions, AutoLayoutOptions, GuideLine, CanvasArrangeAction, ArrangeShortcutBinding, CanvasScenesOptions, CanvasViewport, CanvasScenesStore, CanvasScene, FitViewportOptions, FreehandTool, FreehandStrokeStyle, FreehandStroke, FreehandDrawOptions, ShapeDescription, AutoLayoutMeasure, CanvasTokenOptions, AnimationHistoryTarget, Clock, AnimationLoopMode, AnimatableProperty, CanvasComponentSyncOptions, CanvasComponentsController, DiagramScene, DiagramLayoutOptions, DiagramSceneTheme, MermaidFlowNode, MermaidFlowEdge, DiagramLayout, DiagramSvgOptions } from '@pixerate/editor/canvas';
|
|
6
6
|
export { ANIMATABLE_PROPERTIES, ANIMATION_DATA_KEY, ANIMATION_EASING_LABELS, ANIMATION_EASING_PRESETS, ANIMATION_TIME_EPSILON, AUTO_LAYOUT_DATA_KEY, AddCanvasVariantOptions, AlignEdge, AnimatableProperty, AnimateNodeOptions, AnimationDocument, AnimationEasing, AnimationEasingPreset, AnimationEditError, AnimationEditErrorCode, AnimationFrame, AnimationHistoryTarget, AnimationKeyframe, AnimationKeyframeClipboard, AnimationLoopMode, AnimationMotionPath, AnimationOverrides, AnimationPlayer, AnimationPlayerOptions, AnimationPlayerState, AnimationTrack, AnimationValue, AnimationValueType, ArrangeShortcutBinding, AutoLayout, AutoLayoutAlignContent, AutoLayoutAlignCross, AutoLayoutAlignMain, AutoLayoutCellAlign, AutoLayoutChild, AutoLayoutConstraints, AutoLayoutGrid, AutoLayoutGridArea, AutoLayoutGridCell, AutoLayoutGridGeometry, AutoLayoutGridTrack, AutoLayoutHorizontalConstraint, AutoLayoutInsertTarget, AutoLayoutMeasure, AutoLayoutMode, AutoLayoutOptions, AutoLayoutPadding, AutoLayoutSize, AutoLayoutSizing, AutoLayoutSizingPair, AutoLayoutVerticalConstraint, BezierCommand, BezierPath, BezierPathInput, CANVAS_COMPONENT_DRAG_TYPE, CANVAS_GRADIENT_PRESETS, CANVAS_TOKEN_PROPERTIES, CHILD_LAYOUT_DATA_KEY, CONNECTION_LINE_TYPES, CSS_ANIMATION_PROPERTIES, CUBIC_BEZIER_PRESETS, CanvasAnimationController, CanvasAnimationControllerOptions, CanvasAnimationState, CanvasArrangeAction, CanvasAutoLayoutController, CanvasAutoLayoutControllerOptions, CanvasClipboardPayload, CanvasComponentInfo, CanvasComponentPropertyDef, CanvasComponentPropertyField, CanvasComponentResult, CanvasComponentSetInfo, CanvasComponentSyncOptions, CanvasComponentsController, CanvasComponentsControllerOptions, CanvasConnectionLineType, CanvasDockingCallbacks, CanvasDrawControllerOptions, CanvasEdge, CanvasGradientDef, CanvasHeightOptions, CanvasInstanceInfo, CanvasLayoutOptions, CanvasLinearGradient, CanvasNode, CanvasNodeUpdate, CanvasRadialGradient, CanvasScene, CanvasScenesState, CanvasScenesStore, CanvasTokenBindingInfo, CanvasTokenOptions, CanvasTokenProperty, CanvasViewport, Clock, CollapseNodeOptions, CombineShapeNodesOptions, CombineShapeNodesRefusal, CombineShapeNodesResult, ConnectorSnap, ConnectorSnapTarget, CssAnimationExport, CssExportOptions, CubicBezierEasing, CubicSegment, DEFAULT_ARRANGE_SHORTCUTS, DirectionalDisplacementOptions, DisplacementDirection, DistributeAxis, DistributeMode, DividePathsResult, DockStrategy, EllipseShape, ExplodeNodeOptions, ExplosionSnapshot, FanOutTrajectoryOptions, FitCubicsOptions, FitPathDataOptions, FlattenOptions, FreehandStroke, FreehandStrokeStyle, FreehandTool, GradientStop, GraphDifferences, GuideIndex, GuideLine, IncrementalLayoutOptions, KeyframeDragState, KeyframePatch, KeyframeRef, KeyframeSnap, MAX_KEYFRAME_REFS, ManualClock, MeasureGuide, MeasureSelectionOptions, MeasureSelectionResult, MultiPolygon, NodeAnimation, NodeTransition, OffsetPathOptions, OffsetShapeNodesOptions, OklabColor, OutlineShapeStrokesOptions, OutlineStrokeOptions, PathBooleanResult, PathCommand, PathOperand, PathOperandInput, PathOpsOptions, PathShape, PlaceBesideOptions, Point, PolygonBooleanOperation, PolygonBooleanOptions, PolygonFillRule, PolygonInput, PolygonOperand, PolygonPiece, PolygonRing, PolygonToPathOptions, PolygonWithHoles, Position, RESIZE_HANDLES, Rect, RectShape, ReflowDisplacementOptions, RegularPolygonShape, ResizeHandle, SHAPE_DATA_KEY, SHAPE_KINDS, SHAPE_NODE_TYPE, SHAPE_OPERATIONS, SetCanvasVariantPropertiesOptions, ShapeDescription, ShapeKind, ShapeNodePolygonOptions, ShapeOperation, ShapePaint, ShapePathEditOperation, ShapePathEditRefusal, ShapePathEditResult, ShapeRenderData, ShapeSize, Side, SizeDimension, SnapGuidesOptions, SnapNodeResizeOptions, SnapNodeResizeResult, SnapResizeOptions, SnapResizeResult, SnapResult, SpringEasing, StarShape, StrokeCap, StrokeJoin, StrokeToShapeNodeOptions, SvgGradientDef, SvgGradientStop, TOKEN_BINDINGS_DATA_KEY, TOKEN_MODES_DATA_KEY, TimelineKeyframe, TimelineRow, TrajectoryFunction, TrajectoryPoint, WebAnimationSpec, XYPosition, ZOrderOperation, addCanvasVariant, addKeyframesAtTime, alignNodes, angleToSvgLinearCoords, animateNode, applyAnimation, applyAnimationOverrides, applyConstraints, applyNodeUpdates, applyShapeCombination, applyShapeReplacement, bezierPathArea, bezierPathBounds, bezierPathLength, bezierPathPointAtLength, bezierPathSignedArea, bezierPathToSvg, bindCanvasComponentProperty, bindCanvasToken, blendLayout, boundsOf, calculateDagreReflowDisplacement, calculateDirectionalDisplacement, canCombineShapeNodes, canOffsetShapeNodes, canOutlineShapeNodeStrokes, canvasHeight, centerNodes, centre, clampAnimationValue, clampLayoutSize, combineCanvasComponentsAsVariants, combineShapeNodes, computeNodesBoundingBox, computeSnapGuides, connectedOnly, copyKeyframes, countPathSegments, createAnimationPlayer, createBezierTrajectory, createCanvasAnimationController, createCanvasAutoLayoutController, createCanvasComponent, createCanvasComponentsController, createCanvasDrawController, createCanvasInstance, createCanvasScenesStore, createDefaultStrokeStyle, createFanOutTrajectory, createGuideIndex, createNodeGuideIndex, cubicBezierAt, cubicPointAt, cubicsToPathData, dashContours, defaultEasing, deleteKeyframes, detachCanvasInstance, detachTokenBindings, distanceToBezierPath, distributeNodes, dividePaths, dividePolygons, easingFromInfluence, easingLabel, easingToCss, ensureLayout, estimateCanvasHeight, estimateNodeSize, evaluateAnimation, evaluateEasing, evaluateTrack, excludePaths, exportCssAnimation, findConnectorSnap, findStrokesAtPoint, fitCubicRun, fitCubics, fitFreehandPath, fitPathData, fitViewportToNodes, fitViewportToRect, flattenSvgPath, flowSide, formatAnimationTime, formatOklab, getAbsolutePosition, getAnimatableProperty, getAnimatedProperties, getAnimatedValue, getAnimationDuration, getAnimationTrack, getAutoLayout, getAutoLayoutGrid, getAutoLayoutInsertTarget, getBindableTokenProperties, getCanvasComponentDragId, getCanvasTokenProperty, getCenteredNodePosition, getChildLayout, getComponentSourceId, getCssPropertyAnimations, getEffectiveTokenModes, getFlowChildren, getInstanceData, getInstanceStatus, getKeyframeTimes, getLayoutParent, getLayoutSizing, getLayoutedNodes, getNextVariantValues, getNodeAnimation, getNodeOverrides, getNodeRect, getNodeShape, getNodeSize, getNodeTokenBindings, getNodeTokenModes, getResizingNodeRect, getShapeRenderData, getShapeSvg, getTimelineRows, getTimelineTicks, getTokenPropertyScope, getTokensForProperty, gradientToSvgDef, handlePoint, hasVisibleStroke, inferResizeHandle, inspectCanvasInstance, inspectNodeTokens, interpolateAnimationValue, intersectPaths, intersectPolygons, invertNodeUpdates, isAnimationEasing, isAnimationKeyframe, isAutoLayoutFrame, isCanvasComponent, isCanvasComponentSet, isCanvasGradient, isCanvasInstance, isCssExportExact, isEventFromTextInput, isKeyframeSelected, isLocked, isMeasureModifierHeld, isNodeAnimated, isShapeDescription, isShapeNode, isStraightCubic, isValidCanvasNode, isValidUrl, layoutAll, layoutBounds, layoutFrame, layoutUp, layoutUpMany, linearPositionTrajectory, linearTrajectory, listCanvasComponents, lockNodes, makeSizingCoherent, matchArrangeShortcut, matchSize, measureBetween, measureLabel, measureSelection, measureToLine, mergeNodeUpdates, mixColorsOklab, moveKeyframes, moveLayoutChild, multiPolygonArea, multiPolygonBounds, nearestHandlePositions, normalizeBezierPath, normalizeKeyframes, offsetPath, offsetShapeNodes, oklabToRgb, oppositePosition, outlineShapeNodeStrokes, outlineStroke, overlaps, parseCanvasClipboardData, parseCanvasScenes, parseCssEasing, parseCssGradient, parseKeyframeClipboard, parseOklab, parseSvgPath, pasteKeyframes, pathBoolean, placeBeside, playWebAnimations, pointInBezierPath, pointInMultiPolygon, pointInRings, polygonArea, polygonBoolean, polygonToSvgPath, positionToSide, pruneCanvasTokenModes, pushCanvasInstanceOverrides, readAnimatableValue, readNodeStyleProperty, readStyleSize, realClock, recordAnimationChanges, relayoutUpdates, remapPastedNodes, removeCanvasVariant, removeTrack, renameCanvasVariantProperty, renameCanvasVariantValue, reorderNodes, repositionNodesTo, resetCanvasInstanceOverrides, resizeHandleAxes, resolveCanvasGradient, resolveCanvasTokens, resolveEasing, resolvePadding, restoreCanvasMainComponent, revertShapeCombination, rgbToOklab, ringSignedArea, runMultiNodeTransition, sampleAnimationFrames, scaleKeyframes, serializeCanvasNodes, setCanvasComponentProperty, setCanvasInstanceProperties, setCanvasTokenMode, setCanvasVariantProperties, setKeyframe, setKeyframeEasing, setMotionPath, setTrackEnabled, shapeNodeToBezierPath, shapeNodeToPolygon, shapeToBezierPath, shapeToPolygon, sideToPosition, simplifyRing, snapKeyframeDelta, snapNodeDrag, snapNodeResize, snapResize, snapTimeToFrame, snapToGrid, springAt, streamlinePoints, strokeOutlineRings, strokePointsToPathData, strokeToShapeNode, subtractPaths, subtractPolygons, swapCanvasInstance, syncAllCanvasInstances, syncCanvasComponents, syncCanvasInstance, timeToX, toBezierPath, toWebAnimations, toggleLockNodes, transformBezierPath, unionPolygons, unitePaths, unlockNodes, updateKeyframe, withNodeAnimation, withStyleSize, wouldCreateComponentCycle, wrapAnimationTime, writeNodeStyleProperty, xToTime, xorPolygons } from '@pixerate/editor/canvas';
|
|
7
7
|
import { TokenState, TokenStore, TokenModeContext } from '@pixerate/editor/tokens';
|
|
8
8
|
import { DiagramControllerOptions, DiagramController, DiagramState, MermaidDocument, EditOp, DiagramActionResult, DiagramPlacement, PresenceClock, PresenceStore, DiagramDirector, PresenceState } from '@pixerate/editor/diagram';
|
|
@@ -766,9 +766,39 @@ interface CanvasInstanceInspectorProps<TNode extends CanvasNode = CanvasNode> {
|
|
|
766
766
|
*/
|
|
767
767
|
declare function CanvasInstanceInspector<TNode extends CanvasNode = CanvasNode>({ nodes, nodeId, components, onError, className }: CanvasInstanceInspectorProps<TNode>): React__default.JSX.Element | null;
|
|
768
768
|
|
|
769
|
+
interface MermaidFamilySceneProps {
|
|
770
|
+
/** The family's picture (`useMermaidDiagram().scene`, or `mermaidToScene`). */
|
|
771
|
+
scene: DiagramScene;
|
|
772
|
+
/** Room around the drawing in px (default 16). */
|
|
773
|
+
padding?: number;
|
|
774
|
+
/** Marks with a target get a pointer and report clicks (default true). */
|
|
775
|
+
interactive?: boolean;
|
|
776
|
+
/** A mark was clicked: its node, edge, group or `::title` target (null: the background). */
|
|
777
|
+
onSelect?: (target: string | null, event: React__default.MouseEvent) => void;
|
|
778
|
+
/** A mark was double-clicked (rename it with `diagramRenameOp`). */
|
|
779
|
+
onOpen?: (target: string, event: React__default.MouseEvent) => void;
|
|
780
|
+
/** Colour of selected marks' outline (default `var(--primary, #2563eb)`). */
|
|
781
|
+
selectionColor?: string;
|
|
782
|
+
/** Arrow head colour (default `var(--muted-foreground, #64748b)`). */
|
|
783
|
+
markerColor?: string;
|
|
784
|
+
className?: string;
|
|
785
|
+
style?: React__default.CSSProperties;
|
|
786
|
+
/** Accessible name (default: the family). */
|
|
787
|
+
title?: string;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Headless renderer for a Mermaid family drawn as its own picture (pie, Gantt, sequence,
|
|
791
|
+
* quadrant, timeline, journey, gitGraph, mindmap, C4, architecture, XY and radar charts):
|
|
792
|
+
* one SVG of the scene's marks, sized to the drawing. Clicking a mark selects its node,
|
|
793
|
+
* edge or group; double-clicking opens it for renaming.
|
|
794
|
+
*/
|
|
795
|
+
declare function MermaidFamilyScene({ scene, padding, interactive, onSelect, onOpen, selectionColor, markerColor, className, style, title }: MermaidFamilySceneProps): React__default.JSX.Element;
|
|
796
|
+
|
|
769
797
|
interface UseMermaidDiagramOptions extends DiagramControllerOptions {
|
|
770
798
|
/** Layout spacing and node measuring for new nodes (stored positions always win). */
|
|
771
799
|
layoutOptions?: DiagramLayoutOptions;
|
|
800
|
+
/** Colours for families drawn as scenes (default: the page's CSS colour variables). */
|
|
801
|
+
sceneTheme?: Partial<DiagramSceneTheme>;
|
|
772
802
|
}
|
|
773
803
|
type Placed = {
|
|
774
804
|
id: string;
|
|
@@ -788,6 +818,12 @@ interface UseMermaidDiagramResult {
|
|
|
788
818
|
nodes: MermaidFlowNode[];
|
|
789
819
|
edges: MermaidFlowEdge[];
|
|
790
820
|
layout: DiagramLayout;
|
|
821
|
+
/**
|
|
822
|
+
* The family's own picture (pie, Gantt, sequence, XY, radar…) with the selection marked;
|
|
823
|
+
* null for families drawn as nodes and edges (flowchart, state, class, ER) and text-only
|
|
824
|
+
* ones. Render it with `MermaidFamilyScene`.
|
|
825
|
+
*/
|
|
826
|
+
scene: DiagramScene | null;
|
|
791
827
|
apply: (ops: EditOp | EditOp[], label?: string) => DiagramActionResult;
|
|
792
828
|
/** Replaces the source; `clearHistory` when opening a different diagram. */
|
|
793
829
|
load: (source: string, options?: {
|
|
@@ -799,6 +835,8 @@ interface UseMermaidDiagramResult {
|
|
|
799
835
|
/** Removes nodes / groups (with their edges) and edges by id, as one undo step. */
|
|
800
836
|
remove: (ids: readonly string[]) => DiagramActionResult;
|
|
801
837
|
rename: (id: string, label: string) => DiagramActionResult;
|
|
838
|
+
/** Renames what a scene mark targets: the title (`::title`), a group, an edge or a node. */
|
|
839
|
+
renameTarget: (target: string, label: string) => DiagramActionResult | null;
|
|
802
840
|
select: (ids: readonly string[]) => void;
|
|
803
841
|
undo: () => void;
|
|
804
842
|
redo: () => void;
|
|
@@ -810,7 +848,9 @@ declare function useDiagramState(controller: DiagramController): DiagramState;
|
|
|
810
848
|
* one from options), lays it out and returns canvas nodes and edges with bound edits. Every
|
|
811
849
|
* edit rewrites only the statements it touches; positions go into `%% @pixerate`.
|
|
812
850
|
*/
|
|
813
|
-
declare function useMermaidDiagram(controllerOrOptions?: DiagramController | UseMermaidDiagramOptions
|
|
851
|
+
declare function useMermaidDiagram(controllerOrOptions?: DiagramController | UseMermaidDiagramOptions,
|
|
852
|
+
/** Layout and scene colours when passing a controller (options carry them otherwise). */
|
|
853
|
+
view?: Pick<UseMermaidDiagramOptions, 'layoutOptions' | 'sceneTheme'>): UseMermaidDiagramResult;
|
|
814
854
|
interface UseMermaidStreamOptions extends DiagramLayoutOptions {
|
|
815
855
|
/** True once the whole source has arrived (unconnected nodes are shown then). */
|
|
816
856
|
complete?: boolean;
|
|
@@ -868,6 +908,19 @@ declare function MermaidDiagramNode({ data, width, height, selected, className,
|
|
|
868
908
|
/** Headless Mermaid group (subgraph, composite state, namespace): a titled frame. Register as `mermaid-group`. */
|
|
869
909
|
declare function MermaidDiagramGroup({ data, selected, className, children }: MermaidDiagramNodeProps): React__default.JSX.Element | null;
|
|
870
910
|
|
|
911
|
+
interface MermaidThumbnailProps extends DiagramSvgOptions {
|
|
912
|
+
/** Mermaid text, or an already parsed document. */
|
|
913
|
+
source: string | MermaidDocument;
|
|
914
|
+
className?: string;
|
|
915
|
+
/** Shown for families that cannot be drawn here (sequence, Gantt, …) and empty diagrams. */
|
|
916
|
+
fallback?: React__default.ReactNode;
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* A static preview of a flowchart, state, class or ER diagram (no canvas, no Mermaid runtime):
|
|
920
|
+
* `mermaidThumbnailSvg` fitted inside `maxWidth` × `maxHeight` (default 240 × 160).
|
|
921
|
+
*/
|
|
922
|
+
declare function MermaidThumbnail({ source, className, fallback, ...options }: MermaidThumbnailProps): React__default.JSX.Element;
|
|
923
|
+
|
|
871
924
|
interface UseDiagramDirectorOptions {
|
|
872
925
|
/** Where nodes are drawn now, e.g. `() => diagram.layout` from `useMermaidDiagram`. */
|
|
873
926
|
placement: () => DiagramPlacement;
|
|
@@ -902,4 +955,4 @@ interface DiagramPresenceLayerProps {
|
|
|
902
955
|
/** Agent cursors and their notes over a canvas, from a `PresenceStore` (see `DiagramDirector`). */
|
|
903
956
|
declare function DiagramPresenceLayer({ presence, viewport, className }: DiagramPresenceLayerProps): React__default.JSX.Element | null;
|
|
904
957
|
|
|
905
|
-
export { AgentPresenceLayer, type AgentPresenceLayerProps, AnimationTimeline, type AnimationTimelineProps, type CanvasAnimation, type CanvasArrange, type CanvasAutoLayout, type CanvasComponents, CanvasComponentsPanel, type CanvasComponentsPanelActions, type CanvasComponentsPanelProps, type CanvasDraw, type CanvasDrawActions, CanvasDrawLayer, type CanvasDrawLayerProps, type CanvasDrawState, type CanvasGraphTarget, CanvasGuidesLayer, type CanvasGuidesLayerProps, CanvasInstanceInspector, type CanvasInstanceInspectorActions, type CanvasInstanceInspectorProps, type CanvasMeasure, type CanvasScenes, type CanvasTokens, DiagramPresenceLayer, type DiagramPresenceLayerProps, MermaidDiagramGroup, MermaidDiagramNode, type MermaidDiagramNodeData, type MermaidDiagramNodeProps, ShapeNode, type ShapeNodeProps, TokenBindingPicker, type TokenBindingPickerProps, TokenModeSwitcher, type TokenModeSwitcherProps, type UseCanvasAnimationOptions, type UseCanvasArrangeOptions, type UseCanvasArrangeShortcutsOptions, type UseCanvasAutoLayoutOptions, type UseCanvasClipboardOptions, type UseCanvasComponentsOptions, type UseCanvasDockingOptions, type UseCanvasDrawOptions, type UseCanvasGraphOptions, type UseCanvasLayoutOptions, type UseCanvasMeasureOptions, type UseCanvasScenesOptions, type UseCanvasShortcutsOptions, type UseCanvasTokensOptions, type UseDiagramDirectorOptions, type UseMermaidDiagramOptions, type UseMermaidDiagramResult, type UseMermaidStreamOptions, type UseMermaidStreamResult, type UseStreamingCanvasOptions, mermaidNodeStyle, useCanvasAnimation, useCanvasArrange, useCanvasArrangeShortcuts, useCanvasAutoLayout, useCanvasClipboard, useCanvasComponents, useCanvasDocking, useCanvasDraw, useCanvasExplosion, useCanvasGraph, useCanvasLayout, useCanvasMeasure, useCanvasScenes, useCanvasShortcuts, useCanvasTokens, useDiagramDirector, useDiagramState, useMermaidDiagram, useMermaidStream, usePresenceState, useStreamingCanvas };
|
|
958
|
+
export { AgentPresenceLayer, type AgentPresenceLayerProps, AnimationTimeline, type AnimationTimelineProps, type CanvasAnimation, type CanvasArrange, type CanvasAutoLayout, type CanvasComponents, CanvasComponentsPanel, type CanvasComponentsPanelActions, type CanvasComponentsPanelProps, type CanvasDraw, type CanvasDrawActions, CanvasDrawLayer, type CanvasDrawLayerProps, type CanvasDrawState, type CanvasGraphTarget, CanvasGuidesLayer, type CanvasGuidesLayerProps, CanvasInstanceInspector, type CanvasInstanceInspectorActions, type CanvasInstanceInspectorProps, type CanvasMeasure, type CanvasScenes, type CanvasTokens, DiagramPresenceLayer, type DiagramPresenceLayerProps, MermaidDiagramGroup, MermaidDiagramNode, type MermaidDiagramNodeData, type MermaidDiagramNodeProps, MermaidFamilyScene, type MermaidFamilySceneProps, MermaidThumbnail, type MermaidThumbnailProps, ShapeNode, type ShapeNodeProps, TokenBindingPicker, type TokenBindingPickerProps, TokenModeSwitcher, type TokenModeSwitcherProps, type UseCanvasAnimationOptions, type UseCanvasArrangeOptions, type UseCanvasArrangeShortcutsOptions, type UseCanvasAutoLayoutOptions, type UseCanvasClipboardOptions, type UseCanvasComponentsOptions, type UseCanvasDockingOptions, type UseCanvasDrawOptions, type UseCanvasGraphOptions, type UseCanvasLayoutOptions, type UseCanvasMeasureOptions, type UseCanvasScenesOptions, type UseCanvasShortcutsOptions, type UseCanvasTokensOptions, type UseDiagramDirectorOptions, type UseMermaidDiagramOptions, type UseMermaidDiagramResult, type UseMermaidStreamOptions, type UseMermaidStreamResult, type UseStreamingCanvasOptions, mermaidNodeStyle, useCanvasAnimation, useCanvasArrange, useCanvasArrangeShortcuts, useCanvasAutoLayout, useCanvasClipboard, useCanvasComponents, useCanvasDocking, useCanvasDraw, useCanvasExplosion, useCanvasGraph, useCanvasLayout, useCanvasMeasure, useCanvasScenes, useCanvasShortcuts, useCanvasTokens, useDiagramDirector, useDiagramState, useMermaidDiagram, useMermaidStream, usePresenceState, useStreamingCanvas };
|
package/dist/canvas/index.js
CHANGED
|
@@ -2533,14 +2533,146 @@ import {
|
|
|
2533
2533
|
gradientToSvgDef as gradientToSvgDef2
|
|
2534
2534
|
} from "@pixerate/editor/canvas";
|
|
2535
2535
|
|
|
2536
|
+
// src/canvas/MermaidFamilyScene.tsx
|
|
2537
|
+
import { useId } from "react";
|
|
2538
|
+
import { diagramTextBaseline } from "@pixerate/editor/canvas";
|
|
2539
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2540
|
+
function MermaidFamilyScene({
|
|
2541
|
+
scene,
|
|
2542
|
+
padding = 16,
|
|
2543
|
+
interactive = true,
|
|
2544
|
+
onSelect,
|
|
2545
|
+
onOpen,
|
|
2546
|
+
selectionColor = "var(--primary, #2563eb)",
|
|
2547
|
+
markerColor = "var(--muted-foreground, #64748b)",
|
|
2548
|
+
className = "",
|
|
2549
|
+
style,
|
|
2550
|
+
title
|
|
2551
|
+
}) {
|
|
2552
|
+
const uid = useId().replace(/:/g, "");
|
|
2553
|
+
const marker = (kind) => kind ? `url(#${uid}-${kind})` : void 0;
|
|
2554
|
+
const x = scene.x - padding;
|
|
2555
|
+
const y = scene.y - padding;
|
|
2556
|
+
const width = Math.max(1, scene.width + padding * 2);
|
|
2557
|
+
const height = Math.max(1, scene.height + padding * 2);
|
|
2558
|
+
const handlers = (mark) => interactive && mark.target ? {
|
|
2559
|
+
onClick: (event) => {
|
|
2560
|
+
event.stopPropagation();
|
|
2561
|
+
onSelect?.(mark.target, event);
|
|
2562
|
+
},
|
|
2563
|
+
onDoubleClick: (event) => {
|
|
2564
|
+
event.stopPropagation();
|
|
2565
|
+
onOpen?.(mark.target, event);
|
|
2566
|
+
},
|
|
2567
|
+
cursor: "pointer"
|
|
2568
|
+
} : { pointerEvents: "none" };
|
|
2569
|
+
const stroke = (mark) => mark.selected ? { stroke: selectionColor, strokeWidth: Math.max(2, mark.strokeWidth ?? 0) } : { stroke: mark.stroke, strokeWidth: mark.strokeWidth };
|
|
2570
|
+
return /* @__PURE__ */ jsxs8(
|
|
2571
|
+
"svg",
|
|
2572
|
+
{
|
|
2573
|
+
className: `pixerate-diagram-scene ${className}`.trim(),
|
|
2574
|
+
"data-family": scene.family,
|
|
2575
|
+
role: "img",
|
|
2576
|
+
"aria-label": title ?? `${scene.family} diagram`,
|
|
2577
|
+
viewBox: `${x} ${y} ${width} ${height}`,
|
|
2578
|
+
width,
|
|
2579
|
+
height,
|
|
2580
|
+
style: { display: "block", maxWidth: "100%", height: "auto", overflow: "visible", ...style },
|
|
2581
|
+
onClick: interactive ? (event) => onSelect?.(null, event) : void 0,
|
|
2582
|
+
children: [
|
|
2583
|
+
/* @__PURE__ */ jsxs8("defs", { children: [
|
|
2584
|
+
/* @__PURE__ */ jsx8("marker", { id: `${uid}-arrowclosed`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ jsx8("path", { d: "M0,0 L10,5 L0,10 Z", style: { fill: markerColor } }) }),
|
|
2585
|
+
/* @__PURE__ */ jsx8("marker", { id: `${uid}-arrow`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ jsx8("path", { d: "M0,0 L10,5 L0,10", style: { fill: "none", stroke: markerColor, strokeWidth: 1.5 } }) })
|
|
2586
|
+
] }),
|
|
2587
|
+
scene.marks.map((mark) => {
|
|
2588
|
+
const common = { "data-role": mark.role, "data-target": mark.target, "data-selected": mark.selected ? "" : void 0, opacity: mark.opacity, ...handlers(mark) };
|
|
2589
|
+
switch (mark.kind) {
|
|
2590
|
+
case "rect":
|
|
2591
|
+
return /* @__PURE__ */ jsx8(
|
|
2592
|
+
"rect",
|
|
2593
|
+
{
|
|
2594
|
+
...common,
|
|
2595
|
+
x: mark.x,
|
|
2596
|
+
y: mark.y,
|
|
2597
|
+
width: Math.max(0, mark.width),
|
|
2598
|
+
height: Math.max(0, mark.height),
|
|
2599
|
+
rx: mark.radius,
|
|
2600
|
+
strokeDasharray: mark.dash,
|
|
2601
|
+
style: { fill: mark.fill, ...stroke(mark) }
|
|
2602
|
+
},
|
|
2603
|
+
mark.key
|
|
2604
|
+
);
|
|
2605
|
+
case "circle":
|
|
2606
|
+
return /* @__PURE__ */ jsx8("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, ...stroke(mark) } }, mark.key);
|
|
2607
|
+
case "line":
|
|
2608
|
+
return /* @__PURE__ */ jsx8(
|
|
2609
|
+
"line",
|
|
2610
|
+
{
|
|
2611
|
+
...common,
|
|
2612
|
+
x1: mark.x1,
|
|
2613
|
+
y1: mark.y1,
|
|
2614
|
+
x2: mark.x2,
|
|
2615
|
+
y2: mark.y2,
|
|
2616
|
+
strokeDasharray: mark.dash,
|
|
2617
|
+
markerEnd: marker(mark.markerEnd),
|
|
2618
|
+
markerStart: marker(mark.markerStart),
|
|
2619
|
+
style: { stroke: mark.selected ? selectionColor : mark.stroke, strokeWidth: mark.strokeWidth ?? 1 }
|
|
2620
|
+
},
|
|
2621
|
+
mark.key
|
|
2622
|
+
);
|
|
2623
|
+
case "path":
|
|
2624
|
+
return /* @__PURE__ */ jsx8(
|
|
2625
|
+
"path",
|
|
2626
|
+
{
|
|
2627
|
+
...common,
|
|
2628
|
+
d: mark.d,
|
|
2629
|
+
strokeDasharray: mark.dash,
|
|
2630
|
+
strokeLinejoin: "round",
|
|
2631
|
+
markerEnd: marker(mark.markerEnd),
|
|
2632
|
+
markerStart: marker(mark.markerStart),
|
|
2633
|
+
style: { fill: mark.fill ?? "none", ...stroke(mark) }
|
|
2634
|
+
},
|
|
2635
|
+
mark.key
|
|
2636
|
+
);
|
|
2637
|
+
case "text":
|
|
2638
|
+
return /* @__PURE__ */ jsx8(
|
|
2639
|
+
"text",
|
|
2640
|
+
{
|
|
2641
|
+
...common,
|
|
2642
|
+
x: mark.x,
|
|
2643
|
+
y: mark.y,
|
|
2644
|
+
textAnchor: mark.anchor,
|
|
2645
|
+
dominantBaseline: diagramTextBaseline(mark.baseline),
|
|
2646
|
+
transform: mark.rotate ? `rotate(${mark.rotate} ${mark.x} ${mark.y})` : void 0,
|
|
2647
|
+
style: {
|
|
2648
|
+
fill: mark.selected ? selectionColor : mark.fill,
|
|
2649
|
+
fontSize: mark.size,
|
|
2650
|
+
fontWeight: mark.weight,
|
|
2651
|
+
fontStyle: mark.italic ? "italic" : void 0,
|
|
2652
|
+
userSelect: "none"
|
|
2653
|
+
},
|
|
2654
|
+
children: mark.text
|
|
2655
|
+
},
|
|
2656
|
+
mark.key
|
|
2657
|
+
);
|
|
2658
|
+
}
|
|
2659
|
+
})
|
|
2660
|
+
]
|
|
2661
|
+
}
|
|
2662
|
+
);
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2536
2665
|
// src/canvas/useMermaidDiagram.ts
|
|
2537
2666
|
import { useEffect as useEffect10, useMemo as useMemo8, useRef as useRef15, useState as useState8, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
2538
2667
|
import {
|
|
2539
2668
|
DiagramController
|
|
2540
2669
|
} from "@pixerate/editor/diagram";
|
|
2541
2670
|
import {
|
|
2671
|
+
CSS_VARIABLE_DIAGRAM_SCENE_THEME,
|
|
2542
2672
|
DiagramStream,
|
|
2543
2673
|
blendDiagramLayout,
|
|
2674
|
+
diagramRenameOp,
|
|
2675
|
+
familySceneFromLayout,
|
|
2544
2676
|
easeDiagramTween,
|
|
2545
2677
|
mermaidMovesFromCanvas,
|
|
2546
2678
|
mermaidToCanvas
|
|
@@ -2548,7 +2680,7 @@ import {
|
|
|
2548
2680
|
function useDiagramState(controller) {
|
|
2549
2681
|
return useSyncExternalStore4(controller.subscribe, controller.getState, controller.getState);
|
|
2550
2682
|
}
|
|
2551
|
-
function useMermaidDiagram(controllerOrOptions = {}) {
|
|
2683
|
+
function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
2552
2684
|
const own = useRef15(null);
|
|
2553
2685
|
let controller;
|
|
2554
2686
|
if (controllerOrOptions instanceof DiagramController) controller = controllerOrOptions;
|
|
@@ -2556,13 +2688,19 @@ function useMermaidDiagram(controllerOrOptions = {}) {
|
|
|
2556
2688
|
if (!own.current) own.current = new DiagramController(controllerOrOptions);
|
|
2557
2689
|
controller = own.current;
|
|
2558
2690
|
}
|
|
2559
|
-
const layoutOptions = controllerOrOptions instanceof DiagramController ? void 0 : controllerOrOptions.layoutOptions;
|
|
2691
|
+
const layoutOptions = (controllerOrOptions instanceof DiagramController ? void 0 : controllerOrOptions.layoutOptions) ?? view.layoutOptions;
|
|
2692
|
+
const sceneTheme = (controllerOrOptions instanceof DiagramController ? void 0 : controllerOrOptions.sceneTheme) ?? view.sceneTheme;
|
|
2560
2693
|
const state = useDiagramState(controller);
|
|
2561
2694
|
const canvas = useMemo8(
|
|
2562
2695
|
() => mermaidToCanvas(state.document, { ...layoutOptions, editable: state.editable }),
|
|
2563
2696
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2564
2697
|
[state.document, state.editable]
|
|
2565
2698
|
);
|
|
2699
|
+
const scene = useMemo8(
|
|
2700
|
+
() => state.document.tier === "editable" ? familySceneFromLayout(state.document.family, state.document.graph, canvas.layout, { theme: { ...CSS_VARIABLE_DIAGRAM_SCENE_THEME, ...sceneTheme }, selection: state.selection }) : null,
|
|
2701
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2702
|
+
[state.document, canvas.layout, state.selection]
|
|
2703
|
+
);
|
|
2566
2704
|
const layoutRef = useRef15(canvas.layout);
|
|
2567
2705
|
layoutRef.current = canvas.layout;
|
|
2568
2706
|
const actions = useMemo8(
|
|
@@ -2588,13 +2726,17 @@ function useMermaidDiagram(controllerOrOptions = {}) {
|
|
|
2588
2726
|
controller.getDocument().graph.groups.some((g) => g.id === id) ? { type: "renameGroup", id, label } : { type: "renameNode", id, label },
|
|
2589
2727
|
"Rename"
|
|
2590
2728
|
),
|
|
2729
|
+
renameTarget: (target, label) => {
|
|
2730
|
+
const op = diagramRenameOp(controller.getDocument(), target, label);
|
|
2731
|
+
return op ? controller.apply(op, "Rename") : null;
|
|
2732
|
+
},
|
|
2591
2733
|
select: (ids) => controller.select(ids),
|
|
2592
2734
|
undo: () => void controller.undo(),
|
|
2593
2735
|
redo: () => void controller.redo()
|
|
2594
2736
|
}),
|
|
2595
2737
|
[controller]
|
|
2596
2738
|
);
|
|
2597
|
-
return { controller, state, document: state.document, source: state.source, ...canvas, ...actions };
|
|
2739
|
+
return { controller, state, document: state.document, source: state.source, ...canvas, scene, ...actions };
|
|
2598
2740
|
}
|
|
2599
2741
|
function useMermaidStream(source, options = {}) {
|
|
2600
2742
|
const { complete = false, duration = 300, ...layoutOptions } = options;
|
|
@@ -2637,7 +2779,7 @@ function useMermaidStream(source, options = {}) {
|
|
|
2637
2779
|
|
|
2638
2780
|
// src/canvas/MermaidDiagramNode.tsx
|
|
2639
2781
|
import { MERMAID_SHAPE_PAINT, mermaidLabelLines, mermaidNodeMembers, mermaidNodePaint, mermaidShapePaths } from "@pixerate/editor/canvas";
|
|
2640
|
-
import { jsx as
|
|
2782
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2641
2783
|
function mermaidNodeStyle(styles = {}, selected = false) {
|
|
2642
2784
|
const paint = mermaidNodePaint(styles, selected);
|
|
2643
2785
|
const { color, "stroke-width": strokeWidth, "stroke-dasharray": strokeDasharray, ...vars } = paint;
|
|
@@ -2647,7 +2789,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
2647
2789
|
const node = data.node;
|
|
2648
2790
|
if (!node) return null;
|
|
2649
2791
|
const members = mermaidNodeMembers(node.data);
|
|
2650
|
-
return /* @__PURE__ */
|
|
2792
|
+
return /* @__PURE__ */ jsxs9(
|
|
2651
2793
|
"div",
|
|
2652
2794
|
{
|
|
2653
2795
|
className: `pixerate-diagram-node ${className}`.trim(),
|
|
@@ -2655,14 +2797,14 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
2655
2797
|
"data-selected": selected ? "true" : void 0,
|
|
2656
2798
|
style: { position: "relative", width: "100%", height: "100%", ...mermaidNodeStyle(data.resolvedStyles, selected) },
|
|
2657
2799
|
children: [
|
|
2658
|
-
/* @__PURE__ */
|
|
2659
|
-
/* @__PURE__ */
|
|
2800
|
+
/* @__PURE__ */ jsx9("svg", { viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", width: "100%", height: "100%", style: { position: "absolute", inset: 0, overflow: "visible" }, "aria-hidden": "true", children: mermaidShapePaths(node.shape, width, height).map((path, i) => /* @__PURE__ */ jsx9("path", { d: path.d, style: { ...MERMAID_SHAPE_PAINT[path.paint], vectorEffect: "non-scaling-stroke" } }, i)) }),
|
|
2801
|
+
/* @__PURE__ */ jsxs9(
|
|
2660
2802
|
"div",
|
|
2661
2803
|
{
|
|
2662
2804
|
style: { position: "relative", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: members.length ? "flex-start" : "center", height: "100%", padding: "6px 10px", boxSizing: "border-box", fontSize: 13, lineHeight: 1.3, textAlign: "center", pointerEvents: "none" },
|
|
2663
2805
|
children: [
|
|
2664
|
-
mermaidLabelLines(node.label).map((line, i) => /* @__PURE__ */
|
|
2665
|
-
members.length > 0 && /* @__PURE__ */
|
|
2806
|
+
mermaidLabelLines(node.label).map((line, i) => /* @__PURE__ */ jsx9("span", { style: { fontWeight: members.length ? 600 : void 0 }, children: line }, i)),
|
|
2807
|
+
members.length > 0 && /* @__PURE__ */ jsx9("div", { style: { alignSelf: "stretch", marginTop: 4, paddingTop: 4, borderTop: "1px solid var(--pixerate-diagram-node-border)", textAlign: "left", fontSize: 12 }, children: members.map((m, i) => /* @__PURE__ */ jsx9("div", { children: m }, i)) })
|
|
2666
2808
|
]
|
|
2667
2809
|
}
|
|
2668
2810
|
),
|
|
@@ -2674,7 +2816,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
2674
2816
|
function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
2675
2817
|
const group = data.group;
|
|
2676
2818
|
if (!group) return null;
|
|
2677
|
-
return /* @__PURE__ */
|
|
2819
|
+
return /* @__PURE__ */ jsxs9(
|
|
2678
2820
|
"div",
|
|
2679
2821
|
{
|
|
2680
2822
|
className: `pixerate-diagram-group ${className}`.trim(),
|
|
@@ -2689,13 +2831,30 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
|
2689
2831
|
color: data.resolvedStyles?.color ?? "var(--muted-foreground, #475569)"
|
|
2690
2832
|
},
|
|
2691
2833
|
children: [
|
|
2692
|
-
/* @__PURE__ */
|
|
2834
|
+
/* @__PURE__ */ jsx9("div", { style: { padding: "6px 10px", fontSize: 12, fontWeight: 600 }, children: mermaidLabelLines(group.label).join(" ") }),
|
|
2693
2835
|
children
|
|
2694
2836
|
]
|
|
2695
2837
|
}
|
|
2696
2838
|
);
|
|
2697
2839
|
}
|
|
2698
2840
|
|
|
2841
|
+
// src/canvas/MermaidThumbnail.tsx
|
|
2842
|
+
import { useMemo as useMemo9 } from "react";
|
|
2843
|
+
import { parseMermaid } from "@pixerate/editor/diagram";
|
|
2844
|
+
import { mermaidThumbnailSvg } from "@pixerate/editor/canvas";
|
|
2845
|
+
import { Fragment as Fragment2, jsx as jsx10 } from "react/jsx-runtime";
|
|
2846
|
+
function MermaidThumbnail({ source, className = "", fallback = null, ...options }) {
|
|
2847
|
+
const doc = useMemo9(() => typeof source === "string" ? parseMermaid(source) : source, [source]);
|
|
2848
|
+
const key = JSON.stringify(options);
|
|
2849
|
+
const drawn = useMemo9(
|
|
2850
|
+
() => doc.tier === "editable" && doc.graph.nodes.length ? mermaidThumbnailSvg(doc, options) : null,
|
|
2851
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2852
|
+
[doc, key]
|
|
2853
|
+
);
|
|
2854
|
+
if (!drawn) return /* @__PURE__ */ jsx10(Fragment2, { children: fallback });
|
|
2855
|
+
return /* @__PURE__ */ jsx10("span", { className: `pixerate-diagram-thumbnail ${className}`.trim(), style: { display: "inline-block", lineHeight: 0 }, dangerouslySetInnerHTML: { __html: drawn.svg } });
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2699
2858
|
// src/canvas/useDiagramDirector.ts
|
|
2700
2859
|
import { useRef as useRef16, useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
2701
2860
|
import { DiagramDirector, PresenceStore } from "@pixerate/editor/diagram";
|
|
@@ -2717,13 +2876,13 @@ function usePresenceState(presence) {
|
|
|
2717
2876
|
}
|
|
2718
2877
|
|
|
2719
2878
|
// src/canvas/DiagramPresenceLayer.tsx
|
|
2720
|
-
import { jsx as
|
|
2879
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2721
2880
|
function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
2722
2881
|
const { actors } = usePresenceState(presence);
|
|
2723
2882
|
if (!actors.length) return null;
|
|
2724
|
-
return /* @__PURE__ */
|
|
2725
|
-
/* @__PURE__ */
|
|
2726
|
-
/* @__PURE__ */
|
|
2883
|
+
return /* @__PURE__ */ jsx11("div", { className: `pixerate-diagram-presence ${className}`.trim(), "aria-hidden": "true", style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 }, children: actors.map((a) => /* @__PURE__ */ jsxs10("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${a.x * viewport.zoom + viewport.x}px, ${a.y * viewport.zoom + viewport.y}px)` }, children: [
|
|
2884
|
+
/* @__PURE__ */ jsx11("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0" }, children: /* @__PURE__ */ jsx11("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
|
|
2885
|
+
/* @__PURE__ */ jsx11("span", { style: { position: "absolute", left: 14, top: 16, whiteSpace: "nowrap", borderRadius: 4, padding: "1px 6px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.message ?? a.name })
|
|
2727
2886
|
] }, a.id)) });
|
|
2728
2887
|
}
|
|
2729
2888
|
export {
|
|
@@ -2755,6 +2914,8 @@ export {
|
|
|
2755
2914
|
ManualClock,
|
|
2756
2915
|
MermaidDiagramGroup,
|
|
2757
2916
|
MermaidDiagramNode,
|
|
2917
|
+
MermaidFamilyScene,
|
|
2918
|
+
MermaidThumbnail,
|
|
2758
2919
|
RESIZE_HANDLES,
|
|
2759
2920
|
SHAPE_DATA_KEY,
|
|
2760
2921
|
SHAPE_KINDS,
|