@plait/core 0.47.0 → 0.49.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plait/core",
3
- "version": "0.47.0",
3
+ "version": "0.49.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^16.0.0",
6
6
  "@angular/core": "^16.0.0",
package/utils/board.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { PlaitBoard } from '../interfaces/board';
2
- import { Point } from '../interfaces/point';
3
2
  export type ViewBox = {
4
3
  minX: number;
5
4
  minY: number;
@@ -8,7 +7,5 @@ export type ViewBox = {
8
7
  viewportWidth: number;
9
8
  viewportHeight: number;
10
9
  };
11
- export declare function transformPoints(board: PlaitBoard, points: Point[]): Point[];
12
- export declare function transformPoint(board: PlaitBoard, point: Point): Point;
13
10
  export declare function isInPlaitBoard(board: PlaitBoard, x: number, y: number): boolean;
14
11
  export declare function getRealScrollBarWidth(board: PlaitBoard): number;
@@ -1,21 +1,6 @@
1
1
  import { Options } from 'roughjs/bin/core';
2
- import { PlaitBoard, RectangleClient } from '../../interfaces';
3
- import { Point } from '../../interfaces/point';
2
+ import { RectangleClient } from '../../interfaces';
4
3
  export declare const NS = "http://www.w3.org/2000/svg";
5
- /**
6
- * Get the screen coordinates starting from the upper left corner of the svg element (based on the svg screen coordinate system)
7
- * @param x screen x
8
- * @param y screen x
9
- * @returns
10
- */
11
- export declare function toPoint(x: number, y: number, svg: SVGElement): Point;
12
- /**
13
- * `toPoint` reverse processing
14
- * Get the screen coordinate starting from the upper left corner of the browser window (based on the screen coordinate system)
15
- * @param point screen coordinates based on the upper left corner of the svg
16
- * @returns
17
- */
18
- export declare function toScreenPoint(board: PlaitBoard, point: Point): Point;
19
4
  export declare function createG(): SVGGElement;
20
5
  export declare function createPath(): SVGPathElement;
21
6
  export declare function createRect(rectangle: RectangleClient, options?: Options): SVGRectElement;
package/utils/index.d.ts CHANGED
@@ -21,3 +21,4 @@ export * from './to-image';
21
21
  export * from './clipboard';
22
22
  export * from './touch';
23
23
  export * from './dnd';
24
+ export * from './to-point';
@@ -0,0 +1,21 @@
1
+ import { PlaitBoard } from '../interfaces/board';
2
+ import { Point } from '../interfaces/point';
3
+ export declare const getViewBox: (board: PlaitBoard) => DOMRect;
4
+ /**
5
+ * Get the screen point starting from the upper left corner of the svg element (based on the svg screen coordinate system)
6
+ */
7
+ export declare function toHostPoint(board: PlaitBoard, x: number, y: number): Point;
8
+ /**
9
+ * Get the point in the coordinate system of the svg viewBox
10
+ */
11
+ export declare function toViewBoxPoint(board: PlaitBoard, hostPoint: Point): Point;
12
+ export declare function toViewBoxPoints(board: PlaitBoard, hostPoints: Point[]): Point[];
13
+ /**
14
+ * `toHostPoint` reverse processing
15
+ * Get the screen point starting from the upper left corner of the browser window or the viewport (based on the screen coordinate system)
16
+ */
17
+ export declare function toScreenPointFromHostPoint(board: PlaitBoard, hostPoint: Point): Point;
18
+ /**
19
+ * `toViewBoxPoint` reverse processing
20
+ */
21
+ export declare function toHostPointFromViewBoxPoint(board: PlaitBoard, viewBoxPoint: Point): Point;
@@ -1,5 +1,4 @@
1
1
  import { PlaitBoard, Point, RectangleClient } from '../interfaces';
2
- export declare function toSVGScreenPoint(board: PlaitBoard, point: Point): Point;
3
2
  export declare function getViewportContainerRect(board: PlaitBoard): {
4
3
  width: number;
5
4
  height: number;
@@ -11,14 +10,10 @@ export declare function getElementHostBBox(board: PlaitBoard, zoom: number): {
11
10
  bottom: number;
12
11
  };
13
12
  /**
14
- * 验证缩放比是否符合限制,如果超出限制,则返回合适的缩放比
15
- * @param zoom 缩放比
16
- * @param minZoom 最小缩放比
17
- * @param maxZoom 最大缩放比
18
- * @returns 正确的缩放比
13
+ * Normalize the scaling ratio, or return the corrected scaling ratio if the limit is exceeded
19
14
  */
20
15
  export declare function clampZoomLevel(zoom: number, minZoom?: number, maxZoom?: number): number;
21
- export declare function getViewBox(board: PlaitBoard, zoom: number): number[];
16
+ export declare function calcNewViewBox(board: PlaitBoard, zoom: number): number[];
22
17
  export declare function getViewBoxCenterPoint(board: PlaitBoard): Point;
23
18
  export declare function setSVGViewBox(board: PlaitBoard, viewBox: number[]): void;
24
19
  export declare function updateViewportOffset(board: PlaitBoard): void;