@tmagic/stage 1.5.24 → 1.6.0-beta.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Tencent is pleased to support the open source community by making TMagicEditor available.
2
2
 
3
- Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
3
+ Copyright (C) 2025 Tencent. All rights reserved.
4
4
 
5
5
  TMagicEditor is licensed under the Apache License Version 2.0 except for the third-party components listed below.
6
6
 
@@ -1692,7 +1692,7 @@ class ActionManager extends EventEmitter {
1692
1692
  const dr = new StageDragResize({
1693
1693
  container: config.container,
1694
1694
  disabledDragStart: config.disabledDragStart,
1695
- moveableOptions: this.changeCallback(config.moveableOptions, false),
1695
+ moveableOptions: config.moveableOptions && this.changeCallback(config.moveableOptions, false),
1696
1696
  dragResizeHelper: createDrHelper(),
1697
1697
  getRootContainer: config.getRootContainer,
1698
1698
  getRenderDocument: config.getRenderDocument,
@@ -1726,7 +1726,7 @@ class ActionManager extends EventEmitter {
1726
1726
  });
1727
1727
  const multiDr = new StageMultiDragResize({
1728
1728
  container: config.container,
1729
- moveableOptions: this.changeCallback(config.moveableOptions, true),
1729
+ moveableOptions: config.moveableOptions && this.changeCallback(config.moveableOptions, true),
1730
1730
  dragResizeHelper: createDrHelper(),
1731
1731
  getRootContainer: config.getRootContainer,
1732
1732
  getRenderDocument: config.getRenderDocument,
@@ -4165,7 +4165,7 @@
4165
4165
  const dr = new StageDragResize({
4166
4166
  container: config.container,
4167
4167
  disabledDragStart: config.disabledDragStart,
4168
- moveableOptions: this.changeCallback(config.moveableOptions, false),
4168
+ moveableOptions: config.moveableOptions && this.changeCallback(config.moveableOptions, false),
4169
4169
  dragResizeHelper: createDrHelper(),
4170
4170
  getRootContainer: config.getRootContainer,
4171
4171
  getRenderDocument: config.getRenderDocument,
@@ -4199,7 +4199,7 @@
4199
4199
  });
4200
4200
  const multiDr = new StageMultiDragResize({
4201
4201
  container: config.container,
4202
- moveableOptions: this.changeCallback(config.moveableOptions, true),
4202
+ moveableOptions: config.moveableOptions && this.changeCallback(config.moveableOptions, true),
4203
4203
  dragResizeHelper: createDrHelper(),
4204
4204
  getRootContainer: config.getRootContainer,
4205
4205
  getRenderDocument: config.getRenderDocument,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.24",
2
+ "version": "1.6.0-beta.1",
3
3
  "name": "@tmagic/stage",
4
4
  "type": "module",
5
5
  "main": "dist/tmagic-stage.umd.cjs",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "peerDependencies": {
44
44
  "typescript": "^5.8.3",
45
- "@tmagic/core": "1.5.24"
45
+ "@tmagic/core": "1.6.0-beta.1"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "typescript": {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -427,7 +427,7 @@ export default class ActionManager extends EventEmitter {
427
427
  const dr = new StageDragResize({
428
428
  container: config.container,
429
429
  disabledDragStart: config.disabledDragStart,
430
- moveableOptions: this.changeCallback(config.moveableOptions, false),
430
+ moveableOptions: config.moveableOptions && this.changeCallback(config.moveableOptions, false),
431
431
  dragResizeHelper: createDrHelper(),
432
432
  getRootContainer: config.getRootContainer,
433
433
  getRenderDocument: config.getRenderDocument,
@@ -472,7 +472,7 @@ export default class ActionManager extends EventEmitter {
472
472
  });
473
473
  const multiDr = new StageMultiDragResize({
474
474
  container: config.container,
475
- moveableOptions: this.changeCallback(config.moveableOptions, true),
475
+ moveableOptions: config.moveableOptions && this.changeCallback(config.moveableOptions, true),
476
476
  dragResizeHelper: createDrHelper(),
477
477
  getRootContainer: config.getRootContainer,
478
478
  getRenderDocument: config.getRenderDocument,
@@ -493,7 +493,10 @@ export default class ActionManager extends EventEmitter {
493
493
  return multiDr;
494
494
  }
495
495
 
496
- private changeCallback(options: CustomizeMoveableOptions, isMulti: boolean): CustomizeMoveableOptions {
496
+ private changeCallback(
497
+ options: CustomizeMoveableOptions,
498
+ isMulti: boolean,
499
+ ): MoveableOptions | (() => MoveableOptions) {
497
500
  // 在actionManager才能获取到各种参数,在这里传好参数有比较好的扩展性
498
501
  if (typeof options === 'function') {
499
502
  return () => {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
package/src/StageCore.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
package/src/StageMask.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
package/src/const.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
package/src/logger.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -31,11 +31,11 @@ export type TargetElement = HTMLElement | SVGElement;
31
31
  export type CanSelect = (el: HTMLElement, event: MouseEvent, stop: () => boolean) => boolean | Promise<boolean>;
32
32
  export type IsContainer = (el: HTMLElement) => boolean | Promise<boolean>;
33
33
  export type CustomizeRender = (renderer: StageCore) => Promise<HTMLElement | void> | HTMLElement | void;
34
+
35
+ export type CustomizeMoveableOptionsFunction = (config: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions;
36
+
34
37
  /** 业务方自定义的moveableOptions,可以是配置,也可以是回调函数 */
35
- export type CustomizeMoveableOptions =
36
- | ((config?: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions)
37
- | MoveableOptions
38
- | undefined;
38
+ export type CustomizeMoveableOptions = CustomizeMoveableOptionsFunction | MoveableOptions;
39
39
  /** render提供给的接口,id转成el */
40
40
  export type GetTargetElement = (id: Id) => HTMLElement | null;
41
41
  /** render提供的接口,通过坐标获得坐标下所有HTML元素数组 */
@@ -89,7 +89,7 @@ export interface ActionManagerConfig {
89
89
 
90
90
  export interface MoveableOptionsManagerConfig {
91
91
  container: HTMLElement;
92
- moveableOptions?: CustomizeMoveableOptions;
92
+ moveableOptions?: MoveableOptions | (() => MoveableOptions);
93
93
  getRootContainer: GetRootContainer;
94
94
  }
95
95
 
@@ -113,22 +113,16 @@ export interface StageMaskConfig {
113
113
  core: StageCore;
114
114
  }
115
115
 
116
- export interface StageDragResizeConfig {
117
- container: HTMLElement;
116
+ export interface StageDragResizeConfig extends MoveableOptionsManagerConfig {
118
117
  dragResizeHelper: DragResizeHelper;
119
- moveableOptions?: CustomizeMoveableOptions;
120
118
  disabledDragStart?: boolean;
121
- getRootContainer: GetRootContainer;
122
119
  getRenderDocument: GetRenderDocument;
123
120
  markContainerEnd: MarkContainerEnd;
124
121
  delayedMarkContainer: DelayedMarkContainer;
125
122
  }
126
123
 
127
- export interface StageMultiDragResizeConfig {
128
- container: HTMLElement;
124
+ export interface StageMultiDragResizeConfig extends MoveableOptionsManagerConfig {
129
125
  dragResizeHelper: DragResizeHelper;
130
- moveableOptions?: CustomizeMoveableOptions;
131
- getRootContainer: GetRootContainer;
132
126
  getRenderDocument: GetRenderDocument;
133
127
  markContainerEnd: MarkContainerEnd;
134
128
  delayedMarkContainer: DelayedMarkContainer;
package/src/util.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Tencent is pleased to support the open source community by making TMagicEditor available.
3
3
  *
4
- * Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
package/types/index.d.ts CHANGED
@@ -158,8 +158,9 @@ type TargetElement = HTMLElement | SVGElement;
158
158
  type CanSelect = (el: HTMLElement, event: MouseEvent, stop: () => boolean) => boolean | Promise<boolean>;
159
159
  type IsContainer = (el: HTMLElement) => boolean | Promise<boolean>;
160
160
  type CustomizeRender = (renderer: StageCore) => Promise<HTMLElement | void> | HTMLElement | void;
161
+ type CustomizeMoveableOptionsFunction = (config: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions;
161
162
  /** 业务方自定义的moveableOptions,可以是配置,也可以是回调函数 */
162
- type CustomizeMoveableOptions = ((config?: CustomizeMoveableOptionsCallbackConfig) => MoveableOptions) | MoveableOptions | undefined;
163
+ type CustomizeMoveableOptions = CustomizeMoveableOptionsFunction | MoveableOptions;
163
164
  /** render提供给的接口,id转成el */
164
165
  type GetTargetElement = (id: Id) => HTMLElement | null;
165
166
  /** render提供的接口,通过坐标获得坐标下所有HTML元素数组 */
@@ -209,7 +210,7 @@ interface ActionManagerConfig {
209
210
  }
210
211
  interface MoveableOptionsManagerConfig {
211
212
  container: HTMLElement;
212
- moveableOptions?: CustomizeMoveableOptions;
213
+ moveableOptions?: MoveableOptions | (() => MoveableOptions);
213
214
  getRootContainer: GetRootContainer;
214
215
  }
215
216
  interface CustomizeMoveableOptionsCallbackConfig {
@@ -229,21 +230,15 @@ interface StageRenderConfig {
229
230
  interface StageMaskConfig {
230
231
  core: StageCore;
231
232
  }
232
- interface StageDragResizeConfig {
233
- container: HTMLElement;
233
+ interface StageDragResizeConfig extends MoveableOptionsManagerConfig {
234
234
  dragResizeHelper: DragResizeHelper;
235
- moveableOptions?: CustomizeMoveableOptions;
236
235
  disabledDragStart?: boolean;
237
- getRootContainer: GetRootContainer;
238
236
  getRenderDocument: GetRenderDocument;
239
237
  markContainerEnd: MarkContainerEnd;
240
238
  delayedMarkContainer: DelayedMarkContainer;
241
239
  }
242
- interface StageMultiDragResizeConfig {
243
- container: HTMLElement;
240
+ interface StageMultiDragResizeConfig extends MoveableOptionsManagerConfig {
244
241
  dragResizeHelper: DragResizeHelper;
245
- moveableOptions?: CustomizeMoveableOptions;
246
- getRootContainer: GetRootContainer;
247
242
  getRenderDocument: GetRenderDocument;
248
243
  markContainerEnd: MarkContainerEnd;
249
244
  delayedMarkContainer: DelayedMarkContainer;
@@ -1031,4 +1026,4 @@ declare const _default: (handler: (type: AbleActionEventType) => void, customize
1031
1026
  };
1032
1027
 
1033
1028
  export { AbleActionEventType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GuidesType, HIGHLIGHT_EL_ID_PREFIX, Mode, MouseButton, _default as MoveableActionsAble, PAGE_CLASS, RenderType, SELECTED_CLASS, SelectStatus, StageDragResize, StageDragStatus, StageMask, StageRender, ZIndex, addSelectedClassName, StageCore as default, down, getAbsolutePosition, getBorderWidth, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
1034
- export type { AbleCustomizedButton, ActionManagerConfig, ActionManagerEvents, CanSelect, CoreEvents, CustomizeMoveableOptions, CustomizeMoveableOptionsCallbackConfig, CustomizeRender, DelayedMarkContainer, DrEvents, DragResizeHelperConfig, GetElementsFromPoint, GetRenderDocument, GetRootContainer, GetTargetElement, GuidesEventData, IsContainer, Magic, MarkContainerEnd, MaskEvents, MoveableOptionsManagerConfig, MultiDrEvents, Offset, Point, Rect, RemoveData, RemoveEventData, RenderEvents, RuleOptions, Runtime, RuntimeWindow, SortEventData, StageCoreConfig, StageDragResizeConfig, StageHighlightConfig, StageMaskConfig, StageMultiDragResizeConfig, StageRenderConfig, TargetElement, TargetShadowConfig, UpdateData, UpdateDragEl, UpdateEventData };
1029
+ export type { AbleCustomizedButton, ActionManagerConfig, ActionManagerEvents, CanSelect, CoreEvents, CustomizeMoveableOptions, CustomizeMoveableOptionsCallbackConfig, CustomizeMoveableOptionsFunction, CustomizeRender, DelayedMarkContainer, DrEvents, DragResizeHelperConfig, GetElementsFromPoint, GetRenderDocument, GetRootContainer, GetTargetElement, GuidesEventData, IsContainer, Magic, MarkContainerEnd, MaskEvents, MoveableOptionsManagerConfig, MultiDrEvents, Offset, Point, Rect, RemoveData, RemoveEventData, RenderEvents, RuleOptions, Runtime, RuntimeWindow, SortEventData, StageCoreConfig, StageDragResizeConfig, StageHighlightConfig, StageMaskConfig, StageMultiDragResizeConfig, StageRenderConfig, TargetElement, TargetShadowConfig, UpdateData, UpdateDragEl, UpdateEventData };