@versa_ai/vmml-editor 1.0.51 → 1.0.52
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 +18 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/EditorCanvas.tsx +3 -1
- package/src/index.tsx +10 -2
- package/src/utils/VmmlConverter.ts +2 -27
package/dist/index.mjs
CHANGED
|
@@ -675,6 +675,7 @@ var VmmlConverter = class {
|
|
|
675
675
|
} else {
|
|
676
676
|
editorTrack.clips.push(tClipData);
|
|
677
677
|
}
|
|
678
|
+
this.updateVmml(this.vmml);
|
|
678
679
|
}
|
|
679
680
|
/**
|
|
680
681
|
* 转换 VideoClip
|
|
@@ -742,29 +743,6 @@ var VmmlConverter = class {
|
|
|
742
743
|
}
|
|
743
744
|
}
|
|
744
745
|
}
|
|
745
|
-
updateTextClip(fObj, duration) {
|
|
746
|
-
const posParam = this.setPosParam(fObj);
|
|
747
|
-
const {
|
|
748
|
-
clipData: { id }
|
|
749
|
-
} = fObj;
|
|
750
|
-
const [existClip] = this.findClip(id);
|
|
751
|
-
if (existClip) {
|
|
752
|
-
const { clipData: { text, textColor, bgColor } } = fObj;
|
|
753
|
-
const scale = this.fontSize / 22;
|
|
754
|
-
existClip.duration = duration;
|
|
755
|
-
existClip.textClip = {
|
|
756
|
-
...existClip.textClip,
|
|
757
|
-
posParam,
|
|
758
|
-
backgroundColor: this.toARGB(bgColor),
|
|
759
|
-
textContent: text,
|
|
760
|
-
textColor: this.toARGB(textColor),
|
|
761
|
-
dimension: {
|
|
762
|
-
width: Math.floor(fObj.width * scale),
|
|
763
|
-
height: Math.floor(fObj.height * scale)
|
|
764
|
-
}
|
|
765
|
-
};
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
746
|
/**
|
|
769
747
|
* 删除 Clip
|
|
770
748
|
* @param id - 实例 id
|
|
@@ -1035,7 +1013,7 @@ function usePeekControl(canvas, hideConfig) {
|
|
|
1035
1013
|
return canvas;
|
|
1036
1014
|
}
|
|
1037
1015
|
var EditorCanvas = forwardRef(
|
|
1038
|
-
({ previewState, showCanvas, canvasSize, enterPreview, intoTextEdit, frame, vmml, dragState, initFcObjs, editClips = [], onVideoChange, isBatchModify, hideConfig, textWarapCenter }, ref) => {
|
|
1016
|
+
({ previewState, showCanvas, canvasSize, enterPreview, intoTextEdit, frame, vmml, dragState, initFcObjs, editClips = [], onVideoChange, isBatchModify, hideConfig, textWarapCenter, updateVmml }, ref) => {
|
|
1039
1017
|
const [fc, setFc] = useState(null);
|
|
1040
1018
|
const [history, setHistory] = useState(null);
|
|
1041
1019
|
const [canvasReady, setCanvasReady] = useState(false);
|
|
@@ -1311,7 +1289,7 @@ var EditorCanvas = forwardRef(
|
|
|
1311
1289
|
history.undo();
|
|
1312
1290
|
};
|
|
1313
1291
|
const onBatchModify = (fObj, canvas) => {
|
|
1314
|
-
var _a;
|
|
1292
|
+
var _a, _b;
|
|
1315
1293
|
if (!canvas) return;
|
|
1316
1294
|
const textObjects = canvas.getObjects().filter((item) => {
|
|
1317
1295
|
var _a2;
|
|
@@ -1331,9 +1309,10 @@ var EditorCanvas = forwardRef(
|
|
|
1331
1309
|
vmmlConverterRef.current.updateClip(updatedFObj);
|
|
1332
1310
|
});
|
|
1333
1311
|
canvas.renderAll();
|
|
1312
|
+
updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
|
|
1334
1313
|
const event = new CustomEvent("editor-vmml-batch-change", {
|
|
1335
1314
|
detail: {
|
|
1336
|
-
vmml: ((
|
|
1315
|
+
vmml: ((_b = vmmlConverterRef.current) == null ? void 0 : _b.vmml) ?? null
|
|
1337
1316
|
}
|
|
1338
1317
|
});
|
|
1339
1318
|
window.dispatchEvent(event);
|
|
@@ -1478,6 +1457,7 @@ var EditorCanvas = forwardRef(
|
|
|
1478
1457
|
options.transform.target.isSelected = 0;
|
|
1479
1458
|
});
|
|
1480
1459
|
group.on("modified", () => {
|
|
1460
|
+
var _a;
|
|
1481
1461
|
const fObj = convertToJSON(group);
|
|
1482
1462
|
if (fObj.clipData.isAiError) {
|
|
1483
1463
|
fObj.clipData.textColor = "rgba(0, 0, 0, 0)";
|
|
@@ -1486,6 +1466,7 @@ var EditorCanvas = forwardRef(
|
|
|
1486
1466
|
onBatchModify(fObj, canvas);
|
|
1487
1467
|
} else {
|
|
1488
1468
|
vmmlConverterRef.current.updateClip(fObj);
|
|
1469
|
+
updateVmml((_a = vmmlConverterRef.current) == null ? void 0 : _a.vmml);
|
|
1489
1470
|
}
|
|
1490
1471
|
});
|
|
1491
1472
|
resolve(group);
|
|
@@ -2598,12 +2579,12 @@ var EditorFn = ({
|
|
|
2598
2579
|
}
|
|
2599
2580
|
};
|
|
2600
2581
|
const onControlsClick = () => {
|
|
2601
|
-
setPreviewState(true);
|
|
2602
2582
|
if (previewState) {
|
|
2603
2583
|
const { current } = vmmlPlayerRef;
|
|
2604
2584
|
current.unmute();
|
|
2605
2585
|
current.play();
|
|
2606
2586
|
} else {
|
|
2587
|
+
setPreviewState(true);
|
|
2607
2588
|
setMenuState("");
|
|
2608
2589
|
}
|
|
2609
2590
|
};
|
|
@@ -2976,6 +2957,14 @@ var EditorFn = ({
|
|
|
2976
2957
|
}
|
|
2977
2958
|
return {};
|
|
2978
2959
|
}, [loading]);
|
|
2960
|
+
const updateVmml = (vmml) => {
|
|
2961
|
+
var _a2, _b;
|
|
2962
|
+
const { current } = vmmlPlayerRef;
|
|
2963
|
+
if (!current) return;
|
|
2964
|
+
const playing = ((_b = (_a2 = current == null ? void 0 : current.playerRef) == null ? void 0 : _a2.isPlaying) == null ? void 0 : _b.call(_a2)) ?? false;
|
|
2965
|
+
if (!playing) needPlay.current = false;
|
|
2966
|
+
current.setVmml(vmml, frame, false);
|
|
2967
|
+
};
|
|
2979
2968
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2980
2969
|
/* @__PURE__ */ jsxs("div", { className: "editor", style: { height }, children: [
|
|
2981
2970
|
/* @__PURE__ */ jsx("div", { className: "editor-vessel", onClick: () => {
|
|
@@ -3015,7 +3004,8 @@ var EditorFn = ({
|
|
|
3015
3004
|
onVideoChange,
|
|
3016
3005
|
isBatchModify,
|
|
3017
3006
|
hideConfig,
|
|
3018
|
-
textWarapCenter
|
|
3007
|
+
textWarapCenter,
|
|
3008
|
+
updateVmml
|
|
3019
3009
|
}
|
|
3020
3010
|
),
|
|
3021
3011
|
/* @__PURE__ */ jsx(Loading_default, { show: loading })
|