@logicflow/extension 2.1.5 → 2.1.7
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.log +7 -7
- package/CHANGELOG.md +20 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/components/mini-map/index.js +1 -6
- package/es/components/selection-select/index.d.ts +1 -0
- package/es/components/selection-select/index.js +11 -5
- package/es/tools/label/LabelOverlay.js +3 -3
- package/es/tools/label/mediumEditor.d.ts +1 -1
- package/es/tools/label/mediumEditor.js +89 -52
- package/lib/components/mini-map/index.js +1 -6
- package/lib/components/selection-select/index.d.ts +1 -0
- package/lib/components/selection-select/index.js +11 -5
- package/lib/tools/label/LabelOverlay.js +2 -2
- package/lib/tools/label/mediumEditor.d.ts +1 -1
- package/lib/tools/label/mediumEditor.js +91 -53
- package/package.json +5 -5
- package/src/components/mini-map/index.ts +1 -10
- package/src/components/selection-select/index.ts +11 -8
- package/src/tools/label/LabelOverlay.tsx +7 -3
- package/src/tools/label/mediumEditor.ts +78 -51
- package/stats.html +1 -1
|
@@ -9,7 +9,6 @@ var __values = (this && this.__values) || function(o) {
|
|
|
9
9
|
};
|
|
10
10
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
11
|
};
|
|
12
|
-
import { createTeleportContainer, destroyTeleportContainer, } from '@logicflow/vue-node-registry';
|
|
13
12
|
var MiniMap = /** @class */ (function () {
|
|
14
13
|
function MiniMap(_a) {
|
|
15
14
|
var lf = _a.lf, LogicFlow = _a.LogicFlow, options = _a.options;
|
|
@@ -107,8 +106,6 @@ var MiniMap = /** @class */ (function () {
|
|
|
107
106
|
*/
|
|
108
107
|
this.hide = function () {
|
|
109
108
|
if (_this.isShow) {
|
|
110
|
-
// 隐藏小地图时摧毁实例
|
|
111
|
-
destroyTeleportContainer(_this.lfMap.graphModel.flowId);
|
|
112
109
|
_this.lf.off('graph:resize', _this.onGraphResize);
|
|
113
110
|
_this.lfMap.destroy();
|
|
114
111
|
// 保证重新创建实例时,小地图中内容偏移正确
|
|
@@ -279,12 +276,11 @@ var MiniMap = /** @class */ (function () {
|
|
|
279
276
|
history: false,
|
|
280
277
|
snapline: false,
|
|
281
278
|
disabledPlugins: this.disabledPlugins,
|
|
279
|
+
isMiniMap: true,
|
|
282
280
|
});
|
|
283
281
|
// minimap中禁用adapter。
|
|
284
282
|
// this.lfMap.adapterIn = (a) => a
|
|
285
283
|
// this.lfMap.adapterOut = (a) => a
|
|
286
|
-
// 创建teleport容器(vue3中生效)
|
|
287
|
-
createTeleportContainer(miniMapWrap, this.lfMap.graphModel.flowId);
|
|
288
284
|
this.miniMapWrap = miniMapWrap;
|
|
289
285
|
this.createViewPort();
|
|
290
286
|
miniMapWrap.addEventListener('click', this.mapClick);
|
|
@@ -526,7 +522,6 @@ var MiniMap = /** @class */ (function () {
|
|
|
526
522
|
this.viewport = div;
|
|
527
523
|
};
|
|
528
524
|
MiniMap.prototype.destroy = function () {
|
|
529
|
-
destroyTeleportContainer(this.lfMap.graphModel.flowId);
|
|
530
525
|
this.lf.off('graph:resize', this.onGraphResize);
|
|
531
526
|
};
|
|
532
527
|
MiniMap.pluginName = 'miniMap';
|
|
@@ -32,6 +32,7 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
32
32
|
this.disabled = true;
|
|
33
33
|
this.isWholeNode = true;
|
|
34
34
|
this.isWholeEdge = true;
|
|
35
|
+
this.originStatusSaved = false;
|
|
35
36
|
this.exclusiveMode = false; // 框选独占模式:true 表示只能进行框选操作,false 表示可以同时进行其他画布操作
|
|
36
37
|
// 用于区分选区和点击事件
|
|
37
38
|
this.mouseDownInfo = null;
|
|
@@ -73,6 +74,11 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
73
74
|
}
|
|
74
75
|
};
|
|
75
76
|
this.drawOff = function (e) {
|
|
77
|
+
// 恢复原始的 stopMoveGraph 设置
|
|
78
|
+
_this.lf.updateEditConfig({
|
|
79
|
+
stopMoveGraph: _this.originalStopMoveGraph,
|
|
80
|
+
});
|
|
81
|
+
_this.originStatusSaved = false;
|
|
76
82
|
// 处理鼠标抬起事件
|
|
77
83
|
// 首先判断是否是点击,如果是,则清空框选
|
|
78
84
|
if (_this.mouseDownInfo) {
|
|
@@ -92,10 +98,6 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
92
98
|
if (!_this.exclusiveMode) {
|
|
93
99
|
document.removeEventListener('mouseup', _this.drawOff);
|
|
94
100
|
}
|
|
95
|
-
// 恢复原始的 stopMoveGraph 设置
|
|
96
|
-
_this.lf.updateEditConfig({
|
|
97
|
-
stopMoveGraph: _this.originalStopMoveGraph,
|
|
98
|
-
});
|
|
99
101
|
if (curStartPoint && curEndPoint) {
|
|
100
102
|
var x = curStartPoint.x, y = curStartPoint.y;
|
|
101
103
|
var x1 = curEndPoint.x, y1 = curEndPoint.y;
|
|
@@ -270,7 +272,11 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
270
272
|
time: Date.now(),
|
|
271
273
|
};
|
|
272
274
|
// 记录原始设置并临时禁止画布移动
|
|
273
|
-
|
|
275
|
+
if (!this.originStatusSaved) {
|
|
276
|
+
// 为了防止在开启框选时用户多次点击画布导致缓存的stopMoveGraph变化,所以只在第一次点击时记录原始的stopMoveGraph issue #2263
|
|
277
|
+
this.originalStopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
|
|
278
|
+
this.originStatusSaved = true;
|
|
279
|
+
}
|
|
274
280
|
this.lf.updateEditConfig({
|
|
275
281
|
stopMoveGraph: true,
|
|
276
282
|
});
|
|
@@ -49,7 +49,7 @@ import { Component, observer } from '@logicflow/core';
|
|
|
49
49
|
import { forEach, merge } from 'lodash-es';
|
|
50
50
|
import Label from './Label';
|
|
51
51
|
import LabelModel from './LabelModel';
|
|
52
|
-
import { MediumEditor, defaultOptions,
|
|
52
|
+
import { MediumEditor, defaultOptions, createColorPickerButtonClass, } from './mediumEditor';
|
|
53
53
|
// const { createUuid } = LogicFlowUtil
|
|
54
54
|
// DONE: 解决问题,如果 LabelOverlay 设置为 Observer,拖拽 Label 时会导致 LabelOverlay 组件重新渲染,不知道为何
|
|
55
55
|
// 目前解决了。流程是 拖动 -> 更新 label 的数据信息到 element model -> 重新渲染 LabelOverlay
|
|
@@ -74,7 +74,7 @@ var LabelOverlay = /** @class */ (function (_super) {
|
|
|
74
74
|
this.editor = new MediumEditor('.lf-label-editor', merge(defaultOptions, {
|
|
75
75
|
autoLink: true,
|
|
76
76
|
extensions: {
|
|
77
|
-
colorPicker: new
|
|
77
|
+
colorPicker: new (createColorPickerButtonClass(MediumEditor))(),
|
|
78
78
|
},
|
|
79
79
|
}));
|
|
80
80
|
// TODO: 2. 在此处监听一些事件,当 node、edge 数据变化时,主动触发重新渲染,保证同步更新
|
|
@@ -99,7 +99,7 @@ var LabelOverlay = /** @class */ (function (_super) {
|
|
|
99
99
|
this.editor = new MediumEditor('.lf-label-editor', merge(defaultOptions, {
|
|
100
100
|
autoLink: true,
|
|
101
101
|
extensions: {
|
|
102
|
-
colorPicker: new
|
|
102
|
+
colorPicker: new (createColorPickerButtonClass(MediumEditor))(),
|
|
103
103
|
},
|
|
104
104
|
}));
|
|
105
105
|
}
|
|
@@ -36,56 +36,93 @@ export var defaultOptions = {
|
|
|
36
36
|
},
|
|
37
37
|
disableEditing: true,
|
|
38
38
|
};
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
39
|
+
export function createColorPickerButtonClass(MediumEditor) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
var ButtonBase = ((_a = MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.extensions) === null || _a === void 0 ? void 0 : _a.button) || ((_b = MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.extensions) === null || _b === void 0 ? void 0 : _b.button);
|
|
42
|
+
var ExtensionBase = (MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.Extension) || (MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.Extension);
|
|
43
|
+
// 当 Button 扩展基类不可用时,回退到 Extension 基类,避免在模块加载阶段抛错
|
|
44
|
+
var Base = ButtonBase || ExtensionBase;
|
|
45
|
+
if (!Base) {
|
|
46
|
+
console.warn('MediumEditor button/extension base not available; using noop extension');
|
|
47
|
+
return /** @class */ (function () {
|
|
48
|
+
function class_1() {
|
|
49
|
+
}
|
|
50
|
+
return class_1;
|
|
51
|
+
}());
|
|
52
|
+
}
|
|
53
|
+
return Base.extend({
|
|
54
|
+
name: 'colorpicker',
|
|
55
|
+
tagNames: ['mark'],
|
|
56
|
+
contentDefault: '<b>Color</b>',
|
|
57
|
+
aria: 'Color Picker',
|
|
58
|
+
action: 'colorPicker',
|
|
59
|
+
init: function () {
|
|
60
|
+
var _this = this;
|
|
61
|
+
var _a, _b;
|
|
62
|
+
try {
|
|
63
|
+
rangy.init();
|
|
64
|
+
}
|
|
65
|
+
catch (_c) {
|
|
66
|
+
console.error('rangy.init failed');
|
|
67
|
+
}
|
|
68
|
+
// 初始化按钮(ButtonBase 才有 prototype.init)
|
|
69
|
+
try {
|
|
70
|
+
;
|
|
71
|
+
(_b = (_a = ButtonBase === null || ButtonBase === void 0 ? void 0 : ButtonBase.prototype) === null || _a === void 0 ? void 0 : _a.init) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
72
|
+
}
|
|
73
|
+
catch (_d) {
|
|
74
|
+
console.error('ButtonBase.init failed');
|
|
75
|
+
}
|
|
76
|
+
this.colorPicker = new Picker({
|
|
77
|
+
parent: this.button || undefined,
|
|
78
|
+
color: '#000',
|
|
79
|
+
onDone: function (res) {
|
|
80
|
+
var _a, _b, _c, _d, _e;
|
|
81
|
+
try {
|
|
82
|
+
if (_this.coloredText && ((_b = (_a = _this.coloredText).isAppliedToSelection) === null || _b === void 0 ? void 0 : _b.call(_a))) {
|
|
83
|
+
_this.coloredText.undoToSelection();
|
|
84
|
+
}
|
|
85
|
+
_this.coloredText = rangy.createClassApplier('colored', {
|
|
86
|
+
elementTagName: 'span',
|
|
87
|
+
elementProperties: { style: { color: res.hex } },
|
|
88
|
+
normalize: true,
|
|
89
|
+
});
|
|
90
|
+
_this.coloredText.toggleSelection();
|
|
91
|
+
(_d = (_c = _this.base) === null || _c === void 0 ? void 0 : _c.checkContentChanged) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
92
|
+
(_e = _this.setInactive) === null || _e === void 0 ? void 0 : _e.call(_this);
|
|
93
|
+
}
|
|
94
|
+
catch (_f) {
|
|
95
|
+
console.error('Picker.onDone failed');
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
getButton: function () {
|
|
101
|
+
return this.button;
|
|
102
|
+
},
|
|
103
|
+
handleClick: function () {
|
|
104
|
+
var _a, _b, _c;
|
|
105
|
+
(_a = this.setActive) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
106
|
+
(_c = (_b = this.colorPicker) === null || _b === void 0 ? void 0 : _b.show) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
107
|
+
},
|
|
108
|
+
isAlreadyApplied: function (node) {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return ((_b = (_a = node === null || node === void 0 ? void 0 : node.nodeName) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === 'mark';
|
|
111
|
+
},
|
|
112
|
+
isActive: function () {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
return (_b = (_a = this.button) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.contains('medium-editor-button-active');
|
|
115
|
+
},
|
|
116
|
+
setInactive: function () {
|
|
117
|
+
var _a, _b;
|
|
118
|
+
;
|
|
119
|
+
(_b = (_a = this.button) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('medium-editor-button-active');
|
|
120
|
+
},
|
|
121
|
+
setActive: function () {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
;
|
|
124
|
+
(_b = (_a = this.button) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('medium-editor-button-active');
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
91
128
|
export { MediumEditor };
|
|
@@ -12,7 +12,6 @@ var __values = (this && this.__values) || function(o) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.MiniMap = void 0;
|
|
15
|
-
var vue_node_registry_1 = require("@logicflow/vue-node-registry");
|
|
16
15
|
var MiniMap = /** @class */ (function () {
|
|
17
16
|
function MiniMap(_a) {
|
|
18
17
|
var lf = _a.lf, LogicFlow = _a.LogicFlow, options = _a.options;
|
|
@@ -110,8 +109,6 @@ var MiniMap = /** @class */ (function () {
|
|
|
110
109
|
*/
|
|
111
110
|
this.hide = function () {
|
|
112
111
|
if (_this.isShow) {
|
|
113
|
-
// 隐藏小地图时摧毁实例
|
|
114
|
-
(0, vue_node_registry_1.destroyTeleportContainer)(_this.lfMap.graphModel.flowId);
|
|
115
112
|
_this.lf.off('graph:resize', _this.onGraphResize);
|
|
116
113
|
_this.lfMap.destroy();
|
|
117
114
|
// 保证重新创建实例时,小地图中内容偏移正确
|
|
@@ -282,12 +279,11 @@ var MiniMap = /** @class */ (function () {
|
|
|
282
279
|
history: false,
|
|
283
280
|
snapline: false,
|
|
284
281
|
disabledPlugins: this.disabledPlugins,
|
|
282
|
+
isMiniMap: true,
|
|
285
283
|
});
|
|
286
284
|
// minimap中禁用adapter。
|
|
287
285
|
// this.lfMap.adapterIn = (a) => a
|
|
288
286
|
// this.lfMap.adapterOut = (a) => a
|
|
289
|
-
// 创建teleport容器(vue3中生效)
|
|
290
|
-
(0, vue_node_registry_1.createTeleportContainer)(miniMapWrap, this.lfMap.graphModel.flowId);
|
|
291
287
|
this.miniMapWrap = miniMapWrap;
|
|
292
288
|
this.createViewPort();
|
|
293
289
|
miniMapWrap.addEventListener('click', this.mapClick);
|
|
@@ -529,7 +525,6 @@ var MiniMap = /** @class */ (function () {
|
|
|
529
525
|
this.viewport = div;
|
|
530
526
|
};
|
|
531
527
|
MiniMap.prototype.destroy = function () {
|
|
532
|
-
(0, vue_node_registry_1.destroyTeleportContainer)(this.lfMap.graphModel.flowId);
|
|
533
528
|
this.lf.off('graph:resize', this.onGraphResize);
|
|
534
529
|
};
|
|
535
530
|
MiniMap.pluginName = 'miniMap';
|
|
@@ -35,6 +35,7 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
35
35
|
this.disabled = true;
|
|
36
36
|
this.isWholeNode = true;
|
|
37
37
|
this.isWholeEdge = true;
|
|
38
|
+
this.originStatusSaved = false;
|
|
38
39
|
this.exclusiveMode = false; // 框选独占模式:true 表示只能进行框选操作,false 表示可以同时进行其他画布操作
|
|
39
40
|
// 用于区分选区和点击事件
|
|
40
41
|
this.mouseDownInfo = null;
|
|
@@ -76,6 +77,11 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
79
|
this.drawOff = function (e) {
|
|
80
|
+
// 恢复原始的 stopMoveGraph 设置
|
|
81
|
+
_this.lf.updateEditConfig({
|
|
82
|
+
stopMoveGraph: _this.originalStopMoveGraph,
|
|
83
|
+
});
|
|
84
|
+
_this.originStatusSaved = false;
|
|
79
85
|
// 处理鼠标抬起事件
|
|
80
86
|
// 首先判断是否是点击,如果是,则清空框选
|
|
81
87
|
if (_this.mouseDownInfo) {
|
|
@@ -95,10 +101,6 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
95
101
|
if (!_this.exclusiveMode) {
|
|
96
102
|
document.removeEventListener('mouseup', _this.drawOff);
|
|
97
103
|
}
|
|
98
|
-
// 恢复原始的 stopMoveGraph 设置
|
|
99
|
-
_this.lf.updateEditConfig({
|
|
100
|
-
stopMoveGraph: _this.originalStopMoveGraph,
|
|
101
|
-
});
|
|
102
104
|
if (curStartPoint && curEndPoint) {
|
|
103
105
|
var x = curStartPoint.x, y = curStartPoint.y;
|
|
104
106
|
var x1 = curEndPoint.x, y1 = curEndPoint.y;
|
|
@@ -273,7 +275,11 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
273
275
|
time: Date.now(),
|
|
274
276
|
};
|
|
275
277
|
// 记录原始设置并临时禁止画布移动
|
|
276
|
-
|
|
278
|
+
if (!this.originStatusSaved) {
|
|
279
|
+
// 为了防止在开启框选时用户多次点击画布导致缓存的stopMoveGraph变化,所以只在第一次点击时记录原始的stopMoveGraph issue #2263
|
|
280
|
+
this.originalStopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
|
|
281
|
+
this.originStatusSaved = true;
|
|
282
|
+
}
|
|
277
283
|
this.lf.updateEditConfig({
|
|
278
284
|
stopMoveGraph: true,
|
|
279
285
|
});
|
|
@@ -80,7 +80,7 @@ var LabelOverlay = /** @class */ (function (_super) {
|
|
|
80
80
|
this.editor = new mediumEditor_1.MediumEditor('.lf-label-editor', (0, lodash_es_1.merge)(mediumEditor_1.defaultOptions, {
|
|
81
81
|
autoLink: true,
|
|
82
82
|
extensions: {
|
|
83
|
-
colorPicker: new mediumEditor_1.
|
|
83
|
+
colorPicker: new ((0, mediumEditor_1.createColorPickerButtonClass)(mediumEditor_1.MediumEditor))(),
|
|
84
84
|
},
|
|
85
85
|
}));
|
|
86
86
|
// TODO: 2. 在此处监听一些事件,当 node、edge 数据变化时,主动触发重新渲染,保证同步更新
|
|
@@ -105,7 +105,7 @@ var LabelOverlay = /** @class */ (function (_super) {
|
|
|
105
105
|
this.editor = new mediumEditor_1.MediumEditor('.lf-label-editor', (0, lodash_es_1.merge)(mediumEditor_1.defaultOptions, {
|
|
106
106
|
autoLink: true,
|
|
107
107
|
extensions: {
|
|
108
|
-
colorPicker: new mediumEditor_1.
|
|
108
|
+
colorPicker: new ((0, mediumEditor_1.createColorPickerButtonClass)(mediumEditor_1.MediumEditor))(),
|
|
109
109
|
},
|
|
110
110
|
}));
|
|
111
111
|
}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MediumEditor = exports.
|
|
6
|
+
exports.MediumEditor = exports.createColorPickerButtonClass = exports.defaultOptions = void 0;
|
|
7
7
|
var medium_editor_1 = __importDefault(require("medium-editor"));
|
|
8
8
|
exports.MediumEditor = medium_editor_1.default;
|
|
9
9
|
var vanilla_picker_1 = __importDefault(require("vanilla-picker"));
|
|
@@ -43,55 +43,93 @@ exports.defaultOptions = {
|
|
|
43
43
|
},
|
|
44
44
|
disableEditing: true,
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
46
|
+
function createColorPickerButtonClass(MediumEditor) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
var ButtonBase = ((_a = MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.extensions) === null || _a === void 0 ? void 0 : _a.button) || ((_b = MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.extensions) === null || _b === void 0 ? void 0 : _b.button);
|
|
49
|
+
var ExtensionBase = (MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.Extension) || (MediumEditor === null || MediumEditor === void 0 ? void 0 : MediumEditor.Extension);
|
|
50
|
+
// 当 Button 扩展基类不可用时,回退到 Extension 基类,避免在模块加载阶段抛错
|
|
51
|
+
var Base = ButtonBase || ExtensionBase;
|
|
52
|
+
if (!Base) {
|
|
53
|
+
console.warn('MediumEditor button/extension base not available; using noop extension');
|
|
54
|
+
return /** @class */ (function () {
|
|
55
|
+
function class_1() {
|
|
56
|
+
}
|
|
57
|
+
return class_1;
|
|
58
|
+
}());
|
|
59
|
+
}
|
|
60
|
+
return Base.extend({
|
|
61
|
+
name: 'colorpicker',
|
|
62
|
+
tagNames: ['mark'],
|
|
63
|
+
contentDefault: '<b>Color</b>',
|
|
64
|
+
aria: 'Color Picker',
|
|
65
|
+
action: 'colorPicker',
|
|
66
|
+
init: function () {
|
|
67
|
+
var _this = this;
|
|
68
|
+
var _a, _b;
|
|
69
|
+
try {
|
|
70
|
+
rangy_1.default.init();
|
|
71
|
+
}
|
|
72
|
+
catch (_c) {
|
|
73
|
+
console.error('rangy.init failed');
|
|
74
|
+
}
|
|
75
|
+
// 初始化按钮(ButtonBase 才有 prototype.init)
|
|
76
|
+
try {
|
|
77
|
+
;
|
|
78
|
+
(_b = (_a = ButtonBase === null || ButtonBase === void 0 ? void 0 : ButtonBase.prototype) === null || _a === void 0 ? void 0 : _a.init) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
79
|
+
}
|
|
80
|
+
catch (_d) {
|
|
81
|
+
console.error('ButtonBase.init failed');
|
|
82
|
+
}
|
|
83
|
+
this.colorPicker = new vanilla_picker_1.default({
|
|
84
|
+
parent: this.button || undefined,
|
|
85
|
+
color: '#000',
|
|
86
|
+
onDone: function (res) {
|
|
87
|
+
var _a, _b, _c, _d, _e;
|
|
88
|
+
try {
|
|
89
|
+
if (_this.coloredText && ((_b = (_a = _this.coloredText).isAppliedToSelection) === null || _b === void 0 ? void 0 : _b.call(_a))) {
|
|
90
|
+
_this.coloredText.undoToSelection();
|
|
91
|
+
}
|
|
92
|
+
_this.coloredText = rangy_1.default.createClassApplier('colored', {
|
|
93
|
+
elementTagName: 'span',
|
|
94
|
+
elementProperties: { style: { color: res.hex } },
|
|
95
|
+
normalize: true,
|
|
96
|
+
});
|
|
97
|
+
_this.coloredText.toggleSelection();
|
|
98
|
+
(_d = (_c = _this.base) === null || _c === void 0 ? void 0 : _c.checkContentChanged) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
99
|
+
(_e = _this.setInactive) === null || _e === void 0 ? void 0 : _e.call(_this);
|
|
100
|
+
}
|
|
101
|
+
catch (_f) {
|
|
102
|
+
console.error('Picker.onDone failed');
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
getButton: function () {
|
|
108
|
+
return this.button;
|
|
109
|
+
},
|
|
110
|
+
handleClick: function () {
|
|
111
|
+
var _a, _b, _c;
|
|
112
|
+
(_a = this.setActive) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
113
|
+
(_c = (_b = this.colorPicker) === null || _b === void 0 ? void 0 : _b.show) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
114
|
+
},
|
|
115
|
+
isAlreadyApplied: function (node) {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
return ((_b = (_a = node === null || node === void 0 ? void 0 : node.nodeName) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === 'mark';
|
|
118
|
+
},
|
|
119
|
+
isActive: function () {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
return (_b = (_a = this.button) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.contains('medium-editor-button-active');
|
|
122
|
+
},
|
|
123
|
+
setInactive: function () {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
;
|
|
126
|
+
(_b = (_a = this.button) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('medium-editor-button-active');
|
|
127
|
+
},
|
|
128
|
+
setActive: function () {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
;
|
|
131
|
+
(_b = (_a = this.button) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('medium-editor-button-active');
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
exports.createColorPickerButtonClass = createColorPickerButtonClass;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logicflow/extension",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "LogicFlow Extensions",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"author": "Logicflow-Team",
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@logicflow/
|
|
24
|
-
"@logicflow/
|
|
23
|
+
"@logicflow/core": "2.1.5",
|
|
24
|
+
"@logicflow/vue-node-registry": "1.1.6"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@antv/hierarchy": "^0.6.11",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"preact": "^10.17.1",
|
|
33
33
|
"rangy": "^1.3.1",
|
|
34
34
|
"vanilla-picker": "^2.12.3",
|
|
35
|
-
"@logicflow/
|
|
36
|
-
"@logicflow/
|
|
35
|
+
"@logicflow/vue-node-registry": "1.1.6",
|
|
36
|
+
"@logicflow/core": "2.1.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"less": "^4.1.1",
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import LogicFlow from '@logicflow/core'
|
|
2
|
-
import {
|
|
3
|
-
createTeleportContainer,
|
|
4
|
-
destroyTeleportContainer,
|
|
5
|
-
} from '@logicflow/vue-node-registry'
|
|
6
2
|
|
|
7
3
|
import Position = LogicFlow.Position
|
|
8
4
|
import MiniMapOption = MiniMap.MiniMapOption
|
|
@@ -240,8 +236,6 @@ export class MiniMap {
|
|
|
240
236
|
*/
|
|
241
237
|
public hide = () => {
|
|
242
238
|
if (this.isShow) {
|
|
243
|
-
// 隐藏小地图时摧毁实例
|
|
244
|
-
destroyTeleportContainer(this.lfMap.graphModel.flowId)
|
|
245
239
|
this.lf.off('graph:resize', this.onGraphResize)
|
|
246
240
|
this.lfMap.destroy()
|
|
247
241
|
// 保证重新创建实例时,小地图中内容偏移正确
|
|
@@ -363,14 +357,12 @@ export class MiniMap {
|
|
|
363
357
|
history: false,
|
|
364
358
|
snapline: false,
|
|
365
359
|
disabledPlugins: this.disabledPlugins,
|
|
360
|
+
isMiniMap: true,
|
|
366
361
|
})
|
|
367
362
|
// minimap中禁用adapter。
|
|
368
363
|
// this.lfMap.adapterIn = (a) => a
|
|
369
364
|
// this.lfMap.adapterOut = (a) => a
|
|
370
365
|
|
|
371
|
-
// 创建teleport容器(vue3中生效)
|
|
372
|
-
createTeleportContainer(miniMapWrap, this.lfMap.graphModel.flowId)
|
|
373
|
-
|
|
374
366
|
this.miniMapWrap = miniMapWrap
|
|
375
367
|
this.createViewPort()
|
|
376
368
|
miniMapWrap.addEventListener('click', this.mapClick)
|
|
@@ -687,7 +679,6 @@ export class MiniMap {
|
|
|
687
679
|
}
|
|
688
680
|
|
|
689
681
|
destroy() {
|
|
690
|
-
destroyTeleportContainer(this.lfMap.graphModel.flowId)
|
|
691
682
|
this.lf.off('graph:resize', this.onGraphResize)
|
|
692
683
|
}
|
|
693
684
|
}
|