@versa_ai/vmml-editor 1.0.2

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.
Files changed (47) hide show
  1. package/.turbo/turbo-build.log +335 -0
  2. package/CHANGELOG.md +16 -0
  3. package/README.md +1 -0
  4. package/biome.json +7 -0
  5. package/dist/index.d.mts +5 -0
  6. package/dist/index.d.ts +5 -0
  7. package/dist/index.js +2675 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/index.mjs +2673 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/package.json +48 -0
  12. package/postcss.config.js +3 -0
  13. package/src/assets/css/closeLayer.scss +50 -0
  14. package/src/assets/css/colorSelector.scss +59 -0
  15. package/src/assets/css/editorTextMenu.less +130 -0
  16. package/src/assets/css/editorTextMenu.scss +149 -0
  17. package/src/assets/css/index.scss +252 -0
  18. package/src/assets/css/loading.scss +31 -0
  19. package/src/assets/css/maxTextLayer.scss +31 -0
  20. package/src/assets/img/icon_Brush.png +0 -0
  21. package/src/assets/img/icon_Change.png +0 -0
  22. package/src/assets/img/icon_Cut.png +0 -0
  23. package/src/assets/img/icon_Face.png +0 -0
  24. package/src/assets/img/icon_Graffiti.png +0 -0
  25. package/src/assets/img/icon_Mute.png +0 -0
  26. package/src/assets/img/icon_Refresh.png +0 -0
  27. package/src/assets/img/icon_Text1.png +0 -0
  28. package/src/assets/img/icon_Text2.png +0 -0
  29. package/src/assets/img/icon_Volume.png +0 -0
  30. package/src/assets/img/icon_Word.png +0 -0
  31. package/src/components/CloseLayer.tsx +25 -0
  32. package/src/components/ColorSelector.tsx +90 -0
  33. package/src/components/Controls.tsx +32 -0
  34. package/src/components/EditorCanvas.tsx +566 -0
  35. package/src/components/Loading.tsx +16 -0
  36. package/src/components/MaxTextLayer.tsx +27 -0
  37. package/src/components/SeekBar.tsx +126 -0
  38. package/src/components/TextMenu.tsx +332 -0
  39. package/src/components/VideoMenu.tsx +49 -0
  40. package/src/index.tsx +551 -0
  41. package/src/utils/HistoryClass.ts +131 -0
  42. package/src/utils/VmmlConverter.ts +339 -0
  43. package/src/utils/const.ts +10 -0
  44. package/src/utils/keyBoardUtils.ts +199 -0
  45. package/src/utils/usePeekControl.ts +242 -0
  46. package/tsconfig.json +5 -0
  47. package/tsup.config.ts +14 -0
Binary file
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ import { useEffect, useState } from "react";
2
+ import "../assets/css/closeLayer.scss";
3
+ const CloseLayer = ({ show = false, cancel, confirm }: { show: boolean; cancel: () => void; confirm: () => void }) => {
4
+ return (
5
+ show && (
6
+ <>
7
+ <div className="closeLayer">
8
+ <div>
9
+ <p>
10
+ 确定关闭吗? <br />
11
+ 关闭后将不保存涂鸦操作
12
+ </p>
13
+ <div>
14
+ <p onClick={cancel}>取消</p>
15
+ <div />
16
+ <p onClick={confirm}>确定</p>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </>
21
+ )
22
+ );
23
+ };
24
+
25
+ export default CloseLayer;
@@ -0,0 +1,90 @@
1
+ import "../assets/css/colorSelector.scss";
2
+ import { forwardRef, useImperativeHandle, useState } from "react";
3
+ import { iconText1, iconText2 } from "../utils/const";
4
+ interface Props {
5
+ colors: string[];
6
+ currentColor: string;
7
+ onSelectColor: (color: string) => void;
8
+ }
9
+ const colorList = [
10
+ { colorName: "white", colorValue: "rgb(255,255,255)" },
11
+ { colorName: "black", colorValue: "rgb(0,0,0)" },
12
+ { colorName: "gray", colorValue: "rgb(153,153,153)" },
13
+ { colorName: "red", colorValue: "rgb(248,82,81)" },
14
+ { colorName: "orange", colorValue: "rgb(250,158,60)" },
15
+ { colorName: "yellow", colorValue: "rgb(255,196,0)" },
16
+ { colorName: "lightGreen", colorValue: "rgb(145,212,0)" },
17
+ { colorName: "green", colorValue: "rgb(0,181,212)" },
18
+ { colorName: "lightBlue", colorValue: "rgb(0,183,244)" },
19
+ { colorName: "blue", colorValue: "rgb(23,120,255)" },
20
+ { colorName: "purple", colorValue: "rgb(82,95,255)" },
21
+ ];
22
+
23
+ const ColorSelector = forwardRef(({ onColorChange, onBackGroundChange }: any, ref: any) => {
24
+ // const [currentColor, setCurrentColor] = useState("red");
25
+ const [currentColorItem, setCurrentColorItem] = useState<any>(colorList.find((color) => color.colorName === "red"));
26
+ const [currentBack, setCurrentBgColor] = useState<string | null>(null);
27
+ const [isSetBack, setIsSetBack] = useState(false);
28
+ const setColorClass = (item: any) => {
29
+ const { colorName } = currentColorItem;
30
+ const classes = [
31
+ item.colorName === "black" && "black-border",
32
+ item.colorName === colorName && "current",
33
+ "color-item",
34
+ ]
35
+ .filter(Boolean)
36
+ .join(" ");
37
+ return classes;
38
+ };
39
+
40
+ const handleColorClick = (item: any) => {
41
+ setCurrentColorItem(item);
42
+ onColorChange(item);
43
+ };
44
+
45
+ const handleChangeBackGround = () => {
46
+ const setBgStatus = new Promise<void>((resolve, reject) => {
47
+ setIsSetBack(!isSetBack);
48
+ resolve();
49
+ });
50
+ //暴露到父组件调用
51
+ setBgStatus.then(() => {
52
+ onBackGroundChange(currentColorItem);
53
+ });
54
+ };
55
+ const getBackState = () => {
56
+ return isSetBack;
57
+ };
58
+ useImperativeHandle(ref, () => ({
59
+ getBackState,
60
+ setIsSetBack,
61
+ setCurrentColorItem,
62
+ }));
63
+ return (
64
+ <div className="color-selector">
65
+ <div
66
+ className="text_bg_change"
67
+ onClick={() => {
68
+ handleChangeBackGround();
69
+ }}
70
+ >
71
+ <img alt="" src={isSetBack ? iconText2 : iconText1} style={{ width: "100%", height: "100%" }} />
72
+ </div>
73
+ <div className="text_color_change">
74
+ {colorList.map((item: any) => {
75
+ return (
76
+ <div
77
+ className={setColorClass(item)}
78
+ key={item.colorName}
79
+ style={{ backgroundColor: item.colorValue }}
80
+ onClick={() => {
81
+ handleColorClick(item);
82
+ }}
83
+ />
84
+ );
85
+ })}
86
+ </div>
87
+ </div>
88
+ );
89
+ });
90
+ export default ColorSelector;
@@ -0,0 +1,32 @@
1
+ import { formatTime } from "@versa_ai/vmml-utils"
2
+ import { pauseIcon, playIcon } from "../utils/const"
3
+ import SeekBar from "./SeekBar"
4
+
5
+ const Controls = ({ player, vmmlRef, frame, fps, durationInFrames, intoEdit, isPlaying, setDragState, onControlsClick, signList }: any) => {
6
+ const onClickToggle = (e: any) => {
7
+ if (isPlaying) {
8
+ intoEdit();
9
+ } else {
10
+ onControlsClick();
11
+ }
12
+ }
13
+
14
+ return (
15
+ <div className="player-controls">
16
+ <div className="player-controls-toggle mr-16 opacity-06" onClick={onClickToggle}>
17
+ { isPlaying ? <img src={pauseIcon} alt="暂停" /> : <img src={playIcon} alt="播放" /> }
18
+ </div>
19
+ <div className="player-controls-time opacity-06">
20
+ {formatTime(frame / fps)}
21
+ </div>
22
+ <div className="player-controls-seekbar mr-16">
23
+ <SeekBar player={player} vmmlRef={vmmlRef} frame={frame} durationInFrames={durationInFrames} intoEdit={intoEdit} setDragState={setDragState} signList={signList} />
24
+ </div>
25
+ <div className="player-controls-time opacity-06">
26
+ {formatTime(durationInFrames / fps)}
27
+ </div>
28
+ </div>
29
+ )
30
+ }
31
+
32
+ export default Controls