@pixerate/editor-svelte 0.15.2 → 0.16.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/BubbleMenu.svelte.d.ts +14 -0
- package/dist/BubbleMenu.svelte.d.ts.map +1 -0
- package/{src → dist}/EditableTextNodeEditor.svelte +1 -1
- package/dist/EditableTextNodeEditor.svelte.d.ts +26 -0
- package/dist/EditableTextNodeEditor.svelte.d.ts.map +1 -0
- package/dist/TemplateRenderer.svelte.d.ts +14 -0
- package/dist/TemplateRenderer.svelte.d.ts.map +1 -0
- package/dist/canvas/AgentPresenceLayer.svelte.d.ts +9 -0
- package/dist/canvas/AgentPresenceLayer.svelte.d.ts.map +1 -0
- package/dist/canvas/FloatingHorizontalScrollbar.svelte.d.ts +9 -0
- package/dist/canvas/FloatingHorizontalScrollbar.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasClipboard.svelte.d.ts +32 -0
- package/dist/canvas/createCanvasClipboard.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasClipboard.svelte.js +171 -0
- package/dist/canvas/createCanvasDisplacement.d.ts +32 -0
- package/dist/canvas/createCanvasDisplacement.d.ts.map +1 -0
- package/dist/canvas/createCanvasDisplacement.js +170 -0
- package/dist/canvas/createCanvasDocking.svelte.d.ts +56 -0
- package/dist/canvas/createCanvasDocking.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasDocking.svelte.js +227 -0
- package/dist/canvas/createCanvasExplosion.svelte.d.ts +31 -0
- package/dist/canvas/createCanvasExplosion.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasExplosion.svelte.js +346 -0
- package/dist/canvas/createCanvasGraph.svelte.d.ts +62 -0
- package/dist/canvas/createCanvasGraph.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasGraph.svelte.js +223 -0
- package/dist/canvas/createCanvasInteractions.svelte.d.ts +28 -0
- package/dist/canvas/createCanvasInteractions.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasInteractions.svelte.js +95 -0
- package/dist/canvas/createCanvasLayout.d.ts +22 -0
- package/dist/canvas/createCanvasLayout.d.ts.map +1 -0
- package/dist/canvas/createCanvasLayout.js +76 -0
- package/dist/canvas/createCanvasMultiDrag.svelte.d.ts +61 -0
- package/dist/canvas/createCanvasMultiDrag.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasMultiDrag.svelte.js +105 -0
- package/dist/canvas/createCanvasNodeSync.svelte.d.ts +58 -0
- package/dist/canvas/createCanvasNodeSync.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasNodeSync.svelte.js +82 -0
- package/dist/canvas/createCanvasSelection.svelte.d.ts +26 -0
- package/dist/canvas/createCanvasSelection.svelte.d.ts.map +1 -0
- package/dist/canvas/createCanvasSelection.svelte.js +26 -0
- package/dist/canvas/createCanvasShortcuts.d.ts +9 -0
- package/dist/canvas/createCanvasShortcuts.d.ts.map +1 -0
- package/dist/canvas/createCanvasShortcuts.js +97 -0
- package/dist/canvas/createCanvasTrajectory.d.ts +31 -0
- package/dist/canvas/createCanvasTrajectory.d.ts.map +1 -0
- package/dist/canvas/createCanvasTrajectory.js +141 -0
- package/dist/canvas/createStreamingCanvas.svelte.d.ts +19 -0
- package/dist/canvas/createStreamingCanvas.svelte.d.ts.map +1 -0
- package/dist/canvas/createStreamingCanvas.svelte.js +32 -0
- package/dist/canvas/index.d.ts +18 -688
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/index.js +34 -1839
- package/dist/canvas/types.d.ts +183 -0
- package/dist/canvas/types.d.ts.map +1 -0
- package/dist/canvas/types.js +1 -0
- package/dist/createNavigationGuard.svelte.d.ts +24 -0
- package/dist/createNavigationGuard.svelte.d.ts.map +1 -0
- package/dist/createNavigationGuard.svelte.js +65 -0
- package/dist/editor.svelte.d.ts +23 -0
- package/dist/editor.svelte.d.ts.map +1 -0
- package/dist/editor.svelte.js +41 -0
- package/dist/history/createHistoryShortcuts.d.ts +24 -0
- package/dist/history/createHistoryShortcuts.d.ts.map +1 -0
- package/dist/history/createHistoryShortcuts.js +57 -0
- package/dist/history/history.svelte.d.ts +18 -0
- package/dist/history/history.svelte.d.ts.map +1 -0
- package/dist/history/history.svelte.js +43 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/history/index.js +2 -0
- package/{src → dist}/image-editor/ImageEditor.svelte +1 -1
- package/dist/image-editor/ImageEditor.svelte.d.ts +17 -0
- package/dist/image-editor/ImageEditor.svelte.d.ts.map +1 -0
- package/dist/image-editor/imageEditorState.svelte.d.ts +50 -0
- package/dist/image-editor/imageEditorState.svelte.d.ts.map +1 -0
- package/dist/image-editor/imageEditorState.svelte.js +132 -0
- package/dist/image-editor/index.d.ts +6 -16
- package/dist/image-editor/index.d.ts.map +1 -0
- package/dist/image-editor/index.js +2 -9
- package/dist/index.d.ts +20 -249
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -1119
- package/dist/navigationGuard.d.ts +21 -0
- package/dist/navigationGuard.d.ts.map +1 -0
- package/dist/navigationGuard.js +59 -0
- package/{src → dist}/spreadsheet/FormulaBar.svelte +1 -1
- package/dist/spreadsheet/FormulaBar.svelte.d.ts +17 -0
- package/dist/spreadsheet/FormulaBar.svelte.d.ts.map +1 -0
- package/{src → dist}/spreadsheet/SpreadsheetEditor.svelte +1 -1
- package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts +22 -0
- package/dist/spreadsheet/SpreadsheetEditor.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/index.d.ts +9 -0
- package/dist/spreadsheet/index.d.ts.map +1 -0
- package/{src/spreadsheet/index.ts → dist/spreadsheet/index.js} +1 -1
- package/dist/spreadsheet/spreadsheet.svelte.d.ts +33 -0
- package/dist/spreadsheet/spreadsheet.svelte.d.ts.map +1 -0
- package/dist/spreadsheet/spreadsheet.svelte.js +160 -0
- package/package.json +14 -16
- package/dist/canvas/index.js.map +0 -1
- package/dist/chunk-HEOI4UNF.js +0 -1191
- package/dist/chunk-HEOI4UNF.js.map +0 -1
- package/dist/image-editor/index.js.map +0 -1
- package/dist/index.css +0 -50
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/src/canvas/__tests__/canvas-clipboard.test.ts +0 -154
- package/src/canvas/__tests__/canvas-docking.test.ts +0 -288
- package/src/canvas/__tests__/canvas-explosion.test.ts +0 -634
- package/src/canvas/__tests__/canvas-graph.test.ts +0 -159
- package/src/canvas/__tests__/canvas-interactions.test.ts +0 -86
- package/src/canvas/__tests__/canvas-layout.test.ts +0 -75
- package/src/canvas/__tests__/canvas-multi-drag.test.ts +0 -112
- package/src/canvas/__tests__/canvas-node-sync.svelte.test.ts +0 -104
- package/src/canvas/__tests__/canvas-shortcuts.test.ts +0 -59
- package/src/canvas/createCanvasClipboard.svelte.ts +0 -219
- package/src/canvas/createCanvasDisplacement.ts +0 -253
- package/src/canvas/createCanvasDocking.svelte.ts +0 -355
- package/src/canvas/createCanvasExplosion.svelte.ts +0 -457
- package/src/canvas/createCanvasGraph.svelte.ts +0 -330
- package/src/canvas/createCanvasInteractions.svelte.ts +0 -112
- package/src/canvas/createCanvasLayout.ts +0 -129
- package/src/canvas/createCanvasMultiDrag.svelte.ts +0 -175
- package/src/canvas/createCanvasNodeSync.svelte.ts +0 -150
- package/src/canvas/createCanvasSelection.svelte.ts +0 -51
- package/src/canvas/createCanvasShortcuts.ts +0 -99
- package/src/canvas/createCanvasTrajectory.ts +0 -207
- package/src/canvas/createStreamingCanvas.svelte.ts +0 -56
- package/src/canvas/index.d.ts +0 -688
- package/src/canvas/index.ts +0 -126
- package/src/canvas/types.ts +0 -223
- package/src/createNavigationGuard.svelte.ts +0 -97
- package/src/editor.svelte.ts +0 -65
- package/src/history/createHistoryShortcuts.ts +0 -95
- package/src/history/history.svelte.ts +0 -68
- package/src/history/index.ts +0 -2
- package/src/image-editor/imageEditorState.svelte.ts +0 -151
- package/src/image-editor/index.d.ts +0 -16
- package/src/image-editor/index.ts +0 -2
- package/src/index.d.ts +0 -249
- package/src/index.ts +0 -89
- package/src/navigationGuard.ts +0 -82
- package/src/spreadsheet/spreadsheet.svelte.ts +0 -176
- package/src/svelte.d.ts +0 -5
- /package/{src → dist}/BubbleMenu.svelte +0 -0
- /package/{src → dist}/TemplateRenderer.svelte +0 -0
- /package/{src → dist}/canvas/AgentPresenceLayer.svelte +0 -0
- /package/{src → dist}/canvas/FloatingHorizontalScrollbar.svelte +0 -0
- /package/{src → dist}/canvas/README.md +0 -0
package/src/canvas/index.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// Types
|
|
2
|
-
export * from './types.js';
|
|
3
|
-
|
|
4
|
-
// Graph management rune & pure functions
|
|
5
|
-
export {
|
|
6
|
-
createCanvasGraph,
|
|
7
|
-
calculateGraphDifferences,
|
|
8
|
-
replaceNodeInGraph,
|
|
9
|
-
type CreateCanvasGraphOptions
|
|
10
|
-
} from './createCanvasGraph.svelte.js';
|
|
11
|
-
|
|
12
|
-
// Layout calculations
|
|
13
|
-
export {
|
|
14
|
-
getLayoutedNodes,
|
|
15
|
-
getCenteredNodePosition,
|
|
16
|
-
centerNodes,
|
|
17
|
-
ensureLayout,
|
|
18
|
-
placeBeside,
|
|
19
|
-
estimateNodeSize,
|
|
20
|
-
flowSide
|
|
21
|
-
} from './createCanvasLayout.js';
|
|
22
|
-
|
|
23
|
-
// Clipboard rune & helpers
|
|
24
|
-
export {
|
|
25
|
-
createCanvasClipboard,
|
|
26
|
-
isEventFromTextInput,
|
|
27
|
-
isValidCanvasNode,
|
|
28
|
-
isValidUrl,
|
|
29
|
-
type CreateCanvasClipboardOptions
|
|
30
|
-
} from './createCanvasClipboard.svelte.js';
|
|
31
|
-
|
|
32
|
-
// Docking & drag interactions rune
|
|
33
|
-
export {
|
|
34
|
-
createCanvasDocking,
|
|
35
|
-
type CreateCanvasDockingOptions,
|
|
36
|
-
type DockStrategy
|
|
37
|
-
} from './createCanvasDocking.svelte.js';
|
|
38
|
-
|
|
39
|
-
// Shortcuts manager
|
|
40
|
-
export {
|
|
41
|
-
createCanvasShortcuts
|
|
42
|
-
} from './createCanvasShortcuts.js';
|
|
43
|
-
|
|
44
|
-
// Interaction modes & presets
|
|
45
|
-
export {
|
|
46
|
-
createCanvasInteractions,
|
|
47
|
-
defaultSvelteFlowPreset,
|
|
48
|
-
miroCompatiblePreset,
|
|
49
|
-
restorePanelPointerEvents,
|
|
50
|
-
type CreateCanvasInteractionsOptions
|
|
51
|
-
} from './createCanvasInteractions.svelte.js';
|
|
52
|
-
|
|
53
|
-
// Trajectory calculation & multi-node transitions
|
|
54
|
-
export {
|
|
55
|
-
linearTrajectory,
|
|
56
|
-
linearPositionTrajectory,
|
|
57
|
-
createFanOutTrajectory,
|
|
58
|
-
createBezierTrajectory,
|
|
59
|
-
runMultiNodeTransition
|
|
60
|
-
} from './createCanvasTrajectory.js';
|
|
61
|
-
|
|
62
|
-
// Spatial layout displacement
|
|
63
|
-
export {
|
|
64
|
-
computeNodesBoundingBox,
|
|
65
|
-
calculateDirectionalDisplacement,
|
|
66
|
-
calculateReflowDisplacement
|
|
67
|
-
} from './createCanvasDisplacement.js';
|
|
68
|
-
|
|
69
|
-
// Node explosion & collapse rune
|
|
70
|
-
export {
|
|
71
|
-
createCanvasExplosion,
|
|
72
|
-
type CanvasGraphTarget,
|
|
73
|
-
type CreateCanvasExplosionOptions
|
|
74
|
-
} from './createCanvasExplosion.svelte.js';
|
|
75
|
-
|
|
76
|
-
// Node synchronization & handle normalization
|
|
77
|
-
export {
|
|
78
|
-
createCanvasNodeSync,
|
|
79
|
-
preserveNodeMeasurements,
|
|
80
|
-
normalizeNodeHandles,
|
|
81
|
-
type HandleConfig,
|
|
82
|
-
type NodeMeasurement,
|
|
83
|
-
type CreateCanvasNodeSyncOptions
|
|
84
|
-
} from './createCanvasNodeSync.svelte.js';
|
|
85
|
-
|
|
86
|
-
// Multi-node drag coordination rune
|
|
87
|
-
export {
|
|
88
|
-
createCanvasMultiDrag,
|
|
89
|
-
type MultiDragState,
|
|
90
|
-
type MultiDragFollowerOffset,
|
|
91
|
-
type CreateCanvasMultiDragOptions,
|
|
92
|
-
type FollowerTransform
|
|
93
|
-
} from './createCanvasMultiDrag.svelte.js';
|
|
94
|
-
|
|
95
|
-
// Drag selection helpers & presets
|
|
96
|
-
export {
|
|
97
|
-
getMarqueeSelectionPreset,
|
|
98
|
-
handleDeselectOnEscape,
|
|
99
|
-
type CanvasSelectionOptions
|
|
100
|
-
} from './createCanvasSelection.svelte.js';
|
|
101
|
-
|
|
102
|
-
// Viewport floating scrollbar component
|
|
103
|
-
export { default as FloatingHorizontalScrollbar } from './FloatingHorizontalScrollbar.svelte';
|
|
104
|
-
|
|
105
|
-
// Agent presence visual layer
|
|
106
|
-
export { default as AgentPresenceLayer } from './AgentPresenceLayer.svelte';
|
|
107
|
-
|
|
108
|
-
// Streaming canvas rune
|
|
109
|
-
export {
|
|
110
|
-
createStreamingCanvas,
|
|
111
|
-
type CreateStreamingCanvasOptions
|
|
112
|
-
} from './createStreamingCanvas.svelte.js';
|
|
113
|
-
|
|
114
|
-
// Clock and view helpers from core
|
|
115
|
-
export {
|
|
116
|
-
realClock,
|
|
117
|
-
ManualClock,
|
|
118
|
-
layoutBounds,
|
|
119
|
-
canvasHeight,
|
|
120
|
-
estimateCanvasHeight,
|
|
121
|
-
blendLayout,
|
|
122
|
-
connectedOnly,
|
|
123
|
-
type Clock,
|
|
124
|
-
type CanvasHeightOptions
|
|
125
|
-
} from '@pixerate/editor/canvas';
|
|
126
|
-
|
package/src/canvas/types.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import type { Node, Edge, XYPosition, Rect, ColorMode, Position } from '@xyflow/svelte';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generic node interface representing an element on the canvas.
|
|
5
|
-
*/
|
|
6
|
-
export type CanvasNode<
|
|
7
|
-
TData extends Record<string, any> = Record<string, any>,
|
|
8
|
-
TType extends string | undefined = string | undefined
|
|
9
|
-
> = Node<TData, TType>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Generic edge interface representing a connection on the canvas.
|
|
13
|
-
*/
|
|
14
|
-
export type CanvasEdge<
|
|
15
|
-
TData extends Record<string, any> = Record<string, any>,
|
|
16
|
-
TType extends string | undefined = string | undefined
|
|
17
|
-
> = Edge<TData, TType>;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Differences computed between two graph states.
|
|
21
|
-
*/
|
|
22
|
-
export interface GraphDifferences<
|
|
23
|
-
TNode extends CanvasNode = CanvasNode,
|
|
24
|
-
TEdge extends CanvasEdge = CanvasEdge
|
|
25
|
-
> {
|
|
26
|
-
changedNodes: TNode[];
|
|
27
|
-
changedEdges: TEdge[];
|
|
28
|
-
removedNodes: TNode[];
|
|
29
|
-
removedEdges: TEdge[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Standard serialized clipboard payload for nodes and optional edges.
|
|
34
|
-
*/
|
|
35
|
-
export interface CanvasClipboardPayload<
|
|
36
|
-
TNode extends CanvasNode = CanvasNode,
|
|
37
|
-
TEdge extends CanvasEdge = CanvasEdge
|
|
38
|
-
> {
|
|
39
|
-
version?: number;
|
|
40
|
-
nodes: TNode[];
|
|
41
|
-
edges?: TEdge[];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Options for Dagre graph layout.
|
|
46
|
-
*/
|
|
47
|
-
export interface CanvasLayoutOptions {
|
|
48
|
-
direction?: 'LR' | 'TB' | 'RL' | 'BT';
|
|
49
|
-
ranksep?: number;
|
|
50
|
-
nodesep?: number;
|
|
51
|
-
defaultNodeWidth?: number;
|
|
52
|
-
defaultNodeHeight?: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Options for keyboard shortcuts.
|
|
57
|
-
*/
|
|
58
|
-
export interface CanvasShortcutsOptions<TNode extends CanvasNode = CanvasNode> {
|
|
59
|
-
targetElement?: HTMLElement | Window;
|
|
60
|
-
onCopy?: () => void;
|
|
61
|
-
onCut?: () => void;
|
|
62
|
-
onPaste?: (event: ClipboardEvent) => void;
|
|
63
|
-
onDelete?: (selectedNodes: TNode[]) => void;
|
|
64
|
-
onDuplicate?: (selectedNodes: TNode[]) => void;
|
|
65
|
-
onSelectAll?: () => void;
|
|
66
|
-
onGroup?: (selectedNodes: TNode[]) => void;
|
|
67
|
-
onUngroup?: (selectedNodes: TNode[]) => void;
|
|
68
|
-
onZoomIn?: () => void;
|
|
69
|
-
onZoomOut?: () => void;
|
|
70
|
-
onFitView?: () => void;
|
|
71
|
-
onSearch?: () => void;
|
|
72
|
-
getSelectedNodes?: () => TNode[];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Strategy used to resolve the primary dock target when multiple targets intersect a dragged node.
|
|
77
|
-
* - 'center-point': Chooses the target enclosing or closest to the center coordinate of the dragged node.
|
|
78
|
-
* - 'max-overlap': Chooses the target with the largest bounding box intersection area.
|
|
79
|
-
* - 'pointer': Chooses the target enclosing or closest to the mouse/touch cursor coordinates (falls back to 'center-point').
|
|
80
|
-
* - 'first': Chooses the first intersecting target (legacy behavior).
|
|
81
|
-
*/
|
|
82
|
-
export type DockStrategy = 'center-point' | 'max-overlap' | 'pointer' | 'first';
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Docking and intersection callbacks.
|
|
86
|
-
*/
|
|
87
|
-
export interface CanvasDockingCallbacks<TNode extends CanvasNode = CanvasNode> {
|
|
88
|
-
onDockHover?: (dockTarget: TNode, draggedNode: TNode) => void;
|
|
89
|
-
onDockLeave?: (dockTarget: TNode, draggedNode: TNode) => void;
|
|
90
|
-
onDockDrop?: (dockTarget: TNode, draggedNode: TNode) => void;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Configuration options for SvelteFlow presets.
|
|
95
|
-
*/
|
|
96
|
-
export interface CanvasInteractionPresetConfig {
|
|
97
|
-
snapGrid?: [number, number];
|
|
98
|
-
panOnDrag?: number[] | boolean;
|
|
99
|
-
panOnScroll?: boolean;
|
|
100
|
-
selectionOnDrag?: boolean;
|
|
101
|
-
colorMode?: ColorMode;
|
|
102
|
-
multiSelectionKey?: string[];
|
|
103
|
-
minZoom?: number;
|
|
104
|
-
maxZoom?: number;
|
|
105
|
-
selectionMode?: 'partial' | 'full';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Parametric point returned by a trajectory evaluation.
|
|
110
|
-
*/
|
|
111
|
-
export interface TrajectoryPoint {
|
|
112
|
-
position: XYPosition;
|
|
113
|
-
scale?: number;
|
|
114
|
-
opacity?: number;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Trajectory evaluation function determining path, scale, and opacity over time t in [0, 1].
|
|
119
|
-
*/
|
|
120
|
-
export type TrajectoryFunction = (
|
|
121
|
-
origin: XYPosition,
|
|
122
|
-
target: XYPosition,
|
|
123
|
-
progress: number,
|
|
124
|
-
index: number,
|
|
125
|
-
total: number
|
|
126
|
-
) => TrajectoryPoint;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Options for fan-out trajectory generator.
|
|
130
|
-
*/
|
|
131
|
-
export interface FanOutTrajectoryOptions {
|
|
132
|
-
curvature?: number;
|
|
133
|
-
spreadAngle?: number;
|
|
134
|
-
startScale?: number;
|
|
135
|
-
endScale?: number;
|
|
136
|
-
startOpacity?: number;
|
|
137
|
-
endOpacity?: number;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Single node animation transition definition.
|
|
142
|
-
*/
|
|
143
|
-
export interface NodeTransition<TNode extends CanvasNode = CanvasNode> {
|
|
144
|
-
node: TNode;
|
|
145
|
-
from: XYPosition;
|
|
146
|
-
to: XYPosition;
|
|
147
|
-
trajectory?: TrajectoryFunction;
|
|
148
|
-
delay?: number;
|
|
149
|
-
duration?: number;
|
|
150
|
-
easing?: (t: number) => number;
|
|
151
|
-
index?: number;
|
|
152
|
-
total?: number;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Displacement axis / direction.
|
|
157
|
-
*/
|
|
158
|
-
export type DisplacementDirection = 'right' | 'left' | 'down' | 'up' | 'vertical';
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Options for directional displacement calculation.
|
|
162
|
-
*/
|
|
163
|
-
export interface DirectionalDisplacementOptions {
|
|
164
|
-
direction?: DisplacementDirection;
|
|
165
|
-
gap?: number;
|
|
166
|
-
spreadSiblingLanes?: boolean;
|
|
167
|
-
siblingTolerance?: number;
|
|
168
|
-
minY?: number;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Options for Dagre reflow displacement calculation.
|
|
173
|
-
*/
|
|
174
|
-
export interface ReflowDisplacementOptions extends CanvasLayoutOptions {
|
|
175
|
-
anchorNodeId: string;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Snapshot of canvas graph state prior to node explosion, enabling exact reversibility.
|
|
180
|
-
*/
|
|
181
|
-
export interface ExplosionSnapshot<
|
|
182
|
-
TNode extends CanvasNode = CanvasNode,
|
|
183
|
-
TEdge extends CanvasEdge = CanvasEdge
|
|
184
|
-
> {
|
|
185
|
-
parentId: string;
|
|
186
|
-
childNodeIds: string[];
|
|
187
|
-
childEdgeIds: string[];
|
|
188
|
-
displacedNodes: { id: string; originalPosition: XYPosition }[];
|
|
189
|
-
timestamp: number;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Options for exploding a node.
|
|
194
|
-
*/
|
|
195
|
-
export interface ExplodeNodeOptions<
|
|
196
|
-
TNode extends CanvasNode = CanvasNode,
|
|
197
|
-
TEdge extends CanvasEdge = CanvasEdge
|
|
198
|
-
> {
|
|
199
|
-
childNodes: TNode[];
|
|
200
|
-
childEdges?: TEdge[];
|
|
201
|
-
connectParentToChildren?: boolean | 'first' | 'all';
|
|
202
|
-
connectChildrenToDownstream?: boolean;
|
|
203
|
-
displacementStrategy?: 'directional' | 'dagre' | 'none';
|
|
204
|
-
directionalOptions?: DirectionalDisplacementOptions;
|
|
205
|
-
reflowOptions?: Partial<ReflowDisplacementOptions>;
|
|
206
|
-
trajectory?: TrajectoryFunction;
|
|
207
|
-
duration?: number;
|
|
208
|
-
staggerDelay?: number;
|
|
209
|
-
easing?: (t: number) => number;
|
|
210
|
-
onComplete?: () => void;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Options for collapsing an exploded node.
|
|
215
|
-
*/
|
|
216
|
-
export interface CollapseNodeOptions {
|
|
217
|
-
duration?: number;
|
|
218
|
-
staggerDelay?: number;
|
|
219
|
-
easing?: (t: number) => number;
|
|
220
|
-
trajectory?: TrajectoryFunction;
|
|
221
|
-
onComplete?: () => void;
|
|
222
|
-
}
|
|
223
|
-
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
export interface CreateNavigationGuardOptions {
|
|
2
|
-
/** Function or boolean returning whether there are unsaved changes */
|
|
3
|
-
isDirty: boolean | (() => boolean);
|
|
4
|
-
/** Whether guarding is enabled (defaults to true) */
|
|
5
|
-
enabled?: boolean | (() => boolean);
|
|
6
|
-
/** Optional custom navigation callback (e.g. SvelteKit goto) */
|
|
7
|
-
onNavigate?: (url: string) => void;
|
|
8
|
-
/** Optional callback fired when an internal navigation is intercepted */
|
|
9
|
-
onBlocked?: (url: string) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface NavigationGuardManager {
|
|
13
|
-
readonly showConfirm: boolean;
|
|
14
|
-
setShowConfirm(show: boolean): void;
|
|
15
|
-
readonly pendingUrl: string | null;
|
|
16
|
-
intercept(url: string): boolean;
|
|
17
|
-
confirmLeave(): void;
|
|
18
|
-
cancelLeave(): void;
|
|
19
|
-
destroy(): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Headless Svelte 5 rune managing navigation guard state and beforeunload interception.
|
|
24
|
-
*/
|
|
25
|
-
export function createNavigationGuard(
|
|
26
|
-
options: CreateNavigationGuardOptions,
|
|
27
|
-
): NavigationGuardManager {
|
|
28
|
-
let showConfirm = $state(false);
|
|
29
|
-
let pendingUrl = $state<string | null>(null);
|
|
30
|
-
|
|
31
|
-
const getIsDirty = () =>
|
|
32
|
-
typeof options.isDirty === "function" ? options.isDirty() : options.isDirty;
|
|
33
|
-
|
|
34
|
-
const getEnabled = () =>
|
|
35
|
-
typeof options.enabled === "function"
|
|
36
|
-
? options.enabled()
|
|
37
|
-
: (options.enabled ?? true);
|
|
38
|
-
|
|
39
|
-
function handleBeforeUnload(e: BeforeUnloadEvent) {
|
|
40
|
-
if (!getEnabled() || !getIsDirty()) return;
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
e.returnValue = "";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (typeof window !== "undefined") {
|
|
46
|
-
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function intercept(url: string): boolean {
|
|
50
|
-
if (getEnabled() && getIsDirty()) {
|
|
51
|
-
pendingUrl = url;
|
|
52
|
-
showConfirm = true;
|
|
53
|
-
options.onBlocked?.(url);
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function confirmLeave() {
|
|
60
|
-
showConfirm = false;
|
|
61
|
-
const target = pendingUrl;
|
|
62
|
-
if (target) {
|
|
63
|
-
if (options.onNavigate) {
|
|
64
|
-
options.onNavigate(target);
|
|
65
|
-
} else if (typeof window !== "undefined") {
|
|
66
|
-
window.location.href = target;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function cancelLeave() {
|
|
72
|
-
showConfirm = false;
|
|
73
|
-
pendingUrl = null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function destroy() {
|
|
77
|
-
if (typeof window !== "undefined") {
|
|
78
|
-
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
get showConfirm() {
|
|
84
|
-
return showConfirm;
|
|
85
|
-
},
|
|
86
|
-
setShowConfirm(val: boolean) {
|
|
87
|
-
showConfirm = val;
|
|
88
|
-
},
|
|
89
|
-
get pendingUrl() {
|
|
90
|
-
return pendingUrl;
|
|
91
|
-
},
|
|
92
|
-
intercept,
|
|
93
|
-
confirmLeave,
|
|
94
|
-
cancelLeave,
|
|
95
|
-
destroy,
|
|
96
|
-
};
|
|
97
|
-
}
|
package/src/editor.svelte.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Editor, type Content, type EditorOptions, type Extensions } from "@tiptap/core";
|
|
2
|
-
import { createRichTextPreset, type RichTextPresetOptions } from "@pixerate/editor";
|
|
3
|
-
|
|
4
|
-
export interface SvelteInitiateEditorOptions extends Partial<EditorOptions> {
|
|
5
|
-
richTextOptions?: RichTextPresetOptions;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Initializes a TipTap editor instance preconfigured with rich text extensions.
|
|
10
|
-
*/
|
|
11
|
-
export const initiateEditor = (
|
|
12
|
-
element?: HTMLElement,
|
|
13
|
-
content?: Content,
|
|
14
|
-
extensions?: Extensions,
|
|
15
|
-
options?: SvelteInitiateEditorOptions,
|
|
16
|
-
): Editor => {
|
|
17
|
-
const { richTextOptions, ...editorOptions } = options || {};
|
|
18
|
-
const defaultPreset = createRichTextPreset(richTextOptions);
|
|
19
|
-
|
|
20
|
-
const editor = new Editor({
|
|
21
|
-
element,
|
|
22
|
-
content,
|
|
23
|
-
extensions: [
|
|
24
|
-
...defaultPreset,
|
|
25
|
-
...(extensions ?? []),
|
|
26
|
-
],
|
|
27
|
-
autofocus: false,
|
|
28
|
-
...editorOptions,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return editor;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export interface ReactiveEditorState {
|
|
35
|
-
editor: Editor | undefined;
|
|
36
|
-
content: string;
|
|
37
|
-
isEditable: boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Creates a reactive editor state manager for Svelte 5.
|
|
42
|
-
*/
|
|
43
|
-
export function createReactiveEditor(
|
|
44
|
-
initialContent: string = "",
|
|
45
|
-
extensions: Extensions = [],
|
|
46
|
-
options: Partial<EditorOptions> = {},
|
|
47
|
-
) {
|
|
48
|
-
let editorInstance: Editor | undefined;
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
get current() {
|
|
52
|
-
return editorInstance;
|
|
53
|
-
},
|
|
54
|
-
mount(element: HTMLElement) {
|
|
55
|
-
editorInstance = initiateEditor(element, initialContent, extensions, options);
|
|
56
|
-
return editorInstance;
|
|
57
|
-
},
|
|
58
|
-
destroy() {
|
|
59
|
-
if (editorInstance) {
|
|
60
|
-
editorInstance.destroy();
|
|
61
|
-
editorInstance = undefined;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { HistoryManager } from "@pixerate/editor";
|
|
2
|
-
|
|
3
|
-
export interface HistoryShortcutsOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Whether keyboard shortcuts are enabled. Defaults to true.
|
|
6
|
-
*/
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Target element or window to listen on. Defaults to window.
|
|
10
|
-
*/
|
|
11
|
-
target?: Window | HTMLElement | null;
|
|
12
|
-
/**
|
|
13
|
-
* When true (default), shortcuts will not trigger if an <input>, <textarea>,
|
|
14
|
-
* or [contenteditable] element is currently active / focused.
|
|
15
|
-
*/
|
|
16
|
-
ignoreEditableElements?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Attaches keyboard listeners for Undo (Mod+Z) and Redo (Mod+Shift+Z / Mod+Y).
|
|
21
|
-
* Returns an object with a `destroy()` function for lifecycle cleanup.
|
|
22
|
-
*/
|
|
23
|
-
export function createHistoryShortcuts(
|
|
24
|
-
manager: HistoryManager,
|
|
25
|
-
options: HistoryShortcutsOptions = {},
|
|
26
|
-
): { destroy: () => void } {
|
|
27
|
-
const {
|
|
28
|
-
enabled = true,
|
|
29
|
-
target,
|
|
30
|
-
ignoreEditableElements = true,
|
|
31
|
-
} = options;
|
|
32
|
-
|
|
33
|
-
if (!enabled) {
|
|
34
|
-
return { destroy: () => {} };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
|
|
38
|
-
if (!eventTarget) {
|
|
39
|
-
return { destroy: () => {} };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const handleKeyDown = (event: Event) => {
|
|
43
|
-
const e = event as KeyboardEvent;
|
|
44
|
-
const isMac =
|
|
45
|
-
typeof navigator !== "undefined" &&
|
|
46
|
-
/Mac|iPod|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
47
|
-
const modifier = isMac ? e.metaKey : e.ctrlKey;
|
|
48
|
-
|
|
49
|
-
if (!modifier) return;
|
|
50
|
-
|
|
51
|
-
if (ignoreEditableElements && typeof document !== "undefined") {
|
|
52
|
-
const targetEl = (e.target || document.activeElement) as HTMLElement | null;
|
|
53
|
-
if (targetEl && targetEl.tagName) {
|
|
54
|
-
const tagName = targetEl.tagName.toLowerCase();
|
|
55
|
-
const isInput = tagName === "input" || tagName === "textarea";
|
|
56
|
-
const isContentEditable =
|
|
57
|
-
targetEl.isContentEditable ||
|
|
58
|
-
targetEl.getAttribute?.("contenteditable") === "true";
|
|
59
|
-
if (isInput || isContentEditable) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const key = e.key?.toLowerCase();
|
|
66
|
-
|
|
67
|
-
// Undo: Mod+Z (without Shift)
|
|
68
|
-
if (key === "z" && !e.shiftKey) {
|
|
69
|
-
if (manager.getState().canUndo) {
|
|
70
|
-
e.preventDefault();
|
|
71
|
-
manager.undo();
|
|
72
|
-
}
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Redo: Mod+Shift+Z or (on non-Mac) Mod+Y
|
|
77
|
-
const isRedoKey =
|
|
78
|
-
(key === "z" && e.shiftKey) || (!isMac && key === "y" && !e.shiftKey);
|
|
79
|
-
|
|
80
|
-
if (isRedoKey) {
|
|
81
|
-
if (manager.getState().canRedo) {
|
|
82
|
-
e.preventDefault();
|
|
83
|
-
manager.redo();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
eventTarget.addEventListener("keydown", handleKeyDown);
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
destroy: () => {
|
|
92
|
-
eventTarget.removeEventListener("keydown", handleKeyDown);
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HistoryManager,
|
|
3
|
-
HistoryState,
|
|
4
|
-
Command,
|
|
5
|
-
createHistoryManager,
|
|
6
|
-
HistoryManagerOptions,
|
|
7
|
-
} from "@pixerate/editor";
|
|
8
|
-
|
|
9
|
-
export interface SvelteHistory extends HistoryState {
|
|
10
|
-
readonly manager: HistoryManager;
|
|
11
|
-
undo(): boolean;
|
|
12
|
-
redo(): boolean;
|
|
13
|
-
clear(): void;
|
|
14
|
-
execute(command: Command): void;
|
|
15
|
-
executeMerged(command: Command, options?: { windowMs?: number }): void;
|
|
16
|
-
batch(name: string, fn: () => void): void;
|
|
17
|
-
subscribe(run: (value: HistoryState) => void): () => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates a reactive Svelte 5 rune-based and Svelte store-compatible history adapter.
|
|
22
|
-
*/
|
|
23
|
-
export function createHistory(
|
|
24
|
-
managerOrOptions?: HistoryManager | HistoryManagerOptions,
|
|
25
|
-
): SvelteHistory {
|
|
26
|
-
const manager =
|
|
27
|
-
managerOrOptions instanceof HistoryManager
|
|
28
|
-
? managerOrOptions
|
|
29
|
-
: createHistoryManager(managerOrOptions);
|
|
30
|
-
|
|
31
|
-
let state = $state<HistoryState>(manager.getState());
|
|
32
|
-
|
|
33
|
-
manager.subscribe((newState) => {
|
|
34
|
-
state = newState;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
get canUndo() {
|
|
39
|
-
return state.canUndo;
|
|
40
|
-
},
|
|
41
|
-
get canRedo() {
|
|
42
|
-
return state.canRedo;
|
|
43
|
-
},
|
|
44
|
-
get undoName() {
|
|
45
|
-
return state.undoName;
|
|
46
|
-
},
|
|
47
|
-
get redoName() {
|
|
48
|
-
return state.redoName;
|
|
49
|
-
},
|
|
50
|
-
get undoCount() {
|
|
51
|
-
return state.undoCount;
|
|
52
|
-
},
|
|
53
|
-
get redoCount() {
|
|
54
|
-
return state.redoCount;
|
|
55
|
-
},
|
|
56
|
-
get manager() {
|
|
57
|
-
return manager;
|
|
58
|
-
},
|
|
59
|
-
undo: () => manager.undo(),
|
|
60
|
-
redo: () => manager.redo(),
|
|
61
|
-
clear: () => manager.clear(),
|
|
62
|
-
execute: (cmd: Command) => manager.execute(cmd),
|
|
63
|
-
executeMerged: (cmd: Command, opts?: { windowMs?: number }) =>
|
|
64
|
-
manager.executeMerged(cmd, opts),
|
|
65
|
-
batch: (name: string, fn: () => void) => manager.batch(name, fn),
|
|
66
|
-
subscribe: (run: (value: HistoryState) => void) => manager.subscribe(run),
|
|
67
|
-
};
|
|
68
|
-
}
|
package/src/history/index.ts
DELETED