@logicflow/core 1.1.8 → 1.1.9

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": "@logicflow/core",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "LogicFlow core, to quickly build flowchart editor",
5
5
  "main": "dist/logic-flow.js",
6
6
  "unpkg": "dist/logic-flow.js",
@@ -332,7 +332,7 @@ export default class LogicFlow {
332
332
  * @param leftTopPoint 区域左上角坐标, dom层坐标
333
333
  * @param rightBottomPoint 区域右下角坐标,dom层坐标
334
334
  */
335
- getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple): any[];
335
+ getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple, wholeEdge?: boolean, wholeNode?: boolean): any[];
336
336
  /**
337
337
  * 获取选中的元素数据
338
338
  * @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
@@ -138,8 +138,12 @@ declare class GraphModel {
138
138
  get selectElements(): Map<any, any>;
139
139
  /**
140
140
  * 获取指定区域内的所有元素
141
+ * @param leftTopPoint 表示区域左上角的点
142
+ * @param rightBottomPoint 表示区域右下角的点
143
+ * @param wholeEdge 是否要整个边都在区域内部
144
+ * @param wholeNode 是否要整个节点都在区域内部
141
145
  */
142
- getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple): any[];
146
+ getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple, wholeEdge?: boolean, wholeNode?: boolean): any[];
143
147
  /**
144
148
  * 获取指定类型元素对应的Model
145
149
  */
@@ -168,8 +172,10 @@ declare class GraphModel {
168
172
  * @param element 节点或者边
169
173
  * @param lt 左上角点
170
174
  * @param rb 右下角点
175
+ * @param wholeEdge 边的起点和终点都在区域内才算
176
+ * @param wholeNode 节点的box都在区域内才算
171
177
  */
172
- isElementInArea(element: any, lt: PointTuple, rb: PointTuple, wholeEdge?: boolean): boolean;
178
+ isElementInArea(element: any, lt: PointTuple, rb: PointTuple, wholeEdge?: boolean, wholeNode?: boolean): boolean;
173
179
  /**
174
180
  * 使用新的数据重新设置整个画布的元素
175
181
  * 注意:将会清除画布上所有已有的节点和边
@@ -1,6 +1,6 @@
1
1
  import { OutlineTheme } from '../../constant/DefaultTheme';
2
2
  import { ModelType, ElementType } from '../../constant/constant';
3
- import { AdditionData, NodeData, NodeConfig, NodeMoveRule, Bounds, AnchorConfig, PointAnchor, AnchorsOffsetItem, ShapeStyleAttribute } from '../../type';
3
+ import { AdditionData, NodeData, NodeConfig, NodeMoveRule, Bounds, AnchorConfig, PointAnchor, AnchorsOffsetItem, ShapeStyleAttribute, IsAllowMove } from '../../type';
4
4
  import GraphModel from '../GraphModel';
5
5
  import { IBaseModel } from '../BaseModel';
6
6
  import { BaseEdgeModel } from '../edge';
@@ -161,7 +161,7 @@ export default class BaseNodeModel implements IBaseNodeModel {
161
161
  * 内部方法
162
162
  * 是否允许移动节点到新的位置
163
163
  */
164
- isAllowMoveNode(deltaX: any, deltaY: any): boolean;
164
+ isAllowMoveNode(deltaX: any, deltaY: any): boolean | IsAllowMove;
165
165
  /**
166
166
  * 获取作为连线终点时的所有规则。
167
167
  */
@@ -338,13 +338,21 @@ export declare type AnchorConfig = {
338
338
  y: number;
339
339
  [key: string]: any;
340
340
  };
341
+ /**
342
+ * 移动规则结果,可以支持允许水平移动,不允许垂直移动。
343
+ * 在分组移动到边缘时有用到。
344
+ */
345
+ export declare type IsAllowMove = {
346
+ x: boolean;
347
+ y: boolean;
348
+ };
341
349
  /**
342
350
  * 限制节点移动规则
343
351
  * model: 移动节点的model
344
352
  * deltaX: 移动的x轴距离
345
353
  * deltaY: 移动的y轴距离
346
354
  */
347
- export declare type NodeMoveRule = (model: BaseNodeModel, deltaX: number, deltaY: number) => Boolean;
355
+ export declare type NodeMoveRule = (model: BaseNodeModel, deltaX: number, deltaY: number) => Boolean | IsAllowMove;
348
356
  export declare type ZoomParam = boolean | number;
349
357
  export declare type NodeAttributes = {
350
358
  id: string;
@@ -0,0 +1,2 @@
1
+ export declare const createRaf: (callback: any) => string;
2
+ export declare const cancelRaf: (rafId: any) => void;
@@ -12,6 +12,10 @@ declare type Istate = {
12
12
  };
13
13
  export default abstract class BaseNode extends Component<IProps, Istate> {
14
14
  t: any;
15
+ moveOffset: {
16
+ x: number;
17
+ y: number;
18
+ };
15
19
  static getModel(defaultModel: any): any;
16
20
  stepDrag: StepDrag;
17
21
  contextMenuTime: number;
@@ -23,6 +27,12 @@ export default abstract class BaseNode extends Component<IProps, Istate> {
23
27
  getAnchors(): h.JSX.Element[];
24
28
  getText(): "" | h.JSX.Element;
25
29
  getStateClassName(): string;
30
+ onDragStart: ({ event: { clientX, clientY } }: {
31
+ event: {
32
+ clientX: any;
33
+ clientY: any;
34
+ };
35
+ }) => void;
26
36
  onDraging: ({ event }: {
27
37
  event: any;
28
38
  }) => void;