@tmagic/stage 1.3.0-alpha.17 → 1.3.0-alpha.18

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.0-alpha.17",
2
+ "version": "1.3.0-alpha.18",
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-alpha.17",
34
- "@tmagic/schema": "1.3.0-alpha.17",
35
- "@tmagic/utils": "1.3.0-alpha.17",
33
+ "@tmagic/core": "1.3.0-alpha.18",
34
+ "@tmagic/schema": "1.3.0-alpha.18",
35
+ "@tmagic/utils": "1.3.0-alpha.18",
36
36
  "events": "^3.3.0",
37
37
  "keycon": "^1.4.0",
38
38
  "lodash-es": "^4.17.21",
@@ -112,7 +112,7 @@ export default class ActionManager extends EventEmitter {
112
112
  this.dr = new StageDragResize({
113
113
  container: config.container,
114
114
  disabledDragStart: config.disabledDragStart,
115
- moveableOptions: this.changeCallback(config.moveableOptions),
115
+ moveableOptions: this.changeCallback(config.moveableOptions, false),
116
116
  dragResizeHelper: createDrHelper(),
117
117
  getRootContainer: config.getRootContainer,
118
118
  getRenderDocument: config.getRenderDocument,
@@ -121,7 +121,7 @@ export default class ActionManager extends EventEmitter {
121
121
  });
122
122
  this.multiDr = new StageMultiDragResize({
123
123
  container: config.container,
124
- multiMoveableOptions: config.multiMoveableOptions,
124
+ moveableOptions: this.changeCallback(config.moveableOptions, true),
125
125
  dragResizeHelper: createDrHelper(),
126
126
  getRootContainer: config.getRootContainer,
127
127
  getRenderDocument: config.getRenderDocument,
@@ -353,14 +353,18 @@ export default class ActionManager extends EventEmitter {
353
353
  this.highlightLayer.destroy();
354
354
  }
355
355
 
356
- private changeCallback(options: CustomizeMoveableOptions): CustomizeMoveableOptions {
356
+ private changeCallback(options: CustomizeMoveableOptions, isMulti: boolean): CustomizeMoveableOptions {
357
357
  // 在actionManager才能获取到各种参数,在这里传好参数有比较好的扩展性
358
358
  if (typeof options === 'function') {
359
359
  return () => {
360
360
  // 要再判断一次,不然过不了ts检查
361
361
  if (typeof options === 'function') {
362
362
  const cfg: CustomizeMoveableOptionsCallbackConfig = {
363
+ targetEl: this.selectedEl,
363
364
  targetElId: this.selectedEl?.id,
365
+ targetEls: this.selectedElList,
366
+ targetElIds: this.selectedElList?.map((item) => item.id),
367
+ isMulti,
364
368
  };
365
369
  return options(cfg);
366
370
  }
package/src/StageCore.ts CHANGED
@@ -253,7 +253,6 @@ export default class StageCore extends EventEmitter {
253
253
  containerHighlightDuration: config.containerHighlightDuration,
254
254
  containerHighlightType: config.containerHighlightType,
255
255
  moveableOptions: config.moveableOptions,
256
- multiMoveableOptions: config.multiMoveableOptions,
257
256
  container: this.mask.content,
258
257
  disabledDragStart: config.disabledDragStart,
259
258
  canSelect: config.canSelect,
@@ -47,7 +47,7 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
47
47
  constructor(config: StageMultiDragResizeConfig) {
48
48
  const moveableOptionsManagerConfig: MoveableOptionsManagerConfig = {
49
49
  container: config.container,
50
- moveableOptions: config.multiMoveableOptions,
50
+ moveableOptions: config.moveableOptions,
51
51
  getRootContainer: config.getRootContainer,
52
52
  };
53
53
  super(moveableOptionsManagerConfig);
@@ -170,10 +170,12 @@ export default class StageMultiDragResize extends MoveableOptionsManager {
170
170
  target: this.dragResizeHelper.getShadowEls(),
171
171
  });
172
172
 
173
+ console.log(options);
174
+
173
175
  Object.entries(options).forEach(([key, value]) => {
174
176
  (this.moveableForMulti as any)[key] = value;
175
177
  });
176
- this.moveableForMulti.updateTarget();
178
+ this.moveableForMulti.updateRect();
177
179
  }
178
180
 
179
181
  /**
package/src/types.ts CHANGED
@@ -65,7 +65,6 @@ export interface StageCoreConfig {
65
65
  containerHighlightDuration?: number;
66
66
  containerHighlightType?: ContainerHighlightType;
67
67
  moveableOptions?: CustomizeMoveableOptions;
68
- multiMoveableOptions?: CustomizeMoveableOptions;
69
68
  /** runtime 的HTML地址,可以是一个HTTP地址,如果和编辑器不同域,需要设置跨域,也可以是一个相对或绝对路径 */
70
69
  runtimeUrl?: string;
71
70
  render?: (renderer: StageCore) => Promise<HTMLElement> | HTMLElement;
@@ -80,7 +79,6 @@ export interface ActionManagerConfig {
80
79
  containerHighlightDuration?: number;
81
80
  containerHighlightType?: ContainerHighlightType;
82
81
  moveableOptions?: CustomizeMoveableOptions;
83
- multiMoveableOptions?: CustomizeMoveableOptions;
84
82
  disabledDragStart?: boolean;
85
83
  canSelect?: CanSelect;
86
84
  isContainer: IsContainer;
@@ -98,7 +96,11 @@ export interface MoveableOptionsManagerConfig {
98
96
  }
99
97
 
100
98
  export interface CustomizeMoveableOptionsCallbackConfig {
99
+ targetEl?: HTMLElement;
101
100
  targetElId?: string;
101
+ targetEls?: HTMLElement[];
102
+ targetElIds?: string[];
103
+ isMulti: boolean;
102
104
  }
103
105
 
104
106
  export interface StageRenderConfig {
@@ -125,7 +127,7 @@ export interface StageDragResizeConfig {
125
127
  export interface StageMultiDragResizeConfig {
126
128
  container: HTMLElement;
127
129
  dragResizeHelper: DragResizeHelper;
128
- multiMoveableOptions?: CustomizeMoveableOptions;
130
+ moveableOptions?: CustomizeMoveableOptions;
129
131
  getRootContainer: GetRootContainer;
130
132
  getRenderDocument: GetRenderDocument;
131
133
  markContainerEnd: MarkContainerEnd;
package/types/types.d.ts CHANGED
@@ -38,7 +38,6 @@ export interface StageCoreConfig {
38
38
  containerHighlightDuration?: number;
39
39
  containerHighlightType?: ContainerHighlightType;
40
40
  moveableOptions?: CustomizeMoveableOptions;
41
- multiMoveableOptions?: CustomizeMoveableOptions;
42
41
  /** runtime 的HTML地址,可以是一个HTTP地址,如果和编辑器不同域,需要设置跨域,也可以是一个相对或绝对路径 */
43
42
  runtimeUrl?: string;
44
43
  render?: (renderer: StageCore) => Promise<HTMLElement> | HTMLElement;
@@ -52,7 +51,6 @@ export interface ActionManagerConfig {
52
51
  containerHighlightDuration?: number;
53
52
  containerHighlightType?: ContainerHighlightType;
54
53
  moveableOptions?: CustomizeMoveableOptions;
55
- multiMoveableOptions?: CustomizeMoveableOptions;
56
54
  disabledDragStart?: boolean;
57
55
  canSelect?: CanSelect;
58
56
  isContainer: IsContainer;
@@ -68,7 +66,11 @@ export interface MoveableOptionsManagerConfig {
68
66
  getRootContainer: GetRootContainer;
69
67
  }
70
68
  export interface CustomizeMoveableOptionsCallbackConfig {
69
+ targetEl?: HTMLElement;
71
70
  targetElId?: string;
71
+ targetEls?: HTMLElement[];
72
+ targetElIds?: string[];
73
+ isMulti: boolean;
72
74
  }
73
75
  export interface StageRenderConfig {
74
76
  runtimeUrl?: string;
@@ -91,7 +93,7 @@ export interface StageDragResizeConfig {
91
93
  export interface StageMultiDragResizeConfig {
92
94
  container: HTMLElement;
93
95
  dragResizeHelper: DragResizeHelper;
94
- multiMoveableOptions?: CustomizeMoveableOptions;
96
+ moveableOptions?: CustomizeMoveableOptions;
95
97
  getRootContainer: GetRootContainer;
96
98
  getRenderDocument: GetRenderDocument;
97
99
  markContainerEnd: MarkContainerEnd;