@fieldnotes/core 0.38.6 → 0.39.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.cjs +524 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +523 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -70,6 +70,10 @@ interface HtmlElement extends BaseElement {
|
|
|
70
70
|
size: Size;
|
|
71
71
|
domId?: string;
|
|
72
72
|
interactive?: boolean;
|
|
73
|
+
/** Discriminator matching a renderer registered via `viewport.registerHtmlRenderer`. */
|
|
74
|
+
htmlType?: string;
|
|
75
|
+
/** Serializable payload passed to the registered renderer to rebuild the embed on load. */
|
|
76
|
+
data?: Record<string, unknown>;
|
|
73
77
|
}
|
|
74
78
|
interface TextElement extends BaseElement {
|
|
75
79
|
type: 'text';
|
|
@@ -395,6 +399,14 @@ interface ExportImageOptions {
|
|
|
395
399
|
}
|
|
396
400
|
declare function exportImage(store: ElementStore, options?: ExportImageOptions, layerManager?: LayerManager): Promise<Blob | null>;
|
|
397
401
|
|
|
402
|
+
interface ExportSvgOptions {
|
|
403
|
+
padding?: number;
|
|
404
|
+
background?: string;
|
|
405
|
+
filter?: (el: CanvasElement) => boolean;
|
|
406
|
+
rasterScale?: number;
|
|
407
|
+
}
|
|
408
|
+
declare function exportSvg(store: ElementStore, options?: ExportSvgOptions, layerManager?: LayerManager): Promise<string>;
|
|
409
|
+
|
|
398
410
|
interface RenderStatsSnapshot {
|
|
399
411
|
fps: number;
|
|
400
412
|
avgFrameMs: number;
|
|
@@ -440,6 +452,10 @@ interface ViewportOptions {
|
|
|
440
452
|
x: number;
|
|
441
453
|
y: number;
|
|
442
454
|
}) => void;
|
|
455
|
+
onPaste?: (event: ClipboardEvent, worldPosition: {
|
|
456
|
+
x: number;
|
|
457
|
+
y: number;
|
|
458
|
+
}) => void;
|
|
443
459
|
onImageError?: (info: {
|
|
444
460
|
src: string;
|
|
445
461
|
elementIds: string[];
|
|
@@ -484,6 +500,7 @@ declare class Viewport {
|
|
|
484
500
|
private readonly gridController;
|
|
485
501
|
private readonly interactions;
|
|
486
502
|
private contextMenu;
|
|
503
|
+
private readonly htmlRenderers;
|
|
487
504
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
488
505
|
get ctx(): CanvasRenderingContext2D | null;
|
|
489
506
|
get snapToGrid(): boolean;
|
|
@@ -495,6 +512,7 @@ declare class Viewport {
|
|
|
495
512
|
exportState(): CanvasState;
|
|
496
513
|
exportJSON(): string;
|
|
497
514
|
exportImage(options?: ExportImageOptions): Promise<Blob | null>;
|
|
515
|
+
exportSVG(options?: ExportSvgOptions): Promise<string>;
|
|
498
516
|
loadState(state: CanvasState): void;
|
|
499
517
|
loadJSON(json: string): void;
|
|
500
518
|
setTool(name: string): void;
|
|
@@ -514,6 +532,9 @@ declare class Viewport {
|
|
|
514
532
|
}, size?: {
|
|
515
533
|
w: number;
|
|
516
534
|
h: number;
|
|
535
|
+
}, opts?: {
|
|
536
|
+
htmlType?: string;
|
|
537
|
+
data?: Record<string, unknown>;
|
|
517
538
|
}): string;
|
|
518
539
|
addShape(opts?: {
|
|
519
540
|
shape?: ShapeKind;
|
|
@@ -531,6 +552,7 @@ declare class Viewport {
|
|
|
531
552
|
}): string;
|
|
532
553
|
private centeredPosition;
|
|
533
554
|
removeLayer(id: string): void;
|
|
555
|
+
registerHtmlRenderer(htmlType: string, factory: (el: HtmlElement) => HTMLElement): void;
|
|
534
556
|
updateHtmlElement(id: string, newContent: HTMLElement): void;
|
|
535
557
|
addGrid(input: {
|
|
536
558
|
gridType?: 'square' | 'hex';
|
|
@@ -622,6 +644,8 @@ interface HtmlInput extends BaseDefaults {
|
|
|
622
644
|
size: Size;
|
|
623
645
|
domId?: string;
|
|
624
646
|
interactive?: boolean;
|
|
647
|
+
htmlType?: string;
|
|
648
|
+
data?: Record<string, unknown>;
|
|
625
649
|
}
|
|
626
650
|
interface TextInput extends BaseDefaults {
|
|
627
651
|
position: Point;
|
|
@@ -993,6 +1017,6 @@ declare class TemplateTool implements Tool {
|
|
|
993
1017
|
private notifyOptionsChange;
|
|
994
1018
|
}
|
|
995
1019
|
|
|
996
|
-
declare const VERSION = "0.
|
|
1020
|
+
declare const VERSION = "0.39.0";
|
|
997
1021
|
|
|
998
|
-
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 };
|
|
1022
|
+
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 ExportSvgOptions, 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, exportSvg, 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
|
@@ -70,6 +70,10 @@ interface HtmlElement extends BaseElement {
|
|
|
70
70
|
size: Size;
|
|
71
71
|
domId?: string;
|
|
72
72
|
interactive?: boolean;
|
|
73
|
+
/** Discriminator matching a renderer registered via `viewport.registerHtmlRenderer`. */
|
|
74
|
+
htmlType?: string;
|
|
75
|
+
/** Serializable payload passed to the registered renderer to rebuild the embed on load. */
|
|
76
|
+
data?: Record<string, unknown>;
|
|
73
77
|
}
|
|
74
78
|
interface TextElement extends BaseElement {
|
|
75
79
|
type: 'text';
|
|
@@ -395,6 +399,14 @@ interface ExportImageOptions {
|
|
|
395
399
|
}
|
|
396
400
|
declare function exportImage(store: ElementStore, options?: ExportImageOptions, layerManager?: LayerManager): Promise<Blob | null>;
|
|
397
401
|
|
|
402
|
+
interface ExportSvgOptions {
|
|
403
|
+
padding?: number;
|
|
404
|
+
background?: string;
|
|
405
|
+
filter?: (el: CanvasElement) => boolean;
|
|
406
|
+
rasterScale?: number;
|
|
407
|
+
}
|
|
408
|
+
declare function exportSvg(store: ElementStore, options?: ExportSvgOptions, layerManager?: LayerManager): Promise<string>;
|
|
409
|
+
|
|
398
410
|
interface RenderStatsSnapshot {
|
|
399
411
|
fps: number;
|
|
400
412
|
avgFrameMs: number;
|
|
@@ -440,6 +452,10 @@ interface ViewportOptions {
|
|
|
440
452
|
x: number;
|
|
441
453
|
y: number;
|
|
442
454
|
}) => void;
|
|
455
|
+
onPaste?: (event: ClipboardEvent, worldPosition: {
|
|
456
|
+
x: number;
|
|
457
|
+
y: number;
|
|
458
|
+
}) => void;
|
|
443
459
|
onImageError?: (info: {
|
|
444
460
|
src: string;
|
|
445
461
|
elementIds: string[];
|
|
@@ -484,6 +500,7 @@ declare class Viewport {
|
|
|
484
500
|
private readonly gridController;
|
|
485
501
|
private readonly interactions;
|
|
486
502
|
private contextMenu;
|
|
503
|
+
private readonly htmlRenderers;
|
|
487
504
|
constructor(container: HTMLElement, options?: ViewportOptions);
|
|
488
505
|
get ctx(): CanvasRenderingContext2D | null;
|
|
489
506
|
get snapToGrid(): boolean;
|
|
@@ -495,6 +512,7 @@ declare class Viewport {
|
|
|
495
512
|
exportState(): CanvasState;
|
|
496
513
|
exportJSON(): string;
|
|
497
514
|
exportImage(options?: ExportImageOptions): Promise<Blob | null>;
|
|
515
|
+
exportSVG(options?: ExportSvgOptions): Promise<string>;
|
|
498
516
|
loadState(state: CanvasState): void;
|
|
499
517
|
loadJSON(json: string): void;
|
|
500
518
|
setTool(name: string): void;
|
|
@@ -514,6 +532,9 @@ declare class Viewport {
|
|
|
514
532
|
}, size?: {
|
|
515
533
|
w: number;
|
|
516
534
|
h: number;
|
|
535
|
+
}, opts?: {
|
|
536
|
+
htmlType?: string;
|
|
537
|
+
data?: Record<string, unknown>;
|
|
517
538
|
}): string;
|
|
518
539
|
addShape(opts?: {
|
|
519
540
|
shape?: ShapeKind;
|
|
@@ -531,6 +552,7 @@ declare class Viewport {
|
|
|
531
552
|
}): string;
|
|
532
553
|
private centeredPosition;
|
|
533
554
|
removeLayer(id: string): void;
|
|
555
|
+
registerHtmlRenderer(htmlType: string, factory: (el: HtmlElement) => HTMLElement): void;
|
|
534
556
|
updateHtmlElement(id: string, newContent: HTMLElement): void;
|
|
535
557
|
addGrid(input: {
|
|
536
558
|
gridType?: 'square' | 'hex';
|
|
@@ -622,6 +644,8 @@ interface HtmlInput extends BaseDefaults {
|
|
|
622
644
|
size: Size;
|
|
623
645
|
domId?: string;
|
|
624
646
|
interactive?: boolean;
|
|
647
|
+
htmlType?: string;
|
|
648
|
+
data?: Record<string, unknown>;
|
|
625
649
|
}
|
|
626
650
|
interface TextInput extends BaseDefaults {
|
|
627
651
|
position: Point;
|
|
@@ -993,6 +1017,6 @@ declare class TemplateTool implements Tool {
|
|
|
993
1017
|
private notifyOptionsChange;
|
|
994
1018
|
}
|
|
995
1019
|
|
|
996
|
-
declare const VERSION = "0.
|
|
1020
|
+
declare const VERSION = "0.39.0";
|
|
997
1021
|
|
|
998
|
-
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 };
|
|
1022
|
+
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 ExportSvgOptions, 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, exportSvg, getActiveFormats, getArrowBounds, getArrowControlPoint, getArrowMidpoint, getArrowTangentAngle, getBendFromPoint, getElementBounds, getElementStyle, getElementsBoundingBox, getHexCellsInCone, getHexCellsInLine, getHexCellsInRadius, getHexCellsInSquare, getHexDistance, isNearBezier, setFontSize, smartSnap, snapPoint, snapToHexCenter, styleToPatch, toggleBold, toggleItalic, toggleStrikethrough, toggleUnderline };
|