@versa_ai/vmml-editor 1.0.32 → 1.0.34
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 +33 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/EditorCanvas.tsx +37 -11
- package/src/index.tsx +12 -19
package/dist/index.mjs
CHANGED
|
@@ -1053,6 +1053,7 @@ var EditorCanvas = forwardRef(
|
|
|
1053
1053
|
if (fc) {
|
|
1054
1054
|
const ns = Math.floor((f ?? frame) / 30 * 1e6);
|
|
1055
1055
|
const objects = fc.getObjects();
|
|
1056
|
+
console.log(objects, "checkObjectInPoint>>>objects>>>>>>>>>>>", ns, f, frame);
|
|
1056
1057
|
objects.forEach((item) => {
|
|
1057
1058
|
var _a, _b, _c;
|
|
1058
1059
|
if (((_a = item == null ? void 0 : item.clipData) == null ? void 0 : _a.type) === "\u6587\u5B57") {
|
|
@@ -1439,6 +1440,25 @@ var EditorCanvas = forwardRef(
|
|
|
1439
1440
|
return null;
|
|
1440
1441
|
}
|
|
1441
1442
|
};
|
|
1443
|
+
const setTextAlign = (p, stroke, direction) => {
|
|
1444
|
+
if (direction === "center") {
|
|
1445
|
+
p.style.justifyContent = "center";
|
|
1446
|
+
stroke.style.left = "50%";
|
|
1447
|
+
stroke.style.top = "50%";
|
|
1448
|
+
stroke.style.transform = "translate(-50%, -50%)";
|
|
1449
|
+
}
|
|
1450
|
+
if (direction === "left") {
|
|
1451
|
+
stroke.style.left = "0";
|
|
1452
|
+
stroke.style.top = "0";
|
|
1453
|
+
stroke.style.transform = "none";
|
|
1454
|
+
}
|
|
1455
|
+
if (direction === "right") {
|
|
1456
|
+
p.style.justifyContent = "flex-end";
|
|
1457
|
+
stroke.style.right = "0";
|
|
1458
|
+
stroke.style.top = "50%";
|
|
1459
|
+
stroke.style.transform = "translateY(-50%)";
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1442
1462
|
const createTextImg = async ({ textContent, bgColor, textColor, stColor, strokeW, fontAssetUrl = null, textBasicInfo, letterSpacing }) => {
|
|
1443
1463
|
const fontBase64 = await loadFont(fontAssetUrl);
|
|
1444
1464
|
const container = document.createElement("div");
|
|
@@ -1460,7 +1480,6 @@ var EditorCanvas = forwardRef(
|
|
|
1460
1480
|
p.style.padding = "0";
|
|
1461
1481
|
if (letterSpacing) p.style.letterSpacing = `${letterSpacing}px`;
|
|
1462
1482
|
p.style.zIndex = "2";
|
|
1463
|
-
if (textWarapCenter) p.style.justifyContent = "center";
|
|
1464
1483
|
const fill = document.createElement("span");
|
|
1465
1484
|
fill.textContent = line || " ";
|
|
1466
1485
|
fill.style.color = textColor;
|
|
@@ -1472,15 +1491,9 @@ var EditorCanvas = forwardRef(
|
|
|
1472
1491
|
stroke.style.color = "transparent";
|
|
1473
1492
|
stroke.style.webkitTextStrokeWidth = `${strokeW}px`;
|
|
1474
1493
|
stroke.style.webkitTextStrokeColor = stColor;
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
stroke.style.transform = "translate(-50%, -50%)";
|
|
1479
|
-
} else {
|
|
1480
|
-
stroke.style.left = "0";
|
|
1481
|
-
stroke.style.top = "0";
|
|
1482
|
-
}
|
|
1483
|
-
stroke.style.zIndex = "-1";
|
|
1494
|
+
let dr = textBasicInfo.textAlign || "left";
|
|
1495
|
+
if (textWarapCenter) dr = "center";
|
|
1496
|
+
setTextAlign(p, stroke, dr);
|
|
1484
1497
|
p.appendChild(fill);
|
|
1485
1498
|
p.appendChild(stroke);
|
|
1486
1499
|
container.appendChild(p);
|
|
@@ -2760,24 +2773,24 @@ var EditorFn = ({
|
|
|
2760
2773
|
}
|
|
2761
2774
|
}, [dragState]);
|
|
2762
2775
|
const updateEditor = (v, checkFrame) => {
|
|
2763
|
-
var _a2, _b, _c, _d;
|
|
2776
|
+
var _a2, _b, _c, _d, _e;
|
|
2764
2777
|
const { current: playerCurrent } = vmmlPlayerRef;
|
|
2765
2778
|
const { current: canvasCurrent } = canvasRef;
|
|
2766
2779
|
if (!playerCurrent) return;
|
|
2767
|
-
const isSame = JSON.stringify(v) === JSON.stringify(vmmlState);
|
|
2768
|
-
console.log(v, vmmlState, isSame, "\u5224\u65ADvmml\u662F\u5426\u76F8\u540C");
|
|
2769
2780
|
needPlay.current = false;
|
|
2770
2781
|
once.current = false;
|
|
2771
2782
|
const convertedVmml = convertVmmlTextScaleByForbidden(v);
|
|
2783
|
+
const isSame = JSON.stringify(convertedVmml) === JSON.stringify(vmmlState);
|
|
2784
|
+
const currentFrame = checkFrame ?? (((_a2 = player == null ? void 0 : player.getCurrentFrame) == null ? void 0 : _a2.call(player)) ?? frame ?? pauseFrame);
|
|
2785
|
+
setFrame(currentFrame);
|
|
2786
|
+
playerCurrent.setVmml(convertedVmml, currentFrame);
|
|
2772
2787
|
if (!isSame) {
|
|
2773
|
-
(
|
|
2788
|
+
(_c = (_b = canvasCurrent == null ? void 0 : canvasCurrent.getCanvasCtx()) == null ? void 0 : _b.clear) == null ? void 0 : _c.call(_b);
|
|
2774
2789
|
setVmmlState(convertedVmml);
|
|
2775
|
-
setDurationInFrames(getFrames(((
|
|
2776
|
-
|
|
2790
|
+
setDurationInFrames(getFrames(((_d = convertedVmml == null ? void 0 : convertedVmml.template) == null ? void 0 : _d.duration) || 1, fps));
|
|
2791
|
+
} else {
|
|
2792
|
+
(_e = canvasCurrent == null ? void 0 : canvasCurrent.checkObjectInPoint) == null ? void 0 : _e.call(canvasCurrent, currentFrame);
|
|
2777
2793
|
}
|
|
2778
|
-
const currentFrame = checkFrame ?? pauseFrame;
|
|
2779
|
-
playerCurrent.setVmml(convertedVmml, currentFrame);
|
|
2780
|
-
(_d = canvasCurrent == null ? void 0 : canvasCurrent.checkObjectInPoint) == null ? void 0 : _d.call(canvasCurrent, currentFrame);
|
|
2781
2794
|
};
|
|
2782
2795
|
const getCurrentFrame = () => {
|
|
2783
2796
|
if (!player) return 0;
|
|
@@ -2786,6 +2799,7 @@ var EditorFn = ({
|
|
|
2786
2799
|
const editorSeekTo = (frame2) => {
|
|
2787
2800
|
var _a2;
|
|
2788
2801
|
(_a2 = player == null ? void 0 : player.seekTo) == null ? void 0 : _a2.call(player, frame2 ?? 0);
|
|
2802
|
+
setFrame(frame2 ?? 0);
|
|
2789
2803
|
const { current: canvasCurrent } = canvasRef;
|
|
2790
2804
|
if (canvasCurrent) {
|
|
2791
2805
|
canvasCurrent.checkObjectInPoint(frame2);
|