@leafer-in/editor 1.0.0-rc.9 → 1.0.0

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/dist/editor.js CHANGED
@@ -1,7 +1,199 @@
1
1
  this.LeaferIN = this.LeaferIN || {};
2
- this.LeaferIN.editor = (function (exports, core) {
2
+ this.LeaferIN.editor = (function (exports, draw, core) {
3
3
  'use strict';
4
4
 
5
+ const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = draw.PathCommandMap;
6
+ const PathScaler = {
7
+ scale(data, scaleX, scaleY) {
8
+ if (!data)
9
+ return;
10
+ let command;
11
+ let i = 0, len = data.length;
12
+ while (i < len) {
13
+ command = data[i];
14
+ switch (command) {
15
+ case M:
16
+ scalePoints(data, scaleX, scaleY, i, 1);
17
+ i += 3;
18
+ break;
19
+ case L:
20
+ scalePoints(data, scaleX, scaleY, i, 1);
21
+ i += 3;
22
+ break;
23
+ case C:
24
+ scalePoints(data, scaleX, scaleY, i, 3);
25
+ i += 7;
26
+ break;
27
+ case Q:
28
+ scalePoints(data, scaleX, scaleY, i, 2);
29
+ i += 5;
30
+ break;
31
+ case Z:
32
+ i += 1;
33
+ break;
34
+ case N:
35
+ scalePoints(data, scaleX, scaleY, i, 2);
36
+ i += 5;
37
+ break;
38
+ case D:
39
+ scalePoints(data, scaleX, scaleY, i, 2);
40
+ i += 9;
41
+ break;
42
+ case X:
43
+ scalePoints(data, scaleX, scaleY, i, 2);
44
+ i += 6;
45
+ break;
46
+ case G:
47
+ scalePoints(data, scaleX, scaleY, i, 2);
48
+ i += 9;
49
+ break;
50
+ case F:
51
+ scalePoints(data, scaleX, scaleY, i, 2);
52
+ i += 5;
53
+ break;
54
+ case O:
55
+ data[i] = G;
56
+ data.splice(i + 4, 0, data[i + 3], 0);
57
+ scalePoints(data, scaleX, scaleY, i, 2);
58
+ i += 7 + 2;
59
+ len += 2;
60
+ break;
61
+ case P:
62
+ data[i] = F;
63
+ data.splice(i + 4, 0, data[i + 3]);
64
+ scalePoints(data, scaleX, scaleY, i, 2);
65
+ i += 4 + 1;
66
+ len += 1;
67
+ break;
68
+ case U:
69
+ scalePoints(data, scaleX, scaleY, i, 2);
70
+ i += 6;
71
+ break;
72
+ }
73
+ }
74
+ },
75
+ scalePoints(data, scaleX, scaleY, start, pointCount) {
76
+ for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
77
+ data[i] *= scaleX;
78
+ data[i + 1] *= scaleY;
79
+ }
80
+ }
81
+ };
82
+ const { scalePoints } = PathScaler;
83
+
84
+ const matrix$1 = draw.MatrixHelper.get();
85
+ function scaleResize(leaf, scaleX, scaleY) {
86
+ if (leaf.pathInputed) {
87
+ scaleResizePath(leaf, scaleX, scaleY);
88
+ }
89
+ else {
90
+ if (scaleX !== 1)
91
+ leaf.width *= scaleX;
92
+ if (scaleY !== 1)
93
+ leaf.height *= scaleY;
94
+ }
95
+ }
96
+ function scaleResizeFontSize(leaf, scaleX, scaleY) {
97
+ const { width, height } = leaf.__localBoxBounds;
98
+ if (scaleX !== 1) {
99
+ leaf.fontSize *= scaleX;
100
+ leaf.y -= height * (scaleX - scaleY) / 2;
101
+ }
102
+ else if (scaleY !== 1) {
103
+ leaf.fontSize *= scaleY;
104
+ leaf.x -= width * (scaleY - scaleX) / 2;
105
+ }
106
+ }
107
+ function scaleResizePath(leaf, scaleX, scaleY) {
108
+ PathScaler.scale(leaf.__.path, scaleX, scaleY);
109
+ leaf.path = leaf.__.path;
110
+ }
111
+ function scaleResizePoints(leaf, scaleX, scaleY) {
112
+ PathScaler.scalePoints(leaf.__.points, scaleX, scaleY);
113
+ leaf.points = leaf.__.points;
114
+ }
115
+ function scaleResizeGroup(group, scaleX, scaleY) {
116
+ const { children } = group;
117
+ for (let i = 0; i < children.length; i++) {
118
+ matrix$1.a = scaleX;
119
+ matrix$1.d = scaleY;
120
+ children[i].transform(matrix$1, true);
121
+ }
122
+ }
123
+
124
+ const leaf = draw.Leaf.prototype;
125
+ leaf.scaleResize = function (scaleX, scaleY = scaleX, noResize) {
126
+ const data = this;
127
+ if (noResize || (data.editConfig && data.editConfig.editSize === 'scale')) {
128
+ data.scaleX *= scaleX;
129
+ data.scaleY *= scaleY;
130
+ }
131
+ else {
132
+ if (scaleX < 0)
133
+ data.scaleX *= -1, scaleX = -scaleX;
134
+ if (scaleY < 0)
135
+ data.scaleY *= -1, scaleY = -scaleY;
136
+ this.__scaleResize(scaleX, scaleY);
137
+ }
138
+ };
139
+ leaf.__scaleResize = function (scaleX, scaleY) {
140
+ scaleResize(this, scaleX, scaleY);
141
+ };
142
+ leaf.resizeWidth = function (width) {
143
+ const scale = width / this.getBounds('box', 'local').width;
144
+ this.scaleOf(this.__layout.boxBounds, scale, this.__.lockRatio ? scale : 1, true);
145
+ };
146
+ leaf.resizeHeight = function (height) {
147
+ const scale = height / this.getBounds('box', 'local').height;
148
+ this.scaleOf(this.__layout.boxBounds, this.__.lockRatio ? scale : 1, scale, true);
149
+ };
150
+ draw.Text.prototype.__scaleResize = function (scaleX, scaleY) {
151
+ if (this.__.__autoSize && (this.__.resizeFontSize || (this.editConfig && this.editConfig.editSize === 'font-size'))) {
152
+ scaleResizeFontSize(this, scaleX, scaleY);
153
+ }
154
+ else {
155
+ scaleResize(this, scaleX, scaleY);
156
+ }
157
+ };
158
+ draw.Path.prototype.__scaleResize = function (scaleX, scaleY) {
159
+ scaleResizePath(this, scaleX, scaleY);
160
+ };
161
+ draw.Line.prototype.__scaleResize = function (scaleX, scaleY) {
162
+ if (this.pathInputed) {
163
+ scaleResizePath(this, scaleX, scaleY);
164
+ }
165
+ else if (this.points) {
166
+ scaleResizePoints(this, scaleX, scaleY);
167
+ }
168
+ else {
169
+ this.width *= scaleX;
170
+ }
171
+ };
172
+ draw.Polygon.prototype.__scaleResize = function (scaleX, scaleY) {
173
+ if (this.pathInputed) {
174
+ scaleResizePath(this, scaleX, scaleY);
175
+ }
176
+ else if (this.points) {
177
+ scaleResizePoints(this, scaleX, scaleY);
178
+ }
179
+ else {
180
+ scaleResize(this, scaleX, scaleY);
181
+ }
182
+ };
183
+ draw.Group.prototype.__scaleResize = function (scaleX, scaleY) {
184
+ scaleResizeGroup(this, scaleX, scaleY);
185
+ };
186
+ draw.Box.prototype.__scaleResize = function (scaleX, scaleY) {
187
+ if (this.__.__autoSize && this.children.length) {
188
+ scaleResizeGroup(this, scaleX, scaleY);
189
+ }
190
+ else {
191
+ scaleResize(this, scaleX, scaleY);
192
+ if (this.__.resizeChildren)
193
+ scaleResizeGroup(this, scaleX, scaleY);
194
+ }
195
+ };
196
+
5
197
  /******************************************************************************
6
198
  Copyright (c) Microsoft Corporation.
7
199
 
@@ -31,7 +223,12 @@ this.LeaferIN.editor = (function (exports, core) {
31
223
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
224
  };
33
225
 
34
- class EditorEvent extends core.Event {
226
+ function toList(value) {
227
+ return value ? (value instanceof Array ? value : [value]) : [];
228
+ }
229
+ class EditorEvent extends draw.Event {
230
+ get list() { return toList(this.value); }
231
+ get oldList() { return toList(this.oldValue); }
35
232
  constructor(type, data) {
36
233
  super(type);
37
234
  if (data)
@@ -72,7 +269,7 @@ this.LeaferIN.editor = (function (exports, core) {
72
269
  function targetAttr(fn) {
73
270
  return (target, key) => {
74
271
  const privateKey = '_' + key;
75
- core.defineKey(target, key, {
272
+ draw.defineKey(target, key, {
76
273
  get() { return this[privateKey]; },
77
274
  set(value) {
78
275
  const old = this[privateKey];
@@ -83,10 +280,10 @@ this.LeaferIN.editor = (function (exports, core) {
83
280
  };
84
281
  }
85
282
 
86
- const matrix = core.MatrixHelper.get();
283
+ const matrix = draw.MatrixHelper.get();
87
284
  const { abs } = Math;
88
- const { copy, scale } = core.MatrixHelper;
89
- class Stroker extends core.UI {
285
+ const { copy: copy$1, scale } = draw.MatrixHelper;
286
+ class Stroker extends draw.UI {
90
287
  constructor() {
91
288
  super();
92
289
  this.list = [];
@@ -94,40 +291,43 @@ this.LeaferIN.editor = (function (exports, core) {
94
291
  this.strokeAlign = 'center';
95
292
  }
96
293
  setTarget(target, style) {
97
- const { stroke, strokeWidth } = style;
98
- this.set({ stroke, strokeWidth });
294
+ this.set(style);
99
295
  this.target = target;
100
296
  }
101
297
  __draw(canvas, options) {
102
298
  const { list } = this;
103
299
  if (list.length) {
104
300
  let leaf;
105
- const { stroke, strokeWidth } = this.__;
301
+ const { stroke, strokeWidth, fill } = this.__;
106
302
  const { bounds } = options;
107
303
  for (let i = 0; i < list.length; i++) {
108
304
  leaf = list[i];
109
305
  if (bounds && bounds.hit(leaf.__world, options.matrix)) {
110
- let drewPath;
111
- if (leaf.__.editSize === 'scale') {
112
- const aScaleX = abs(leaf.__world.scaleX), aScaleY = abs(leaf.__world.scaleY);
113
- if (aScaleX !== aScaleY) {
114
- copy(matrix, leaf.__world);
115
- scale(matrix, 1 / aScaleX, 1 / aScaleY);
116
- canvas.setWorld(matrix, options.matrix);
117
- canvas.beginPath();
118
- this.__.strokeWidth = strokeWidth;
119
- const { x, y, width, height } = leaf.__layout.boxBounds;
120
- canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
121
- drewPath = true;
122
- }
306
+ const aScaleX = abs(leaf.__world.scaleX), aScaleY = abs(leaf.__world.scaleY);
307
+ if (aScaleX !== aScaleY) {
308
+ copy$1(matrix, leaf.__world);
309
+ scale(matrix, 1 / aScaleX, 1 / aScaleY);
310
+ canvas.setWorld(matrix, options.matrix);
311
+ canvas.beginPath();
312
+ this.__.strokeWidth = strokeWidth;
313
+ const { x, y, width, height } = leaf.__layout.boxBounds;
314
+ canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
123
315
  }
124
- if (!drewPath) {
316
+ else {
125
317
  canvas.setWorld(leaf.__world, options.matrix);
126
318
  canvas.beginPath();
127
- leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
319
+ if (leaf.__.__useArrow) {
320
+ leaf.__drawPath(canvas);
321
+ }
322
+ else {
323
+ leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
324
+ }
128
325
  this.__.strokeWidth = strokeWidth / abs(leaf.__world.scaleX);
129
326
  }
130
- typeof stroke === 'string' ? core.Paint.stroke(stroke, this, canvas, options) : core.Paint.strokes(stroke, this, canvas, options);
327
+ if (stroke)
328
+ typeof stroke === 'string' ? draw.Paint.stroke(stroke, this, canvas) : draw.Paint.strokes(stroke, this, canvas);
329
+ if (fill)
330
+ typeof fill === 'string' ? draw.Paint.fill(fill, this, canvas) : draw.Paint.fills(fill, this, canvas);
131
331
  }
132
332
  }
133
333
  this.__.strokeWidth = strokeWidth;
@@ -147,11 +347,11 @@ this.LeaferIN.editor = (function (exports, core) {
147
347
  stroker.forceUpdate();
148
348
  }
149
349
 
150
- class SelectArea extends core.Group {
350
+ class SelectArea extends draw.Group {
151
351
  constructor(data) {
152
352
  super(data);
153
- this.strokeArea = new core.Rect({ strokeAlign: 'center' });
154
- this.fillArea = new core.Rect();
353
+ this.strokeArea = new draw.Rect({ strokeAlign: 'center' });
354
+ this.fillArea = new draw.Rect();
155
355
  this.visible = this.hittable = false;
156
356
  this.addMany(this.fillArea, this.strokeArea);
157
357
  }
@@ -167,21 +367,13 @@ this.LeaferIN.editor = (function (exports, core) {
167
367
  }
168
368
  }
169
369
 
170
- var AnswerType;
171
- (function (AnswerType) {
172
- AnswerType[AnswerType["No"] = 0] = "No";
173
- AnswerType[AnswerType["Yes"] = 1] = "Yes";
174
- AnswerType[AnswerType["NoAndSkip"] = 2] = "NoAndSkip";
175
- AnswerType[AnswerType["YesAndSkip"] = 3] = "YesAndSkip";
176
- })(AnswerType || (AnswerType = {}));
177
-
178
- const { No, Yes, NoAndSkip, YesAndSkip } = AnswerType;
370
+ const { No, Yes, NoAndSkip, YesAndSkip } = draw.Answer;
179
371
  const EditSelectHelper = {
180
372
  findOne(path) {
181
373
  return path.list.find((leaf) => leaf.editable);
182
374
  },
183
375
  findBounds(leaf, bounds) {
184
- if (leaf.__.hittable && !leaf.__.locked && bounds.hit(leaf.__world)) {
376
+ if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
185
377
  if (leaf.__.editable) {
186
378
  if (leaf.isBranch && !leaf.__.hitChildren) {
187
379
  return leaf.__.hitSelf ? YesAndSkip : NoAndSkip;
@@ -203,15 +395,15 @@ this.LeaferIN.editor = (function (exports, core) {
203
395
  };
204
396
 
205
397
  const { findOne } = EditSelectHelper;
206
- class EditSelect extends core.Group {
398
+ class EditSelect extends draw.Group {
207
399
  get dragging() { return !!this.originList; }
208
- get running() { return this.editor.hittable && this.editor.config.selector; }
400
+ get running() { const { editor } = this; return this.hittable && editor.visible && editor.hittable && editor.mergeConfig.selector; }
209
401
  get isMoveMode() { return this.app && this.app.interaction.moveMode; }
210
402
  constructor(editor) {
211
403
  super();
212
404
  this.hoverStroker = new Stroker();
213
405
  this.targetStroker = new Stroker();
214
- this.bounds = new core.Bounds();
406
+ this.bounds = new draw.Bounds();
215
407
  this.selectArea = new SelectArea();
216
408
  this.__eventIds = [];
217
409
  this.editor = editor;
@@ -221,8 +413,8 @@ this.LeaferIN.editor = (function (exports, core) {
221
413
  onHover() {
222
414
  const { editor } = this;
223
415
  if (this.running && !this.dragging && !editor.dragging) {
224
- const { stroke, strokeWidth, hover } = editor.config;
225
- this.hoverStroker.setTarget(hover ? this.editor.hoverTarget : null, { stroke, strokeWidth });
416
+ const { stroke, strokeWidth, hover, hoverStyle } = editor.mergeConfig;
417
+ this.hoverStroker.setTarget(hover ? this.editor.hoverTarget : null, Object.assign({ stroke, strokeWidth }, (hoverStyle || {})));
226
418
  }
227
419
  else {
228
420
  this.hoverStroker.target = null;
@@ -230,62 +422,72 @@ this.LeaferIN.editor = (function (exports, core) {
230
422
  }
231
423
  onSelect() {
232
424
  if (this.running) {
233
- const { config, list } = this.editor;
425
+ const { mergeConfig: config, list } = this.editor;
234
426
  const { stroke, strokeWidth } = config;
235
427
  this.targetStroker.setTarget(list, { stroke, strokeWidth: Math.max(1, strokeWidth / 2) });
236
428
  this.hoverStroker.target = null;
237
429
  }
238
430
  }
239
431
  update() {
240
- if (this.running)
432
+ if (this.targetStroker.target)
241
433
  this.targetStroker.forceUpdate();
242
434
  }
243
435
  onPointerMove(e) {
244
- if (this.running && !this.isMoveMode) {
245
- const find = e.shiftKey ? this.findDeepOne(e) : findOne(e.path);
246
- this.editor.hoverTarget = this.editor.hasItem(find) ? null : find;
436
+ const { app, editor } = this;
437
+ if (this.running && !this.isMoveMode && app.config.pointer.hover && !app.interaction.dragging) {
438
+ const find = this.findUI(e);
439
+ editor.hoverTarget = editor.hasItem(find) ? null : find;
247
440
  }
248
441
  if (this.isMoveMode) {
249
- this.editor.hoverTarget = null;
442
+ editor.hoverTarget = null;
250
443
  }
251
444
  }
252
445
  onBeforeDown(e) {
253
- if (this.running && !this.isMoveMode && !e.middle) {
254
- const find = this.lastDownLeaf = findOne(e.path);
446
+ const { select } = this.editor.mergeConfig;
447
+ if (select === 'press')
448
+ this.checkAndSelect(e);
449
+ }
450
+ onTap(e) {
451
+ const { editor } = this;
452
+ const { select } = editor.mergeConfig;
453
+ if (select === 'tap')
454
+ this.checkAndSelect(e);
455
+ if (this.needRemoveItem) {
456
+ editor.removeItem(this.needRemoveItem);
457
+ }
458
+ else if (this.isMoveMode) {
459
+ editor.target = null;
460
+ }
461
+ }
462
+ checkAndSelect(e) {
463
+ this.needRemoveItem = null;
464
+ if (this.allowSelect(e)) {
465
+ const { editor } = this;
466
+ const find = this.findUI(e);
255
467
  if (find) {
256
- if (e.shiftKey) {
257
- this.editor.shiftItem(find);
468
+ if (this.isMultipleSelect(e)) {
469
+ if (editor.hasItem(find))
470
+ this.needRemoveItem = find;
471
+ else
472
+ editor.addItem(find);
258
473
  }
259
474
  else {
260
- this.editor.target = find;
475
+ editor.target = find;
261
476
  }
262
- this.editor.updateLayout();
263
- find.leafer.interaction.updateDownData();
264
477
  }
265
478
  else if (this.allow(e.target)) {
266
479
  if (!e.shiftKey)
267
- this.editor.target = null;
480
+ editor.target = null;
268
481
  }
269
482
  }
270
483
  }
271
- onTap(e) {
272
- if (this.running && e.shiftKey && !e.middle && !this.lastDownLeaf) {
273
- const find = this.findDeepOne(e);
274
- if (find)
275
- this.editor.shiftItem(find);
276
- }
277
- else if (this.isMoveMode) {
278
- this.editor.target = null;
279
- }
280
- this.lastDownLeaf = null;
281
- }
282
484
  onDragStart(e) {
283
- if (this.running && this.allowDrag(e)) {
485
+ if (this.allowDrag(e)) {
284
486
  const { editor } = this;
285
- const { stroke, strokeWidth, area } = editor.config;
487
+ const { stroke, area } = editor.mergeConfig;
286
488
  const { x, y } = e.getInner(this);
287
489
  this.bounds.set(x, y);
288
- this.selectArea.setStyle({ visible: true, stroke, strokeWidth, x, y }, area);
490
+ this.selectArea.setStyle({ visible: true, stroke, x, y }, area);
289
491
  this.selectArea.setBounds(this.bounds.get());
290
492
  this.originList = editor.leafList.clone();
291
493
  }
@@ -299,7 +501,7 @@ this.LeaferIN.editor = (function (exports, core) {
299
501
  const { editor } = this;
300
502
  const total = e.getInnerTotal(this);
301
503
  const dragBounds = this.bounds.clone().unsign();
302
- const list = new core.LeafList(editor.app.find(EditSelectHelper.findBounds, dragBounds));
504
+ const list = new draw.LeafList(editor.app.find(EditSelectHelper.findBounds, dragBounds));
303
505
  this.bounds.width = total.x;
304
506
  this.bounds.height = total.y;
305
507
  this.selectArea.setBounds(dragBounds.get());
@@ -315,8 +517,6 @@ this.LeaferIN.editor = (function (exports, core) {
315
517
  }
316
518
  else {
317
519
  editor.target = this.originList.list;
318
- if (editor.leafList.length)
319
- editor.update();
320
520
  }
321
521
  }
322
522
  }
@@ -335,17 +535,26 @@ this.LeaferIN.editor = (function (exports, core) {
335
535
  return target.leafer !== this.editor.leafer;
336
536
  }
337
537
  allowDrag(e) {
338
- if (this.editor.config.boxSelect && !e.target.draggable) {
339
- return (!this.editor.hasTarget && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
538
+ if (this.running && this.editor.mergeConfig.boxSelect && !e.target.draggable) {
539
+ return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
340
540
  }
341
541
  else {
342
542
  return false;
343
543
  }
344
544
  }
545
+ allowSelect(e) {
546
+ return this.running && !this.isMoveMode && !e.middle;
547
+ }
345
548
  findDeepOne(e) {
346
- const options = { exclude: new core.LeafList(this.editor.editBox.rect) };
549
+ const options = { exclude: new draw.LeafList(this.editor.editBox.rect) };
347
550
  return findOne(e.target.leafer.interaction.findPath(e, options));
348
551
  }
552
+ findUI(e) {
553
+ return this.isMultipleSelect(e) ? this.findDeepOne(e) : findOne(e.path);
554
+ }
555
+ isMultipleSelect(e) {
556
+ return e.shiftKey || this.editor.mergeConfig.continuousSelect;
557
+ }
349
558
  __listenEvents() {
350
559
  const { editor } = this;
351
560
  editor.waitLeafer(() => {
@@ -372,29 +581,17 @@ this.LeaferIN.editor = (function (exports, core) {
372
581
  }
373
582
  }
374
583
  destroy() {
375
- this.editor = this.originList = this.lastDownLeaf = null;
584
+ this.editor = this.originList = this.needRemoveItem = null;
376
585
  this.__removeListenEvents();
377
586
  super.destroy();
378
587
  }
379
588
  }
380
589
 
381
- var IDirection8;
382
- (function (IDirection8) {
383
- IDirection8[IDirection8["topLeft"] = 0] = "topLeft";
384
- IDirection8[IDirection8["top"] = 1] = "top";
385
- IDirection8[IDirection8["topRight"] = 2] = "topRight";
386
- IDirection8[IDirection8["right"] = 3] = "right";
387
- IDirection8[IDirection8["bottomRight"] = 4] = "bottomRight";
388
- IDirection8[IDirection8["bottom"] = 5] = "bottom";
389
- IDirection8[IDirection8["bottomLeft"] = 6] = "bottomLeft";
390
- IDirection8[IDirection8["left"] = 7] = "left";
391
- })(IDirection8 || (IDirection8 = {}));
392
-
393
- const { topLeft: topLeft$1, top: top$1, topRight: topRight$1, right: right$2, bottomRight: bottomRight$1, bottom: bottom$1, bottomLeft: bottomLeft$1, left: left$2 } = IDirection8;
394
- const { toPoint } = core.AroundHelper;
590
+ const { topLeft, top, topRight, right: right$1, bottomRight, bottom, bottomLeft, left: left$1 } = draw.Direction9;
591
+ const { toPoint } = draw.AroundHelper;
395
592
  const EditDataHelper = {
396
593
  getScaleData(bounds, direction, pointMove, lockRatio, around) {
397
- let origin, scaleX = 1, scaleY = 1;
594
+ let align, origin = {}, scaleX = 1, scaleY = 1;
398
595
  const { width, height } = bounds;
399
596
  if (around) {
400
597
  pointMove.x *= 2;
@@ -409,101 +606,103 @@ this.LeaferIN.editor = (function (exports, core) {
409
606
  const bottomScale = (pointMove.y + height) / height;
410
607
  const leftScale = (-pointMove.x + width) / width;
411
608
  switch (direction) {
412
- case top$1:
609
+ case top:
413
610
  scaleY = topScale;
414
- origin = { x: 0.5, y: 1 };
611
+ align = 'bottom';
415
612
  break;
416
- case right$2:
613
+ case right$1:
417
614
  scaleX = rightScale;
418
- origin = { x: 0, y: 0.5 };
615
+ align = 'left';
419
616
  break;
420
- case bottom$1:
617
+ case bottom:
421
618
  scaleY = bottomScale;
422
- origin = { x: 0.5, y: 0 };
619
+ align = 'top';
423
620
  break;
424
- case left$2:
621
+ case left$1:
425
622
  scaleX = leftScale;
426
- origin = { x: 1, y: 0.5 };
623
+ align = 'right';
427
624
  break;
428
- case topLeft$1:
625
+ case topLeft:
429
626
  scaleY = topScale;
430
627
  scaleX = leftScale;
431
- origin = { x: 1, y: 1 };
628
+ align = 'bottom-right';
432
629
  break;
433
- case topRight$1:
630
+ case topRight:
434
631
  scaleY = topScale;
435
632
  scaleX = rightScale;
436
- origin = { x: 0, y: 1 };
633
+ align = 'bottom-left';
437
634
  break;
438
- case bottomRight$1:
635
+ case bottomRight:
439
636
  scaleY = bottomScale;
440
637
  scaleX = rightScale;
441
- origin = { x: 0, y: 0 };
638
+ align = 'top-left';
442
639
  break;
443
- case bottomLeft$1:
640
+ case bottomLeft:
444
641
  scaleY = bottomScale;
445
642
  scaleX = leftScale;
446
- origin = { x: 1, y: 0 };
643
+ align = 'top-right';
447
644
  }
448
645
  if (lockRatio) {
449
- if (scaleX !== 1)
450
- scaleY = scaleX;
451
- else
452
- scaleX = scaleY;
646
+ const unlockSide = lockRatio === 'corner' && direction % 2;
647
+ if (!unlockSide) {
648
+ const scale = Math.sqrt(Math.abs(scaleX * scaleY));
649
+ scaleX = scaleX < 0 ? -scale : scale;
650
+ scaleY = scaleY < 0 ? -scale : scale;
651
+ }
453
652
  }
454
- toPoint(around || origin, bounds, origin);
653
+ toPoint(around || align, bounds, origin);
455
654
  return { origin, scaleX, scaleY, direction, lockRatio, around };
456
655
  },
457
656
  getRotateData(bounds, direction, current, last, around) {
458
- let origin;
657
+ let align, origin = {};
459
658
  switch (direction) {
460
- case topLeft$1:
461
- origin = { x: 1, y: 1 };
659
+ case topLeft:
660
+ align = 'bottom-right';
462
661
  break;
463
- case topRight$1:
464
- origin = { x: 0, y: 1 };
662
+ case topRight:
663
+ align = 'bottom-left';
465
664
  break;
466
- case bottomRight$1:
467
- origin = { x: 0, y: 0 };
665
+ case bottomRight:
666
+ align = 'top-left';
468
667
  break;
469
- case bottomLeft$1:
470
- origin = { x: 1, y: 0 };
668
+ case bottomLeft:
669
+ align = 'top-right';
471
670
  break;
472
671
  default:
473
- origin = { x: 0.5, y: 0.5 };
672
+ align = 'center';
474
673
  }
475
- toPoint(around || origin, bounds, origin);
476
- return { origin, rotation: core.PointHelper.getRotation(last, origin, current) };
674
+ toPoint(around || align, bounds, origin);
675
+ return { origin, rotation: draw.PointHelper.getRotation(last, origin, current) };
477
676
  },
478
677
  getSkewData(bounds, direction, move, around) {
479
- let origin, skewX = 0, skewY = 0;
678
+ let align, origin = {}, skewX = 0, skewY = 0;
480
679
  let last;
481
680
  switch (direction) {
482
- case top$1:
681
+ case top:
483
682
  last = { x: 0.5, y: 0 };
484
- origin = { x: 0.5, y: 1 };
683
+ align = 'bottom';
485
684
  skewX = 1;
486
685
  break;
487
- case bottom$1:
686
+ case bottom:
488
687
  last = { x: 0.5, y: 1 };
489
- origin = { x: 0.5, y: 0 };
688
+ align = 'top';
490
689
  skewX = 1;
491
690
  break;
492
- case left$2:
691
+ case left$1:
493
692
  last = { x: 0, y: 0.5 };
494
- origin = { x: 1, y: 0.5 };
693
+ align = 'right';
495
694
  skewY = 1;
496
695
  break;
497
- case right$2:
696
+ case right$1:
498
697
  last = { x: 1, y: 0.5 };
499
- origin = { x: 0, y: 0.5 };
698
+ align = 'left';
500
699
  skewY = 1;
501
700
  }
502
701
  const { x, y, width, height } = bounds;
503
702
  last.x = x + last.x * width;
504
703
  last.y = y + last.y * height;
505
- toPoint(around || origin, bounds, origin);
506
- const rotation = core.PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) });
704
+ toPoint(around || align, bounds, origin);
705
+ const rotation = draw.PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) });
507
706
  skewX ? skewX = -rotation : skewY = rotation;
508
707
  return { origin, skewX, skewY };
509
708
  },
@@ -515,69 +714,104 @@ this.LeaferIN.editor = (function (exports, core) {
515
714
  if (direction < 0)
516
715
  direction += totalDirection;
517
716
  return direction;
717
+ },
718
+ getFlipDirection(direction, flipedX, flipedY) {
719
+ if (flipedX) {
720
+ switch (direction) {
721
+ case left$1:
722
+ direction = right$1;
723
+ break;
724
+ case topLeft:
725
+ direction = topRight;
726
+ break;
727
+ case bottomLeft:
728
+ direction = bottomRight;
729
+ break;
730
+ case right$1:
731
+ direction = left$1;
732
+ break;
733
+ case topRight:
734
+ direction = topLeft;
735
+ break;
736
+ case bottomRight:
737
+ direction = bottomLeft;
738
+ break;
739
+ }
740
+ }
741
+ if (flipedY) {
742
+ switch (direction) {
743
+ case top:
744
+ direction = bottom;
745
+ break;
746
+ case topLeft:
747
+ direction = bottomLeft;
748
+ break;
749
+ case topRight:
750
+ direction = bottomRight;
751
+ break;
752
+ case bottom:
753
+ direction = top;
754
+ break;
755
+ case bottomLeft:
756
+ direction = topLeft;
757
+ break;
758
+ case bottomRight:
759
+ direction = topRight;
760
+ break;
761
+ }
762
+ }
763
+ return direction;
518
764
  }
519
765
  };
520
766
 
521
- const { topLeft, top, topRight, right: right$1, bottomRight, bottom, bottomLeft, left: left$1 } = IDirection8;
767
+ const cacheCursors = {};
522
768
  function updateCursor(editor, e) {
523
769
  const { editBox } = editor, point = editBox.enterPoint;
524
- if (!point || !editor.hasTarget || !editBox.visible)
770
+ if (!point || !editor.editing || !editBox.visible)
771
+ return;
772
+ if (point.name === 'circle')
525
773
  return;
526
774
  let { rotation } = editBox;
527
- let { resizeCursor, rotateCursor, resizeable, rotateable } = editor.config;
528
- const { direction, pointType } = point;
529
- editBox.enterPoint = point;
530
- const isResizePoint = pointType === 'resize';
531
- if (isResizePoint && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
532
- resizeCursor = rotateCursor;
533
- if (editBox.flipped) {
534
- const { flippedX, flippedY } = editBox;
535
- mirrorCursors(resizeCursor = [...resizeCursor], flippedX, flippedY);
536
- mirrorCursors(rotateCursor = [...rotateCursor], flippedY, flippedX);
537
- if (editBox.flippedOne)
538
- rotation = -rotation;
775
+ const { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editor.mergeConfig;
776
+ const { pointType } = point, { flippedX, flippedY } = editBox;
777
+ let showResize = pointType === 'resize';
778
+ if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
779
+ showResize = false;
780
+ const showSkew = skewable && !showResize && point.name === 'resize-line';
781
+ const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
782
+ rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
783
+ rotation = Math.round(draw.MathHelper.formatRotation(rotation, true) / 2) * 2;
784
+ const { url, x, y } = cursor;
785
+ const key = url + rotation;
786
+ if (cacheCursors[key]) {
787
+ point.cursor = cacheCursors[key];
788
+ }
789
+ else {
790
+ cacheCursors[key] = point.cursor = { url: toDataURL(url, rotation), x, y };
539
791
  }
540
- const index = EditDataHelper.getRotateDirection(direction, rotation);
541
- point.cursor = isResizePoint ? resizeCursor[index] : rotateCursor[index];
542
792
  }
543
793
  function updateMoveCursor(editor) {
544
- editor.editBox.rect.cursor = editor.config.moveCursor;
794
+ editor.editBox.rect.cursor = editor.mergeConfig.moveCursor;
545
795
  }
546
- function mirrorCursors(mirror, mirrorX, mirrorY) {
547
- if (mirrorX) {
548
- const topCursor = mirror[top], topLeftCursor = mirror[topLeft], topRightCursor = mirror[topRight];
549
- mirror[top] = mirror[bottom];
550
- mirror[topLeft] = mirror[bottomLeft];
551
- mirror[topRight] = mirror[bottomRight];
552
- mirror[bottom] = topCursor;
553
- mirror[bottomLeft] = topLeftCursor;
554
- mirror[bottomRight] = topRightCursor;
555
- }
556
- if (mirrorY) {
557
- const leftCursor = mirror[left$1], topLeftCursor = mirror[topLeft], bottomLeftCursor = mirror[bottomLeft];
558
- mirror[left$1] = mirror[right$1];
559
- mirror[topLeft] = mirror[topRight];
560
- mirror[bottomLeft] = mirror[bottomRight];
561
- mirror[right$1] = leftCursor;
562
- mirror[topRight] = topLeftCursor;
563
- mirror[bottomRight] = bottomLeftCursor;
564
- }
796
+ function toDataURL(svg, rotation) {
797
+ return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
565
798
  }
566
799
 
567
- class EditPoint extends core.Box {
800
+ class EditPoint extends draw.Box {
568
801
  }
569
802
 
570
803
  const fourDirection = ['top', 'right', 'bottom', 'left'];
571
- class EditBox extends core.Group {
804
+ class EditBox extends draw.Group {
572
805
  get flipped() { return this.flippedX || this.flippedY; }
573
806
  get flippedX() { return this.scaleX < 0; }
574
807
  get flippedY() { return this.scaleY < 0; }
575
808
  get flippedOne() { return this.scaleX * this.scaleY < 0; }
576
809
  constructor(editor) {
577
810
  super();
578
- this.rect = new core.Box({ name: 'rect', hitFill: 'all', hitStroke: 'none', strokeAlign: 'center', hitRadius: 5 });
579
- this.circle = new EditPoint({ name: 'circle', strokeAlign: 'outside', around: 'center', cursor: 'crosshair', hitRadius: 5 });
580
- this.buttons = new core.Group({ around: 'center', hitSelf: false });
811
+ this.view = new draw.Group();
812
+ this.rect = new draw.Box({ name: 'rect', hitFill: 'all', hitStroke: 'none', strokeAlign: 'center', hitRadius: 5 });
813
+ this.circle = new EditPoint({ name: 'circle', strokeAlign: 'center', around: 'center', cursor: 'crosshair', hitRadius: 5 });
814
+ this.buttons = new draw.Group({ around: 'center', hitSelf: false });
581
815
  this.resizePoints = [];
582
816
  this.rotatePoints = [];
583
817
  this.resizeLines = [];
@@ -585,14 +819,15 @@ this.LeaferIN.editor = (function (exports, core) {
585
819
  this.editor = editor;
586
820
  this.visible = false;
587
821
  this.create();
822
+ this.rect.syncEventer = editor;
588
823
  this.__listenEvents();
589
824
  }
590
825
  create() {
591
826
  let rotatePoint, resizeLine, resizePoint;
592
- const { resizePoints, rotatePoints, resizeLines, rect, circle, buttons } = this;
593
- const arounds = [{ x: 1, y: 1 }, { x: 0.5, y: 1 }, { x: 0, y: 1 }, { x: 0, y: 0.5 }, { x: 0, y: 0 }, { x: 0.5, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 0.5 }];
827
+ const { view, resizePoints, rotatePoints, resizeLines, rect, circle, buttons } = this;
828
+ const arounds = ['bottom-right', 'bottom', 'bottom-left', 'left', 'top-left', 'top', 'top-right', 'right'];
594
829
  for (let i = 0; i < 8; i++) {
595
- rotatePoint = new EditPoint({ around: arounds[i], width: 15, height: 15, hitFill: "all" });
830
+ rotatePoint = new EditPoint({ name: 'rotate-point', around: arounds[i], width: 15, height: 15, hitFill: "all" });
596
831
  rotatePoints.push(rotatePoint);
597
832
  this.listenPointEvents(rotatePoint, 'rotate', i);
598
833
  if (i % 2) {
@@ -600,58 +835,82 @@ this.LeaferIN.editor = (function (exports, core) {
600
835
  resizeLines.push(resizeLine);
601
836
  this.listenPointEvents(resizeLine, 'resize', i);
602
837
  }
603
- resizePoint = new EditPoint({ name: 'resize-point', around: 'center', strokeAlign: 'outside', hitRadius: 5 });
838
+ resizePoint = new EditPoint({ name: 'resize-point', hitRadius: 5 });
604
839
  resizePoints.push(resizePoint);
605
840
  this.listenPointEvents(resizePoint, 'resize', i);
606
841
  }
607
842
  buttons.add(circle);
608
843
  this.listenPointEvents(circle, 'rotate', 2);
609
- this.addMany(...rotatePoints, rect, buttons, ...resizeLines, ...resizePoints);
844
+ view.addMany(...rotatePoints, rect, buttons, ...resizeLines, ...resizePoints);
845
+ this.add(view);
610
846
  }
611
- update(bounds) {
612
- const { config, list } = this.editor;
613
- const { width, height } = bounds;
614
- const { rect, circle, resizePoints, rotatePoints, resizeLines } = this;
615
- const { middlePoint, resizeable, rotateable, stroke, strokeWidth } = config;
847
+ load() {
848
+ const { mergeConfig, element, single } = this.editor;
849
+ const { rect, circle, resizePoints } = this;
850
+ const { stroke, strokeWidth, moveable } = mergeConfig;
616
851
  const pointsStyle = this.getPointsStyle();
617
852
  const middlePointsStyle = this.getMiddlePointsStyle();
618
- this.visible = list[0] && !list[0].locked;
619
- let point = {}, style, rotateP, resizeP, resizeL;
853
+ let resizeP;
620
854
  for (let i = 0; i < 8; i++) {
621
- core.AroundHelper.toPoint(core.AroundHelper.directionData[i], bounds, point);
622
- style = this.getPointStyle((i % 2) ? middlePointsStyle[((i - 1) / 2) % middlePointsStyle.length] : pointsStyle[(i / 2) % pointsStyle.length]);
623
- resizeP = resizePoints[i], rotateP = rotatePoints[i], resizeL = resizeLines[Math.floor(i / 2)];
624
- resizeP.set(style);
625
- resizeP.set(point), rotateP.set(point), resizeL.set(point);
626
- resizeP.visible = resizeL.visible = resizeable || rotateable;
627
- rotateP.visible = rotateable && resizeable;
628
- if (i % 2) {
629
- resizeP.visible = rotateP.visible = !!middlePoint;
630
- if (((i + 1) / 2) % 2) {
631
- resizeL.width = width;
632
- if (resizeP.width > width - 30)
633
- resizeP.visible = false;
634
- }
635
- else {
636
- resizeL.height = height;
637
- resizeP.rotation = 90;
638
- if (resizeP.width > height - 30)
639
- resizeP.visible = false;
640
- }
641
- }
642
- else {
855
+ resizeP = resizePoints[i];
856
+ resizeP.set(this.getPointStyle((i % 2) ? middlePointsStyle[((i - 1) / 2) % middlePointsStyle.length] : pointsStyle[(i / 2) % pointsStyle.length]));
857
+ if (!(i % 2))
643
858
  resizeP.rotation = (i / 2) * 90;
859
+ }
860
+ circle.set(this.getPointStyle(mergeConfig.rotatePoint || pointsStyle[0]));
861
+ rect.set(Object.assign({ stroke, strokeWidth }, (mergeConfig.rect || {})));
862
+ rect.hittable = !single && moveable;
863
+ element.syncEventer = (single && moveable) ? rect : null;
864
+ this.app.interaction.bottomList = (single && moveable) ? [{ target: rect, proxy: element }] : null;
865
+ }
866
+ update(bounds) {
867
+ this.visible = !this.editor.element.locked;
868
+ if (this.view.worldOpacity) {
869
+ const { mergeConfig } = this.editor;
870
+ const { width, height } = bounds;
871
+ const { rect, circle, resizePoints, rotatePoints, resizeLines } = this;
872
+ const { middlePoint, resizeable, rotateable, hideOnSmall } = mergeConfig;
873
+ const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
874
+ const showPoints = !(hideOnSmall && width < smallSize && height < smallSize);
875
+ let point = {}, rotateP, resizeP, resizeL;
876
+ for (let i = 0; i < 8; i++) {
877
+ draw.AroundHelper.toPoint(draw.AroundHelper.directionData[i], bounds, point);
878
+ resizeP = resizePoints[i];
879
+ rotateP = rotatePoints[i];
880
+ resizeL = resizeLines[Math.floor(i / 2)];
881
+ resizeP.set(point);
882
+ rotateP.set(point);
883
+ resizeL.set(point);
884
+ resizeP.visible = resizeL.visible = showPoints && !!(resizeable || rotateable);
885
+ rotateP.visible = showPoints && rotateable && resizeable && !mergeConfig.rotatePoint;
886
+ if (i % 2) {
887
+ resizeP.visible = rotateP.visible = showPoints && !!middlePoint;
888
+ if (((i + 1) / 2) % 2) {
889
+ resizeL.width = width;
890
+ if (resizeP.width > width - 30)
891
+ resizeP.visible = false;
892
+ }
893
+ else {
894
+ resizeL.height = height;
895
+ resizeP.rotation = 90;
896
+ if (resizeP.width > height - 30)
897
+ resizeP.visible = false;
898
+ }
899
+ }
644
900
  }
901
+ circle.visible = showPoints && rotateable && !!mergeConfig.rotatePoint;
902
+ if (rect.path)
903
+ rect.path = null;
904
+ rect.set(Object.assign(Object.assign({}, bounds), { visible: true }));
905
+ const buttonVisible = showPoints && (circle.visible || this.buttons.children.length > 1);
906
+ this.buttons.visible = buttonVisible;
907
+ if (buttonVisible)
908
+ this.layoutButtons();
645
909
  }
646
- circle.visible = rotateable && !!config.rotatePoint;
647
- circle.set(this.getPointStyle(config.rotatePoint || pointsStyle[0]));
648
- rect.set(Object.assign({ stroke, strokeWidth }, (config.rect || {})));
649
- rect.set(Object.assign(Object.assign({}, bounds), { visible: true }));
650
- this.layoutButtons();
651
910
  }
652
911
  layoutButtons() {
653
912
  const { buttons, resizePoints } = this;
654
- const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } = this.editor.config;
913
+ const { buttonsDirection, buttonsFixed, buttonsMargin, middlePoint } = this.editor.mergeConfig;
655
914
  const { flippedX, flippedY } = this;
656
915
  let index = fourDirection.indexOf(buttonsDirection);
657
916
  if ((index % 2 && flippedX) || ((index + 1) % 2 && flippedY)) {
@@ -678,42 +937,58 @@ this.LeaferIN.editor = (function (exports, core) {
678
937
  buttons.scaleY = flippedY ? -1 : 1;
679
938
  }
680
939
  }
940
+ unload() {
941
+ this.visible = false;
942
+ }
681
943
  getPointStyle(userStyle) {
682
- const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.editor.config;
683
- const defaultStyle = { fill: pointFill, stroke, strokeWidth, width: pointSize, height: pointSize, cornerRadius: pointRadius };
944
+ const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.editor.mergeConfig;
945
+ const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius };
684
946
  return userStyle ? Object.assign(defaultStyle, userStyle) : defaultStyle;
685
947
  }
686
948
  getPointsStyle() {
687
- const { point } = this.editor.config;
949
+ const { point } = this.editor.mergeConfig;
688
950
  return point instanceof Array ? point : [point];
689
951
  }
690
952
  getMiddlePointsStyle() {
691
- const { middlePoint } = this.editor.config;
953
+ const { middlePoint } = this.editor.mergeConfig;
692
954
  return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
693
955
  }
956
+ onSelect(e) {
957
+ if (e.oldList.length === 1) {
958
+ e.oldList[0].syncEventer = null;
959
+ if (this.app)
960
+ this.app.interaction.bottomList = null;
961
+ }
962
+ }
694
963
  onDragStart(e) {
695
964
  this.dragging = true;
696
- if (e.target.name === 'rect')
697
- this.editor.opacity = this.editor.config.hideOnMove ? 0 : 1;
965
+ if (e.current.name === 'rect') {
966
+ const { editor } = this;
967
+ this.moving = true;
968
+ editor.dragStartPoint = { x: editor.element.x, y: editor.element.y };
969
+ editor.opacity = editor.mergeConfig.hideOnMove ? 0 : 1;
970
+ }
698
971
  }
699
972
  onDragEnd(e) {
700
973
  this.dragging = false;
701
- if (e.target.name === 'rect')
974
+ this.moving = false;
975
+ if (e.current.name === 'rect')
702
976
  this.editor.opacity = 1;
703
977
  }
704
978
  onDrag(e) {
705
979
  const { editor } = this;
706
- const point = e.current;
707
- if (point.pointType === 'rotate' || e.metaKey || e.ctrlKey || !editor.config.resizeable) {
708
- if (editor.config.rotateable)
980
+ const point = this.enterPoint = e.current;
981
+ if (point.pointType === 'rotate' || e.metaKey || e.ctrlKey || !editor.mergeConfig.resizeable) {
982
+ if (editor.mergeConfig.rotateable)
709
983
  editor.onRotate(e);
710
984
  }
711
985
  else {
712
986
  editor.onScale(e);
713
987
  }
988
+ updateCursor(editor, e);
714
989
  }
715
990
  onArrow(e) {
716
- if (this.editor.hasTarget) {
991
+ if (this.editor.editing && this.editor.mergeConfig.keyEvent) {
717
992
  const move = { x: 0, y: 0 };
718
993
  const distance = e.shiftKey ? 10 : 1;
719
994
  switch (e.code) {
@@ -729,13 +1004,29 @@ this.LeaferIN.editor = (function (exports, core) {
729
1004
  case 'ArrowRight':
730
1005
  move.x = distance;
731
1006
  }
732
- if (move.x || move.y)
733
- this.editor.move(move.x, move.y);
1007
+ this.editor.move(move);
734
1008
  }
735
1009
  }
736
- onDoubleClick() {
1010
+ onDoubleTap(e) {
1011
+ if (this.editor.mergeConfig.openInner === 'double')
1012
+ this.openInner(e);
1013
+ }
1014
+ onLongPress(e) {
1015
+ if (this.editor.mergeConfig.openInner === 'long')
1016
+ this.openInner(e);
1017
+ }
1018
+ openInner(e) {
737
1019
  const { editor } = this;
738
- if (editor.single && editor.element.isBranch) ;
1020
+ if (editor.single) {
1021
+ const { element } = editor;
1022
+ if (element.isBranch) {
1023
+ editor.openGroup(element);
1024
+ editor.target = editor.selector.findDeepOne(e);
1025
+ }
1026
+ else {
1027
+ editor.openInnerEditor();
1028
+ }
1029
+ }
739
1030
  }
740
1031
  listenPointEvents(point, type, direction) {
741
1032
  const { editor } = this;
@@ -751,12 +1042,15 @@ this.LeaferIN.editor = (function (exports, core) {
751
1042
  __listenEvents() {
752
1043
  const { rect, editor } = this;
753
1044
  this.__eventIds = [
754
- editor.on_(EditorEvent.SELECT, () => { this.visible = editor.hasTarget; }),
1045
+ editor.on_(EditorEvent.SELECT, this.onSelect, this),
755
1046
  rect.on_(core.DragEvent.START, this.onDragStart, this),
756
1047
  rect.on_(core.DragEvent.DRAG, editor.onMove, editor),
757
1048
  rect.on_(core.DragEvent.END, this.onDragEnd, this),
1049
+ rect.on_(core.ZoomEvent.BEFORE_ZOOM, editor.onScale, editor, true),
1050
+ rect.on_(core.RotateEvent.BEFORE_ROTATE, editor.onRotate, editor, true),
758
1051
  rect.on_(core.PointerEvent.ENTER, () => updateMoveCursor(editor)),
759
- rect.on_(core.PointerEvent.DOUBLE_CLICK, this.onDoubleClick, this)
1052
+ rect.on_(core.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this),
1053
+ rect.on_(core.PointerEvent.LONG_PRESS, this.onLongPress, this)
760
1054
  ];
761
1055
  }
762
1056
  __removeListenEvents() {
@@ -770,167 +1064,111 @@ this.LeaferIN.editor = (function (exports, core) {
770
1064
  }
771
1065
  }
772
1066
 
1067
+ class EditMask extends draw.UI {
1068
+ constructor(editor) {
1069
+ super();
1070
+ this.editor = editor;
1071
+ this.hittable = false;
1072
+ }
1073
+ __draw(canvas, options) {
1074
+ const { editor } = this;
1075
+ const { mask } = editor.mergeConfig;
1076
+ if (mask && editor.list.length) {
1077
+ const { rect } = editor.editBox;
1078
+ const { width, height } = rect.__;
1079
+ canvas.resetTransform();
1080
+ canvas.fillWorld(canvas.bounds, mask);
1081
+ canvas.setWorld(rect.__world, options.matrix);
1082
+ canvas.clearRect(0, 0, width, height);
1083
+ }
1084
+ }
1085
+ destroy() {
1086
+ this.editor = null;
1087
+ super.destroy();
1088
+ }
1089
+ }
1090
+
1091
+ const filterStyle = `
1092
+ <feOffset dy="1"/>
1093
+ <feGaussianBlur stdDeviation="1.5"/>
1094
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2 0"/>
1095
+ <feBlend mode="normal" in="SourceGraphic" result="shape"/>`;
1096
+ const resizeSVG = `
1097
+ <svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
1098
+ <g filter="url(#f)">
1099
+ <g transform="rotate({{rotation}},12,12)">
1100
+ <path d="M7.5 8.0H8.5V5.9L6.8 7.2L7.5 8.0ZM3 11.4L2.3 10.6L1.3 11.4L2.3 12.2L3 11.4ZM7.5 10.4H6.5V11.4H7.5V10.4ZM16.5 10.4V11.4H17.5V10.4H16.5ZM16.5 8.0L17.1 7.2L15.5 5.9V8.0H16.5ZM21 11.4L21.6 12.2L22.6 11.4L21.6 10.6L21 11.4ZM16.5 14.9H15.5V16.9L17.1 15.7L16.5 14.9ZM16.5 12.4H17.5V11.4H16.5V12.4ZM7.5 12.4V11.4H6.5V12.4H7.5ZM7.5 14.9L6.8 15.7L8.5 16.9V14.9H7.5ZM6.8 7.2L2.3 10.6L3.6 12.2L8.1 8.7L6.8 7.2ZM8.5 10.4V8.0H6.5V10.4H8.5ZM16.5 9.4H7.5V11.4H16.5V9.4ZM17.5 10.4V8.0H15.5V10.4H17.5ZM15.8 8.7L20.3 12.2L21.6 10.6L17.1 7.2L15.8 8.7ZM20.3 10.6L15.8 14.1L17.1 15.7L21.6 12.2L20.3 10.6ZM17.5 14.9V12.4H15.5V14.9H17.5ZM7.5 13.4H16.5V11.4H7.5V13.4ZM8.5 14.9V12.4H6.5V14.9H8.5ZM2.3 12.2L6.8 15.7L8.1 14.1L3.6 10.6L2.3 12.2Z" fill="white"/>
1101
+ <path fill-rule="evenodd" d="M3 11.4L7.5 8.0V10.4H16.5V8.0L21 11.4L16.5 14.9V12.4H7.5V14.9L3 11.4Z" fill="black"/>
1102
+ </g>
1103
+ </g>
1104
+ <defs>
1105
+ <filter id="f" x="-1.6" y="3.9" width="27.2" height="16.9" filterUnits="userSpaceOnUse">
1106
+ ${filterStyle}
1107
+ </filter>
1108
+ </defs>
1109
+ </svg>
1110
+ `;
1111
+ const rotateSVG = `
1112
+ <svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
1113
+ <g filter="url(#f)">
1114
+ <g transform="rotate(135,12,12),rotate({{rotation}},12,12)">
1115
+ <path d="M20.4 8H21.4L20.8 7.1L17.3 2.6L17 2.1L16.6 2.6L13.1 7.1L12.5 8H13.5H15.4C14.9 11.8 11.8 14.9 8 15.4V13.5V12.5L7.1 13.1L2.6 16.6L2.1 17L2.6 17.3L7.1 20.8L8 21.4V20.4V18.4C13.5 17.9 17.9 13.5 18.4 8H20.4Z" stroke="white"/>
1116
+ <path fill-rule="evenodd" d="M17 3L20.4 7.5H17.9C17.7 13.1 13.1 17.7 7.5 17.9V20.4L3 17L7.5 13.5V15.9C12.0 15.7 15.7 12.0 15.9 7.5H13.5L17 3Z" fill="black"/>
1117
+ </g>
1118
+ </g>
1119
+ <defs>
1120
+ <filter id="f" x="-1.6" y="-0.6" width="27.1" height="27.1" filterUnits="userSpaceOnUse">
1121
+ ${filterStyle}
1122
+ </filter>
1123
+ </defs>
1124
+ </svg>
1125
+ `;
1126
+ const skewSVG = `
1127
+ <svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
1128
+ <g filter="url(#f)">
1129
+ <g transform="rotate(90,12,12),rotate({{rotation}},12,12)">
1130
+ <path d="M21 10.4L21 11.4L23.8 11.4L21.6 9.6L21 10.4ZM17 10.4V11.4L17 11.4L17 10.4ZM15.5 6L16.1 5.2L14.5 3.9V6H15.5ZM15.5 8.4V9.4H16.5V8.4H15.5ZM6 8.4V7.4H5V8.4H6ZM6 10.4H5V11.4H6V10.4ZM7 14.4V13.4L7 13.4L7 14.4ZM3 14.4L3 13.4L0.1 13.4L2.3 15.2L3 14.4ZM8.5 18.9L7.8 19.7L9.5 21.0V18.9H8.5ZM8.5 16.4V15.4H7.5V16.4H8.5ZM19 16.4V17.4H20V16.4H19ZM19 14.4H20V13.4H19V14.4ZM21 9.4L17 9.4L17 11.4L21 11.4L21 9.4ZM14.8 6.7L20.3 11.2L21.6 9.6L16.1 5.2L14.8 6.7ZM16.5 8.4V6H14.5V8.4H16.5ZM6 9.4H15.5V7.4H6V9.4ZM7 10.4V8.4H5V10.4H7ZM15.5 9.4H6V11.4H15.5V9.4ZM17 9.4H15.5V11.4H17V9.4ZM7 15.4H8.5V13.4H7V15.4ZM3 15.4L7 15.4L7 13.4L3 13.4L3 15.4ZM9.1 18.1L3.6 13.6L2.3 15.2L7.8 19.7L9.1 18.1ZM7.5 16.4V18.9H9.5V16.4H7.5ZM19 15.4H8.5V17.4H19V15.4ZM18 14.4V16.4H20V14.4H18ZM8.5 15.4H19V13.4H8.5V15.4Z" fill="white"/>
1131
+ <path fill-rule="evenodd" d="M17 10.4L21 10.4L15.5 6V8.4H6V10.4H15.5H17ZM8.5 14.4H7L3 14.4L8.5 18.9V16.4H19V14.4H8.5Z" fill="black"/>
1132
+ </g>
1133
+ </g>
1134
+ <defs>
1135
+ <filter x="-2.8" y="1.9" width="29.6" height="23.1" filterUnits="userSpaceOnUse" >
1136
+ ${filterStyle}
1137
+ </filter>
1138
+ </defs>
1139
+ </svg>
1140
+ `;
1141
+
773
1142
  const config = {
774
- editSize: 'auto',
1143
+ editSize: 'size',
1144
+ keyEvent: true,
775
1145
  stroke: '#836DFF',
776
1146
  strokeWidth: 2,
777
1147
  pointFill: '#FFFFFF',
778
- pointSize: 8,
1148
+ pointSize: 10,
779
1149
  pointRadius: 16,
780
1150
  rotateGap: 45,
781
1151
  buttonsDirection: 'bottom',
782
1152
  buttonsMargin: 12,
1153
+ hideOnSmall: true,
783
1154
  moveCursor: 'move',
784
- resizeCursor: ['nwse-resize', 'ns-resize', 'nesw-resize', 'ew-resize', 'nwse-resize', 'ns-resize', 'nesw-resize', 'ew-resize'],
785
- rotateCursor: ['ne-resize', 'e-resize', 'se-resize', 's-resize', 'sw-resize', 'w-resize', 'nw-resize', 'n-resize'],
1155
+ resizeCursor: { url: resizeSVG, x: 12, y: 12 },
1156
+ rotateCursor: { url: rotateSVG, x: 12, y: 12 },
1157
+ skewCursor: { url: skewSVG, x: 12, y: 12 },
786
1158
  selector: true,
787
1159
  hover: true,
1160
+ select: 'press',
1161
+ openInner: 'double',
788
1162
  boxSelect: true,
1163
+ moveable: true,
789
1164
  resizeable: true,
790
1165
  rotateable: true,
791
1166
  skewable: true
792
1167
  };
793
1168
 
794
- class EditTool {
795
- constructor() {
796
- this.tag = 'EditTool';
797
- }
798
- onMove(e) {
799
- const { moveX, moveY, editor } = e;
800
- const { app, list } = editor;
801
- app.lockLayout();
802
- list.forEach(target => {
803
- const move = target.getLocalPoint({ x: moveX, y: moveY }, null, true);
804
- target.move(move.x, move.y);
805
- });
806
- app.unlockLayout();
807
- }
808
- onScale(e) {
809
- const { scaleX, scaleY, transform, worldOrigin, editor } = e;
810
- const { app, list } = editor;
811
- app.lockLayout();
812
- list.forEach(target => {
813
- const resize = editor.getEditSize(target) === 'size';
814
- if (transform) {
815
- target.transform(transform, resize);
816
- }
817
- else {
818
- target.scaleOf(target.getInnerPoint(worldOrigin), scaleX, scaleY, resize);
819
- }
820
- });
821
- app.unlockLayout();
822
- }
823
- onRotate(e) {
824
- const { rotation, worldOrigin, editor } = e;
825
- const { app, list } = editor;
826
- app.lockLayout();
827
- list.forEach(target => {
828
- target.rotateOf(target.getInnerPoint(worldOrigin), rotation);
829
- });
830
- app.unlockLayout();
831
- }
832
- onSkew(e) {
833
- const { skewX, skewY, transform, worldOrigin, editor } = e;
834
- const { app, list } = editor;
835
- app.lockLayout();
836
- list.forEach(target => {
837
- const resize = editor.getEditSize(target) === 'size';
838
- if (transform) {
839
- target.transform(transform, resize);
840
- }
841
- else {
842
- target.skewOf(target.getInnerPoint(worldOrigin), skewX, skewY, resize);
843
- }
844
- });
845
- app.unlockLayout();
846
- }
847
- update(editor) {
848
- const { simulateTarget, element } = editor;
849
- if (editor.multiple)
850
- simulateTarget.parent.updateLayout();
851
- const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = element.getLayoutBounds('box', editor, true);
852
- editor.editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
853
- editor.editBox.update({ x: 0, y: 0, width, height });
854
- }
855
- }
856
- EditTool.list = [];
857
-
858
- const { left, right } = IDirection8;
859
- class LineEditTool extends EditTool {
860
- constructor() {
861
- super(...arguments);
862
- this.tag = 'LineEditTool';
863
- this.scaleOfEvent = true;
864
- }
865
- onScaleWithDrag(e) {
866
- const { drag, direction, lockRatio, around } = e;
867
- const target = e.target;
868
- const fromPoint = { x: 0, y: 0 };
869
- const { toPoint } = target;
870
- target.rotation = 0;
871
- let { x, y } = drag.getInnerMove(target);
872
- if (lockRatio) {
873
- if (Math.abs(x) > Math.abs(y)) {
874
- y = 0;
875
- }
876
- else {
877
- x = 0;
878
- }
879
- }
880
- if (direction === left) {
881
- fromPoint.x += x;
882
- fromPoint.y += y;
883
- if (around) {
884
- toPoint.x -= x;
885
- toPoint.y -= y;
886
- }
887
- }
888
- else {
889
- if (around) {
890
- fromPoint.x -= x;
891
- fromPoint.y -= y;
892
- }
893
- toPoint.x += x;
894
- toPoint.y += y;
895
- }
896
- target.getLocalPointByInner(fromPoint, null, null, true);
897
- target.getLocalPointByInner(toPoint, null, null, true);
898
- target.x = fromPoint.x;
899
- target.y = fromPoint.y;
900
- target.getInnerPointByLocal(toPoint, null, null, true);
901
- target.toPoint = toPoint;
902
- }
903
- onSkew(_e) {
904
- }
905
- update(editor) {
906
- const { rotatePoints, resizeLines, resizePoints } = editor.editBox;
907
- super.update(editor);
908
- for (let i = 0; i < 8; i++) {
909
- if (i < 4)
910
- resizeLines[i].visible = false;
911
- resizePoints[i].visible = rotatePoints[i].visible = (i === left || i === right);
912
- }
913
- }
914
- }
915
-
916
- function getEditTool(list) {
917
- if (list.length === 1) {
918
- const leaf = list[0];
919
- if (leaf instanceof core.Line && !leaf.points) {
920
- return new LineEditTool();
921
- }
922
- else {
923
- return new EditTool();
924
- }
925
- }
926
- else {
927
- return new EditTool();
928
- }
929
- }
930
-
931
1169
  function simulate(editor) {
932
1170
  const { simulateTarget, leafList: targetList } = editor;
933
- const { x, y, width, height } = new core.Bounds().setListWithFn(targetList.list, (leaf) => leaf.worldBoxBounds);
1171
+ const { x, y, width, height } = new draw.Bounds().setListWithFn(targetList.list, (leaf) => leaf.worldBoxBounds);
934
1172
  const parent = simulateTarget.parent = targetList.list[0].leafer.zoomLayer;
935
1173
  const { scaleX, scaleY, e: worldX, f: worldY } = parent.__world;
936
1174
  simulateTarget.reset({ x: (x - worldX) / scaleX, y: (y - worldY) / scaleY, width: width / scaleX, height: height / scaleY });
@@ -939,13 +1177,14 @@ this.LeaferIN.editor = (function (exports, core) {
939
1177
  function onTarget(editor, oldValue) {
940
1178
  const { target } = editor;
941
1179
  if (target) {
942
- editor.leafList = target instanceof core.LeafList ? target : new core.LeafList(target instanceof Array ? target : target);
1180
+ editor.leafList = target instanceof draw.LeafList ? target : new draw.LeafList(target instanceof Array ? target : target);
943
1181
  }
944
1182
  else {
945
1183
  editor.leafList.reset();
946
1184
  }
947
1185
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, { editor, value: target, oldValue }));
948
- if (editor.hasTarget) {
1186
+ editor.checkOpenedGroups();
1187
+ if (editor.editing) {
949
1188
  editor.waitLeafer(() => {
950
1189
  if (editor.multiple)
951
1190
  simulate(editor);
@@ -956,6 +1195,7 @@ this.LeaferIN.editor = (function (exports, core) {
956
1195
  });
957
1196
  }
958
1197
  else {
1198
+ editor.updateEditTool();
959
1199
  editor.removeTargetEvents();
960
1200
  }
961
1201
  }
@@ -966,14 +1206,19 @@ this.LeaferIN.editor = (function (exports, core) {
966
1206
  const order = (a, b) => a.parent.children.indexOf(a) - b.parent.children.indexOf(b);
967
1207
  const reverseOrder = (a, b) => b.parent.children.indexOf(b) - a.parent.children.indexOf(a);
968
1208
  const EditorHelper = {
969
- group(list, element, group) {
1209
+ group(list, element, userGroup) {
970
1210
  list.sort(reverseOrder);
971
1211
  const { app, parent } = list[0];
972
- if (!group)
973
- group = new core.Group();
1212
+ let group;
1213
+ if (userGroup && userGroup.add) {
1214
+ group = userGroup;
1215
+ }
1216
+ else {
1217
+ group = new draw.Group(userGroup);
1218
+ }
974
1219
  parent.addAt(group, parent.children.indexOf(list[0]));
975
1220
  list.sort(order);
976
- const matrx = new core.Matrix(element.worldTransform);
1221
+ const matrx = new draw.Matrix(element.worldTransform);
977
1222
  matrx.divideParent(parent.worldTransform);
978
1223
  group.setTransform(matrx);
979
1224
  group.editable = true;
@@ -1019,25 +1264,79 @@ this.LeaferIN.editor = (function (exports, core) {
1019
1264
  }
1020
1265
  };
1021
1266
 
1022
- class Editor extends core.Group {
1267
+ const debug = draw.Debug.get('EditToolCreator');
1268
+ function registerEditTool() {
1269
+ return (target) => {
1270
+ EditToolCreator.register(target);
1271
+ };
1272
+ }
1273
+ const registerInnerEditor = registerEditTool;
1274
+ const EditToolCreator = {
1275
+ list: {},
1276
+ register(EditTool) {
1277
+ const { tag } = EditTool.prototype;
1278
+ list[tag] ? debug.repeat(tag) : (list[tag] = EditTool);
1279
+ },
1280
+ get(tag, editor) {
1281
+ return new list[tag](editor);
1282
+ }
1283
+ };
1284
+ const { list } = EditToolCreator;
1285
+
1286
+ class InnerEditorEvent extends EditorEvent {
1287
+ constructor(type, data) {
1288
+ super(type, data);
1289
+ }
1290
+ }
1291
+ InnerEditorEvent.BEFORE_OPEN = 'innerEditor.before_open';
1292
+ InnerEditorEvent.OPEN = 'innerEditor.open';
1293
+ InnerEditorEvent.BEFORE_CLOSE = 'innerEditor.before_close';
1294
+ InnerEditorEvent.CLOSE = 'innerEditor.close';
1295
+
1296
+ class EditorGroupEvent extends EditorEvent {
1297
+ constructor(type, data) {
1298
+ super(type, data);
1299
+ }
1300
+ }
1301
+ EditorGroupEvent.GROUP = 'editor.group';
1302
+ EditorGroupEvent.BEFORE_UNGROUP = 'editor.before_ungroup';
1303
+ EditorGroupEvent.UNGROUP = 'editor.ungroup';
1304
+ EditorGroupEvent.OPEN = 'editor.open_group';
1305
+ EditorGroupEvent.CLOSE = 'editor.close_group';
1306
+
1307
+ class Editor extends draw.Group {
1308
+ get mergeConfig() {
1309
+ const { element, config } = this;
1310
+ return this.single && element.editConfig ? Object.assign(Object.assign({}, config), element.editConfig) : config;
1311
+ }
1023
1312
  get list() { return this.leafList.list; }
1024
- get hasTarget() { return !!this.list.length; }
1313
+ get editing() { return !!this.list.length; }
1314
+ get groupOpening() { return !!this.openedGroupList.length; }
1025
1315
  get multiple() { return this.list.length > 1; }
1026
1316
  get single() { return this.list.length === 1; }
1317
+ get dragging() { return this.editBox.dragging; }
1027
1318
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
1028
1319
  get buttons() { return this.editBox.buttons; }
1029
- get dragging() { return this.editBox.dragging; }
1030
1320
  constructor(userConfig, data) {
1031
1321
  super(data);
1032
1322
  this.config = config;
1033
- this.leafList = new core.LeafList();
1034
- this.simulateTarget = new core.Rect({ visible: false });
1323
+ this.leafList = new draw.LeafList();
1324
+ this.openedGroupList = new draw.LeafList();
1325
+ this.simulateTarget = new draw.Rect({ visible: false });
1035
1326
  this.editBox = new EditBox(this);
1327
+ this.editToolList = {};
1036
1328
  this.selector = new EditSelect(this);
1329
+ this.editMask = new EditMask(this);
1037
1330
  this.targetEventIds = [];
1038
1331
  if (userConfig)
1039
- this.config = core.DataHelper.default(userConfig, this.config);
1040
- this.addMany(this.selector, this.editBox);
1332
+ this.config = draw.DataHelper.default(userConfig, this.config);
1333
+ this.addMany(this.editMask, this.selector, this.editBox);
1334
+ }
1335
+ select(target) {
1336
+ this.target = target;
1337
+ }
1338
+ cancel() {
1339
+ this.target = null;
1041
1340
  }
1042
1341
  hasItem(item) {
1043
1342
  return this.leafList.has(item);
@@ -1054,52 +1353,82 @@ this.LeaferIN.editor = (function (exports, core) {
1054
1353
  this.hasItem(item) ? this.removeItem(item) : this.addItem(item);
1055
1354
  }
1056
1355
  update() {
1057
- if (this.target) {
1058
- this.editTool.update(this);
1356
+ if (this.editing) {
1357
+ if (this.innerEditing)
1358
+ this.innerEditor.update();
1359
+ this.editTool.update();
1059
1360
  this.selector.update();
1060
1361
  }
1061
1362
  }
1363
+ updateEditBox() {
1364
+ if (this.multiple)
1365
+ simulate(this);
1366
+ this.update();
1367
+ }
1062
1368
  updateEditTool() {
1063
- this.editTool = getEditTool(this.list);
1369
+ const tool = this.editTool;
1370
+ if (tool) {
1371
+ this.editBox.unload();
1372
+ tool.unload();
1373
+ this.editTool = null;
1374
+ }
1375
+ if (this.editing) {
1376
+ const tag = this.single ? this.list[0].editOuter : 'EditTool';
1377
+ this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
1378
+ this.editBox.load();
1379
+ this.editTool.load();
1380
+ }
1064
1381
  }
1065
- getEditSize(ui) {
1066
- let { editSize } = this.config;
1067
- return editSize === 'auto' ? ui.editSize : editSize;
1382
+ getEditSize(_ui) {
1383
+ return this.mergeConfig.editSize;
1068
1384
  }
1069
1385
  onMove(e) {
1070
- const move = e.getLocalMove(this.element);
1386
+ const total = { x: e.totalX, y: e.totalY };
1071
1387
  if (e.shiftKey) {
1072
- if (Math.abs(move.x) > Math.abs(move.y))
1073
- move.y = 0;
1388
+ if (Math.abs(total.x) > Math.abs(total.y))
1389
+ total.y = 0;
1074
1390
  else
1075
- move.x = 0;
1391
+ total.x = 0;
1076
1392
  }
1077
- this.move(move.x, move.y);
1393
+ this.move(core.DragEvent.getValidMove(this.element, this.dragStartPoint, total));
1078
1394
  }
1079
1395
  onScale(e) {
1080
1396
  const { element } = this;
1081
- const { direction } = e.current;
1082
- let { around, lockRatio } = this.config;
1083
- if (e.shiftKey)
1084
- lockRatio = true;
1085
- const data = EditDataHelper.getScaleData(element.boxBounds, direction, e.getInnerMove(element), lockRatio, EditDataHelper.getAround(around, e.altKey));
1086
- if (this.editTool.onScaleWithDrag) {
1087
- data.drag = e;
1088
- this.scaleWithDrag(data);
1397
+ if (e instanceof core.ZoomEvent) {
1398
+ if (this.mergeConfig.resizeable === 'zoom') {
1399
+ e.stop();
1400
+ this.scaleOf(element.getInnerPoint(e), e.scale, e.scale);
1401
+ }
1089
1402
  }
1090
1403
  else {
1091
- this.scaleOf(data.origin, data.scaleX, data.scaleY);
1404
+ const { direction } = e.current;
1405
+ let { around, lockRatio } = this.mergeConfig;
1406
+ if (e.shiftKey || element.lockRatio)
1407
+ lockRatio = true;
1408
+ const data = EditDataHelper.getScaleData(element.boxBounds, direction, e.getInnerMove(element), lockRatio, EditDataHelper.getAround(around, e.altKey));
1409
+ if (this.editTool.onScaleWithDrag) {
1410
+ data.drag = e;
1411
+ this.scaleWithDrag(data);
1412
+ }
1413
+ else {
1414
+ this.scaleOf(data.origin, data.scaleX, data.scaleY);
1415
+ }
1092
1416
  }
1093
1417
  }
1094
1418
  onRotate(e) {
1095
- const { skewable, around, rotateGap } = this.config;
1419
+ const { skewable, around, rotateGap } = this.mergeConfig;
1096
1420
  const { direction, name } = e.current;
1097
1421
  if (skewable && name === 'resize-line')
1098
1422
  return this.onSkew(e);
1099
- const { element, editBox } = this;
1423
+ const { element } = this;
1100
1424
  let origin, rotation;
1101
1425
  if (e instanceof core.RotateEvent) {
1102
- rotation = e.rotation, origin = element.getInnerPoint(e);
1426
+ if (this.mergeConfig.rotateable === 'rotate') {
1427
+ e.stop();
1428
+ rotation = e.rotation, origin = element.getInnerPoint(e);
1429
+ }
1430
+ else
1431
+ return;
1103
1432
  }
1104
1433
  else {
1105
1434
  const last = { x: e.x - e.moveX, y: e.y - e.moveY };
@@ -1107,24 +1436,26 @@ this.LeaferIN.editor = (function (exports, core) {
1107
1436
  rotation = data.rotation;
1108
1437
  origin = data.origin;
1109
1438
  }
1110
- rotation = core.MathHelper.getGapRotation(rotation, rotateGap, element.rotation);
1439
+ rotation = draw.MathHelper.getGapRotation(rotation, rotateGap, element.rotation);
1111
1440
  if (!rotation)
1112
1441
  return;
1113
- if (editBox.flippedOne)
1442
+ if (element.scaleX * element.scaleY < 0)
1114
1443
  rotation = -rotation;
1115
- this.rotateOf(origin, rotation);
1444
+ this.rotateOf(origin, draw.MathHelper.float(rotation, 2));
1116
1445
  }
1117
1446
  onSkew(e) {
1118
1447
  const { element } = this;
1119
- const { around } = this.config;
1448
+ const { around } = this.mergeConfig;
1120
1449
  const { origin, skewX, skewY } = EditDataHelper.getSkewData(element.boxBounds, e.current.direction, e.getInnerMove(element), EditDataHelper.getAround(around, e.altKey));
1121
1450
  if (!skewX && !skewY)
1122
1451
  return;
1123
1452
  this.skewOf(origin, skewX, skewY);
1124
1453
  }
1125
- move(x, y) {
1454
+ move(x, y = 0) {
1455
+ if (!this.mergeConfig.moveable || this.element.locked)
1456
+ return;
1126
1457
  const { element } = this;
1127
- const world = element.getWorldPointByLocal({ x, y }, null, true);
1458
+ const world = element.getWorldPointByLocal(typeof x === 'object' ? Object.assign({}, x) : { x, y }, null, true);
1128
1459
  const event = new EditorMoveEvent(EditorMoveEvent.MOVE, { target: element, editor: this, moveX: world.x, moveY: world.y });
1129
1460
  this.editTool.onMove(event);
1130
1461
  this.emitEvent(event);
@@ -1132,6 +1463,8 @@ this.LeaferIN.editor = (function (exports, core) {
1132
1463
  element.move(x, y);
1133
1464
  }
1134
1465
  scaleWithDrag(data) {
1466
+ if (!this.mergeConfig.resizeable || this.element.locked)
1467
+ return;
1135
1468
  const { element } = this;
1136
1469
  const worldOrigin = element.getWorldPoint(data.origin);
1137
1470
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, Object.assign(Object.assign({}, data), { target: element, editor: this, worldOrigin }));
@@ -1139,35 +1472,45 @@ this.LeaferIN.editor = (function (exports, core) {
1139
1472
  this.emitEvent(event);
1140
1473
  }
1141
1474
  scaleOf(origin, scaleX, scaleY = scaleX, _resize) {
1475
+ if (!this.mergeConfig.resizeable || this.element.locked)
1476
+ return;
1142
1477
  const { element } = this;
1143
- const worldOrigin = element.getWorldPoint(origin);
1478
+ const worldOrigin = element.getWorldPoint(draw.LeafHelper.getInnerOrigin(element, origin));
1144
1479
  let transform;
1145
1480
  if (this.multiple) {
1146
- const childMatrix = Object.assign({}, element.localTransform);
1481
+ const oldMatrix = new draw.Matrix(element.worldTransform);
1147
1482
  element.scaleOf(origin, scaleX, scaleY);
1148
- transform = new core.Matrix(element.localTransform).divide(childMatrix);
1483
+ transform = new draw.Matrix(element.worldTransform).divide(oldMatrix);
1149
1484
  }
1150
1485
  const event = new EditorScaleEvent(EditorScaleEvent.SCALE, { target: element, editor: this, worldOrigin, scaleX, scaleY, transform });
1151
1486
  this.editTool.onScale(event);
1152
1487
  this.emitEvent(event);
1153
1488
  }
1154
1489
  rotateOf(origin, rotation) {
1490
+ if (!this.mergeConfig.rotateable || this.element.locked)
1491
+ return;
1155
1492
  const { element } = this;
1156
- const worldOrigin = element.getWorldPoint(origin);
1157
- const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, { target: element, editor: this, worldOrigin, rotation });
1493
+ const worldOrigin = element.getWorldPoint(draw.LeafHelper.getInnerOrigin(element, origin));
1494
+ let transform;
1495
+ if (this.multiple) {
1496
+ const oldMatrix = new draw.Matrix(element.worldTransform);
1497
+ element.rotateOf(origin, rotation);
1498
+ transform = new draw.Matrix(element.worldTransform).divide(oldMatrix);
1499
+ }
1500
+ const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, { target: element, editor: this, worldOrigin, rotation, transform });
1158
1501
  this.editTool.onRotate(event);
1159
1502
  this.emitEvent(event);
1160
- if (this.multiple)
1161
- element.rotateOf(origin, rotation);
1162
1503
  }
1163
1504
  skewOf(origin, skewX, skewY = 0, _resize) {
1505
+ if (!this.mergeConfig.skewable || this.element.locked)
1506
+ return;
1164
1507
  const { element } = this;
1165
- const worldOrigin = element.getWorldPoint(origin);
1508
+ const worldOrigin = element.getWorldPoint(draw.LeafHelper.getInnerOrigin(element, origin));
1166
1509
  let transform;
1167
1510
  if (this.multiple) {
1168
- const childMatrix = Object.assign({}, element.localTransform);
1511
+ const oldMatrix = new draw.Matrix(element.worldTransform);
1169
1512
  element.skewOf(origin, skewX, skewY);
1170
- transform = new core.Matrix(element.localTransform).divide(childMatrix);
1513
+ transform = new draw.Matrix(element.worldTransform).divide(oldMatrix);
1171
1514
  }
1172
1515
  const event = new EditorSkewEvent(EditorSkewEvent.SKEW, {
1173
1516
  target: element, editor: this, skewX, skewY, transform, worldOrigin
@@ -1175,16 +1518,92 @@ this.LeaferIN.editor = (function (exports, core) {
1175
1518
  this.editTool.onSkew(event);
1176
1519
  this.emitEvent(event);
1177
1520
  }
1178
- group(group) {
1179
- if (this.multiple)
1180
- this.target = EditorHelper.group(this.list, this.element, group);
1521
+ group(userGroup) {
1522
+ if (this.multiple) {
1523
+ this.target = EditorHelper.group(this.list, this.element, userGroup);
1524
+ this.emitGroupEvent(EditorGroupEvent.GROUP, this.target);
1525
+ }
1181
1526
  return this.target;
1182
1527
  }
1183
1528
  ungroup() {
1184
- if (this.list.length)
1185
- this.target = EditorHelper.ungroup(this.list);
1529
+ const { list } = this;
1530
+ if (list.length) {
1531
+ list.forEach(item => item.isBranch && this.emitGroupEvent(EditorGroupEvent.BEFORE_UNGROUP, item));
1532
+ this.target = EditorHelper.ungroup(list);
1533
+ list.forEach(item => item.isBranch && this.emitGroupEvent(EditorGroupEvent.UNGROUP, item));
1534
+ }
1186
1535
  return this.list;
1187
1536
  }
1537
+ openGroup(group) {
1538
+ this.openedGroupList.add(group);
1539
+ group.hitChildren = true;
1540
+ this.emitGroupEvent(EditorGroupEvent.OPEN, group);
1541
+ }
1542
+ closeGroup(group) {
1543
+ this.openedGroupList.remove(group);
1544
+ group.hitChildren = false;
1545
+ this.emitGroupEvent(EditorGroupEvent.CLOSE, group);
1546
+ }
1547
+ checkOpenedGroups() {
1548
+ const opened = this.openedGroupList;
1549
+ if (opened.length) {
1550
+ let { list } = opened;
1551
+ if (this.editing)
1552
+ list = [], opened.forEach(item => this.list.every(leaf => !draw.LeafHelper.hasParent(leaf, item)) && list.push(item));
1553
+ list.forEach(item => this.closeGroup(item));
1554
+ }
1555
+ if (this.editing && !this.selector.dragging)
1556
+ this.checkDeepSelect();
1557
+ }
1558
+ checkDeepSelect() {
1559
+ let parent, { list } = this;
1560
+ for (let i = 0; i < list.length; i++) {
1561
+ parent = list[i].parent;
1562
+ while (parent && !parent.hitChildren) {
1563
+ this.openGroup(parent);
1564
+ parent = parent.parent;
1565
+ }
1566
+ }
1567
+ }
1568
+ emitGroupEvent(type, group) {
1569
+ const event = new EditorGroupEvent(type, { editTarget: group });
1570
+ this.emitEvent(event);
1571
+ group.emitEvent(event);
1572
+ }
1573
+ openInnerEditor(target) {
1574
+ if (target)
1575
+ this.target = target;
1576
+ if (this.single) {
1577
+ const editTarget = this.element;
1578
+ const tag = editTarget.editInner;
1579
+ if (tag && EditToolCreator.list[tag]) {
1580
+ this.editTool.unload();
1581
+ this.innerEditing = true;
1582
+ this.innerEditor = this.editToolList[tag] || EditToolCreator.get(tag, this);
1583
+ this.innerEditor.editTarget = editTarget;
1584
+ this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
1585
+ this.innerEditor.load();
1586
+ this.emitInnerEvent(InnerEditorEvent.OPEN);
1587
+ }
1588
+ }
1589
+ }
1590
+ closeInnerEditor() {
1591
+ if (this.innerEditing) {
1592
+ this.innerEditing = false;
1593
+ this.emitInnerEvent(InnerEditorEvent.BEFORE_CLOSE);
1594
+ this.innerEditor.unload();
1595
+ this.emitInnerEvent(InnerEditorEvent.CLOSE);
1596
+ this.editTool.load();
1597
+ this.innerEditor = null;
1598
+ }
1599
+ }
1600
+ emitInnerEvent(type) {
1601
+ const { innerEditor } = this;
1602
+ const { editTarget } = innerEditor;
1603
+ const event = new InnerEditorEvent(type, { editTarget, innerEditor });
1604
+ this.emitEvent(event);
1605
+ editTarget.emitEvent(event);
1606
+ }
1188
1607
  lock() {
1189
1608
  this.list.forEach(leaf => leaf.locked = true);
1190
1609
  this.update();
@@ -1209,7 +1628,7 @@ this.LeaferIN.editor = (function (exports, core) {
1209
1628
  if (!this.targetEventIds.length) {
1210
1629
  const { leafer } = this.list[0];
1211
1630
  this.targetEventIds = [
1212
- leafer.on_(core.RenderEvent.START, this.update, this),
1631
+ leafer.on_(draw.RenderEvent.START, this.update, this),
1213
1632
  leafer.on_([core.KeyEvent.HOLD, core.KeyEvent.UP], (e) => { updateCursor(this, e); }),
1214
1633
  leafer.on_(core.KeyEvent.DOWN, this.editBox.onArrow, this.editBox)
1215
1634
  ];
@@ -1225,7 +1644,9 @@ this.LeaferIN.editor = (function (exports, core) {
1225
1644
  destroy() {
1226
1645
  if (!this.destroyed) {
1227
1646
  this.simulateTarget.destroy();
1228
- this.target = this.hoverTarget = this.simulateTarget = null;
1647
+ Object.values(this.editToolList).forEach(item => item.destroy());
1648
+ this.editToolList = {};
1649
+ this.target = this.hoverTarget = this.simulateTarget = this.editTool = this.innerEditor = null;
1229
1650
  super.destroy();
1230
1651
  }
1231
1652
  }
@@ -1237,8 +1658,254 @@ this.LeaferIN.editor = (function (exports, core) {
1237
1658
  targetAttr(onTarget)
1238
1659
  ], Editor.prototype, "target", void 0);
1239
1660
 
1240
- core.Creator.editor = function (options) {
1241
- return new Editor(options);
1661
+ class InnerEditor {
1662
+ static registerInnerEditor() {
1663
+ EditToolCreator.register(this);
1664
+ }
1665
+ get tag() { return 'InnerEditor'; }
1666
+ get editBox() { return this.editor.editBox; }
1667
+ constructor(editor) {
1668
+ this.editor = editor;
1669
+ this.create();
1670
+ }
1671
+ onCreate() { }
1672
+ create() {
1673
+ this.view = new draw.Group();
1674
+ this.onCreate();
1675
+ }
1676
+ onLoad() { }
1677
+ load() {
1678
+ this.editor.selector.hittable = this.editor.app.tree.hitChildren = false;
1679
+ this.onLoad();
1680
+ }
1681
+ onUpdate() { }
1682
+ update() { this.onUpdate(); }
1683
+ onUnload() { }
1684
+ unload() {
1685
+ this.editor.selector.hittable = this.editor.app.tree.hitChildren = true;
1686
+ this.onUnload();
1687
+ }
1688
+ onDestroy() { }
1689
+ destroy() {
1690
+ this.onDestroy();
1691
+ if (this.editor) {
1692
+ if (this.view)
1693
+ this.view.destroy();
1694
+ if (this.eventIds)
1695
+ this.editor.off_(this.eventIds);
1696
+ this.editor = this.view = this.eventIds = null;
1697
+ }
1698
+ }
1699
+ }
1700
+
1701
+ exports.EditTool = class EditTool extends InnerEditor {
1702
+ static registerEditTool() {
1703
+ EditToolCreator.register(this);
1704
+ }
1705
+ get tag() { return 'EditTool'; }
1706
+ onMove(e) {
1707
+ const { moveX, moveY, editor } = e;
1708
+ const { app, list } = editor;
1709
+ app.lockLayout();
1710
+ list.forEach(target => {
1711
+ target.moveWorld(moveX, moveY);
1712
+ });
1713
+ app.unlockLayout();
1714
+ }
1715
+ onScale(e) {
1716
+ const { scaleX, scaleY, transform, worldOrigin, editor } = e;
1717
+ const { app, list } = editor;
1718
+ app.lockLayout();
1719
+ list.forEach(target => {
1720
+ const resize = editor.getEditSize(target) !== 'scale';
1721
+ if (transform) {
1722
+ target.transformWorld(transform, resize);
1723
+ }
1724
+ else {
1725
+ target.scaleOfWorld(worldOrigin, scaleX, scaleY, resize);
1726
+ }
1727
+ });
1728
+ app.unlockLayout();
1729
+ }
1730
+ onRotate(e) {
1731
+ const { rotation, transform, worldOrigin, editor } = e;
1732
+ const { app, list } = editor;
1733
+ app.lockLayout();
1734
+ list.forEach(target => {
1735
+ const resize = editor.getEditSize(target) !== 'scale';
1736
+ if (transform) {
1737
+ target.transformWorld(transform, resize);
1738
+ }
1739
+ else {
1740
+ target.rotateOfWorld(worldOrigin, rotation);
1741
+ }
1742
+ });
1743
+ app.unlockLayout();
1744
+ }
1745
+ onSkew(e) {
1746
+ const { skewX, skewY, transform, worldOrigin, editor } = e;
1747
+ const { app, list } = editor;
1748
+ app.lockLayout();
1749
+ list.forEach(target => {
1750
+ const resize = editor.getEditSize(target) !== 'scale';
1751
+ if (transform) {
1752
+ target.transformWorld(transform, resize);
1753
+ }
1754
+ else {
1755
+ target.skewOfWorld(worldOrigin, skewX, skewY, resize);
1756
+ }
1757
+ });
1758
+ app.unlockLayout();
1759
+ }
1760
+ load() {
1761
+ this.editBox.view.visible = true;
1762
+ this.onLoad();
1763
+ }
1764
+ update() {
1765
+ const { editor, editBox } = this;
1766
+ const { simulateTarget, element } = editor;
1767
+ if (editor.multiple)
1768
+ simulateTarget.parent.updateLayout();
1769
+ const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = element.getLayoutBounds('box', editor, true);
1770
+ editBox.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
1771
+ editBox.update({ x: 0, y: 0, width, height });
1772
+ this.onUpdate();
1773
+ }
1774
+ unload() {
1775
+ this.editBox.view.visible = false;
1776
+ this.onUnload();
1777
+ }
1778
+ };
1779
+ exports.EditTool = __decorate([
1780
+ registerEditTool()
1781
+ ], exports.EditTool);
1782
+
1783
+ const { left, right } = draw.Direction9;
1784
+ const { move, copy } = draw.PointHelper;
1785
+ exports.LineEditTool = class LineEditTool extends exports.EditTool {
1786
+ constructor() {
1787
+ super(...arguments);
1788
+ this.scaleOfEvent = true;
1789
+ }
1790
+ get tag() { return 'LineEditTool'; }
1791
+ onScaleWithDrag(e) {
1792
+ const { drag, direction, lockRatio, around } = e;
1793
+ const line = e.target;
1794
+ const isDragFrom = direction === left;
1795
+ if (line.pathInputed) {
1796
+ const { path } = line.__;
1797
+ const { from, to } = this.getFromToByPath(path);
1798
+ this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
1799
+ path[1] = from.x, path[2] = from.y;
1800
+ path[4] = to.x, path[5] = to.y;
1801
+ line.path = path;
1802
+ }
1803
+ else if (line.points) {
1804
+ const { points } = line;
1805
+ const { from, to } = this.getFromToByPoints(points);
1806
+ this.dragPoint(from, to, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
1807
+ points[0] = from.x, points[1] = from.y;
1808
+ points[2] = to.x, points[3] = to.y;
1809
+ line.points = points;
1810
+ }
1811
+ else {
1812
+ const from = draw.getPointData();
1813
+ const { toPoint } = line;
1814
+ line.rotation = 0;
1815
+ this.dragPoint(from, toPoint, isDragFrom, around, this.getInnerMove(line, drag, lockRatio));
1816
+ line.getLocalPointByInner(from, null, null, true);
1817
+ line.getLocalPointByInner(toPoint, null, null, true);
1818
+ line.x = from.x;
1819
+ line.y = from.y;
1820
+ line.getInnerPointByLocal(toPoint, null, null, true);
1821
+ line.toPoint = toPoint;
1822
+ }
1823
+ }
1824
+ getInnerMove(ui, event, lockRatio) {
1825
+ const movePoint = event.getInnerMove(ui);
1826
+ if (lockRatio) {
1827
+ if (Math.abs(movePoint.x) > Math.abs(movePoint.y)) {
1828
+ movePoint.y = 0;
1829
+ }
1830
+ else {
1831
+ movePoint.x = 0;
1832
+ }
1833
+ }
1834
+ return movePoint;
1835
+ }
1836
+ getFromToByPath(path) {
1837
+ return {
1838
+ from: { x: path[1], y: path[2] },
1839
+ to: { x: path[4], y: path[5] }
1840
+ };
1841
+ }
1842
+ getFromToByPoints(points) {
1843
+ return {
1844
+ from: { x: points[0], y: points[1] },
1845
+ to: { x: points[2], y: points[3] }
1846
+ };
1847
+ }
1848
+ dragPoint(fromPoint, toPoint, isDragFrom, around, movePoint) {
1849
+ const { x, y } = movePoint;
1850
+ if (isDragFrom) {
1851
+ move(fromPoint, x, y);
1852
+ if (around)
1853
+ move(toPoint, -x, -y);
1854
+ }
1855
+ else {
1856
+ if (around)
1857
+ move(fromPoint, -x, -y);
1858
+ move(toPoint, x, y);
1859
+ }
1860
+ }
1861
+ onSkew(_e) {
1862
+ }
1863
+ onUpdate() {
1864
+ const { editBox } = this, { rotatePoints, resizeLines, resizePoints, rect } = editBox;
1865
+ const line = this.editor.element;
1866
+ let fromTo, leftOrRight;
1867
+ if (line.pathInputed)
1868
+ fromTo = this.getFromToByPath(line.__.path);
1869
+ else if (line.points)
1870
+ fromTo = this.getFromToByPoints(line.__.points);
1871
+ if (fromTo) {
1872
+ const { from, to } = fromTo;
1873
+ line.innerToWorld(from, from, false, editBox);
1874
+ line.innerToWorld(to, to, false, editBox);
1875
+ rect.pen.clearPath().moveTo(from.x, from.y).lineTo(to.x, to.y);
1876
+ copy(resizePoints[7], from);
1877
+ copy(rotatePoints[7], from);
1878
+ copy(resizePoints[3], to);
1879
+ copy(rotatePoints[3], to);
1880
+ }
1881
+ for (let i = 0; i < 8; i++) {
1882
+ if (i < 4)
1883
+ resizeLines[i].visible = false;
1884
+ leftOrRight = i === left || i === right;
1885
+ resizePoints[i].visible = leftOrRight;
1886
+ rotatePoints[i].visible = fromTo ? false : leftOrRight;
1887
+ }
1888
+ }
1889
+ };
1890
+ exports.LineEditTool = __decorate([
1891
+ registerEditTool()
1892
+ ], exports.LineEditTool);
1893
+
1894
+ draw.Creator.editor = function (options) { return new Editor(options); };
1895
+ draw.UI.setEditConfig = function (config) {
1896
+ draw.defineKey(this.prototype, 'editConfig', {
1897
+ get() { return typeof config === 'function' ? config(this) : config; }
1898
+ });
1899
+ };
1900
+ draw.UI.setEditOuter = function (toolName) {
1901
+ draw.defineKey(this.prototype, 'editOuter', {
1902
+ get() { return typeof toolName === 'string' ? toolName : toolName(this); }
1903
+ });
1904
+ };
1905
+ draw.UI.setEditInner = function (editorName) {
1906
+ draw.defineKey(this.prototype, 'editInner', {
1907
+ get() { return typeof editorName === 'string' ? editorName : editorName(this); }
1908
+ });
1242
1909
  };
1243
1910
 
1244
1911
  exports.EditBox = EditBox;
@@ -1246,18 +1913,28 @@ this.LeaferIN.editor = (function (exports, core) {
1246
1913
  exports.EditPoint = EditPoint;
1247
1914
  exports.EditSelect = EditSelect;
1248
1915
  exports.EditSelectHelper = EditSelectHelper;
1249
- exports.EditTool = EditTool;
1916
+ exports.EditToolCreator = EditToolCreator;
1250
1917
  exports.Editor = Editor;
1251
1918
  exports.EditorEvent = EditorEvent;
1919
+ exports.EditorGroupEvent = EditorGroupEvent;
1252
1920
  exports.EditorHelper = EditorHelper;
1253
1921
  exports.EditorMoveEvent = EditorMoveEvent;
1254
1922
  exports.EditorRotateEvent = EditorRotateEvent;
1255
1923
  exports.EditorScaleEvent = EditorScaleEvent;
1256
1924
  exports.EditorSkewEvent = EditorSkewEvent;
1257
- exports.LineEditTool = LineEditTool;
1925
+ exports.InnerEditor = InnerEditor;
1926
+ exports.InnerEditorEvent = InnerEditorEvent;
1927
+ exports.PathScaler = PathScaler;
1258
1928
  exports.SelectArea = SelectArea;
1259
1929
  exports.Stroker = Stroker;
1930
+ exports.registerEditTool = registerEditTool;
1931
+ exports.registerInnerEditor = registerInnerEditor;
1932
+ exports.scaleResize = scaleResize;
1933
+ exports.scaleResizeFontSize = scaleResizeFontSize;
1934
+ exports.scaleResizeGroup = scaleResizeGroup;
1935
+ exports.scaleResizePath = scaleResizePath;
1936
+ exports.scaleResizePoints = scaleResizePoints;
1260
1937
 
1261
1938
  return exports;
1262
1939
 
1263
- })({}, LeaferUI);
1940
+ })({}, LeaferUI, LeaferUI);