@versa_ai/vmml-editor 1.0.22 → 1.0.24
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 +21 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/components/EditorCanvas.tsx +23 -3
- package/src/index.tsx +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1224,6 +1224,7 @@ var EditorCanvas = forwardRef(
|
|
|
1224
1224
|
});
|
|
1225
1225
|
if (editRenderTime.current === time) {
|
|
1226
1226
|
canvas.add(...objects).renderAll();
|
|
1227
|
+
checkObjectInPoint();
|
|
1227
1228
|
}
|
|
1228
1229
|
};
|
|
1229
1230
|
const createImageFromClip = (clip, fc2) => {
|
|
@@ -1405,9 +1406,10 @@ var EditorCanvas = forwardRef(
|
|
|
1405
1406
|
if (lower.includes(".ttf")) return "truetype";
|
|
1406
1407
|
return null;
|
|
1407
1408
|
};
|
|
1408
|
-
const embedFontInSVG = async (svgString, url) => {
|
|
1409
|
+
const embedFontInSVG = async (svgString, url, fontBase64) => {
|
|
1409
1410
|
if (url) {
|
|
1410
|
-
|
|
1411
|
+
let res = fontBase64;
|
|
1412
|
+
if (!res) await urlToBlob({ url });
|
|
1411
1413
|
const format = detectFontFormat(url);
|
|
1412
1414
|
const fontFamilyName = getFontFamilyName(url);
|
|
1413
1415
|
const srcValue = format ? `url('${res}') format('${format}')` : `url('${res}')`;
|
|
@@ -1423,7 +1425,22 @@ var EditorCanvas = forwardRef(
|
|
|
1423
1425
|
}
|
|
1424
1426
|
return svgString;
|
|
1425
1427
|
};
|
|
1428
|
+
const loadFont = async (url) => {
|
|
1429
|
+
if (!url) return null;
|
|
1430
|
+
try {
|
|
1431
|
+
const base64 = await urlToBlob({ url });
|
|
1432
|
+
const fontFamilyName = getFontFamilyName(url);
|
|
1433
|
+
const format = detectFontFormat(url);
|
|
1434
|
+
const fontFace = new FontFace(fontFamilyName, `url(${base64})${format ? ` format('${format}')` : ""}`);
|
|
1435
|
+
await fontFace.load();
|
|
1436
|
+
document.fonts.add(fontFace);
|
|
1437
|
+
return base64;
|
|
1438
|
+
} catch (e) {
|
|
1439
|
+
return null;
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1426
1442
|
const createTextImg = async ({ textContent, bgColor, textColor, stColor, strokeW, fontAssetUrl = null, textBasicInfo }) => {
|
|
1443
|
+
const fontBase64 = await loadFont(fontAssetUrl);
|
|
1427
1444
|
const container = document.createElement("div");
|
|
1428
1445
|
container.style.backgroundColor = bgColor;
|
|
1429
1446
|
container.style.boxSizing = "content-box";
|
|
@@ -1465,7 +1482,7 @@ var EditorCanvas = forwardRef(
|
|
|
1465
1482
|
const { width, height } = container == null ? void 0 : container.getBoundingClientRect();
|
|
1466
1483
|
const dataurl = await toSvg(container);
|
|
1467
1484
|
document.body.removeChild(container);
|
|
1468
|
-
const base64Image = await embedFontInSVG(dataurl, fontAssetUrl);
|
|
1485
|
+
const base64Image = await embedFontInSVG(dataurl, fontAssetUrl, fontBase64);
|
|
1469
1486
|
return { base64Image, height, width };
|
|
1470
1487
|
};
|
|
1471
1488
|
const createText = async ({ textContent, bgColor, textColor, position, textBasicInfo, id }, fc2) => {
|
|
@@ -2684,7 +2701,7 @@ var EditorFn = ({
|
|
|
2684
2701
|
if (editableArray.length && (vmmlState == null ? void 0 : vmmlState.template)) {
|
|
2685
2702
|
initCanEditClips(vmmlState.template.tracks);
|
|
2686
2703
|
}
|
|
2687
|
-
}, [editableArray, refreshEdit]);
|
|
2704
|
+
}, [editableArray, refreshEdit, vmmlState]);
|
|
2688
2705
|
useEffect(() => {
|
|
2689
2706
|
var _a2;
|
|
2690
2707
|
if (propVmml) {
|