@fieldnotes/core 0.34.0 → 0.36.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
@@ -22,6 +22,9 @@ interface BaseElement {
22
22
  layerId: string;
23
23
  /** Optional flat group membership. Elements sharing a groupId select/move/delete as a unit. */
24
24
  groupId?: string;
25
+ /** Rotation in radians (clockwise) about the element's center. Absent = 0 (unrotated).
26
+ * Applied to note/text/image/html/shape/stroke; ignored for arrow/grid/template. */
27
+ rotation?: number;
25
28
  }
26
29
  interface StrokeElement extends BaseElement {
27
30
  type: 'stroke';
@@ -171,6 +174,7 @@ declare class ElementStore {
171
174
  getElementsByType<T extends ElementType>(type: T): Extract<CanvasElement, {
172
175
  type: T;
173
176
  }>[];
177
+ private indexBounds;
174
178
  add(element: CanvasElement): void;
175
179
  update(id: string, partial: Partial<CanvasElement>): void;
176
180
  remove(id: string): void;
@@ -441,6 +445,8 @@ interface ViewportOptions {
441
445
  }) => void;
442
446
  /** CSS-pixel margin cached beyond the viewport. Default `256`. Set `0` to disable. */
443
447
  panBufferMargin?: number;
448
+ /** Enable the built-in context menu. Default `true`. */
449
+ contextMenu?: boolean;
444
450
  }
445
451
  declare class Viewport {
446
452
  private readonly container;
@@ -453,6 +459,7 @@ declare class Viewport {
453
459
  private readonly canvasEl;
454
460
  private readonly wrapper;
455
461
  private readonly unsubCamera;
462
+ private readonly unsubToolChange;
456
463
  private readonly unsubStore;
457
464
  private readonly inputHandler;
458
465
  private readonly background;
@@ -475,6 +482,7 @@ declare class Viewport {
475
482
  private readonly doubleTapDetector;
476
483
  private tapDownX;
477
484
  private tapDownY;
485
+ private contextMenu;
478
486
  constructor(container: HTMLElement, options?: ViewportOptions);
479
487
  get ctx(): CanvasRenderingContext2D | null;
480
488
  get snapToGrid(): boolean;
@@ -522,11 +530,15 @@ declare class Viewport {
522
530
  onGridChange(listener: (info: GridInfo | null) => void): () => void;
523
531
  private getSelectTool;
524
532
  getSelectedIds(): string[];
533
+ runAction(action: string): void;
534
+ canPaste(): boolean;
535
+ openContextMenu(screenPos: Point): void;
525
536
  onSelectionChange(listener: () => void): () => void;
526
537
  getSelectionStyle(): ElementStyle | null;
527
538
  applyStyleToSelection(style: ElementStyle): void;
528
539
  groupSelection(): void;
529
540
  ungroupSelection(): void;
541
+ toggleLockSelection(): void;
530
542
  alignSelection(edge: AlignEdge): void;
531
543
  distributeSelection(axis: DistributeAxis): void;
532
544
  private boundedSelection;
@@ -767,6 +779,7 @@ declare class SelectTool implements Tool {
767
779
  onSelectionChange(listener: () => void): () => void;
768
780
  private setSelectedIds;
769
781
  setSelection(ids: string[]): void;
782
+ selectAtPoint(world: Point, ctx: ToolContext): void;
770
783
  get isMarqueeActive(): boolean;
771
784
  onActivate(ctx: ToolContext): void;
772
785
  onDeactivate(ctx: ToolContext): void;
@@ -782,11 +795,17 @@ declare class SelectTool implements Tool {
782
795
  private updateHoverCursor;
783
796
  private setHovered;
784
797
  private handleResize;
798
+ private anchorOffset;
799
+ private handleRotatedResize;
785
800
  private hitTestResizeHandle;
801
+ private hitTestRotateHandle;
786
802
  private hitTestLineHandles;
787
803
  private getHandlePositions;
804
+ private getOverlayLayout;
805
+ private topMidpoint;
788
806
  private renderMarquee;
789
807
  private renderSelectionBoxes;
808
+ private drawLockBadge;
790
809
  private renderBindingHighlights;
791
810
  private hitTestTemplateResizeHandle;
792
811
  private handleTemplateResize;
@@ -992,6 +1011,6 @@ declare class TemplateTool implements Tool {
992
1011
  private notifyOptionsChange;
993
1012
  }
994
1013
 
995
- declare const VERSION = "0.34.0";
1014
+ declare const VERSION = "0.36.0";
996
1015
 
997
1016
  export { type ActiveFormats, type AlignEdge, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,9 @@ interface BaseElement {
22
22
  layerId: string;
23
23
  /** Optional flat group membership. Elements sharing a groupId select/move/delete as a unit. */
24
24
  groupId?: string;
25
+ /** Rotation in radians (clockwise) about the element's center. Absent = 0 (unrotated).
26
+ * Applied to note/text/image/html/shape/stroke; ignored for arrow/grid/template. */
27
+ rotation?: number;
25
28
  }
26
29
  interface StrokeElement extends BaseElement {
27
30
  type: 'stroke';
@@ -171,6 +174,7 @@ declare class ElementStore {
171
174
  getElementsByType<T extends ElementType>(type: T): Extract<CanvasElement, {
172
175
  type: T;
173
176
  }>[];
177
+ private indexBounds;
174
178
  add(element: CanvasElement): void;
175
179
  update(id: string, partial: Partial<CanvasElement>): void;
176
180
  remove(id: string): void;
@@ -441,6 +445,8 @@ interface ViewportOptions {
441
445
  }) => void;
442
446
  /** CSS-pixel margin cached beyond the viewport. Default `256`. Set `0` to disable. */
443
447
  panBufferMargin?: number;
448
+ /** Enable the built-in context menu. Default `true`. */
449
+ contextMenu?: boolean;
444
450
  }
445
451
  declare class Viewport {
446
452
  private readonly container;
@@ -453,6 +459,7 @@ declare class Viewport {
453
459
  private readonly canvasEl;
454
460
  private readonly wrapper;
455
461
  private readonly unsubCamera;
462
+ private readonly unsubToolChange;
456
463
  private readonly unsubStore;
457
464
  private readonly inputHandler;
458
465
  private readonly background;
@@ -475,6 +482,7 @@ declare class Viewport {
475
482
  private readonly doubleTapDetector;
476
483
  private tapDownX;
477
484
  private tapDownY;
485
+ private contextMenu;
478
486
  constructor(container: HTMLElement, options?: ViewportOptions);
479
487
  get ctx(): CanvasRenderingContext2D | null;
480
488
  get snapToGrid(): boolean;
@@ -522,11 +530,15 @@ declare class Viewport {
522
530
  onGridChange(listener: (info: GridInfo | null) => void): () => void;
523
531
  private getSelectTool;
524
532
  getSelectedIds(): string[];
533
+ runAction(action: string): void;
534
+ canPaste(): boolean;
535
+ openContextMenu(screenPos: Point): void;
525
536
  onSelectionChange(listener: () => void): () => void;
526
537
  getSelectionStyle(): ElementStyle | null;
527
538
  applyStyleToSelection(style: ElementStyle): void;
528
539
  groupSelection(): void;
529
540
  ungroupSelection(): void;
541
+ toggleLockSelection(): void;
530
542
  alignSelection(edge: AlignEdge): void;
531
543
  distributeSelection(axis: DistributeAxis): void;
532
544
  private boundedSelection;
@@ -767,6 +779,7 @@ declare class SelectTool implements Tool {
767
779
  onSelectionChange(listener: () => void): () => void;
768
780
  private setSelectedIds;
769
781
  setSelection(ids: string[]): void;
782
+ selectAtPoint(world: Point, ctx: ToolContext): void;
770
783
  get isMarqueeActive(): boolean;
771
784
  onActivate(ctx: ToolContext): void;
772
785
  onDeactivate(ctx: ToolContext): void;
@@ -782,11 +795,17 @@ declare class SelectTool implements Tool {
782
795
  private updateHoverCursor;
783
796
  private setHovered;
784
797
  private handleResize;
798
+ private anchorOffset;
799
+ private handleRotatedResize;
785
800
  private hitTestResizeHandle;
801
+ private hitTestRotateHandle;
786
802
  private hitTestLineHandles;
787
803
  private getHandlePositions;
804
+ private getOverlayLayout;
805
+ private topMidpoint;
788
806
  private renderMarquee;
789
807
  private renderSelectionBoxes;
808
+ private drawLockBadge;
790
809
  private renderBindingHighlights;
791
810
  private hitTestTemplateResizeHandle;
792
811
  private handleTemplateResize;
@@ -992,6 +1011,6 @@ declare class TemplateTool implements Tool {
992
1011
  private notifyOptionsChange;
993
1012
  }
994
1013
 
995
- declare const VERSION = "0.34.0";
1014
+ declare const VERSION = "0.36.0";
996
1015
 
997
1016
  export { type ActiveFormats, type AlignEdge, type ArrowElement, ArrowTool, type ArrowToolOptions, AutoSave, type AutoSaveOptions, type BackgroundOptions, type BackgroundPattern, type Binding, type Bounds, Camera, type CameraChangeInfo, type CameraOptions, type CanvasElement, type CanvasState, type Command, DEFAULT_NOTE_FONT_SIZE, type DistributeAxis, ElementStore, type ElementStyle, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, type ExportImageOptions, type FontSizePreset, type GridElement, type GridInfo, HandTool, type HexOrientation, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, type NoteElement, NoteTool, type NoteToolOptions, PencilTool, type PencilToolOptions, type Point, type PointerState, type RenderStatsSnapshot, SelectTool, type ShapeElement, type ShapeKind, ShapeTool, type ShapeToolOptions, type ShortcutBindings, type ShortcutOptions, type ShortcutsApi, type Size, type StrokeElement, type StrokePoint, type TemplateElement, type TemplateShape, TemplateTool, type TemplateToolOptions, type TextElement, TextTool, type TextToolOptions, type Tool, type ToolContext, ToolManager, type ToolName, VERSION, Viewport, type ViewportOptions, boundsIntersect, createArrow, createGrid, createHtmlElement, createImage, createNote, createShape, createStroke, createTemplate, createText, drawHexPath, exportImage, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };