@tmagic/stage 1.3.0-alpha.0 → 1.3.0-alpha.10
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 +17 -1
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +17 -1
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +4 -4
- package/src/ActionManager.ts +11 -1
- package/src/MoveableOptionsManager.ts +7 -1
- package/src/StageCore.ts +8 -2
- package/types/ActionManager.d.ts +3 -1
- package/types/MoveableOptionsManager.d.ts +2 -0
- package/types/StageCore.d.ts +4 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.0-alpha.
|
|
2
|
+
"version": "1.3.0-alpha.10",
|
|
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.23.3",
|
|
33
|
-
"@tmagic/core": "1.3.0-alpha.
|
|
34
|
-
"@tmagic/schema": "1.3.0-alpha.
|
|
35
|
-
"@tmagic/utils": "1.3.0-alpha.
|
|
33
|
+
"@tmagic/core": "1.3.0-alpha.10",
|
|
34
|
+
"@tmagic/schema": "1.3.0-alpha.10",
|
|
35
|
+
"@tmagic/utils": "1.3.0-alpha.10",
|
|
36
36
|
"events": "^3.3.0",
|
|
37
37
|
"keycon": "^1.1.2",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
package/src/ActionManager.ts
CHANGED
|
@@ -19,9 +19,10 @@ 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
23
|
|
|
23
24
|
import { Env } from '@tmagic/core';
|
|
24
|
-
import { Id } from '@tmagic/schema';
|
|
25
|
+
import type { Id } from '@tmagic/schema';
|
|
25
26
|
import { addClassName, getDocument, removeClassNameByClassName } from '@tmagic/utils';
|
|
26
27
|
|
|
27
28
|
import { CONTAINER_HIGHLIGHT_CLASS_NAME, GHOST_EL_ID_PREFIX, GuidesType, MouseButton, PAGE_CLASS } from './const';
|
|
@@ -186,6 +187,15 @@ export default class ActionManager extends EventEmitter {
|
|
|
186
187
|
return this.selectedElList;
|
|
187
188
|
}
|
|
188
189
|
|
|
190
|
+
public getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined {
|
|
191
|
+
if (this.dr.getTarget()) {
|
|
192
|
+
return this.dr.getOption(key);
|
|
193
|
+
}
|
|
194
|
+
if (this.multiDr.targetList.length) {
|
|
195
|
+
return this.multiDr.getOption(key);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
189
199
|
/**
|
|
190
200
|
* 获取鼠标下方第一个可选中元素,如果元素层叠,返回到是最上层元素
|
|
191
201
|
* @param event 鼠标事件
|
|
@@ -36,6 +36,7 @@ export default class MoveableOptionsManager extends EventEmitter {
|
|
|
36
36
|
|
|
37
37
|
/** 画布容器 */
|
|
38
38
|
protected container: HTMLElement;
|
|
39
|
+
protected options: MoveableOptions = {};
|
|
39
40
|
|
|
40
41
|
/** 水平参考线 */
|
|
41
42
|
private horizontalGuidelines: number[] = [];
|
|
@@ -55,6 +56,10 @@ export default class MoveableOptionsManager extends EventEmitter {
|
|
|
55
56
|
this.getRootContainer = config.getRootContainer;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
public getOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] {
|
|
60
|
+
return this.options[key];
|
|
61
|
+
}
|
|
62
|
+
|
|
58
63
|
/**
|
|
59
64
|
* 设置水平/垂直参考线
|
|
60
65
|
* @param type 参考线类型
|
|
@@ -106,7 +111,8 @@ export default class MoveableOptionsManager extends EventEmitter {
|
|
|
106
111
|
const defaultOptions = this.getDefaultOptions(isMultiSelect);
|
|
107
112
|
const customizedOptions = this.getCustomizeOptions();
|
|
108
113
|
|
|
109
|
-
|
|
114
|
+
this.options = merge(defaultOptions, customizedOptions, runtimeOptions);
|
|
115
|
+
return this.options;
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
/**
|
package/src/StageCore.ts
CHANGED
|
@@ -18,13 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
import { EventEmitter } from 'events';
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import type { MoveableOptions } from 'moveable';
|
|
22
|
+
|
|
23
|
+
import type { Id } from '@tmagic/schema';
|
|
22
24
|
|
|
23
25
|
import ActionManager from './ActionManager';
|
|
24
26
|
import { DEFAULT_ZOOM } from './const';
|
|
25
27
|
import StageMask from './StageMask';
|
|
26
28
|
import StageRender from './StageRender';
|
|
27
|
-
import {
|
|
29
|
+
import type {
|
|
28
30
|
ActionManagerConfig,
|
|
29
31
|
CustomizeRender,
|
|
30
32
|
GuidesEventData,
|
|
@@ -207,6 +209,10 @@ export default class StageCore extends EventEmitter {
|
|
|
207
209
|
return this.actionManager.delayedMarkContainer(event, excludeElList);
|
|
208
210
|
}
|
|
209
211
|
|
|
212
|
+
public getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined {
|
|
213
|
+
return this.actionManager.getMoveableOption(key);
|
|
214
|
+
}
|
|
215
|
+
|
|
210
216
|
/**
|
|
211
217
|
* 销毁实例
|
|
212
218
|
*/
|
package/types/ActionManager.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
|
-
import {
|
|
4
|
+
import type { MoveableOptions } from 'moveable';
|
|
5
|
+
import type { Id } from '@tmagic/schema';
|
|
5
6
|
import { GuidesType } from './const';
|
|
6
7
|
import { ActionManagerConfig, SelectStatus } from './types';
|
|
7
8
|
/**
|
|
@@ -58,6 +59,7 @@ export default class ActionManager extends EventEmitter {
|
|
|
58
59
|
setSelectedEl(el: HTMLElement): void;
|
|
59
60
|
getSelectedEl(): HTMLElement | undefined;
|
|
60
61
|
getSelectedElList(): HTMLElement[];
|
|
62
|
+
getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined;
|
|
61
63
|
/**
|
|
62
64
|
* 获取鼠标下方第一个可选中元素,如果元素层叠,返回到是最上层元素
|
|
63
65
|
* @param event 鼠标事件
|
|
@@ -12,6 +12,7 @@ export default class MoveableOptionsManager extends EventEmitter {
|
|
|
12
12
|
mode: Mode;
|
|
13
13
|
/** 画布容器 */
|
|
14
14
|
protected container: HTMLElement;
|
|
15
|
+
protected options: MoveableOptions;
|
|
15
16
|
/** 水平参考线 */
|
|
16
17
|
private horizontalGuidelines;
|
|
17
18
|
/** 垂直参考线 */
|
|
@@ -23,6 +24,7 @@ export default class MoveableOptionsManager extends EventEmitter {
|
|
|
23
24
|
/** 获取整个画布的根元素(在StageCore的mount函数中挂载的container) */
|
|
24
25
|
private getRootContainer;
|
|
25
26
|
constructor(config: MoveableOptionsManagerConfig);
|
|
27
|
+
getOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K];
|
|
26
28
|
/**
|
|
27
29
|
* 设置水平/垂直参考线
|
|
28
30
|
* @param type 参考线类型
|
package/types/StageCore.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
|
-
import {
|
|
4
|
+
import type { MoveableOptions } from 'moveable';
|
|
5
|
+
import type { Id } from '@tmagic/schema';
|
|
5
6
|
import StageMask from './StageMask';
|
|
6
7
|
import StageRender from './StageRender';
|
|
7
|
-
import { RemoveData, StageCoreConfig, UpdateData } from './types';
|
|
8
|
+
import type { RemoveData, StageCoreConfig, UpdateData } from './types';
|
|
8
9
|
/**
|
|
9
10
|
* 负责管理画布,管理renderer、mask、actionManager三个核心类,并负责统一对外通信,包括提供接口和抛事件
|
|
10
11
|
*/
|
|
@@ -69,6 +70,7 @@ export default class StageCore extends EventEmitter {
|
|
|
69
70
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
70
71
|
*/
|
|
71
72
|
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
73
|
+
getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined;
|
|
72
74
|
/**
|
|
73
75
|
* 销毁实例
|
|
74
76
|
*/
|