@bwp-web/canvas 0.5.0 → 0.5.1
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/hooks/useEditCanvas.d.ts.map +1 -1
- package/dist/hooks/useViewCanvas.d.ts.map +1 -1
- package/dist/index.cjs +62 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -10
- package/dist/index.js.map +1 -1
- package/dist/interactions/dragToCreate.d.ts +6 -1
- package/dist/interactions/dragToCreate.d.ts.map +1 -1
- package/dist/serialization.d.ts +13 -0
- package/dist/serialization.d.ts.map +1 -1
- package/dist/styles.d.ts +6 -0
- package/dist/styles.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Canvas as FabricCanvas, FabricObject } from 'fabric';
|
|
2
|
-
import type { DragBounds, ShapeStyleOptions, SnappableInteractionOptions } from '../types';
|
|
2
|
+
import type { DragBounds, Point2D, ShapeStyleOptions, SnappableInteractionOptions } from '../types';
|
|
3
3
|
export interface DragToCreateOptions extends SnappableInteractionOptions {
|
|
4
4
|
/** Style applied to the preview rectangle shown during drag. */
|
|
5
5
|
previewStyle?: ShapeStyleOptions & {
|
|
@@ -8,6 +8,11 @@ export interface DragToCreateOptions extends SnappableInteractionOptions {
|
|
|
8
8
|
};
|
|
9
9
|
/** When true, constrain the drag to a 1:1 aspect ratio (square). */
|
|
10
10
|
constrainToSquare?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Factory called when the user clicks without dragging (below MIN_DRAG_SIZE).
|
|
13
|
+
* Receives the canvas and the click point. If not provided, clicks are ignored.
|
|
14
|
+
*/
|
|
15
|
+
clickFactory?: (canvas: FabricCanvas, point: Point2D) => FabricObject;
|
|
11
16
|
/** Called when the user cancels the drag via Escape. */
|
|
12
17
|
onCancel?: () => void;
|
|
13
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragToCreate.d.ts","sourceRoot":"","sources":["../../src/interactions/dragToCreate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,YAAY,EAAQ,MAAM,QAAQ,CAAC;AACpE,OAAO,KAAK,EACV,UAAU,
|
|
1
|
+
{"version":3,"file":"dragToCreate.d.ts","sourceRoot":"","sources":["../../src/interactions/dragToCreate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,YAAY,EAAQ,MAAM,QAAQ,CAAC;AACpE,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAMlB,MAAM,WAAW,mBAAoB,SAAQ,2BAA2B;IACtE,gEAAgE;IAChE,YAAY,CAAC,EAAE,iBAAiB,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,KAAK,YAAY,CAAC;IACtE,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,KAAK,YAAY,EACnE,OAAO,CAAC,EAAE,mBAAmB,GAC5B,MAAM,IAAI,CA6JZ"}
|
package/dist/serialization.d.ts
CHANGED
|
@@ -11,6 +11,19 @@ import { Canvas as FabricCanvas, type FabricObject } from 'fabric';
|
|
|
11
11
|
* stroke widths to their base values.
|
|
12
12
|
*/
|
|
13
13
|
export declare function enableScaledStrokes(canvas: FabricCanvas): () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Keep border radii visually constant on Rects loaded via {@link loadCanvas}.
|
|
16
|
+
*
|
|
17
|
+
* On every render, each tracked Rect's `rx`/`ry` is recalculated as
|
|
18
|
+
* `VIEW_BORDER_RADIUS / scale` so corners always appear circular regardless
|
|
19
|
+
* of non-uniform scaling. The original rx/ry values are stored in an internal
|
|
20
|
+
* WeakMap and automatically restored before serialization by
|
|
21
|
+
* {@link serializeCanvas}.
|
|
22
|
+
*
|
|
23
|
+
* Returns a cleanup function that removes the listener and restores all
|
|
24
|
+
* rx/ry values to their originals.
|
|
25
|
+
*/
|
|
26
|
+
export declare function enableScaledBorderRadius(canvas: FabricCanvas): () => void;
|
|
14
27
|
/**
|
|
15
28
|
* Options for {@link serializeCanvas}.
|
|
16
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAQ,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAQ,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAC;AAoBzE;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,CA2BpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,CAuBzE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAE5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,CAqDR;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC;CACzC;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC,CA0DzB"}
|
package/dist/styles.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/** Selection handle appearance (border, corner color). Applied to all objects. */
|
|
1
2
|
export declare const DEFAULT_CONTROL_STYLE: {
|
|
2
3
|
borderColor: string;
|
|
3
4
|
cornerColor: string;
|
|
4
5
|
cornerStrokeColor: string;
|
|
5
6
|
transparentCorners: boolean;
|
|
6
7
|
};
|
|
8
|
+
/** Default fill/stroke for rectangles and polygons. */
|
|
7
9
|
export declare const DEFAULT_SHAPE_STYLE: {
|
|
8
10
|
borderColor: string;
|
|
9
11
|
cornerColor: string;
|
|
@@ -14,6 +16,7 @@ export declare const DEFAULT_SHAPE_STYLE: {
|
|
|
14
16
|
strokeWidth: number;
|
|
15
17
|
strokeUniform: boolean;
|
|
16
18
|
};
|
|
19
|
+
/** Default fill for circles (Rects with full border-radius). */
|
|
17
20
|
export declare const DEFAULT_CIRCLE_STYLE: {
|
|
18
21
|
borderColor: string;
|
|
19
22
|
cornerColor: string;
|
|
@@ -24,6 +27,7 @@ export declare const DEFAULT_CIRCLE_STYLE: {
|
|
|
24
27
|
strokeWidth: number;
|
|
25
28
|
strokeUniform: boolean;
|
|
26
29
|
};
|
|
30
|
+
/** Preview rectangle shown during drag-to-create (dashed stroke). */
|
|
27
31
|
export declare const DEFAULT_DRAG_SHAPE_STYLE: {
|
|
28
32
|
fill: string;
|
|
29
33
|
stroke: string;
|
|
@@ -31,6 +35,7 @@ export declare const DEFAULT_DRAG_SHAPE_STYLE: {
|
|
|
31
35
|
strokeUniform: boolean;
|
|
32
36
|
strokeDashArray: number[];
|
|
33
37
|
};
|
|
38
|
+
/** Preview polygon shown during draw-to-create (semi-transparent dashed stroke). */
|
|
34
39
|
export declare const DEFAULT_GUIDELINE_SHAPE_STYLE: {
|
|
35
40
|
fill: string;
|
|
36
41
|
stroke: string;
|
|
@@ -38,6 +43,7 @@ export declare const DEFAULT_GUIDELINE_SHAPE_STYLE: {
|
|
|
38
43
|
strokeUniform: boolean;
|
|
39
44
|
strokeDashArray: number[];
|
|
40
45
|
};
|
|
46
|
+
/** Alignment guideline appearance (color, width, x-marker size). */
|
|
41
47
|
export declare const DEFAULT_ALIGNMENT_STYLE: {
|
|
42
48
|
readonly color: "rgba(255, 0, 0, 0.9)";
|
|
43
49
|
readonly width: 1;
|
package/dist/styles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB;;;;;CAKjC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;CAM/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;CAMhC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;CAMzC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAKA,kFAAkF;AAClF,eAAO,MAAM,qBAAqB;;;;;CAKjC,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,mBAAmB;;;;;;;;;CAM/B,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,oBAAoB;;;;;;;;;CAMhC,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,wBAAwB;;;;;;CAMpC,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,6BAA6B;;;;;;CAMzC,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
|