@logicflow/core 1.2.0-alpha.2 → 1.2.0-alpha.5

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.
@@ -6,6 +6,9 @@
6
6
  background: #ffffff;
7
7
  user-select: none;
8
8
  }
9
+ .lf-graph svg {
10
+ display: block;
11
+ }
9
12
  .lf-element-text {
10
13
  cursor: text;
11
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/core",
3
- "version": "1.2.0-alpha.2",
3
+ "version": "1.2.0-alpha.5",
4
4
  "description": "LogicFlow core, to quickly build flowchart editor",
5
5
  "main": "dist/logic-flow.js",
6
6
  "unpkg": "dist/logic-flow.js",
@@ -19,7 +19,7 @@
19
19
  "build": "npm run build:umd",
20
20
  "build:umd": "cross-env NODE_ENV=production webpack --config scripts/webpack.config.build.js && cp -r src/style/ dist/style",
21
21
  "build-analyse": "cross-env analyse=true npm run build",
22
- "types": "tsc -d --declarationDir ./types --outDir temp && rimraf temp",
22
+ "types": "tsc -d --declarationDir ./tempTypes --outDir temp && rimraf types && mv ./tempTypes/src ./types && rimraf temp && rimraf tempTypes",
23
23
  "lint": "eslint . --ext .ts,.tsx",
24
24
  "publish-lib": "npm run types & npm run clean && npm run build && npm publish",
25
25
  "publish-next": "npm run types & npm run clean && npm run build && npm publish --tag next"
@@ -73,9 +73,8 @@
73
73
  "ids": "^1.0.0",
74
74
  "less-loader": "^6.0.0",
75
75
  "lodash-es": "^4.17.15",
76
- "mobx": "^5.15.7",
77
- "mobx-react": "^6.3.0",
78
- "mobx-utils": "^5.6.1",
76
+ "mobx": "^6.5.0",
77
+ "mobx-react": "^7.3.0",
79
78
  "prettier": "^2.2.1",
80
79
  "rimraf": "^3.0.2",
81
80
  "standard-version": "^9.0.0",
@@ -468,7 +468,7 @@ export default class LogicFlow {
468
468
  /**
469
469
  * 触发监听事件
470
470
  */
471
- emit(evt: string, arg: any): void;
471
+ emit(evt: string, arg?: any): void;
472
472
  /**
473
473
  * 添加扩展, 待讨论,这里是不是静态方法好一些?
474
474
  * 重复添加插件的时候,把上一次添加的插件的销毁。
@@ -519,7 +519,7 @@ export default class LogicFlow {
519
519
  * 用于支持国际化
520
520
  */
521
521
  static t(text: string): string;
522
- renderRawData(graphRawData: any): void;
522
+ renderRawData(graphRawData: any, isForce?: boolean): void;
523
523
  /**
524
524
  * 渲染图
525
525
  * @example
@@ -548,7 +548,7 @@ export default class LogicFlow {
548
548
  * })
549
549
  * @param graphData 图数据
550
550
  */
551
- render(graphData?: {}): void;
551
+ render(graphData?: {}, isForce?: boolean): void;
552
552
  /**
553
553
  * 内部保留方法
554
554
  * 获取指定类型的view
@@ -46,6 +46,8 @@ export declare enum EventType {
46
46
  NODE_MOUSEMOVE = "node:mousemove",
47
47
  NODE_MOUSEENTER = "node:mouseenter",
48
48
  NODE_MOUSELEAVE = "node:mouseleave",
49
+ NODE_TEXT_UPDATE = "node:text-update",
50
+ NODE_PROPERTY_UPDATE = "node:property-update",
49
51
  NODE_CONTEXTMENU = "node:contextmenu",
50
52
  EDGE_DELETE = "edge:delete",
51
53
  EDGE_ADD = "edge:add",
@@ -53,6 +55,8 @@ export declare enum EventType {
53
55
  EDGE_DBCLICK = "edge:dbclick",
54
56
  EDGE_MOUSEENTER = "edge:mouseenter",
55
57
  EDGE_MOUSELEAVE = "edge:mouseleave",
58
+ EDGE_TEXT_UPDATE = "edge:text-update",
59
+ EDGE_PROPERTY_UPDATE = "edge:property-update",
56
60
  EDGE_CONTEXTMENU = "edge:contextmenu",
57
61
  EDGE_ADJUST = "edge:adjust",
58
62
  EDGE_EXCHANGE_NODE = "edge:exchange-node",
@@ -76,7 +80,9 @@ export declare enum EventType {
76
80
  SELECTION_CONTEXTMENU = "selection:contextmenu",
77
81
  CONNECTION_NOT_ALLOWED = "connection:not-allowed",
78
82
  HISTORY_CHANGE = "history:change",
83
+ HISTORY_INSERT = "history:insert",
79
84
  TEXT_UPDATE = "text:update",
85
+ TEXT_DROP = "text:drop",
80
86
  GRAPH_TRANSFORM = "graph:transform",
81
87
  GRAPH_RENDERED = "graph:rendered"
82
88
  }
@@ -8,13 +8,15 @@ declare class History {
8
8
  maxSize: number;
9
9
  waitTime: number;
10
10
  eventCenter: EventEmitter;
11
- constructor(eventCenter: any);
11
+ model: any;
12
+ constructor(graphModel: any, isPropertiesChangeHistory: any);
12
13
  add(data: any): void;
13
14
  undoAble(): boolean;
14
15
  undo(): any;
15
16
  redoAble(): boolean;
16
17
  redo(): any;
17
- watch(model: any): void;
18
+ emitHistoryChange(): void;
19
+ listenHistoryChange: () => void;
18
20
  }
19
21
  export { History };
20
22
  export default History;
package/types/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { h } from 'preact';
2
1
  import LogicFlow from './LogicFlow';
3
2
  import * as LogicFlowUtil from './util';
4
- export declare function observer<P>(props: P): any;
5
- export { LogicFlow, h };
6
- export { LogicFlowUtil };
3
+ import { version } from '../package.json';
4
+ export { h } from 'preact';
5
+ export * from './util/stateUtil';
6
+ export { LogicFlowUtil, version, LogicFlow };
7
7
  export * from './type/index';
8
8
  export * from './view';
9
9
  export * from './model';
@@ -38,6 +38,7 @@ declare class BaseEdgeModel implements IBaseModel {
38
38
  animationData: import("../../constant/DefaultAnimation").Animation;
39
39
  [propName: string]: any;
40
40
  constructor(data: EdgeConfig, graphModel: GraphModel);
41
+ init(): void;
41
42
  /**
42
43
  * @override 支持重写
43
44
  * 初始化边数据
@@ -5,6 +5,7 @@ export { BezierEdgeModel };
5
5
  export default class BezierEdgeModel extends BaseEdgeModel {
6
6
  modelType: ModelType;
7
7
  path: string;
8
+ constructor(data: any, graphModel: any);
8
9
  initEdgeData(data: any): void;
9
10
  getEdgeStyle(): {
10
11
  [x: string]: any;
@@ -6,6 +6,7 @@ export default class PolylineEdgeModel extends BaseEdgeModel {
6
6
  modelType: ModelType;
7
7
  draggingPointList: any;
8
8
  dbClickPosition: Point;
9
+ constructor(data: any, graphModel: any);
9
10
  initEdgeData(data: any): void;
10
11
  getEdgeStyle(): {
11
12
  [x: string]: any;
@@ -59,6 +59,7 @@ export default class BaseNodeModel implements IBaseNodeModel {
59
59
  hasSetSourceRules: boolean;
60
60
  [propName: string]: any;
61
61
  constructor(data: NodeConfig, graphModel: GraphModel);
62
+ init(): void;
62
63
  /**
63
64
  * 获取进入当前节点的边和节点
64
65
  */
@@ -105,6 +106,7 @@ export default class BaseNodeModel implements IBaseNodeModel {
105
106
  * @override 支持重写
106
107
  */
107
108
  getData(): NodeData;
109
+ setIsDragging(isDragging: any): void;
108
110
  /**
109
111
  * 用于在历史记录时获取节点数据,
110
112
  * 在某些情况下,如果希望某个属性变化不引起history的变化,
@@ -193,5 +195,15 @@ export default class BaseNodeModel implements IBaseNodeModel {
193
195
  setProperty(key: any, val: any): void;
194
196
  setProperties(properties: any): void;
195
197
  setZIndex(zIndex?: number): void;
198
+ /**
199
+ * 设置节点属性;
200
+ * 支持属性请参考节点属性文档
201
+ * http://logic-flow.org/api/nodeModelApi.html#%E6%95%B0%E6%8D%AE%E5%B1%9E%E6%80%A7
202
+ * @example
203
+ * nodeModel.updateAttributes({
204
+ * width: 100,
205
+ * height: 100
206
+ * })
207
+ */
196
208
  updateAttributes(attributes: any): void;
197
209
  }
@@ -3,6 +3,7 @@ import { ModelType } from '../../constant/constant';
3
3
  declare class CircleNodeModel extends BaseNodeModel {
4
4
  modelType: ModelType;
5
5
  r: number;
6
+ constructor(data: any, graphData: any);
6
7
  get width(): number;
7
8
  get height(): number;
8
9
  getNodeStyle(): {
@@ -5,6 +5,7 @@ declare class DiamondNodeModel extends BaseNodeModel {
5
5
  modelType: ModelType;
6
6
  rx: number;
7
7
  ry: number;
8
+ constructor(data: any, graphData: any);
8
9
  getNodeStyle(): {
9
10
  [x: string]: any;
10
11
  fill?: string;
@@ -4,6 +4,7 @@ declare class EllipseNodeModel extends BaseNodeModel {
4
4
  modelType: ModelType;
5
5
  rx: number;
6
6
  ry: number;
7
+ constructor(data: any, graphData: any);
7
8
  getNodeStyle(): {
8
9
  [x: string]: any;
9
10
  fill?: string;
@@ -4,6 +4,7 @@ import { ModelType } from '../../constant/constant';
4
4
  declare class PolygonNodeModel extends BaseNodeModel {
5
5
  modelType: ModelType;
6
6
  points: PointTuple[];
7
+ constructor(data: any, graphModel: any);
7
8
  getNodeStyle(): {
8
9
  [x: string]: any;
9
10
  fill?: string;
@@ -3,6 +3,7 @@ import { ModelType } from '../../constant/constant';
3
3
  declare class RectNodeModel extends BaseNodeModel {
4
4
  modelType: ModelType;
5
5
  radius: number;
6
+ constructor(data: any, graphModel: any);
6
7
  getDefaultAnchor(): {
7
8
  x: number;
8
9
  y: number;
@@ -2,6 +2,7 @@ import BaseNodeModel from './BaseNodeModel';
2
2
  import { ModelType } from '../../constant/constant';
3
3
  declare class TextNodeModel extends BaseNodeModel {
4
4
  modelType: ModelType;
5
+ constructor(data: any, graphModel: any);
5
6
  getTextStyle(): {
6
7
  [x: string]: any;
7
8
  color?: string;
@@ -60,6 +60,13 @@ export declare type Definition = {
60
60
  * 是否开启历史记录功能,默认开启
61
61
  */
62
62
  history?: boolean;
63
+ /**
64
+ * 节点、连线的属性的变化是否会记录到history中,默认是。
65
+ * 例如:节点的一个属性为active, 在自定义节点时这个属性为true节点高亮。
66
+ * 那么在isPropertiesChangeHistory为true的情况下,将节点active设置为true
67
+ * 会在历史记录中多一个active为false的快照。
68
+ */
69
+ isPropertiesChangeHistory?: boolean;
63
70
  /**
64
71
  * 是否开启局部渲染,默认不开启
65
72
  */
@@ -107,6 +114,7 @@ export declare function get(options: Definition): {
107
114
  background: boolean;
108
115
  grid: boolean;
109
116
  textEdit: boolean;
117
+ isPropertiesChangeHistory: boolean;
110
118
  disabledTools: any[];
111
119
  } & {
112
120
  [key: string]: any;
@@ -155,6 +163,13 @@ export declare function get(options: Definition): {
155
163
  * 是否开启历史记录功能,默认开启
156
164
  */
157
165
  history?: boolean;
166
+ /**
167
+ * 节点、连线的属性的变化是否会记录到history中,默认是。
168
+ * 例如:节点的一个属性为active, 在自定义节点时这个属性为true节点高亮。
169
+ * 那么在isPropertiesChangeHistory为true的情况下,将节点active设置为true
170
+ * 会在历史记录中多一个active为false的快照。
171
+ */
172
+ isPropertiesChangeHistory?: boolean;
158
173
  /**
159
174
  * 是否开启局部渲染,默认不开启
160
175
  */
@@ -197,6 +212,7 @@ export declare const defaults: {
197
212
  background: boolean;
198
213
  grid: boolean;
199
214
  textEdit: boolean;
215
+ isPropertiesChangeHistory: boolean;
200
216
  disabledTools: any[];
201
217
  };
202
218
  export {};
@@ -28,6 +28,7 @@ export default class TextEdit extends Component<IProps, IState> {
28
28
  componentDidUpdate(): void;
29
29
  keyupHandler: (ev: any) => void;
30
30
  inputHandler: (ev: any) => void;
31
+ keydownHandler: (ev: any) => void;
31
32
  placeCaretAtEnd(el: any): void;
32
33
  render(): h.JSX.Element;
33
34
  }
@@ -26,8 +26,11 @@ export declare const isBboxOverLapping: (b1: PBBox, b2: PBBox) => boolean;
26
26
  export declare const filterRepeatPoints: (points: PolyPoint[]) => PolyPoint[];
27
27
  export declare const getSimplePolyline: (sPoint: PolyPoint, tPoint: PolyPoint) => PolyPoint[];
28
28
  export declare const getExpandedBBox: (bbox: PBBox, offset: number) => PBBox;
29
- export declare const pointDirection: (point: PolyPoint, bbox: PBBox) => Direction;
30
- export declare const getExpandedBBoxPoint: (bbox: PBBox, point: PolyPoint) => PolyPoint;
29
+ /**
30
+ * 判断点与中心点边的方向:是否水平,true水平,false垂直
31
+ */
32
+ export declare const pointDirection: (point: PolyPoint, node: BaseNode) => Direction;
33
+ export declare const getExpandedBBoxPoint: (bbox: PBBox, point: PolyPoint, direction: any) => PolyPoint;
31
34
  export declare const mergeBBox: (b1: PBBox, b2: PBBox) => PBBox;
32
35
  export declare const getBBoxOfPoints: (points?: PolyPoint[], offset?: number) => PBBox;
33
36
  export declare const getPointsFromBBox: (bbox: PBBox) => PolyPoint[];
@@ -46,6 +49,14 @@ export declare const getNextNeighborPoints: (points: PolyPoint[], point: PolyPoi
46
49
  export declare const pathFinder: (points: PolyPoint[], start: PolyPoint, goal: PolyPoint, sBBox: PBBox, tBBox: PBBox, os: PolyPoint, ot: PolyPoint) => PolyPoint[];
47
50
  export declare const getBoxByOriginNode: (node: BaseNode) => PBBox;
48
51
  export declare const pointFilter: (points: PolyPoint[]) => PolyPoint[];
52
+ /**
53
+ * 计算折线点
54
+ * @param start 连线的开始点坐标
55
+ * @param end 连线的结束点坐标
56
+ * @param sNode 连线连接的开始节点
57
+ * @param tNode 连线连接的结束节点
58
+ * @param offset 连线箭头距离
59
+ */
49
60
  export declare const getPolylinePoints: (start: PolyPoint, end: PolyPoint, sNode: BaseNode, tNode: BaseNode, offset: number) => PolyPoint[];
50
61
  /**
51
62
  * 获取折线中最长的一个线
@@ -0,0 +1,4 @@
1
+ export { action, observable, computed, makeObservable, configure, toJS, isObservable, } from 'mobx';
2
+ export declare function observer<P>(props: P): any;
3
+ export type { IReactionDisposer, IReactionPublic, IReactionOptions } from 'mobx';
4
+ export * as mobx from 'mobx';
@@ -13,7 +13,12 @@ declare class CanvasOverlay extends Component<IProps, IState> {
13
13
  stepDrag: StepDrag;
14
14
  stepScrollX: number;
15
15
  stepScrollY: number;
16
+ ref: HTMLElement;
16
17
  constructor(props: IProps);
18
+ componentDidMount(): void;
19
+ componentWillUnmount(): void;
20
+ setRef: (dom: any) => void;
21
+ get rootEl(): HTMLElement;
17
22
  onDragging: ({ deltaX, deltaY }: {
18
23
  deltaX: any;
19
24
  deltaY: any;
@@ -22,6 +22,7 @@ export default class BaseText extends Component<IProps, IState> {
22
22
  deltaX: any;
23
23
  deltaY: any;
24
24
  }) => void;
25
+ onDragEnd: (e: any) => void;
25
26
  dblClickHandler: () => void;
26
27
  mouseDownHandle: (ev: MouseEvent) => void;
27
28
  render(): h.JSX.Element;
@@ -1 +0,0 @@
1
- export default function Rect(props: any): void;
@@ -1,4 +0,0 @@
1
- import { h, Component } from 'preact';
2
- export default class TransfromGraph extends Component {
3
- render(): h.JSX.Element;
4
- }