@fieldnotes/core 0.37.0 → 0.38.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
@@ -514,6 +514,21 @@ declare class Viewport {
514
514
  w: number;
515
515
  h: number;
516
516
  }): string;
517
+ addShape(opts?: {
518
+ shape?: ShapeKind;
519
+ size?: {
520
+ w: number;
521
+ h: number;
522
+ };
523
+ position?: {
524
+ x: number;
525
+ y: number;
526
+ };
527
+ strokeColor?: string;
528
+ fillColor?: string;
529
+ strokeWidth?: number;
530
+ }): string;
531
+ private centeredPosition;
517
532
  removeLayer(id: string): void;
518
533
  updateHtmlElement(id: string, newContent: HTMLElement): void;
519
534
  addGrid(input: {
@@ -1011,6 +1026,6 @@ declare class TemplateTool implements Tool {
1011
1026
  private notifyOptionsChange;
1012
1027
  }
1013
1028
 
1014
- declare const VERSION = "0.37.0";
1029
+ declare const VERSION = "0.38.0";
1015
1030
 
1016
1031
  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
@@ -514,6 +514,21 @@ declare class Viewport {
514
514
  w: number;
515
515
  h: number;
516
516
  }): string;
517
+ addShape(opts?: {
518
+ shape?: ShapeKind;
519
+ size?: {
520
+ w: number;
521
+ h: number;
522
+ };
523
+ position?: {
524
+ x: number;
525
+ y: number;
526
+ };
527
+ strokeColor?: string;
528
+ fillColor?: string;
529
+ strokeWidth?: number;
530
+ }): string;
531
+ private centeredPosition;
517
532
  removeLayer(id: string): void;
518
533
  updateHtmlElement(id: string, newContent: HTMLElement): void;
519
534
  addGrid(input: {
@@ -1011,6 +1026,6 @@ declare class TemplateTool implements Tool {
1011
1026
  private notifyOptionsChange;
1012
1027
  }
1013
1028
 
1014
- declare const VERSION = "0.37.0";
1029
+ declare const VERSION = "0.38.0";
1015
1030
 
1016
1031
  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.js CHANGED
@@ -6039,6 +6039,32 @@ var Viewport = class {
6039
6039
  this.requestRender();
6040
6040
  return el.id;
6041
6041
  }
6042
+ addShape(opts = {}) {
6043
+ const size = opts.size ?? { w: 100, h: 100 };
6044
+ const position = opts.position ?? this.centeredPosition(size);
6045
+ const shape = createShape({
6046
+ position,
6047
+ size,
6048
+ shape: opts.shape,
6049
+ strokeColor: opts.strokeColor,
6050
+ strokeWidth: opts.strokeWidth,
6051
+ fillColor: opts.fillColor,
6052
+ layerId: this.layerManager.activeLayerId
6053
+ });
6054
+ this.historyRecorder.begin();
6055
+ this.store.add(shape);
6056
+ this.historyRecorder.commit();
6057
+ this.getSelectTool()?.setSelection([shape.id]);
6058
+ this.requestRender();
6059
+ return shape.id;
6060
+ }
6061
+ centeredPosition(size) {
6062
+ const c = this.camera.screenToWorld({
6063
+ x: this.wrapper.clientWidth / 2,
6064
+ y: this.wrapper.clientHeight / 2
6065
+ });
6066
+ return { x: c.x - size.w / 2, y: c.y - size.h / 2 };
6067
+ }
6042
6068
  removeLayer(id) {
6043
6069
  this.historyRecorder.begin();
6044
6070
  this.layerManager.removeLayer(id);
@@ -8840,7 +8866,7 @@ var TemplateTool = class {
8840
8866
  };
8841
8867
 
8842
8868
  // src/index.ts
8843
- var VERSION = "0.37.0";
8869
+ var VERSION = "0.38.0";
8844
8870
  export {
8845
8871
  ArrowTool,
8846
8872
  AutoSave,