@versa_ai/vmml-editor 1.0.40 → 1.0.42
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 +8 -8
- package/dist/index.js +165 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -182
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/EditorCanvas.tsx +387 -449
- package/src/index.tsx +6 -2
- package/src/utils/VmmlConverter.ts +46 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @versa_ai/vmml-editor@1.0.
|
|
2
|
+
> @versa_ai/vmml-editor@1.0.42 build D:\code\work\vmml-player\packages\editor
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
|
@@ -124,12 +124,12 @@ More info and automated migrator: https://sass-lang.com/d/slash-div[0m [1m[35
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
[34mDTS[39m Build start
|
|
127
|
-
[32mESM[39m [1mdist\index.mjs [22m[
|
|
128
|
-
[32mESM[39m [1mdist\index.mjs.map [22m[
|
|
129
|
-
[32mESM[39m ⚡️ Build success in
|
|
130
|
-
[32mCJS[39m [1mdist\index.js [22m[
|
|
131
|
-
[32mCJS[39m [1mdist\index.js.map [22m[
|
|
132
|
-
[32mCJS[39m ⚡️ Build success in
|
|
133
|
-
[32mDTS[39m ⚡️ Build success in
|
|
127
|
+
[32mESM[39m [1mdist\index.mjs [22m[32m119.77 KB[39m
|
|
128
|
+
[32mESM[39m [1mdist\index.mjs.map [22m[32m233.03 KB[39m
|
|
129
|
+
[32mESM[39m ⚡️ Build success in 786ms
|
|
130
|
+
[32mCJS[39m [1mdist\index.js [22m[32m121.41 KB[39m
|
|
131
|
+
[32mCJS[39m [1mdist\index.js.map [22m[32m233.32 KB[39m
|
|
132
|
+
[32mCJS[39m ⚡️ Build success in 787ms
|
|
133
|
+
[32mDTS[39m ⚡️ Build success in 2403ms
|
|
134
134
|
[32mDTS[39m [1mdist\index.d.ts [22m[32m158.00 B[39m
|
|
135
135
|
[32mDTS[39m [1mdist\index.d.mts [22m[32m158.00 B[39m
|
package/dist/index.js
CHANGED
|
@@ -617,6 +617,20 @@ var VmmlConverter = class {
|
|
|
617
617
|
rotationY: _rotationY
|
|
618
618
|
};
|
|
619
619
|
}
|
|
620
|
+
findClip(id) {
|
|
621
|
+
const tracks = this.vmml.template.tracks || [];
|
|
622
|
+
const isString = typeof id === "string";
|
|
623
|
+
const ids = isString ? [id] : id;
|
|
624
|
+
const list = [];
|
|
625
|
+
tracks.forEach((track) => {
|
|
626
|
+
track.clips.forEach((clip) => {
|
|
627
|
+
if (ids == null ? void 0 : ids.includes(clip.id)) {
|
|
628
|
+
list.push(clip);
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
return list;
|
|
633
|
+
}
|
|
620
634
|
/**
|
|
621
635
|
* 转换 TextClip
|
|
622
636
|
* @param fObj - 画布fObj
|
|
@@ -624,6 +638,7 @@ var VmmlConverter = class {
|
|
|
624
638
|
addTextClip(fObj) {
|
|
625
639
|
console.log("addTextClip fObj", fObj);
|
|
626
640
|
const posParam = this.setPosParam(fObj);
|
|
641
|
+
console.log(fObj, "fObj>>>>");
|
|
627
642
|
const { clipData: { id, inPoint, text, textColor, bgColor } } = fObj;
|
|
628
643
|
const { template: { duration } } = this.vmml;
|
|
629
644
|
const clips = [];
|
|
@@ -714,19 +729,7 @@ var VmmlConverter = class {
|
|
|
714
729
|
const {
|
|
715
730
|
clipData: { id, type, lineSpacing, originClip }
|
|
716
731
|
} = fObj;
|
|
717
|
-
|
|
718
|
-
if (originClip) {
|
|
719
|
-
for (const track of this.tracks) {
|
|
720
|
-
const clip = (track.clips || []).find((c) => c.id === originClip.id);
|
|
721
|
-
if (clip) {
|
|
722
|
-
existClip = clip;
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
} else {
|
|
727
|
-
const editorTrack = this.tracks.find((track) => track.editorType === type);
|
|
728
|
-
existClip = ((editorTrack == null ? void 0 : editorTrack.clips) || []).find((clip) => clip.id === id);
|
|
729
|
-
}
|
|
732
|
+
const [existClip] = this.findClip(id);
|
|
730
733
|
if (existClip) {
|
|
731
734
|
!originClip && (existClip.fObj = fObj);
|
|
732
735
|
if (type === "\u8868\u60C5\u5305") {
|
|
@@ -748,6 +751,32 @@ var VmmlConverter = class {
|
|
|
748
751
|
}
|
|
749
752
|
}
|
|
750
753
|
}
|
|
754
|
+
updateTextClip(fObj, duration) {
|
|
755
|
+
console.log("updateClip fObj", fObj, this.tracks);
|
|
756
|
+
const posParam = this.setPosParam(fObj);
|
|
757
|
+
const {
|
|
758
|
+
clipData: { id }
|
|
759
|
+
} = fObj;
|
|
760
|
+
const [existClip] = this.findClip(id);
|
|
761
|
+
if (existClip) {
|
|
762
|
+
const { clipData: { text, textColor, bgColor } } = fObj;
|
|
763
|
+
const scale = this.fontSize / 22;
|
|
764
|
+
existClip.duration = duration;
|
|
765
|
+
console.log(bgColor, "bgColor>>>");
|
|
766
|
+
existClip.textClip = {
|
|
767
|
+
...existClip.textClip,
|
|
768
|
+
posParam,
|
|
769
|
+
backgroundColor: this.toARGB(bgColor),
|
|
770
|
+
textContent: text,
|
|
771
|
+
textColor: this.toARGB(textColor),
|
|
772
|
+
dimension: {
|
|
773
|
+
width: Math.floor(fObj.width * scale),
|
|
774
|
+
height: Math.floor(fObj.height * scale)
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
console.log(this.vmml, "updateText>>>");
|
|
779
|
+
}
|
|
751
780
|
/**
|
|
752
781
|
* 删除 Clip
|
|
753
782
|
* @param id - 实例 id
|
|
@@ -779,9 +808,11 @@ var VmmlConverter = class {
|
|
|
779
808
|
}
|
|
780
809
|
}
|
|
781
810
|
}
|
|
811
|
+
console.log("\u5220\u9664\u4E4B\u540E\u7684vmml", this.vmml);
|
|
782
812
|
}
|
|
783
813
|
changeVmml(newVmml) {
|
|
784
814
|
this.vmml = newVmml;
|
|
815
|
+
this.tracks = this.vmml.template.tracks;
|
|
785
816
|
}
|
|
786
817
|
//切换静音 视频/音频
|
|
787
818
|
changeMute({ id, isMute }) {
|
|
@@ -1069,11 +1100,11 @@ var EditorCanvas = react.forwardRef(
|
|
|
1069
1100
|
const ns = Math.floor((f ?? frame) / 30 * 1e6);
|
|
1070
1101
|
const objects = fc.getObjects();
|
|
1071
1102
|
objects.forEach((item) => {
|
|
1072
|
-
var _a, _b, _c;
|
|
1103
|
+
var _a, _b, _c, _d, _e;
|
|
1073
1104
|
if (((_a = item == null ? void 0 : item.clipData) == null ? void 0 : _a.type) === "\u6587\u5B57") {
|
|
1074
1105
|
item.set("visible", item.clipData.duration > 0 && ns >= item.clipData.inPoint && ns < item.clipData.inPoint + (item.clipData.duration || vmml.template.duration));
|
|
1075
1106
|
} else {
|
|
1076
|
-
item.set("visible", item.clipData.duration > 0 && ns >= item.clipData.inPoint && ns < item.clipData.inPoint + ((
|
|
1107
|
+
item.set("visible", ((_c = (_b = item == null ? void 0 : item.clipData) == null ? void 0 : _b.fileUrl) == null ? void 0 : _c.duration) > 0 && ns >= item.clipData.inPoint && ns < item.clipData.inPoint + ((_e = (_d = item.clipData) == null ? void 0 : _d.fileUrl) == null ? void 0 : _e.duration));
|
|
1077
1108
|
}
|
|
1078
1109
|
});
|
|
1079
1110
|
fc.discardActiveObject();
|
|
@@ -1236,7 +1267,6 @@ var EditorCanvas = react.forwardRef(
|
|
|
1236
1267
|
objects.push(item.value);
|
|
1237
1268
|
}
|
|
1238
1269
|
});
|
|
1239
|
-
console.log(editRenderTime.current === time, "editRenderTime.current === time");
|
|
1240
1270
|
if (editRenderTime.current === time) {
|
|
1241
1271
|
canvas.add(...objects).renderAll();
|
|
1242
1272
|
checkObjectInPoint();
|
|
@@ -1325,91 +1355,104 @@ var EditorCanvas = react.forwardRef(
|
|
|
1325
1355
|
});
|
|
1326
1356
|
window.dispatchEvent(event);
|
|
1327
1357
|
};
|
|
1358
|
+
const createTextObjs = async ({ strokeW, stColor, fontAssetUrl = null, letterSpace, bgColor, textContent, textBasicInfo, textColor }) => {
|
|
1359
|
+
let fontFamily = "sansMedium";
|
|
1360
|
+
if (fontAssetUrl) {
|
|
1361
|
+
const base64 = await loadFont(fontAssetUrl);
|
|
1362
|
+
if (base64) {
|
|
1363
|
+
fontFamily = getFontFamilyName(fontAssetUrl);
|
|
1364
|
+
await document.fonts.ready;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
const lines = textContent.split("\n").filter((item) => item);
|
|
1368
|
+
const lineHeight = 22 + strokeW;
|
|
1369
|
+
const paddingX = 7;
|
|
1370
|
+
const groupWidth = Math.max(...lines.map((l) => {
|
|
1371
|
+
const temp = new fabric.fabric.Text(l || " ", { fontSize: 22, fontFamily, charSpacing: letterSpace, strokeWidth: strokeW ?? 0 });
|
|
1372
|
+
return (temp == null ? void 0 : temp.width) ?? 0;
|
|
1373
|
+
})) + paddingX * 2;
|
|
1374
|
+
const groupHeight = lines.length * lineHeight;
|
|
1375
|
+
const textObjs = [];
|
|
1376
|
+
lines.forEach((line, idx) => {
|
|
1377
|
+
const y = -groupHeight / 2 + lineHeight / 2 + idx * lineHeight;
|
|
1378
|
+
let originX = "left";
|
|
1379
|
+
let left = paddingX;
|
|
1380
|
+
if (textBasicInfo.textAlign === "center") {
|
|
1381
|
+
originX = "center";
|
|
1382
|
+
left = 0;
|
|
1383
|
+
} else if (textBasicInfo.textAlign === "right") {
|
|
1384
|
+
originX = "right";
|
|
1385
|
+
left = groupWidth - paddingX;
|
|
1386
|
+
}
|
|
1387
|
+
const strokeText = new fabric.fabric.Text(line || " ", {
|
|
1388
|
+
fontFamily,
|
|
1389
|
+
fontSize: 22,
|
|
1390
|
+
fill: "transparent",
|
|
1391
|
+
stroke: stColor,
|
|
1392
|
+
strokeWidth: strokeW,
|
|
1393
|
+
originX,
|
|
1394
|
+
originY: "center",
|
|
1395
|
+
left,
|
|
1396
|
+
top: y,
|
|
1397
|
+
charSpacing: letterSpace,
|
|
1398
|
+
textAlign: "left",
|
|
1399
|
+
objectCaching: false
|
|
1400
|
+
});
|
|
1401
|
+
const fillText = new fabric.fabric.Text(line || " ", {
|
|
1402
|
+
fontFamily,
|
|
1403
|
+
fontSize: 22,
|
|
1404
|
+
fill: textColor,
|
|
1405
|
+
stroke: "transparent",
|
|
1406
|
+
originX,
|
|
1407
|
+
originY: "center",
|
|
1408
|
+
strokeWidth: 0,
|
|
1409
|
+
left,
|
|
1410
|
+
top: y,
|
|
1411
|
+
charSpacing: letterSpace,
|
|
1412
|
+
textAlign: "left",
|
|
1413
|
+
objectCaching: false
|
|
1414
|
+
});
|
|
1415
|
+
textObjs.push(strokeText, fillText);
|
|
1416
|
+
});
|
|
1417
|
+
const bgRect = new fabric.fabric.Rect({
|
|
1418
|
+
width: groupWidth,
|
|
1419
|
+
height: groupHeight + 13,
|
|
1420
|
+
// padddingY: 6.5
|
|
1421
|
+
fill: bgColor,
|
|
1422
|
+
originX: "center",
|
|
1423
|
+
originY: "center",
|
|
1424
|
+
rx: 5,
|
|
1425
|
+
ry: 5
|
|
1426
|
+
});
|
|
1427
|
+
return {
|
|
1428
|
+
objects: [bgRect, ...textObjs],
|
|
1429
|
+
fontFamily
|
|
1430
|
+
};
|
|
1431
|
+
};
|
|
1328
1432
|
const createTextFromClipCanvas = async (clip, fc2) => {
|
|
1329
1433
|
return new Promise(async (resolve) => {
|
|
1330
1434
|
const canvas = fc || fc2;
|
|
1331
1435
|
if (!canvas) return null;
|
|
1332
1436
|
const { width, height } = vmml.template.dimension;
|
|
1333
1437
|
const fontSize = vmmlUtils.getFontSize(width, height);
|
|
1334
|
-
|
|
1438
|
+
let { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType, strokeColor, strokeWidth, letterSpacing } = clip.textClip;
|
|
1335
1439
|
const scaleX = posParam.scaleX * fontSize / 22 / widthScaleRef.current;
|
|
1336
1440
|
const scaleY = posParam.scaleY * fontSize / 22 / heightScaleRef.current;
|
|
1337
1441
|
const left = canvasSize.width * posParam.centerX;
|
|
1338
1442
|
const top = canvasSize.height * posParam.centerY;
|
|
1339
1443
|
const bgColor = backgroundColor ? vmmlUtils.argbToRgba(backgroundColor) : "transparent";
|
|
1444
|
+
const strokeW = strokeColor && strokeWidth ? strokeWidth * 30 * 1.5 / fontSize : 0;
|
|
1340
1445
|
const stColor = strokeColor ? vmmlUtils.argbToRgba(strokeColor) : "transparent";
|
|
1446
|
+
const letterSpace = letterSpacing * 22 / fontSize * 45;
|
|
1341
1447
|
const textFill = vmmlUtils.argbToRgba(textColor || "#ffffffff");
|
|
1342
|
-
const strokeW = strokeColor && strokeWidth ? strokeWidth * 26 * 1.5 / fontSize : 0;
|
|
1343
|
-
const letterSpace = letterSpacing * 22 / fontSize;
|
|
1344
|
-
let fontFamily = "sansMedium";
|
|
1345
|
-
if (fontAssetUrl) {
|
|
1346
|
-
const base64 = await loadFont(fontAssetUrl);
|
|
1347
|
-
if (base64) {
|
|
1348
|
-
fontFamily = getFontFamilyName(fontAssetUrl);
|
|
1349
|
-
await document.fonts.ready;
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
const lines = textContent.split("\n").filter((item) => item);
|
|
1353
|
-
const lineHeight = 22 + strokeW;
|
|
1354
|
-
const textHeight = lines.length * lineHeight;
|
|
1355
|
-
const groupWidth = Math.max(...lines.map((l) => {
|
|
1356
|
-
const temp = new fabric.fabric.Text(l || " ", { fontSize: 22, fontFamily, charSpacing: (letterSpace || 0) * 50, strokeWidth: strokeW ?? 0 });
|
|
1357
|
-
return (temp == null ? void 0 : temp.width) ?? 0;
|
|
1358
|
-
})) + 14;
|
|
1359
|
-
const groupHeight = textHeight + 13;
|
|
1360
|
-
const textObjs = [];
|
|
1361
|
-
lines.forEach((line, idx) => {
|
|
1362
|
-
const y = (groupHeight - textHeight) / 2 + idx * lineHeight + lineHeight / 2 + 1;
|
|
1363
|
-
const strokeText = new fabric.fabric.Text(line || " ", {
|
|
1364
|
-
fontFamily,
|
|
1365
|
-
fontSize: 22,
|
|
1366
|
-
fill: "transparent",
|
|
1367
|
-
stroke: stColor,
|
|
1368
|
-
strokeWidth: strokeW,
|
|
1369
|
-
originX: "center",
|
|
1370
|
-
originY: "center",
|
|
1371
|
-
left: groupWidth / 2,
|
|
1372
|
-
// 水平居中
|
|
1373
|
-
top: y,
|
|
1374
|
-
charSpacing: (letterSpace || 0) * 50,
|
|
1375
|
-
textAlign: alignType === 1 ? "center" : alignType === 2 ? "right" : "left",
|
|
1376
|
-
objectCaching: false
|
|
1377
|
-
});
|
|
1378
|
-
const fillText = new fabric.fabric.Text(line || " ", {
|
|
1379
|
-
fontFamily,
|
|
1380
|
-
fontSize: 22,
|
|
1381
|
-
fill: textFill,
|
|
1382
|
-
stroke: "transparent",
|
|
1383
|
-
originX: "center",
|
|
1384
|
-
originY: "center",
|
|
1385
|
-
strokeWidth: 0,
|
|
1386
|
-
left: groupWidth / 2,
|
|
1387
|
-
// 水平居中
|
|
1388
|
-
top: y,
|
|
1389
|
-
charSpacing: (letterSpace || 0) * 50,
|
|
1390
|
-
textAlign: alignType === 1 ? "center" : alignType === 2 ? "right" : "left",
|
|
1391
|
-
objectCaching: false
|
|
1392
|
-
});
|
|
1393
|
-
textObjs.push(strokeText, fillText);
|
|
1394
|
-
});
|
|
1395
|
-
const bgRect = new fabric.fabric.Rect({
|
|
1396
|
-
width: groupWidth,
|
|
1397
|
-
height: groupHeight,
|
|
1398
|
-
fill: bgColor,
|
|
1399
|
-
originX: "left",
|
|
1400
|
-
originY: "top",
|
|
1401
|
-
rx: 5,
|
|
1402
|
-
ry: 5,
|
|
1403
|
-
left: 0,
|
|
1404
|
-
top: 0
|
|
1405
|
-
});
|
|
1406
1448
|
const textBasicInfo = {
|
|
1407
1449
|
isBack: backgroundColor ? true : false,
|
|
1408
1450
|
colorValue: textFill,
|
|
1409
1451
|
colorName: "custom",
|
|
1410
1452
|
textAlign: alignType === 1 ? "center" : alignType === 2 ? "right" : "left"
|
|
1411
1453
|
};
|
|
1412
|
-
const
|
|
1454
|
+
const { fontFamily, objects } = await createTextObjs({ strokeW, stColor, fontAssetUrl, letterSpace, bgColor, textContent, textBasicInfo, textColor: textFill });
|
|
1455
|
+
const group = new fabric.fabric.Group([...objects], {
|
|
1413
1456
|
left,
|
|
1414
1457
|
top,
|
|
1415
1458
|
scaleX,
|
|
@@ -1453,91 +1496,6 @@ var EditorCanvas = react.forwardRef(
|
|
|
1453
1496
|
resolve(group);
|
|
1454
1497
|
});
|
|
1455
1498
|
};
|
|
1456
|
-
const createTextFromClip = async (clip, fc2) => {
|
|
1457
|
-
return new Promise(async (resolve) => {
|
|
1458
|
-
const canvas = fc || fc2;
|
|
1459
|
-
if (!canvas) {
|
|
1460
|
-
resolve(null);
|
|
1461
|
-
return;
|
|
1462
|
-
}
|
|
1463
|
-
const { width, height } = vmml.template.dimension;
|
|
1464
|
-
const fontSize = vmmlUtils.getFontSize(width, height);
|
|
1465
|
-
const { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType, strokeColor, strokeWidth, letterSpacing } = clip.textClip;
|
|
1466
|
-
const scaleX = posParam.scaleX * fontSize / 22 / widthScaleRef.current;
|
|
1467
|
-
const scaleY = posParam.scaleY * fontSize / 22 / heightScaleRef.current;
|
|
1468
|
-
const strokeW = strokeWidth * 26 * 1.5 / fontSize;
|
|
1469
|
-
const letterSpace = letterSpacing * 22 / fontSize;
|
|
1470
|
-
const left = canvasSize.width * posParam.centerX;
|
|
1471
|
-
const top = canvasSize.height * posParam.centerY - 2;
|
|
1472
|
-
const bgColor = backgroundColor ? vmmlUtils.argbToRgba(backgroundColor) : "transparent";
|
|
1473
|
-
const stColor = strokeColor ? vmmlUtils.argbToRgba(strokeColor) : "transparent";
|
|
1474
|
-
const isAiError = textContent === "\u8BF7\u8F93\u5165\u6587\u6848" && textColor === "#00000000";
|
|
1475
|
-
const textFill = vmmlUtils.argbToRgba(isAiError ? "#ffffffff" : textColor || "#ffffffff");
|
|
1476
|
-
const textBasicInfo = {
|
|
1477
|
-
isBack: backgroundColor ? true : false,
|
|
1478
|
-
colorValue: textFill,
|
|
1479
|
-
colorName: "custom",
|
|
1480
|
-
textAlign: alignType === 1 ? "center" : alignType === 2 ? "right" : "left"
|
|
1481
|
-
};
|
|
1482
|
-
const textImgData = await createTextImg({ textContent, bgColor, stColor, strokeW, textColor: textFill, fontAssetUrl, textBasicInfo, letterSpacing: letterSpace });
|
|
1483
|
-
const fontJSON = localStorage.getItem("VMML_PLAYER_FONTSMAP");
|
|
1484
|
-
let fontMap = {};
|
|
1485
|
-
try {
|
|
1486
|
-
fontMap = fontJSON ? JSON.parse(fontJSON) : {};
|
|
1487
|
-
} catch {
|
|
1488
|
-
fontMap = {};
|
|
1489
|
-
}
|
|
1490
|
-
const fontFamily = fontMap[fontAssetUrl] || "";
|
|
1491
|
-
fabric.fabric.Image.fromURL(textImgData.base64Image, (imgData) => {
|
|
1492
|
-
imgData.set({
|
|
1493
|
-
left,
|
|
1494
|
-
top,
|
|
1495
|
-
width: textImgData.width,
|
|
1496
|
-
height: textImgData.height,
|
|
1497
|
-
scaleX,
|
|
1498
|
-
scaleY,
|
|
1499
|
-
angle: posParam.rotationZ,
|
|
1500
|
-
originX: "center",
|
|
1501
|
-
originY: "center",
|
|
1502
|
-
objectCaching: false,
|
|
1503
|
-
clipData: {
|
|
1504
|
-
id: clip.id,
|
|
1505
|
-
inPoint: clip.inPoint,
|
|
1506
|
-
inFrame: vmmlUtils.getFrames(clip.inPoint, 30),
|
|
1507
|
-
type: "\u6587\u5B57",
|
|
1508
|
-
textColor: textFill,
|
|
1509
|
-
text: textContent,
|
|
1510
|
-
bgColor,
|
|
1511
|
-
originClip: clip,
|
|
1512
|
-
fontAssetUrl,
|
|
1513
|
-
fontFamily,
|
|
1514
|
-
textBasicInfo,
|
|
1515
|
-
isAiError,
|
|
1516
|
-
duration: clip.duration
|
|
1517
|
-
}
|
|
1518
|
-
});
|
|
1519
|
-
imgData.on("selected", (options) => {
|
|
1520
|
-
options.target.isSelected = -1;
|
|
1521
|
-
});
|
|
1522
|
-
imgData.on("moving", (options) => {
|
|
1523
|
-
options.transform.target.isSelected = 0;
|
|
1524
|
-
});
|
|
1525
|
-
imgData.on("modified", () => {
|
|
1526
|
-
const fObj = convertToJSON(imgData);
|
|
1527
|
-
if (fObj.clipData.isAiError) {
|
|
1528
|
-
fObj.clipData.textColor = "rgba(0, 0, 0, 0)";
|
|
1529
|
-
}
|
|
1530
|
-
if (isBatchModify) {
|
|
1531
|
-
onBatchModify(fObj, canvas);
|
|
1532
|
-
} else {
|
|
1533
|
-
vmmlConverterRef.current.updateClip(fObj);
|
|
1534
|
-
}
|
|
1535
|
-
});
|
|
1536
|
-
console.log("fabricjs>>>end>>>>>>>>>>>>");
|
|
1537
|
-
resolve(imgData);
|
|
1538
|
-
});
|
|
1539
|
-
});
|
|
1540
|
-
};
|
|
1541
1499
|
const getFontFamilyName = (url) => {
|
|
1542
1500
|
const filename = url.split("/").pop() || "";
|
|
1543
1501
|
const name = filename.replace(/\.(ttf|otf|woff2?|eot)$/i, "");
|
|
@@ -1706,13 +1664,25 @@ var EditorCanvas = react.forwardRef(
|
|
|
1706
1664
|
});
|
|
1707
1665
|
};
|
|
1708
1666
|
const updateText = async ({ id, textContent, bgColor, textColor, textBasicInfo, fontAssetUrl }) => {
|
|
1709
|
-
|
|
1710
|
-
const target = fc.getObjects().find((item) =>
|
|
1711
|
-
|
|
1712
|
-
|
|
1667
|
+
var _a;
|
|
1668
|
+
const target = fc.getObjects().find((item) => {
|
|
1669
|
+
var _a2;
|
|
1670
|
+
return ((_a2 = item.clipData) == null ? void 0 : _a2.id) === id;
|
|
1671
|
+
});
|
|
1672
|
+
const center = target.getCenterPoint();
|
|
1673
|
+
const originClip = (_a = target.clipData) == null ? void 0 : _a.originClip;
|
|
1674
|
+
if (originClip && (target == null ? void 0 : target.type) === "group") {
|
|
1675
|
+
const objects = target.getObjects();
|
|
1676
|
+
const strokeText = objects[1];
|
|
1677
|
+
target._objects.length = 0;
|
|
1678
|
+
const { objects: textObjects } = await createTextObjs({ strokeW: strokeText.strokeWidth, stColor: "", fontAssetUrl, letterSpace: strokeText.charSpacing, bgColor, textContent, textBasicInfo, textColor });
|
|
1679
|
+
textObjects.forEach((obj) => {
|
|
1680
|
+
target.addWithUpdate(obj);
|
|
1681
|
+
});
|
|
1682
|
+
target.set({
|
|
1713
1683
|
visible: true,
|
|
1714
1684
|
clipData: {
|
|
1715
|
-
...
|
|
1685
|
+
...target.clipData,
|
|
1716
1686
|
textBasicInfo,
|
|
1717
1687
|
textColor,
|
|
1718
1688
|
text: textContent,
|
|
@@ -1720,10 +1690,20 @@ var EditorCanvas = react.forwardRef(
|
|
|
1720
1690
|
isAiError: false
|
|
1721
1691
|
}
|
|
1722
1692
|
});
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1693
|
+
target._calcBounds();
|
|
1694
|
+
target._updateObjectsCoords();
|
|
1695
|
+
target.setPositionByOrigin(center, "center", "center");
|
|
1696
|
+
originClip.textClip = {
|
|
1697
|
+
...originClip.textClip,
|
|
1698
|
+
textContent,
|
|
1699
|
+
backgroundColor: bgColor,
|
|
1700
|
+
textColor,
|
|
1701
|
+
strokeColor: ""
|
|
1702
|
+
};
|
|
1703
|
+
target.setCoords();
|
|
1704
|
+
fc == null ? void 0 : fc.requestRenderAll();
|
|
1705
|
+
vmmlConverterRef.current.updateClip(convertToJSON(target));
|
|
1706
|
+
}
|
|
1727
1707
|
};
|
|
1728
1708
|
const changeObjectVisible = (id, visible = true) => {
|
|
1729
1709
|
const target = fc.getObjects().find((item) => item.clipData.id === id);
|
|
@@ -1747,7 +1727,7 @@ var EditorCanvas = react.forwardRef(
|
|
|
1747
1727
|
top: canvasSize.top,
|
|
1748
1728
|
display: showCanvas ? "block" : "none"
|
|
1749
1729
|
};
|
|
1750
|
-
}, [showCanvas]);
|
|
1730
|
+
}, [showCanvas, canvasSize]);
|
|
1751
1731
|
react.useEffect(() => {
|
|
1752
1732
|
if (!fc && canvasSize.width) {
|
|
1753
1733
|
initCanvas();
|
|
@@ -1774,7 +1754,9 @@ var EditorCanvas = react.forwardRef(
|
|
|
1774
1754
|
}, [fc, dragState]);
|
|
1775
1755
|
react.useEffect(() => {
|
|
1776
1756
|
if (canvasSize.width && canvasSize.height) {
|
|
1777
|
-
if (vmmlConverterRef.current)
|
|
1757
|
+
if (vmmlConverterRef.current) {
|
|
1758
|
+
vmmlConverterRef.current.changeVmml(vmml);
|
|
1759
|
+
} else {
|
|
1778
1760
|
vmmlConverterRef.current = new VmmlConverter_default({ vmml, canvasSize });
|
|
1779
1761
|
}
|
|
1780
1762
|
}
|
|
@@ -1810,7 +1792,6 @@ var EditorCanvas = react.forwardRef(
|
|
|
1810
1792
|
getfcObject,
|
|
1811
1793
|
checkObjectInPoint,
|
|
1812
1794
|
createImageFromClip,
|
|
1813
|
-
createTextFromClip,
|
|
1814
1795
|
changeObjectVisible,
|
|
1815
1796
|
getCanvasCtx
|
|
1816
1797
|
}), [fc, frame]);
|
|
@@ -2593,7 +2574,7 @@ var EditorFn = ({
|
|
|
2593
2574
|
pauseWhenBuffering = false,
|
|
2594
2575
|
isBatchModify = false,
|
|
2595
2576
|
textWarapCenter = false,
|
|
2596
|
-
hideConfig =
|
|
2577
|
+
hideConfig = { hideDelete: false, hideEdit: false, hideMute: false, hideVolume: false }
|
|
2597
2578
|
// { hideDelete: false, hideEdit: false, hideMute: false, hideVolume: false }
|
|
2598
2579
|
}, ref) => {
|
|
2599
2580
|
var _a;
|
|
@@ -2801,6 +2782,10 @@ var EditorFn = ({
|
|
|
2801
2782
|
const onPause = () => {
|
|
2802
2783
|
setShowCanvas(true);
|
|
2803
2784
|
setIsPlaying(false);
|
|
2785
|
+
if (canvasRef.current) {
|
|
2786
|
+
const { current: canvasC } = canvasRef;
|
|
2787
|
+
canvasC.checkObjectInPoint();
|
|
2788
|
+
}
|
|
2804
2789
|
};
|
|
2805
2790
|
const onWaiting = () => {
|
|
2806
2791
|
var _a2, _b;
|
|
@@ -2838,7 +2823,6 @@ var EditorFn = ({
|
|
|
2838
2823
|
if (fcTracks.length) {
|
|
2839
2824
|
const clips = fcTracks.map((item) => item.clips).flat().filter((item) => Reflect.has(item, "fObj"));
|
|
2840
2825
|
const fObjs = clips.map((item) => item.fObj);
|
|
2841
|
-
setInitFcObjs(fObjs);
|
|
2842
2826
|
fObjs.forEach((item) => {
|
|
2843
2827
|
onVideoChange(item.clipData);
|
|
2844
2828
|
});
|