@versa_ai/vmml-editor 1.0.16 → 1.0.18
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 +37 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/EditorCanvas.tsx +32 -33
- package/src/index.tsx +8 -3
- package/src/utils/VmmlConverter.ts +16 -3
package/dist/index.mjs
CHANGED
|
@@ -575,8 +575,9 @@ var VmmlConverter = class {
|
|
|
575
575
|
}
|
|
576
576
|
//更新位置
|
|
577
577
|
setPosParam(fObj) {
|
|
578
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
578
579
|
const {
|
|
579
|
-
clipData: { type },
|
|
580
|
+
clipData: { type, originClip },
|
|
580
581
|
centerPoint,
|
|
581
582
|
scaleX,
|
|
582
583
|
scaleY,
|
|
@@ -584,24 +585,35 @@ var VmmlConverter = class {
|
|
|
584
585
|
width,
|
|
585
586
|
height
|
|
586
587
|
} = fObj;
|
|
587
|
-
let _scaleX, _scaleY, _centerX, _centerY;
|
|
588
|
+
let _scaleX, _scaleY, _centerX, _centerY, _scaleZ, _centerZ, _rotationX, _rotationY;
|
|
589
|
+
let key = "";
|
|
588
590
|
if (type === "\u6587\u5B57") {
|
|
589
591
|
_scaleX = 22 * scaleX * this.widthScale / this.fontSize;
|
|
590
592
|
_scaleY = 22 * scaleY * this.heightScale / this.fontSize;
|
|
591
593
|
_centerX = centerPoint.x / this.canvasSize.width;
|
|
592
594
|
_centerY = centerPoint.y / this.canvasSize.height;
|
|
595
|
+
key = "textClip";
|
|
593
596
|
} else if (type === "\u8868\u60C5\u5305") {
|
|
594
597
|
_scaleX = width * scaleX * this.widthScale / width;
|
|
595
598
|
_scaleY = height * scaleY * this.heightScale / height;
|
|
596
599
|
_centerX = centerPoint.x / this.canvasSize.width;
|
|
597
600
|
_centerY = centerPoint.y / this.canvasSize.height;
|
|
601
|
+
key = "videoClip";
|
|
598
602
|
}
|
|
603
|
+
_scaleZ = ((_b = (_a = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _a.posParam) == null ? void 0 : _b.scaleZ) ?? 1;
|
|
604
|
+
_centerZ = ((_d = (_c = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _c.posParam) == null ? void 0 : _d.centerZ) ?? 0.5;
|
|
605
|
+
_rotationX = ((_f = (_e = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _e.posParam) == null ? void 0 : _f.rotationX) ?? 0;
|
|
606
|
+
_rotationY = ((_h = (_g = originClip == null ? void 0 : originClip[key]) == null ? void 0 : _g.posParam) == null ? void 0 : _h.rotationY) ?? 0;
|
|
599
607
|
return {
|
|
600
608
|
scaleX: _scaleX,
|
|
601
609
|
scaleY: _scaleY,
|
|
610
|
+
scaleZ: _scaleZ,
|
|
602
611
|
centerX: _centerX,
|
|
603
612
|
centerY: _centerY,
|
|
604
|
-
|
|
613
|
+
centerZ: _centerZ,
|
|
614
|
+
rotationZ: angle,
|
|
615
|
+
rotationX: _rotationX,
|
|
616
|
+
rotationY: _rotationY
|
|
605
617
|
};
|
|
606
618
|
}
|
|
607
619
|
/**
|
|
@@ -1195,15 +1207,6 @@ var EditorCanvas = forwardRef(
|
|
|
1195
1207
|
}
|
|
1196
1208
|
};
|
|
1197
1209
|
const createEditObjes = async (canvas, time) => {
|
|
1198
|
-
const allObjects = canvas.getObjects();
|
|
1199
|
-
const toRemove = [];
|
|
1200
|
-
allObjects.forEach((obj) => {
|
|
1201
|
-
var _a;
|
|
1202
|
-
if ((_a = obj == null ? void 0 : obj.clipData) == null ? void 0 : _a.originClip) {
|
|
1203
|
-
toRemove.push(obj);
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
toRemove.forEach((obj) => canvas.remove(obj));
|
|
1207
1210
|
const promises = editClips.map((clip) => {
|
|
1208
1211
|
if (clip.videoClip) {
|
|
1209
1212
|
return createImageFromClip(clip);
|
|
@@ -1315,12 +1318,14 @@ var EditorCanvas = forwardRef(
|
|
|
1315
1318
|
}
|
|
1316
1319
|
const { width, height } = vmml.template.dimension;
|
|
1317
1320
|
const fontSize = getFontSize(width, height);
|
|
1318
|
-
const { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType } = clip.textClip;
|
|
1321
|
+
const { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType, strokeColor, strokeWidth } = clip.textClip;
|
|
1319
1322
|
const scaleX = posParam.scaleX * fontSize / 22 / widthScaleRef.current;
|
|
1320
1323
|
const scaleY = posParam.scaleY * fontSize / 22 / heightScaleRef.current;
|
|
1324
|
+
const strokeW = strokeWidth ? strokeWidth * 22 / fontSize : 0;
|
|
1321
1325
|
const left = canvasSize.width * posParam.centerX;
|
|
1322
1326
|
const top = canvasSize.height * posParam.centerY;
|
|
1323
1327
|
const bgColor = backgroundColor ? argbToRgba(backgroundColor) : "transparent";
|
|
1328
|
+
const stColor = strokeColor ? argbToRgba(strokeColor) : "transparent";
|
|
1324
1329
|
const isAiError = textContent === "\u8BF7\u8F93\u5165\u6587\u6848" && textColor === "#00000000";
|
|
1325
1330
|
const textFill = argbToRgba(isAiError ? "#ffffffff" : textColor || "#ffffffff");
|
|
1326
1331
|
const textBasicInfo = {
|
|
@@ -1329,7 +1334,7 @@ var EditorCanvas = forwardRef(
|
|
|
1329
1334
|
colorName: "custom",
|
|
1330
1335
|
textAlign: alignType === 1 ? "center" : alignType === 2 ? "right" : "left"
|
|
1331
1336
|
};
|
|
1332
|
-
const textImgData = await createTextImg({ textContent, bgColor, textColor: textFill, fontAssetUrl, textBasicInfo });
|
|
1337
|
+
const textImgData = await createTextImg({ textContent, bgColor, stColor, strokeW, textColor: textFill, fontAssetUrl, textBasicInfo });
|
|
1333
1338
|
const fontJSON = localStorage.getItem("VMML_PLAYER_FONTSMAP");
|
|
1334
1339
|
let fontMap = {};
|
|
1335
1340
|
try {
|
|
@@ -1417,7 +1422,7 @@ var EditorCanvas = forwardRef(
|
|
|
1417
1422
|
}
|
|
1418
1423
|
return svgString;
|
|
1419
1424
|
};
|
|
1420
|
-
const createTextImg = async ({ textContent, bgColor, textColor, fontAssetUrl = null, textBasicInfo }) => {
|
|
1425
|
+
const createTextImg = async ({ textContent, bgColor, textColor, stColor, strokeW, fontAssetUrl = null, textBasicInfo }) => {
|
|
1421
1426
|
const container = document.createElement("div");
|
|
1422
1427
|
container.style.backgroundColor = bgColor;
|
|
1423
1428
|
container.style.boxSizing = "content-box";
|
|
@@ -1433,6 +1438,9 @@ var EditorCanvas = forwardRef(
|
|
|
1433
1438
|
p.style.fontFamily = fontFamily;
|
|
1434
1439
|
p.style.whiteSpace = "nowrap";
|
|
1435
1440
|
p.style.padding = "0";
|
|
1441
|
+
p.style.margin = "0";
|
|
1442
|
+
p.style.webkitTextStrokeWidth = `${strokeW ?? 0}px`;
|
|
1443
|
+
p.style.webkitTextStrokeColor = stColor;
|
|
1436
1444
|
p.textContent = line || " ";
|
|
1437
1445
|
container.appendChild(p);
|
|
1438
1446
|
});
|
|
@@ -1579,6 +1587,9 @@ var EditorCanvas = forwardRef(
|
|
|
1579
1587
|
}
|
|
1580
1588
|
}
|
|
1581
1589
|
}, [fc]);
|
|
1590
|
+
const getCanvasCtx = () => {
|
|
1591
|
+
return fc;
|
|
1592
|
+
};
|
|
1582
1593
|
useImperativeHandle(ref, () => ({
|
|
1583
1594
|
createImage,
|
|
1584
1595
|
createText,
|
|
@@ -1592,8 +1603,9 @@ var EditorCanvas = forwardRef(
|
|
|
1592
1603
|
checkObjectInPoint,
|
|
1593
1604
|
createImageFromClip,
|
|
1594
1605
|
createTextFromClip,
|
|
1595
|
-
changeObjectVisible
|
|
1596
|
-
|
|
1606
|
+
changeObjectVisible,
|
|
1607
|
+
getCanvasCtx
|
|
1608
|
+
}), [fc]);
|
|
1597
1609
|
const getActions = () => {
|
|
1598
1610
|
if (history) {
|
|
1599
1611
|
return history.getActionType();
|
|
@@ -2417,10 +2429,12 @@ var EditorFn = ({
|
|
|
2417
2429
|
const onPlayerReady = () => {
|
|
2418
2430
|
const { current } = vmmlPlayerRef;
|
|
2419
2431
|
vmmlFlag.current = false;
|
|
2432
|
+
let show = false;
|
|
2420
2433
|
if (current && current.playerRef) {
|
|
2421
2434
|
setPlayer(current.playerRef);
|
|
2422
2435
|
current.unmute();
|
|
2423
2436
|
if (!once.current) {
|
|
2437
|
+
show = true;
|
|
2424
2438
|
once.current = true;
|
|
2425
2439
|
} else {
|
|
2426
2440
|
if (needPlay.current) {
|
|
@@ -2430,7 +2444,7 @@ var EditorFn = ({
|
|
|
2430
2444
|
}
|
|
2431
2445
|
}
|
|
2432
2446
|
}
|
|
2433
|
-
setShowCanvas(
|
|
2447
|
+
setShowCanvas(show);
|
|
2434
2448
|
setLoading(false);
|
|
2435
2449
|
};
|
|
2436
2450
|
const onClickMain = () => {
|
|
@@ -2571,9 +2585,11 @@ var EditorFn = ({
|
|
|
2571
2585
|
setFrame(e.detail.frame);
|
|
2572
2586
|
};
|
|
2573
2587
|
const onPlay = () => {
|
|
2588
|
+
setShowCanvas(false);
|
|
2574
2589
|
setIsPlaying(true);
|
|
2575
2590
|
};
|
|
2576
2591
|
const onPause = () => {
|
|
2592
|
+
setShowCanvas(true);
|
|
2577
2593
|
setIsPlaying(false);
|
|
2578
2594
|
};
|
|
2579
2595
|
const onWaiting = () => {
|
|
@@ -2711,13 +2727,14 @@ var EditorFn = ({
|
|
|
2711
2727
|
}
|
|
2712
2728
|
}, [dragState]);
|
|
2713
2729
|
const updateVmml = (v) => {
|
|
2714
|
-
var _a2;
|
|
2730
|
+
var _a2, _b, _c;
|
|
2715
2731
|
const { current: playerCurrent } = vmmlPlayerRef;
|
|
2716
2732
|
const { current: canvasCurrent } = canvasRef;
|
|
2717
2733
|
if (!playerCurrent) return;
|
|
2734
|
+
(_b = (_a2 = canvasCurrent == null ? void 0 : canvasCurrent.getCanvasCtx()) == null ? void 0 : _a2.clear) == null ? void 0 : _b.call(_a2);
|
|
2718
2735
|
const convertedVmml = convertVmmlTextScaleByForbidden(v);
|
|
2719
2736
|
setVmmlState(convertedVmml);
|
|
2720
|
-
setDurationInFrames(getFrames(((
|
|
2737
|
+
setDurationInFrames(getFrames(((_c = v == null ? void 0 : v.template) == null ? void 0 : _c.duration) || 1, fps));
|
|
2721
2738
|
playerCurrent.setVmml(convertedVmml, pauseFrame);
|
|
2722
2739
|
setRefreshEdit(Date.now());
|
|
2723
2740
|
if (canvasCurrent) {
|