@logicflow/core 2.0.12 → 2.0.14
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/.turbo/turbo-build$colon$dev.log +2 -2
- package/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +12 -0
- package/__tests__/algorithm/index.test.ts +22 -17
- package/__tests__/algorithm/outline.test.ts +9 -9
- package/__tests__/event/event.test.ts +18 -18
- package/__tests__/history/history.test.ts +23 -23
- package/__tests__/logicflow.test.ts +236 -228
- package/__tests__/model/graphmodel.test.ts +51 -31
- package/__tests__/util/compatible.test.ts +5 -5
- package/__tests__/util/geometry.test.ts +10 -10
- package/__tests__/util/graph.test.ts +12 -12
- package/__tests__/util/matrix.test.ts +26 -26
- package/__tests__/util/node.test.ts +22 -22
- package/__tests__/util/sampling.test.ts +6 -10
- package/__tests__/util/vector.test.ts +36 -36
- package/__tests__/util/zIndex.test.ts +6 -6
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/LogicFlow.d.ts +29 -4
- package/es/LogicFlow.js +35 -6
- package/es/model/GraphModel.d.ts +35 -1
- package/es/model/GraphModel.js +45 -5
- package/es/model/node/RectNodeModel.js +3 -0
- package/es/options.d.ts +1 -0
- package/es/util/theme.d.ts +67 -2
- package/es/util/theme.js +189 -2
- package/es/view/Graph.d.ts +0 -3
- package/es/view/Graph.js +3 -7
- package/es/view/edge/BaseEdge.d.ts +4 -0
- package/es/view/edge/BaseEdge.js +45 -3
- package/es/view/overlay/Grid.js +3 -2
- package/es/view/overlay/ToolOverlay.d.ts +1 -3
- package/es/view/overlay/ToolOverlay.js +2 -39
- package/es/view/shape/Polygon.d.ts +8 -0
- package/es/view/shape/Polygon.js +50 -3
- package/lib/LogicFlow.d.ts +29 -4
- package/lib/LogicFlow.js +34 -5
- package/lib/model/GraphModel.d.ts +35 -1
- package/lib/model/GraphModel.js +43 -3
- package/lib/model/node/RectNodeModel.js +3 -0
- package/lib/options.d.ts +1 -0
- package/lib/util/theme.d.ts +67 -2
- package/lib/util/theme.js +192 -2
- package/lib/view/Graph.d.ts +0 -3
- package/lib/view/Graph.js +2 -6
- package/lib/view/edge/BaseEdge.d.ts +4 -0
- package/lib/view/edge/BaseEdge.js +45 -3
- package/lib/view/overlay/Grid.js +3 -2
- package/lib/view/overlay/ToolOverlay.d.ts +1 -3
- package/lib/view/overlay/ToolOverlay.js +2 -39
- package/lib/view/shape/Polygon.d.ts +8 -0
- package/lib/view/shape/Polygon.js +52 -4
- package/package.json +1 -1
- package/src/LogicFlow.tsx +57 -7
- package/src/model/GraphModel.ts +56 -3
- package/src/model/edge/index.ts +4 -4
- package/src/model/index.ts +7 -7
- package/src/model/node/RectNodeModel.ts +2 -1
- package/src/model/node/index.ts +8 -8
- package/src/options.ts +1 -0
- package/src/util/theme.ts +198 -3
- package/src/view/Graph.tsx +3 -15
- package/src/view/edge/BaseEdge.tsx +96 -12
- package/src/view/overlay/Grid.tsx +2 -1
- package/src/view/overlay/ToolOverlay.tsx +2 -17
- package/src/view/shape/Polygon.tsx +56 -4
- package/stats.html +1 -1
package/es/LogicFlow.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import History from './history';
|
|
|
8
8
|
import Keyboard from './keyboard';
|
|
9
9
|
import { EventCallback, CallbackArgs, EventArgs } from './event/eventEmitter';
|
|
10
10
|
import { EventType, SegmentDirection } from './constant';
|
|
11
|
+
import { Grid } from './view/overlay';
|
|
11
12
|
import Extension = LogicFlow.Extension;
|
|
12
13
|
import ExtensionConfig = LogicFlow.ExtensionConfig;
|
|
13
14
|
import ExtensionConstructor = LogicFlow.ExtensionConstructor;
|
|
@@ -263,6 +264,11 @@ export declare class LogicFlow {
|
|
|
263
264
|
* @param toFront 是否将选中的元素置顶,默认为true
|
|
264
265
|
*/
|
|
265
266
|
selectElementById(id: string, multiple?: boolean, toFront?: boolean): void;
|
|
267
|
+
/**
|
|
268
|
+
* 移除选中的元素
|
|
269
|
+
* @param id 元素ID
|
|
270
|
+
*/
|
|
271
|
+
deselectElementById(id: string): void;
|
|
266
272
|
/**
|
|
267
273
|
* 获取选中的元素数据
|
|
268
274
|
* @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
|
|
@@ -309,7 +315,7 @@ export declare class LogicFlow {
|
|
|
309
315
|
getAreaElement(leftTopPoint: PointTuple, rightBottomPoint: PointTuple, wholeEdge?: boolean, wholeNode?: boolean, ignoreHideElement?: boolean): (EdgeData | NodeData)[];
|
|
310
316
|
/**
|
|
311
317
|
* 设置元素的自定义属性
|
|
312
|
-
* @see
|
|
318
|
+
* @see http://logicflow.cn/api/detail#setproperties
|
|
313
319
|
* @param id 元素的id
|
|
314
320
|
* @param properties 自定义属性
|
|
315
321
|
*/
|
|
@@ -351,12 +357,12 @@ export declare class LogicFlow {
|
|
|
351
357
|
/**
|
|
352
358
|
* 更新流程图编辑相关设置
|
|
353
359
|
* @param {object} config 编辑配置
|
|
354
|
-
* @see
|
|
360
|
+
* @see http://logicflow.cn/api/detail#updateeditconfig
|
|
355
361
|
*/
|
|
356
362
|
updateEditConfig(config: Partial<IEditConfigType>): void;
|
|
357
363
|
/**
|
|
358
364
|
* 获取流程图当前编辑相关设置
|
|
359
|
-
* @see
|
|
365
|
+
* @see http://logicflow.cn/api/detail#geteditconfig
|
|
360
366
|
*/
|
|
361
367
|
getEditConfig(): _Model.IEditConfigType;
|
|
362
368
|
/*********************************************************
|
|
@@ -367,7 +373,12 @@ export declare class LogicFlow {
|
|
|
367
373
|
* @param { object } style 自定义主题样式
|
|
368
374
|
* todo docs link
|
|
369
375
|
*/
|
|
370
|
-
setTheme(style: Partial<LogicFlow.Theme
|
|
376
|
+
setTheme(style: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string): void;
|
|
377
|
+
/**
|
|
378
|
+
* 获取当前主题样式
|
|
379
|
+
* @see todo docs link
|
|
380
|
+
*/
|
|
381
|
+
getTheme(): LogicFlow.Theme;
|
|
371
382
|
private focusByElement;
|
|
372
383
|
private focusByCoordinate;
|
|
373
384
|
/**
|
|
@@ -563,6 +574,14 @@ export declare class LogicFlow {
|
|
|
563
574
|
* @param props
|
|
564
575
|
*/
|
|
565
576
|
static use(extension: ExtensionConstructor | ExtensionDefinition, props?: Record<string, unknown>): void;
|
|
577
|
+
/**
|
|
578
|
+
* 添加主题模式
|
|
579
|
+
* @param themeMode 主题模式
|
|
580
|
+
* @param style 主题样式
|
|
581
|
+
*/
|
|
582
|
+
static addThemeMode(themeMode: string, style: Partial<LogicFlow.Theme>): void;
|
|
583
|
+
static removeThemeMode(themeMode: string): void;
|
|
584
|
+
static clearThemeMode(): void;
|
|
566
585
|
private installPlugins;
|
|
567
586
|
/**
|
|
568
587
|
* 加载插件-内部方法
|
|
@@ -893,6 +912,10 @@ export declare namespace LogicFlow {
|
|
|
893
912
|
refX?: number;
|
|
894
913
|
refY?: number;
|
|
895
914
|
verticalLength: number;
|
|
915
|
+
endArrowType?: 'solid' | 'hollow' | 'diamond' | 'circle' | 'none';
|
|
916
|
+
startArrowType?: 'solid' | 'hollow' | 'diamond' | 'circle' | 'none';
|
|
917
|
+
strokeLinecap?: 'butt' | 'round' | 'square';
|
|
918
|
+
strokeLinejoin?: 'miter' | 'round' | 'bevel';
|
|
896
919
|
} & CommonTheme;
|
|
897
920
|
type ArrowAttributesType = {
|
|
898
921
|
d: string;
|
|
@@ -940,6 +963,8 @@ export declare namespace LogicFlow {
|
|
|
940
963
|
edgeAdjust: CircleTheme;
|
|
941
964
|
outline: OutlineTheme;
|
|
942
965
|
edgeAnimation: EdgeAnimation;
|
|
966
|
+
background?: boolean | Partial<LFOptions.BackgroundConfig>;
|
|
967
|
+
grid?: boolean | Partial<Grid.GridOptions>;
|
|
943
968
|
}
|
|
944
969
|
}
|
|
945
970
|
export declare namespace LogicFlow {
|
package/es/LogicFlow.js
CHANGED
|
@@ -43,7 +43,7 @@ import * as _Model from './model';
|
|
|
43
43
|
import { GraphModel, SnaplineModel, } from './model';
|
|
44
44
|
import Graph from './view/Graph';
|
|
45
45
|
import * as _View from './view';
|
|
46
|
-
import { formatData } from './util';
|
|
46
|
+
import { formatData, addThemeMode, removeThemeMode, clearThemeMode, } from './util';
|
|
47
47
|
import { Dnd, snapline } from './view/behavior';
|
|
48
48
|
import Tool from './tool';
|
|
49
49
|
import History from './history';
|
|
@@ -640,6 +640,13 @@ var LogicFlow = /** @class */ (function () {
|
|
|
640
640
|
this.graphModel.toFront(id);
|
|
641
641
|
}
|
|
642
642
|
};
|
|
643
|
+
/**
|
|
644
|
+
* 移除选中的元素
|
|
645
|
+
* @param id 元素ID
|
|
646
|
+
*/
|
|
647
|
+
LogicFlow.prototype.deselectElementById = function (id) {
|
|
648
|
+
this.graphModel.deselectElementById(id);
|
|
649
|
+
};
|
|
643
650
|
/**
|
|
644
651
|
* 获取选中的元素数据
|
|
645
652
|
* @param isIgnoreCheck 是否包括sourceNode和targetNode没有被选中的边,默认包括。
|
|
@@ -716,7 +723,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
716
723
|
};
|
|
717
724
|
/**
|
|
718
725
|
* 设置元素的自定义属性
|
|
719
|
-
* @see
|
|
726
|
+
* @see http://logicflow.cn/api/detail#setproperties
|
|
720
727
|
* @param id 元素的id
|
|
721
728
|
* @param properties 自定义属性
|
|
722
729
|
*/
|
|
@@ -773,7 +780,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
773
780
|
/**
|
|
774
781
|
* 更新流程图编辑相关设置
|
|
775
782
|
* @param {object} config 编辑配置
|
|
776
|
-
* @see
|
|
783
|
+
* @see http://logicflow.cn/api/detail#updateeditconfig
|
|
777
784
|
*/
|
|
778
785
|
LogicFlow.prototype.updateEditConfig = function (config) {
|
|
779
786
|
var _a = this.graphModel, editConfigModel = _a.editConfigModel, transformModel = _a.transformModel;
|
|
@@ -792,7 +799,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
792
799
|
};
|
|
793
800
|
/**
|
|
794
801
|
* 获取流程图当前编辑相关设置
|
|
795
|
-
* @see
|
|
802
|
+
* @see http://logicflow.cn/api/detail#geteditconfig
|
|
796
803
|
*/
|
|
797
804
|
LogicFlow.prototype.getEditConfig = function () {
|
|
798
805
|
return this.graphModel.editConfigModel.getConfig();
|
|
@@ -805,8 +812,15 @@ var LogicFlow = /** @class */ (function () {
|
|
|
805
812
|
* @param { object } style 自定义主题样式
|
|
806
813
|
* todo docs link
|
|
807
814
|
*/
|
|
808
|
-
LogicFlow.prototype.setTheme = function (style) {
|
|
809
|
-
this.graphModel.setTheme(style);
|
|
815
|
+
LogicFlow.prototype.setTheme = function (style, themeMode) {
|
|
816
|
+
this.graphModel.setTheme(style, themeMode);
|
|
817
|
+
};
|
|
818
|
+
/**
|
|
819
|
+
* 获取当前主题样式
|
|
820
|
+
* @see todo docs link
|
|
821
|
+
*/
|
|
822
|
+
LogicFlow.prototype.getTheme = function () {
|
|
823
|
+
return this.graphModel.getTheme();
|
|
810
824
|
};
|
|
811
825
|
LogicFlow.prototype.focusByElement = function (id) {
|
|
812
826
|
var coordinate = undefined;
|
|
@@ -1121,6 +1135,20 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1121
1135
|
_a.props = props,
|
|
1122
1136
|
_a));
|
|
1123
1137
|
};
|
|
1138
|
+
/**
|
|
1139
|
+
* 添加主题模式
|
|
1140
|
+
* @param themeMode 主题模式
|
|
1141
|
+
* @param style 主题样式
|
|
1142
|
+
*/
|
|
1143
|
+
LogicFlow.addThemeMode = function (themeMode, style) {
|
|
1144
|
+
addThemeMode(themeMode, style);
|
|
1145
|
+
};
|
|
1146
|
+
LogicFlow.removeThemeMode = function (themeMode) {
|
|
1147
|
+
removeThemeMode(themeMode);
|
|
1148
|
+
};
|
|
1149
|
+
LogicFlow.clearThemeMode = function () {
|
|
1150
|
+
clearThemeMode();
|
|
1151
|
+
};
|
|
1124
1152
|
LogicFlow.prototype.installPlugins = function (disabledPlugins) {
|
|
1125
1153
|
var _this = this;
|
|
1126
1154
|
if (disabledPlugins === void 0) { disabledPlugins = []; }
|
|
@@ -1183,6 +1211,7 @@ var LogicFlow = /** @class */ (function () {
|
|
|
1183
1211
|
this.graphModel.destroy();
|
|
1184
1212
|
this.tool.destroy();
|
|
1185
1213
|
this.history.destroy();
|
|
1214
|
+
this.clearThemeMode();
|
|
1186
1215
|
for (var extensionName in this.extension) {
|
|
1187
1216
|
var extensionInstance = this.extension[extensionName];
|
|
1188
1217
|
if ('destroy' in extensionInstance) {
|
package/es/model/GraphModel.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class GraphModel {
|
|
|
17
17
|
width: number;
|
|
18
18
|
height: number;
|
|
19
19
|
theme: LogicFlow.Theme;
|
|
20
|
+
customStyles: object;
|
|
20
21
|
grid: Grid.GridOptions;
|
|
21
22
|
readonly eventCenter: EventEmitter;
|
|
22
23
|
readonly modelMap: Map<string, LogicFlow.GraphElementCtor>;
|
|
@@ -322,6 +323,7 @@ export declare class GraphModel {
|
|
|
322
323
|
* @param multiple 是否允许多选,如果为true,不会将上一个选中的元素重置
|
|
323
324
|
*/
|
|
324
325
|
selectElementById(id: string, multiple?: boolean): void;
|
|
326
|
+
deselectElementById(id: string): void;
|
|
325
327
|
/**
|
|
326
328
|
* 将所有选中的元素设置为非选中
|
|
327
329
|
*/
|
|
@@ -393,7 +395,39 @@ export declare class GraphModel {
|
|
|
393
395
|
* 设置主题
|
|
394
396
|
* todo docs link
|
|
395
397
|
*/
|
|
396
|
-
setTheme(style: Partial<LogicFlow.Theme
|
|
398
|
+
setTheme(style: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string): void;
|
|
399
|
+
/**
|
|
400
|
+
* 设置主题
|
|
401
|
+
* todo docs link
|
|
402
|
+
*/
|
|
403
|
+
getTheme(): {
|
|
404
|
+
background: boolean | LFOptions.BackgroundConfig | undefined;
|
|
405
|
+
grid: Grid.GridOptions;
|
|
406
|
+
baseNode: LogicFlow.CommonTheme;
|
|
407
|
+
baseEdge: LogicFlow.CommonTheme;
|
|
408
|
+
rect: LogicFlow.CommonTheme;
|
|
409
|
+
circle: LogicFlow.CommonTheme;
|
|
410
|
+
diamond: LogicFlow.CommonTheme;
|
|
411
|
+
ellipse: LogicFlow.CommonTheme;
|
|
412
|
+
polygon: LogicFlow.CommonTheme;
|
|
413
|
+
line: LogicFlow.CommonTheme;
|
|
414
|
+
polyline: LogicFlow.CommonTheme;
|
|
415
|
+
bezier: LogicFlow.EdgeBezierTheme;
|
|
416
|
+
anchorLine: LogicFlow.AnchorLineTheme;
|
|
417
|
+
text: LogicFlow.TextNodeTheme;
|
|
418
|
+
nodeText: LogicFlow.NodeTextTheme;
|
|
419
|
+
edgeText: LogicFlow.EdgeTextTheme;
|
|
420
|
+
inputText?: LogicFlow.CommonTheme | undefined;
|
|
421
|
+
anchor: LogicFlow.AnchorTheme;
|
|
422
|
+
arrow: LogicFlow.ArrowTheme;
|
|
423
|
+
snapline: LogicFlow.CommonTheme;
|
|
424
|
+
rotateControl: LogicFlow.CommonTheme;
|
|
425
|
+
resizeControl: LogicFlow.CommonTheme;
|
|
426
|
+
resizeOutline: LogicFlow.CommonTheme;
|
|
427
|
+
edgeAdjust: LogicFlow.CommonTheme;
|
|
428
|
+
outline: LogicFlow.OutlineTheme;
|
|
429
|
+
edgeAnimation: LogicFlow.EdgeAnimation;
|
|
430
|
+
};
|
|
397
431
|
/**
|
|
398
432
|
* 更新网格配置
|
|
399
433
|
*/
|
package/es/model/GraphModel.js
CHANGED
|
@@ -51,11 +51,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
51
51
|
}
|
|
52
52
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
53
53
|
};
|
|
54
|
-
import { find, forEach, map, merge, isBoolean, debounce, isNil, } from 'lodash-es';
|
|
54
|
+
import { find, forEach, map, merge, isBoolean, debounce, cloneDeep, isNil, } from 'lodash-es';
|
|
55
55
|
import { action, computed, observable } from 'mobx';
|
|
56
56
|
import { EditConfigModel, TransformModel, } from '.';
|
|
57
57
|
import { DEFAULT_VISIBLE_SPACE, ELEMENT_MAX_Z_INDEX, ElementState, ElementType, EventType, ModelType, OverlapMode, TextMode, } from '../constant';
|
|
58
|
-
import { createEdgeGenerator, createUuid, formatData, getClosestPointOfPolyline, getMinIndex, getNodeAnchorPosition, getNodeBBox, getZIndex, isPointInArea, setupAnimation, setupTheme, snapToGrid, updateTheme, } from '../util';
|
|
58
|
+
import { createEdgeGenerator, createUuid, formatData, getClosestPointOfPolyline, getMinIndex, getNodeAnchorPosition, getNodeBBox, getZIndex, isPointInArea, setupAnimation, setupTheme, snapToGrid, updateTheme, backgroundModeMap, gridModeMap, } from '../util';
|
|
59
59
|
import EventEmitter from '../event/eventEmitter';
|
|
60
60
|
import { Grid } from '../view/overlay';
|
|
61
61
|
var GraphModel = /** @class */ (function () {
|
|
@@ -104,8 +104,11 @@ var GraphModel = /** @class */ (function () {
|
|
|
104
104
|
// TODO:需要让用户设置成 0 吗?后面可以讨论一下
|
|
105
105
|
this.gridSize = grid.size || 1; // 默认 gridSize 设置为 1
|
|
106
106
|
}
|
|
107
|
-
this.
|
|
107
|
+
this.customStyles = options.style || {};
|
|
108
108
|
this.grid = Grid.getGridOptions(grid !== null && grid !== void 0 ? grid : false);
|
|
109
|
+
this.theme = setupTheme(options.style, options.themeMode);
|
|
110
|
+
this.theme.grid = cloneDeep(this.grid);
|
|
111
|
+
this.theme.background = cloneDeep(this.background);
|
|
109
112
|
this.edgeType = options.edgeType || 'polyline';
|
|
110
113
|
this.animation = setupAnimation(animation);
|
|
111
114
|
this.overlapMode = options.overlapMode || OverlapMode.DEFAULT;
|
|
@@ -1054,6 +1057,12 @@ var GraphModel = /** @class */ (function () {
|
|
|
1054
1057
|
var selectElement = this.getElement(id);
|
|
1055
1058
|
selectElement === null || selectElement === void 0 ? void 0 : selectElement.setSelected(true);
|
|
1056
1059
|
};
|
|
1060
|
+
GraphModel.prototype.deselectElementById = function (id) {
|
|
1061
|
+
var element = this.getElement(id);
|
|
1062
|
+
if (element) {
|
|
1063
|
+
element.setSelected(false);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1057
1066
|
/**
|
|
1058
1067
|
* 将所有选中的元素设置为非选中
|
|
1059
1068
|
*/
|
|
@@ -1292,8 +1301,33 @@ var GraphModel = /** @class */ (function () {
|
|
|
1292
1301
|
* 设置主题
|
|
1293
1302
|
* todo docs link
|
|
1294
1303
|
*/
|
|
1295
|
-
GraphModel.prototype.setTheme = function (style) {
|
|
1296
|
-
|
|
1304
|
+
GraphModel.prototype.setTheme = function (style, themeMode) {
|
|
1305
|
+
var _a;
|
|
1306
|
+
if (themeMode) {
|
|
1307
|
+
// 修改背景颜色
|
|
1308
|
+
backgroundModeMap[themeMode] &&
|
|
1309
|
+
this.updateBackgroundOptions(__assign(__assign({}, (typeof this.background === 'object' ? this.background : {})), backgroundModeMap[themeMode]));
|
|
1310
|
+
gridModeMap[themeMode] &&
|
|
1311
|
+
this.updateGridOptions(Grid.getGridOptions(__assign(__assign({}, this.grid), gridModeMap[themeMode])));
|
|
1312
|
+
}
|
|
1313
|
+
if (style.background) {
|
|
1314
|
+
this.updateBackgroundOptions(style.background);
|
|
1315
|
+
}
|
|
1316
|
+
if (style.grid) {
|
|
1317
|
+
var formattedGrid = Grid.getGridOptions((_a = style.grid) !== null && _a !== void 0 ? _a : false);
|
|
1318
|
+
this.updateGridOptions(formattedGrid);
|
|
1319
|
+
}
|
|
1320
|
+
this.theme = updateTheme(__assign(__assign({}, this.customStyles), style), themeMode);
|
|
1321
|
+
this.customStyles = __assign(__assign({}, this.customStyles), style);
|
|
1322
|
+
};
|
|
1323
|
+
/**
|
|
1324
|
+
* 设置主题
|
|
1325
|
+
* todo docs link
|
|
1326
|
+
*/
|
|
1327
|
+
GraphModel.prototype.getTheme = function () {
|
|
1328
|
+
var _a = this, background = _a.background, grid = _a.grid;
|
|
1329
|
+
var theme = __assign(__assign({}, cloneDeep(this.theme)), { background: background, grid: grid });
|
|
1330
|
+
return theme;
|
|
1297
1331
|
};
|
|
1298
1332
|
/**
|
|
1299
1333
|
* 更新网格配置
|
|
@@ -1590,6 +1624,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
1590
1624
|
__decorate([
|
|
1591
1625
|
action
|
|
1592
1626
|
], GraphModel.prototype, "selectElementById", null);
|
|
1627
|
+
__decorate([
|
|
1628
|
+
action
|
|
1629
|
+
], GraphModel.prototype, "deselectElementById", null);
|
|
1593
1630
|
__decorate([
|
|
1594
1631
|
action
|
|
1595
1632
|
], GraphModel.prototype, "clearSelectElements", null);
|
|
@@ -1626,6 +1663,9 @@ var GraphModel = /** @class */ (function () {
|
|
|
1626
1663
|
__decorate([
|
|
1627
1664
|
action
|
|
1628
1665
|
], GraphModel.prototype, "setTheme", null);
|
|
1666
|
+
__decorate([
|
|
1667
|
+
action
|
|
1668
|
+
], GraphModel.prototype, "getTheme", null);
|
|
1629
1669
|
__decorate([
|
|
1630
1670
|
action
|
|
1631
1671
|
], GraphModel.prototype, "resize", null);
|
|
@@ -51,6 +51,7 @@ var RectNodeModel = /** @class */ (function (_super) {
|
|
|
51
51
|
RectNodeModel.prototype.setAttributes = function () {
|
|
52
52
|
_super.prototype.setAttributes.call(this);
|
|
53
53
|
var _a = this.properties, width = _a.width, height = _a.height, radius = _a.radius;
|
|
54
|
+
var styleRadius = this.getNodeStyle().radius;
|
|
54
55
|
if (!isNil(width))
|
|
55
56
|
this.width = width;
|
|
56
57
|
if (!isNil(height))
|
|
@@ -58,6 +59,8 @@ var RectNodeModel = /** @class */ (function (_super) {
|
|
|
58
59
|
// 矩形特有
|
|
59
60
|
if (!isNil(radius))
|
|
60
61
|
this.radius = radius;
|
|
62
|
+
if (!isNil(styleRadius))
|
|
63
|
+
this.radius = styleRadius;
|
|
61
64
|
};
|
|
62
65
|
RectNodeModel.prototype.getDefaultAnchor = function () {
|
|
63
66
|
var _a = this, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
package/es/options.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export declare namespace Options {
|
|
|
66
66
|
idGenerator?: (type?: string) => string;
|
|
67
67
|
edgeGenerator?: EdgeGeneratorType;
|
|
68
68
|
customTrajectory?: (props: CustomAnchorLineProps) => h.JSX.Element;
|
|
69
|
+
themeMode?: 'radius' | 'dark' | 'colorful';
|
|
69
70
|
[key: string]: unknown;
|
|
70
71
|
}
|
|
71
72
|
interface ManualBooleans {
|
package/es/util/theme.d.ts
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
1
|
import LogicFlow from '../LogicFlow';
|
|
2
2
|
export declare const defaultTheme: LogicFlow.Theme;
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const radiusMode: any;
|
|
4
|
+
export declare const darkMode: any;
|
|
5
|
+
export declare const colorfulMode: any;
|
|
6
|
+
export declare const themeModeMap: {
|
|
7
|
+
colorful: any;
|
|
8
|
+
dark: any;
|
|
9
|
+
radius: any;
|
|
10
|
+
default: LogicFlow.Theme;
|
|
11
|
+
};
|
|
12
|
+
export declare const darkBackground: {
|
|
13
|
+
background: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const colorfulBackground: {
|
|
16
|
+
background: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const defaultBackground: {
|
|
19
|
+
background: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const backgroundModeMap: {
|
|
22
|
+
colorful: {
|
|
23
|
+
background: string;
|
|
24
|
+
};
|
|
25
|
+
dark: {
|
|
26
|
+
background: string;
|
|
27
|
+
};
|
|
28
|
+
radius: {
|
|
29
|
+
background: string;
|
|
30
|
+
};
|
|
31
|
+
default: {
|
|
32
|
+
background: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const darkGrid: {
|
|
36
|
+
color: string;
|
|
37
|
+
thickness: number;
|
|
38
|
+
};
|
|
39
|
+
export declare const colorfulGrid: {
|
|
40
|
+
color: string;
|
|
41
|
+
thickness: number;
|
|
42
|
+
};
|
|
43
|
+
export declare const defaultGrid: {
|
|
44
|
+
color: string;
|
|
45
|
+
thickness: number;
|
|
46
|
+
};
|
|
47
|
+
export declare const gridModeMap: {
|
|
48
|
+
colorful: {
|
|
49
|
+
color: string;
|
|
50
|
+
thickness: number;
|
|
51
|
+
};
|
|
52
|
+
dark: {
|
|
53
|
+
color: string;
|
|
54
|
+
thickness: number;
|
|
55
|
+
};
|
|
56
|
+
radius: {
|
|
57
|
+
color: string;
|
|
58
|
+
thickness: number;
|
|
59
|
+
};
|
|
60
|
+
default: {
|
|
61
|
+
color: string;
|
|
62
|
+
thickness: number;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export declare const setupTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string) => LogicFlow.Theme;
|
|
66
|
+
export declare const addThemeMode: (themeMode: string, style: Partial<LogicFlow.Theme>) => void;
|
|
67
|
+
export declare const removeThemeMode: (themeMode: string) => void;
|
|
68
|
+
export declare const clearThemeMode: () => void;
|
|
69
|
+
export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string) => LogicFlow.Theme;
|
package/es/util/theme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cloneDeep, merge } from 'lodash-es';
|
|
1
|
+
import { cloneDeep, merge, assign } from 'lodash-es';
|
|
2
2
|
export var defaultTheme = {
|
|
3
3
|
baseNode: {
|
|
4
4
|
fill: '#fff',
|
|
@@ -116,9 +116,171 @@ export var defaultTheme = {
|
|
|
116
116
|
strokeDasharray: '3,3',
|
|
117
117
|
},
|
|
118
118
|
};
|
|
119
|
+
export var radiusMode = {
|
|
120
|
+
rect: { radius: 8 },
|
|
121
|
+
diamond: { radius: 8 },
|
|
122
|
+
polygon: { radius: 8 },
|
|
123
|
+
polyline: { radius: 8 },
|
|
124
|
+
arrow: {
|
|
125
|
+
strokeLinecap: 'round',
|
|
126
|
+
strokeLinejoin: 'round',
|
|
127
|
+
offset: 10,
|
|
128
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
129
|
+
},
|
|
130
|
+
snapline: {
|
|
131
|
+
strokeLinecap: 'round',
|
|
132
|
+
strokeLinejoin: 'round',
|
|
133
|
+
stroke: '#949494',
|
|
134
|
+
strokeWidth: 1,
|
|
135
|
+
},
|
|
136
|
+
outline: {
|
|
137
|
+
radius: 8,
|
|
138
|
+
fill: 'transparent',
|
|
139
|
+
stroke: '#949494',
|
|
140
|
+
strokeDasharray: '3,3',
|
|
141
|
+
hover: {
|
|
142
|
+
stroke: '#949494',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
resizeOutline: {
|
|
146
|
+
radius: 8,
|
|
147
|
+
fill: 'none',
|
|
148
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
149
|
+
strokeWidth: 1,
|
|
150
|
+
strokeDasharray: '3,3',
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
export var darkMode = {
|
|
154
|
+
baseNode: {
|
|
155
|
+
fill: '#23272e',
|
|
156
|
+
stroke: '#fefeff',
|
|
157
|
+
},
|
|
158
|
+
baseEdge: {
|
|
159
|
+
stroke: '#fefeff',
|
|
160
|
+
},
|
|
161
|
+
rect: { radius: 8 },
|
|
162
|
+
diamond: { radius: 8 },
|
|
163
|
+
polygon: { radius: 8 },
|
|
164
|
+
polyline: { radius: 8 },
|
|
165
|
+
nodeText: {
|
|
166
|
+
color: '#fefeff',
|
|
167
|
+
overflowMode: 'default',
|
|
168
|
+
fontSize: 12,
|
|
169
|
+
lineHeight: 1.2,
|
|
170
|
+
},
|
|
171
|
+
arrow: {
|
|
172
|
+
strokeLinecap: 'round',
|
|
173
|
+
strokeLinejoin: 'round',
|
|
174
|
+
offset: 10,
|
|
175
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
176
|
+
},
|
|
177
|
+
snapline: {
|
|
178
|
+
strokeLinecap: 'round',
|
|
179
|
+
strokeLinejoin: 'round',
|
|
180
|
+
stroke: '#949494',
|
|
181
|
+
strokeWidth: 1,
|
|
182
|
+
},
|
|
183
|
+
outline: {
|
|
184
|
+
radius: 8,
|
|
185
|
+
fill: 'transparent',
|
|
186
|
+
stroke: '#949494',
|
|
187
|
+
strokeDasharray: '3,3',
|
|
188
|
+
hover: {
|
|
189
|
+
stroke: '#949494',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
resizeOutline: {
|
|
193
|
+
radius: 8,
|
|
194
|
+
fill: 'none',
|
|
195
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
196
|
+
strokeWidth: 1,
|
|
197
|
+
strokeDasharray: '3,3',
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
export var colorfulMode = {
|
|
201
|
+
rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
|
|
202
|
+
circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
|
|
203
|
+
ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
|
|
204
|
+
text: { fill: '#72CBFF', radius: 8 },
|
|
205
|
+
diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
|
|
206
|
+
polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
|
|
207
|
+
polyline: { radius: 8 },
|
|
208
|
+
arrow: {
|
|
209
|
+
strokeLinecap: 'round',
|
|
210
|
+
strokeLinejoin: 'round',
|
|
211
|
+
offset: 10,
|
|
212
|
+
verticalLength: 5, // 箭头垂直于边的距离
|
|
213
|
+
},
|
|
214
|
+
snapline: {
|
|
215
|
+
strokeLinecap: 'round',
|
|
216
|
+
strokeLinejoin: 'round',
|
|
217
|
+
stroke: '#949494',
|
|
218
|
+
strokeWidth: 1,
|
|
219
|
+
},
|
|
220
|
+
outline: {
|
|
221
|
+
radius: 8,
|
|
222
|
+
fill: 'transparent',
|
|
223
|
+
stroke: '#949494',
|
|
224
|
+
strokeDasharray: '3,3',
|
|
225
|
+
hover: {
|
|
226
|
+
stroke: '#949494',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
resizeOutline: {
|
|
230
|
+
radius: 8,
|
|
231
|
+
fill: 'none',
|
|
232
|
+
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
233
|
+
strokeWidth: 1,
|
|
234
|
+
strokeDasharray: '3,3',
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
export var themeModeMap = {
|
|
238
|
+
colorful: colorfulMode,
|
|
239
|
+
dark: darkMode,
|
|
240
|
+
radius: radiusMode,
|
|
241
|
+
default: defaultTheme,
|
|
242
|
+
};
|
|
243
|
+
// 不同主题的背景色
|
|
244
|
+
export var darkBackground = {
|
|
245
|
+
background: '#23272e',
|
|
246
|
+
};
|
|
247
|
+
export var colorfulBackground = {
|
|
248
|
+
background: '#fefeff',
|
|
249
|
+
};
|
|
250
|
+
export var defaultBackground = {
|
|
251
|
+
background: '#ffffff',
|
|
252
|
+
};
|
|
253
|
+
export var backgroundModeMap = {
|
|
254
|
+
colorful: colorfulBackground,
|
|
255
|
+
dark: darkBackground,
|
|
256
|
+
radius: defaultBackground,
|
|
257
|
+
default: defaultBackground,
|
|
258
|
+
};
|
|
259
|
+
// 不同主题的网格样式
|
|
260
|
+
export var darkGrid = {
|
|
261
|
+
color: '#66676a',
|
|
262
|
+
thickness: 1,
|
|
263
|
+
};
|
|
264
|
+
export var colorfulGrid = {
|
|
265
|
+
color: '#dadada',
|
|
266
|
+
thickness: 1,
|
|
267
|
+
};
|
|
268
|
+
export var defaultGrid = {
|
|
269
|
+
color: '#acacac',
|
|
270
|
+
thickness: 1,
|
|
271
|
+
};
|
|
272
|
+
export var gridModeMap = {
|
|
273
|
+
colorful: colorfulGrid,
|
|
274
|
+
dark: darkGrid,
|
|
275
|
+
radius: defaultGrid,
|
|
276
|
+
default: defaultGrid,
|
|
277
|
+
};
|
|
119
278
|
/* 主题(全局样式)相关工具方法 */
|
|
120
|
-
export var setupTheme = function (customTheme) {
|
|
279
|
+
export var setupTheme = function (customTheme, themeMode) {
|
|
121
280
|
var theme = cloneDeep(defaultTheme);
|
|
281
|
+
if (themeMode) {
|
|
282
|
+
theme = merge(theme, themeModeMap[themeMode]);
|
|
283
|
+
}
|
|
122
284
|
if (customTheme) {
|
|
123
285
|
/**
|
|
124
286
|
* 为了不让默认样式被覆盖,使用 merge 方法
|
|
@@ -151,5 +313,30 @@ export var setupTheme = function (customTheme) {
|
|
|
151
313
|
}
|
|
152
314
|
return theme;
|
|
153
315
|
};
|
|
316
|
+
export var addThemeMode = function (themeMode, style) {
|
|
317
|
+
if (themeModeMap[themeMode]) {
|
|
318
|
+
console.warn("theme mode ".concat(themeMode, " already exists"));
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
themeModeMap[themeMode] = style;
|
|
322
|
+
backgroundModeMap[themeMode] = style.background || defaultBackground;
|
|
323
|
+
gridModeMap[themeMode] = style.grid || defaultGrid;
|
|
324
|
+
};
|
|
325
|
+
export var removeThemeMode = function (themeMode) {
|
|
326
|
+
delete themeModeMap[themeMode];
|
|
327
|
+
delete backgroundModeMap[themeMode];
|
|
328
|
+
delete gridModeMap[themeMode];
|
|
329
|
+
};
|
|
330
|
+
export var clearThemeMode = function () {
|
|
331
|
+
var resetTheme = {
|
|
332
|
+
colorful: {},
|
|
333
|
+
dark: {},
|
|
334
|
+
radius: {},
|
|
335
|
+
default: {},
|
|
336
|
+
};
|
|
337
|
+
assign(themeModeMap, resetTheme);
|
|
338
|
+
assign(backgroundModeMap, resetTheme);
|
|
339
|
+
assign(gridModeMap, resetTheme);
|
|
340
|
+
};
|
|
154
341
|
/* 更新 theme 方法 */
|
|
155
342
|
export var updateTheme = setupTheme;
|
package/es/view/Graph.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, ComponentType } from 'preact/compat';
|
|
2
|
-
import { CanvasOverlay } from './overlay';
|
|
3
2
|
import DnD from './behavior/dnd';
|
|
4
3
|
import Tool from '../tool';
|
|
5
4
|
import { Options as LFOptions } from '../options';
|
|
@@ -13,8 +12,6 @@ type IGraphProps = {
|
|
|
13
12
|
graphModel: GraphModel;
|
|
14
13
|
};
|
|
15
14
|
declare class Graph extends Component<IGraphProps> {
|
|
16
|
-
canvasOverlayRef: import("preact").RefObject<CanvasOverlay>;
|
|
17
|
-
getCanvasOverlay: () => CanvasOverlay | null;
|
|
18
15
|
private handleResize;
|
|
19
16
|
private throttleResize;
|
|
20
17
|
componentDidMount(): void;
|