@fieldnotes/core 0.9.0 → 0.10.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
@@ -59,6 +59,7 @@ interface NoteElement extends BaseElement {
59
59
  text: string;
60
60
  backgroundColor: string;
61
61
  textColor: string;
62
+ fontSize?: number;
62
63
  }
63
64
  interface Binding {
64
65
  elementId: string;
@@ -449,6 +450,28 @@ declare class InputHandler {
449
450
  private cancelToolIfActive;
450
451
  }
451
452
 
453
+ interface FontSizePreset {
454
+ label: string;
455
+ size: number;
456
+ }
457
+ declare const DEFAULT_FONT_SIZE_PRESETS: FontSizePreset[];
458
+ declare class NoteToolbar {
459
+ private el;
460
+ private anchor;
461
+ private selectionListener;
462
+ private readonly fontSizePresets;
463
+ constructor(fontSizePresets?: FontSizePreset[]);
464
+ show(anchor: HTMLElement): void;
465
+ hide(): void;
466
+ getElement(): HTMLDivElement | null;
467
+ updatePosition(anchor: HTMLElement): void;
468
+ private createToolbarElement;
469
+ private createFormatButton;
470
+ private createFontSizeSelect;
471
+ private positionToolbar;
472
+ private updateActiveStates;
473
+ }
474
+
452
475
  interface ExportImageOptions {
453
476
  scale?: number;
454
477
  padding?: number;
@@ -469,6 +492,8 @@ interface RenderStatsSnapshot {
469
492
  interface ViewportOptions {
470
493
  camera?: CameraOptions;
471
494
  background?: BackgroundOptions;
495
+ fontSizePresets?: FontSizePreset[];
496
+ toolbar?: boolean;
472
497
  }
473
498
  declare class Viewport {
474
499
  private readonly container;
@@ -581,6 +606,10 @@ declare class ElementRenderer {
581
606
  private getImage;
582
607
  }
583
608
 
609
+ interface NoteEditorOptions {
610
+ fontSizePresets?: FontSizePreset[];
611
+ toolbar?: boolean;
612
+ }
584
613
  declare class NoteEditor {
585
614
  private editingId;
586
615
  private editingNode;
@@ -589,17 +618,46 @@ declare class NoteEditor {
589
618
  private pointerHandler;
590
619
  private pendingEditId;
591
620
  private onStopCallback;
621
+ private toolbar;
622
+ constructor(options?: NoteEditorOptions);
592
623
  get isEditing(): boolean;
593
624
  get editingElementId(): string | null;
594
625
  setOnStop(callback: (elementId: string) => void): void;
595
626
  startEditing(node: HTMLDivElement, elementId: string, store: ElementStore): void;
596
627
  stopEditing(store: ElementStore): void;
597
628
  destroy(store: ElementStore): void;
629
+ updateToolbarPosition(): void;
598
630
  private activateEditing;
599
631
  }
600
632
 
633
+ interface RunStyle {
634
+ bold: boolean;
635
+ italic: boolean;
636
+ underline: boolean;
637
+ strikethrough: boolean;
638
+ fontSize: number;
639
+ }
640
+ interface StyledRun extends RunStyle {
641
+ text: string;
642
+ }
643
+ declare function sanitizeNoteHtml(html: string): string;
644
+
645
+ interface ActiveFormats {
646
+ bold: boolean;
647
+ italic: boolean;
648
+ underline: boolean;
649
+ strikethrough: boolean;
650
+ }
651
+ declare function toggleBold(): void;
652
+ declare function toggleItalic(): void;
653
+ declare function toggleUnderline(): void;
654
+ declare function toggleStrikethrough(): void;
655
+ declare function setFontSize(size: number): void;
656
+ declare function getActiveFormats(): ActiveFormats;
657
+
601
658
  declare function createId(prefix: string): string;
602
659
 
660
+ declare const DEFAULT_NOTE_FONT_SIZE = 18;
603
661
  interface BaseDefaults {
604
662
  position?: Point;
605
663
  zIndex?: number;
@@ -618,6 +676,7 @@ interface NoteInput extends BaseDefaults {
618
676
  text?: string;
619
677
  backgroundColor?: string;
620
678
  textColor?: string;
679
+ fontSize?: number;
621
680
  }
622
681
  interface ArrowInput extends BaseDefaults {
623
682
  from: Point;
@@ -862,12 +921,14 @@ interface NoteToolOptions {
862
921
  backgroundColor?: string;
863
922
  textColor?: string;
864
923
  size?: Size;
924
+ fontSize?: number;
865
925
  }
866
926
  declare class NoteTool implements Tool {
867
927
  readonly name = "note";
868
928
  private backgroundColor;
869
929
  private textColor;
870
930
  private size;
931
+ private fontSize;
871
932
  private optionListeners;
872
933
  constructor(options?: NoteToolOptions);
873
934
  getOptions(): NoteToolOptions;
@@ -1048,6 +1109,6 @@ declare class UpdateLayerCommand implements Command {
1048
1109
  undo(_store: ElementStore): void;
1049
1110
  }
1050
1111
 
1051
- declare const VERSION = "0.9.0";
1112
+ declare const VERSION = "0.10.0";
1052
1113
 
1053
- export { 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, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, 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 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, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, smartSnap, snapPoint, snapToHexCenter, unbindArrow, updateBoundArrow };
1114
+ 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, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FontSizePreset, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, 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, 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
@@ -59,6 +59,7 @@ interface NoteElement extends BaseElement {
59
59
  text: string;
60
60
  backgroundColor: string;
61
61
  textColor: string;
62
+ fontSize?: number;
62
63
  }
63
64
  interface Binding {
64
65
  elementId: string;
@@ -449,6 +450,28 @@ declare class InputHandler {
449
450
  private cancelToolIfActive;
450
451
  }
451
452
 
453
+ interface FontSizePreset {
454
+ label: string;
455
+ size: number;
456
+ }
457
+ declare const DEFAULT_FONT_SIZE_PRESETS: FontSizePreset[];
458
+ declare class NoteToolbar {
459
+ private el;
460
+ private anchor;
461
+ private selectionListener;
462
+ private readonly fontSizePresets;
463
+ constructor(fontSizePresets?: FontSizePreset[]);
464
+ show(anchor: HTMLElement): void;
465
+ hide(): void;
466
+ getElement(): HTMLDivElement | null;
467
+ updatePosition(anchor: HTMLElement): void;
468
+ private createToolbarElement;
469
+ private createFormatButton;
470
+ private createFontSizeSelect;
471
+ private positionToolbar;
472
+ private updateActiveStates;
473
+ }
474
+
452
475
  interface ExportImageOptions {
453
476
  scale?: number;
454
477
  padding?: number;
@@ -469,6 +492,8 @@ interface RenderStatsSnapshot {
469
492
  interface ViewportOptions {
470
493
  camera?: CameraOptions;
471
494
  background?: BackgroundOptions;
495
+ fontSizePresets?: FontSizePreset[];
496
+ toolbar?: boolean;
472
497
  }
473
498
  declare class Viewport {
474
499
  private readonly container;
@@ -581,6 +606,10 @@ declare class ElementRenderer {
581
606
  private getImage;
582
607
  }
583
608
 
609
+ interface NoteEditorOptions {
610
+ fontSizePresets?: FontSizePreset[];
611
+ toolbar?: boolean;
612
+ }
584
613
  declare class NoteEditor {
585
614
  private editingId;
586
615
  private editingNode;
@@ -589,17 +618,46 @@ declare class NoteEditor {
589
618
  private pointerHandler;
590
619
  private pendingEditId;
591
620
  private onStopCallback;
621
+ private toolbar;
622
+ constructor(options?: NoteEditorOptions);
592
623
  get isEditing(): boolean;
593
624
  get editingElementId(): string | null;
594
625
  setOnStop(callback: (elementId: string) => void): void;
595
626
  startEditing(node: HTMLDivElement, elementId: string, store: ElementStore): void;
596
627
  stopEditing(store: ElementStore): void;
597
628
  destroy(store: ElementStore): void;
629
+ updateToolbarPosition(): void;
598
630
  private activateEditing;
599
631
  }
600
632
 
633
+ interface RunStyle {
634
+ bold: boolean;
635
+ italic: boolean;
636
+ underline: boolean;
637
+ strikethrough: boolean;
638
+ fontSize: number;
639
+ }
640
+ interface StyledRun extends RunStyle {
641
+ text: string;
642
+ }
643
+ declare function sanitizeNoteHtml(html: string): string;
644
+
645
+ interface ActiveFormats {
646
+ bold: boolean;
647
+ italic: boolean;
648
+ underline: boolean;
649
+ strikethrough: boolean;
650
+ }
651
+ declare function toggleBold(): void;
652
+ declare function toggleItalic(): void;
653
+ declare function toggleUnderline(): void;
654
+ declare function toggleStrikethrough(): void;
655
+ declare function setFontSize(size: number): void;
656
+ declare function getActiveFormats(): ActiveFormats;
657
+
601
658
  declare function createId(prefix: string): string;
602
659
 
660
+ declare const DEFAULT_NOTE_FONT_SIZE = 18;
603
661
  interface BaseDefaults {
604
662
  position?: Point;
605
663
  zIndex?: number;
@@ -618,6 +676,7 @@ interface NoteInput extends BaseDefaults {
618
676
  text?: string;
619
677
  backgroundColor?: string;
620
678
  textColor?: string;
679
+ fontSize?: number;
621
680
  }
622
681
  interface ArrowInput extends BaseDefaults {
623
682
  from: Point;
@@ -862,12 +921,14 @@ interface NoteToolOptions {
862
921
  backgroundColor?: string;
863
922
  textColor?: string;
864
923
  size?: Size;
924
+ fontSize?: number;
865
925
  }
866
926
  declare class NoteTool implements Tool {
867
927
  readonly name = "note";
868
928
  private backgroundColor;
869
929
  private textColor;
870
930
  private size;
931
+ private fontSize;
871
932
  private optionListeners;
872
933
  constructor(options?: NoteToolOptions);
873
934
  getOptions(): NoteToolOptions;
@@ -1048,6 +1109,6 @@ declare class UpdateLayerCommand implements Command {
1048
1109
  undo(_store: ElementStore): void;
1049
1110
  }
1050
1111
 
1051
- declare const VERSION = "0.9.0";
1112
+ declare const VERSION = "0.10.0";
1052
1113
 
1053
- export { 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, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, InputHandler, type Layer, LayerManager, MeasureTool, type MeasureToolOptions, type Measurement, NoteEditor, type NoteElement, NoteTool, type NoteToolOptions, 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 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, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getEdgeIntersection, getElementBounds, getElementCenter, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, smartSnap, snapPoint, snapToHexCenter, unbindArrow, updateBoundArrow };
1114
+ 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, ElementRenderer, ElementStore, type ElementType, type ElementUpdateEvent, EraserTool, type EraserToolOptions, EventBus, type ExportImageOptions, type FontSizePreset, type GridElement, HandTool, type HexOrientation, HistoryRecorder, HistoryStack, type HistoryStackOptions, type HtmlElement, type ImageElement, ImageTool, type ImageToolOptions, 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, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isBindable, isNearBezier, parseState, sanitizeNoteHtml, setFontSize, smartSnap, snapPoint, snapToHexCenter, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline, unbindArrow, updateBoundArrow };