@fieldnotes/core 0.15.0 → 0.17.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 +471 -220
- package/dist/index.d.cts +31 -11
- package/dist/index.d.ts +31 -11
- package/dist/index.js +471 -220
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -270,6 +270,15 @@ declare function snapPoint(point: Point, gridSize: number): Point;
|
|
|
270
270
|
declare function snapToHexCenter(point: Point, cellSize: number, orientation: HexOrientation): Point;
|
|
271
271
|
declare function smartSnap(point: Point, ctx: ToolContext): Point;
|
|
272
272
|
|
|
273
|
+
interface LayerManagerEvents {
|
|
274
|
+
change: null;
|
|
275
|
+
create: Layer;
|
|
276
|
+
remove: Layer;
|
|
277
|
+
update: {
|
|
278
|
+
previous: Layer;
|
|
279
|
+
current: Layer;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
273
282
|
declare class LayerManager {
|
|
274
283
|
private readonly store;
|
|
275
284
|
private layers;
|
|
@@ -293,7 +302,7 @@ declare class LayerManager {
|
|
|
293
302
|
moveElementToLayer(elementId: string, layerId: string): void;
|
|
294
303
|
snapshot(): Layer[];
|
|
295
304
|
loadSnapshot(layers: Layer[]): void;
|
|
296
|
-
on(event:
|
|
305
|
+
on<K extends keyof LayerManagerEvents>(event: K, callback: (data: LayerManagerEvents[K]) => void): () => void;
|
|
297
306
|
addLayerDirect(layer: Layer): void;
|
|
298
307
|
removeLayerDirect(id: string): void;
|
|
299
308
|
updateLayerDirect(id: string, props: Omit<Partial<Layer>, 'id'>): void;
|
|
@@ -399,11 +408,12 @@ declare class HistoryStack {
|
|
|
399
408
|
declare class HistoryRecorder {
|
|
400
409
|
private readonly store;
|
|
401
410
|
private readonly stack;
|
|
411
|
+
private readonly layerManager?;
|
|
402
412
|
private recording;
|
|
403
413
|
private transaction;
|
|
404
414
|
private updateSnapshots;
|
|
405
415
|
private unsubscribers;
|
|
406
|
-
constructor(store: ElementStore, stack: HistoryStack);
|
|
416
|
+
constructor(store: ElementStore, stack: HistoryStack, layerManager?: LayerManager | undefined);
|
|
407
417
|
pause(): void;
|
|
408
418
|
resume(): void;
|
|
409
419
|
begin(): void;
|
|
@@ -414,6 +424,9 @@ declare class HistoryRecorder {
|
|
|
414
424
|
private onAdd;
|
|
415
425
|
private onRemove;
|
|
416
426
|
private onUpdate;
|
|
427
|
+
private onLayerCreate;
|
|
428
|
+
private onLayerRemove;
|
|
429
|
+
private onLayerUpdate;
|
|
417
430
|
private flushUpdateSnapshots;
|
|
418
431
|
}
|
|
419
432
|
|
|
@@ -422,6 +435,7 @@ interface InputHandlerOptions {
|
|
|
422
435
|
toolContext?: ToolContext;
|
|
423
436
|
historyRecorder?: HistoryRecorder;
|
|
424
437
|
historyStack?: HistoryStack;
|
|
438
|
+
fitToContent?: () => void;
|
|
425
439
|
}
|
|
426
440
|
declare class InputHandler {
|
|
427
441
|
private readonly element;
|
|
@@ -441,10 +455,10 @@ declare class InputHandler {
|
|
|
441
455
|
private readonly inputFilter;
|
|
442
456
|
private deferredDown;
|
|
443
457
|
private readonly abortController;
|
|
444
|
-
private
|
|
445
|
-
private pasteCount;
|
|
458
|
+
private readonly actions;
|
|
446
459
|
constructor(element: HTMLElement, camera: Camera, options?: InputHandlerOptions);
|
|
447
460
|
setToolManager(toolManager: ToolManager, toolContext: ToolContext): void;
|
|
461
|
+
flushPendingHistory(): void;
|
|
448
462
|
destroy(): void;
|
|
449
463
|
private bind;
|
|
450
464
|
private onWheel;
|
|
@@ -463,12 +477,6 @@ declare class InputHandler {
|
|
|
463
477
|
private dispatchToolMove;
|
|
464
478
|
private dispatchToolHover;
|
|
465
479
|
private dispatchToolUp;
|
|
466
|
-
private deleteSelected;
|
|
467
|
-
private handleUndo;
|
|
468
|
-
private handleRedo;
|
|
469
|
-
private handleCopy;
|
|
470
|
-
private handlePaste;
|
|
471
|
-
private handleZOrder;
|
|
472
480
|
private cancelToolIfActive;
|
|
473
481
|
}
|
|
474
482
|
|
|
@@ -559,6 +567,11 @@ interface ViewportOptions {
|
|
|
559
567
|
background?: BackgroundOptions;
|
|
560
568
|
fontSizePresets?: FontSizePreset[];
|
|
561
569
|
toolbar?: boolean;
|
|
570
|
+
onHtmlElementMount?: (elementId: string, domId: string | undefined, container: HTMLDivElement) => void;
|
|
571
|
+
onDrop?: (event: DragEvent, worldPosition: {
|
|
572
|
+
x: number;
|
|
573
|
+
y: number;
|
|
574
|
+
}) => void;
|
|
562
575
|
}
|
|
563
576
|
declare class Viewport {
|
|
564
577
|
private readonly container;
|
|
@@ -584,6 +597,8 @@ declare class Viewport {
|
|
|
584
597
|
private readonly renderLoop;
|
|
585
598
|
private readonly domNodeManager;
|
|
586
599
|
private readonly interactMode;
|
|
600
|
+
private readonly onHtmlElementMount?;
|
|
601
|
+
private readonly dropHandler?;
|
|
587
602
|
private readonly gridChangeListeners;
|
|
588
603
|
private readonly doubleTapDetector;
|
|
589
604
|
private tapDownX;
|
|
@@ -592,6 +607,7 @@ declare class Viewport {
|
|
|
592
607
|
get ctx(): CanvasRenderingContext2D | null;
|
|
593
608
|
get snapToGrid(): boolean;
|
|
594
609
|
setSnapToGrid(enabled: boolean): void;
|
|
610
|
+
fitToContent(padding?: number): void;
|
|
595
611
|
requestRender(): void;
|
|
596
612
|
exportState(): CanvasState;
|
|
597
613
|
exportJSON(): string;
|
|
@@ -614,6 +630,8 @@ declare class Viewport {
|
|
|
614
630
|
w: number;
|
|
615
631
|
h: number;
|
|
616
632
|
}): string;
|
|
633
|
+
removeLayer(id: string): void;
|
|
634
|
+
updateHtmlElement(id: string, newContent: HTMLElement): void;
|
|
617
635
|
addGrid(input: {
|
|
618
636
|
gridType?: 'square' | 'hex';
|
|
619
637
|
hexOrientation?: 'pointy' | 'flat';
|
|
@@ -954,6 +972,8 @@ declare class SelectTool implements Tool {
|
|
|
954
972
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
955
973
|
onHover(state: PointerState, ctx: ToolContext): void;
|
|
956
974
|
renderOverlay(canvasCtx: CanvasRenderingContext2D): void;
|
|
975
|
+
private updateArrowsBoundTo;
|
|
976
|
+
nudgeSelection(dx: number, dy: number, ctx: ToolContext): boolean;
|
|
957
977
|
private updateHoverCursor;
|
|
958
978
|
private handleResize;
|
|
959
979
|
private hitTestResizeHandle;
|
|
@@ -1189,6 +1209,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
1189
1209
|
undo(_store: ElementStore): void;
|
|
1190
1210
|
}
|
|
1191
1211
|
|
|
1192
|
-
declare const VERSION = "0.
|
|
1212
|
+
declare const VERSION = "0.17.0";
|
|
1193
1213
|
|
|
1194
1214
|
export { type ActiveFormats, AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, DEFAULT_FONT_SIZE_PRESETS, DEFAULT_NOTE_FONT_SIZE, DoubleTapDetector, type DoubleTapDetectorOptions, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FilterAction, type FilteredEvent, type FilteredUpEvent, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputFilter, InputHandler, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, NoteEditor, type NoteEditorOptions, type NoteElement, NoteTool, type NoteToolOptions, NoteToolbar, PencilTool, type PencilToolOptions, type Point, type PointerState, Quadtree, RemoveElementCommand, RemoveLayerCommand, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type StyledRun, type TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, boundsIntersect, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportState, findBindTarget, findBoundArrows, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, sanitizeNoteHtml, setFontSize, smartSnap, snapPoint, snapToHexCenter, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline, unbindArrow, updateBoundArrow };
|
package/dist/index.d.ts
CHANGED
|
@@ -270,6 +270,15 @@ declare function snapPoint(point: Point, gridSize: number): Point;
|
|
|
270
270
|
declare function snapToHexCenter(point: Point, cellSize: number, orientation: HexOrientation): Point;
|
|
271
271
|
declare function smartSnap(point: Point, ctx: ToolContext): Point;
|
|
272
272
|
|
|
273
|
+
interface LayerManagerEvents {
|
|
274
|
+
change: null;
|
|
275
|
+
create: Layer;
|
|
276
|
+
remove: Layer;
|
|
277
|
+
update: {
|
|
278
|
+
previous: Layer;
|
|
279
|
+
current: Layer;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
273
282
|
declare class LayerManager {
|
|
274
283
|
private readonly store;
|
|
275
284
|
private layers;
|
|
@@ -293,7 +302,7 @@ declare class LayerManager {
|
|
|
293
302
|
moveElementToLayer(elementId: string, layerId: string): void;
|
|
294
303
|
snapshot(): Layer[];
|
|
295
304
|
loadSnapshot(layers: Layer[]): void;
|
|
296
|
-
on(event:
|
|
305
|
+
on<K extends keyof LayerManagerEvents>(event: K, callback: (data: LayerManagerEvents[K]) => void): () => void;
|
|
297
306
|
addLayerDirect(layer: Layer): void;
|
|
298
307
|
removeLayerDirect(id: string): void;
|
|
299
308
|
updateLayerDirect(id: string, props: Omit<Partial<Layer>, 'id'>): void;
|
|
@@ -399,11 +408,12 @@ declare class HistoryStack {
|
|
|
399
408
|
declare class HistoryRecorder {
|
|
400
409
|
private readonly store;
|
|
401
410
|
private readonly stack;
|
|
411
|
+
private readonly layerManager?;
|
|
402
412
|
private recording;
|
|
403
413
|
private transaction;
|
|
404
414
|
private updateSnapshots;
|
|
405
415
|
private unsubscribers;
|
|
406
|
-
constructor(store: ElementStore, stack: HistoryStack);
|
|
416
|
+
constructor(store: ElementStore, stack: HistoryStack, layerManager?: LayerManager | undefined);
|
|
407
417
|
pause(): void;
|
|
408
418
|
resume(): void;
|
|
409
419
|
begin(): void;
|
|
@@ -414,6 +424,9 @@ declare class HistoryRecorder {
|
|
|
414
424
|
private onAdd;
|
|
415
425
|
private onRemove;
|
|
416
426
|
private onUpdate;
|
|
427
|
+
private onLayerCreate;
|
|
428
|
+
private onLayerRemove;
|
|
429
|
+
private onLayerUpdate;
|
|
417
430
|
private flushUpdateSnapshots;
|
|
418
431
|
}
|
|
419
432
|
|
|
@@ -422,6 +435,7 @@ interface InputHandlerOptions {
|
|
|
422
435
|
toolContext?: ToolContext;
|
|
423
436
|
historyRecorder?: HistoryRecorder;
|
|
424
437
|
historyStack?: HistoryStack;
|
|
438
|
+
fitToContent?: () => void;
|
|
425
439
|
}
|
|
426
440
|
declare class InputHandler {
|
|
427
441
|
private readonly element;
|
|
@@ -441,10 +455,10 @@ declare class InputHandler {
|
|
|
441
455
|
private readonly inputFilter;
|
|
442
456
|
private deferredDown;
|
|
443
457
|
private readonly abortController;
|
|
444
|
-
private
|
|
445
|
-
private pasteCount;
|
|
458
|
+
private readonly actions;
|
|
446
459
|
constructor(element: HTMLElement, camera: Camera, options?: InputHandlerOptions);
|
|
447
460
|
setToolManager(toolManager: ToolManager, toolContext: ToolContext): void;
|
|
461
|
+
flushPendingHistory(): void;
|
|
448
462
|
destroy(): void;
|
|
449
463
|
private bind;
|
|
450
464
|
private onWheel;
|
|
@@ -463,12 +477,6 @@ declare class InputHandler {
|
|
|
463
477
|
private dispatchToolMove;
|
|
464
478
|
private dispatchToolHover;
|
|
465
479
|
private dispatchToolUp;
|
|
466
|
-
private deleteSelected;
|
|
467
|
-
private handleUndo;
|
|
468
|
-
private handleRedo;
|
|
469
|
-
private handleCopy;
|
|
470
|
-
private handlePaste;
|
|
471
|
-
private handleZOrder;
|
|
472
480
|
private cancelToolIfActive;
|
|
473
481
|
}
|
|
474
482
|
|
|
@@ -559,6 +567,11 @@ interface ViewportOptions {
|
|
|
559
567
|
background?: BackgroundOptions;
|
|
560
568
|
fontSizePresets?: FontSizePreset[];
|
|
561
569
|
toolbar?: boolean;
|
|
570
|
+
onHtmlElementMount?: (elementId: string, domId: string | undefined, container: HTMLDivElement) => void;
|
|
571
|
+
onDrop?: (event: DragEvent, worldPosition: {
|
|
572
|
+
x: number;
|
|
573
|
+
y: number;
|
|
574
|
+
}) => void;
|
|
562
575
|
}
|
|
563
576
|
declare class Viewport {
|
|
564
577
|
private readonly container;
|
|
@@ -584,6 +597,8 @@ declare class Viewport {
|
|
|
584
597
|
private readonly renderLoop;
|
|
585
598
|
private readonly domNodeManager;
|
|
586
599
|
private readonly interactMode;
|
|
600
|
+
private readonly onHtmlElementMount?;
|
|
601
|
+
private readonly dropHandler?;
|
|
587
602
|
private readonly gridChangeListeners;
|
|
588
603
|
private readonly doubleTapDetector;
|
|
589
604
|
private tapDownX;
|
|
@@ -592,6 +607,7 @@ declare class Viewport {
|
|
|
592
607
|
get ctx(): CanvasRenderingContext2D | null;
|
|
593
608
|
get snapToGrid(): boolean;
|
|
594
609
|
setSnapToGrid(enabled: boolean): void;
|
|
610
|
+
fitToContent(padding?: number): void;
|
|
595
611
|
requestRender(): void;
|
|
596
612
|
exportState(): CanvasState;
|
|
597
613
|
exportJSON(): string;
|
|
@@ -614,6 +630,8 @@ declare class Viewport {
|
|
|
614
630
|
w: number;
|
|
615
631
|
h: number;
|
|
616
632
|
}): string;
|
|
633
|
+
removeLayer(id: string): void;
|
|
634
|
+
updateHtmlElement(id: string, newContent: HTMLElement): void;
|
|
617
635
|
addGrid(input: {
|
|
618
636
|
gridType?: 'square' | 'hex';
|
|
619
637
|
hexOrientation?: 'pointy' | 'flat';
|
|
@@ -954,6 +972,8 @@ declare class SelectTool implements Tool {
|
|
|
954
972
|
onPointerUp(_state: PointerState, ctx: ToolContext): void;
|
|
955
973
|
onHover(state: PointerState, ctx: ToolContext): void;
|
|
956
974
|
renderOverlay(canvasCtx: CanvasRenderingContext2D): void;
|
|
975
|
+
private updateArrowsBoundTo;
|
|
976
|
+
nudgeSelection(dx: number, dy: number, ctx: ToolContext): boolean;
|
|
957
977
|
private updateHoverCursor;
|
|
958
978
|
private handleResize;
|
|
959
979
|
private hitTestResizeHandle;
|
|
@@ -1189,6 +1209,6 @@ declare class UpdateLayerCommand implements Command {
|
|
|
1189
1209
|
undo(_store: ElementStore): void;
|
|
1190
1210
|
}
|
|
1191
1211
|
|
|
1192
|
-
declare const VERSION = "0.
|
|
1212
|
+
declare const VERSION = "0.17.0";
|
|
1193
1213
|
|
|
1194
1214
|
export { type ActiveFormats, AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, CreateLayerCommand, DEFAULT_FONT_SIZE_PRESETS, DEFAULT_NOTE_FONT_SIZE, DoubleTapDetector, type DoubleTapDetectorOptions, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FilterAction, type FilteredEvent, type FilteredUpEvent, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputFilter, InputHandler, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, NoteEditor, type NoteEditorOptions, type NoteElement, NoteTool, type NoteToolOptions, NoteToolbar, PencilTool, type PencilToolOptions, type Point, type PointerState, Quadtree, RemoveElementCommand, RemoveLayerCommand, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type Size, type StrokeElement, type StrokePoint, type StyledRun, type TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, UpdateLayerCommand, VERSION, Viewport, type ViewportOptions, boundsIntersect, clearStaleBindings, createArrow, createGrid, createHtmlElement, createId, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, exportState, findBindTarget, findBoundArrows, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, sanitizeNoteHtml, setFontSize, smartSnap, snapPoint, snapToHexCenter, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline, unbindArrow, updateBoundArrow };
|