@gedit/editor-2d 0.3.13 → 0.3.16
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/lib/browser/editor2d-contribution.d.ts.map +1 -1
- package/lib/browser/editor2d-contribution.js +19 -18
- package/lib/browser/editor2d-contribution.js.map +1 -1
- package/lib/browser/playground/canvas-layer.d.ts +2 -1
- package/lib/browser/playground/canvas-layer.d.ts.map +1 -1
- package/lib/browser/playground/canvas-layer.js +8 -1
- package/lib/browser/playground/canvas-layer.js.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.d.ts.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js +29 -3
- package/lib/browser/playground/path-edit/path-edit-layer-move-point.js.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts +9 -2
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.d.ts.map +1 -1
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js +232 -13
- package/lib/browser/playground/path-edit/path-edit-layer-svg-path.js.map +1 -1
- package/lib/browser/playground/path-edit/utils.d.ts +15 -3
- package/lib/browser/playground/path-edit/utils.d.ts.map +1 -1
- package/lib/browser/playground/path-edit/utils.js +63 -13
- package/lib/browser/playground/path-edit/utils.js.map +1 -1
- package/lib/browser/playground/path-edit-layer.d.ts +46 -3
- package/lib/browser/playground/path-edit-layer.d.ts.map +1 -1
- package/lib/browser/playground/path-edit-layer.js +469 -110
- package/lib/browser/playground/path-edit-layer.js.map +1 -1
- package/lib/browser/playground/playground-contribution.d.ts.map +1 -1
- package/lib/browser/playground/playground-contribution.js +2 -0
- package/lib/browser/playground/playground-contribution.js.map +1 -1
- package/lib/browser/utils/bezier.path.utils.d.ts.map +1 -1
- package/lib/browser/utils/bezier.path.utils.js +3 -0
- package/lib/browser/utils/bezier.path.utils.js.map +1 -1
- package/package.json +7 -7
- package/src/browser/editor2d-contribution.ts +19 -18
- package/src/browser/playground/canvas-layer.ts +6 -1
- package/src/browser/playground/path-edit/path-edit-layer-move-point.tsx +38 -4
- package/src/browser/playground/path-edit/path-edit-layer-svg-path.tsx +303 -26
- package/src/browser/playground/path-edit/utils.tsx +80 -17
- package/src/browser/playground/path-edit-layer.tsx +526 -122
- package/src/browser/playground/playground-contribution.ts +2 -0
- package/src/browser/style/path-edit-layer.less +17 -5
- package/src/browser/svg/drag_path.svg +17 -0
- package/src/browser/utils/bezier.path.utils.ts +3 -0
|
@@ -16,7 +16,48 @@ import { TreeSelection } from '@gedit/tree';
|
|
|
16
16
|
import { PATH_FUNC_TYPE, toFixedValue, } from '@gedit/canvas-draw';
|
|
17
17
|
import { deepClone, DisposableCollection, generateUuid, } from '@gedit/utils';
|
|
18
18
|
import { SvgPath, getNewPoint, setBezierMovePoint, updatePathNodeData, inverseTransformToData, transformToData, } from './path-edit';
|
|
19
|
+
import { isOSX } from '@gedit/application-common';
|
|
20
|
+
import { getParallelPositionByPoint } from '../utils/bezier.path.utils';
|
|
19
21
|
export const PathEditLayerEventContext = React.createContext({});
|
|
22
|
+
export var Editor2dPathKeyCommands;
|
|
23
|
+
(function (Editor2dPathKeyCommands) {
|
|
24
|
+
const EDITOR2D_PATH_CATEGORY = 'Editor2dPath';
|
|
25
|
+
Editor2dPathKeyCommands.TAB_PATH = {
|
|
26
|
+
id: 'editor2d.path.tab',
|
|
27
|
+
category: EDITOR2D_PATH_CATEGORY,
|
|
28
|
+
label: '下一个点',
|
|
29
|
+
};
|
|
30
|
+
// export const SHOW_ALL_BEZIER: Command = {
|
|
31
|
+
// id: 'editor2d.path.showAllBezier',
|
|
32
|
+
// category: EDITOR2D_PATH_CATEGORY,
|
|
33
|
+
// label: '显示全部贝塞尔点',
|
|
34
|
+
// };
|
|
35
|
+
Editor2dPathKeyCommands.SELECT_All = {
|
|
36
|
+
id: 'editor2d.path.selectAll',
|
|
37
|
+
category: EDITOR2D_PATH_CATEGORY,
|
|
38
|
+
label: '选择全部',
|
|
39
|
+
};
|
|
40
|
+
Editor2dPathKeyCommands.BEZIER_STRAIGHT = {
|
|
41
|
+
id: 'editor2d.path.bezierStraight',
|
|
42
|
+
category: EDITOR2D_PATH_CATEGORY,
|
|
43
|
+
label: '无贝塞尔',
|
|
44
|
+
};
|
|
45
|
+
Editor2dPathKeyCommands.BEZIER_EQUAL = {
|
|
46
|
+
id: 'editor2d.path.bezierEqual',
|
|
47
|
+
category: EDITOR2D_PATH_CATEGORY,
|
|
48
|
+
label: '左右相等',
|
|
49
|
+
};
|
|
50
|
+
Editor2dPathKeyCommands.BEZIER_BREAK = {
|
|
51
|
+
id: 'editor2d.path.bezierBreak',
|
|
52
|
+
category: EDITOR2D_PATH_CATEGORY,
|
|
53
|
+
label: '左右断开',
|
|
54
|
+
};
|
|
55
|
+
Editor2dPathKeyCommands.BEZIER_UNEQUAL = {
|
|
56
|
+
id: 'editor2d.path.bezierUnequal',
|
|
57
|
+
category: EDITOR2D_PATH_CATEGORY,
|
|
58
|
+
label: '左右不相等',
|
|
59
|
+
};
|
|
60
|
+
})(Editor2dPathKeyCommands || (Editor2dPathKeyCommands = {}));
|
|
20
61
|
/**
|
|
21
62
|
* 动态绘制层
|
|
22
63
|
*/
|
|
@@ -25,9 +66,25 @@ export class PathEditLayer extends Layer {
|
|
|
25
66
|
super(...arguments);
|
|
26
67
|
this.node = domUtils.createDivWithClass('gedit-path-edit-layer');
|
|
27
68
|
this.id = 'pathEditLayer';
|
|
69
|
+
// 显示全部贝塞尔点
|
|
70
|
+
this.altKey = false;
|
|
71
|
+
// 按住 shit 键
|
|
72
|
+
this.shiftKey = false;
|
|
73
|
+
// 按住 ctrl 或 ⌘ 键;
|
|
74
|
+
this.ctrlKey = false;
|
|
75
|
+
this._historyIndex = 0;
|
|
76
|
+
this.noHistory = false;
|
|
28
77
|
// 访录当前图层在 timeline 里的监听事件
|
|
29
78
|
this.layerDisposeMap = new Map();
|
|
30
79
|
}
|
|
80
|
+
get historyIndex() {
|
|
81
|
+
const h = this._historyIndex;
|
|
82
|
+
this._historyIndex++;
|
|
83
|
+
return h;
|
|
84
|
+
}
|
|
85
|
+
set historyIndex(h) {
|
|
86
|
+
this._historyIndex = h;
|
|
87
|
+
}
|
|
31
88
|
get document() {
|
|
32
89
|
return this.documentEntity.config.document;
|
|
33
90
|
}
|
|
@@ -44,13 +101,14 @@ export class PathEditLayer extends Layer {
|
|
|
44
101
|
}
|
|
45
102
|
reNodeData() {
|
|
46
103
|
var _a;
|
|
104
|
+
this.clearHistory();
|
|
47
105
|
this.currentPathNode = undefined;
|
|
48
106
|
this.startPos = undefined;
|
|
49
107
|
this.pathPointSelection.clearSelection();
|
|
50
108
|
this.pathPointSelection.selectMode = PathSelectMode.ADD_PATH;
|
|
51
109
|
(_a = this.docDispose) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
52
110
|
}
|
|
53
|
-
updateNodeData() {
|
|
111
|
+
updateNodeData(noHistory) {
|
|
54
112
|
var _a;
|
|
55
113
|
if (!this.currentPathNode) {
|
|
56
114
|
return;
|
|
@@ -59,7 +117,68 @@ export class PathEditLayer extends Layer {
|
|
|
59
117
|
// console.log('updateNodeData', nodeData);
|
|
60
118
|
// 直接更新数据,,动画 updateAnimationNode 里会把数据删了;
|
|
61
119
|
this.currentPathNode.path = nodeData.path;
|
|
120
|
+
this.currentPathNode.selected = true;
|
|
62
121
|
(_a = this.document) === null || _a === void 0 ? void 0 : _a.updateNode(this.currentPathNode, nodeData, true);
|
|
122
|
+
this.addHistoryData(noHistory);
|
|
123
|
+
}
|
|
124
|
+
reloadNodeData(content) {
|
|
125
|
+
var _a;
|
|
126
|
+
if (!this.currentPathNode || !this.pathPointSelection) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const path = JSON.parse(content);
|
|
130
|
+
this.currentPathNode.path = path;
|
|
131
|
+
(_a = this.document) === null || _a === void 0 ? void 0 : _a.updateNode(this.currentPathNode, { path }, true);
|
|
132
|
+
this.pathPointSelection.selection = path.paths[path.paths.length - 1]
|
|
133
|
+
? [{ pointId: path.paths[path.paths.length - 1].id }]
|
|
134
|
+
: [];
|
|
135
|
+
if (!path.paths.length) {
|
|
136
|
+
this.pathPointSelection.enterPathMode([]);
|
|
137
|
+
}
|
|
138
|
+
this.draw();
|
|
139
|
+
}
|
|
140
|
+
clearHistory() {
|
|
141
|
+
if (this.historyUri) {
|
|
142
|
+
this.context.historyService.clearHistory(this.historyUri);
|
|
143
|
+
this.historyUri = undefined;
|
|
144
|
+
this.context.historyService.switchHistory(this.context.document.uri);
|
|
145
|
+
}
|
|
146
|
+
this.historyIndex = 0;
|
|
147
|
+
}
|
|
148
|
+
addHistoryData(noHistory) {
|
|
149
|
+
var _a;
|
|
150
|
+
const nodePath = (_a = this.currentPathNode) === null || _a === void 0 ? void 0 : _a.path;
|
|
151
|
+
if (!nodePath || noHistory || !this.historyUri) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const index = this.historyIndex;
|
|
155
|
+
this.context.historyService.add(this.historyUri, {
|
|
156
|
+
key: index,
|
|
157
|
+
data: {
|
|
158
|
+
content: JSON.stringify(nodePath),
|
|
159
|
+
resource: {
|
|
160
|
+
reload: (content) => {
|
|
161
|
+
this.reloadNodeData(content);
|
|
162
|
+
},
|
|
163
|
+
resource: {
|
|
164
|
+
uri: this.historyUri,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
createHistory() {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
if (!this.currentPathNode) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
this.historyUri = `${this.context.document.uri}?${(_a = this.currentPathNode) === null || _a === void 0 ? void 0 : _a.id}`;
|
|
176
|
+
if (this.context.historyService.currentUri !== this.historyUri) {
|
|
177
|
+
this.context.historyService.switchHistory(this.historyUri);
|
|
178
|
+
if (!((_b = this.context.historyService.getHistoryNavigator(this.historyUri)) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
179
|
+
this.addHistoryData();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
63
182
|
}
|
|
64
183
|
// updateNodePathData(): void {
|
|
65
184
|
// if (!this.currentPathNode) {
|
|
@@ -164,17 +283,196 @@ export class PathEditLayer extends Layer {
|
|
|
164
283
|
this.layerDisposeMap.set(this.currentPathNode.id, currentDispose);
|
|
165
284
|
}
|
|
166
285
|
}
|
|
286
|
+
updateCurrentPointBezierType(type) {
|
|
287
|
+
if (!this.currentPathNode || !this.pathPointSelection) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const { selection = [] } = this.pathPointSelection;
|
|
291
|
+
selection.forEach(item => {
|
|
292
|
+
const path = this.currentPathNode.path;
|
|
293
|
+
const point = path.paths.find(c => c.id === item.pointId);
|
|
294
|
+
if (point) {
|
|
295
|
+
point.type = type;
|
|
296
|
+
switch (type) {
|
|
297
|
+
case PATH_FUNC_TYPE.STRAIGHT:
|
|
298
|
+
delete point.x1;
|
|
299
|
+
delete point.y1;
|
|
300
|
+
delete point.x2;
|
|
301
|
+
delete point.y2;
|
|
302
|
+
break;
|
|
303
|
+
case PATH_FUNC_TYPE.EQUAL:
|
|
304
|
+
case PATH_FUNC_TYPE.UNEQUAL:
|
|
305
|
+
case PATH_FUNC_TYPE.BREAK: {
|
|
306
|
+
const inP1 = 'x1' in point && 'y1' in point;
|
|
307
|
+
const inP2 = 'x2' in point && 'y2' in point;
|
|
308
|
+
if (type === PATH_FUNC_TYPE.BREAK && inP1 && inP2) {
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
const index = path.paths.findIndex(c => c.id === point.id);
|
|
312
|
+
const prevPoint = path.paths[index - 1] || path.paths[path.paths.length - 1];
|
|
313
|
+
const nextPoint = path.paths[index + 1] || path.paths[0];
|
|
314
|
+
// 计算平衡线;
|
|
315
|
+
// 点线长度计算两个点的长的距一半;
|
|
316
|
+
const { p1, p2 /* isReverse */ } = getParallelPositionByPoint(prevPoint, nextPoint, point);
|
|
317
|
+
if (type === PATH_FUNC_TYPE.BREAK) {
|
|
318
|
+
if (inP1 && !inP2) {
|
|
319
|
+
point.x2 = p2.x;
|
|
320
|
+
point.y2 = p2.y;
|
|
321
|
+
}
|
|
322
|
+
else if (inP2 && !inP1) {
|
|
323
|
+
point.x1 = p1.x;
|
|
324
|
+
point.y1 = p1.y;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
point.x1 = p1.x;
|
|
328
|
+
point.y1 = p1.y;
|
|
329
|
+
point.x2 = p2.x;
|
|
330
|
+
point.y2 = p2.y;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
default:
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
this.updateNodeData();
|
|
339
|
+
}
|
|
340
|
+
registerKeybindings() {
|
|
341
|
+
const ctrlKey = !isOSX ? 'control' : 'meta';
|
|
342
|
+
return [
|
|
343
|
+
// alt shift 之类在 keybindings 里面不能单个做快捷键
|
|
344
|
+
this.listenGlobalEvent('keydown', e => {
|
|
345
|
+
// alt 显示全部贝赛尔点
|
|
346
|
+
if (this.isEnabled && e.key.toLowerCase() === 'alt') {
|
|
347
|
+
this.altKey = true;
|
|
348
|
+
this.draw();
|
|
349
|
+
}
|
|
350
|
+
if (this.isEnabled && e.key.toLowerCase() === 'shift') {
|
|
351
|
+
this.shiftKey = true;
|
|
352
|
+
this.draw();
|
|
353
|
+
}
|
|
354
|
+
if (this.isEnabled && e.key.toLowerCase() === ctrlKey) {
|
|
355
|
+
this.ctrlKey = true;
|
|
356
|
+
this.draw();
|
|
357
|
+
}
|
|
358
|
+
}),
|
|
359
|
+
this.listenGlobalEvent('keyup', (e) => {
|
|
360
|
+
if (this.isEnabled && e.key.toLowerCase() === 'alt') {
|
|
361
|
+
this.altKey = false;
|
|
362
|
+
this.draw();
|
|
363
|
+
}
|
|
364
|
+
if (this.isEnabled && e.key.toLowerCase() === 'shift') {
|
|
365
|
+
this.shiftKey = false;
|
|
366
|
+
this.draw();
|
|
367
|
+
}
|
|
368
|
+
if (this.isEnabled && e.key.toLowerCase() === ctrlKey) {
|
|
369
|
+
this.ctrlKey = false;
|
|
370
|
+
this.draw();
|
|
371
|
+
}
|
|
372
|
+
}),
|
|
373
|
+
// tab 切换点
|
|
374
|
+
this.commands.registerCommand(Editor2dPathKeyCommands.TAB_PATH, {
|
|
375
|
+
execute: () => {
|
|
376
|
+
var _a, _b, _c;
|
|
377
|
+
const currentPoint = (_b = (_a = this.pathPointSelection.selection) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.pointId;
|
|
378
|
+
const { paths = [] } = ((_c = this.currentPathNode) === null || _c === void 0 ? void 0 : _c.path) || {};
|
|
379
|
+
const index = currentPoint
|
|
380
|
+
? paths.findIndex(c => c.id === currentPoint)
|
|
381
|
+
: -1;
|
|
382
|
+
let nextPoint;
|
|
383
|
+
if (index === -1) {
|
|
384
|
+
nextPoint = paths[0];
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
nextPoint = paths[index + 1] || paths[0];
|
|
388
|
+
}
|
|
389
|
+
this.selectionChange(nextPoint);
|
|
390
|
+
},
|
|
391
|
+
isEnabled: () => !!this.isEnabled,
|
|
392
|
+
}),
|
|
393
|
+
this.keybindings.registerKeybindings({
|
|
394
|
+
command: Editor2dPathKeyCommands.TAB_PATH.id,
|
|
395
|
+
keybinding: 'tab',
|
|
396
|
+
when: 'editor2dWidgetFocus',
|
|
397
|
+
}),
|
|
398
|
+
// all 全选
|
|
399
|
+
this.commands.registerCommand(Editor2dPathKeyCommands.SELECT_All, {
|
|
400
|
+
execute: () => {
|
|
401
|
+
if (!this.currentPathNode || !this.pathPointSelection) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const { paths = [] } = this.currentPathNode.path;
|
|
405
|
+
const selection = paths.map(c => ({
|
|
406
|
+
pointId: c.id,
|
|
407
|
+
}));
|
|
408
|
+
this.pathPointSelection.enterSelectBezierMode(selection);
|
|
409
|
+
},
|
|
410
|
+
isEnabled: () => !!this.isEnabled,
|
|
411
|
+
}),
|
|
412
|
+
this.keybindings.registerKeybindings({
|
|
413
|
+
command: Editor2dPathKeyCommands.SELECT_All.id,
|
|
414
|
+
keybinding: isOSX ? 'cmd+a' : 'ctrl+a',
|
|
415
|
+
when: 'editor2dWidgetFocus',
|
|
416
|
+
}),
|
|
417
|
+
// 贝赛尔点
|
|
418
|
+
this.commands.registerCommand(Editor2dPathKeyCommands.BEZIER_STRAIGHT, {
|
|
419
|
+
execute: () => {
|
|
420
|
+
this.updateCurrentPointBezierType(PATH_FUNC_TYPE.STRAIGHT);
|
|
421
|
+
},
|
|
422
|
+
isEnabled: () => !!this.isEnabled,
|
|
423
|
+
}),
|
|
424
|
+
this.keybindings.registerKeybindings({
|
|
425
|
+
command: Editor2dPathKeyCommands.BEZIER_STRAIGHT.id,
|
|
426
|
+
keybinding: '1',
|
|
427
|
+
when: 'editor2dWidgetFocus',
|
|
428
|
+
}),
|
|
429
|
+
this.commands.registerCommand(Editor2dPathKeyCommands.BEZIER_EQUAL, {
|
|
430
|
+
execute: () => {
|
|
431
|
+
this.updateCurrentPointBezierType(PATH_FUNC_TYPE.EQUAL);
|
|
432
|
+
},
|
|
433
|
+
isEnabled: () => !!this.isEnabled,
|
|
434
|
+
}),
|
|
435
|
+
this.keybindings.registerKeybindings({
|
|
436
|
+
command: Editor2dPathKeyCommands.BEZIER_EQUAL.id,
|
|
437
|
+
keybinding: '2',
|
|
438
|
+
when: 'editor2dWidgetFocus',
|
|
439
|
+
}),
|
|
440
|
+
this.commands.registerCommand(Editor2dPathKeyCommands.BEZIER_BREAK, {
|
|
441
|
+
execute: () => {
|
|
442
|
+
this.updateCurrentPointBezierType(PATH_FUNC_TYPE.BREAK);
|
|
443
|
+
},
|
|
444
|
+
isEnabled: () => !!this.isEnabled,
|
|
445
|
+
}),
|
|
446
|
+
this.keybindings.registerKeybindings({
|
|
447
|
+
command: Editor2dPathKeyCommands.BEZIER_BREAK.id,
|
|
448
|
+
keybinding: '3',
|
|
449
|
+
when: 'editor2dWidgetFocus',
|
|
450
|
+
}),
|
|
451
|
+
this.commands.registerCommand(Editor2dPathKeyCommands.BEZIER_UNEQUAL, {
|
|
452
|
+
execute: () => {
|
|
453
|
+
this.updateCurrentPointBezierType(PATH_FUNC_TYPE.UNEQUAL);
|
|
454
|
+
},
|
|
455
|
+
isEnabled: () => !!this.isEnabled,
|
|
456
|
+
}),
|
|
457
|
+
this.keybindings.registerKeybindings({
|
|
458
|
+
command: Editor2dPathKeyCommands.BEZIER_UNEQUAL.id,
|
|
459
|
+
keybinding: '4',
|
|
460
|
+
when: 'editor2dWidgetFocus',
|
|
461
|
+
}),
|
|
462
|
+
];
|
|
463
|
+
}
|
|
167
464
|
onReady() {
|
|
168
465
|
var _a;
|
|
169
466
|
this.addDispose([
|
|
170
|
-
this.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
467
|
+
...this.registerKeybindings(),
|
|
468
|
+
// this.context.historyService.onHistoryBack(e => {
|
|
469
|
+
// this.reNodeData();
|
|
470
|
+
// this.pathPointSelection!.selectMode = PathSelectMode.ADD_PATH;
|
|
471
|
+
// this.pathPointSelection!.clearSelection();
|
|
472
|
+
// this.editorState.toDefaultState();
|
|
473
|
+
// }),
|
|
176
474
|
this.editorState.onStateChange(e => {
|
|
177
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
475
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
178
476
|
/**
|
|
179
477
|
* 1. 不是路径编辑状态时,清空数据
|
|
180
478
|
* 2. 是路径编辑状态时
|
|
@@ -196,6 +494,7 @@ export class PathEditLayer extends Layer {
|
|
|
196
494
|
if (selectNodes.length && pathSelectsNodes.length) {
|
|
197
495
|
// 选中一个 path 路径时;
|
|
198
496
|
this.currentPathNode = deepClone(pathSelectsNodes[0]);
|
|
497
|
+
this.createHistory();
|
|
199
498
|
if (this.currentPathNode.useAnimationId &&
|
|
200
499
|
((_c = (_b = this.document) === null || _b === void 0 ? void 0 : _b.timelineService) === null || _c === void 0 ? void 0 : _c.currentTimelineData) &&
|
|
201
500
|
this.document.timelineService.currentTimelineData.id ===
|
|
@@ -203,32 +502,34 @@ export class PathEditLayer extends Layer {
|
|
|
203
502
|
this.updateTimelineCurrentFrameDataToCurrentNode();
|
|
204
503
|
this.onRegisterTimelineEvent();
|
|
205
504
|
}
|
|
206
|
-
const selectionNode = [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
505
|
+
const selectionNode = ((_d = this.currentPathNode.path.paths[this.currentPathNode.path.paths.length - 1]) === null || _d === void 0 ? void 0 : _d.id)
|
|
506
|
+
? [
|
|
507
|
+
{
|
|
508
|
+
pointId: this.currentPathNode.path.paths[this.currentPathNode.path.paths.length - 1].id,
|
|
509
|
+
},
|
|
510
|
+
]
|
|
511
|
+
: [];
|
|
211
512
|
this.currentPathNode.path.closed
|
|
212
513
|
? this.pathPointSelection.enterSelectBezierMode(selectionNode)
|
|
213
514
|
: this.pathPointSelection.enterPathMode(selectionNode);
|
|
214
515
|
// 如果中心点不同,更新数据;
|
|
215
|
-
if ((((
|
|
216
|
-
((
|
|
516
|
+
if ((((_e = this.currentPathNode.origin) === null || _e === void 0 ? void 0 : _e.x) ||
|
|
517
|
+
((_f = this.currentPathNode.origin) === null || _f === void 0 ? void 0 : _f.y)) &&
|
|
217
518
|
!this.currentPathNode.path.originChangeBeforeSize) {
|
|
218
519
|
// 初始 origin 是照这个宽度算的;计算偏差使用;
|
|
219
520
|
this.currentPathNode.path.originChangeBeforeSize = {
|
|
220
|
-
width: ((
|
|
221
|
-
height: ((
|
|
521
|
+
width: ((_g = this.currentPathNode.size) === null || _g === void 0 ? void 0 : _g.width) || 0,
|
|
522
|
+
height: ((_h = this.currentPathNode.size) === null || _h === void 0 ? void 0 : _h.height) || 0,
|
|
222
523
|
};
|
|
223
|
-
(
|
|
524
|
+
(_j = this.document) === null || _j === void 0 ? void 0 : _j.updateNode(this.currentPathNode, this.currentPathNode, true);
|
|
224
525
|
}
|
|
225
|
-
else if (!((
|
|
226
|
-
!((
|
|
526
|
+
else if (!((_k = this.currentPathNode.origin) === null || _k === void 0 ? void 0 : _k.x) &&
|
|
527
|
+
!((_l = this.currentPathNode.origin) === null || _l === void 0 ? void 0 : _l.y) &&
|
|
227
528
|
this.currentPathNode.path.originChangeBeforeSize) {
|
|
228
529
|
delete this.currentPathNode.path.originChangeBeforeSize;
|
|
229
|
-
(
|
|
530
|
+
(_m = this.document) === null || _m === void 0 ? void 0 : _m.updateNode(this.currentPathNode, this.currentPathNode, true);
|
|
230
531
|
}
|
|
231
|
-
this.docDispose = (
|
|
532
|
+
this.docDispose = (_o = this.document) === null || _o === void 0 ? void 0 : _o.onContentChanged(c => {
|
|
232
533
|
var _a, _b, _c, _d;
|
|
233
534
|
const newNode = (_a = c.nodes) === null || _a === void 0 ? void 0 : _a.find(c => { var _a; return c.id === ((_a = this.currentPathNode) === null || _a === void 0 ? void 0 : _a.id); });
|
|
234
535
|
if (newNode &&
|
|
@@ -310,60 +611,68 @@ export class PathEditLayer extends Layer {
|
|
|
310
611
|
}
|
|
311
612
|
this.reNodeData();
|
|
312
613
|
}), */
|
|
614
|
+
// 拦掉画布点击事件,失焦再次点击时会触发 widget 的点击事件, 会聚焦到 widget 上
|
|
615
|
+
this.listenPlaygroundEvent('click', (event) => {
|
|
616
|
+
if (this.isEnabled) {
|
|
617
|
+
event.preventDefault();
|
|
618
|
+
event.stopPropagation();
|
|
619
|
+
this.createHistory();
|
|
620
|
+
}
|
|
621
|
+
}),
|
|
313
622
|
// 画布新增点点击事件;
|
|
314
623
|
this.listenPlaygroundEvent('mousedown', (event) => {
|
|
315
624
|
// 只在左键点击时绘制
|
|
316
|
-
if (event.buttons !== 1) {
|
|
625
|
+
if (event.buttons !== 1 || !this.isEnabled) {
|
|
317
626
|
return;
|
|
318
627
|
}
|
|
628
|
+
event.preventDefault();
|
|
629
|
+
event.stopPropagation();
|
|
319
630
|
this.startDrag(event.clientX, event.clientY, {
|
|
320
631
|
onDragStart: e => {
|
|
321
632
|
var _a, _b, _c;
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
(this.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
this.pathPointSelection.selection.length > 1)) {
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
const { position = { x: 0, y: 0 }, scale = { x: 1, y: 1 }, rotation = 0, } = this.currentPathNode || {};
|
|
340
|
-
const offset = this.getBoundsOffset();
|
|
341
|
-
let x = e.endPos.x / (((_b = this.config) === null || _b === void 0 ? void 0 : _b.finalScale) || 1) -
|
|
342
|
-
position.x -
|
|
343
|
-
offset.x;
|
|
344
|
-
let y = e.endPos.y / (((_c = this.config) === null || _c === void 0 ? void 0 : _c.finalScale) || 1) -
|
|
345
|
-
position.y -
|
|
346
|
-
offset.y;
|
|
347
|
-
const center = {
|
|
348
|
-
x: -offset.x,
|
|
349
|
-
y: -offset.y,
|
|
350
|
-
};
|
|
351
|
-
const { x: rx, y: ry } = inverseTransformToData({ x, y }, { scale, rotation }, center);
|
|
352
|
-
x = rx;
|
|
353
|
-
y = ry;
|
|
354
|
-
this.startPos = {
|
|
355
|
-
x,
|
|
356
|
-
y,
|
|
357
|
-
};
|
|
358
|
-
this.startPos.id = generateUuid();
|
|
359
|
-
this.startPos.type = PATH_FUNC_TYPE.STRAIGHT;
|
|
360
|
-
this.addPath(this.startPos);
|
|
361
|
-
this.pathPointSelection.enterPathMode([
|
|
362
|
-
{
|
|
363
|
-
pointId: this.startPos.id,
|
|
364
|
-
},
|
|
365
|
-
]);
|
|
633
|
+
const { selectMode } = this.pathPointSelection || {};
|
|
634
|
+
/**
|
|
635
|
+
* 拦截画布点击事件,不处理绘制;
|
|
636
|
+
* 1. 闭合路径时;
|
|
637
|
+
* 2. 带区域选择模式时;
|
|
638
|
+
* 3. 多点选择时;
|
|
639
|
+
*/
|
|
640
|
+
if (
|
|
641
|
+
// 判断当前 select 是否 path 路径
|
|
642
|
+
(this.currentPathNode && this.currentPathNode.path.closed) ||
|
|
643
|
+
selectMode !== PathSelectMode.ADD_PATH ||
|
|
644
|
+
(((_a = this.pathPointSelection) === null || _a === void 0 ? void 0 : _a.selection) &&
|
|
645
|
+
this.pathPointSelection.selection.length > 1)) {
|
|
646
|
+
return;
|
|
366
647
|
}
|
|
648
|
+
const { position = { x: 0, y: 0 }, scale = { x: 1, y: 1 }, rotation = 0, } = this.currentPathNode || {};
|
|
649
|
+
const offset = this.getBoundsOffset();
|
|
650
|
+
let x = e.endPos.x / (((_b = this.config) === null || _b === void 0 ? void 0 : _b.finalScale) || 1) -
|
|
651
|
+
position.x -
|
|
652
|
+
offset.x;
|
|
653
|
+
let y = e.endPos.y / (((_c = this.config) === null || _c === void 0 ? void 0 : _c.finalScale) || 1) -
|
|
654
|
+
position.y -
|
|
655
|
+
offset.y;
|
|
656
|
+
const center = {
|
|
657
|
+
x: -offset.x,
|
|
658
|
+
y: -offset.y,
|
|
659
|
+
};
|
|
660
|
+
const { x: rx, y: ry } = inverseTransformToData({ x, y }, { scale, rotation }, center);
|
|
661
|
+
x = rx;
|
|
662
|
+
y = ry;
|
|
663
|
+
this.startPos = {
|
|
664
|
+
x,
|
|
665
|
+
y,
|
|
666
|
+
};
|
|
667
|
+
this.startPos.id = generateUuid();
|
|
668
|
+
this.startPos.type = PATH_FUNC_TYPE.STRAIGHT;
|
|
669
|
+
this.addPath(this.startPos);
|
|
670
|
+
this.pathPointSelection.enterPathMode([
|
|
671
|
+
{
|
|
672
|
+
pointId: this.startPos.id,
|
|
673
|
+
},
|
|
674
|
+
]);
|
|
675
|
+
this.updateNodeData(true);
|
|
367
676
|
},
|
|
368
677
|
onDrag: e => {
|
|
369
678
|
var _a, _b;
|
|
@@ -399,23 +708,29 @@ export class PathEditLayer extends Layer {
|
|
|
399
708
|
pathNode.y1 = toFixedValue(reverse ? y : y1, 2);
|
|
400
709
|
pathNode.type = PATH_FUNC_TYPE.EQUAL;
|
|
401
710
|
// console.log(this.startPos, path?.paths);
|
|
402
|
-
this.updateNodeData();
|
|
711
|
+
this.updateNodeData(true);
|
|
403
712
|
}
|
|
404
713
|
},
|
|
405
714
|
onDragEnd: () => {
|
|
406
715
|
this.startPos = undefined;
|
|
716
|
+
this.updateNodeData();
|
|
407
717
|
},
|
|
408
718
|
});
|
|
409
719
|
}),
|
|
410
720
|
this.listenPlaygroundEvent('dblclick', (e) => {
|
|
411
721
|
var _a;
|
|
722
|
+
if (!this.isEnabled) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
e.preventDefault();
|
|
726
|
+
e.stopPropagation();
|
|
412
727
|
// 双击画布时,关闭路径
|
|
413
728
|
// 1. 在路径编辑状态时,不处理;
|
|
414
729
|
// 2. 选中的是 path 路径时,不处理,新增点;
|
|
415
730
|
// 3. 选中点时,不处理;
|
|
416
731
|
// 4. 右键时,不处理;
|
|
417
732
|
// 5. 不是路径编辑状态时,不处理;
|
|
418
|
-
const isExit = this.
|
|
733
|
+
const isExit = this.isEnabled &&
|
|
419
734
|
this.pathPointSelection.selectMode === PathSelectMode.SELECT_BEZIER;
|
|
420
735
|
if (isExit) {
|
|
421
736
|
const playgroundLayer = this.pipelineLayers.find(c => c.id === 'playgroundLayer');
|
|
@@ -438,6 +753,8 @@ export class PathEditLayer extends Layer {
|
|
|
438
753
|
// 选中一个 path 路径
|
|
439
754
|
if (!this.currentPathNode ||
|
|
440
755
|
selectNodes[0].id !== this.currentPathNode.id) {
|
|
756
|
+
// 清空上个 path 的 history
|
|
757
|
+
this.clearHistory();
|
|
441
758
|
// 选中的不是当前的 path 路径, 切换 currentPathNode;
|
|
442
759
|
this.currentPathNode = selectNodes[0];
|
|
443
760
|
if (this.currentPathNode.useAnimationId &&
|
|
@@ -456,6 +773,7 @@ export class PathEditLayer extends Layer {
|
|
|
456
773
|
this.currentPathNode.path.closed
|
|
457
774
|
? pathPointSelection.enterSelectBezierMode(selectionNode)
|
|
458
775
|
: pathPointSelection.enterPathMode(selectionNode);
|
|
776
|
+
this.createHistory();
|
|
459
777
|
// this.updateNodePathData();
|
|
460
778
|
}
|
|
461
779
|
return;
|
|
@@ -510,13 +828,18 @@ export class PathEditLayer extends Layer {
|
|
|
510
828
|
if (!this.currentPathNode) {
|
|
511
829
|
this.currentPathNode = this.document.createDisplayNode(GameObjectBaseType.PATH, undefined, { x: 0, y: 0 });
|
|
512
830
|
this.currentPathNode.selected = true;
|
|
831
|
+
this.currentPathNode.path.paths = [];
|
|
513
832
|
this.context.selection.clearSelection();
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
833
|
+
setTimeout(() => {
|
|
834
|
+
this.context.selection.addSelection({
|
|
835
|
+
node: this.currentPathNode,
|
|
836
|
+
type: TreeSelection.SelectionType.TOGGLE,
|
|
837
|
+
});
|
|
517
838
|
});
|
|
518
839
|
}
|
|
519
|
-
|
|
840
|
+
// 把空数组先插入历史;
|
|
841
|
+
this.createHistory();
|
|
842
|
+
// this.currentPathNode.path.paths = this.currentPathNode.path.paths || []; // array 会被复用,复制一个,保证不会被修改
|
|
520
843
|
if (this.isOnePoint() && this.currentPathNode.path.paths.length > 1) {
|
|
521
844
|
// 第一帧
|
|
522
845
|
this.currentPathNode.path.paths.unshift(pos);
|
|
@@ -529,16 +852,6 @@ export class PathEditLayer extends Layer {
|
|
|
529
852
|
// this.updateNodeData();
|
|
530
853
|
// });
|
|
531
854
|
}
|
|
532
|
-
onBezierPointMove(pos) {
|
|
533
|
-
const { key, path: p } = this.bezierStartPos;
|
|
534
|
-
const { path = { paths: [] } } = this.currentPathNode || {};
|
|
535
|
-
const pathNode = path.paths.find(c => c.id === p.id);
|
|
536
|
-
if (!pathNode || !this.currentPathNode) {
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
setBezierMovePoint(pathNode, key, pos);
|
|
540
|
-
this.updateNodeData();
|
|
541
|
-
}
|
|
542
855
|
onBezierPointMouseDown(e, p, key) {
|
|
543
856
|
if (e.buttons !== 1) {
|
|
544
857
|
return;
|
|
@@ -562,7 +875,7 @@ export class PathEditLayer extends Layer {
|
|
|
562
875
|
onDrag: e => {
|
|
563
876
|
var _a, _b;
|
|
564
877
|
if (this.bezierStartPos) {
|
|
565
|
-
const { position = { x: 0, y: 0 }, scale = { x: 1, y: 1 }, rotation = 0, } = this.currentPathNode || {};
|
|
878
|
+
const { position = { x: 0, y: 0 }, scale = { x: 1, y: 1 }, rotation = 0, path = { paths: [] }, } = this.currentPathNode || {};
|
|
566
879
|
const offset = this.getBoundsOffset();
|
|
567
880
|
let x = e.endPos.x / (((_a = this.config) === null || _a === void 0 ? void 0 : _a.finalScale) || 1) - position.x - offset.x;
|
|
568
881
|
let y = e.endPos.y / (((_b = this.config) === null || _b === void 0 ? void 0 : _b.finalScale) || 1) - position.y - offset.y;
|
|
@@ -573,7 +886,12 @@ export class PathEditLayer extends Layer {
|
|
|
573
886
|
const { x: currentX, y: currentY } = inverseTransformToData({ x, y }, { scale, rotation }, center);
|
|
574
887
|
x = currentX;
|
|
575
888
|
y = currentY;
|
|
576
|
-
|
|
889
|
+
const pathNode = path.paths.find(c => c.id === p.id);
|
|
890
|
+
if (!pathNode) {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
setBezierMovePoint(pathNode, key, { x, y }, { shiftKey: this.shiftKey, ctrlKey: this.ctrlKey });
|
|
894
|
+
this.updateNodeData(true);
|
|
577
895
|
}
|
|
578
896
|
},
|
|
579
897
|
onDragEnd: () => {
|
|
@@ -590,6 +908,7 @@ export class PathEditLayer extends Layer {
|
|
|
590
908
|
]);
|
|
591
909
|
}
|
|
592
910
|
}
|
|
911
|
+
this.updateNodeData();
|
|
593
912
|
},
|
|
594
913
|
});
|
|
595
914
|
this.draw();
|
|
@@ -602,16 +921,13 @@ export class PathEditLayer extends Layer {
|
|
|
602
921
|
}
|
|
603
922
|
return event;
|
|
604
923
|
}
|
|
605
|
-
|
|
606
|
-
if (e.buttons !== 1) {
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
924
|
+
selectionChange(currentPoint) {
|
|
609
925
|
// 如果在 selection 里拖动所有点, 没有则切换当前 selection 里的点
|
|
610
926
|
const { pathPointSelection } = this;
|
|
611
927
|
if (!pathPointSelection) {
|
|
612
928
|
return;
|
|
613
929
|
}
|
|
614
|
-
|
|
930
|
+
const selection = (pathPointSelection === null || pathPointSelection === void 0 ? void 0 : pathPointSelection.selection) || [];
|
|
615
931
|
const node = this.currentPathNode;
|
|
616
932
|
const selectionNode = [
|
|
617
933
|
{
|
|
@@ -654,12 +970,20 @@ export class PathEditLayer extends Layer {
|
|
|
654
970
|
}
|
|
655
971
|
}
|
|
656
972
|
}
|
|
973
|
+
}
|
|
974
|
+
onPointMouseDown(e, currentPoint) {
|
|
975
|
+
if (e.buttons !== 1) {
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
this.selectionChange(currentPoint);
|
|
979
|
+
const node = this.currentPathNode;
|
|
657
980
|
const startNodeClone = deepClone(node.path.paths);
|
|
658
981
|
this.startDrag(e.clientX, e.clientY, {
|
|
659
982
|
// 拖动
|
|
660
983
|
onDrag: dragEvent => {
|
|
661
984
|
var _a, _b;
|
|
662
|
-
|
|
985
|
+
const { pathPointSelection } = this;
|
|
986
|
+
const selection = (pathPointSelection === null || pathPointSelection === void 0 ? void 0 : pathPointSelection.selection) || [];
|
|
663
987
|
const selectionNodes = selection
|
|
664
988
|
.map(s => node.path.paths.find(p => p.id === s.pointId))
|
|
665
989
|
.filter(c => c);
|
|
@@ -695,50 +1019,83 @@ export class PathEditLayer extends Layer {
|
|
|
695
1019
|
const d = delta[i];
|
|
696
1020
|
const deltaX = x - start.x + d.x;
|
|
697
1021
|
const deltaY = y - start.y + d.y;
|
|
1022
|
+
const max = Math.max(Math.abs(deltaX), Math.abs(deltaY));
|
|
1023
|
+
const isX = max === Math.abs(deltaX);
|
|
1024
|
+
const isY = max === Math.abs(deltaY);
|
|
1025
|
+
const noX = this.shiftKey && !isX;
|
|
1026
|
+
const noY = this.shiftKey && !isY;
|
|
698
1027
|
if (typeof p.x1 === 'number') {
|
|
699
|
-
p.x1 = toFixedValue(start.x1 + deltaX, 2);
|
|
1028
|
+
p.x1 = noX ? start.x1 : toFixedValue(start.x1 + deltaX, 2);
|
|
700
1029
|
}
|
|
701
1030
|
if (typeof p.x2 === 'number') {
|
|
702
|
-
p.x2 = toFixedValue(start.x2 + deltaX, 2);
|
|
1031
|
+
p.x2 = noX ? start.x2 : toFixedValue(start.x2 + deltaX, 2);
|
|
703
1032
|
}
|
|
704
1033
|
if (typeof p.y1 === 'number') {
|
|
705
|
-
p.y1 = toFixedValue(start.y1 + deltaY, 2);
|
|
1034
|
+
p.y1 = noY ? start.y1 : toFixedValue(start.y1 + deltaY, 2);
|
|
706
1035
|
}
|
|
707
1036
|
if (typeof p.y2 === 'number') {
|
|
708
|
-
p.y2 = toFixedValue(start.y2 + deltaY, 2);
|
|
1037
|
+
p.y2 = noY ? start.y2 : toFixedValue(start.y2 + deltaY, 2);
|
|
709
1038
|
}
|
|
710
|
-
p.x = toFixedValue(x + d.x, 2);
|
|
711
|
-
p.y = toFixedValue(y + d.y, 2);
|
|
1039
|
+
p.x = noX ? start.x : toFixedValue(x + d.x, 2);
|
|
1040
|
+
p.y = noY ? start.y : toFixedValue(y + d.y, 2);
|
|
712
1041
|
});
|
|
1042
|
+
this.updateNodeData(true);
|
|
1043
|
+
},
|
|
1044
|
+
onDragEnd: () => {
|
|
713
1045
|
this.updateNodeData();
|
|
714
1046
|
},
|
|
715
1047
|
});
|
|
716
1048
|
this.draw();
|
|
717
1049
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
const { path, position = { x: 0, y: 0 }, scale = { x: 1, y: 1 }, rotation = 0, } = this.currentPathNode || {};
|
|
723
|
-
const { paths = [] } = path;
|
|
724
|
-
const p = this.getPosFromMouseEvent(e);
|
|
1050
|
+
// 画布坐标转换成 path 坐标;
|
|
1051
|
+
canvasPosToPathPos(p) {
|
|
1052
|
+
const { position = { x: 0, y: 0 }, scale = { x: 1, y: 1 }, rotation = 0 } = this.currentPathNode || {};
|
|
725
1053
|
const offset = this.getBoundsOffset();
|
|
726
|
-
let x = p.x - position.x - offset.x;
|
|
727
|
-
let y = p.y - position.y - offset.y;
|
|
728
1054
|
const center = {
|
|
729
1055
|
x: -offset.x,
|
|
730
1056
|
y: -offset.y,
|
|
731
1057
|
};
|
|
1058
|
+
let x = p.x - position.x - offset.x;
|
|
1059
|
+
let y = p.y - position.y - offset.y;
|
|
732
1060
|
const { x: currentX, y: currentY } = inverseTransformToData({ x, y }, { scale, rotation }, center);
|
|
733
1061
|
x = currentX;
|
|
734
1062
|
y = currentY;
|
|
735
|
-
|
|
1063
|
+
return {
|
|
736
1064
|
x,
|
|
737
1065
|
y,
|
|
738
1066
|
};
|
|
1067
|
+
}
|
|
1068
|
+
pathPosToCanvasPos(c) {
|
|
1069
|
+
const { position = { x: 0, y: 0 }, scale = { x: 1, y: 1 }, rotation = 0 } = this.currentPathNode || {};
|
|
1070
|
+
const offset = this.getBoundsOffset();
|
|
1071
|
+
const center = {
|
|
1072
|
+
x: -offset.x,
|
|
1073
|
+
y: -offset.y,
|
|
1074
|
+
};
|
|
1075
|
+
const { x, y } = transformToData({ x: c.x, y: c.y }, { scale, rotation }, center);
|
|
1076
|
+
return {
|
|
1077
|
+
x: x + position.x + offset.x,
|
|
1078
|
+
y: y + position.y + offset.y,
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
getPathMousePos(e) {
|
|
1082
|
+
var _a, _b;
|
|
1083
|
+
const p = this.getPosFromMouseEvent({
|
|
1084
|
+
clientX: (_a = e.clientX) !== null && _a !== void 0 ? _a : 0,
|
|
1085
|
+
clientY: (_b = e.clientY) !== null && _b !== void 0 ? _b : 0,
|
|
1086
|
+
});
|
|
1087
|
+
return this.canvasPosToPathPos(p);
|
|
1088
|
+
}
|
|
1089
|
+
onPathAddPoint(i, e) {
|
|
1090
|
+
if (!this.currentPathNode || !this.document) {
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
const { path } = this.currentPathNode || {};
|
|
1094
|
+
const { paths = [] } = path;
|
|
1095
|
+
const pos = this.getPathMousePos(e);
|
|
739
1096
|
const point = paths[i];
|
|
740
1097
|
const nextPoint = paths[i + 1] ? paths[i + 1] : paths[0];
|
|
741
|
-
const newPoint = getNewPoint(point, nextPoint, pos);
|
|
1098
|
+
const newPoint = getNewPoint(point, nextPoint, pos, this.shiftKey);
|
|
742
1099
|
paths.splice(i + 1, 0, newPoint);
|
|
743
1100
|
this.pathPointSelection.enterPathMode([
|
|
744
1101
|
{
|
|
@@ -778,7 +1135,7 @@ export class PathEditLayer extends Layer {
|
|
|
778
1135
|
y: -offset.y,
|
|
779
1136
|
};
|
|
780
1137
|
const paths = [...p].map(c => {
|
|
781
|
-
const item = Object.assign(
|
|
1138
|
+
const item = Object.assign({}, c);
|
|
782
1139
|
const { x, y } = transformToData({ x: c.x, y: c.y }, { scale, rotation }, center);
|
|
783
1140
|
item.x = x + position.x + offset.x;
|
|
784
1141
|
item.y = y + position.y + offset.y;
|
|
@@ -800,8 +1157,10 @@ export class PathEditLayer extends Layer {
|
|
|
800
1157
|
onBezierPointMouseDown: this.onBezierPointMouseDown.bind(this),
|
|
801
1158
|
onClosePath: this.onClosePath.bind(this),
|
|
802
1159
|
onPathAddPoint: this.onPathAddPoint.bind(this),
|
|
1160
|
+
isShiftKey: this.shiftKey,
|
|
1161
|
+
isCtrlKey: this.ctrlKey,
|
|
803
1162
|
} },
|
|
804
|
-
React.createElement(SvgPath, { width: ((_b = this.config.config.pageBounds) === null || _b === void 0 ? void 0 : _b.width) || 300, height: ((_c = this.config.config.pageBounds) === null || _c === void 0 ? void 0 : _c.height) || 300, getPosFromMouseEvent: this.getPosFromMouseEvent.bind(this), node: this.currentPathNode, paths: paths, selection: (_d = this.pathPointSelection) === null || _d === void 0 ? void 0 : _d.selection, selectMode: (_e = this.pathPointSelection) === null || _e === void 0 ? void 0 : _e.selectMode, getPointIsStartOrEnd: this.getPointIsStartOrEnd.bind(this), scale: this.config.finalScale })));
|
|
1163
|
+
React.createElement(SvgPath, { width: ((_b = this.config.config.pageBounds) === null || _b === void 0 ? void 0 : _b.width) || 300, height: ((_c = this.config.config.pageBounds) === null || _c === void 0 ? void 0 : _c.height) || 300, getPosFromMouseEvent: this.getPosFromMouseEvent.bind(this), node: this.currentPathNode, showAllBezier: this.altKey, paths: paths, selection: (_d = this.pathPointSelection) === null || _d === void 0 ? void 0 : _d.selection, selectMode: (_e = this.pathPointSelection) === null || _e === void 0 ? void 0 : _e.selectMode, getPointIsStartOrEnd: this.getPointIsStartOrEnd.bind(this), onUpdateNodeData: this.updateNodeData.bind(this), scale: this.config.finalScale, getPathMousePos: this.getPathMousePos.bind(this), pathPosToCanvasPos: this.pathPosToCanvasPos.bind(this) })));
|
|
805
1164
|
}
|
|
806
1165
|
}
|
|
807
1166
|
__decorate([
|