@tmagic/stage 1.3.0-beta.0 → 1.3.0-beta.2
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/tmagic-stage.js +29 -1
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +29 -1
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/ActionManager.ts +15 -2
- package/src/StageCore.ts +22 -1
- package/src/StageDragResize.ts +5 -0
- package/src/index.ts +1 -1
- package/types/ActionManager.d.ts +2 -1
- package/types/StageCore.d.ts +5 -0
- package/types/StageDragResize.d.ts +2 -0
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-beta.
|
|
2
|
+
"version": "1.3.0-beta.2",
|
|
3
3
|
"name": "@tmagic/stage",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@scena/guides": "^0.29.2",
|
|
33
|
-
"@tmagic/core": "1.3.0-beta.
|
|
34
|
-
"@tmagic/schema": "1.3.0-beta.
|
|
35
|
-
"@tmagic/utils": "1.3.0-beta.
|
|
33
|
+
"@tmagic/core": "1.3.0-beta.2",
|
|
34
|
+
"@tmagic/schema": "1.3.0-beta.2",
|
|
35
|
+
"@tmagic/utils": "1.3.0-beta.2",
|
|
36
36
|
"events": "^3.3.0",
|
|
37
37
|
"keycon": "^1.4.0",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
package/src/ActionManager.ts
CHANGED
|
@@ -19,7 +19,7 @@ import EventEmitter from 'events';
|
|
|
19
19
|
|
|
20
20
|
import KeyController from 'keycon';
|
|
21
21
|
import { throttle } from 'lodash-es';
|
|
22
|
-
import type { MoveableOptions } from 'moveable';
|
|
22
|
+
import type { MoveableOptions, OnDragStart } from 'moveable';
|
|
23
23
|
|
|
24
24
|
import { Env } from '@tmagic/core';
|
|
25
25
|
import type { Id } from '@tmagic/schema';
|
|
@@ -88,6 +88,9 @@ export default class ActionManager extends EventEmitter {
|
|
|
88
88
|
this.clearHighlight();
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
this.emit('mousemove', event);
|
|
93
|
+
|
|
91
94
|
this.highlight(el);
|
|
92
95
|
}, throttleTime);
|
|
93
96
|
|
|
@@ -204,6 +207,8 @@ export default class ActionManager extends EventEmitter {
|
|
|
204
207
|
public async getElementFromPoint(event: MouseEvent): Promise<HTMLElement | undefined> {
|
|
205
208
|
const els = this.getElementsFromPoint(event as Point);
|
|
206
209
|
|
|
210
|
+
this.emit('get-elements-from-point', els);
|
|
211
|
+
|
|
207
212
|
let stopped = false;
|
|
208
213
|
const stop = () => (stopped = true);
|
|
209
214
|
for (const el of els) {
|
|
@@ -343,6 +348,10 @@ export default class ActionManager extends EventEmitter {
|
|
|
343
348
|
return undefined;
|
|
344
349
|
}
|
|
345
350
|
|
|
351
|
+
public getDragStatus() {
|
|
352
|
+
return this.dr.getDragStatus();
|
|
353
|
+
}
|
|
354
|
+
|
|
346
355
|
public destroy(): void {
|
|
347
356
|
this.container.removeEventListener('mousedown', this.mouseDownHandler);
|
|
348
357
|
this.container.removeEventListener('mousemove', this.mouseMoveHandler);
|
|
@@ -484,6 +493,9 @@ export default class ActionManager extends EventEmitter {
|
|
|
484
493
|
data: [{ el: drTarget }],
|
|
485
494
|
};
|
|
486
495
|
this.emit('remove', data);
|
|
496
|
+
})
|
|
497
|
+
.on('drag-start', (e: OnDragStart) => {
|
|
498
|
+
this.emit('drag-start', e);
|
|
487
499
|
});
|
|
488
500
|
|
|
489
501
|
this.multiDr
|
|
@@ -555,8 +567,9 @@ export default class ActionManager extends EventEmitter {
|
|
|
555
567
|
}
|
|
556
568
|
};
|
|
557
569
|
|
|
558
|
-
private mouseLeaveHandler = () => {
|
|
570
|
+
private mouseLeaveHandler = (event: MouseEvent) => {
|
|
559
571
|
setTimeout(() => this.clearHighlight(), throttleTime);
|
|
572
|
+
this.emit('mouseleave', event);
|
|
560
573
|
};
|
|
561
574
|
|
|
562
575
|
private mouseWheelHandler = () => {
|
package/src/StageCore.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import { EventEmitter } from 'events';
|
|
20
20
|
|
|
21
|
-
import type { MoveableOptions } from 'moveable';
|
|
21
|
+
import type { MoveableOptions, OnDragStart } from 'moveable';
|
|
22
22
|
|
|
23
23
|
import type { Id } from '@tmagic/schema';
|
|
24
24
|
|
|
@@ -217,6 +217,10 @@ export default class StageCore extends EventEmitter {
|
|
|
217
217
|
return this.actionManager.getMoveableOption(key);
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
+
public getDragStatus() {
|
|
221
|
+
return this.actionManager.getDragStatus();
|
|
222
|
+
}
|
|
223
|
+
|
|
220
224
|
/**
|
|
221
225
|
* 销毁实例
|
|
222
226
|
*/
|
|
@@ -292,6 +296,7 @@ export default class StageCore extends EventEmitter {
|
|
|
292
296
|
this.initDrEvent();
|
|
293
297
|
this.initMulDrEvent();
|
|
294
298
|
this.initHighlightEvent();
|
|
299
|
+
this.initMouseEvent();
|
|
295
300
|
}
|
|
296
301
|
|
|
297
302
|
/**
|
|
@@ -356,4 +361,20 @@ export default class StageCore extends EventEmitter {
|
|
|
356
361
|
this.emit('highlight', highlightEl);
|
|
357
362
|
});
|
|
358
363
|
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* 初始化Highlight类通过ActionManager抛出来的事件监听
|
|
367
|
+
*/
|
|
368
|
+
private initMouseEvent(): void {
|
|
369
|
+
this.actionManager
|
|
370
|
+
.on('mousemove', (event: MouseEvent) => {
|
|
371
|
+
this.emit('mousemove', event);
|
|
372
|
+
})
|
|
373
|
+
.on('mouseleave', (event: MouseEvent) => {
|
|
374
|
+
this.emit('mouseleave', event);
|
|
375
|
+
})
|
|
376
|
+
.on('drag-start', (e: OnDragStart) => {
|
|
377
|
+
this.emit('drag-start', e);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
359
380
|
}
|
package/src/StageDragResize.ts
CHANGED
|
@@ -105,6 +105,10 @@ export default class StageDragResize extends MoveableOptionsManager {
|
|
|
105
105
|
this.moveable.updateRect();
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
public getDragStatus(): StageDragStatus {
|
|
109
|
+
return this.dragStatus;
|
|
110
|
+
}
|
|
111
|
+
|
|
108
112
|
/**
|
|
109
113
|
* 销毁实例
|
|
110
114
|
*/
|
|
@@ -187,6 +191,7 @@ export default class StageDragResize extends MoveableOptionsManager {
|
|
|
187
191
|
this.dragStatus = StageDragStatus.START;
|
|
188
192
|
|
|
189
193
|
this.dragResizeHelper.onDragStart(e);
|
|
194
|
+
this.emit('drag-start', e);
|
|
190
195
|
})
|
|
191
196
|
.on('drag', (e) => {
|
|
192
197
|
if (!this.target || !this.dragResizeHelper.getShadowEl()) return;
|
package/src/index.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import StageCore from './StageCore';
|
|
20
20
|
|
|
21
|
-
export type { MoveableOptions } from 'moveable';
|
|
21
|
+
export type { MoveableOptions, OnDragStart } from 'moveable';
|
|
22
22
|
export { default as StageRender } from './StageRender';
|
|
23
23
|
export { default as StageMask } from './StageMask';
|
|
24
24
|
export { default as StageDragResize } from './StageDragResize';
|
package/types/ActionManager.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import EventEmitter from 'events';
|
|
|
4
4
|
import type { MoveableOptions } from 'moveable';
|
|
5
5
|
import type { Id } from '@tmagic/schema';
|
|
6
6
|
import { GuidesType } from './const';
|
|
7
|
-
import { ActionManagerConfig, SelectStatus } from './types';
|
|
7
|
+
import { ActionManagerConfig, SelectStatus, StageDragStatus } from './types';
|
|
8
8
|
/**
|
|
9
9
|
* 管理蒙层mask之上的操作:1、监听键盘鼠标事件,判断形成单选、多选、高亮操作;2、管理单选、多选、高亮三个类协同工作。
|
|
10
10
|
* @extends EventEmitter
|
|
@@ -103,6 +103,7 @@ export default class ActionManager extends EventEmitter {
|
|
|
103
103
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
104
104
|
*/
|
|
105
105
|
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
106
|
+
getDragStatus(): StageDragStatus;
|
|
106
107
|
destroy(): void;
|
|
107
108
|
private changeCallback;
|
|
108
109
|
/**
|
package/types/StageCore.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export default class StageCore extends EventEmitter {
|
|
|
72
72
|
*/
|
|
73
73
|
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
74
74
|
getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined;
|
|
75
|
+
getDragStatus(): import("./types").StageDragStatus;
|
|
75
76
|
/**
|
|
76
77
|
* 销毁实例
|
|
77
78
|
*/
|
|
@@ -103,4 +104,8 @@ export default class StageCore extends EventEmitter {
|
|
|
103
104
|
* 初始化Highlight类通过ActionManager抛出来的事件监听
|
|
104
105
|
*/
|
|
105
106
|
private initHighlightEvent;
|
|
107
|
+
/**
|
|
108
|
+
* 初始化Highlight类通过ActionManager抛出来的事件监听
|
|
109
|
+
*/
|
|
110
|
+
private initMouseEvent;
|
|
106
111
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import MoveableOptionsManager from './MoveableOptionsManager';
|
|
2
2
|
import type { StageDragResizeConfig } from './types';
|
|
3
|
+
import { StageDragStatus } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* 管理单选操作,响应选中操作,初始化moveableOption参数并初始化moveable,处理moveable回调事件对组件进行更新
|
|
5
6
|
* @extends MoveableOptionsManager
|
|
@@ -30,6 +31,7 @@ export default class StageDragResize extends MoveableOptionsManager {
|
|
|
30
31
|
*/
|
|
31
32
|
updateMoveable(el?: HTMLElement | undefined): void;
|
|
32
33
|
clearSelectStatus(): void;
|
|
34
|
+
getDragStatus(): StageDragStatus;
|
|
33
35
|
/**
|
|
34
36
|
* 销毁实例
|
|
35
37
|
*/
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import StageCore from './StageCore';
|
|
2
|
-
export type { MoveableOptions } from 'moveable';
|
|
2
|
+
export type { MoveableOptions, OnDragStart } from 'moveable';
|
|
3
3
|
export { default as StageRender } from './StageRender';
|
|
4
4
|
export { default as StageMask } from './StageMask';
|
|
5
5
|
export { default as StageDragResize } from './StageDragResize';
|