@vvfx/sdk 0.2.8 → 0.2.9
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/config.js +231 -0
- package/dist/exporter/config.js +18 -0
- package/dist/exporter/const.js +71 -0
- package/dist/exporter/export-media.js +878 -0
- package/dist/exporter/exporter.js +121 -0
- package/dist/exporter/index.js +1 -0
- package/dist/exporter/types.js +1 -0
- package/dist/exporter/utils.js +190 -0
- package/dist/exporter/wav-audio.js +50 -0
- package/dist/gesture-handler/gizmo/adsorption-gizmo.js +227 -0
- package/dist/gesture-handler/gizmo/control-gizmo.js +149 -0
- package/dist/gesture-handler/gizmo/gizmo.js +17 -0
- package/dist/gesture-handler/gizmo/icon-gizmo.js +189 -0
- package/dist/gesture-handler/gizmo/index.js +6 -0
- package/dist/gesture-handler/gizmo/item-create-gizmo.js +256 -0
- package/dist/gesture-handler/gizmo/loading-gizmo.js +320 -0
- package/dist/gesture-handler/gizmo/mask-gizmo.js +648 -0
- package/dist/gesture-handler/gizmo/picture-cut-gizmo.js +550 -0
- package/dist/gesture-handler/gizmo/picture-expand-gizmo.js +491 -0
- package/dist/gesture-handler/gizmo/preference-gizmo.js +148 -0
- package/dist/gesture-handler/gizmo/selector-gizmo.d.ts +1 -1
- package/dist/gesture-handler/gizmo/selector-gizmo.js +468 -0
- package/dist/gesture-handler/gizmo/sprite-text-edit-gizmo.js +247 -0
- package/dist/gesture-handler/gizmo/text-gizmo.js +1033 -0
- package/dist/gesture-handler/gizmo/transform-gizmo.js +1199 -0
- package/dist/gesture-handler/gizmo/type.js +18 -0
- package/dist/gesture-handler/index.js +3 -0
- package/dist/gesture-handler/src/gesture-handler.js +770 -0
- package/dist/gesture-handler/src/icons.js +24 -0
- package/dist/gesture-handler/utils.js +40 -0
- package/dist/html-overlay/anchor-navigation-runtime.js +27 -0
- package/dist/html-overlay/auto-height-runtime.js +132 -0
- package/dist/html-overlay/document-runtime.js +71 -0
- package/dist/html-overlay/document-transform.js +96 -0
- package/dist/html-overlay/dom-order.js +8 -0
- package/dist/html-overlay/host-message-runtime.js +24 -0
- package/dist/html-overlay/html-capture-runtime.js +282 -0
- package/dist/html-overlay/html-viewport-style.js +10 -0
- package/dist/html-overlay/index.js +1 -0
- package/dist/html-overlay/manager.js +1663 -0
- package/dist/html-overlay/mime-utils.js +21 -0
- package/dist/html-overlay/overlay-transform.js +57 -0
- package/dist/html-overlay/path-utils.js +35 -0
- package/dist/html-overlay/shell-runtime.js +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -75311
- package/dist/index.mjs +75311 -0
- package/dist/{index.js.map → index.mjs.map} +1 -1
- package/dist/layer-order.js +8 -0
- package/dist/math/box2.js +396 -0
- package/dist/math/circle.js +131 -0
- package/dist/math/euler.js +35 -0
- package/dist/math/index.js +13 -0
- package/dist/math/line2.js +153 -0
- package/dist/math/line3.js +36 -0
- package/dist/math/matrix4.js +207 -0
- package/dist/math/plane.js +52 -0
- package/dist/math/quaternion.js +3 -0
- package/dist/math/ray-caster.js +25 -0
- package/dist/math/ray.js +47 -0
- package/dist/math/type.js +1 -0
- package/dist/math/utils.js +77 -0
- package/dist/math/vector2.js +70 -0
- package/dist/math/vector3.js +60 -0
- package/dist/screen-shot/index.js +1 -0
- package/dist/screen-shot/screen-shot.js +113 -0
- package/dist/sdk-item/base-item.js +160 -0
- package/dist/sdk-item/card-item.js +131 -0
- package/dist/sdk-item/effects-item.js +144 -0
- package/dist/sdk-item/frame-item.js +217 -0
- package/dist/sdk-item/generator-item.js +188 -0
- package/dist/sdk-item/group-item.js +116 -0
- package/dist/sdk-item/index.js +39 -0
- package/dist/sdk-item/sprite-item.js +147 -0
- package/dist/sdk-item/text-item.js +223 -0
- package/dist/sdk-item/types.d.ts +1 -1
- package/dist/sdk-item/types.js +15 -0
- package/dist/sdk-item/video-item.js +174 -0
- package/dist/sdk.js +1903 -0
- package/dist/service/UndoRedo.js +79 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +2 -0
- package/dist/shared/player.d.ts +1 -1
- package/dist/shared/player.js +9 -0
- package/dist/shared/spec.d.ts +1 -0
- package/dist/shared/spec.js +1 -0
- package/dist/size-adapte/index.js +1 -0
- package/dist/size-adapte/size-adapt.js +395 -0
- package/dist/types.d.ts +5 -1
- package/dist/types.js +17 -0
- package/dist/utils/background-manager.js +189 -0
- package/dist/utils/common-utils.js +183 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/interaction-utils.js +205 -0
- package/dist/utils/json-data-utils.js +1529 -0
- package/dist/utils/layout-utils.js +1217 -0
- package/dist/utils/page-data-utils.js +5397 -0
- package/dist/utils/player-data-utils.js +48 -0
- package/dist/utils/types.js +8 -0
- package/dist/wireframe/common/box.js +18 -0
- package/dist/wireframe/common/dashed-line.js +21 -0
- package/dist/wireframe/common/line.js +17 -0
- package/dist/wireframe/common/pixi-ext.js +1 -0
- package/dist/wireframe/common/pixi.js +31 -0
- package/dist/wireframe/index.js +4 -0
- package/package.json +10 -3
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
2
|
+
import { Application } from '@pixi/app';
|
|
3
|
+
import { AdsorptionGizmo, ControlGizmo, SelectorGizmo, TransformGizmo } from '../gizmo';
|
|
4
|
+
import { PreferenceGizmo } from '../gizmo/preference-gizmo';
|
|
5
|
+
import { cursorMap, loadCursorIcons } from './icons';
|
|
6
|
+
import { PictureCutGizmo } from '../gizmo/picture-cut-gizmo';
|
|
7
|
+
import { SDK } from '../../sdk';
|
|
8
|
+
import { TextGizmo } from '../gizmo/text-gizmo';
|
|
9
|
+
import { Texture } from '@pixi/core';
|
|
10
|
+
import { MaskGizmo } from '../gizmo/mask-gizmo';
|
|
11
|
+
import { LoadingGizmo } from '../gizmo/loading-gizmo';
|
|
12
|
+
import { PictureExpandGizmo } from '../gizmo/picture-expand-gizmo';
|
|
13
|
+
import { SpriteTextEditGizmo } from '../gizmo/sprite-text-edit-gizmo';
|
|
14
|
+
import { IconGizmo } from '../gizmo/icon-gizmo';
|
|
15
|
+
import { ItemCreateGizmo } from '../gizmo/item-create-gizmo';
|
|
16
|
+
export class GestureHandler {
|
|
17
|
+
wireframeApplication;
|
|
18
|
+
gizmos = [];
|
|
19
|
+
activeGizmo;
|
|
20
|
+
selectorGizmo;
|
|
21
|
+
transformGizmo;
|
|
22
|
+
controlGizmo;
|
|
23
|
+
preferenceGizmo;
|
|
24
|
+
pictureCutGizmo;
|
|
25
|
+
pictureExpandGizmo;
|
|
26
|
+
textGizmo;
|
|
27
|
+
maskGizmo;
|
|
28
|
+
loadingGizmo;
|
|
29
|
+
spriteTextEditGizmo;
|
|
30
|
+
iconGizmo;
|
|
31
|
+
itemCreateGizmo;
|
|
32
|
+
_ignoreInteraction = false;
|
|
33
|
+
clickButtons = 0;
|
|
34
|
+
container;
|
|
35
|
+
_emitter;
|
|
36
|
+
/**
|
|
37
|
+
* @description Current time when mouse down is first trigger.
|
|
38
|
+
*/
|
|
39
|
+
clickTime = 0;
|
|
40
|
+
/**
|
|
41
|
+
* @description Is first click.
|
|
42
|
+
*/
|
|
43
|
+
firstClick = true;
|
|
44
|
+
/**
|
|
45
|
+
* @description The maximum span duration a double click interact. - 500ms 操作是 windows 默认的双击时间间隔
|
|
46
|
+
*/
|
|
47
|
+
dblclickTimeSpan = 500;
|
|
48
|
+
/**
|
|
49
|
+
* @description 是否按下空格键
|
|
50
|
+
*/
|
|
51
|
+
spaceEmit = false;
|
|
52
|
+
/**
|
|
53
|
+
* @description 辅助面板交互状态
|
|
54
|
+
*/
|
|
55
|
+
interactType = 'select';
|
|
56
|
+
constructor(container) {
|
|
57
|
+
this.gizmos = [];
|
|
58
|
+
const { width, height } = container.getBoundingClientRect();
|
|
59
|
+
this.wireframeApplication = new Application({
|
|
60
|
+
backgroundAlpha: 0,
|
|
61
|
+
width,
|
|
62
|
+
height,
|
|
63
|
+
resolution: 2,
|
|
64
|
+
autoDensity: true,
|
|
65
|
+
antialias: true,
|
|
66
|
+
});
|
|
67
|
+
this.container = container;
|
|
68
|
+
this.wireframeApplication.view.style.position = 'absolute';
|
|
69
|
+
this.wireframeApplication.view.id = 'wireframeApplicationCanvas';
|
|
70
|
+
container.appendChild(this.wireframeApplication.view);
|
|
71
|
+
this.wireframeApplication.stage.sortableChildren = true;
|
|
72
|
+
void loadCursorIcons();
|
|
73
|
+
}
|
|
74
|
+
set ignoreInteraction(state) {
|
|
75
|
+
if (state === this._ignoreInteraction) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this._ignoreInteraction = state;
|
|
79
|
+
if (state) {
|
|
80
|
+
this.activeGizmo?.cancelPreparation();
|
|
81
|
+
this.activeGizmo = undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
get ignoreInteraction() {
|
|
85
|
+
return this._ignoreInteraction;
|
|
86
|
+
}
|
|
87
|
+
resize() {
|
|
88
|
+
if (!this.wireframeApplication) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.wireframeApplication.resizeTo = this.container;
|
|
92
|
+
this.render();
|
|
93
|
+
}
|
|
94
|
+
refresh() {
|
|
95
|
+
this.gizmos.forEach(gizmo => {
|
|
96
|
+
gizmo.refreshResults();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
render() {
|
|
100
|
+
this.refresh();
|
|
101
|
+
if (!this.wireframeApplication?.stage) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.wireframeApplication?.stage?.removeChildren();
|
|
105
|
+
const resultGizmos = this.ignoreInteraction ? [this.preferenceGizmo] : this.gizmos;
|
|
106
|
+
const results = resultGizmos.flatMap(gizmo => gizmo.getRenderObjects());
|
|
107
|
+
this.wireframeApplication?.stage?.addChild(...results);
|
|
108
|
+
// 绘制
|
|
109
|
+
this.wireframeApplication?.render();
|
|
110
|
+
// 获取鼠标指针样式 [移除屏幕时也持续绘制,因为其不可见]
|
|
111
|
+
const cursorResult = (this.activeGizmo instanceof TransformGizmo ||
|
|
112
|
+
this.activeGizmo instanceof PictureCutGizmo ||
|
|
113
|
+
this.activeGizmo instanceof PictureExpandGizmo ||
|
|
114
|
+
this.activeGizmo instanceof MaskGizmo ||
|
|
115
|
+
this.activeGizmo instanceof TextGizmo ||
|
|
116
|
+
this.activeGizmo instanceof ControlGizmo ||
|
|
117
|
+
this.activeGizmo instanceof IconGizmo ||
|
|
118
|
+
this.activeGizmo instanceof ItemCreateGizmo) ? this.activeGizmo.cursorResult : undefined;
|
|
119
|
+
this.setCursor(cursorResult);
|
|
120
|
+
}
|
|
121
|
+
async init(pageDataUtils, emitter) {
|
|
122
|
+
if (this.wireframeApplication === null) {
|
|
123
|
+
setTimeout(async () => {
|
|
124
|
+
await this.init(pageDataUtils, emitter);
|
|
125
|
+
}, 50);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
this.gizmos = [];
|
|
129
|
+
this.controlGizmo = new ControlGizmo(pageDataUtils);
|
|
130
|
+
this.selectorGizmo = new SelectorGizmo(pageDataUtils);
|
|
131
|
+
const adsorptionGizmo = new AdsorptionGizmo();
|
|
132
|
+
this.transformGizmo = new TransformGizmo(pageDataUtils, adsorptionGizmo, this.selectorGizmo);
|
|
133
|
+
this.preferenceGizmo = new PreferenceGizmo(pageDataUtils);
|
|
134
|
+
this.pictureCutGizmo = new PictureCutGizmo(pageDataUtils, emitter);
|
|
135
|
+
this.pictureExpandGizmo = new PictureExpandGizmo(pageDataUtils, emitter);
|
|
136
|
+
this.textGizmo = new TextGizmo(pageDataUtils, adsorptionGizmo, this.selectorGizmo, emitter, this.wireframeApplication?.view.parentElement);
|
|
137
|
+
this.textGizmo.rotationSprite.texture = await Texture.fromURL(SDK.config.gestureHandlerConfig.textGizmoConfig.rotationCornerTexture);
|
|
138
|
+
this.maskGizmo = new MaskGizmo(pageDataUtils, this.wireframeApplication, emitter);
|
|
139
|
+
this.loadingGizmo = new LoadingGizmo(pageDataUtils);
|
|
140
|
+
this.spriteTextEditGizmo = new SpriteTextEditGizmo(pageDataUtils, emitter);
|
|
141
|
+
this.iconGizmo = new IconGizmo(pageDataUtils, emitter);
|
|
142
|
+
await this.iconGizmo.init();
|
|
143
|
+
this.itemCreateGizmo = new ItemCreateGizmo(pageDataUtils, emitter);
|
|
144
|
+
this.gizmos.push(this.itemCreateGizmo, this.maskGizmo, this.spriteTextEditGizmo, this.pictureCutGizmo, this.pictureExpandGizmo, this.loadingGizmo, this.iconGizmo, this.transformGizmo, this.textGizmo, this.selectorGizmo, this.controlGizmo, this.preferenceGizmo, adsorptionGizmo);
|
|
145
|
+
this._emitter = emitter;
|
|
146
|
+
this.initEvents();
|
|
147
|
+
this.registerViewEvent();
|
|
148
|
+
}
|
|
149
|
+
initEvents() {
|
|
150
|
+
this.onMouseMove = this.onMouseMove.bind(this);
|
|
151
|
+
this.onMouseUp = this.onMouseUp.bind(this);
|
|
152
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
153
|
+
this.onKeyUp = this.onKeyUp.bind(this);
|
|
154
|
+
document.addEventListener('keydown', this.onKeyDown);
|
|
155
|
+
document.addEventListener('keyup', this.onKeyUp);
|
|
156
|
+
}
|
|
157
|
+
registerViewEvent() {
|
|
158
|
+
this.wireframeApplication.view.onmousedown = (event) => {
|
|
159
|
+
this.onMouseDown(event);
|
|
160
|
+
};
|
|
161
|
+
this.wireframeApplication.view.onmousemove = (event) => {
|
|
162
|
+
if (event.buttons === 0) {
|
|
163
|
+
this.onMouseMove(event);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
this.wireframeApplication.view.onmouseout = () => {
|
|
167
|
+
this.selectorGizmo?.cancelPreparation();
|
|
168
|
+
// 鼠标跳出屏幕
|
|
169
|
+
this.render();
|
|
170
|
+
};
|
|
171
|
+
this.wireframeApplication.view.onwheel = (event) => {
|
|
172
|
+
this.onWheel(event);
|
|
173
|
+
};
|
|
174
|
+
this.wireframeApplication.view.oncontextmenu = (event) => {
|
|
175
|
+
event.stopPropagation();
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 鼠标按下事件
|
|
181
|
+
* @param event 鼠标事件
|
|
182
|
+
*/
|
|
183
|
+
onMouseDown(event) {
|
|
184
|
+
if (this.ignoreInteraction) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.clickButtons = event.buttons;
|
|
188
|
+
switch (this.interactType) {
|
|
189
|
+
case 'select': {
|
|
190
|
+
if (this.clickButtons === 4) {
|
|
191
|
+
this.activeGizmo = this.controlGizmo;
|
|
192
|
+
this.controlGizmo.preAction(event);
|
|
193
|
+
}
|
|
194
|
+
this.firstClick = this.firstClick ? Date.now() - this.clickTime < this.dblclickTimeSpan : false;
|
|
195
|
+
if (!this.firstClick) {
|
|
196
|
+
// 当mouseUp后未进行mouseMove时,前置进行获取一次activeGizmo
|
|
197
|
+
if (this.activeGizmo === undefined) {
|
|
198
|
+
this.gizmos.forEach(gizmo => {
|
|
199
|
+
if (!gizmo.interactive || this.activeGizmo) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const activeType = gizmo.preparationAction(event);
|
|
203
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === activeType);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
const activeType = this.activeGizmo?.preAction(event);
|
|
207
|
+
if (activeType && !['selector', 'transform'].includes(activeType) && this.selectorGizmo) {
|
|
208
|
+
this.selectorGizmo.clearResult = true;
|
|
209
|
+
}
|
|
210
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === activeType);
|
|
211
|
+
this.clickTime = Date.now();
|
|
212
|
+
this.firstClick = true;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this.gizmos.forEach(gizmo => {
|
|
216
|
+
if (!gizmo.interactive) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (this.activeGizmo === undefined) {
|
|
220
|
+
const activeType = gizmo.preparationAction(event);
|
|
221
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === activeType);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
gizmo.cancelPreparation();
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
if (this.activeGizmo && ['transform', 'text'].includes(this.activeGizmo.type)) {
|
|
228
|
+
const activeType = this.activeGizmo.preAction(event, true);
|
|
229
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === (activeType ?? 'null'));
|
|
230
|
+
}
|
|
231
|
+
else if (this.activeGizmo && !['picture-cut', 'picture-expand', 'mask', 'sprite-text-edit', 'icon'].includes(this.activeGizmo.type)) {
|
|
232
|
+
this.activeGizmo = undefined;
|
|
233
|
+
const activeType = this.selectorGizmo?.preAction(event, true);
|
|
234
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === (activeType ?? 'null'));
|
|
235
|
+
}
|
|
236
|
+
this.firstClick = false;
|
|
237
|
+
}
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
case 'hand': {
|
|
241
|
+
this.activeGizmo = this.controlGizmo;
|
|
242
|
+
this.activeGizmo.preAction(event);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
this.render();
|
|
246
|
+
this._emitter?.emit('itemOnDragStart', this.activeGizmo?.type ?? 'null');
|
|
247
|
+
document.addEventListener('mousemove', this.onMouseMove);
|
|
248
|
+
document.addEventListener('mouseup', this.onMouseUp);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 鼠标移动事件
|
|
252
|
+
* @param event 鼠标事件
|
|
253
|
+
*/
|
|
254
|
+
onMouseMove(event) {
|
|
255
|
+
if (this.ignoreInteraction) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
// 无鼠标按下时,执行交互准备事件
|
|
259
|
+
if (event.buttons !== 0) {
|
|
260
|
+
this.activeGizmo?.action(event);
|
|
261
|
+
if (this.activeGizmo?.type !== 'selector' && this.selectorGizmo) {
|
|
262
|
+
this.selectorGizmo.clearResult = true;
|
|
263
|
+
}
|
|
264
|
+
this._emitter?.emit('itemOnDrag', this.activeGizmo?.type ?? 'null');
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
switch (this.interactType) {
|
|
268
|
+
case 'select': {
|
|
269
|
+
this.activeGizmo = undefined;
|
|
270
|
+
if (this.spaceEmit) {
|
|
271
|
+
this.activeGizmo = this.controlGizmo;
|
|
272
|
+
this.controlGizmo.interactionType = 'mouse';
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
this.gizmos.forEach(gizmo => {
|
|
276
|
+
if (!gizmo.interactive) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (this.activeGizmo === undefined) {
|
|
280
|
+
const activeType = gizmo.preparationAction(event);
|
|
281
|
+
if (activeType && !['selector', 'transform'].includes(activeType) && this.selectorGizmo) {
|
|
282
|
+
this.selectorGizmo.clearResult = true;
|
|
283
|
+
}
|
|
284
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === activeType);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
gizmo.cancelPreparation();
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case 'hand': {
|
|
294
|
+
this.activeGizmo = this.controlGizmo;
|
|
295
|
+
this.activeGizmo.preparationAction(event);
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
this.render();
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* 鼠标滚轮事件
|
|
304
|
+
* @param event 鼠标事件
|
|
305
|
+
*/
|
|
306
|
+
onWheel(event) {
|
|
307
|
+
if (this.ignoreInteraction) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
if (this.selectorGizmo) {
|
|
312
|
+
this.selectorGizmo.clearResult = true;
|
|
313
|
+
}
|
|
314
|
+
if (this.spriteTextEditGizmo) {
|
|
315
|
+
this.spriteTextEditGizmo.clearPreSelected = true;
|
|
316
|
+
}
|
|
317
|
+
this.controlGizmo?.action(event);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 鼠标松开事件
|
|
321
|
+
* @param event 鼠标事件
|
|
322
|
+
*/
|
|
323
|
+
onMouseUp(event) {
|
|
324
|
+
if (this.ignoreInteraction) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// 结束交互
|
|
328
|
+
const activeType = this.activeGizmo?.endAction(event);
|
|
329
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === activeType);
|
|
330
|
+
// 当左键结束交互返回活跃Gizmo为空时,根据当前位置触发行动准备事件[以刷新鼠标状态]
|
|
331
|
+
if (this.activeGizmo === undefined && this.clickButtons === 1) {
|
|
332
|
+
this.gizmos.forEach(gizmo => {
|
|
333
|
+
if (!gizmo.interactive) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (this.activeGizmo === undefined) {
|
|
337
|
+
const activeType = gizmo.preparationAction(event);
|
|
338
|
+
this.activeGizmo = this.gizmos.find(gizmo => gizmo.type === activeType);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
gizmo.cancelPreparation();
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
this.clickButtons = 0;
|
|
346
|
+
this._emitter?.emit('itemOnDragEnd', this.activeGizmo?.type ?? 'null');
|
|
347
|
+
this.render();
|
|
348
|
+
document.removeEventListener('mousemove', this.onMouseMove);
|
|
349
|
+
document.removeEventListener('mouseup', this.onMouseUp);
|
|
350
|
+
}
|
|
351
|
+
onKeyDown(keyCode) {
|
|
352
|
+
if (this.ignoreInteraction) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (keyCode.code.toLocaleLowerCase() === 'escape' && this.interactType !== 'select') {
|
|
356
|
+
this.setInteractType('select');
|
|
357
|
+
}
|
|
358
|
+
if (keyCode.code.toLocaleLowerCase() === 'space' && !this.activeGizmo?.active) {
|
|
359
|
+
this.spaceEmit = true;
|
|
360
|
+
this.activeGizmo = this.controlGizmo;
|
|
361
|
+
this.controlGizmo.interactionType = this.interactType === 'hand' || this.spaceEmit ? 'mouse' : 'wheel';
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.gizmos.forEach(gizmo => {
|
|
365
|
+
gizmo.actionKey(keyCode);
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
this.render();
|
|
369
|
+
}
|
|
370
|
+
onKeyUp(keyCode) {
|
|
371
|
+
if (this.ignoreInteraction) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
this.gizmos.forEach(gizmo => {
|
|
375
|
+
gizmo.endActionKey(keyCode);
|
|
376
|
+
});
|
|
377
|
+
if (keyCode.code.toLocaleLowerCase() === 'space') {
|
|
378
|
+
this.spaceEmit = false;
|
|
379
|
+
this.controlGizmo.interactionType = this.interactType === 'hand' || this.spaceEmit ? 'mouse' : 'wheel';
|
|
380
|
+
}
|
|
381
|
+
this.render();
|
|
382
|
+
}
|
|
383
|
+
dispose() {
|
|
384
|
+
this.container.removeChild(this.wireframeApplication.view);
|
|
385
|
+
this.wireframeApplication.destroy();
|
|
386
|
+
this.gizmos = [];
|
|
387
|
+
this.activeGizmo = undefined;
|
|
388
|
+
}
|
|
389
|
+
setCursor(result) {
|
|
390
|
+
let cssCursor = 'default';
|
|
391
|
+
if (result?.type === 'circle') {
|
|
392
|
+
const strokeWidth = 1;
|
|
393
|
+
const radius = (result.radius || 10);
|
|
394
|
+
const svgStr = encodeURIComponent(`<svg width="${radius * 2}" height="${radius * 2}" xmlns="http://www.w3.org/2000/svg"><circle cx="${radius}" cy="${radius}" r="${radius}" fill="rgba(255, 255, 255, 0.6)" stroke="#6A34FF" stroke-width="${strokeWidth}" /></svg>`);
|
|
395
|
+
cssCursor = `url("data:image/svg+xml,${svgStr}") ${radius} ${radius}, auto`;
|
|
396
|
+
}
|
|
397
|
+
else if (result?.type && ['scale', 'rotation', 'hand', 'active-hand', 'pointer', 'text-create', 'frame-create', 'box-select'].includes(result.type)) {
|
|
398
|
+
const cursor = cursorMap[result.type];
|
|
399
|
+
if (cursor.type === 'svg') {
|
|
400
|
+
const pointerShift = 16; // svg大小固定为32 * 32
|
|
401
|
+
// (旋转会导致CSS图标变糊)
|
|
402
|
+
cssCursor = encodeURIComponent(cursor.content.replace('rotate(0.00)', `rotate(${result.angle ?? 0})`));
|
|
403
|
+
cssCursor = `url("data:image/svg+xml,${cssCursor}") ${pointerShift} ${pointerShift}, auto`;
|
|
404
|
+
}
|
|
405
|
+
else { // cursor.type == preset
|
|
406
|
+
cssCursor = cursor.content;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
this.wireframeApplication.view.style.cursor = cssCursor;
|
|
410
|
+
}
|
|
411
|
+
openPictureCutGizmo() {
|
|
412
|
+
if (!this.pictureCutGizmo) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
this.setInteractType('select');
|
|
416
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
417
|
+
this.pictureCutGizmo.interactive = true;
|
|
418
|
+
if (this.pictureCutGizmo.interactive) {
|
|
419
|
+
this.pictureExpandGizmo.interactive = false;
|
|
420
|
+
this.maskGizmo.interactive = false;
|
|
421
|
+
this.selectorGizmo.interactive = false;
|
|
422
|
+
this.transformGizmo.interactive = false;
|
|
423
|
+
this.textGizmo.interactive = false;
|
|
424
|
+
this.itemCreateGizmo.interactive = false;
|
|
425
|
+
}
|
|
426
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
427
|
+
this.render();
|
|
428
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
429
|
+
}
|
|
430
|
+
closePictureCutGizmo() {
|
|
431
|
+
if (!this.pictureCutGizmo) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
435
|
+
this.pictureCutGizmo.interactive = false;
|
|
436
|
+
this.transformGizmo.interactive = true;
|
|
437
|
+
this.selectorGizmo.interactive = true;
|
|
438
|
+
this.textGizmo.interactive = true;
|
|
439
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
440
|
+
this.render();
|
|
441
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
442
|
+
}
|
|
443
|
+
setInteractType(type) {
|
|
444
|
+
if (type === this.interactType) {
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
this.interactType = type;
|
|
448
|
+
this.controlGizmo.interactionType = this.interactType === 'hand' || this.spaceEmit ? 'mouse' : 'wheel';
|
|
449
|
+
}
|
|
450
|
+
getCutInfo() {
|
|
451
|
+
return this.pictureCutGizmo?.getCutInfo();
|
|
452
|
+
}
|
|
453
|
+
setCutBox(min, max) {
|
|
454
|
+
const cutBox = this.pictureCutGizmo?.setCutBox(min, max);
|
|
455
|
+
this.render();
|
|
456
|
+
return cutBox;
|
|
457
|
+
}
|
|
458
|
+
openPictureExpandGizmo() {
|
|
459
|
+
if (!this.pictureExpandGizmo) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
this.setInteractType('select');
|
|
463
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
464
|
+
this.pictureExpandGizmo.interactive = true;
|
|
465
|
+
if (this.pictureExpandGizmo.interactive) {
|
|
466
|
+
this.pictureCutGizmo.interactive = false;
|
|
467
|
+
this.maskGizmo.interactive = false;
|
|
468
|
+
this.selectorGizmo.interactive = false;
|
|
469
|
+
this.transformGizmo.interactive = false;
|
|
470
|
+
this.textGizmo.interactive = false;
|
|
471
|
+
this.itemCreateGizmo.interactive = false;
|
|
472
|
+
}
|
|
473
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
474
|
+
this.render();
|
|
475
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
476
|
+
}
|
|
477
|
+
closePictureExpandGizmo() {
|
|
478
|
+
if (!this.pictureExpandGizmo) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
482
|
+
this.pictureExpandGizmo.interactive = false;
|
|
483
|
+
this.transformGizmo.interactive = true;
|
|
484
|
+
this.selectorGizmo.interactive = true;
|
|
485
|
+
this.textGizmo.interactive = true;
|
|
486
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
487
|
+
this.render();
|
|
488
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
489
|
+
}
|
|
490
|
+
getExpandInfo() {
|
|
491
|
+
return this.pictureExpandGizmo?.getExpandInfo();
|
|
492
|
+
}
|
|
493
|
+
setExpandBox(min, max) {
|
|
494
|
+
const cutBox = this.pictureExpandGizmo?.setExpandBox(min, max);
|
|
495
|
+
this.render();
|
|
496
|
+
return cutBox;
|
|
497
|
+
}
|
|
498
|
+
openMaskGizmo(brushSize) {
|
|
499
|
+
if (!this.maskGizmo) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
this.setInteractType('select');
|
|
503
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
504
|
+
this.maskGizmo.interactive = true;
|
|
505
|
+
this.maskGizmo.config = {
|
|
506
|
+
brushSize,
|
|
507
|
+
};
|
|
508
|
+
if (this.maskGizmo.interactive) {
|
|
509
|
+
this.pictureCutGizmo.interactive = false;
|
|
510
|
+
this.pictureExpandGizmo.interactive = false;
|
|
511
|
+
this.transformGizmo.interactive = false;
|
|
512
|
+
this.selectorGizmo.interactive = false;
|
|
513
|
+
this.itemCreateGizmo.interactive = false;
|
|
514
|
+
}
|
|
515
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
516
|
+
this.render();
|
|
517
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
518
|
+
}
|
|
519
|
+
clearMaskGizmo() {
|
|
520
|
+
if (!this.maskGizmo) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
this.maskGizmo.clearMask();
|
|
524
|
+
this.render();
|
|
525
|
+
}
|
|
526
|
+
closeMaskGizmo() {
|
|
527
|
+
if (!this.maskGizmo) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
531
|
+
this.maskGizmo.interactive = false;
|
|
532
|
+
this.maskGizmo.close();
|
|
533
|
+
this.transformGizmo.interactive = true;
|
|
534
|
+
this.selectorGizmo.interactive = true;
|
|
535
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
536
|
+
this.render();
|
|
537
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
538
|
+
}
|
|
539
|
+
setMaskGizmoConfig(config) {
|
|
540
|
+
if (!this.maskGizmo) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
this.maskGizmo.config = config;
|
|
544
|
+
this.render();
|
|
545
|
+
}
|
|
546
|
+
getMask() {
|
|
547
|
+
if (!this.maskGizmo) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
return this.maskGizmo.getMask();
|
|
551
|
+
}
|
|
552
|
+
setMaskGizmoMode(mode) {
|
|
553
|
+
if (!this.maskGizmo) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
this.maskGizmo.setMode(mode);
|
|
557
|
+
this.render();
|
|
558
|
+
}
|
|
559
|
+
openLoadingGizmo(id, options) {
|
|
560
|
+
if (!this.loadingGizmo) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
564
|
+
this.loadingGizmo.add(id, options);
|
|
565
|
+
if (this.loadingGizmo.interactive) {
|
|
566
|
+
this.maskGizmo.interactive = false;
|
|
567
|
+
this.pictureCutGizmo.interactive = false;
|
|
568
|
+
this.pictureExpandGizmo.interactive = false;
|
|
569
|
+
this.itemCreateGizmo.interactive = false;
|
|
570
|
+
}
|
|
571
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
572
|
+
this.render();
|
|
573
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
574
|
+
}
|
|
575
|
+
updateLoadingGizmo(id, options) {
|
|
576
|
+
if (!this.loadingGizmo) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
580
|
+
this.loadingGizmo.update(id, options);
|
|
581
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
582
|
+
this.render();
|
|
583
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
584
|
+
}
|
|
585
|
+
closeLoadingGizmo(id) {
|
|
586
|
+
if (!this.loadingGizmo) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
590
|
+
this.loadingGizmo.delete(id);
|
|
591
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
592
|
+
this.render();
|
|
593
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
594
|
+
}
|
|
595
|
+
setPictureCutGizmoLockScale(state) {
|
|
596
|
+
this.pictureCutGizmo.isLockScale = state;
|
|
597
|
+
}
|
|
598
|
+
setPictureExpandGizmoLockScale(state) {
|
|
599
|
+
this.pictureExpandGizmo.isLockScale = state;
|
|
600
|
+
}
|
|
601
|
+
setTransformGizmoLockScale(state) {
|
|
602
|
+
this.transformGizmo.isLockScale = state;
|
|
603
|
+
}
|
|
604
|
+
// Mask Gizmo UndoRedo
|
|
605
|
+
maskGizmoUndo() {
|
|
606
|
+
if (!this.maskGizmo) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
const result = this.maskGizmo.undo();
|
|
610
|
+
if (result) {
|
|
611
|
+
this.render();
|
|
612
|
+
}
|
|
613
|
+
return result;
|
|
614
|
+
}
|
|
615
|
+
maskGizmoRedo() {
|
|
616
|
+
if (!this.maskGizmo) {
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
const result = this.maskGizmo.redo();
|
|
620
|
+
if (result) {
|
|
621
|
+
this.render();
|
|
622
|
+
}
|
|
623
|
+
return result;
|
|
624
|
+
}
|
|
625
|
+
get maskGizmoCanUndo() {
|
|
626
|
+
return this.maskGizmo?.canUndo ?? false;
|
|
627
|
+
}
|
|
628
|
+
get maskGizmoCanRedo() {
|
|
629
|
+
return this.maskGizmo?.canRedo ?? false;
|
|
630
|
+
}
|
|
631
|
+
clearMaskGizmoUndoRedo() {
|
|
632
|
+
this.maskGizmo?.clearUndoRedo();
|
|
633
|
+
}
|
|
634
|
+
// PictureCut Gizmo UndoRedo
|
|
635
|
+
pictureCutGizmoUndo() {
|
|
636
|
+
if (!this.pictureCutGizmo) {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
const result = this.pictureCutGizmo.undo();
|
|
640
|
+
if (result) {
|
|
641
|
+
this.render();
|
|
642
|
+
}
|
|
643
|
+
return result;
|
|
644
|
+
}
|
|
645
|
+
pictureCutGizmoRedo() {
|
|
646
|
+
if (!this.pictureCutGizmo) {
|
|
647
|
+
return false;
|
|
648
|
+
}
|
|
649
|
+
const result = this.pictureCutGizmo.redo();
|
|
650
|
+
if (result) {
|
|
651
|
+
this.render();
|
|
652
|
+
}
|
|
653
|
+
return result;
|
|
654
|
+
}
|
|
655
|
+
get pictureCutGizmoCanUndo() {
|
|
656
|
+
return this.pictureCutGizmo?.canUndo ?? false;
|
|
657
|
+
}
|
|
658
|
+
get pictureCutGizmoCanRedo() {
|
|
659
|
+
return this.pictureCutGizmo?.canRedo ?? false;
|
|
660
|
+
}
|
|
661
|
+
clearPictureCutGizmoUndoRedo() {
|
|
662
|
+
this.pictureCutGizmo?.clearUndoRedo();
|
|
663
|
+
}
|
|
664
|
+
openSpriteTextGizmo(initParam) {
|
|
665
|
+
if (!this.spriteTextEditGizmo) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
this.setInteractType('select');
|
|
669
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
670
|
+
this.spriteTextEditGizmo.interactive = true;
|
|
671
|
+
this.spriteTextEditGizmo.initResult(initParam);
|
|
672
|
+
if (this.spriteTextEditGizmo.interactive) {
|
|
673
|
+
this.maskGizmo.interactive = false;
|
|
674
|
+
this.pictureCutGizmo.interactive = false;
|
|
675
|
+
this.pictureExpandGizmo.interactive = false;
|
|
676
|
+
this.transformGizmo.interactive = false;
|
|
677
|
+
this.selectorGizmo.interactive = false;
|
|
678
|
+
this.itemCreateGizmo.interactive = false;
|
|
679
|
+
}
|
|
680
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
681
|
+
this.render();
|
|
682
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
683
|
+
}
|
|
684
|
+
closeSpriteTextEditGizmo() {
|
|
685
|
+
if (!this.spriteTextEditGizmo) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
689
|
+
this.spriteTextEditGizmo.interactive = false;
|
|
690
|
+
this.spriteTextEditGizmo.clearResult();
|
|
691
|
+
this.transformGizmo.interactive = true;
|
|
692
|
+
this.selectorGizmo.interactive = true;
|
|
693
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
694
|
+
this.render();
|
|
695
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
696
|
+
}
|
|
697
|
+
setSpriteTextSelectedIndex(id, index) {
|
|
698
|
+
this.spriteTextEditGizmo?.setSelected(id, index);
|
|
699
|
+
}
|
|
700
|
+
setSpriteTextSelectedText(id, index, text) {
|
|
701
|
+
this.spriteTextEditGizmo?.setText(id, index, text);
|
|
702
|
+
}
|
|
703
|
+
setSpriteTextChangedState(id, index, hasChanged) {
|
|
704
|
+
this.spriteTextEditGizmo?.setChangedState(id, index, hasChanged);
|
|
705
|
+
}
|
|
706
|
+
setSpriteTextEditState(id, index, isEditing) {
|
|
707
|
+
this.spriteTextEditGizmo?.setEditState(id, index, isEditing);
|
|
708
|
+
}
|
|
709
|
+
openItemCreateGizmo(type) {
|
|
710
|
+
if (!this.itemCreateGizmo) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
this.setInteractType('select');
|
|
714
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
715
|
+
this.itemCreateGizmo.interactive = true;
|
|
716
|
+
this.itemCreateGizmo.createType = type;
|
|
717
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
718
|
+
if (this.itemCreateGizmo.interactive) {
|
|
719
|
+
this.maskGizmo.interactive = false;
|
|
720
|
+
this.pictureCutGizmo.interactive = false;
|
|
721
|
+
this.pictureExpandGizmo.interactive = false;
|
|
722
|
+
this.transformGizmo.interactive = false;
|
|
723
|
+
this.selectorGizmo.interactive = false;
|
|
724
|
+
this.spriteTextEditGizmo.interactive = false;
|
|
725
|
+
}
|
|
726
|
+
this.render();
|
|
727
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
728
|
+
}
|
|
729
|
+
closeItemCreateGizmo() {
|
|
730
|
+
if (!this.itemCreateGizmo) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const preConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
734
|
+
this.itemCreateGizmo.interactive = false;
|
|
735
|
+
this.transformGizmo.interactive = true;
|
|
736
|
+
this.selectorGizmo.interactive = true;
|
|
737
|
+
const currentConfig = JSON.parse(JSON.stringify(SDK.config));
|
|
738
|
+
this.render();
|
|
739
|
+
this._emitter?.emit('sdkConfigChange', preConfig, currentConfig);
|
|
740
|
+
}
|
|
741
|
+
openTextGizmo(textItemId, mode = 'select') {
|
|
742
|
+
if (!this.textGizmo) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
const pageDataUtils = this.selectorGizmo?.pageDataUtils;
|
|
746
|
+
// 如果指定了文本元素ID,则先选中该元素
|
|
747
|
+
if (textItemId !== undefined && pageDataUtils) {
|
|
748
|
+
pageDataUtils.clearSelectedItems();
|
|
749
|
+
pageDataUtils.addSelectedItems([textItemId]);
|
|
750
|
+
}
|
|
751
|
+
this.setInteractType('select');
|
|
752
|
+
this.textGizmo.interactionParam.type = 'edit';
|
|
753
|
+
this.textGizmo.interactionParam.textareaType = mode;
|
|
754
|
+
this.textGizmo.interactive = true;
|
|
755
|
+
if (this.textGizmo.interactive) {
|
|
756
|
+
this.maskGizmo.interactive = false;
|
|
757
|
+
this.pictureCutGizmo.interactive = false;
|
|
758
|
+
this.pictureExpandGizmo.interactive = false;
|
|
759
|
+
this.spriteTextEditGizmo.interactive = false;
|
|
760
|
+
}
|
|
761
|
+
this.render();
|
|
762
|
+
}
|
|
763
|
+
closeTextGizmo() {
|
|
764
|
+
if (!this.textGizmo) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
this.textGizmo.interactive = false;
|
|
768
|
+
this.render();
|
|
769
|
+
}
|
|
770
|
+
}
|