@pixerate/editor 0.22.0 → 0.23.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/README.md +80 -2
- package/THIRD_PARTY_NOTICES.md +88 -0
- package/dist/agent/index.cjs +83 -108
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +69 -211
- package/dist/agent/index.d.ts +69 -211
- package/dist/agent/index.js +76 -101
- package/dist/agent/index.js.map +1 -1
- package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
- package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
- package/dist/canvas/index.cjs +879 -83
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +291 -186
- package/dist/canvas/index.d.ts +291 -186
- package/dist/canvas/index.js +865 -69
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-26BVFKHU.cjs +453 -0
- package/dist/chunk-26BVFKHU.cjs.map +1 -0
- package/dist/chunk-2H7ZHPEJ.js +762 -0
- package/dist/chunk-2H7ZHPEJ.js.map +1 -0
- package/dist/chunk-7DWMJCAT.js +453 -0
- package/dist/chunk-7DWMJCAT.js.map +1 -0
- package/dist/chunk-ARRTP33I.js +101 -0
- package/dist/chunk-ARRTP33I.js.map +1 -0
- package/dist/chunk-CPOKFNBG.cjs +101 -0
- package/dist/chunk-CPOKFNBG.cjs.map +1 -0
- package/dist/chunk-G2I4QJOT.cjs +762 -0
- package/dist/chunk-G2I4QJOT.cjs.map +1 -0
- package/dist/{chunk-RU52I7QO.js → chunk-K3R5NG2D.js} +147 -42
- package/dist/chunk-K3R5NG2D.js.map +1 -0
- package/dist/{chunk-DENSCKFC.js → chunk-QBJ22YZR.js} +423 -30
- package/dist/chunk-QBJ22YZR.js.map +1 -0
- package/dist/{chunk-SAZRENEZ.cjs → chunk-RIKBJLS2.cjs} +424 -31
- package/dist/chunk-RIKBJLS2.cjs.map +1 -0
- package/dist/{chunk-6M3BCTBD.cjs → chunk-XDMXXC4Z.cjs} +230 -125
- package/dist/chunk-XDMXXC4Z.cjs.map +1 -0
- package/dist/commands/index.cjs +860 -0
- package/dist/commands/index.cjs.map +1 -0
- package/dist/commands/index.d.cts +592 -0
- package/dist/commands/index.d.ts +592 -0
- package/dist/commands/index.js +860 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/{controller-B7GIybc4.d.cts → controller-pePCJLT1.d.cts} +78 -5
- package/dist/{controller-B7GIybc4.d.ts → controller-pePCJLT1.d.ts} +78 -5
- package/dist/history/index.cjs +12 -2
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +211 -7
- package/dist/history/index.d.ts +211 -7
- package/dist/history/index.js +13 -3
- package/dist/image-editor/index.cjs +418 -13
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +154 -3
- package/dist/image-editor/index.d.ts +154 -3
- package/dist/image-editor/index.js +417 -12
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +34 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -42
- package/dist/index.d.ts +5 -42
- package/dist/index.js +27 -69
- package/dist/index.js.map +1 -1
- package/dist/registry-D5-R90p0.d.cts +209 -0
- package/dist/registry-D5-R90p0.d.ts +209 -0
- package/dist/spreadsheet/index.cjs +19 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +67 -9
- package/dist/spreadsheet/index.d.ts +67 -9
- package/dist/spreadsheet/index.js +18 -2
- package/dist/{types-CJ4U-HHI.d.cts → types-DX4Mh4SL.d.cts} +1 -1
- package/dist/{types-CJ4U-HHI.d.ts → types-DX4Mh4SL.d.ts} +1 -1
- package/dist/types-GT5a5YAX.d.cts +86 -0
- package/dist/types-GT5a5YAX.d.ts +86 -0
- package/package.json +8 -2
- package/dist/chunk-2TWGLC5K.cjs +0 -262
- package/dist/chunk-2TWGLC5K.cjs.map +0 -1
- package/dist/chunk-6M3BCTBD.cjs.map +0 -1
- package/dist/chunk-DENSCKFC.js.map +0 -1
- package/dist/chunk-KAADNAPF.js +0 -262
- package/dist/chunk-KAADNAPF.js.map +0 -1
- package/dist/chunk-RU52I7QO.js.map +0 -1
- package/dist/chunk-SAZRENEZ.cjs.map +0 -1
- package/dist/types-BZgcDsC5.d.cts +0 -42
- package/dist/types-BZgcDsC5.d.ts +0 -42
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { R as Rect, X as XYPosition, C as CanvasNode, a as CanvasNodeStyle } from './types-DX4Mh4SL.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Edge (or centre line) used by `alignNodes`.
|
|
5
|
+
* `center` aligns horizontal centres (a vertical line); `middle` aligns vertical centres.
|
|
6
|
+
*/
|
|
7
|
+
type AlignEdge = 'left' | 'center' | 'right' | 'top' | 'middle' | 'bottom';
|
|
8
|
+
/** Axis used by `distributeNodes`. `both` distributes horizontally and vertically. */
|
|
9
|
+
type DistributeAxis = 'horizontal' | 'vertical' | 'both';
|
|
10
|
+
/**
|
|
11
|
+
* `gaps` leaves equal space between neighbouring nodes, `centres` spaces their centres equally.
|
|
12
|
+
*/
|
|
13
|
+
type DistributeMode = 'gaps' | 'centres';
|
|
14
|
+
/** Dimension(s) copied by `matchSize`. */
|
|
15
|
+
type SizeDimension = 'width' | 'height' | 'both';
|
|
16
|
+
/**
|
|
17
|
+
* Partial node change produced by the arrange helpers. `position` is in the node's own
|
|
18
|
+
* coordinate space (relative to its `parentId` parent when it has one).
|
|
19
|
+
*/
|
|
20
|
+
interface CanvasNodeUpdate {
|
|
21
|
+
id: string;
|
|
22
|
+
position?: XYPosition;
|
|
23
|
+
width?: number;
|
|
24
|
+
height?: number;
|
|
25
|
+
zIndex?: number;
|
|
26
|
+
}
|
|
27
|
+
interface NodeRectOptions {
|
|
28
|
+
/** Width used when a node has no measured, explicit or style size and estimation is off. */
|
|
29
|
+
defaultWidth?: number;
|
|
30
|
+
/** Height used when a node has no measured, explicit or style size and estimation is off. */
|
|
31
|
+
defaultHeight?: number;
|
|
32
|
+
/** Estimate unmeasured node sizes from their label via `estimateNodeSize` (default `true`). */
|
|
33
|
+
estimate?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** Data key marking a node as locked. See `lockNodes`. */
|
|
36
|
+
declare const LOCKED_DATA_KEY = "locked";
|
|
37
|
+
/** Data key holding the interaction flags a node had before it was locked. */
|
|
38
|
+
declare const LOCKED_PREVIOUS_FLAGS_KEY = "lockedPrevious";
|
|
39
|
+
/**
|
|
40
|
+
* Reads a pixel `width` / `height` from a node style, which may be a CSS string (SvelteFlow)
|
|
41
|
+
* or a style object (React Flow). Non-pixel values (`%`, `auto`, ...) are ignored.
|
|
42
|
+
*/
|
|
43
|
+
declare function readStyleSize(style: CanvasNodeStyle | undefined | null): {
|
|
44
|
+
width?: number;
|
|
45
|
+
height?: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Returns `style` with its pixel `width` / `height` replaced, keeping its representation
|
|
49
|
+
* (string or object). Only dimensions already present in the style are rewritten, because
|
|
50
|
+
* xyflow applies the node's own `width` / `height` props otherwise.
|
|
51
|
+
*/
|
|
52
|
+
declare function withStyleSize(style: CanvasNodeStyle | undefined | null, size: {
|
|
53
|
+
width?: number;
|
|
54
|
+
height?: number;
|
|
55
|
+
}): CanvasNodeStyle | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves a node's size: measured DOM size, then explicit `width` / `height`, then a pixel
|
|
58
|
+
* size in `style`, then a label-based estimate (or the defaults when `estimate` is `false`).
|
|
59
|
+
*/
|
|
60
|
+
declare function getNodeSize(node: CanvasNode, options?: NodeRectOptions): {
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Absolute (flow-space) position of a node, following its `parentId` chain.
|
|
66
|
+
* Cycles and missing parents are tolerated.
|
|
67
|
+
*/
|
|
68
|
+
declare function getAbsolutePosition(node: CanvasNode, lookup: ReadonlyMap<string, CanvasNode>): XYPosition;
|
|
69
|
+
/** Builds an id lookup for a node array. */
|
|
70
|
+
declare function createNodeLookup<TNode extends CanvasNode>(nodes: TNode[]): Map<string, TNode>;
|
|
71
|
+
/** Absolute flow-space rectangle of a node. */
|
|
72
|
+
declare function getNodeRect(node: CanvasNode, lookup?: ReadonlyMap<string, CanvasNode>, options?: NodeRectOptions): Rect;
|
|
73
|
+
/**
|
|
74
|
+
* Whether a node has been locked with `lockNodes`.
|
|
75
|
+
*/
|
|
76
|
+
declare function isLocked(node: CanvasNode | undefined | null): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Locks nodes: marks `data.locked = true` and sets `draggable: false` and `deletable: false`
|
|
79
|
+
* so both SvelteFlow and React Flow stop dragging and deleting them. Nodes stay `selectable`
|
|
80
|
+
* so they can be unlocked again. The previous flags are kept in `data.lockedPrevious` and
|
|
81
|
+
* restored by `unlockNodes`. Returns a new array; untouched nodes keep their identity.
|
|
82
|
+
*/
|
|
83
|
+
declare function lockNodes<TNode extends CanvasNode>(nodes: TNode[], ids: Iterable<string>): TNode[];
|
|
84
|
+
/**
|
|
85
|
+
* Reverses `lockNodes`, restoring the `draggable` / `deletable` flags the node had before.
|
|
86
|
+
*/
|
|
87
|
+
declare function unlockNodes<TNode extends CanvasNode>(nodes: TNode[], ids: Iterable<string>): TNode[];
|
|
88
|
+
/** Locks the given nodes if any of them is unlocked, otherwise unlocks them all. */
|
|
89
|
+
declare function toggleLockNodes<TNode extends CanvasNode>(nodes: TNode[], ids: Iterable<string>): TNode[];
|
|
90
|
+
interface AlignNodesOptions extends NodeRectOptions {
|
|
91
|
+
/**
|
|
92
|
+
* What to align to: the selection bounding box (default) or a fixed rectangle.
|
|
93
|
+
* Locked nodes never move but still count towards the selection bounds, so they act as anchors.
|
|
94
|
+
*/
|
|
95
|
+
to?: 'selection' | Rect;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Aligns nodes to a shared edge or centre line of their bounding box (Freeform's
|
|
99
|
+
* Align Left / Center / Right / Top / Middle / Bottom). Needs at least two nodes unless
|
|
100
|
+
* `options.to` is a rectangle. Locked nodes are not moved.
|
|
101
|
+
*/
|
|
102
|
+
declare function alignNodes(nodes: CanvasNode[], ids: Iterable<string>, edge: AlignEdge, options?: AlignNodesOptions): CanvasNodeUpdate[];
|
|
103
|
+
interface DistributeNodesOptions extends NodeRectOptions {
|
|
104
|
+
/** Explicit gap between neighbours for `gaps` mode. Default: spread evenly between the outer nodes. */
|
|
105
|
+
gap?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Distributes nodes along an axis (Freeform's Distribute Horizontally / Vertically / Evenly).
|
|
109
|
+
* The outermost nodes stay put and the others are spaced with equal gaps (`gaps`, default)
|
|
110
|
+
* or equally spaced centres (`centres`). Needs at least three nodes (two with an explicit
|
|
111
|
+
* `gap`). Locked nodes keep their place in the order but are not moved.
|
|
112
|
+
*/
|
|
113
|
+
declare function distributeNodes(nodes: CanvasNode[], ids: Iterable<string>, axis: DistributeAxis, mode?: DistributeMode, options?: DistributeNodesOptions): CanvasNodeUpdate[];
|
|
114
|
+
interface MatchSizeOptions extends NodeRectOptions {
|
|
115
|
+
/**
|
|
116
|
+
* Size source: the `largest` (default) or `smallest` node, the `first` id given,
|
|
117
|
+
* or a specific node id.
|
|
118
|
+
*/
|
|
119
|
+
reference?: 'largest' | 'smallest' | 'first' | {
|
|
120
|
+
id: string;
|
|
121
|
+
};
|
|
122
|
+
/** Keep each node's centre in place instead of its top-left corner (default `false`). */
|
|
123
|
+
keepCentre?: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Makes nodes the same width, height or both (Freeform's Make Same Size). Returns size
|
|
127
|
+
* updates (plus position updates with `keepCentre`). Locked nodes are not resized but can
|
|
128
|
+
* be the reference.
|
|
129
|
+
*/
|
|
130
|
+
declare function matchSize(nodes: CanvasNode[], ids: Iterable<string>, dimension: SizeDimension, options?: MatchSizeOptions): CanvasNodeUpdate[];
|
|
131
|
+
/** Z-order operation. */
|
|
132
|
+
type ZOrderOperation = 'bringForward' | 'sendBackward' | 'bringToFront' | 'sendToBack';
|
|
133
|
+
/**
|
|
134
|
+
* Restacks nodes (Bring Forward / Send Backward / Bring to Front / Send to Back).
|
|
135
|
+
*
|
|
136
|
+
* Both SvelteFlow and React Flow stack nodes by `zIndex` (missing = 0) and, for equal
|
|
137
|
+
* `zIndex`, by array order. This computes that effective order for the siblings that share
|
|
138
|
+
* the targets' parent, applies the operation, and returns `zIndex` updates assigning each
|
|
139
|
+
* sibling its new rank. The array order is left alone, because xyflow requires parents to
|
|
140
|
+
* precede their children. Locked nodes are not restacked. "Forward" moves past the next
|
|
141
|
+
* sibling the node overlaps, falling back to the next sibling when nothing overlaps.
|
|
142
|
+
*/
|
|
143
|
+
declare function reorderNodes(nodes: CanvasNode[], ids: Iterable<string>, operation: ZOrderOperation, options?: NodeRectOptions): CanvasNodeUpdate[];
|
|
144
|
+
/**
|
|
145
|
+
* Applies `CanvasNodeUpdate`s to a node array, returning a new array. Unchanged nodes keep
|
|
146
|
+
* their identity. Size updates set `width` / `height` and rewrite pixel sizes already present
|
|
147
|
+
* in `style` (string or object). An existing `measured` size is updated too, so geometry
|
|
148
|
+
* helpers see the new size before xyflow re-measures the node.
|
|
149
|
+
*/
|
|
150
|
+
declare function applyNodeUpdates<TNode extends CanvasNode>(nodes: TNode[], updates: CanvasNodeUpdate[]): TNode[];
|
|
151
|
+
/**
|
|
152
|
+
* Inverse of a set of updates against the current nodes, for undo. Restores the previous
|
|
153
|
+
* position / size / zIndex of every node an update touches.
|
|
154
|
+
*/
|
|
155
|
+
declare function invertNodeUpdates(nodes: CanvasNode[], updates: CanvasNodeUpdate[]): CanvasNodeUpdate[];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Canvas arrangement actions that have keyboard shortcuts.
|
|
159
|
+
*/
|
|
160
|
+
type CanvasArrangeAction = 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignTop' | 'alignMiddle' | 'alignBottom' | 'distributeHorizontal' | 'distributeVertical' | 'lock' | 'unlock' | 'bringForward' | 'sendBackward' | 'bringToFront' | 'sendToBack' | 'nextScene' | 'previousScene';
|
|
161
|
+
interface ArrangeShortcutBinding {
|
|
162
|
+
action: CanvasArrangeAction;
|
|
163
|
+
/** `KeyboardEvent.code` (layout- and Option-independent, e.g. `KeyA`, `BracketRight`). */
|
|
164
|
+
code: string;
|
|
165
|
+
mod?: boolean;
|
|
166
|
+
alt?: boolean;
|
|
167
|
+
shift?: boolean;
|
|
168
|
+
/** Human readable label, e.g. for menus. `Mod` is ⌘ on macOS and Ctrl elsewhere. */
|
|
169
|
+
label: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Default bindings. Align/distribute follow Figma (Option/Alt + letter), layer order follows
|
|
173
|
+
* the common `Mod+]` / `Mod+[` convention, lock follows Keynote/Freeform (`Mod+L`,
|
|
174
|
+
* `Mod+Alt+L` to unlock) and scenes step with PageDown / PageUp.
|
|
175
|
+
*/
|
|
176
|
+
declare const DEFAULT_ARRANGE_SHORTCUTS: readonly ArrangeShortcutBinding[];
|
|
177
|
+
/**
|
|
178
|
+
* Resolves a keydown event to an arrange action, or `null`. Events from text inputs,
|
|
179
|
+
* textareas, selects, contenteditable and ProseMirror are ignored (see `isEventFromTextInput`).
|
|
180
|
+
* `Mod` is ⌘ or Ctrl. Built on the command system's `ShortcutMap` (matching `event.code`).
|
|
181
|
+
*/
|
|
182
|
+
declare function matchArrangeShortcut(event: KeyboardEvent, bindings?: readonly ArrangeShortcutBinding[]): CanvasArrangeAction | null;
|
|
183
|
+
|
|
184
|
+
export { type AlignEdge as A, type CanvasArrangeAction as C, type DistributeAxis as D, LOCKED_DATA_KEY as L, type MatchSizeOptions as M, type NodeRectOptions as N, type SizeDimension as S, type ZOrderOperation as Z, type DistributeMode as a, type CanvasNodeUpdate as b, type AlignNodesOptions as c, type DistributeNodesOptions as d, type ArrangeShortcutBinding as e, DEFAULT_ARRANGE_SHORTCUTS as f, LOCKED_PREVIOUS_FLAGS_KEY as g, alignNodes as h, applyNodeUpdates as i, createNodeLookup as j, distributeNodes as k, getAbsolutePosition as l, getNodeRect as m, getNodeSize as n, invertNodeUpdates as o, isLocked as p, lockNodes as q, matchArrangeShortcut as r, matchSize as s, readStyleSize as t, reorderNodes as u, toggleLockNodes as v, unlockNodes as w, withStyleSize as x };
|