@logicflow/core 0.7.16 → 1.0.0-alpha.11

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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/logic-flow.js +2 -11
  3. package/dist/style/index.css +1 -1
  4. package/package.json +6 -3
  5. package/types/LogicFlow.d.ts +341 -137
  6. package/types/constant/DefaultTheme.d.ts +260 -171
  7. package/types/constant/constant.d.ts +7 -1
  8. package/types/keyboard/index.d.ts +1 -5
  9. package/types/model/BaseModel.d.ts +60 -1
  10. package/types/model/EditConfigModel.d.ts +6 -16
  11. package/types/model/GraphModel.d.ts +279 -63
  12. package/types/model/SnaplineModel.d.ts +6 -2
  13. package/types/model/TransformModel.d.ts +8 -2
  14. package/types/model/edge/BaseEdgeModel.d.ts +91 -43
  15. package/types/model/edge/BezierEdgeModel.d.ts +10 -2
  16. package/types/model/edge/LineEdgeModel.d.ts +6 -1
  17. package/types/model/edge/PolylineEdgeModel.d.ts +8 -3
  18. package/types/model/node/BaseNodeModel.d.ts +113 -48
  19. package/types/model/node/CircleNodeModel.d.ts +12 -4
  20. package/types/model/node/DiamondNodeModel.d.ts +7 -4
  21. package/types/model/node/EllipseNodeModel.d.ts +6 -2
  22. package/types/model/node/HtmlNodeModel.d.ts +0 -2
  23. package/types/model/node/PolygonNodeModel.d.ts +11 -2
  24. package/types/model/node/RectNodeModel.d.ts +9 -2
  25. package/types/model/node/TextNodeModel.d.ts +8 -4
  26. package/types/options.d.ts +78 -12
  27. package/types/type/index.d.ts +50 -37
  28. package/types/util/edge.d.ts +3 -3
  29. package/types/util/graph.d.ts +1 -1
  30. package/types/util/node.d.ts +1 -1
  31. package/types/util/theme.d.ts +2 -173
  32. package/types/view/Anchor.d.ts +0 -2
  33. package/types/view/Graph.d.ts +1 -3
  34. package/types/view/basic-shape/Path.d.ts +1 -9
  35. package/types/view/basic-shape/Rect.d.ts +1 -5
  36. package/types/view/behavior/DnD.d.ts +0 -4
  37. package/types/view/edge/AdjustPoint.d.ts +1 -3
  38. package/types/view/edge/Arrow.d.ts +3 -3
  39. package/types/view/edge/BaseEdge.d.ts +2 -20
  40. package/types/view/edge/BezierEdge.d.ts +0 -12
  41. package/types/view/edge/LineEdge.d.ts +0 -13
  42. package/types/view/edge/PolylineEdge.d.ts +0 -12
  43. package/types/view/node/BaseNode.d.ts +1 -36
  44. package/types/view/node/CircleNode.d.ts +0 -37
  45. package/types/view/node/DiamondNode.d.ts +0 -37
  46. package/types/view/node/EllipseNode.d.ts +0 -26
  47. package/types/view/node/HtmlNode.d.ts +21 -0
  48. package/types/view/node/PolygonNode.d.ts +1 -19
  49. package/types/view/node/RectNode.d.ts +0 -37
  50. package/types/view/node/TextNode.d.ts +1 -0
  51. package/types/view/overlay/BackgroundOverlay.d.ts +18 -29
  52. package/types/view/overlay/CanvasOverlay.d.ts +0 -2
  53. package/types/view/overlay/OutlineOverlay.d.ts +1 -1
  54. package/types/view/text/BaseText.d.ts +0 -2
@@ -1,14 +1,19 @@
1
1
  import { ModelType } from '../../constant/constant';
2
2
  import { Point } from '../../type';
3
3
  import BaseEdgeModel from './BaseEdgeModel';
4
- import GraphModel from '../GraphModel';
5
4
  export { PolylineEdgeModel };
6
5
  export default class PolylineEdgeModel extends BaseEdgeModel {
7
6
  modelType: ModelType;
8
- offset: number;
7
+ offset: any;
9
8
  draginngPointList: any;
10
9
  dbClickPosition: Point;
11
- constructor(data: any, graphModel: GraphModel);
10
+ initEdgeData(data: any): void;
11
+ getEdgeStyle(): {
12
+ [x: string]: any;
13
+ fill?: string;
14
+ stroke?: string;
15
+ strokeWidth?: number;
16
+ };
12
17
  getTextPosition(): {
13
18
  x: number;
14
19
  y: number;
@@ -1,76 +1,132 @@
1
- import { ElementState, ModelType, ElementType } from '../../constant/constant';
2
- import { AdditionData, NodeData, NodeAttribute, NodeConfig, NodeMoveRule, Bounds, Point, AnchorConfig } from '../../type';
1
+ import { OutlineTheme } from '../../constant/DefaultTheme';
2
+ import { ModelType, ElementType } from '../../constant/constant';
3
+ import { AdditionData, NodeData, NodeConfig, NodeMoveRule, Bounds, AnchorConfig, PointAnchor, AnchorsOffsetItem, ShapeStyleAttribute } from '../../type';
3
4
  import GraphModel from '../GraphModel';
4
5
  import { IBaseModel } from '../BaseModel';
5
6
  export declare type ConnectRule = {
6
7
  message: string;
7
- validate: (source: BaseNodeModel, target: BaseNodeModel, sourceAnchor: AnchorConfig, targetAnchor: AnchorConfig) => boolean;
8
+ validate: (source?: BaseNodeModel, target?: BaseNodeModel, sourceAnchor?: AnchorConfig, targetAnchor?: AnchorConfig) => boolean;
8
9
  };
9
10
  export declare type ConnectRuleResult = {
10
11
  isAllPass: boolean;
11
12
  msg?: string;
12
13
  };
14
+ interface IBaseNodeModel extends IBaseModel {
15
+ /**
16
+ * model基础类型,固定为node
17
+ */
18
+ readonly BaseType: ElementType.NODE;
19
+ }
13
20
  export { BaseNodeModel };
14
- export default class BaseNodeModel implements IBaseModel {
21
+ export default class BaseNodeModel implements IBaseNodeModel {
15
22
  id: string;
16
- readonly BaseType = ElementType.NODE;
17
- modelType: ModelType;
18
- additionStateData: AdditionData;
19
- [propName: string]: any;
20
- targetRules: ConnectRule[];
21
- sourceRules: ConnectRule[];
22
- moveRules: NodeMoveRule[];
23
- hasSetTargetRules: boolean;
24
- hasSetSourceRules: boolean;
25
- properties: Record<string, any>;
26
23
  type: string;
27
24
  x: number;
28
25
  y: number;
26
+ text: {
27
+ value: string;
28
+ x: number;
29
+ y: number;
30
+ draggable: boolean;
31
+ editable: boolean;
32
+ };
33
+ properties: Record<string, any>;
29
34
  private _width;
30
- graphModel: GraphModel;
31
35
  get width(): number;
32
36
  set width(value: number);
33
37
  private _height;
34
38
  get height(): number;
35
39
  set height(value: number);
36
- fill: string;
37
- fillOpacity: number;
38
- strokeWidth: number;
39
- stroke: string;
40
- strokeOpacity: number;
41
- opacity: number;
42
- outlineColor: string;
43
- hideOutline: boolean;
44
- hoverOutlineColor: string;
45
- outlineStrokeDashArray: string;
46
- hoverOutlineStrokeDashArray: string;
40
+ anchorsOffset: AnchorsOffsetItem[];
47
41
  isSelected: boolean;
48
42
  isHovered: boolean;
49
43
  isDragging: boolean;
50
44
  isHitable: boolean;
45
+ draggable: boolean;
46
+ graphModel: GraphModel;
51
47
  zIndex: number;
52
- anchorsOffset: any[];
53
48
  state: number;
54
- text: {
55
- value: string;
56
- x: number;
57
- y: number;
58
- draggable: boolean;
59
- editable: boolean;
60
- };
61
- draggable: boolean;
62
- constructor(data: NodeConfig, graphModel: GraphModel, type: any);
49
+ readonly BaseType = ElementType.NODE;
50
+ modelType: ModelType;
51
+ additionStateData: AdditionData;
52
+ targetRules: ConnectRule[];
53
+ sourceRules: ConnectRule[];
54
+ moveRules: NodeMoveRule[];
55
+ hasSetTargetRules: boolean;
56
+ hasSetSourceRules: boolean;
57
+ [propName: string]: any;
58
+ constructor(data: NodeConfig, graphModel: GraphModel);
59
+ /**
60
+ * @overridable 可以重写
61
+ * 初始化节点数据
62
+ * initNodeData和setAttributes的区别在于
63
+ * initNodeData只在节点初始化的时候调用,用于初始化节点的所有属性。
64
+ * setAttributes除了初始化调用外,还会在properties发生变化了调用。
65
+ */
63
66
  initNodeData(data: any): void;
64
- createId(): any;
65
- formatText(data: any): void;
67
+ /**
68
+ * 设置model属性,每次properties发生变化会触发
69
+ * 例如设置节点的宽度
70
+ * @example
71
+ *
72
+ * setAttributes () {
73
+ * this.width = 300
74
+ * this.height = 200
75
+ * }
76
+ *
77
+ * @overridable 支持重写
78
+ */
66
79
  setAttributes(): void;
67
80
  /**
68
- * 保存时获取的数据
81
+ * @overridable 支持重写,自定义此类型节点默认生成方式
82
+ * @returns string
83
+ */
84
+ createId(): string;
85
+ /**
86
+ * 初始化文本属性
87
+ */
88
+ private formatText;
89
+ /**
90
+ * 获取被保存时返回的数据
91
+ * @overridable 支持重写
69
92
  */
70
93
  getData(): NodeData;
94
+ /**
95
+ * 获取当前节点的properties
96
+ */
71
97
  getProperties(): Record<string, any>;
72
98
  /**
73
- * 在连线的时候,是否允许这个节点为source节点,连线到target节点。
99
+ * @overridable 支持重写
100
+ * 获取当前节点样式
101
+ * @returns 自定义节点样式
102
+ */
103
+ getNodeStyle(): ShapeStyleAttribute;
104
+ /**
105
+ * @overridable 支持重写
106
+ * 获取当前节点文本样式
107
+ */
108
+ getTextStyle(): import("../../constant/DefaultTheme").NodeTextTheme;
109
+ /**
110
+ * @overridable 支持重写
111
+ * 获取当前节点锚点样式
112
+ * @returns 自定义样式
113
+ */
114
+ getAnchorStyle(): Record<string, any>;
115
+ /**
116
+ * @overridable 支持重写
117
+ * 获取当前节点锚点拖出连线样式
118
+ * @returns 自定义锚点拖出样式
119
+ */
120
+ getAnchorLineStyle(): import("../../constant/DefaultTheme").CommonTheme;
121
+ /**
122
+ * @overridable 支持重写
123
+ * 获取outline样式,重写可以定义此类型节点outline样式, 默认使用主题样式
124
+ * @returns 自定义outline样式
125
+ */
126
+ getOutlineStyle(): OutlineTheme;
127
+ /**
128
+ * @over
129
+ * 在边的时候,是否允许这个节点为source节点,边到target节点。
74
130
  */
75
131
  isAllowConnectedAsSource(target: BaseNodeModel, soureAnchor: AnchorConfig, targetAnchor: AnchorConfig): ConnectRuleResult | Boolean;
76
132
  /**
@@ -78,20 +134,32 @@ export default class BaseNodeModel implements IBaseModel {
78
134
  */
79
135
  getConnectedSourceRules(): ConnectRule[];
80
136
  /**
81
- * 在连线的时候,是否允许这个节点未target节点
137
+ * 在连线的时候,是否允许这个节点为target节点
82
138
  */
83
139
  isAllowConnectedAsTarget(source: BaseNodeModel, soureAnchor: AnchorConfig, targetAnchor: AnchorConfig): ConnectRuleResult | Boolean;
84
140
  /**
141
+ * 内部方法
85
142
  * 是否允许移动节点到新的位置
86
143
  */
87
144
  isAllowMoveNode(deltaX: any, deltaY: any): boolean;
145
+ /**
146
+ * 获取作为连线终点时的所有规则。
147
+ */
88
148
  getConnectedTargetRules(): ConnectRule[];
89
- getAnchorsByOffset(): Point[];
90
149
  /**
91
- * 获取节点区域
150
+ * @overridable 子类重写此方法设置锚点
151
+ * @returns Point[] 锚点坐标构成的数组
152
+ */
153
+ getAnchorsByOffset(): PointAnchor[];
154
+ /**
155
+ * 获取节点默认情况下的锚点
156
+ */
157
+ getDetaultAnchor(): PointAnchor[];
158
+ /**
159
+ * 获取节点BBox
92
160
  */
93
161
  getBounds(): Bounds;
94
- get anchors(): Point[];
162
+ get anchors(): PointAnchor[];
95
163
  addNodeMoveRules(fn: NodeMoveRule): void;
96
164
  move(deltaX: any, deltaY: any, isignoreRule?: boolean): void;
97
165
  moveTo(x: any, y: any, isignoreRule?: boolean): void;
@@ -100,12 +168,9 @@ export default class BaseNodeModel implements IBaseModel {
100
168
  setSelected(flag?: boolean): void;
101
169
  setHovered(flag?: boolean): void;
102
170
  setHitable(flag?: boolean): void;
103
- setElementState(state: ElementState, additionStateData?: AdditionData): void;
104
- updateStroke(color: any): void;
105
- updateData(nodeAttribute: NodeAttribute): void;
171
+ setElementState(state: number, additionStateData?: AdditionData): void;
106
172
  setProperty(key: any, val: any): void;
107
173
  setProperties(properties: any): void;
108
- setStyleFromTheme(type: any, graphModel: any): void;
109
174
  setZIndex(zindex?: number): void;
110
175
  updateAttributes(attributes: any): void;
111
176
  }
@@ -1,14 +1,22 @@
1
- import { Point } from '../../type';
2
1
  import BaseNodeModel from './BaseNodeModel';
3
2
  import { ModelType } from '../../constant/constant';
4
- import GraphModel from '../GraphModel';
5
3
  declare class CircleNodeModel extends BaseNodeModel {
6
4
  modelType: ModelType;
7
5
  r: number;
8
- constructor(data: any, graphModel: GraphModel);
9
6
  get width(): number;
10
7
  get height(): number;
11
- get anchors(): Point[];
8
+ getNodeStyle(): {
9
+ [x: string]: any;
10
+ r?: number;
11
+ fill?: string;
12
+ stroke?: string;
13
+ strokeWidth?: number;
14
+ };
15
+ getDetaultAnchor(): {
16
+ x: number;
17
+ y: number;
18
+ id: string;
19
+ }[];
12
20
  }
13
21
  export { CircleNodeModel };
14
22
  export default CircleNodeModel;
@@ -1,13 +1,16 @@
1
- import { NodeData, Point, PointTuple } from '../../type';
1
+ import { Point, PointTuple } from '../../type';
2
2
  import BaseNodeModel from './BaseNodeModel';
3
3
  import { ModelType } from '../../constant/constant';
4
- import GraphModel from '../GraphModel';
5
4
  declare class DiamondNodeModel extends BaseNodeModel {
6
5
  modelType: ModelType;
7
6
  rx: number;
8
7
  ry: number;
9
- constructor(data: any, graphModel: GraphModel);
10
- getData(): NodeData;
8
+ getNodeStyle(): {
9
+ [x: string]: any;
10
+ fill?: string;
11
+ stroke?: string;
12
+ strokeWidth?: number;
13
+ };
11
14
  get points(): PointTuple[];
12
15
  get pointsPosition(): Point[];
13
16
  get width(): number;
@@ -1,12 +1,16 @@
1
1
  import { Point } from '../../type';
2
2
  import BaseNodeModel from './BaseNodeModel';
3
3
  import { ModelType } from '../../constant/constant';
4
- import GraphModel from '../GraphModel';
5
4
  declare class EllipseNodeModel extends BaseNodeModel {
6
5
  modelType: ModelType;
7
6
  rx: number;
8
7
  ry: number;
9
- constructor(data: any, graphModel: GraphModel);
8
+ getNodeStyle(): {
9
+ [x: string]: any;
10
+ fill?: string;
11
+ stroke?: string;
12
+ strokeWidth?: number;
13
+ };
10
14
  get width(): number;
11
15
  get height(): number;
12
16
  get anchors(): Point[];
@@ -1,10 +1,8 @@
1
1
  import { Point } from '../../type';
2
2
  import BaseNodeModel from './BaseNodeModel';
3
3
  import { ModelType } from '../../constant/constant';
4
- import GraphModel from '../GraphModel';
5
4
  declare class HtmlNodeModel extends BaseNodeModel {
6
5
  modelType: ModelType;
7
- constructor(data: any, graphModel: GraphModel);
8
6
  get anchors(): Point[];
9
7
  }
10
8
  export { HtmlNodeModel };
@@ -1,11 +1,20 @@
1
1
  import { Point, PointTuple } from '../../type';
2
2
  import BaseNodeModel from './BaseNodeModel';
3
3
  import { ModelType } from '../../constant/constant';
4
- import GraphModel from '../GraphModel';
5
4
  declare class PolygonNodeModel extends BaseNodeModel {
6
5
  modelType: ModelType;
7
6
  points: PointTuple[];
8
- constructor(data: any, graphModel: GraphModel);
7
+ getNodeStyle(): {
8
+ [x: string]: any;
9
+ fill?: string;
10
+ stroke?: string;
11
+ strokeWidth?: number;
12
+ };
13
+ /**
14
+ * 由于大多数情况下,我们初始化拿到的多边形坐标都是基于原点的(例如绘图工具到处的svg)。
15
+ * 在logicflow中对多边形进行移动,我们不需要去更新points,
16
+ * 而是去更新多边形中心点即可。
17
+ */
9
18
  get pointsPosition(): Point[];
10
19
  get width(): number;
11
20
  get height(): number;
@@ -1,12 +1,19 @@
1
1
  import { Point } from '../../type';
2
2
  import BaseNodeModel from './BaseNodeModel';
3
3
  import { ModelType } from '../../constant/constant';
4
- import GraphModel from '../GraphModel';
5
4
  declare class RectNodeModel extends BaseNodeModel {
6
5
  modelType: ModelType;
7
6
  radius: number;
8
- constructor(data: any, graphModel: GraphModel);
9
7
  get anchors(): Point[];
8
+ getNodeStyle(): {
9
+ [x: string]: any;
10
+ width?: number;
11
+ height?: number;
12
+ radius?: number;
13
+ fill?: string;
14
+ stroke?: string;
15
+ strokeWidth?: number;
16
+ };
10
17
  }
11
18
  export { RectNodeModel };
12
19
  export default RectNodeModel;
@@ -1,12 +1,16 @@
1
1
  import BaseNodeModel from './BaseNodeModel';
2
2
  import { ModelType } from '../../constant/constant';
3
- import GraphModel from '../GraphModel';
4
3
  declare class TextNodeModel extends BaseNodeModel {
5
4
  modelType: ModelType;
6
5
  fontSize: number;
7
- fontFamily: string;
8
- fontWeight: string;
9
- constructor(data: any, graphModel: GraphModel);
6
+ getNodeStyle(): {
7
+ [x: string]: any;
8
+ color?: string;
9
+ fontSize?: number;
10
+ fill?: string;
11
+ stroke?: string;
12
+ strokeWidth?: number;
13
+ };
10
14
  get width(): number;
11
15
  get height(): number;
12
16
  }
@@ -1,21 +1,22 @@
1
- import { DndOptions } from './view/behavior/DnD';
2
1
  import { GridOptions } from './view/overlay/Grid';
3
2
  import { BackgroundConfig } from './view/overlay/BackgroundOverlay';
4
- import { Style, NodeData, EdgeData, GraphConfigData } from './type';
3
+ import { NodeData, EdgeData, GraphConfigData } from './type';
5
4
  import { KeyboardDef } from './keyboard';
6
- import { EditConfigInterface } from './model/EditConfigModel';
5
+ import { EditConfigInterface } from './model/editConfigModel';
6
+ import { Theme } from './constant/DefaultTheme';
7
7
  export declare type EdgeType = 'line' | 'polyline' | 'bezier' | any;
8
8
  declare type DefaultOverlapMode = 0;
9
9
  declare type IncreaseOverlapMode = 1;
10
10
  /**
11
11
  * 元素重叠处理方式
12
- * 0:表示节点在上,连线在下,点击元素时选择元素显示在最顶部。
12
+ * 0:表示节点在上,边在下,点击元素时选择元素显示在最顶部。
13
13
  * 1:表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
14
14
  */
15
15
  export declare type OverlapMode = DefaultOverlapMode | IncreaseOverlapMode;
16
16
  export declare type Definition = {
17
17
  /**
18
18
  * 画布初始化容器
19
+ * 注意,在不传入width和height的情况下,container元素本身应该存在高度和高度。
19
20
  */
20
21
  container: HTMLElement;
21
22
  /**
@@ -34,18 +35,49 @@ export declare type Definition = {
34
35
  * 网格
35
36
  */
36
37
  grid?: boolean | GridOptions;
38
+ /**
39
+ * 键盘快捷操作
40
+ */
37
41
  keyboard?: KeyboardDef;
38
- style?: Style;
39
- dndOptions?: DndOptions;
42
+ /**
43
+ * 主题配置
44
+ */
45
+ style?: Theme;
46
+ /**
47
+ * 禁止初始化的插件名称
48
+ */
40
49
  disabledPlugins?: string[];
50
+ /**
51
+ * 默认边类型
52
+ */
41
53
  edgeType?: EdgeType;
54
+ /**
55
+ * 是否开启对齐线,默认开启
56
+ */
42
57
  snapline?: boolean;
58
+ /**
59
+ * 是否开启历史记录功能,默认开启
60
+ */
43
61
  history?: boolean;
62
+ /**
63
+ * 是否开启局部渲染,默认不开启
64
+ */
44
65
  partial?: boolean;
66
+ /**
67
+ * 删除和克隆之前的判断函数
68
+ * todo: 目前不完善,仅支持同步
69
+ */
45
70
  guards?: GuardsTypes;
46
- hideOutline?: boolean;
71
+ /**
72
+ * 表示节点在上,边在下,点击元素时选择元素显示在最顶部。
73
+ * 表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
74
+ */
47
75
  overlapMode?: OverlapMode;
48
- idGenerator?: () => number | string;
76
+ /**
77
+ * 自定义创建节点、连线时生成id规则。
78
+ * @param type 节点、连线类型
79
+ */
80
+ idGenerator?: (type?: string) => string;
49
81
  /**
50
82
  * 禁止启用的内置工具
51
83
  * 有些场景下,需要自定义多选效果或者文本编辑效果,则需要禁用这些内置的工具
@@ -53,6 +85,7 @@ export declare type Definition = {
53
85
  * todo: 将multipleSelect放到插件中
54
86
  */
55
87
  disabledTools?: string[];
88
+ [key: string]: any;
56
89
  } & EditConfigInterface;
57
90
  export interface GuardsTypes {
58
91
  beforeClone?: (data: NodeData | GraphConfigData) => boolean;
@@ -64,8 +97,10 @@ export declare function get(options: Definition): {
64
97
  textEdit: boolean;
65
98
  disabledTools: any[];
66
99
  } & {
100
+ [key: string]: any;
67
101
  /**
68
102
  * 画布初始化容器
103
+ * 注意,在不传入width和height的情况下,container元素本身应该存在高度和高度。
69
104
  */
70
105
  container: HTMLElement;
71
106
  /**
@@ -84,18 +119,49 @@ export declare function get(options: Definition): {
84
119
  * 网格
85
120
  */
86
121
  grid?: boolean | GridOptions;
122
+ /**
123
+ * 键盘快捷操作
124
+ */
87
125
  keyboard?: KeyboardDef;
88
- style?: Style;
89
- dndOptions?: DndOptions;
126
+ /**
127
+ * 主题配置
128
+ */
129
+ style?: Theme;
130
+ /**
131
+ * 禁止初始化的插件名称
132
+ */
90
133
  disabledPlugins?: string[];
134
+ /**
135
+ * 默认边类型
136
+ */
91
137
  edgeType?: any;
138
+ /**
139
+ * 是否开启对齐线,默认开启
140
+ */
92
141
  snapline?: boolean;
142
+ /**
143
+ * 是否开启历史记录功能,默认开启
144
+ */
93
145
  history?: boolean;
146
+ /**
147
+ * 是否开启局部渲染,默认不开启
148
+ */
94
149
  partial?: boolean;
150
+ /**
151
+ * 删除和克隆之前的判断函数
152
+ * todo: 目前不完善,仅支持同步
153
+ */
95
154
  guards?: GuardsTypes;
96
- hideOutline?: boolean;
155
+ /**
156
+ * 表示节点在上,边在下,点击元素时选择元素显示在最顶部。
157
+ * 表示安装元素创建顺序排序,点击元素也不会将其置顶。要置顶需要调用置顶API。
158
+ */
97
159
  overlapMode?: OverlapMode;
98
- idGenerator?: () => string | number;
160
+ /**
161
+ * 自定义创建节点、连线时生成id规则。
162
+ * @param type 节点、连线类型
163
+ */
164
+ idGenerator?: (type?: string) => string;
99
165
  /**
100
166
  * 禁止启用的内置工具
101
167
  * 有些场景下,需要自定义多选效果或者文本编辑效果,则需要禁用这些内置的工具
@@ -23,12 +23,34 @@ import EllipseNodeModel from '../model/node/EllipseNodeModel';
23
23
  import HtmlNode from '../view/node/HtmlNode';
24
24
  import HtmlNodeModel from '../model/node/HtmlNodeModel';
25
25
  import * as Options from '../options';
26
+ import { CommonTheme, EdgeTextTheme } from '../constant/DefaultTheme';
26
27
  export declare type PointTuple = [number, number];
27
28
  export declare type Point = {
28
29
  x: number;
29
30
  y: number;
30
31
  [key: string]: unknown;
31
32
  };
33
+ /**
34
+ * 锚点坐标
35
+ * 为了方便计算
36
+ * 锚点的位置都是相对于节点中心点的偏移量。
37
+ */
38
+ export declare type PointAnchor = {
39
+ /**
40
+ * 锚点x轴相对于中心点的偏移量
41
+ */
42
+ x: number;
43
+ /**
44
+ * 锚点y轴相对于中心点的偏移量
45
+ */
46
+ y: number;
47
+ /**
48
+ * 锚点Id
49
+ */
50
+ id?: string;
51
+ [key: string]: unknown;
52
+ };
53
+ export declare type AnchorsOffsetItem = PointTuple | PointAnchor;
32
54
  export declare type Size = {
33
55
  width: number;
34
56
  height: number;
@@ -103,7 +125,11 @@ export declare type EdgeFilter = {
103
125
  };
104
126
  export declare type EdgeConfig = {
105
127
  id?: string;
106
- type: string;
128
+ /**
129
+ * 边的类型,不传默认为lf.setDefaultEdgeType(type)传入的类型。
130
+ * LogicFlow内部默认为polyline
131
+ */
132
+ type?: string;
107
133
  sourceNodeId: string;
108
134
  sourceAnchorId?: string;
109
135
  targetNodeId: string;
@@ -143,9 +169,7 @@ export declare type CommonStyle = {
143
169
  strokeOpacity?: number;
144
170
  opacity?: number;
145
171
  outlineColor?: string;
146
- hoverOutlineColor?: string;
147
172
  outlineStrokeDashArray?: string;
148
- hoverOutlineStrokeDashArray?: string;
149
173
  };
150
174
  export declare type RectStyle = CommonStyle & {
151
175
  width?: number;
@@ -205,25 +229,10 @@ export declare type TextStyle = {
205
229
  fontFamily?: string;
206
230
  };
207
231
  export declare type NodeTextStyle = TextStyle & {
208
- autoWrap?: boolean;
209
- lineHeight?: number;
210
- wrapPadding?: string;
211
- };
212
- export declare type EdgeTextStyle = TextStyle & {
213
- background?: {
214
- fill?: string;
215
- stroke?: string;
216
- radius?: number;
217
- };
218
- hoverBackground?: {
219
- fill?: string;
220
- stroke?: string;
221
- radius?: number;
222
- };
223
- autoWrap?: boolean;
224
232
  lineHeight?: number;
225
233
  wrapPadding?: string;
226
234
  };
235
+ export declare type EdgeTextStyle = TextStyle & EdgeTextTheme;
227
236
  export declare type ArrowStyle = {
228
237
  offset?: number;
229
238
  verticalLength?: number;
@@ -233,24 +242,6 @@ export declare type EdgeAdjustStyle = {
233
242
  fill?: string;
234
243
  stroke?: string;
235
244
  };
236
- export declare type Style = {
237
- rect?: RectStyle;
238
- circle?: CircleStyle;
239
- ellipse?: EllipseStyle;
240
- diamond?: DiamondStyle;
241
- polygon?: PolygonStyle;
242
- anchor?: AnchorStyle;
243
- text?: TextStyle;
244
- nodeText?: NodeTextStyle;
245
- edgeText?: EdgeTextStyle;
246
- line?: LineStyle;
247
- polyline?: PolylineStyle;
248
- bezier?: BezierStyle;
249
- arrow?: ArrowStyle;
250
- anchorLine?: AnchorLineStyle;
251
- anchorHover?: AnchorHoverStyle;
252
- EdgeAdjustStyle?: EdgeAdjustStyle;
253
- };
254
245
  export declare type GraphTransform = {
255
246
  transform: string;
256
247
  transformOrigin: string;
@@ -353,4 +344,26 @@ export declare type AnchorConfig = {
353
344
  */
354
345
  export declare type NodeMoveRule = (model: BaseNodeModel, deltaX: number, deltaY: number) => Boolean;
355
346
  export declare type ZoomParam = boolean | number;
347
+ export declare type NodeAttributes = {
348
+ id: string;
349
+ properties: Record<string, any>;
350
+ type: string;
351
+ x: number;
352
+ y: number;
353
+ isSelected: boolean;
354
+ isHovered: boolean;
355
+ width: number;
356
+ height: number;
357
+ text: {
358
+ x: number;
359
+ y: number;
360
+ value: string;
361
+ [key: string]: any;
362
+ };
363
+ [key: string]: any;
364
+ };
365
+ export declare type DiamondAttributes = {
366
+ points: PointTuple[];
367
+ } & NodeAttributes;
368
+ export declare type ShapeStyleAttribute = CommonTheme;
356
369
  export {};