@overtone-art/canvas-editor-core 0.3.1 → 0.3.2

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.mts CHANGED
@@ -359,6 +359,47 @@ declare function renderTextureMask(id: TextureMaskId): HTMLCanvasElement;
359
359
  /** Drop memoized textures — used by tests and by long-lived editors on dispose. */
360
360
  declare function clearTextureMaskCache(): void;
361
361
 
362
+ /**
363
+ * Look of the selection frame and its resize handles.
364
+ *
365
+ * Every measurement is in **screen** pixels. Zoom is a display transform (the
366
+ * view layer CSS-scales the canvas element), so a handle drawn at its nominal
367
+ * size would grow and shrink with the zoom level; `applySelectionStyle`
368
+ * counter-scales by 1/zoom so the frame stays the same size on screen whatever
369
+ * the zoom.
370
+ */
371
+ interface SelectionStyle {
372
+ /** Colour of the frame around the selection. */
373
+ borderColor: string;
374
+ /** Fill of the resize handles. */
375
+ cornerColor: string;
376
+ /** Outline drawn around each handle. */
377
+ cornerStrokeColor: string;
378
+ /** Handle diameter, in screen pixels. */
379
+ cornerSize: number;
380
+ /** Round handles (as in the design tools) or square ones. */
381
+ cornerStyle: 'circle' | 'rect';
382
+ /** Frame line width, in screen pixels. */
383
+ borderWidth: number;
384
+ /** Dash pattern for the frame, in screen pixels. Null = solid. */
385
+ borderDashArray: number[] | null;
386
+ /** Gap between the object bounds and the frame, in screen pixels. */
387
+ padding: number;
388
+ /** Fill of the drag-to-select marquee. */
389
+ marqueeFill: string;
390
+ }
391
+ declare const DEFAULT_SELECTION_STYLE: SelectionStyle;
392
+ /** Applies the style to ONE object at the given display zoom. */
393
+ declare function applyObjectSelectionStyle(object: FabricObject, style: SelectionStyle, zoom: number): void;
394
+ /**
395
+ * Applies the style to every object on the canvas plus the active selection.
396
+ *
397
+ * The active selection is a transient group that `getObjects()` does not list,
398
+ * so it is styled separately — otherwise a multi-object selection would keep
399
+ * fabric's default blue squares.
400
+ */
401
+ declare function applySelectionStyle(canvas: Canvas, style: SelectionStyle, zoom: number): void;
402
+
362
403
  declare class UnitConverter {
363
404
  private unit;
364
405
  private dpi;
@@ -520,6 +561,7 @@ declare class CanvasEditor {
520
561
  private fileAdapter?;
521
562
  private imageProvider?;
522
563
  private zoomLevel;
564
+ private selectionStyle;
523
565
  private mockup;
524
566
  private designBackground;
525
567
  private designBackgroundImage;
@@ -642,6 +684,14 @@ declare class CanvasEditor {
642
684
  clearMockup(): void;
643
685
  getMockup(): MockupConfig | null;
644
686
  dispose(): void;
687
+ /** Current look of the selection frame and its handles. */
688
+ getSelectionStyle(): SelectionStyle;
689
+ /**
690
+ * Restyles the selection frame and resize handles. Sizes are in screen
691
+ * pixels and stay constant across zoom levels (see `SelectionStyle`).
692
+ */
693
+ setSelectionStyle(style: Partial<SelectionStyle>): void;
694
+ private refreshSelectionStyle;
645
695
  private setupCanvasEvents;
646
696
  }
647
697
 
@@ -770,4 +820,4 @@ declare class AnnotationOverlay {
770
820
  */
771
821
  declare function displaceRgba(source: Uint8ClampedArray, map: Uint8ClampedArray, width: number, height: number, options: Omit<MockupDisplacement, 'image'>): Uint8ClampedArray;
772
822
 
773
- export { AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_SIZE_PRESETS, CanvasEditor, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, PatternSourceResolver, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TilePlacement, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyPatternLocks, buildCurvePathData, buildPatternDataURL, captureLocks, clamp, clearPatternImageCache, clearTextureMaskCache, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, loadPatternImage, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData };
823
+ export { AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_SIZE_PRESETS, CanvasEditor, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, PatternSourceResolver, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TilePlacement, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applyPatternLocks, applySelectionStyle, buildCurvePathData, buildPatternDataURL, captureLocks, clamp, clearPatternImageCache, clearTextureMaskCache, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, loadPatternImage, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData };
package/dist/index.d.ts CHANGED
@@ -359,6 +359,47 @@ declare function renderTextureMask(id: TextureMaskId): HTMLCanvasElement;
359
359
  /** Drop memoized textures — used by tests and by long-lived editors on dispose. */
360
360
  declare function clearTextureMaskCache(): void;
361
361
 
362
+ /**
363
+ * Look of the selection frame and its resize handles.
364
+ *
365
+ * Every measurement is in **screen** pixels. Zoom is a display transform (the
366
+ * view layer CSS-scales the canvas element), so a handle drawn at its nominal
367
+ * size would grow and shrink with the zoom level; `applySelectionStyle`
368
+ * counter-scales by 1/zoom so the frame stays the same size on screen whatever
369
+ * the zoom.
370
+ */
371
+ interface SelectionStyle {
372
+ /** Colour of the frame around the selection. */
373
+ borderColor: string;
374
+ /** Fill of the resize handles. */
375
+ cornerColor: string;
376
+ /** Outline drawn around each handle. */
377
+ cornerStrokeColor: string;
378
+ /** Handle diameter, in screen pixels. */
379
+ cornerSize: number;
380
+ /** Round handles (as in the design tools) or square ones. */
381
+ cornerStyle: 'circle' | 'rect';
382
+ /** Frame line width, in screen pixels. */
383
+ borderWidth: number;
384
+ /** Dash pattern for the frame, in screen pixels. Null = solid. */
385
+ borderDashArray: number[] | null;
386
+ /** Gap between the object bounds and the frame, in screen pixels. */
387
+ padding: number;
388
+ /** Fill of the drag-to-select marquee. */
389
+ marqueeFill: string;
390
+ }
391
+ declare const DEFAULT_SELECTION_STYLE: SelectionStyle;
392
+ /** Applies the style to ONE object at the given display zoom. */
393
+ declare function applyObjectSelectionStyle(object: FabricObject, style: SelectionStyle, zoom: number): void;
394
+ /**
395
+ * Applies the style to every object on the canvas plus the active selection.
396
+ *
397
+ * The active selection is a transient group that `getObjects()` does not list,
398
+ * so it is styled separately — otherwise a multi-object selection would keep
399
+ * fabric's default blue squares.
400
+ */
401
+ declare function applySelectionStyle(canvas: Canvas, style: SelectionStyle, zoom: number): void;
402
+
362
403
  declare class UnitConverter {
363
404
  private unit;
364
405
  private dpi;
@@ -520,6 +561,7 @@ declare class CanvasEditor {
520
561
  private fileAdapter?;
521
562
  private imageProvider?;
522
563
  private zoomLevel;
564
+ private selectionStyle;
523
565
  private mockup;
524
566
  private designBackground;
525
567
  private designBackgroundImage;
@@ -642,6 +684,14 @@ declare class CanvasEditor {
642
684
  clearMockup(): void;
643
685
  getMockup(): MockupConfig | null;
644
686
  dispose(): void;
687
+ /** Current look of the selection frame and its handles. */
688
+ getSelectionStyle(): SelectionStyle;
689
+ /**
690
+ * Restyles the selection frame and resize handles. Sizes are in screen
691
+ * pixels and stay constant across zoom levels (see `SelectionStyle`).
692
+ */
693
+ setSelectionStyle(style: Partial<SelectionStyle>): void;
694
+ private refreshSelectionStyle;
645
695
  private setupCanvasEvents;
646
696
  }
647
697
 
@@ -770,4 +820,4 @@ declare class AnnotationOverlay {
770
820
  */
771
821
  declare function displaceRgba(source: Uint8ClampedArray, map: Uint8ClampedArray, width: number, height: number, options: Omit<MockupDisplacement, 'image'>): Uint8ClampedArray;
772
822
 
773
- export { AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_SIZE_PRESETS, CanvasEditor, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, PatternSourceResolver, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TilePlacement, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyPatternLocks, buildCurvePathData, buildPatternDataURL, captureLocks, clamp, clearPatternImageCache, clearTextureMaskCache, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, loadPatternImage, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData };
823
+ export { AnnotationOverlay, type AnnotationPrimitive, BackgroundImageOptions, CANVAS_SIZE_PRESETS, CanvasEditor, CanvasSizePreset, type CoverPlacement, CropController, DEFAULT_LAYER_SHADOW, DEFAULT_SELECTION_STYLE, DEFAULT_TEXT_CURVE, DpiIssue, EditorConfig, EditorEvents, EditorState, EventEmitter, FileAdapter, FontDefinition, FontRegistry, HistoryManager, ImageAdjustments, ImageProvider, ImageProviderResult, ImageSearchOptions, ImageSearchResult, Layer, LayerData, LayerManager, LayerMeta, LayerShadowConfig, LayerType, LicenseConfig, LicenseManager, LicenseStatus, MaskBrushOptions, MaskController, type MaskPerformanceSample, MaskPoint, MaskPresetId, MaskPresetManager, MaskRefinementError, type MaskRefinementErrorCode, MaskRefinementPrompt, MaskRefinementProvider, MaskRefinementResult, MockupConfig, MockupDisplacement, MockupPrintArea, NormalizedLayerPosition, PatternConfig, PatternLocks, PatternManager, PatternSourceResolver, type PngExportOptions, PositioningAdapter, PrintifyPositioning, ProjectManager, ProjectState, ResizeOptions, SHAPE_MASK_BOX, SHAPE_MASK_IDS, type SelectionStyle, SemanticExportOptions, SerializedBackgroundImageOptions, SerializedLayer, ShapeMaskPresetId, ShapePlugin, SnapManager, SvgExportOptions, TEXTURE_MASK_IDS, TEXTURE_MASK_SIZE, TemplateDefinition, TextCurveConfig, TextCurveManager, TextureMaskPresetId, type TilePlacement, Unit, UnitConverter, type ViewportTransform, applyAspectLock, applyLayerShadow, applyObjectSelectionStyle, applyPatternLocks, applySelectionStyle, buildCurvePathData, buildPatternDataURL, captureLocks, clamp, clearPatternImageCache, clearTextureMaskCache, computeCoverPlacement, computePrintAreaClip, computeTilePositions, deserializeEditor, displaceRgba, drawTiles, escapeXml, exportDataURL, exportMockup, exportPNG, exportPrintArea, exportSVG, generateId, isCssColor, isMaskPresetId, isShapeMaskId, isTextureMaskId, loadPatternImage, readLayerShadow, renderTextureMask, resetTransform, restoreLocks, round2, sanitizeSvg, serializeEditor, shapeMaskPathData };