@plait/common 0.1.0-next.9 → 0.29.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/README.md +14 -2
- package/constants/media.d.ts +3 -0
- package/core/image-base.component.d.ts +29 -0
- package/esm2022/constants/media.mjs +4 -1
- package/esm2022/constants/resize.mjs +1 -1
- package/esm2022/core/image-base.component.mjs +93 -0
- package/esm2022/generators/generator.mjs +2 -1
- package/esm2022/generators/image.generator.mjs +54 -0
- package/esm2022/generators/index.mjs +2 -1
- package/esm2022/plugins/with-resize.mjs +2 -2
- package/esm2022/public-api.mjs +2 -1
- package/esm2022/transforms/property.mjs +1 -1
- package/esm2022/utils/direction.mjs +6 -2
- package/esm2022/utils/hot-key.mjs +1 -1
- package/esm2022/utils/image.mjs +40 -0
- package/esm2022/utils/index.mjs +2 -1
- package/esm2022/utils/resize.mjs +3 -3
- package/esm2022/utils/text.mjs +1 -1
- package/fesm2022/plait-common.mjs +195 -6
- package/fesm2022/plait-common.mjs.map +1 -1
- package/generators/generator.d.ts +1 -0
- package/generators/image.generator.d.ts +23 -0
- package/generators/index.d.ts +1 -0
- package/package.json +1 -1
- package/plugins/with-resize.d.ts +2 -6
- package/public-api.d.ts +1 -0
- package/transforms/property.d.ts +2 -2
- package/utils/direction.d.ts +2 -1
- package/utils/image.d.ts +12 -0
- package/utils/index.d.ts +1 -0
- package/utils/resize.d.ts +9 -4
package/plugins/with-resize.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlaitBoard, PlaitElement, Point } from '@plait/core';
|
|
2
2
|
import { ResizeHandle, ResizeCursorClass } from '../constants/resize';
|
|
3
|
+
import { ResizeRef } from '../utils/resize';
|
|
3
4
|
export interface WithResizeOptions<T extends PlaitElement = PlaitElement, K = ResizeHandle> {
|
|
4
5
|
key: string;
|
|
5
6
|
canResize: () => boolean;
|
|
@@ -12,11 +13,6 @@ export interface ResizeDetectResult<T extends PlaitElement = PlaitElement, K = R
|
|
|
12
13
|
handle: K;
|
|
13
14
|
cursorClass?: ResizeCursorClass;
|
|
14
15
|
}
|
|
15
|
-
export interface ResizeRef<T extends PlaitElement = PlaitElement, K = ResizeHandle> {
|
|
16
|
-
element: T;
|
|
17
|
-
path: Path;
|
|
18
|
-
handle: K;
|
|
19
|
-
}
|
|
20
16
|
export interface ResizeState {
|
|
21
17
|
offsetX: number;
|
|
22
18
|
offsetY: number;
|
package/public-api.d.ts
CHANGED
package/transforms/property.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlaitBoard } from '@plait/core';
|
|
2
2
|
export declare const PropertyTransforms: {
|
|
3
3
|
setFillColor: (board: PlaitBoard, fill: string) => void;
|
|
4
4
|
setStrokeStyle: (board: PlaitBoard, strokeStyle: string) => void;
|
|
5
|
-
setProperty: (board: PlaitBoard, options: any, callback?: ((component: PlaitPluginElementComponent<PlaitElement, PlaitBoard>, path: Path) => void) | undefined) => void;
|
|
5
|
+
setProperty: (board: PlaitBoard, options: any, callback?: ((component: import("@plait/core").PlaitPluginElementComponent<import("@plait/core").PlaitElement, PlaitBoard>, path: import("@plait/core").Path) => void) | undefined) => void;
|
|
6
6
|
setStrokeWidth: (board: PlaitBoard, strokeWidth: number) => void;
|
|
7
7
|
setStrokeColor: (board: PlaitBoard, strokeColor: string) => void;
|
|
8
8
|
};
|
package/utils/direction.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export declare function getDirectionByPointOfRectangle(point: PointOfRectangle):
|
|
|
7
7
|
* if the vector has two directions, the function will return the string in which direction it is closer.
|
|
8
8
|
*/
|
|
9
9
|
export declare function getDirectionByVector(vector: Vector): Direction | null;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function getPointByVector(point: Point, vector: Vector, offset: number): Point;
|
|
11
|
+
export declare function rotateVectorAnti90(vector: Vector): Vector;
|
|
11
12
|
export declare function getDirectionBetweenPointAndPoint(source: Point, target: Point): Direction;
|
|
12
13
|
export declare function getDirectionFactor(direction: Direction): {
|
|
13
14
|
x: number;
|
package/utils/image.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentType, PlaitBoard } from '@plait/core';
|
|
2
|
+
import { ImageBaseComponent } from '../core/image-base.component';
|
|
3
|
+
export interface CommonImageItem {
|
|
4
|
+
url: string;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
export interface WithCommonPluginOptions {
|
|
9
|
+
imageComponentType?: ComponentType<ImageBaseComponent>;
|
|
10
|
+
}
|
|
11
|
+
export declare const selectImage: (board: PlaitBoard, defaultImageWidth: number, handle: (commonImage: CommonImageItem) => void, acceptImageTypes?: string[]) => void;
|
|
12
|
+
export declare const buildImage: (board: PlaitBoard, imageFile: File, defaultImageWidth: number, handle: (commonImage: CommonImageItem) => void) => Promise<void>;
|
package/utils/index.d.ts
CHANGED
package/utils/resize.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { PlaitBoard, PlaitElement, RectangleClient } from '@plait/core';
|
|
1
|
+
import { Path, PlaitBoard, PlaitElement, RectangleClient } from '@plait/core';
|
|
2
2
|
import { ResizeCursorClass, ResizeHandle } from '../constants/resize';
|
|
3
|
+
export interface ResizeRef<T extends PlaitElement = PlaitElement, K = ResizeHandle> {
|
|
4
|
+
element: T;
|
|
5
|
+
path: Path;
|
|
6
|
+
handle: K;
|
|
7
|
+
}
|
|
3
8
|
export declare const getRectangleResizeHandleRefs: (rectangle: RectangleClient, diameter: number) => {
|
|
4
9
|
rectangle: {
|
|
5
10
|
x: number;
|
|
@@ -10,8 +15,8 @@ export declare const getRectangleResizeHandleRefs: (rectangle: RectangleClient,
|
|
|
10
15
|
handle: ResizeHandle;
|
|
11
16
|
cursorClass: ResizeCursorClass;
|
|
12
17
|
}[];
|
|
13
|
-
export declare const IS_RESIZING: WeakMap<PlaitBoard,
|
|
18
|
+
export declare const IS_RESIZING: WeakMap<PlaitBoard, ResizeRef<any, any>>;
|
|
14
19
|
export declare const isResizing: (board: PlaitBoard) => boolean;
|
|
15
|
-
export declare const isResizingByCondition: (board: PlaitBoard, match: (
|
|
16
|
-
export declare const addResizing: (board: PlaitBoard,
|
|
20
|
+
export declare const isResizingByCondition: <T extends PlaitElement, K>(board: PlaitBoard, match: (resizeRef: ResizeRef<T, K>) => boolean) => boolean;
|
|
21
|
+
export declare const addResizing: <T extends PlaitElement, K>(board: PlaitBoard, resizeRef: ResizeRef<T, K>, key: string) => void;
|
|
17
22
|
export declare const removeResizing: (board: PlaitBoard, key: string) => void;
|