@fieldnotes/core 0.3.0 → 0.3.1

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
@@ -44,6 +44,9 @@ interface NoteElement extends BaseElement {
44
44
  text: string;
45
45
  backgroundColor: string;
46
46
  }
47
+ interface Binding {
48
+ elementId: string;
49
+ }
47
50
  interface ArrowElement extends BaseElement {
48
51
  type: 'arrow';
49
52
  from: Point;
@@ -51,6 +54,8 @@ interface ArrowElement extends BaseElement {
51
54
  bend: number;
52
55
  color: string;
53
56
  width: number;
57
+ fromBinding?: Binding;
58
+ toBinding?: Binding;
54
59
  }
55
60
  interface ImageElement extends BaseElement {
56
61
  type: 'image';
@@ -381,6 +386,7 @@ declare class Viewport {
381
386
  private onDrop;
382
387
  private syncDomNode;
383
388
  private renderDomContent;
389
+ private unbindArrowsFrom;
384
390
  private removeDomNode;
385
391
  private clearDomNodes;
386
392
  private createWrapper;
@@ -392,11 +398,14 @@ declare class Viewport {
392
398
  }
393
399
 
394
400
  declare class ElementRenderer {
401
+ private store;
402
+ setStore(store: ElementStore): void;
395
403
  isDomElement(element: CanvasElement): boolean;
396
404
  renderCanvasElement(ctx: CanvasRenderingContext2D, element: CanvasElement): void;
397
405
  private renderStroke;
398
406
  private renderArrow;
399
407
  private renderArrowhead;
408
+ private getVisualEndpoints;
400
409
  }
401
410
 
402
411
  declare class NoteEditor {
@@ -441,6 +450,8 @@ interface ArrowInput extends BaseDefaults {
441
450
  bend?: number;
442
451
  color?: string;
443
452
  width?: number;
453
+ fromBinding?: Binding;
454
+ toBinding?: Binding;
444
455
  }
445
456
  interface ImageInput extends BaseDefaults {
446
457
  position: Point;
@@ -479,6 +490,16 @@ declare function getArrowTangentAngle(from: Point, to: Point, bend: number, t: n
479
490
  declare function isNearBezier(point: Point, from: Point, to: Point, bend: number, threshold: number): boolean;
480
491
  declare function getArrowBounds(from: Point, to: Point, bend: number): Rect;
481
492
 
493
+ declare function isBindable(element: CanvasElement): boolean;
494
+ declare function getElementCenter(element: CanvasElement): Point;
495
+ declare function getElementBounds(element: CanvasElement): Rect | null;
496
+ declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
497
+ declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string): CanvasElement | null;
498
+ declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
499
+ declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
500
+ declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
501
+ declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement>;
502
+
482
503
  declare class AddElementCommand implements Command {
483
504
  private readonly element;
484
505
  constructor(element: CanvasElement);
@@ -579,6 +600,7 @@ declare class SelectTool implements Tool {
579
600
  private getHandlePositions;
580
601
  private renderMarquee;
581
602
  private renderSelectionBoxes;
603
+ private renderBindingHighlights;
582
604
  private getMarqueeRect;
583
605
  private findElementsInRect;
584
606
  private rectsOverlap;
@@ -598,6 +620,9 @@ declare class ArrowTool implements Tool {
598
620
  private end;
599
621
  private color;
600
622
  private width;
623
+ private fromBinding;
624
+ private fromTarget;
625
+ private toTarget;
601
626
  constructor(options?: ArrowToolOptions);
602
627
  setOptions(options: ArrowToolOptions): void;
603
628
  onPointerDown(state: PointerState, ctx: ToolContext): void;
@@ -654,6 +679,6 @@ declare class ImageTool implements Tool {
654
679
  onPointerUp(state: PointerState, ctx: ToolContext): void;
655
680
  }
656
681
 
657
- declare const VERSION = "0.3.0";
682
+ declare const VERSION = "0.3.1";
658
683
 
659
- export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, 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 Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, VERSION, Viewport, type ViewportOptions, createArrow, createHtmlElement, createId, createImage, createNote, createStroke, createText, exportState, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, isNearBezier, parseState };
684
+ 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 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, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, unbindArrow, updateBoundArrow };
package/dist/index.d.ts CHANGED
@@ -44,6 +44,9 @@ interface NoteElement extends BaseElement {
44
44
  text: string;
45
45
  backgroundColor: string;
46
46
  }
47
+ interface Binding {
48
+ elementId: string;
49
+ }
47
50
  interface ArrowElement extends BaseElement {
48
51
  type: 'arrow';
49
52
  from: Point;
@@ -51,6 +54,8 @@ interface ArrowElement extends BaseElement {
51
54
  bend: number;
52
55
  color: string;
53
56
  width: number;
57
+ fromBinding?: Binding;
58
+ toBinding?: Binding;
54
59
  }
55
60
  interface ImageElement extends BaseElement {
56
61
  type: 'image';
@@ -381,6 +386,7 @@ declare class Viewport {
381
386
  private onDrop;
382
387
  private syncDomNode;
383
388
  private renderDomContent;
389
+ private unbindArrowsFrom;
384
390
  private removeDomNode;
385
391
  private clearDomNodes;
386
392
  private createWrapper;
@@ -392,11 +398,14 @@ declare class Viewport {
392
398
  }
393
399
 
394
400
  declare class ElementRenderer {
401
+ private store;
402
+ setStore(store: ElementStore): void;
395
403
  isDomElement(element: CanvasElement): boolean;
396
404
  renderCanvasElement(ctx: CanvasRenderingContext2D, element: CanvasElement): void;
397
405
  private renderStroke;
398
406
  private renderArrow;
399
407
  private renderArrowhead;
408
+ private getVisualEndpoints;
400
409
  }
401
410
 
402
411
  declare class NoteEditor {
@@ -441,6 +450,8 @@ interface ArrowInput extends BaseDefaults {
441
450
  bend?: number;
442
451
  color?: string;
443
452
  width?: number;
453
+ fromBinding?: Binding;
454
+ toBinding?: Binding;
444
455
  }
445
456
  interface ImageInput extends BaseDefaults {
446
457
  position: Point;
@@ -479,6 +490,16 @@ declare function getArrowTangentAngle(from: Point, to: Point, bend: number, t: n
479
490
  declare function isNearBezier(point: Point, from: Point, to: Point, bend: number, threshold: number): boolean;
480
491
  declare function getArrowBounds(from: Point, to: Point, bend: number): Rect;
481
492
 
493
+ declare function isBindable(element: CanvasElement): boolean;
494
+ declare function getElementCenter(element: CanvasElement): Point;
495
+ declare function getElementBounds(element: CanvasElement): Rect | null;
496
+ declare function getEdgeIntersection(bounds: Rect, outsidePoint: Point): Point;
497
+ declare function findBindTarget(point: Point, store: ElementStore, threshold: number, excludeId?: string): CanvasElement | null;
498
+ declare function findBoundArrows(elementId: string, store: ElementStore): ArrowElement[];
499
+ declare function updateBoundArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
500
+ declare function clearStaleBindings(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement> | null;
501
+ declare function unbindArrow(arrow: ArrowElement, store: ElementStore): Partial<ArrowElement>;
502
+
482
503
  declare class AddElementCommand implements Command {
483
504
  private readonly element;
484
505
  constructor(element: CanvasElement);
@@ -579,6 +600,7 @@ declare class SelectTool implements Tool {
579
600
  private getHandlePositions;
580
601
  private renderMarquee;
581
602
  private renderSelectionBoxes;
603
+ private renderBindingHighlights;
582
604
  private getMarqueeRect;
583
605
  private findElementsInRect;
584
606
  private rectsOverlap;
@@ -598,6 +620,9 @@ declare class ArrowTool implements Tool {
598
620
  private end;
599
621
  private color;
600
622
  private width;
623
+ private fromBinding;
624
+ private fromTarget;
625
+ private toTarget;
601
626
  constructor(options?: ArrowToolOptions);
602
627
  setOptions(options: ArrowToolOptions): void;
603
628
  onPointerDown(state: PointerState, ctx: ToolContext): void;
@@ -654,6 +679,6 @@ declare class ImageTool implements Tool {
654
679
  onPointerUp(state: PointerState, ctx: ToolContext): void;
655
680
  }
656
681
 
657
- declare const VERSION = "0.3.0";
682
+ declare const VERSION = "0.3.1";
658
683
 
659
- export { AddElementCommand, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, Background, type BackgroundOptions, type BackgroundPattern, BatchCommand, 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 Size, type StrokeElement, type StrokePoint, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, UpdateElementCommand, VERSION, Viewport, type ViewportOptions, createArrow, createHtmlElement, createId, createImage, createNote, createStroke, createText, exportState, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, isNearBezier, parseState };
684
+ 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 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, createStroke, createText, exportState, findBindTarget, findBoundArrows, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, isBindable, isNearBezier, parseState, unbindArrow, updateBoundArrow };