@fieldnotes/core 0.16.0 → 0.18.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.d.cts CHANGED
@@ -411,12 +411,14 @@ declare class HistoryRecorder {
411
411
  private readonly layerManager?;
412
412
  private recording;
413
413
  private transaction;
414
+ private generation;
414
415
  private updateSnapshots;
415
416
  private unsubscribers;
416
417
  constructor(store: ElementStore, stack: HistoryStack, layerManager?: LayerManager | undefined);
417
418
  pause(): void;
418
419
  resume(): void;
419
420
  begin(): void;
421
+ get currentTransactionId(): number | null;
420
422
  commit(): void;
421
423
  rollback(): void;
422
424
  destroy(): void;
@@ -435,6 +437,7 @@ interface InputHandlerOptions {
435
437
  toolContext?: ToolContext;
436
438
  historyRecorder?: HistoryRecorder;
437
439
  historyStack?: HistoryStack;
440
+ fitToContent?: () => void;
438
441
  }
439
442
  declare class InputHandler {
440
443
  private readonly element;
@@ -454,10 +457,10 @@ declare class InputHandler {
454
457
  private readonly inputFilter;
455
458
  private deferredDown;
456
459
  private readonly abortController;
457
- private clipboard;
458
- private pasteCount;
460
+ private readonly actions;
459
461
  constructor(element: HTMLElement, camera: Camera, options?: InputHandlerOptions);
460
462
  setToolManager(toolManager: ToolManager, toolContext: ToolContext): void;
463
+ flushPendingHistory(): void;
461
464
  destroy(): void;
462
465
  private bind;
463
466
  private onWheel;
@@ -476,12 +479,6 @@ declare class InputHandler {
476
479
  private dispatchToolMove;
477
480
  private dispatchToolHover;
478
481
  private dispatchToolUp;
479
- private deleteSelected;
480
- private handleUndo;
481
- private handleRedo;
482
- private handleCopy;
483
- private handlePaste;
484
- private handleZOrder;
485
482
  private cancelToolIfActive;
486
483
  }
487
484
 
@@ -612,12 +609,14 @@ declare class Viewport {
612
609
  get ctx(): CanvasRenderingContext2D | null;
613
610
  get snapToGrid(): boolean;
614
611
  setSnapToGrid(enabled: boolean): void;
612
+ fitToContent(padding?: number): void;
615
613
  requestRender(): void;
616
614
  exportState(): CanvasState;
617
615
  exportJSON(): string;
618
616
  exportImage(options?: ExportImageOptions): Promise<Blob | null>;
619
617
  loadState(state: CanvasState): void;
620
618
  loadJSON(json: string): void;
619
+ setTool(name: string): void;
621
620
  undo(): boolean;
622
621
  redo(): boolean;
623
622
  addImage(src: string, position: {
@@ -976,6 +975,8 @@ declare class SelectTool implements Tool {
976
975
  onPointerUp(_state: PointerState, ctx: ToolContext): void;
977
976
  onHover(state: PointerState, ctx: ToolContext): void;
978
977
  renderOverlay(canvasCtx: CanvasRenderingContext2D): void;
978
+ private updateArrowsBoundTo;
979
+ nudgeSelection(dx: number, dy: number, ctx: ToolContext): boolean;
979
980
  private updateHoverCursor;
980
981
  private handleResize;
981
982
  private hitTestResizeHandle;
@@ -1211,6 +1212,6 @@ declare class UpdateLayerCommand implements Command {
1211
1212
  undo(_store: ElementStore): void;
1212
1213
  }
1213
1214
 
1214
- declare const VERSION = "0.16.0";
1215
+ declare const VERSION = "0.18.0";
1215
1216
 
1216
- 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 };
1217
+ 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 InputHandlerOptions, 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
@@ -411,12 +411,14 @@ declare class HistoryRecorder {
411
411
  private readonly layerManager?;
412
412
  private recording;
413
413
  private transaction;
414
+ private generation;
414
415
  private updateSnapshots;
415
416
  private unsubscribers;
416
417
  constructor(store: ElementStore, stack: HistoryStack, layerManager?: LayerManager | undefined);
417
418
  pause(): void;
418
419
  resume(): void;
419
420
  begin(): void;
421
+ get currentTransactionId(): number | null;
420
422
  commit(): void;
421
423
  rollback(): void;
422
424
  destroy(): void;
@@ -435,6 +437,7 @@ interface InputHandlerOptions {
435
437
  toolContext?: ToolContext;
436
438
  historyRecorder?: HistoryRecorder;
437
439
  historyStack?: HistoryStack;
440
+ fitToContent?: () => void;
438
441
  }
439
442
  declare class InputHandler {
440
443
  private readonly element;
@@ -454,10 +457,10 @@ declare class InputHandler {
454
457
  private readonly inputFilter;
455
458
  private deferredDown;
456
459
  private readonly abortController;
457
- private clipboard;
458
- private pasteCount;
460
+ private readonly actions;
459
461
  constructor(element: HTMLElement, camera: Camera, options?: InputHandlerOptions);
460
462
  setToolManager(toolManager: ToolManager, toolContext: ToolContext): void;
463
+ flushPendingHistory(): void;
461
464
  destroy(): void;
462
465
  private bind;
463
466
  private onWheel;
@@ -476,12 +479,6 @@ declare class InputHandler {
476
479
  private dispatchToolMove;
477
480
  private dispatchToolHover;
478
481
  private dispatchToolUp;
479
- private deleteSelected;
480
- private handleUndo;
481
- private handleRedo;
482
- private handleCopy;
483
- private handlePaste;
484
- private handleZOrder;
485
482
  private cancelToolIfActive;
486
483
  }
487
484
 
@@ -612,12 +609,14 @@ declare class Viewport {
612
609
  get ctx(): CanvasRenderingContext2D | null;
613
610
  get snapToGrid(): boolean;
614
611
  setSnapToGrid(enabled: boolean): void;
612
+ fitToContent(padding?: number): void;
615
613
  requestRender(): void;
616
614
  exportState(): CanvasState;
617
615
  exportJSON(): string;
618
616
  exportImage(options?: ExportImageOptions): Promise<Blob | null>;
619
617
  loadState(state: CanvasState): void;
620
618
  loadJSON(json: string): void;
619
+ setTool(name: string): void;
621
620
  undo(): boolean;
622
621
  redo(): boolean;
623
622
  addImage(src: string, position: {
@@ -976,6 +975,8 @@ declare class SelectTool implements Tool {
976
975
  onPointerUp(_state: PointerState, ctx: ToolContext): void;
977
976
  onHover(state: PointerState, ctx: ToolContext): void;
978
977
  renderOverlay(canvasCtx: CanvasRenderingContext2D): void;
978
+ private updateArrowsBoundTo;
979
+ nudgeSelection(dx: number, dy: number, ctx: ToolContext): boolean;
979
980
  private updateHoverCursor;
980
981
  private handleResize;
981
982
  private hitTestResizeHandle;
@@ -1211,6 +1212,6 @@ declare class UpdateLayerCommand implements Command {
1211
1212
  undo(_store: ElementStore): void;
1212
1213
  }
1213
1214
 
1214
- declare const VERSION = "0.16.0";
1215
+ declare const VERSION = "0.18.0";
1215
1216
 
1216
- 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 };
1217
+ 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 InputHandlerOptions, 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 };