@plait/core 0.29.0 → 0.31.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.
@@ -3,7 +3,7 @@ import { ComponentType, PlaitElement } from './element';
3
3
  import { PlaitPluginElementContext } from '../core/element/context';
4
4
  import { PlaitHistory } from './history';
5
5
  import { PlaitOperation } from './operation';
6
- import { Selection, Range } from './selection';
6
+ import { Selection } from './selection';
7
7
  import { Viewport } from './viewport';
8
8
  import { PlaitPluginElementComponent } from '../core/element/plugin-element';
9
9
  import { RoughSVG } from 'roughjs/bin/svg';
@@ -44,7 +44,8 @@ export interface PlaitBoard {
44
44
  drawElement: (context: PlaitPluginElementContext) => SVGGElement[] | ComponentType<PlaitPluginElementComponent>;
45
45
  redrawElement: (context: PlaitPluginElementContext, previousContext?: PlaitPluginElementContext) => SVGGElement[] | void;
46
46
  destroyElement: (context: PlaitPluginElementContext) => void;
47
- isHitSelection: (element: PlaitElement, range: Range) => boolean;
47
+ isRectangleHit: (element: PlaitElement, range: Selection) => boolean;
48
+ isHit: (element: PlaitElement, point: Point) => boolean;
48
49
  isRecursion: (element: PlaitElement) => boolean;
49
50
  isMovable: (element: PlaitElement) => boolean;
50
51
  getRectangle: (element: PlaitElement) => RectangleClient | null;
@@ -53,6 +54,7 @@ export interface PlaitBoard {
53
54
  pathRefs: () => Set<PathRef>;
54
55
  applyTheme: (element: PlaitElement) => void;
55
56
  isAlign: (element: PlaitElement) => boolean;
57
+ isImageBindingAllowed: (element: PlaitElement) => boolean;
56
58
  pointerDown: (pointer: PointerEvent) => void;
57
59
  pointerMove: (pointer: PointerEvent) => void;
58
60
  pointerUp: (pointer: PointerEvent) => void;
@@ -5,4 +5,6 @@ export interface XYPosition {
5
5
  }
6
6
  export declare const Point: {
7
7
  isEquals(point?: Point, otherPoint?: Point): boolean | undefined;
8
+ isHorizontalAlign(point?: Point, otherPoint?: Point, tolerance?: number): boolean | undefined;
9
+ isVerticalAlign(point?: Point, otherPoint?: Point, tolerance?: number): boolean | undefined;
8
10
  };
@@ -12,7 +12,9 @@ export interface RectangleClient {
12
12
  export type PointOfRectangle = [number, number];
13
13
  export declare const RectangleClient: {
14
14
  isHit: (origin: RectangleClient, target: RectangleClient) => boolean;
15
- toRectangleClient: (points: [Point, Point]) => {
15
+ isHitX: (origin: RectangleClient, target: RectangleClient) => boolean;
16
+ isHitY: (origin: RectangleClient, target: RectangleClient) => boolean;
17
+ toRectangleClient: (points: Point[]) => {
16
18
  x: number;
17
19
  y: number;
18
20
  width: number;
@@ -34,4 +36,12 @@ export declare const RectangleClient: {
34
36
  getCornerPoints: (rectangle: RectangleClient) => [Point, Point, Point, Point];
35
37
  getEdgeCenterPoints: (rectangle: RectangleClient) => [Point, Point, Point, Point];
36
38
  getConnectionPoint: (rectangle: RectangleClient, point: PointOfRectangle) => Point;
39
+ expand(rectangle: RectangleClient, left: number, top?: number, right?: number, bottom?: number): {
40
+ x: number;
41
+ y: number;
42
+ width: number;
43
+ height: number;
44
+ };
45
+ getGapCenter(rectangle1: RectangleClient, rectangle2: RectangleClient, isHorizontal: boolean): number;
46
+ isPointInRectangle(rectangle: RectangleClient, point: Point): boolean;
37
47
  };
@@ -1,13 +1,10 @@
1
1
  import { Point } from './point';
2
2
  export declare const SELECTION_BORDER_COLOR = "#6698FF";
3
3
  export declare const SELECTION_FILL_COLOR = "#6698FF19";
4
- export interface Range {
4
+ export interface Selection {
5
5
  anchor: Point;
6
6
  focus: Point;
7
7
  }
8
- export interface Selection {
9
- ranges: Range[];
10
- }
11
8
  export declare const Selection: {
12
- isCollapsed(selection: Range): boolean;
9
+ isCollapsed(selection: Selection): boolean;
13
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plait/core",
3
- "version": "0.29.0",
3
+ "version": "0.31.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^16.0.0",
6
6
  "@angular/core": "^16.0.0",
@@ -43,6 +43,9 @@
43
43
  }
44
44
  }
45
45
 
46
+ &.ns-resize {
47
+ cursor: ns-resize;
48
+ }
46
49
  &.ew-resize {
47
50
  cursor: ew-resize;
48
51
  }
@@ -1,9 +1,9 @@
1
1
  import { PlaitBoard } from '../interfaces/board';
2
- import { Selection, Range } from '../interfaces/selection';
2
+ import { Selection } from '../interfaces/selection';
3
3
  import { PlaitElement } from '../interfaces/element';
4
- export declare const getHitElements: (board: PlaitBoard, selection?: Selection, match?: (element: PlaitElement) => boolean) => PlaitElement[];
5
- export declare const getHitElementOfRoot: (board: PlaitBoard, rootElements: PlaitElement[], range: Range) => PlaitElement | undefined;
6
- export declare const isHitElements: (board: PlaitBoard, elements: PlaitElement[], ranges: Range[]) => boolean;
4
+ import { Point } from '../interfaces/point';
5
+ export declare const getHitElementsBySelection: (board: PlaitBoard, selection?: Selection, match?: (element: PlaitElement) => boolean) => PlaitElement[];
6
+ export declare const getHitElementByPoint: (board: PlaitBoard, point: Point, match?: (element: PlaitElement) => boolean) => undefined | PlaitElement;
7
7
  export declare const cacheSelectedElements: (board: PlaitBoard, selectedElements: PlaitElement[]) => void;
8
8
  export declare const getSelectedElements: (board: PlaitBoard) => PlaitElement[];
9
9
  export declare const addSelectedElement: (board: PlaitBoard, element: PlaitElement) => void;