@versa_ai/vmml-editor 1.0.54 → 1.0.55
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/.turbo/turbo-build.log +9 -9
- package/dist/index.js +186 -23272
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -23146
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/EditorCanvas.tsx +3 -9
- package/src/index.tsx +1 -9
- package/src/utils/VmmlConverter.ts +16 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versa_ai/vmml-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"module": "dist/index.mjs",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"remotion": "4.0.166",
|
|
18
18
|
"uuid": "^10.0.0",
|
|
19
19
|
"zod": "^3.23.8",
|
|
20
|
-
"@versa_ai/vmml-
|
|
21
|
-
"@versa_ai/vmml-
|
|
20
|
+
"@versa_ai/vmml-player": "1.1.24",
|
|
21
|
+
"@versa_ai/vmml-utils": "1.0.15"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@biomejs/biome": "^1.7.1",
|
|
@@ -44,7 +44,6 @@ const EditorCanvas = forwardRef(
|
|
|
44
44
|
item.on('modified', () => {
|
|
45
45
|
const fObj = convertToJSON(item)
|
|
46
46
|
vmmlConverterRef.current.updateClip(fObj);
|
|
47
|
-
updateVmml(vmmlConverterRef.current.vmml)
|
|
48
47
|
});
|
|
49
48
|
item.set("visible", ns >= item.clipData.inPoint);
|
|
50
49
|
canvas.add(item);
|
|
@@ -88,7 +87,6 @@ const EditorCanvas = forwardRef(
|
|
|
88
87
|
}
|
|
89
88
|
const { clipData } = e.target.toJSON(['clipData']);
|
|
90
89
|
vmmlConverterRef.current.deleteClip(clipData);
|
|
91
|
-
updateVmml(vmmlConverterRef.current.vmml)
|
|
92
90
|
});
|
|
93
91
|
|
|
94
92
|
canvas.on('object:muteChange', (e: any) => {
|
|
@@ -290,7 +288,7 @@ const EditorCanvas = forwardRef(
|
|
|
290
288
|
const fObj = convertToJSON(img);
|
|
291
289
|
fObj.src = "";
|
|
292
290
|
vmmlConverterRef.current.updateClip(fObj);
|
|
293
|
-
|
|
291
|
+
|
|
294
292
|
});
|
|
295
293
|
resolve(img);
|
|
296
294
|
});
|
|
@@ -320,7 +318,7 @@ const EditorCanvas = forwardRef(
|
|
|
320
318
|
});
|
|
321
319
|
textObj.setCoords();
|
|
322
320
|
const updatedFObj = convertToJSON(textObj);
|
|
323
|
-
vmmlConverterRef.current.updateClip(updatedFObj);
|
|
321
|
+
vmmlConverterRef.current.updateClip(updatedFObj, false);
|
|
324
322
|
});
|
|
325
323
|
canvas.renderAll();
|
|
326
324
|
updateVmml(vmmlConverterRef.current?.vmml)
|
|
@@ -505,7 +503,6 @@ const EditorCanvas = forwardRef(
|
|
|
505
503
|
onBatchModify(fObj, canvas)
|
|
506
504
|
} else {
|
|
507
505
|
vmmlConverterRef.current.updateClip(fObj);
|
|
508
|
-
updateVmml(vmmlConverterRef.current?.vmml)
|
|
509
506
|
}
|
|
510
507
|
});
|
|
511
508
|
|
|
@@ -594,7 +591,6 @@ const EditorCanvas = forwardRef(
|
|
|
594
591
|
group.on('modified', () => {
|
|
595
592
|
const fObj = convertToJSON(group)
|
|
596
593
|
vmmlConverterRef.current.updateClip(fObj);
|
|
597
|
-
updateVmml(vmmlConverterRef.current?.vmml)
|
|
598
594
|
});
|
|
599
595
|
canvas.centerObject(group);
|
|
600
596
|
canvas.add(group)
|
|
@@ -603,7 +599,6 @@ const EditorCanvas = forwardRef(
|
|
|
603
599
|
})
|
|
604
600
|
onVideoChange(group?.clipData??null);
|
|
605
601
|
vmmlConverterRef.current.addTextClip(convertToJSON(group));
|
|
606
|
-
updateVmml(vmmlConverterRef.current?.vmml)
|
|
607
602
|
resolve(true);
|
|
608
603
|
})
|
|
609
604
|
|
|
@@ -678,7 +673,6 @@ const EditorCanvas = forwardRef(
|
|
|
678
673
|
target.setCoords();
|
|
679
674
|
fc?.requestRenderAll();
|
|
680
675
|
vmmlConverterRef.current.updateClip(convertToJSON(target));
|
|
681
|
-
updateVmml(vmmlConverterRef.current?.vmml)
|
|
682
676
|
}
|
|
683
677
|
}
|
|
684
678
|
const changeObjectVisible = (id: string, visible: boolean = true) => {
|
|
@@ -739,7 +733,7 @@ const EditorCanvas = forwardRef(
|
|
|
739
733
|
if (vmmlConverterRef.current) {
|
|
740
734
|
vmmlConverterRef.current.changeVmml(vmml)
|
|
741
735
|
} else {
|
|
742
|
-
vmmlConverterRef.current = new VmmlConverter({ vmml, canvasSize });
|
|
736
|
+
vmmlConverterRef.current = new VmmlConverter({ vmml, canvasSize, updatePlayer: updateVmml });
|
|
743
737
|
}
|
|
744
738
|
}
|
|
745
739
|
}, [canvasSize, vmml]);
|
package/src/index.tsx
CHANGED
|
@@ -130,14 +130,6 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
|
|
|
130
130
|
current.play();
|
|
131
131
|
setPreviewState(true);
|
|
132
132
|
setMenuState("");
|
|
133
|
-
// if (previewState) {
|
|
134
|
-
// const { current }: any = vmmlPlayerRef;
|
|
135
|
-
// current.unmute();
|
|
136
|
-
// current.play();
|
|
137
|
-
// } else {
|
|
138
|
-
// setPreviewState(true);
|
|
139
|
-
// setMenuState("");
|
|
140
|
-
// }
|
|
141
133
|
}
|
|
142
134
|
|
|
143
135
|
// 点击底部菜单
|
|
@@ -379,7 +371,7 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
|
|
|
379
371
|
useEffect(() => {
|
|
380
372
|
if (canvasSize.width && canvasSize.height && vmmlState) {
|
|
381
373
|
if (!vmmlConverterRef.current) {
|
|
382
|
-
vmmlConverterRef.current = new VmmlConverter({ vmml: vmmlState, canvasSize });
|
|
374
|
+
vmmlConverterRef.current = new VmmlConverter({ vmml: vmmlState, canvasSize, updatePlayer: updateVmml });
|
|
383
375
|
} else {
|
|
384
376
|
vmmlConverterRef.current.vmml = vmmlState;
|
|
385
377
|
}
|
|
@@ -7,18 +7,20 @@ class VmmlConverter {
|
|
|
7
7
|
private heightScale: any;
|
|
8
8
|
private widthScale: any;
|
|
9
9
|
private fontSize: number;
|
|
10
|
+
private updatePlayer: any
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* VmmlConverter 构造函数
|
|
13
14
|
* @param vmml - VMML 模板数据
|
|
14
15
|
* @param canvasSize - 画布尺寸
|
|
15
16
|
*/
|
|
16
|
-
constructor({ vmml, canvasSize }: { vmml: any; canvasSize: any}) {
|
|
17
|
+
constructor({ vmml, canvasSize, updatePlayer }: { vmml: any; canvasSize: any, updatePlayer?: any }) {
|
|
17
18
|
const { width, height } = vmml.template.dimension;
|
|
18
19
|
this.vmml = vmml;
|
|
19
20
|
this.canvasSize = canvasSize;
|
|
20
21
|
this.tracks = vmml.template.tracks;
|
|
21
22
|
this.fontSize = getFontSize(width, height);
|
|
23
|
+
this.updatePlayer = updatePlayer
|
|
22
24
|
|
|
23
25
|
// 计算宽高比
|
|
24
26
|
this.heightScale = height / canvasSize.height;
|
|
@@ -93,7 +95,8 @@ class VmmlConverter {
|
|
|
93
95
|
* 转换 TextClip
|
|
94
96
|
* @param fObj - 画布fObj
|
|
95
97
|
*/
|
|
96
|
-
public addTextClip(fObj: any): void {
|
|
98
|
+
public addTextClip(fObj: any, isUpdate?: boolean): void {
|
|
99
|
+
isUpdate = isUpdate ?? true
|
|
97
100
|
const posParam = this.setPosParam(fObj);
|
|
98
101
|
|
|
99
102
|
// const [rect, textbox] = fObj.objects;
|
|
@@ -141,7 +144,7 @@ class VmmlConverter {
|
|
|
141
144
|
editorTrack.clips.push(tClipData);
|
|
142
145
|
}
|
|
143
146
|
|
|
144
|
-
this
|
|
147
|
+
if (isUpdate) this?.updatePlayer?.(this.vmml)
|
|
145
148
|
// console.log("addTextClip 最终vmml", this.vmml);
|
|
146
149
|
}
|
|
147
150
|
|
|
@@ -149,7 +152,8 @@ class VmmlConverter {
|
|
|
149
152
|
* 转换 VideoClip
|
|
150
153
|
* @param fObj - 画布fObj
|
|
151
154
|
*/
|
|
152
|
-
public addVideoClip(fObj: any): void {
|
|
155
|
+
public addVideoClip(fObj: any, isUpdate: boolean): void {
|
|
156
|
+
isUpdate = isUpdate ?? true
|
|
153
157
|
const clips = [];
|
|
154
158
|
const editorTrack = this.tracks.find((track: any) => track.editorType === "表情包");
|
|
155
159
|
const clipData = this.loadClipData(fObj);
|
|
@@ -182,6 +186,7 @@ class VmmlConverter {
|
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
|
|
189
|
+
if (isUpdate) this?.updatePlayer?.(this.vmml)
|
|
185
190
|
// console.log("addVideoClip 最终vmml", this.vmml);
|
|
186
191
|
}
|
|
187
192
|
|
|
@@ -189,7 +194,8 @@ class VmmlConverter {
|
|
|
189
194
|
* 更新 clip
|
|
190
195
|
* @param fObj - 画布fObj
|
|
191
196
|
*/
|
|
192
|
-
public updateClip(fObj: any) {
|
|
197
|
+
public updateClip(fObj: any, isUpdate: boolean) {
|
|
198
|
+
isUpdate = isUpdate ?? true
|
|
193
199
|
// console.log("updateClip fObj", fObj, this.tracks);
|
|
194
200
|
const posParam = this.setPosParam(fObj);
|
|
195
201
|
const {
|
|
@@ -220,6 +226,7 @@ class VmmlConverter {
|
|
|
220
226
|
}
|
|
221
227
|
|
|
222
228
|
// console.log("updateClip 最终vmml", this.vmml);
|
|
229
|
+
if (isUpdate) this?.updatePlayer?.(this.vmml)
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
/**
|
|
@@ -227,7 +234,7 @@ class VmmlConverter {
|
|
|
227
234
|
* @param id - 实例 id
|
|
228
235
|
* @param type - 实例 类型
|
|
229
236
|
*/
|
|
230
|
-
public deleteClip({ id, type, originClip }: { id: string; type: string, originClip: any }): void {
|
|
237
|
+
public deleteClip({ id, type, originClip, isUpdate = true }: { id: string; type: string, originClip: any, isUpdate?: boolean }): void {
|
|
231
238
|
if (originClip) {
|
|
232
239
|
// originClip.duration = 0
|
|
233
240
|
const [existClip] = this.findClip(id)
|
|
@@ -251,7 +258,7 @@ class VmmlConverter {
|
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
260
|
}
|
|
254
|
-
|
|
261
|
+
if (isUpdate) this?.updatePlayer?.(this.vmml)
|
|
255
262
|
}
|
|
256
263
|
|
|
257
264
|
changeVmml (newVmml: any) {
|
|
@@ -260,7 +267,7 @@ class VmmlConverter {
|
|
|
260
267
|
}
|
|
261
268
|
|
|
262
269
|
//切换静音 视频/音频
|
|
263
|
-
public changeMute({ id, isMute }: { id: string; isMute: boolean }): void {
|
|
270
|
+
public changeMute({ id, isMute, isUpdate = true }: { id: string; isMute: boolean, isUpdate?: boolean }): void {
|
|
264
271
|
const editorTrack = this.tracks.find((track: any) => track.editorType === "表情包");
|
|
265
272
|
const index = editorTrack.clips.findIndex((item: any) => item.id === id);
|
|
266
273
|
if (index !== -1) {
|
|
@@ -274,6 +281,7 @@ class VmmlConverter {
|
|
|
274
281
|
}
|
|
275
282
|
}
|
|
276
283
|
|
|
284
|
+
if (isUpdate) this?.updatePlayer?.(this.vmml)
|
|
277
285
|
// console.log("changeMute 最终Vmml", this.vmml);
|
|
278
286
|
}
|
|
279
287
|
|