@versa_ai/vmml-editor 1.0.31 → 1.0.33

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/dist/index.mjs CHANGED
@@ -1439,6 +1439,25 @@ var EditorCanvas = forwardRef(
1439
1439
  return null;
1440
1440
  }
1441
1441
  };
1442
+ const setTextAlign = (p, stroke, direction) => {
1443
+ if (direction === "center") {
1444
+ p.style.justifyContent = "center";
1445
+ stroke.style.left = "50%";
1446
+ stroke.style.top = "50%";
1447
+ stroke.style.transform = "translate(-50%, -50%)";
1448
+ }
1449
+ if (direction === "left") {
1450
+ stroke.style.left = "0";
1451
+ stroke.style.top = "0";
1452
+ stroke.style.transform = "none";
1453
+ }
1454
+ if (direction === "right") {
1455
+ p.style.justifyContent = "flex-end";
1456
+ stroke.style.right = "0";
1457
+ stroke.style.top = "50%";
1458
+ stroke.style.transform = "translateY(-50%)";
1459
+ }
1460
+ };
1442
1461
  const createTextImg = async ({ textContent, bgColor, textColor, stColor, strokeW, fontAssetUrl = null, textBasicInfo, letterSpacing }) => {
1443
1462
  const fontBase64 = await loadFont(fontAssetUrl);
1444
1463
  const container = document.createElement("div");
@@ -1460,7 +1479,6 @@ var EditorCanvas = forwardRef(
1460
1479
  p.style.padding = "0";
1461
1480
  if (letterSpacing) p.style.letterSpacing = `${letterSpacing}px`;
1462
1481
  p.style.zIndex = "2";
1463
- if (textWarapCenter) p.style.justifyContent = "center";
1464
1482
  const fill = document.createElement("span");
1465
1483
  fill.textContent = line || " ";
1466
1484
  fill.style.color = textColor;
@@ -1472,15 +1490,9 @@ var EditorCanvas = forwardRef(
1472
1490
  stroke.style.color = "transparent";
1473
1491
  stroke.style.webkitTextStrokeWidth = `${strokeW}px`;
1474
1492
  stroke.style.webkitTextStrokeColor = stColor;
1475
- if (textWarapCenter) {
1476
- stroke.style.left = "50%";
1477
- stroke.style.top = "50%";
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";
1493
+ let dr = textBasicInfo.textAlign || "left";
1494
+ if (textWarapCenter) dr = "center";
1495
+ setTextAlign(p, stroke, dr);
1484
1496
  p.appendChild(fill);
1485
1497
  p.appendChild(stroke);
1486
1498
  container.appendChild(p);
@@ -2721,10 +2733,8 @@ var EditorFn = ({
2721
2733
  if (player) {
2722
2734
  const parent = player.getContainerNode();
2723
2735
  if (!canvasSize.width) {
2724
- console.log(parent, "parent>>>>");
2725
2736
  const playerElement = parent == null ? void 0 : parent.children[0];
2726
2737
  const { width, height: height2 } = (playerElement == null ? void 0 : playerElement.getBoundingClientRect()) || {};
2727
- console.log(height2);
2728
2738
  setCanvasSize({ width, height: height2, top: playerElement.offsetTop });
2729
2739
  }
2730
2740
  player.addEventListener("play", onPlay);
@@ -2769,6 +2779,7 @@ var EditorFn = ({
2769
2779
  const isSame = JSON.stringify(v) === JSON.stringify(vmmlState);
2770
2780
  console.log(v, vmmlState, isSame, "\u5224\u65ADvmml\u662F\u5426\u76F8\u540C");
2771
2781
  needPlay.current = false;
2782
+ once.current = false;
2772
2783
  const convertedVmml = convertVmmlTextScaleByForbidden(v);
2773
2784
  if (!isSame) {
2774
2785
  (_b = (_a2 = canvasCurrent == null ? void 0 : canvasCurrent.getCanvasCtx()) == null ? void 0 : _a2.clear) == null ? void 0 : _b.call(_a2);