@tmagic/stage 1.2.7 → 1.2.8
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 +65 -51
- package/dist/tmagic-stage.js.map +1 -1
- package/dist/tmagic-stage.umd.cjs +69 -55
- package/dist/tmagic-stage.umd.cjs.map +1 -1
- package/package.json +6 -6
- package/src/ActionManager.ts +23 -16
- package/src/DragResizeHelper.ts +40 -2
- package/src/StageCore.ts +7 -4
- package/src/StageDragResize.ts +4 -34
- package/src/StageMultiDragResize.ts +28 -14
- package/src/types.ts +5 -2
- package/types/ActionManager.d.ts +1 -1
- package/types/DragResizeHelper.d.ts +2 -1
- package/types/StageCore.d.ts +2 -2
- package/types/StageMultiDragResize.d.ts +2 -0
- package/types/types.d.ts +5 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.8",
|
|
3
3
|
"name": "@tmagic/stage",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"url": "https://github.com/Tencent/tmagic-editor.git"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@scena/guides": "^0.
|
|
33
|
-
"@tmagic/core": "1.2.
|
|
34
|
-
"@tmagic/schema": "1.2.
|
|
35
|
-
"@tmagic/utils": "1.2.
|
|
32
|
+
"@scena/guides": "^0.23.3",
|
|
33
|
+
"@tmagic/core": "1.2.8",
|
|
34
|
+
"@tmagic/schema": "1.2.8",
|
|
35
|
+
"@tmagic/utils": "1.2.8",
|
|
36
36
|
"events": "^3.3.0",
|
|
37
37
|
"keycon": "^1.1.2",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
|
39
|
-
"moveable": "^0.
|
|
39
|
+
"moveable": "^0.43.1",
|
|
40
40
|
"moveable-helper": "^0.4.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
package/src/ActionManager.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { Id } from '@tmagic/schema';
|
|
|
25
25
|
import { addClassName, getDocument, removeClassNameByClassName } from '@tmagic/utils';
|
|
26
26
|
|
|
27
27
|
import { CONTAINER_HIGHLIGHT_CLASS_NAME, GHOST_EL_ID_PREFIX, GuidesType, MouseButton, PAGE_CLASS } from './const';
|
|
28
|
+
import DragResizeHelper from './DragResizeHelper';
|
|
28
29
|
import StageDragResize from './StageDragResize';
|
|
29
30
|
import StageHighlight from './StageHighlight';
|
|
30
31
|
import StageMultiDragResize from './StageMultiDragResize';
|
|
@@ -101,27 +102,30 @@ export default class ActionManager extends EventEmitter {
|
|
|
101
102
|
this.getRenderDocument = config.getRenderDocument;
|
|
102
103
|
this.isContainer = config.isContainer;
|
|
103
104
|
|
|
105
|
+
const createDrHelper = () =>
|
|
106
|
+
new DragResizeHelper({
|
|
107
|
+
container: config.container,
|
|
108
|
+
updateDragEl: config.updateDragEl,
|
|
109
|
+
});
|
|
110
|
+
|
|
104
111
|
this.dr = new StageDragResize({
|
|
105
112
|
container: config.container,
|
|
106
113
|
disabledDragStart: config.disabledDragStart,
|
|
114
|
+
moveableOptions: this.changeCallback(config.moveableOptions),
|
|
115
|
+
dragResizeHelper: createDrHelper(),
|
|
107
116
|
getRootContainer: config.getRootContainer,
|
|
108
117
|
getRenderDocument: config.getRenderDocument,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
delayedMarkContainer: (event: MouseEvent, exclude: Element[]) => {
|
|
112
|
-
if (this.canAddToContainer()) {
|
|
113
|
-
return this.delayedMarkContainer(event, exclude);
|
|
114
|
-
}
|
|
115
|
-
return undefined;
|
|
116
|
-
},
|
|
117
|
-
moveableOptions: this.changeCallback(config.moveableOptions),
|
|
118
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
119
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this),
|
|
118
120
|
});
|
|
119
121
|
this.multiDr = new StageMultiDragResize({
|
|
120
122
|
container: config.container,
|
|
121
123
|
multiMoveableOptions: config.multiMoveableOptions,
|
|
124
|
+
dragResizeHelper: createDrHelper(),
|
|
122
125
|
getRootContainer: config.getRootContainer,
|
|
123
126
|
getRenderDocument: config.getRenderDocument,
|
|
124
|
-
|
|
127
|
+
markContainerEnd: this.markContainerEnd.bind(this),
|
|
128
|
+
delayedMarkContainer: this.delayedMarkContainer.bind(this),
|
|
125
129
|
});
|
|
126
130
|
this.highlightLayer = new StageHighlight({
|
|
127
131
|
container: config.container,
|
|
@@ -320,10 +324,13 @@ export default class ActionManager extends EventEmitter {
|
|
|
320
324
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
|
321
325
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
322
326
|
*/
|
|
323
|
-
public delayedMarkContainer(event: MouseEvent, excludeElList: Element[] = []): NodeJS.Timeout {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
public delayedMarkContainer(event: MouseEvent, excludeElList: Element[] = []): NodeJS.Timeout | undefined {
|
|
328
|
+
if (this.canAddToContainer()) {
|
|
329
|
+
return globalThis.setTimeout(() => {
|
|
330
|
+
this.addContainerHighlightClassName(event, excludeElList);
|
|
331
|
+
}, this.containerHighlightDuration);
|
|
332
|
+
}
|
|
333
|
+
return undefined;
|
|
327
334
|
}
|
|
328
335
|
|
|
329
336
|
public destroy(): void {
|
|
@@ -466,8 +473,8 @@ export default class ActionManager extends EventEmitter {
|
|
|
466
473
|
});
|
|
467
474
|
|
|
468
475
|
this.multiDr
|
|
469
|
-
.on('update', (data: UpdateEventData
|
|
470
|
-
this.emit('multi-update', data
|
|
476
|
+
.on('update', (data: UpdateEventData) => {
|
|
477
|
+
this.emit('multi-update', data);
|
|
471
478
|
})
|
|
472
479
|
.on('change-to-select', async (id: Id) => {
|
|
473
480
|
// 如果还在多选状态,不触发切换到单选
|
package/src/DragResizeHelper.ts
CHANGED
|
@@ -34,8 +34,8 @@ import MoveableHelper from 'moveable-helper';
|
|
|
34
34
|
|
|
35
35
|
import { DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, Mode, ZIndex } from './const';
|
|
36
36
|
import TargetShadow from './TargetShadow';
|
|
37
|
-
import { DragResizeHelperConfig, TargetElement } from './types';
|
|
38
|
-
import { getAbsolutePosition, getOffset } from './util';
|
|
37
|
+
import { DragResizeHelperConfig, Rect, TargetElement } from './types';
|
|
38
|
+
import { calcValueByFontsize, getAbsolutePosition, getOffset } from './util';
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* 拖拽/改变大小等操作发生时,moveable会抛出各种状态事件,DragResizeHelper负责响应这些事件,对目标节点target和拖拽节点targetShadow进行修改;
|
|
@@ -282,6 +282,44 @@ export default class DragResizeHelper {
|
|
|
282
282
|
this.moveableHelper.onDragGroup(e);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
public getUpdatedElRect(el: HTMLElement, parentEl: HTMLElement | null, doc: Document): Rect {
|
|
286
|
+
const offset = this.mode === Mode.SORTABLE ? { left: 0, top: 0 } : { left: el.offsetLeft, top: el.offsetTop };
|
|
287
|
+
|
|
288
|
+
let left = calcValueByFontsize(doc, offset.left);
|
|
289
|
+
let top = calcValueByFontsize(doc, offset.top);
|
|
290
|
+
const width = calcValueByFontsize(doc, el.clientWidth);
|
|
291
|
+
const height = calcValueByFontsize(doc, el.clientHeight);
|
|
292
|
+
|
|
293
|
+
let shadowEl = this.getShadowEl();
|
|
294
|
+
const shadowEls = this.getShadowEls();
|
|
295
|
+
|
|
296
|
+
if (shadowEls.length) {
|
|
297
|
+
shadowEl = shadowEls.find((item) => item.id.endsWith(el.id));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (parentEl && this.mode === Mode.ABSOLUTE && shadowEl) {
|
|
301
|
+
const targetShadowHtmlEl = shadowEl as HTMLElement;
|
|
302
|
+
const targetShadowElOffsetLeft = targetShadowHtmlEl.offsetLeft || 0;
|
|
303
|
+
const targetShadowElOffsetTop = targetShadowHtmlEl.offsetTop || 0;
|
|
304
|
+
|
|
305
|
+
const frame = this.getFrame(shadowEl);
|
|
306
|
+
|
|
307
|
+
const [translateX, translateY] = frame?.properties.transform.translate.value;
|
|
308
|
+
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
309
|
+
|
|
310
|
+
left =
|
|
311
|
+
calcValueByFontsize(doc, targetShadowElOffsetLeft) +
|
|
312
|
+
parseFloat(translateX) -
|
|
313
|
+
calcValueByFontsize(doc, parentLeft);
|
|
314
|
+
top =
|
|
315
|
+
calcValueByFontsize(doc, targetShadowElOffsetTop) +
|
|
316
|
+
parseFloat(translateY) -
|
|
317
|
+
calcValueByFontsize(doc, parentTop);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return { width, height, left, top };
|
|
321
|
+
}
|
|
322
|
+
|
|
285
323
|
/**
|
|
286
324
|
* 多选状态设置多个节点的快照
|
|
287
325
|
*/
|
package/src/StageCore.ts
CHANGED
|
@@ -189,7 +189,10 @@ export default class StageCore extends EventEmitter {
|
|
|
189
189
|
/**
|
|
190
190
|
* @deprecated 废弃接口,建议用delayedMarkContainer代替
|
|
191
191
|
*/
|
|
192
|
-
public getAddContainerHighlightClassNameTimeout(
|
|
192
|
+
public getAddContainerHighlightClassNameTimeout(
|
|
193
|
+
event: MouseEvent,
|
|
194
|
+
excludeElList: Element[] = [],
|
|
195
|
+
): NodeJS.Timeout | undefined {
|
|
193
196
|
return this.delayedMarkContainer(event, excludeElList);
|
|
194
197
|
}
|
|
195
198
|
|
|
@@ -200,7 +203,7 @@ export default class StageCore extends EventEmitter {
|
|
|
200
203
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
|
201
204
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
202
205
|
*/
|
|
203
|
-
public delayedMarkContainer(event: MouseEvent, excludeElList: Element[] = []): NodeJS.Timeout {
|
|
206
|
+
public delayedMarkContainer(event: MouseEvent, excludeElList: Element[] = []): NodeJS.Timeout | undefined {
|
|
204
207
|
return this.actionManager.delayedMarkContainer(event, excludeElList);
|
|
205
208
|
}
|
|
206
209
|
|
|
@@ -331,8 +334,8 @@ export default class StageCore extends EventEmitter {
|
|
|
331
334
|
// 先保证画布内完成渲染,再通知外部更新
|
|
332
335
|
setTimeout(() => this.emit('select', el));
|
|
333
336
|
})
|
|
334
|
-
.on('multi-update', (data: UpdateEventData
|
|
335
|
-
this.emit('update',
|
|
337
|
+
.on('multi-update', (data: UpdateEventData) => {
|
|
338
|
+
this.emit('update', data);
|
|
336
339
|
});
|
|
337
340
|
}
|
|
338
341
|
|
package/src/StageDragResize.ts
CHANGED
|
@@ -24,7 +24,7 @@ import DragResizeHelper from './DragResizeHelper';
|
|
|
24
24
|
import MoveableOptionsManager from './MoveableOptionsManager';
|
|
25
25
|
import type { DelayedMarkContainer, GetRenderDocument, MarkContainerEnd, StageDragResizeConfig } from './types';
|
|
26
26
|
import { StageDragStatus } from './types';
|
|
27
|
-
import {
|
|
27
|
+
import { down, getMode, up } from './util';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* 管理单选操作,响应选中操作,初始化moveableOption参数并初始化moveable,处理moveable回调事件对组件进行更新
|
|
@@ -51,10 +51,7 @@ export default class StageDragResize extends MoveableOptionsManager {
|
|
|
51
51
|
this.delayedMarkContainer = config.delayedMarkContainer;
|
|
52
52
|
this.disabledDragStart = config.disabledDragStart;
|
|
53
53
|
|
|
54
|
-
this.dragResizeHelper =
|
|
55
|
-
container: config.container,
|
|
56
|
-
updateDragEl: config.updateDragEl,
|
|
57
|
-
});
|
|
54
|
+
this.dragResizeHelper = config.dragResizeHelper;
|
|
58
55
|
|
|
59
56
|
this.on('update-moveable', () => {
|
|
60
57
|
if (this.moveable) {
|
|
@@ -315,40 +312,13 @@ export default class StageDragResize extends MoveableOptionsManager {
|
|
|
315
312
|
|
|
316
313
|
if (!doc) return;
|
|
317
314
|
|
|
318
|
-
const
|
|
319
|
-
this.mode === Mode.SORTABLE ? { left: 0, top: 0 } : { left: this.target.offsetLeft, top: this.target.offsetTop };
|
|
320
|
-
|
|
321
|
-
let left = calcValueByFontsize(doc, offset.left);
|
|
322
|
-
let top = calcValueByFontsize(doc, offset.top);
|
|
323
|
-
const width = calcValueByFontsize(doc, this.target.clientWidth);
|
|
324
|
-
const height = calcValueByFontsize(doc, this.target.clientHeight);
|
|
325
|
-
|
|
326
|
-
const shadowEl = this.dragResizeHelper.getShadowEl();
|
|
327
|
-
if (parentEl && this.mode === Mode.ABSOLUTE && shadowEl) {
|
|
328
|
-
const targetShadowHtmlEl = shadowEl as HTMLElement;
|
|
329
|
-
const targetShadowElOffsetLeft = targetShadowHtmlEl.offsetLeft || 0;
|
|
330
|
-
const targetShadowElOffsetTop = targetShadowHtmlEl.offsetTop || 0;
|
|
331
|
-
|
|
332
|
-
const frame = this.dragResizeHelper.getFrame(shadowEl);
|
|
333
|
-
|
|
334
|
-
const [translateX, translateY] = frame?.properties.transform.translate.value;
|
|
335
|
-
const { left: parentLeft, top: parentTop } = getOffset(parentEl);
|
|
336
|
-
|
|
337
|
-
left =
|
|
338
|
-
calcValueByFontsize(doc, targetShadowElOffsetLeft) +
|
|
339
|
-
parseFloat(translateX) -
|
|
340
|
-
calcValueByFontsize(doc, parentLeft);
|
|
341
|
-
top =
|
|
342
|
-
calcValueByFontsize(doc, targetShadowElOffsetTop) +
|
|
343
|
-
parseFloat(translateY) -
|
|
344
|
-
calcValueByFontsize(doc, parentTop);
|
|
345
|
-
}
|
|
315
|
+
const rect = this.dragResizeHelper.getUpdatedElRect(this.target, parentEl, doc);
|
|
346
316
|
|
|
347
317
|
this.emit('update', {
|
|
348
318
|
data: [
|
|
349
319
|
{
|
|
350
320
|
el: this.target,
|
|
351
|
-
style: isResize ?
|
|
321
|
+
style: isResize ? rect : { left: rect.left, top: rect.top },
|
|
352
322
|
},
|
|
353
323
|
],
|
|
354
324
|
parentEl,
|
|
@@ -21,8 +21,15 @@ import Moveable from 'moveable';
|
|
|
21
21
|
import { DRAG_EL_ID_PREFIX, Mode } from './const';
|
|
22
22
|
import DragResizeHelper from './DragResizeHelper';
|
|
23
23
|
import MoveableOptionsManager from './MoveableOptionsManager';
|
|
24
|
-
import {
|
|
25
|
-
|
|
24
|
+
import {
|
|
25
|
+
DelayedMarkContainer,
|
|
26
|
+
GetRenderDocument,
|
|
27
|
+
MarkContainerEnd,
|
|
28
|
+
MoveableOptionsManagerConfig,
|
|
29
|
+
StageDragStatus,
|
|
30
|
+
StageMultiDragResizeConfig,
|
|
31
|
+
} from './types';
|
|
32
|
+
import { getMode } from './util';
|
|
26
33
|
|
|
27
34
|
export default class StageMultiDragResize extends MoveableOptionsManager {
|
|
28
35
|
/** 画布容器 */
|
|
@@ -34,6 +41,8 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
34
41
|
public dragStatus: StageDragStatus = StageDragStatus.END;
|
|
35
42
|
private dragResizeHelper: DragResizeHelper;
|
|
36
43
|
private getRenderDocument: GetRenderDocument;
|
|
44
|
+
private delayedMarkContainer: DelayedMarkContainer;
|
|
45
|
+
private markContainerEnd: MarkContainerEnd;
|
|
37
46
|
|
|
38
47
|
constructor(config: StageMultiDragResizeConfig) {
|
|
39
48
|
const moveableOptionsManagerConfig: MoveableOptionsManagerConfig = {
|
|
@@ -43,13 +52,12 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
43
52
|
};
|
|
44
53
|
super(moveableOptionsManagerConfig);
|
|
45
54
|
|
|
55
|
+
this.delayedMarkContainer = config.delayedMarkContainer;
|
|
56
|
+
this.markContainerEnd = config.markContainerEnd;
|
|
46
57
|
this.container = config.container;
|
|
47
58
|
this.getRenderDocument = config.getRenderDocument;
|
|
48
59
|
|
|
49
|
-
this.dragResizeHelper =
|
|
50
|
-
container: config.container,
|
|
51
|
-
updateDragEl: config.updateDragEl,
|
|
52
|
-
});
|
|
60
|
+
this.dragResizeHelper = config.dragResizeHelper;
|
|
53
61
|
|
|
54
62
|
this.on('update-moveable', () => {
|
|
55
63
|
if (this.moveableForMulti) {
|
|
@@ -85,6 +93,8 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
85
93
|
}),
|
|
86
94
|
);
|
|
87
95
|
|
|
96
|
+
let timeout: NodeJS.Timeout | undefined;
|
|
97
|
+
|
|
88
98
|
this.moveableForMulti
|
|
89
99
|
.on('resizeGroupStart', (e) => {
|
|
90
100
|
this.dragResizeHelper.onResizeGroupStart(e);
|
|
@@ -103,11 +113,18 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
103
113
|
this.dragStatus = StageDragStatus.START;
|
|
104
114
|
})
|
|
105
115
|
.on('dragGroup', (e) => {
|
|
116
|
+
if (timeout) {
|
|
117
|
+
globalThis.clearTimeout(timeout);
|
|
118
|
+
timeout = undefined;
|
|
119
|
+
}
|
|
120
|
+
timeout = this.delayedMarkContainer(e.inputEvent, this.targetList);
|
|
121
|
+
|
|
106
122
|
this.dragResizeHelper.onDragGroup(e);
|
|
107
123
|
this.dragStatus = StageDragStatus.ING;
|
|
108
124
|
})
|
|
109
125
|
.on('dragGroupEnd', () => {
|
|
110
|
-
this.
|
|
126
|
+
const parentEl = this.markContainerEnd();
|
|
127
|
+
this.update(false, parentEl);
|
|
111
128
|
this.dragStatus = StageDragStatus.END;
|
|
112
129
|
})
|
|
113
130
|
.on('clickGroup', (e) => {
|
|
@@ -182,22 +199,19 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
182
199
|
* 拖拽完成后将更新的位置信息暴露给上层业务方,业务方可以接收事件进行保存
|
|
183
200
|
* @param isResize 是否进行大小缩放
|
|
184
201
|
*/
|
|
185
|
-
private update(isResize = false): void {
|
|
202
|
+
private update(isResize = false, parentEl: HTMLElement | null = null): void {
|
|
186
203
|
if (this.targetList.length === 0) return;
|
|
187
204
|
|
|
188
205
|
const doc = this.getRenderDocument();
|
|
189
206
|
if (!doc) return;
|
|
190
207
|
|
|
191
208
|
const data = this.targetList.map((targetItem) => {
|
|
192
|
-
const
|
|
193
|
-
const top = calcValueByFontsize(doc, targetItem.offsetTop);
|
|
194
|
-
const width = calcValueByFontsize(doc, targetItem.clientWidth);
|
|
195
|
-
const height = calcValueByFontsize(doc, targetItem.clientHeight);
|
|
209
|
+
const rect = this.dragResizeHelper.getUpdatedElRect(targetItem, parentEl, doc);
|
|
196
210
|
return {
|
|
197
211
|
el: targetItem,
|
|
198
|
-
style: isResize ?
|
|
212
|
+
style: isResize ? rect : { left: rect.left, top: rect.top },
|
|
199
213
|
};
|
|
200
214
|
});
|
|
201
|
-
this.emit('update', data,
|
|
215
|
+
this.emit('update', { data, parentEl });
|
|
202
216
|
}
|
|
203
217
|
}
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,7 @@ import Core from '@tmagic/core';
|
|
|
22
22
|
import type { Id, MApp, MContainer, MNode } from '@tmagic/schema';
|
|
23
23
|
|
|
24
24
|
import { GuidesType, ZIndex } from './const';
|
|
25
|
+
import DragResizeHelper from './DragResizeHelper';
|
|
25
26
|
import StageCore from './StageCore';
|
|
26
27
|
|
|
27
28
|
export type TargetElement = HTMLElement | SVGElement;
|
|
@@ -112,21 +113,23 @@ export interface StageMaskConfig {
|
|
|
112
113
|
|
|
113
114
|
export interface StageDragResizeConfig {
|
|
114
115
|
container: HTMLElement;
|
|
116
|
+
dragResizeHelper: DragResizeHelper;
|
|
115
117
|
moveableOptions?: CustomizeMoveableOptions;
|
|
116
118
|
disabledDragStart?: boolean;
|
|
117
119
|
getRootContainer: GetRootContainer;
|
|
118
120
|
getRenderDocument: GetRenderDocument;
|
|
119
121
|
markContainerEnd: MarkContainerEnd;
|
|
120
122
|
delayedMarkContainer: DelayedMarkContainer;
|
|
121
|
-
updateDragEl?: UpdateDragEl;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
export interface StageMultiDragResizeConfig {
|
|
125
126
|
container: HTMLElement;
|
|
127
|
+
dragResizeHelper: DragResizeHelper;
|
|
126
128
|
multiMoveableOptions?: CustomizeMoveableOptions;
|
|
127
129
|
getRootContainer: GetRootContainer;
|
|
128
130
|
getRenderDocument: GetRenderDocument;
|
|
129
|
-
|
|
131
|
+
markContainerEnd: MarkContainerEnd;
|
|
132
|
+
delayedMarkContainer: DelayedMarkContainer;
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
export interface DragResizeHelperConfig {
|
package/types/ActionManager.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export default class ActionManager extends EventEmitter {
|
|
|
100
100
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
|
101
101
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
102
102
|
*/
|
|
103
|
-
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout;
|
|
103
|
+
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
104
104
|
destroy(): void;
|
|
105
105
|
private changeCallback;
|
|
106
106
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OnDrag, OnDragGroup, OnDragGroupStart, OnDragStart, OnResize, OnResizeGroup, OnResizeGroupStart, OnResizeStart, OnRotate, OnRotateStart, OnScale, OnScaleStart } from 'moveable';
|
|
2
2
|
import MoveableHelper from 'moveable-helper';
|
|
3
3
|
import { Mode } from './const';
|
|
4
|
-
import { DragResizeHelperConfig, TargetElement } from './types';
|
|
4
|
+
import { DragResizeHelperConfig, Rect, TargetElement } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* 拖拽/改变大小等操作发生时,moveable会抛出各种状态事件,DragResizeHelper负责响应这些事件,对目标节点target和拖拽节点targetShadow进行修改;
|
|
7
7
|
* 其中目标节点是DragResizeHelper直接改的,targetShadow作为直接被操作的拖拽框,是调用moveableHelper改的;
|
|
@@ -58,6 +58,7 @@ export default class DragResizeHelper {
|
|
|
58
58
|
onResizeGroup(e: OnResizeGroup): void;
|
|
59
59
|
onDragGroupStart(e: OnDragGroupStart): void;
|
|
60
60
|
onDragGroup(e: OnDragGroup): void;
|
|
61
|
+
getUpdatedElRect(el: HTMLElement, parentEl: HTMLElement | null, doc: Document): Rect;
|
|
61
62
|
/**
|
|
62
63
|
* 多选状态设置多个节点的快照
|
|
63
64
|
*/
|
package/types/StageCore.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export default class StageCore extends EventEmitter {
|
|
|
60
60
|
/**
|
|
61
61
|
* @deprecated 废弃接口,建议用delayedMarkContainer代替
|
|
62
62
|
*/
|
|
63
|
-
getAddContainerHighlightClassNameTimeout(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout;
|
|
63
|
+
getAddContainerHighlightClassNameTimeout(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
64
64
|
/**
|
|
65
65
|
* 鼠标拖拽着元素,在容器上方悬停,延迟一段时间后,对容器进行标记,如果悬停时间够长将标记成功,悬停时间短,调用方通过返回的timeoutId取消标记
|
|
66
66
|
* 标记的作用:1、高亮容器,给用户一个加入容器的交互感知;2、释放鼠标后,通过标记的标志找到要加入的容器
|
|
@@ -68,7 +68,7 @@ export default class StageCore extends EventEmitter {
|
|
|
68
68
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
|
69
69
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
70
70
|
*/
|
|
71
|
-
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout;
|
|
71
|
+
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
72
72
|
/**
|
|
73
73
|
* 销毁实例
|
|
74
74
|
*/
|
|
@@ -11,6 +11,8 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
|
|
|
11
11
|
dragStatus: StageDragStatus;
|
|
12
12
|
private dragResizeHelper;
|
|
13
13
|
private getRenderDocument;
|
|
14
|
+
private delayedMarkContainer;
|
|
15
|
+
private markContainerEnd;
|
|
14
16
|
constructor(config: StageMultiDragResizeConfig);
|
|
15
17
|
/**
|
|
16
18
|
* 多选
|
package/types/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { MoveableOptions } from 'moveable';
|
|
|
3
3
|
import Core from '@tmagic/core';
|
|
4
4
|
import type { Id, MApp, MContainer, MNode } from '@tmagic/schema';
|
|
5
5
|
import { GuidesType, ZIndex } from './const';
|
|
6
|
+
import DragResizeHelper from './DragResizeHelper';
|
|
6
7
|
import StageCore from './StageCore';
|
|
7
8
|
export declare type TargetElement = HTMLElement | SVGElement;
|
|
8
9
|
export declare type CanSelect = (el: HTMLElement, event: MouseEvent, stop: () => boolean) => boolean | Promise<boolean>;
|
|
@@ -79,20 +80,22 @@ export interface StageMaskConfig {
|
|
|
79
80
|
}
|
|
80
81
|
export interface StageDragResizeConfig {
|
|
81
82
|
container: HTMLElement;
|
|
83
|
+
dragResizeHelper: DragResizeHelper;
|
|
82
84
|
moveableOptions?: CustomizeMoveableOptions;
|
|
83
85
|
disabledDragStart?: boolean;
|
|
84
86
|
getRootContainer: GetRootContainer;
|
|
85
87
|
getRenderDocument: GetRenderDocument;
|
|
86
88
|
markContainerEnd: MarkContainerEnd;
|
|
87
89
|
delayedMarkContainer: DelayedMarkContainer;
|
|
88
|
-
updateDragEl?: UpdateDragEl;
|
|
89
90
|
}
|
|
90
91
|
export interface StageMultiDragResizeConfig {
|
|
91
92
|
container: HTMLElement;
|
|
93
|
+
dragResizeHelper: DragResizeHelper;
|
|
92
94
|
multiMoveableOptions?: CustomizeMoveableOptions;
|
|
93
95
|
getRootContainer: GetRootContainer;
|
|
94
96
|
getRenderDocument: GetRenderDocument;
|
|
95
|
-
|
|
97
|
+
markContainerEnd: MarkContainerEnd;
|
|
98
|
+
delayedMarkContainer: DelayedMarkContainer;
|
|
96
99
|
}
|
|
97
100
|
export interface DragResizeHelperConfig {
|
|
98
101
|
container: HTMLElement;
|