@fieldnotes/core 0.4.1 → 0.6.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/index.cjs +375 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -4
- package/dist/index.d.ts +95 -4
- package/dist/index.js +370 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -30,6 +30,7 @@ interface BaseElement {
|
|
|
30
30
|
position: Point;
|
|
31
31
|
zIndex: number;
|
|
32
32
|
locked: boolean;
|
|
33
|
+
layerId: string;
|
|
33
34
|
}
|
|
34
35
|
interface StrokeElement extends BaseElement {
|
|
35
36
|
type: 'stroke';
|
|
@@ -87,6 +88,15 @@ interface ShapeElement extends BaseElement {
|
|
|
87
88
|
type CanvasElement = StrokeElement | NoteElement | ArrowElement | ImageElement | HtmlElement | TextElement | ShapeElement;
|
|
88
89
|
type ElementType = CanvasElement['type'];
|
|
89
90
|
|
|
91
|
+
interface Layer {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
visible: boolean;
|
|
95
|
+
locked: boolean;
|
|
96
|
+
order: number;
|
|
97
|
+
opacity: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
interface CanvasState {
|
|
91
101
|
version: number;
|
|
92
102
|
camera: {
|
|
@@ -94,13 +104,16 @@ interface CanvasState {
|
|
|
94
104
|
zoom: number;
|
|
95
105
|
};
|
|
96
106
|
elements: CanvasElement[];
|
|
107
|
+
layers?: Layer[];
|
|
97
108
|
}
|
|
98
109
|
declare function exportState(elements: CanvasElement[], camera: {
|
|
99
110
|
position: Point;
|
|
100
111
|
zoom: number;
|
|
101
|
-
}): CanvasState;
|
|
112
|
+
}, layers?: Layer[]): CanvasState;
|
|
102
113
|
declare function parseState(json: string): CanvasState;
|
|
103
114
|
|
|
115
|
+
declare function snapPoint(point: Point, gridSize: number): Point;
|
|
116
|
+
|
|
104
117
|
interface ElementUpdateEvent {
|
|
105
118
|
previous: CanvasElement;
|
|
106
119
|
current: CanvasElement;
|
|
@@ -114,7 +127,9 @@ interface ElementStoreEvents {
|
|
|
114
127
|
declare class ElementStore {
|
|
115
128
|
private elements;
|
|
116
129
|
private bus;
|
|
130
|
+
private layerOrderMap;
|
|
117
131
|
get count(): number;
|
|
132
|
+
setLayerOrder(order: Map<string, number>): void;
|
|
118
133
|
getAll(): CanvasElement[];
|
|
119
134
|
getById(id: string): CanvasElement | undefined;
|
|
120
135
|
getElementsByType<T extends ElementType>(type: T): Extract<CanvasElement, {
|
|
@@ -154,15 +169,47 @@ declare class Camera {
|
|
|
154
169
|
private notifyChange;
|
|
155
170
|
}
|
|
156
171
|
|
|
172
|
+
declare class LayerManager {
|
|
173
|
+
private readonly store;
|
|
174
|
+
private layers;
|
|
175
|
+
private _activeLayerId;
|
|
176
|
+
private bus;
|
|
177
|
+
constructor(store: ElementStore);
|
|
178
|
+
get activeLayer(): Layer;
|
|
179
|
+
get activeLayerId(): string;
|
|
180
|
+
getLayers(): Layer[];
|
|
181
|
+
getLayer(id: string): Layer | undefined;
|
|
182
|
+
isLayerVisible(id: string): boolean;
|
|
183
|
+
isLayerLocked(id: string): boolean;
|
|
184
|
+
createLayer(name?: string): Layer;
|
|
185
|
+
removeLayer(id: string): void;
|
|
186
|
+
renameLayer(id: string, name: string): void;
|
|
187
|
+
reorderLayer(id: string, newOrder: number): void;
|
|
188
|
+
setLayerVisible(id: string, visible: boolean): boolean;
|
|
189
|
+
setLayerLocked(id: string, locked: boolean): boolean;
|
|
190
|
+
setActiveLayer(id: string): void;
|
|
191
|
+
moveElementToLayer(elementId: string, layerId: string): void;
|
|
192
|
+
snapshot(): Layer[];
|
|
193
|
+
loadSnapshot(layers: Layer[]): void;
|
|
194
|
+
on(event: 'change', callback: () => void): () => void;
|
|
195
|
+
addLayerDirect(layer: Layer): void;
|
|
196
|
+
removeLayerDirect(id: string): void;
|
|
197
|
+
updateLayerDirect(id: string, props: Omit<Partial<Layer>, 'id'>): void;
|
|
198
|
+
private syncLayerOrder;
|
|
199
|
+
private findFallbackLayer;
|
|
200
|
+
}
|
|
201
|
+
|
|
157
202
|
interface AutoSaveOptions {
|
|
158
203
|
key?: string;
|
|
159
204
|
debounceMs?: number;
|
|
205
|
+
layerManager?: LayerManager;
|
|
160
206
|
}
|
|
161
207
|
declare class AutoSave {
|
|
162
208
|
private readonly store;
|
|
163
209
|
private readonly camera;
|
|
164
210
|
private readonly key;
|
|
165
211
|
private readonly debounceMs;
|
|
212
|
+
private readonly layerManager?;
|
|
166
213
|
private timerId;
|
|
167
214
|
private unsubscribers;
|
|
168
215
|
constructor(store: ElementStore, camera: Camera, options?: AutoSaveOptions);
|
|
@@ -203,6 +250,11 @@ interface ToolContext {
|
|
|
203
250
|
switchTool?: (name: string) => void;
|
|
204
251
|
editElement?: (id: string) => void;
|
|
205
252
|
setCursor?: (cursor: string) => void;
|
|
253
|
+
snapToGrid?: boolean;
|
|
254
|
+
gridSize?: number;
|
|
255
|
+
activeLayerId?: string;
|
|
256
|
+
isLayerVisible?: (layerId: string) => boolean;
|
|
257
|
+
isLayerLocked?: (layerId: string) => boolean;
|
|
206
258
|
}
|
|
207
259
|
interface PointerState {
|
|
208
260
|
x: number;
|
|
@@ -338,6 +390,7 @@ declare class Viewport {
|
|
|
338
390
|
private readonly container;
|
|
339
391
|
readonly camera: Camera;
|
|
340
392
|
readonly store: ElementStore;
|
|
393
|
+
readonly layerManager: LayerManager;
|
|
341
394
|
readonly toolManager: ToolManager;
|
|
342
395
|
readonly history: HistoryStack;
|
|
343
396
|
readonly domLayer: HTMLDivElement;
|
|
@@ -353,12 +406,16 @@ declare class Viewport {
|
|
|
353
406
|
readonly toolContext: ToolContext;
|
|
354
407
|
private resizeObserver;
|
|
355
408
|
private animFrameId;
|
|
409
|
+
private _snapToGrid;
|
|
410
|
+
private readonly _gridSize;
|
|
356
411
|
private needsRender;
|
|
357
412
|
private domNodes;
|
|
358
413
|
private htmlContent;
|
|
359
414
|
private interactingElementId;
|
|
360
415
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
361
416
|
get ctx(): CanvasRenderingContext2D | null;
|
|
417
|
+
get snapToGrid(): boolean;
|
|
418
|
+
setSnapToGrid(enabled: boolean): void;
|
|
362
419
|
requestRender(): void;
|
|
363
420
|
exportState(): CanvasState;
|
|
364
421
|
exportJSON(): string;
|
|
@@ -397,6 +454,7 @@ declare class Viewport {
|
|
|
397
454
|
private syncDomNode;
|
|
398
455
|
private renderDomContent;
|
|
399
456
|
private unbindArrowsFrom;
|
|
457
|
+
private hideDomNode;
|
|
400
458
|
private removeDomNode;
|
|
401
459
|
private clearDomNodes;
|
|
402
460
|
private createWrapper;
|
|
@@ -409,7 +467,10 @@ declare class Viewport {
|
|
|
409
467
|
|
|
410
468
|
declare class ElementRenderer {
|
|
411
469
|
private store;
|
|
470
|
+
private imageCache;
|
|
471
|
+
private onImageLoad;
|
|
412
472
|
setStore(store: ElementStore): void;
|
|
473
|
+
setOnImageLoad(callback: () => void): void;
|
|
413
474
|
isDomElement(element: CanvasElement): boolean;
|
|
414
475
|
renderCanvasElement(ctx: CanvasRenderingContext2D, element: CanvasElement): void;
|
|
415
476
|
private renderStroke;
|
|
@@ -419,6 +480,8 @@ declare class ElementRenderer {
|
|
|
419
480
|
private renderShape;
|
|
420
481
|
private fillShapePath;
|
|
421
482
|
private strokeShapePath;
|
|
483
|
+
private renderImage;
|
|
484
|
+
private getImage;
|
|
422
485
|
}
|
|
423
486
|
|
|
424
487
|
declare class NoteEditor {
|
|
@@ -444,6 +507,7 @@ interface BaseDefaults {
|
|
|
444
507
|
position?: Point;
|
|
445
508
|
zIndex?: number;
|
|
446
509
|
locked?: boolean;
|
|
510
|
+
layerId?: string;
|
|
447
511
|
}
|
|
448
512
|
interface StrokeInput extends BaseDefaults {
|
|
449
513
|
points: StrokePoint[];
|
|
@@ -517,7 +581,7 @@ declare function isBindable(element: CanvasElement): boolean;
|
|
|
517
581
|
declare function getElementCenter(element: CanvasElement): Point;
|
|
518
582
|
declare function getElementBounds(element: CanvasElement): Rect | null;
|
|
519
583
|
declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
|
|
520
|
-
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string): CanvasElement | null;
|
|
584
|
+
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string, filter?: (el: CanvasElement) => boolean): CanvasElement | null;
|
|
521
585
|
declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
|
|
522
586
|
declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
523
587
|
declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
@@ -612,6 +676,7 @@ declare class SelectTool implements Tool {
|
|
|
612
676
|
get isMarqueeActive(): boolean;
|
|
613
677
|
onActivate(ctx: ToolContext): void;
|
|
614
678
|
onDeactivate(ctx: ToolContext): void;
|
|
679
|
+
private snap;
|
|
615
680
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
616
681
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
617
682
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
@@ -648,6 +713,7 @@ declare class ArrowTool implements Tool {
|
|
|
648
713
|
private toTarget;
|
|
649
714
|
constructor(options?: ArrowToolOptions);
|
|
650
715
|
setOptions(options: ArrowToolOptions): void;
|
|
716
|
+
private layerFilter;
|
|
651
717
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
652
718
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
653
719
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
@@ -729,10 +795,35 @@ declare class ShapeTool implements Tool {
|
|
|
729
795
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
730
796
|
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
731
797
|
private computeRect;
|
|
798
|
+
private snap;
|
|
732
799
|
private onKeyDown;
|
|
733
800
|
private onKeyUp;
|
|
734
801
|
}
|
|
735
802
|
|
|
736
|
-
declare
|
|
803
|
+
declare class CreateLayerCommand implements Command {
|
|
804
|
+
private readonly manager;
|
|
805
|
+
private readonly layer;
|
|
806
|
+
constructor(manager: LayerManager, layer: Layer);
|
|
807
|
+
execute(_store: ElementStore): void;
|
|
808
|
+
undo(_store: ElementStore): void;
|
|
809
|
+
}
|
|
810
|
+
declare class RemoveLayerCommand implements Command {
|
|
811
|
+
private readonly manager;
|
|
812
|
+
private readonly layer;
|
|
813
|
+
constructor(manager: LayerManager, layer: Layer);
|
|
814
|
+
execute(_store: ElementStore): void;
|
|
815
|
+
undo(_store: ElementStore): void;
|
|
816
|
+
}
|
|
817
|
+
declare class UpdateLayerCommand implements Command {
|
|
818
|
+
private readonly manager;
|
|
819
|
+
private readonly layerId;
|
|
820
|
+
private readonly previous;
|
|
821
|
+
private readonly current;
|
|
822
|
+
constructor(manager: LayerManager, layerId: string, previous: Layer, current: Layer);
|
|
823
|
+
execute(_store: ElementStore): void;
|
|
824
|
+
undo(_store: ElementStore): void;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
declare const VERSION = "0.6.0";
|
|
737
828
|
|
|
738
|
-
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, HandTool, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, unbindArrow, updateBoundArrow };
|
|
829
|
+
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, HandTool, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ interface BaseElement {
|
|
|
30
30
|
position: Point;
|
|
31
31
|
zIndex: number;
|
|
32
32
|
locked: boolean;
|
|
33
|
+
layerId: string;
|
|
33
34
|
}
|
|
34
35
|
interface StrokeElement extends BaseElement {
|
|
35
36
|
type: 'stroke';
|
|
@@ -87,6 +88,15 @@ interface ShapeElement extends BaseElement {
|
|
|
87
88
|
type CanvasElement = StrokeElement | NoteElement | ArrowElement | ImageElement | HtmlElement | TextElement | ShapeElement;
|
|
88
89
|
type ElementType = CanvasElement['type'];
|
|
89
90
|
|
|
91
|
+
interface Layer {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
visible: boolean;
|
|
95
|
+
locked: boolean;
|
|
96
|
+
order: number;
|
|
97
|
+
opacity: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
interface CanvasState {
|
|
91
101
|
version: number;
|
|
92
102
|
camera: {
|
|
@@ -94,13 +104,16 @@ interface CanvasState {
|
|
|
94
104
|
zoom: number;
|
|
95
105
|
};
|
|
96
106
|
elements: CanvasElement[];
|
|
107
|
+
layers?: Layer[];
|
|
97
108
|
}
|
|
98
109
|
declare function exportState(elements: CanvasElement[], camera: {
|
|
99
110
|
position: Point;
|
|
100
111
|
zoom: number;
|
|
101
|
-
}): CanvasState;
|
|
112
|
+
}, layers?: Layer[]): CanvasState;
|
|
102
113
|
declare function parseState(json: string): CanvasState;
|
|
103
114
|
|
|
115
|
+
declare function snapPoint(point: Point, gridSize: number): Point;
|
|
116
|
+
|
|
104
117
|
interface ElementUpdateEvent {
|
|
105
118
|
previous: CanvasElement;
|
|
106
119
|
current: CanvasElement;
|
|
@@ -114,7 +127,9 @@ interface ElementStoreEvents {
|
|
|
114
127
|
declare class ElementStore {
|
|
115
128
|
private elements;
|
|
116
129
|
private bus;
|
|
130
|
+
private layerOrderMap;
|
|
117
131
|
get count(): number;
|
|
132
|
+
setLayerOrder(order: Map<string, number>): void;
|
|
118
133
|
getAll(): CanvasElement[];
|
|
119
134
|
getById(id: string): CanvasElement | undefined;
|
|
120
135
|
getElementsByType<T extends ElementType>(type: T): Extract<CanvasElement, {
|
|
@@ -154,15 +169,47 @@ declare class Camera {
|
|
|
154
169
|
private notifyChange;
|
|
155
170
|
}
|
|
156
171
|
|
|
172
|
+
declare class LayerManager {
|
|
173
|
+
private readonly store;
|
|
174
|
+
private layers;
|
|
175
|
+
private _activeLayerId;
|
|
176
|
+
private bus;
|
|
177
|
+
constructor(store: ElementStore);
|
|
178
|
+
get activeLayer(): Layer;
|
|
179
|
+
get activeLayerId(): string;
|
|
180
|
+
getLayers(): Layer[];
|
|
181
|
+
getLayer(id: string): Layer | undefined;
|
|
182
|
+
isLayerVisible(id: string): boolean;
|
|
183
|
+
isLayerLocked(id: string): boolean;
|
|
184
|
+
createLayer(name?: string): Layer;
|
|
185
|
+
removeLayer(id: string): void;
|
|
186
|
+
renameLayer(id: string, name: string): void;
|
|
187
|
+
reorderLayer(id: string, newOrder: number): void;
|
|
188
|
+
setLayerVisible(id: string, visible: boolean): boolean;
|
|
189
|
+
setLayerLocked(id: string, locked: boolean): boolean;
|
|
190
|
+
setActiveLayer(id: string): void;
|
|
191
|
+
moveElementToLayer(elementId: string, layerId: string): void;
|
|
192
|
+
snapshot(): Layer[];
|
|
193
|
+
loadSnapshot(layers: Layer[]): void;
|
|
194
|
+
on(event: 'change', callback: () => void): () => void;
|
|
195
|
+
addLayerDirect(layer: Layer): void;
|
|
196
|
+
removeLayerDirect(id: string): void;
|
|
197
|
+
updateLayerDirect(id: string, props: Omit<Partial<Layer>, 'id'>): void;
|
|
198
|
+
private syncLayerOrder;
|
|
199
|
+
private findFallbackLayer;
|
|
200
|
+
}
|
|
201
|
+
|
|
157
202
|
interface AutoSaveOptions {
|
|
158
203
|
key?: string;
|
|
159
204
|
debounceMs?: number;
|
|
205
|
+
layerManager?: LayerManager;
|
|
160
206
|
}
|
|
161
207
|
declare class AutoSave {
|
|
162
208
|
private readonly store;
|
|
163
209
|
private readonly camera;
|
|
164
210
|
private readonly key;
|
|
165
211
|
private readonly debounceMs;
|
|
212
|
+
private readonly layerManager?;
|
|
166
213
|
private timerId;
|
|
167
214
|
private unsubscribers;
|
|
168
215
|
constructor(store: ElementStore, camera: Camera, options?: AutoSaveOptions);
|
|
@@ -203,6 +250,11 @@ interface ToolContext {
|
|
|
203
250
|
switchTool?: (name: string) => void;
|
|
204
251
|
editElement?: (id: string) => void;
|
|
205
252
|
setCursor?: (cursor: string) => void;
|
|
253
|
+
snapToGrid?: boolean;
|
|
254
|
+
gridSize?: number;
|
|
255
|
+
activeLayerId?: string;
|
|
256
|
+
isLayerVisible?: (layerId: string) => boolean;
|
|
257
|
+
isLayerLocked?: (layerId: string) => boolean;
|
|
206
258
|
}
|
|
207
259
|
interface PointerState {
|
|
208
260
|
x: number;
|
|
@@ -338,6 +390,7 @@ declare class Viewport {
|
|
|
338
390
|
private readonly container;
|
|
339
391
|
readonly camera: Camera;
|
|
340
392
|
readonly store: ElementStore;
|
|
393
|
+
readonly layerManager: LayerManager;
|
|
341
394
|
readonly toolManager: ToolManager;
|
|
342
395
|
readonly history: HistoryStack;
|
|
343
396
|
readonly domLayer: HTMLDivElement;
|
|
@@ -353,12 +406,16 @@ declare class Viewport {
|
|
|
353
406
|
readonly toolContext: ToolContext;
|
|
354
407
|
private resizeObserver;
|
|
355
408
|
private animFrameId;
|
|
409
|
+
private _snapToGrid;
|
|
410
|
+
private readonly _gridSize;
|
|
356
411
|
private needsRender;
|
|
357
412
|
private domNodes;
|
|
358
413
|
private htmlContent;
|
|
359
414
|
private interactingElementId;
|
|
360
415
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
361
416
|
get ctx(): CanvasRenderingContext2D | null;
|
|
417
|
+
get snapToGrid(): boolean;
|
|
418
|
+
setSnapToGrid(enabled: boolean): void;
|
|
362
419
|
requestRender(): void;
|
|
363
420
|
exportState(): CanvasState;
|
|
364
421
|
exportJSON(): string;
|
|
@@ -397,6 +454,7 @@ declare class Viewport {
|
|
|
397
454
|
private syncDomNode;
|
|
398
455
|
private renderDomContent;
|
|
399
456
|
private unbindArrowsFrom;
|
|
457
|
+
private hideDomNode;
|
|
400
458
|
private removeDomNode;
|
|
401
459
|
private clearDomNodes;
|
|
402
460
|
private createWrapper;
|
|
@@ -409,7 +467,10 @@ declare class Viewport {
|
|
|
409
467
|
|
|
410
468
|
declare class ElementRenderer {
|
|
411
469
|
private store;
|
|
470
|
+
private imageCache;
|
|
471
|
+
private onImageLoad;
|
|
412
472
|
setStore(store: ElementStore): void;
|
|
473
|
+
setOnImageLoad(callback: () => void): void;
|
|
413
474
|
isDomElement(element: CanvasElement): boolean;
|
|
414
475
|
renderCanvasElement(ctx: CanvasRenderingContext2D, element: CanvasElement): void;
|
|
415
476
|
private renderStroke;
|
|
@@ -419,6 +480,8 @@ declare class ElementRenderer {
|
|
|
419
480
|
private renderShape;
|
|
420
481
|
private fillShapePath;
|
|
421
482
|
private strokeShapePath;
|
|
483
|
+
private renderImage;
|
|
484
|
+
private getImage;
|
|
422
485
|
}
|
|
423
486
|
|
|
424
487
|
declare class NoteEditor {
|
|
@@ -444,6 +507,7 @@ interface BaseDefaults {
|
|
|
444
507
|
position?: Point;
|
|
445
508
|
zIndex?: number;
|
|
446
509
|
locked?: boolean;
|
|
510
|
+
layerId?: string;
|
|
447
511
|
}
|
|
448
512
|
interface StrokeInput extends BaseDefaults {
|
|
449
513
|
points: StrokePoint[];
|
|
@@ -517,7 +581,7 @@ declare function isBindable(element: CanvasElement): boolean;
|
|
|
517
581
|
declare function getElementCenter(element: CanvasElement): Point;
|
|
518
582
|
declare function getElementBounds(element: CanvasElement): Rect | null;
|
|
519
583
|
declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
|
|
520
|
-
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string): CanvasElement | null;
|
|
584
|
+
declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string, filter?: (el: CanvasElement) => boolean): CanvasElement | null;
|
|
521
585
|
declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
|
|
522
586
|
declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
523
587
|
declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
|
|
@@ -612,6 +676,7 @@ declare class SelectTool implements Tool {
|
|
|
612
676
|
get isMarqueeActive(): boolean;
|
|
613
677
|
onActivate(ctx: ToolContext): void;
|
|
614
678
|
onDeactivate(ctx: ToolContext): void;
|
|
679
|
+
private snap;
|
|
615
680
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
616
681
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
617
682
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
@@ -648,6 +713,7 @@ declare class ArrowTool implements Tool {
|
|
|
648
713
|
private toTarget;
|
|
649
714
|
constructor(options?: ArrowToolOptions);
|
|
650
715
|
setOptions(options: ArrowToolOptions): void;
|
|
716
|
+
private layerFilter;
|
|
651
717
|
onPointerDown(state: PointerState, ctx: ToolContext): void;
|
|
652
718
|
onPointerMove(state: PointerState, ctx: ToolContext): void;
|
|
653
719
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
@@ -729,10 +795,35 @@ declare class ShapeTool implements Tool {
|
|
|
729
795
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
730
796
|
renderOverlay(ctx: CanvasRenderingContext2D): void;
|
|
731
797
|
private computeRect;
|
|
798
|
+
private snap;
|
|
732
799
|
private onKeyDown;
|
|
733
800
|
private onKeyUp;
|
|
734
801
|
}
|
|
735
802
|
|
|
736
|
-
declare
|
|
803
|
+
declare class CreateLayerCommand implements Command {
|
|
804
|
+
private readonly manager;
|
|
805
|
+
private readonly layer;
|
|
806
|
+
constructor(manager: LayerManager, layer: Layer);
|
|
807
|
+
execute(_store: ElementStore): void;
|
|
808
|
+
undo(_store: ElementStore): void;
|
|
809
|
+
}
|
|
810
|
+
declare class RemoveLayerCommand implements Command {
|
|
811
|
+
private readonly manager;
|
|
812
|
+
private readonly layer;
|
|
813
|
+
constructor(manager: LayerManager, layer: Layer);
|
|
814
|
+
execute(_store: ElementStore): void;
|
|
815
|
+
undo(_store: ElementStore): void;
|
|
816
|
+
}
|
|
817
|
+
declare class UpdateLayerCommand implements Command {
|
|
818
|
+
private readonly manager;
|
|
819
|
+
private readonly layerId;
|
|
820
|
+
private readonly previous;
|
|
821
|
+
private readonly current;
|
|
822
|
+
constructor(manager: LayerManager, layerId: string, previous: Layer, current: Layer);
|
|
823
|
+
execute(_store: ElementStore): void;
|
|
824
|
+
undo(_store: ElementStore): void;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
declare const VERSION = "0.6.0";
|
|
737
828
|
|
|
738
|
-
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, HandTool, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, unbindArrow, updateBoundArrow };
|
|
829
|
+
export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, HandTool, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, RemoveElementCommand, RemoveLayerCommand, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, clearStaleBindings, createArrow, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, snapPoint, unbindArrow, updateBoundArrow };
|