@versa_ai/vmml-editor 1.0.42 → 1.0.44

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @versa_ai/vmml-editor@1.0.42 build D:\code\work\vmml-player\packages\editor
2
+ > @versa_ai/vmml-editor@1.0.44 build D:\code\work\vmml-player\packages\editor
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -66,6 +66,7 @@ More info and automated migrator: https://sass-lang.com/d/slash-div [35
66
66
 
67
67
 
68
68
 
69
+ DTS Build start
69
70
 
70
71
   WARN  ▲ [WARNING] Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.
71
72
 
@@ -123,13 +124,12 @@ More info and automated migrator: https://sass-lang.com/d/slash-div [35
123
124
 
124
125
 
125
126
 
126
- DTS Build start
127
- ESM dist\index.mjs 119.77 KB
128
- ESM dist\index.mjs.map 233.03 KB
129
- ESM ⚡️ Build success in 786ms
130
- CJS dist\index.js 121.41 KB
131
- CJS dist\index.js.map 233.32 KB
132
- CJS ⚡️ Build success in 787ms
133
- DTS ⚡️ Build success in 2403ms
127
+ CJS dist\index.js 121.53 KB
128
+ CJS dist\index.js.map 233.39 KB
129
+ CJS ⚡️ Build success in 1082ms
130
+ ESM dist\index.mjs 119.73 KB
131
+ ESM dist\index.mjs.map 233.08 KB
132
+ ESM ⚡️ Build success in 1083ms
133
+ DTS ⚡️ Build success in 2236ms
134
134
  DTS dist\index.d.ts 158.00 B
135
135
  DTS dist\index.d.mts 158.00 B
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var vmmlPlayer = require('@versa_ai/vmml-player');
4
+ var cloneDeep = require('lodash.clonedeep');
4
5
  var react = require('react');
5
6
  var vmmlUtils = require('@versa_ai/vmml-utils');
6
7
  var remotion = require('remotion');
@@ -9,6 +10,10 @@ var fabric = require('fabric');
9
10
  var uuid = require('uuid');
10
11
  var domToImage = require('dom-to-image');
11
12
 
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var cloneDeep__default = /*#__PURE__*/_interopDefault(cloneDeep);
16
+
12
17
  // src/index.tsx
13
18
 
14
19
  // src/assets/css/index.scss
@@ -638,7 +643,6 @@ var VmmlConverter = class {
638
643
  addTextClip(fObj) {
639
644
  console.log("addTextClip fObj", fObj);
640
645
  const posParam = this.setPosParam(fObj);
641
- console.log(fObj, "fObj>>>>");
642
646
  const { clipData: { id, inPoint, text, textColor, bgColor } } = fObj;
643
647
  const { template: { duration } } = this.vmml;
644
648
  const clips = [];
@@ -784,13 +788,8 @@ var VmmlConverter = class {
784
788
  */
785
789
  deleteClip({ id, type, originClip }) {
786
790
  if (originClip) {
787
- for (const track of this.tracks) {
788
- const clip = (track.clips || []).find((c) => c.id === originClip.id);
789
- if (clip) {
790
- clip.duration = 0;
791
- break;
792
- }
793
- }
791
+ const [existClip] = this.findClip(id);
792
+ existClip.duration = 0;
794
793
  } else {
795
794
  const editorTrack = this.tracks.find((track) => track.editorType === type);
796
795
  const index = editorTrack.clips.findIndex((item) => item.id === id);
@@ -1368,20 +1367,20 @@ var EditorCanvas = react.forwardRef(
1368
1367
  const lineHeight = 22 + strokeW;
1369
1368
  const paddingX = 7;
1370
1369
  const groupWidth = Math.max(...lines.map((l) => {
1371
- const temp = new fabric.fabric.Text(l || " ", { fontSize: 22, fontFamily, charSpacing: letterSpace, strokeWidth: strokeW ?? 0 });
1370
+ let options = { fontSize: 22, fontFamily, strokeWidth: strokeW ?? 0 };
1371
+ if (letterSpace) options.charSpacing = letterSpace;
1372
+ let temp = new fabric.fabric.Text(l, options);
1372
1373
  return (temp == null ? void 0 : temp.width) ?? 0;
1373
1374
  })) + paddingX * 2;
1374
1375
  const groupHeight = lines.length * lineHeight;
1375
1376
  const textObjs = [];
1376
1377
  lines.forEach((line, idx) => {
1377
1378
  const y = -groupHeight / 2 + lineHeight / 2 + idx * lineHeight;
1378
- let originX = "left";
1379
+ let originX = textBasicInfo.textAlign;
1379
1380
  let left = paddingX;
1380
- if (textBasicInfo.textAlign === "center") {
1381
- originX = "center";
1382
- left = 0;
1383
- } else if (textBasicInfo.textAlign === "right") {
1384
- originX = "right";
1381
+ if (originX === "center") {
1382
+ left = groupWidth / 2;
1383
+ } else if (originX === "right") {
1385
1384
  left = groupWidth - paddingX;
1386
1385
  }
1387
1386
  const strokeText = new fabric.fabric.Text(line || " ", {
@@ -1394,7 +1393,6 @@ var EditorCanvas = react.forwardRef(
1394
1393
  originY: "center",
1395
1394
  left,
1396
1395
  top: y,
1397
- charSpacing: letterSpace,
1398
1396
  textAlign: "left",
1399
1397
  objectCaching: false
1400
1398
  });
@@ -1408,10 +1406,13 @@ var EditorCanvas = react.forwardRef(
1408
1406
  strokeWidth: 0,
1409
1407
  left,
1410
1408
  top: y,
1411
- charSpacing: letterSpace,
1412
1409
  textAlign: "left",
1413
1410
  objectCaching: false
1414
1411
  });
1412
+ if (letterSpace) {
1413
+ fillText.set({ charSpacing: letterSpace });
1414
+ strokeText.set({ charSpacing: letterSpace });
1415
+ }
1415
1416
  textObjs.push(strokeText, fillText);
1416
1417
  });
1417
1418
  const bgRect = new fabric.fabric.Rect({
@@ -1419,7 +1420,7 @@ var EditorCanvas = react.forwardRef(
1419
1420
  height: groupHeight + 13,
1420
1421
  // padddingY: 6.5
1421
1422
  fill: bgColor,
1422
- originX: "center",
1423
+ originX: "left",
1423
1424
  originY: "center",
1424
1425
  rx: 5,
1425
1426
  ry: 5
@@ -1435,7 +1436,7 @@ var EditorCanvas = react.forwardRef(
1435
1436
  if (!canvas) return null;
1436
1437
  const { width, height } = vmml.template.dimension;
1437
1438
  const fontSize = vmmlUtils.getFontSize(width, height);
1438
- let { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType, strokeColor, strokeWidth, letterSpacing } = clip.textClip;
1439
+ const { textContent, backgroundColor, textColor, posParam, fontAssetUrl, alignType, strokeColor, strokeWidth, letterSpacing } = clip.textClip;
1439
1440
  const scaleX = posParam.scaleX * fontSize / 22 / widthScaleRef.current;
1440
1441
  const scaleY = posParam.scaleY * fontSize / 22 / heightScaleRef.current;
1441
1442
  const left = canvasSize.width * posParam.centerX;
@@ -1443,7 +1444,7 @@ var EditorCanvas = react.forwardRef(
1443
1444
  const bgColor = backgroundColor ? vmmlUtils.argbToRgba(backgroundColor) : "transparent";
1444
1445
  const strokeW = strokeColor && strokeWidth ? strokeWidth * 30 * 1.5 / fontSize : 0;
1445
1446
  const stColor = strokeColor ? vmmlUtils.argbToRgba(strokeColor) : "transparent";
1446
- const letterSpace = letterSpacing * 22 / fontSize * 45;
1447
+ const letterSpace = letterSpacing ? letterSpacing * 22 / fontSize * 45 : 0;
1447
1448
  const textFill = vmmlUtils.argbToRgba(textColor || "#ffffffff");
1448
1449
  const textBasicInfo = {
1449
1450
  isBack: backgroundColor ? true : false,
@@ -2927,11 +2928,12 @@ var EditorFn = ({
2927
2928
  setFrame(currentFrame);
2928
2929
  const convertedVmml = v;
2929
2930
  const isSame = JSON.stringify(convertedVmml) == JSON.stringify(vmmlState);
2930
- console.log(isSame, "VMML\u662F\u5426\u76F8\u540C", convertedVmml, vmmlState);
2931
+ console.log(isSame, "isSamew>>>");
2931
2932
  if (!isSame) {
2933
+ const currentV = cloneDeep__default.default(convertedVmml);
2932
2934
  (_e = (_d = canvasCurrent == null ? void 0 : canvasCurrent.getCanvasCtx()) == null ? void 0 : _d.clear) == null ? void 0 : _e.call(_d);
2933
- setVmmlState(convertedVmml);
2934
- setDurationInFrames(vmmlUtils.getFrames(((_f = convertedVmml == null ? void 0 : convertedVmml.template) == null ? void 0 : _f.duration) || 1, fps));
2935
+ setVmmlState(currentV);
2936
+ setDurationInFrames(vmmlUtils.getFrames(((_f = currentV == null ? void 0 : currentV.template) == null ? void 0 : _f.duration) || 1, fps));
2935
2937
  }
2936
2938
  playerCurrent.setVmml(convertedVmml, currentFrame);
2937
2939
  if (isSame) (_g = canvasCurrent == null ? void 0 : canvasCurrent.checkObjectInPoint) == null ? void 0 : _g.call(canvasCurrent, currentFrame);