@versa_ai/vmml-editor 1.0.45 → 1.0.47
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 +40 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -127
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/EditorCanvas.tsx +44 -137
- package/src/index.tsx +1 -1
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.47 build D:\code\work\vmml-player\packages\editor
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
[34mCLI[39m Target: node16
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
+
[34mDTS[39m Build start
|
|
12
13
|
|
|
13
14
|
[43m[30m WARN [39m[49m [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mUsing / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
|
|
14
15
|
|
|
@@ -66,7 +67,6 @@ More info and automated migrator: https://sass-lang.com/d/slash-div[0m [1m[35
|
|
|
66
67
|
|
|
67
68
|
|
|
68
69
|
|
|
69
|
-
[34mDTS[39m Build start
|
|
70
70
|
|
|
71
71
|
[43m[30m WARN [39m[49m [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mUsing / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
|
|
72
72
|
|
|
@@ -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
|
|
|
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[32m115.63 KB[39m
|
|
128
|
+
[32mESM[39m [1mdist\index.mjs.map [22m[32m224.90 KB[39m
|
|
129
|
+
[32mESM[39m ⚡️ Build success in 918ms
|
|
130
|
+
[32mCJS[39m [1mdist\index.js [22m[32m117.40 KB[39m
|
|
131
|
+
[32mCJS[39m [1mdist\index.js.map [22m[32m225.19 KB[39m
|
|
132
|
+
[32mCJS[39m ⚡️ Build success in 918ms
|
|
133
|
+
[32mDTS[39m ⚡️ Build success in 2182ms
|
|
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
|
@@ -8,7 +8,6 @@ var remotion = require('remotion');
|
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
var fabric = require('fabric');
|
|
10
10
|
var uuid = require('uuid');
|
|
11
|
-
var domToImage = require('dom-to-image');
|
|
12
11
|
|
|
13
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
|
|
@@ -1500,25 +1499,6 @@ var EditorCanvas = react.forwardRef(
|
|
|
1500
1499
|
if (lower.includes(".ttf")) return "truetype";
|
|
1501
1500
|
return null;
|
|
1502
1501
|
};
|
|
1503
|
-
const embedFontInSVG = async (svgString, url, fontBase64) => {
|
|
1504
|
-
if (url) {
|
|
1505
|
-
let res = fontBase64;
|
|
1506
|
-
if (!res) await vmmlUtils.urlToBlob({ url });
|
|
1507
|
-
const format = detectFontFormat(url);
|
|
1508
|
-
const fontFamilyName = getFontFamilyName(url);
|
|
1509
|
-
const srcValue = format ? `url('${res}') format('${format}')` : `url('${res}')`;
|
|
1510
|
-
const fontFace = `
|
|
1511
|
-
@font-face {
|
|
1512
|
-
font-family: '${fontFamilyName}';
|
|
1513
|
-
src: ${srcValue};
|
|
1514
|
-
}
|
|
1515
|
-
`;
|
|
1516
|
-
const styleElement = `<style type="text/css"><![CDATA[${fontFace}]]></style>`;
|
|
1517
|
-
const result = svgString.replace("</svg>", `${styleElement}</svg>`);
|
|
1518
|
-
return result;
|
|
1519
|
-
}
|
|
1520
|
-
return svgString;
|
|
1521
|
-
};
|
|
1522
1502
|
const loadFont = async (url) => {
|
|
1523
1503
|
if (!url) return null;
|
|
1524
1504
|
if (fontCacheRef.current.has(url)) {
|
|
@@ -1541,117 +1521,50 @@ var EditorCanvas = react.forwardRef(
|
|
|
1541
1521
|
fontCacheRef.current.set(url, loadPromise);
|
|
1542
1522
|
return loadPromise;
|
|
1543
1523
|
};
|
|
1544
|
-
const setTextAlign = (p, stroke, direction) => {
|
|
1545
|
-
if (direction === "center") {
|
|
1546
|
-
p.style.justifyContent = "center";
|
|
1547
|
-
stroke.style.left = "50%";
|
|
1548
|
-
stroke.style.top = "50%";
|
|
1549
|
-
stroke.style.transform = "translate(-50%, -50%)";
|
|
1550
|
-
}
|
|
1551
|
-
if (direction === "left") {
|
|
1552
|
-
stroke.style.left = "0";
|
|
1553
|
-
stroke.style.top = "0";
|
|
1554
|
-
stroke.style.transform = "none";
|
|
1555
|
-
}
|
|
1556
|
-
if (direction === "right") {
|
|
1557
|
-
p.style.justifyContent = "flex-end";
|
|
1558
|
-
stroke.style.right = "0";
|
|
1559
|
-
stroke.style.top = "50%";
|
|
1560
|
-
stroke.style.transform = "translateY(-50%)";
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
|
-
const createTextImg = async ({ textContent, bgColor, textColor, stColor, strokeW, fontAssetUrl = null, textBasicInfo, letterSpacing }) => {
|
|
1564
|
-
const fontBase64 = await loadFont(fontAssetUrl);
|
|
1565
|
-
const container = document.createElement("div");
|
|
1566
|
-
container.style.backgroundColor = bgColor;
|
|
1567
|
-
container.style.boxSizing = "content-box";
|
|
1568
|
-
container.style.display = "inline-block";
|
|
1569
|
-
container.style.textAlign = textBasicInfo.textAlign || "left";
|
|
1570
|
-
const lines = textContent.split("\n");
|
|
1571
|
-
const fontFamily = fontAssetUrl ? getFontFamilyName(fontAssetUrl) : "sansMedium";
|
|
1572
|
-
lines.forEach((line) => {
|
|
1573
|
-
const p = document.createElement("p");
|
|
1574
|
-
p.style.position = "relative";
|
|
1575
|
-
p.style.display = "flex";
|
|
1576
|
-
p.style.fontSize = "22px";
|
|
1577
|
-
p.style.lineHeight = "22px";
|
|
1578
|
-
p.style.fontFamily = fontFamily;
|
|
1579
|
-
p.style.whiteSpace = "nowrap";
|
|
1580
|
-
p.style.margin = "0";
|
|
1581
|
-
p.style.padding = "0";
|
|
1582
|
-
if (letterSpacing) p.style.letterSpacing = `${letterSpacing}px`;
|
|
1583
|
-
p.style.zIndex = "2";
|
|
1584
|
-
const fill = document.createElement("span");
|
|
1585
|
-
fill.textContent = line || " ";
|
|
1586
|
-
fill.style.color = textColor;
|
|
1587
|
-
fill.style.position = "relative";
|
|
1588
|
-
fill.style.zIndex = "1";
|
|
1589
|
-
const stroke = document.createElement("span");
|
|
1590
|
-
stroke.textContent = line || " ";
|
|
1591
|
-
stroke.style.position = "absolute";
|
|
1592
|
-
stroke.style.color = "transparent";
|
|
1593
|
-
stroke.style.webkitTextStrokeWidth = `${strokeW}px`;
|
|
1594
|
-
stroke.style.webkitTextStrokeColor = stColor;
|
|
1595
|
-
let dr = textBasicInfo.textAlign || "left";
|
|
1596
|
-
if (textWarapCenter) dr = "center";
|
|
1597
|
-
setTextAlign(p, stroke, dr);
|
|
1598
|
-
p.appendChild(fill);
|
|
1599
|
-
p.appendChild(stroke);
|
|
1600
|
-
container.appendChild(p);
|
|
1601
|
-
});
|
|
1602
|
-
container.style.padding = "6.5px 7px 6.5px 7px";
|
|
1603
|
-
container.style.borderRadius = "5px";
|
|
1604
|
-
document.body.appendChild(container);
|
|
1605
|
-
const { width, height } = container == null ? void 0 : container.getBoundingClientRect();
|
|
1606
|
-
const dataurl = await domToImage.toSvg(container);
|
|
1607
|
-
document.body.removeChild(container);
|
|
1608
|
-
const base64Image = await embedFontInSVG(dataurl, fontAssetUrl, fontBase64);
|
|
1609
|
-
return { base64Image, height, width };
|
|
1610
|
-
};
|
|
1611
1524
|
const createText = async ({ textContent, bgColor, textColor, position, textBasicInfo, id }, fc2) => {
|
|
1612
1525
|
const canvas = fc || fc2;
|
|
1613
1526
|
const { left, top, angle, scaleX, scaleY, zoomX, zoomY } = position;
|
|
1614
|
-
const
|
|
1527
|
+
const { objects } = await createTextObjs({ strokeW: 0, stColor: "", fontAssetUrl: null, letterSpace: 0, bgColor, textContent, textBasicInfo, textColor });
|
|
1615
1528
|
return new Promise((resolve, reject) => {
|
|
1616
|
-
fabric.fabric.
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
onVideoChange(imgData.clipData);
|
|
1652
|
-
vmmlConverterRef.current.addTextClip(convertToJSON(imgData));
|
|
1653
|
-
resolve(true);
|
|
1529
|
+
const group = new fabric.fabric.Group([...objects], {
|
|
1530
|
+
left,
|
|
1531
|
+
top,
|
|
1532
|
+
scaleX,
|
|
1533
|
+
scaleY,
|
|
1534
|
+
angle,
|
|
1535
|
+
originX: "center",
|
|
1536
|
+
originY: "center",
|
|
1537
|
+
clipData: {
|
|
1538
|
+
duration: vmmlConverterRef.current.vmml.template.duration,
|
|
1539
|
+
id: uuid.v4(),
|
|
1540
|
+
inPoint: Math.floor(frame / 30 * 1e6),
|
|
1541
|
+
inFrame: frame,
|
|
1542
|
+
type: "\u6587\u5B57",
|
|
1543
|
+
textBasicInfo,
|
|
1544
|
+
textColor,
|
|
1545
|
+
text: textContent,
|
|
1546
|
+
bgColor,
|
|
1547
|
+
visible: true
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
group.on("selected", (options) => {
|
|
1551
|
+
options.target.isSelected = -1;
|
|
1552
|
+
});
|
|
1553
|
+
group.on("moving", (options) => {
|
|
1554
|
+
options.transform.target.isSelected = 0;
|
|
1555
|
+
});
|
|
1556
|
+
group.on("modified", () => {
|
|
1557
|
+
const fObj = convertToJSON(group);
|
|
1558
|
+
vmmlConverterRef.current.updateClip(fObj);
|
|
1559
|
+
});
|
|
1560
|
+
canvas.centerObject(group);
|
|
1561
|
+
canvas.add(group);
|
|
1562
|
+
setTimeout(() => {
|
|
1563
|
+
canvas.renderAll();
|
|
1654
1564
|
});
|
|
1565
|
+
onVideoChange((group == null ? void 0 : group.clipData) ?? null);
|
|
1566
|
+
vmmlConverterRef.current.addTextClip(convertToJSON(group));
|
|
1567
|
+
resolve(true);
|
|
1655
1568
|
});
|
|
1656
1569
|
};
|
|
1657
1570
|
const updateText = async ({ id, textContent, bgColor, textColor, textBasicInfo, fontAssetUrl }) => {
|
|
@@ -2859,7 +2772,7 @@ var EditorFn = ({
|
|
|
2859
2772
|
if (editableArray.length && (vmmlState == null ? void 0 : vmmlState.template)) {
|
|
2860
2773
|
initCanEditClips(vmmlState.template.tracks);
|
|
2861
2774
|
}
|
|
2862
|
-
}, [editableArray,
|
|
2775
|
+
}, [editableArray, vmmlState]);
|
|
2863
2776
|
react.useEffect(() => {
|
|
2864
2777
|
if (vmmlState) {
|
|
2865
2778
|
initFcObjects(vmmlState.template.tracks);
|