@tmagic/stage 1.8.0-beta.2 → 1.8.0-beta.21
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/es/ActionManager.js +14 -6
- package/dist/es/StageCore.js +19 -4
- package/dist/es/StageFlashHighlight.js +102 -0
- package/dist/es/StageMask.js +2 -2
- package/dist/es/const.js +3 -1
- package/dist/es/index.js +3 -3
- package/dist/es/moveable-able.js +1 -1
- package/dist/es/util.js +28 -1
- package/dist/tmagic-stage.umd.cjs +203 -21
- package/package.json +2 -2
- package/src/ActionManager.ts +20 -8
- package/src/StageCore.ts +29 -5
- package/src/StageFlashHighlight.ts +135 -0
- package/src/StageMask.ts +5 -3
- package/src/const.ts +3 -0
- package/src/moveable-able.css +1 -1
- package/src/types.ts +22 -1
- package/src/util.ts +43 -1
- package/types/index.d.ts +74 -6
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { getDocument, injectStyle } from '@tmagic/core';
|
|
20
|
+
|
|
21
|
+
import { FLASH_EL_ID_PREFIX, ZIndex } from './const';
|
|
22
|
+
import TargetShadow from './TargetShadow';
|
|
23
|
+
import type { StageFlashHighlightConfig } from './types';
|
|
24
|
+
|
|
25
|
+
/** 闪烁提示节点的 class name */
|
|
26
|
+
export const FLASH_TIP_CLASS_NAME = 'tmagic-stage-flash-tip';
|
|
27
|
+
/** 闪烁动画名称 */
|
|
28
|
+
const FLASH_ANIMATION_NAME = 'tmagic-stage-flash';
|
|
29
|
+
/** 闪烁动画时长(ms) */
|
|
30
|
+
const FLASH_DURATION = 1500;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 选中区域闪烁提示
|
|
34
|
+
* @description 当组件不是通过点击画布选中(如从图层树、面包屑等外部选中)时,在画布上对选中区域做一次高亮闪烁,
|
|
35
|
+
* 帮助用户快速定位组件在画布中的位置。
|
|
36
|
+
*/
|
|
37
|
+
export default class StageFlashHighlight {
|
|
38
|
+
/** 复用 TargetShadow 负责节点的定位校准(updateDragEl、fixed、滚动偏移等) */
|
|
39
|
+
private targetShadow: TargetShadow;
|
|
40
|
+
private timer?: NodeJS.Timeout;
|
|
41
|
+
private styleEl?: HTMLStyleElement;
|
|
42
|
+
|
|
43
|
+
constructor(config: StageFlashHighlightConfig) {
|
|
44
|
+
this.targetShadow = new TargetShadow({
|
|
45
|
+
container: config.container,
|
|
46
|
+
updateDragEl: config.updateDragEl,
|
|
47
|
+
zIndex: ZIndex.SELECTED_EL,
|
|
48
|
+
idPrefix: FLASH_EL_ID_PREFIX,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 在目标元素所在区域做一次高亮闪烁
|
|
54
|
+
* @param el 选中组件的Dom节点元素
|
|
55
|
+
*/
|
|
56
|
+
public flash(el: HTMLElement): void {
|
|
57
|
+
if (!el) return;
|
|
58
|
+
|
|
59
|
+
this.injectStyle();
|
|
60
|
+
// 先销毁旧节点再 update,确保每次都拿到全新节点,让闪烁动画重新播放
|
|
61
|
+
this.clear();
|
|
62
|
+
|
|
63
|
+
const flashEl = this.targetShadow.update(el);
|
|
64
|
+
flashEl.classList.add(FLASH_TIP_CLASS_NAME);
|
|
65
|
+
flashEl.style.boxSizing = 'border-box';
|
|
66
|
+
flashEl.style.pointerEvents = 'none';
|
|
67
|
+
// getTargetElStyle 会写入 target 的内联 border,需清掉以让动画 class 的边框生效
|
|
68
|
+
flashEl.style.border = '';
|
|
69
|
+
|
|
70
|
+
this.timer = globalThis.setTimeout(() => {
|
|
71
|
+
this.clear();
|
|
72
|
+
}, FLASH_DURATION);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 清除闪烁节点
|
|
77
|
+
*/
|
|
78
|
+
public clear(): void {
|
|
79
|
+
if (this.timer) {
|
|
80
|
+
globalThis.clearTimeout(this.timer);
|
|
81
|
+
this.timer = undefined;
|
|
82
|
+
}
|
|
83
|
+
this.targetShadow.destroyEl();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 销毁实例
|
|
88
|
+
*/
|
|
89
|
+
public destroy(): void {
|
|
90
|
+
this.clear();
|
|
91
|
+
this.targetShadow.destroy();
|
|
92
|
+
this.styleEl?.remove();
|
|
93
|
+
this.styleEl = undefined;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 注入闪烁动画样式(仅注入一次)
|
|
98
|
+
*/
|
|
99
|
+
private injectStyle(): void {
|
|
100
|
+
if (this.styleEl) return;
|
|
101
|
+
|
|
102
|
+
this.styleEl = injectStyle(
|
|
103
|
+
getDocument(),
|
|
104
|
+
`
|
|
105
|
+
@keyframes ${FLASH_ANIMATION_NAME} {
|
|
106
|
+
0% {
|
|
107
|
+
opacity: 0;
|
|
108
|
+
background-color: rgba(146, 84, 222, 0);
|
|
109
|
+
}
|
|
110
|
+
20% {
|
|
111
|
+
opacity: 1;
|
|
112
|
+
background-color: rgba(146, 84, 222, 0.7);
|
|
113
|
+
}
|
|
114
|
+
45% {
|
|
115
|
+
opacity: 0.6;
|
|
116
|
+
background-color: rgba(146, 84, 222, 0.4);
|
|
117
|
+
}
|
|
118
|
+
70% {
|
|
119
|
+
opacity: 1;
|
|
120
|
+
background-color: rgba(146, 84, 222, 0.7);
|
|
121
|
+
}
|
|
122
|
+
100% {
|
|
123
|
+
opacity: 0;
|
|
124
|
+
background-color: rgba(146, 84, 222, 0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
.${FLASH_TIP_CLASS_NAME} {
|
|
128
|
+
border: 2px solid #9254de;
|
|
129
|
+
border-radius: 2px;
|
|
130
|
+
animation: ${FLASH_ANIMATION_NAME} ${FLASH_DURATION}ms cubic-bezier(0.4, 0, 0.2, 1) both;
|
|
131
|
+
}
|
|
132
|
+
`,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
package/src/StageMask.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { createDiv, getDocument, injectStyle } from '@tmagic/core';
|
|
|
21
21
|
import { Mode, ZIndex } from './const';
|
|
22
22
|
import Rule from './Rule';
|
|
23
23
|
import type { MaskEvents, RuleOptions } from './types';
|
|
24
|
-
import { getScrollParent, isFixedParent } from './util';
|
|
24
|
+
import { getScrollParent, isFixedParent, scrollElementIntoView } from './util';
|
|
25
25
|
|
|
26
26
|
const wrapperClassName = 'editor-mask-wrapper';
|
|
27
27
|
|
|
@@ -165,10 +165,12 @@ export default class StageMask extends Rule {
|
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
el.scrollIntoView();
|
|
169
|
-
|
|
170
168
|
if (!this.pageScrollParent) return;
|
|
171
169
|
|
|
170
|
+
// 不使用原生 scrollIntoView,避免编辑器画布外层滚动容器被浏览器连带滚动导致整个 stage 位移,
|
|
171
|
+
// 只滚动页面所在的滚动容器
|
|
172
|
+
scrollElementIntoView(el, this.pageScrollParent);
|
|
173
|
+
|
|
172
174
|
this.scrollLeft = this.pageScrollParent.scrollLeft;
|
|
173
175
|
this.scrollTop = this.pageScrollParent.scrollTop;
|
|
174
176
|
|
package/src/const.ts
CHANGED
|
@@ -25,6 +25,9 @@ export const DRAG_EL_ID_PREFIX = 'drag_el_';
|
|
|
25
25
|
/** 高亮时需要在蒙层中创建一个占位节点,该节点的id前缀 */
|
|
26
26
|
export const HIGHLIGHT_EL_ID_PREFIX = 'highlight_el_';
|
|
27
27
|
|
|
28
|
+
/** 闪烁提示时需要在蒙层中创建一个占位节点,该节点的id前缀 */
|
|
29
|
+
export const FLASH_EL_ID_PREFIX = 'flash_el_';
|
|
30
|
+
|
|
28
31
|
export const CONTAINER_HIGHLIGHT_CLASS_NAME = 'tmagic-stage-container-highlight';
|
|
29
32
|
|
|
30
33
|
export const PAGE_CLASS = 'magic-ui-page';
|
package/src/moveable-able.css
CHANGED
package/src/types.ts
CHANGED
|
@@ -53,7 +53,11 @@ export type GetTargetElement = (id: Id) => HTMLElement | null;
|
|
|
53
53
|
/** render提供的接口,通过坐标获得坐标下所有HTML元素数组 */
|
|
54
54
|
export type GetElementsFromPoint = (point: Point) => HTMLElement[];
|
|
55
55
|
export type GetRenderDocument = () => Document | undefined;
|
|
56
|
-
export type DelayedMarkContainer = (
|
|
56
|
+
export type DelayedMarkContainer = (
|
|
57
|
+
event: MouseEvent,
|
|
58
|
+
exclude?: Element[],
|
|
59
|
+
isAdd?: boolean,
|
|
60
|
+
) => NodeJS.Timeout | undefined;
|
|
57
61
|
export type MarkContainerEnd = () => HTMLElement | null;
|
|
58
62
|
export type GetRootContainer = () => HTMLDivElement | undefined;
|
|
59
63
|
|
|
@@ -74,6 +78,11 @@ export interface StageCoreConfig {
|
|
|
74
78
|
containerHighlightClassName?: string;
|
|
75
79
|
containerHighlightDuration?: number;
|
|
76
80
|
containerHighlightType?: ContainerHighlightType;
|
|
81
|
+
/**
|
|
82
|
+
* 是否仅在新增组件(从组件列表拖入新组件)时才启用将组件拖入容器,
|
|
83
|
+
* 开启后在画布中拖动已有组件不会识别容器,默认 false
|
|
84
|
+
*/
|
|
85
|
+
containerHighlightAddOnly?: boolean;
|
|
77
86
|
moveableOptions?: CustomizeMoveableOptions;
|
|
78
87
|
/** runtime 的HTML地址,可以是一个HTTP地址,如果和编辑器不同域,需要设置跨域,也可以是一个相对或绝对路径 */
|
|
79
88
|
runtimeUrl?: string;
|
|
@@ -90,6 +99,11 @@ export interface StageCoreConfig {
|
|
|
90
99
|
*/
|
|
91
100
|
alwaysMultiSelect?: boolean;
|
|
92
101
|
disabledRule?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* 是否禁用「非点击画布选中组件时,对选中区域做高亮闪烁提示」,默认 false(即默认开启闪烁提示)。
|
|
104
|
+
* 用于从图层树、面包屑等外部选中组件时,帮助用户快速定位组件在画布中的位置。
|
|
105
|
+
*/
|
|
106
|
+
disabledFlashTip?: boolean;
|
|
93
107
|
}
|
|
94
108
|
|
|
95
109
|
export interface ActionManagerConfig {
|
|
@@ -97,6 +111,8 @@ export interface ActionManagerConfig {
|
|
|
97
111
|
containerHighlightClassName?: string;
|
|
98
112
|
containerHighlightDuration?: number;
|
|
99
113
|
containerHighlightType?: ContainerHighlightType;
|
|
114
|
+
/** 见 StageCoreConfig.containerHighlightAddOnly */
|
|
115
|
+
containerHighlightAddOnly?: boolean;
|
|
100
116
|
moveableOptions?: CustomizeMoveableOptions;
|
|
101
117
|
disabledDragStart?: boolean;
|
|
102
118
|
disabledMultiSelect?: boolean;
|
|
@@ -264,6 +280,11 @@ export interface TargetShadowConfig {
|
|
|
264
280
|
idPrefix?: string;
|
|
265
281
|
}
|
|
266
282
|
|
|
283
|
+
export interface StageFlashHighlightConfig {
|
|
284
|
+
container: HTMLElement;
|
|
285
|
+
updateDragEl?: UpdateDragEl;
|
|
286
|
+
}
|
|
287
|
+
|
|
267
288
|
export interface RuleOptions {
|
|
268
289
|
guidesOptions?: Partial<GuidesOptions>;
|
|
269
290
|
disabledRule?: boolean;
|
package/src/util.ts
CHANGED
|
@@ -126,7 +126,7 @@ export const getScrollParent = (element: HTMLElement, includeHidden = false): HT
|
|
|
126
126
|
|
|
127
127
|
if (isFixed(style)) return null;
|
|
128
128
|
|
|
129
|
-
for (let parent = element; parent.parentElement;
|
|
129
|
+
for (let parent = element; parent.parentElement;) {
|
|
130
130
|
parent = parent.parentElement;
|
|
131
131
|
|
|
132
132
|
if (parent.tagName === 'HTML') return parent;
|
|
@@ -141,6 +141,48 @@ export const getScrollParent = (element: HTMLElement, includeHidden = false): HT
|
|
|
141
141
|
return null;
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* 将元素滚动到指定滚动容器的可视区域内(仅垂直方向,滚动最小距离)
|
|
146
|
+
* @description 与原生 scrollIntoView 不同,只滚动指定的容器自身,不会连带滚动外层祖先滚动容器,
|
|
147
|
+
* 避免编辑器画布外层容器(如 stage 外层使用 transform 模拟滚动的容器)被浏览器自动滚动导致整个画布位移
|
|
148
|
+
* @param el 目标元素
|
|
149
|
+
* @param container 滚动容器
|
|
150
|
+
*/
|
|
151
|
+
export const scrollElementIntoView = (el: Element, container: HTMLElement): void => {
|
|
152
|
+
const { ownerDocument } = container;
|
|
153
|
+
const win = ownerDocument?.defaultView;
|
|
154
|
+
if (!ownerDocument || !win) return;
|
|
155
|
+
|
|
156
|
+
const elRect = el.getBoundingClientRect();
|
|
157
|
+
|
|
158
|
+
let viewTop = 0;
|
|
159
|
+
let viewHeight = 0;
|
|
160
|
+
|
|
161
|
+
if (container === ownerDocument.documentElement || container === ownerDocument.body) {
|
|
162
|
+
// 文档滚动元素的可视区域为窗口视口
|
|
163
|
+
viewTop = 0;
|
|
164
|
+
viewHeight = win.innerHeight;
|
|
165
|
+
} else {
|
|
166
|
+
const containerRect = container.getBoundingClientRect();
|
|
167
|
+
viewTop = containerRect.top + container.clientTop;
|
|
168
|
+
viewHeight = container.clientHeight;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const viewBottom = viewTop + viewHeight;
|
|
172
|
+
|
|
173
|
+
let delta = 0;
|
|
174
|
+
if (elRect.top < viewTop) {
|
|
175
|
+
delta = elRect.top - viewTop;
|
|
176
|
+
} else if (elRect.bottom > viewBottom) {
|
|
177
|
+
// 元素高度超过可视区域高度时,优先保证元素顶部可见
|
|
178
|
+
delta = Math.min(elRect.bottom - viewBottom, elRect.top - viewTop);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (delta !== 0) {
|
|
182
|
+
container.scrollTop += delta;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
144
186
|
export const removeSelectedClassName = (doc: Document) => {
|
|
145
187
|
const oldEl = doc.querySelector(`.${SELECTED_CLASS}`);
|
|
146
188
|
|
package/types/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ declare const GHOST_EL_ID_PREFIX = "ghost_el_";
|
|
|
13
13
|
declare const DRAG_EL_ID_PREFIX = "drag_el_";
|
|
14
14
|
/** 高亮时需要在蒙层中创建一个占位节点,该节点的id前缀 */
|
|
15
15
|
declare const HIGHLIGHT_EL_ID_PREFIX = "highlight_el_";
|
|
16
|
+
/** 闪烁提示时需要在蒙层中创建一个占位节点,该节点的id前缀 */
|
|
17
|
+
declare const FLASH_EL_ID_PREFIX = "flash_el_";
|
|
16
18
|
declare const CONTAINER_HIGHLIGHT_CLASS_NAME = "tmagic-stage-container-highlight";
|
|
17
19
|
declare const PAGE_CLASS = "magic-ui-page";
|
|
18
20
|
/** 默认放到缩小倍数 */
|
|
@@ -180,7 +182,7 @@ type GetTargetElement = (id: Id) => HTMLElement | null;
|
|
|
180
182
|
/** render提供的接口,通过坐标获得坐标下所有HTML元素数组 */
|
|
181
183
|
type GetElementsFromPoint = (point: Point) => HTMLElement[];
|
|
182
184
|
type GetRenderDocument = () => Document | undefined;
|
|
183
|
-
type DelayedMarkContainer = (event: MouseEvent, exclude
|
|
185
|
+
type DelayedMarkContainer = (event: MouseEvent, exclude?: Element[], isAdd?: boolean) => NodeJS.Timeout | undefined;
|
|
184
186
|
type MarkContainerEnd = () => HTMLElement | null;
|
|
185
187
|
type GetRootContainer = () => HTMLDivElement | undefined;
|
|
186
188
|
type UpdateDragEl = (el: TargetElement, target: TargetElement, container: HTMLElement) => void;
|
|
@@ -199,6 +201,11 @@ interface StageCoreConfig {
|
|
|
199
201
|
containerHighlightClassName?: string;
|
|
200
202
|
containerHighlightDuration?: number;
|
|
201
203
|
containerHighlightType?: ContainerHighlightType;
|
|
204
|
+
/**
|
|
205
|
+
* 是否仅在新增组件(从组件列表拖入新组件)时才启用将组件拖入容器,
|
|
206
|
+
* 开启后在画布中拖动已有组件不会识别容器,默认 false
|
|
207
|
+
*/
|
|
208
|
+
containerHighlightAddOnly?: boolean;
|
|
202
209
|
moveableOptions?: CustomizeMoveableOptions;
|
|
203
210
|
/** runtime 的HTML地址,可以是一个HTTP地址,如果和编辑器不同域,需要设置跨域,也可以是一个相对或绝对路径 */
|
|
204
211
|
runtimeUrl?: string;
|
|
@@ -215,12 +222,19 @@ interface StageCoreConfig {
|
|
|
215
222
|
*/
|
|
216
223
|
alwaysMultiSelect?: boolean;
|
|
217
224
|
disabledRule?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* 是否禁用「非点击画布选中组件时,对选中区域做高亮闪烁提示」,默认 false(即默认开启闪烁提示)。
|
|
227
|
+
* 用于从图层树、面包屑等外部选中组件时,帮助用户快速定位组件在画布中的位置。
|
|
228
|
+
*/
|
|
229
|
+
disabledFlashTip?: boolean;
|
|
218
230
|
}
|
|
219
231
|
interface ActionManagerConfig {
|
|
220
232
|
container: HTMLElement;
|
|
221
233
|
containerHighlightClassName?: string;
|
|
222
234
|
containerHighlightDuration?: number;
|
|
223
235
|
containerHighlightType?: ContainerHighlightType;
|
|
236
|
+
/** 见 StageCoreConfig.containerHighlightAddOnly */
|
|
237
|
+
containerHighlightAddOnly?: boolean;
|
|
224
238
|
moveableOptions?: CustomizeMoveableOptions;
|
|
225
239
|
disabledDragStart?: boolean;
|
|
226
240
|
disabledMultiSelect?: boolean;
|
|
@@ -363,6 +377,10 @@ interface TargetShadowConfig {
|
|
|
363
377
|
updateDragEl?: UpdateDragEl;
|
|
364
378
|
idPrefix?: string;
|
|
365
379
|
}
|
|
380
|
+
interface StageFlashHighlightConfig {
|
|
381
|
+
container: HTMLElement;
|
|
382
|
+
updateDragEl?: UpdateDragEl;
|
|
383
|
+
}
|
|
366
384
|
interface RuleOptions {
|
|
367
385
|
guidesOptions?: Partial<GuidesOptions$1>;
|
|
368
386
|
disabledRule?: boolean;
|
|
@@ -456,6 +474,8 @@ declare class ActionManager extends EventEmitter$1 {
|
|
|
456
474
|
private containerHighlightDuration;
|
|
457
475
|
/** 将组件加入容器的操作方式 */
|
|
458
476
|
private containerHighlightType?;
|
|
477
|
+
/** 是否仅在新增组件时才启用将组件加入容器 */
|
|
478
|
+
private containerHighlightAddOnly;
|
|
459
479
|
private isAltKeydown;
|
|
460
480
|
private getTargetElement;
|
|
461
481
|
private getElementsFromPoint;
|
|
@@ -546,9 +566,10 @@ declare class ActionManager extends EventEmitter$1 {
|
|
|
546
566
|
* 标记的作用:1、高亮容器,给用户一个加入容器的交互感知;2、释放鼠标后,通过标记的标志找到要加入的容器
|
|
547
567
|
* @param event 鼠标事件
|
|
548
568
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
|
569
|
+
* @param isAdd 当前操作是否为新增组件(从组件列表拖入),开启 containerHighlightAddOnly 时只有新增才会标记
|
|
549
570
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
550
571
|
*/
|
|
551
|
-
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
572
|
+
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[], isAdd?: boolean): NodeJS.Timeout | undefined;
|
|
552
573
|
getDragStatus(): StageDragStatus | undefined;
|
|
553
574
|
updateMoveableOptions(): void;
|
|
554
575
|
destroy(): void;
|
|
@@ -564,7 +585,9 @@ declare class ActionManager extends EventEmitter$1 {
|
|
|
564
585
|
*/
|
|
565
586
|
private beforeMultiSelect;
|
|
566
587
|
/**
|
|
567
|
-
* 当前状态下能否将组件加入容器,默认是鼠标悬停一段时间加入,alt模式则是按住alt
|
|
588
|
+
* 当前状态下能否将组件加入容器,默认是鼠标悬停一段时间加入,alt模式则是按住alt+鼠标悬停一段时间加入;
|
|
589
|
+
* 开启containerHighlightAddOnly时,画布中拖动已有组件不能加入容器
|
|
590
|
+
* @param isAdd 当前操作是否为新增组件
|
|
568
591
|
*/
|
|
569
592
|
private canAddToContainer;
|
|
570
593
|
/**
|
|
@@ -591,6 +614,37 @@ declare class ActionManager extends EventEmitter$1 {
|
|
|
591
614
|
private dblclickHandler;
|
|
592
615
|
}
|
|
593
616
|
//#endregion
|
|
617
|
+
//#region temp/packages/stage/src/StageFlashHighlight.d.ts
|
|
618
|
+
/**
|
|
619
|
+
* 选中区域闪烁提示
|
|
620
|
+
* @description 当组件不是通过点击画布选中(如从图层树、面包屑等外部选中)时,在画布上对选中区域做一次高亮闪烁,
|
|
621
|
+
* 帮助用户快速定位组件在画布中的位置。
|
|
622
|
+
*/
|
|
623
|
+
declare class StageFlashHighlight {
|
|
624
|
+
/** 复用 TargetShadow 负责节点的定位校准(updateDragEl、fixed、滚动偏移等) */
|
|
625
|
+
private targetShadow;
|
|
626
|
+
private timer?;
|
|
627
|
+
private styleEl?;
|
|
628
|
+
constructor(config: StageFlashHighlightConfig);
|
|
629
|
+
/**
|
|
630
|
+
* 在目标元素所在区域做一次高亮闪烁
|
|
631
|
+
* @param el 选中组件的Dom节点元素
|
|
632
|
+
*/
|
|
633
|
+
flash(el: HTMLElement): void;
|
|
634
|
+
/**
|
|
635
|
+
* 清除闪烁节点
|
|
636
|
+
*/
|
|
637
|
+
clear(): void;
|
|
638
|
+
/**
|
|
639
|
+
* 销毁实例
|
|
640
|
+
*/
|
|
641
|
+
destroy(): void;
|
|
642
|
+
/**
|
|
643
|
+
* 注入闪烁动画样式(仅注入一次)
|
|
644
|
+
*/
|
|
645
|
+
private injectStyle;
|
|
646
|
+
}
|
|
647
|
+
//#endregion
|
|
594
648
|
//#region temp/packages/stage/src/Rule.d.ts
|
|
595
649
|
declare class Rule extends EventEmitter$1 {
|
|
596
650
|
hGuides?: Guides;
|
|
@@ -790,15 +844,20 @@ declare class StageCore extends EventEmitter {
|
|
|
790
844
|
renderer: StageRender | null;
|
|
791
845
|
mask: StageMask | null;
|
|
792
846
|
actionManager: ActionManager | null;
|
|
847
|
+
flashHighlight: StageFlashHighlight | null;
|
|
793
848
|
private pageResizeObserver;
|
|
794
849
|
private autoScrollIntoView;
|
|
795
850
|
private customizedRender?;
|
|
851
|
+
/** 非点击画布选中组件时,是否对选中区域做高亮闪烁提示,默认开启 */
|
|
852
|
+
private disabledFlashTip;
|
|
796
853
|
constructor(config: StageCoreConfig);
|
|
797
854
|
/**
|
|
798
855
|
* 单选选中元素
|
|
799
856
|
* @param id 选中的id
|
|
800
857
|
*/
|
|
801
|
-
select(id: Id, event?: MouseEvent
|
|
858
|
+
select(id: Id, event?: MouseEvent, options?: {
|
|
859
|
+
flash?: boolean;
|
|
860
|
+
}): Promise<void>;
|
|
802
861
|
/**
|
|
803
862
|
* 多选选中多个元素
|
|
804
863
|
* @param ids 选中元素的id列表
|
|
@@ -844,9 +903,10 @@ declare class StageCore extends EventEmitter {
|
|
|
844
903
|
* 标记的作用:1、高亮容器,给用户一个加入容器的交互感知;2、释放鼠标后,通过标记的标志找到要加入的容器
|
|
845
904
|
* @param event 鼠标事件
|
|
846
905
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
|
906
|
+
* @param isAdd 当前操作是否为新增组件(从组件列表拖入),开启 containerHighlightAddOnly 时只有新增才会标记
|
|
847
907
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
|
848
908
|
*/
|
|
849
|
-
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
|
|
909
|
+
delayedMarkContainer(event: MouseEvent, excludeElList?: Element[], isAdd?: boolean): NodeJS.Timeout | undefined;
|
|
850
910
|
getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined;
|
|
851
911
|
getDragStatus(): import("@tmagic/editor").StageDragStatus | undefined;
|
|
852
912
|
disableMultiSelect(): void;
|
|
@@ -1057,6 +1117,14 @@ declare const isFixed: (style: {
|
|
|
1057
1117
|
declare const isFixedParent: (el: Element) => boolean;
|
|
1058
1118
|
declare const getMode: (el: Element) => Mode;
|
|
1059
1119
|
declare const getScrollParent: (element: HTMLElement, includeHidden?: boolean) => HTMLElement | null;
|
|
1120
|
+
/**
|
|
1121
|
+
* 将元素滚动到指定滚动容器的可视区域内(仅垂直方向,滚动最小距离)
|
|
1122
|
+
* @description 与原生 scrollIntoView 不同,只滚动指定的容器自身,不会连带滚动外层祖先滚动容器,
|
|
1123
|
+
* 避免编辑器画布外层容器(如 stage 外层使用 transform 模拟滚动的容器)被浏览器自动滚动导致整个画布位移
|
|
1124
|
+
* @param el 目标元素
|
|
1125
|
+
* @param container 滚动容器
|
|
1126
|
+
*/
|
|
1127
|
+
declare const scrollElementIntoView: (el: Element, container: HTMLElement) => void;
|
|
1060
1128
|
declare const removeSelectedClassName: (doc: Document) => void;
|
|
1061
1129
|
declare const addSelectedClassName: (el: Element, doc: Document) => void;
|
|
1062
1130
|
/**
|
|
@@ -1102,4 +1170,4 @@ declare const _default: (handler: (type: AbleActionEventType) => void, customize
|
|
|
1102
1170
|
render(moveable: MoveableManagerInterface<any, any>, React: Renderer): any;
|
|
1103
1171
|
};
|
|
1104
1172
|
//#endregion
|
|
1105
|
-
export { AbleActionEventType, AbleCustomizedButton, ActionManagerConfig, ActionManagerEvents, CONTAINER_HIGHLIGHT_CLASS_NAME, CanDropIn, CanSelect, ContainerHighlightType, CoreEvents, CustomizeMoveableOptions, CustomizeMoveableOptionsCallbackConfig, CustomizeMoveableOptionsFunction, CustomizeRender, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, DelayedMarkContainer, DrEvents, DragResizeHelperConfig, GHOST_EL_ID_PREFIX, GetElementsFromPoint, GetRenderDocument, GetRootContainer, GetTargetElement, GuidesEventData, type GuidesOptions, GuidesType, HIGHLIGHT_EL_ID_PREFIX, IsContainer, Magic, MarkContainerEnd, MaskEvents, Mode, MouseButton, _default as MoveableActionsAble, MoveableOptionsManagerConfig, MultiDrEvents, Offset, PAGE_CLASS, Point, Rect, RemoveData, RemoveEventData, RenderEvents, RenderType, RuleOptions, Runtime, RuntimeWindow, SELECTED_CLASS, SelectStatus, SortEventData, StageCoreConfig, StageDragResize, StageDragResizeConfig, StageDragStatus, StageHighlightConfig, StageMask, StageMaskConfig, StageMultiDragResizeConfig, StageRender, StageRenderConfig, TargetElement, TargetShadowConfig, UpdateData, UpdateDragEl, UpdateEventData, ZIndex, addSelectedClassName, StageCore as default, down, getAbsolutePosition, getBorderWidth, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, up };
|
|
1173
|
+
export { AbleActionEventType, AbleCustomizedButton, ActionManagerConfig, ActionManagerEvents, CONTAINER_HIGHLIGHT_CLASS_NAME, CanDropIn, CanSelect, ContainerHighlightType, CoreEvents, CustomizeMoveableOptions, CustomizeMoveableOptionsCallbackConfig, CustomizeMoveableOptionsFunction, CustomizeRender, DEFAULT_ZOOM, DRAG_EL_ID_PREFIX, DelayedMarkContainer, DrEvents, DragResizeHelperConfig, FLASH_EL_ID_PREFIX, GHOST_EL_ID_PREFIX, GetElementsFromPoint, GetRenderDocument, GetRootContainer, GetTargetElement, GuidesEventData, type GuidesOptions, GuidesType, HIGHLIGHT_EL_ID_PREFIX, IsContainer, Magic, MarkContainerEnd, MaskEvents, Mode, MouseButton, _default as MoveableActionsAble, MoveableOptionsManagerConfig, MultiDrEvents, Offset, PAGE_CLASS, Point, Rect, RemoveData, RemoveEventData, RenderEvents, RenderType, RuleOptions, Runtime, RuntimeWindow, SELECTED_CLASS, SelectStatus, SortEventData, StageCoreConfig, StageDragResize, StageDragResizeConfig, StageDragStatus, StageFlashHighlightConfig, StageHighlightConfig, StageMask, StageMaskConfig, StageMultiDragResizeConfig, StageRender, StageRenderConfig, TargetElement, TargetShadowConfig, UpdateData, UpdateDragEl, UpdateEventData, ZIndex, addSelectedClassName, StageCore as default, down, getAbsolutePosition, getBorderWidth, getMarginValue, getMode, getOffset, getScrollParent, getTargetElStyle, isAbsolute, isFixed, isFixedParent, isMoveableButton, isRelative, isStatic, removeSelectedClassName, scrollElementIntoView, up };
|