@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.
@@ -1,5 +1,6 @@
1
- import { Path, PlaitBoard, PlaitElement, Point } from '@plait/core';
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
@@ -5,3 +5,4 @@ export * from './shapes';
5
5
  export * from './plugins';
6
6
  export * from './utils';
7
7
  export * from './core/plugin-element';
8
+ export * from './core/image-base.component';
@@ -1,8 +1,8 @@
1
- import { Path, PlaitBoard, PlaitElement, PlaitPluginElementComponent } from '@plait/core';
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
  };
@@ -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 rotateVector90(vector: Vector): Vector;
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;
@@ -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
@@ -5,3 +5,4 @@ export * from './rectangle';
5
5
  export * from './creation-mode';
6
6
  export * from './direction';
7
7
  export * from './text';
8
+ export * from './image';
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, PlaitElement>;
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: (element: PlaitElement) => boolean) => boolean;
16
- export declare const addResizing: (board: PlaitBoard, element: PlaitElement, key: string) => void;
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;