@versa_ai/vmml-editor 1.0.13 → 1.0.14
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 +8 -8
- package/dist/index.js +29 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/assets/css/index.scss +6 -6
- package/src/components/EditorCanvas.tsx +3 -4
- package/src/components/SeekBar.tsx +3 -2
- package/src/index.tsx +9 -6
- package/src/utils/usePeekControl.ts +15 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versa_ai/vmml-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"module": "dist/index.mjs",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"remotion": "4.0.166",
|
|
17
17
|
"uuid": "^10.0.0",
|
|
18
18
|
"zod": "^3.23.8",
|
|
19
|
-
"@versa_ai/vmml-
|
|
20
|
-
"@versa_ai/vmml-
|
|
19
|
+
"@versa_ai/vmml-player": "1.1.15",
|
|
20
|
+
"@versa_ai/vmml-utils": "1.0.15"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@biomejs/biome": "^1.7.1",
|
|
@@ -272,8 +272,8 @@
|
|
|
272
272
|
.player-controls-toggle {
|
|
273
273
|
>img {
|
|
274
274
|
display: block;
|
|
275
|
-
width:
|
|
276
|
-
height:
|
|
275
|
+
width: 30px !important;
|
|
276
|
+
height: 30px !important;
|
|
277
277
|
cursor: pointer;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
@@ -282,7 +282,7 @@
|
|
|
282
282
|
.seekbar-container {
|
|
283
283
|
height: 2px !important;
|
|
284
284
|
.seekbar-background {
|
|
285
|
-
height:
|
|
285
|
+
height: 8px !important;
|
|
286
286
|
width: 100%;
|
|
287
287
|
border-radius: 1vw;
|
|
288
288
|
.seekbar-fill {
|
|
@@ -300,9 +300,9 @@
|
|
|
300
300
|
margin-top: -6px;
|
|
301
301
|
}
|
|
302
302
|
.seekbar-cirle {
|
|
303
|
-
top: -
|
|
304
|
-
width:
|
|
305
|
-
height:
|
|
303
|
+
top: -5px !important;
|
|
304
|
+
width: 20px !important;
|
|
305
|
+
height: 20px !important;
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
}
|
|
@@ -8,7 +8,7 @@ import { usePeekControl } from "../utils/usePeekControl";
|
|
|
8
8
|
import { toSvg } from 'dom-to-image'
|
|
9
9
|
|
|
10
10
|
const EditorCanvas = forwardRef(
|
|
11
|
-
({ previewState, showCanvas, canvasSize, enterPreview, intoTextEdit, frame, vmml, dragState, initFcObjs, onVideoChange }: any, ref: any) => {
|
|
11
|
+
({ previewState, showCanvas, canvasSize, enterPreview, intoTextEdit, frame, vmml, dragState, initFcObjs, onVideoChange, isBatchModify, hideConfig }: any, ref: any) => {
|
|
12
12
|
const [fc, setFc] = useState<any>(null);
|
|
13
13
|
const [history, setHistory] = useState<any>(null);
|
|
14
14
|
const waitFcTasks = useRef<any>([]);
|
|
@@ -30,7 +30,7 @@ const EditorCanvas = forwardRef(
|
|
|
30
30
|
}
|
|
31
31
|
setFc(canvas);
|
|
32
32
|
initCanvasEvent(canvas);
|
|
33
|
-
usePeekControl(canvas);
|
|
33
|
+
usePeekControl(canvas, hideConfig);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
const createFcObjs = (canvas: any) => {
|
|
@@ -71,7 +71,7 @@ const EditorCanvas = forwardRef(
|
|
|
71
71
|
if (active) {
|
|
72
72
|
if (active.isSelected !== null && active.clipData.type === "文字") {
|
|
73
73
|
//文字内容双击
|
|
74
|
-
imitateDBclick(active, canvas);
|
|
74
|
+
if (!hideConfig.hideEdit) imitateDBclick(active, canvas);
|
|
75
75
|
}
|
|
76
76
|
} else {
|
|
77
77
|
enterPreview(canvas);
|
|
@@ -401,7 +401,6 @@ const EditorCanvas = forwardRef(
|
|
|
401
401
|
p.style.color = textColor;
|
|
402
402
|
p.style.fontSize = '22px'
|
|
403
403
|
p.style.lineHeight = '22px'
|
|
404
|
-
const font = fontAssetUrl ? `font-${fontAssetUrl}` : 'sansMedium';
|
|
405
404
|
p.style.fontFamily = fontFamily;
|
|
406
405
|
p.style.whiteSpace = "nowrap"
|
|
407
406
|
// p.style.backgroundColor = bgColor;
|
|
@@ -16,13 +16,14 @@ const getFrameFromX = (
|
|
|
16
16
|
);
|
|
17
17
|
return frame;
|
|
18
18
|
};
|
|
19
|
-
console.log(2222)
|
|
20
19
|
const SeekBar = ({ player, vmmlRef, frame, durationInFrames, intoEdit, setDragState, signList }: any ) => {
|
|
21
20
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
22
21
|
const [dragging, setDragging] = useState<any>({
|
|
23
22
|
dragging: false,
|
|
24
23
|
})
|
|
25
24
|
|
|
25
|
+
const max750 = document.body.clientWidth > 750
|
|
26
|
+
|
|
26
27
|
const fillStyle = useMemo(() => {
|
|
27
28
|
return {
|
|
28
29
|
width: `${(frame / (durationInFrames - 1)) * 100}%`,
|
|
@@ -31,7 +32,7 @@ const SeekBar = ({ player, vmmlRef, frame, durationInFrames, intoEdit, setDragSt
|
|
|
31
32
|
|
|
32
33
|
const cirleStyle = useMemo(() => {
|
|
33
34
|
return {
|
|
34
|
-
left: `calc(${(frame / (durationInFrames - 1)) * 100}% - 1.6vw)`,
|
|
35
|
+
left: `calc(${(frame / (durationInFrames - 1)) * 100}% - ${max750 ? '10px' : '1.6vw'})`,
|
|
35
36
|
}
|
|
36
37
|
}, [frame, durationInFrames])
|
|
37
38
|
|
package/src/index.tsx
CHANGED
|
@@ -28,6 +28,8 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
|
|
|
28
28
|
strategyId,
|
|
29
29
|
height = '100vh',
|
|
30
30
|
pauseWhenBuffering = false,
|
|
31
|
+
isBatchModify = false,
|
|
32
|
+
hideConfig = null // { hideDelete: false, hideEdit: false, hideMute: false, hideVolume: false }
|
|
31
33
|
}: any,
|
|
32
34
|
ref: any,
|
|
33
35
|
) => {
|
|
@@ -477,6 +479,8 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
|
|
|
477
479
|
dragState={dragState}
|
|
478
480
|
initFcObjs={initFcObjs}
|
|
479
481
|
onVideoChange={onVideoChange}
|
|
482
|
+
isBatchModify={isBatchModify}
|
|
483
|
+
hideConfig={hideConfig}
|
|
480
484
|
// textInfoReset={textInfoReset}
|
|
481
485
|
/>
|
|
482
486
|
<div className="controls-box">
|
|
@@ -527,12 +531,11 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
|
|
|
527
531
|
}
|
|
528
532
|
</section>
|
|
529
533
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
534
|
+
{
|
|
535
|
+
maxVideo > 0 && (
|
|
536
|
+
<VideoMenu menuState={menuState} createImage={createImage} videoMenus={videoMenus} />
|
|
537
|
+
)
|
|
538
|
+
}
|
|
536
539
|
{menuState === "text" && (
|
|
537
540
|
<TextMenu ref={textMenuRef} createText={createText} textClose={textClose} textInfo={textInfo} showTextButtons={showTextButtons} />
|
|
538
541
|
)}
|
|
@@ -17,14 +17,14 @@ function drawImg(
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// 顶点
|
|
20
|
-
function usePeekControl(canvas: fabric.Canvas) {
|
|
20
|
+
function usePeekControl(canvas: fabric.Canvas, hideConfig: any) {
|
|
21
21
|
const iconUrls = {
|
|
22
|
-
delete: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/0c7084a9-6067-4277-a5af-2932983cbeb7.png",
|
|
22
|
+
delete: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/0c7084a9-6067-4277-a5af-2932983cbeb7.png", // 删除
|
|
23
23
|
// zoom: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/ff6aea73-4d12-4201-9404-3134d5f9525c.png",
|
|
24
|
-
zoom: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/0909485d-46db-47b4-8bb1-5a686510ddb3.png",
|
|
25
|
-
mute: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/3fef2c5d-7576-424d-813c-34508b051884.png",
|
|
26
|
-
volume: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/1ab2e829-c5b1-4177-8554-ae2f74b02e1d.png",
|
|
27
|
-
edit: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/9e9ed472-62cf-4b71-891f-bc08c8b08a5d.png"
|
|
24
|
+
zoom: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/0909485d-46db-47b4-8bb1-5a686510ddb3.png", // 缩放
|
|
25
|
+
mute: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/3fef2c5d-7576-424d-813c-34508b051884.png", // 静音
|
|
26
|
+
volume: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/1ab2e829-c5b1-4177-8554-ae2f74b02e1d.png", // 音量
|
|
27
|
+
edit: "https://mass.alipay.com/finmedia_versaassets/uri/file/as/9e9ed472-62cf-4b71-891f-bc08c8b08a5d.png", // 编辑
|
|
28
28
|
};
|
|
29
29
|
const createIconElement = (url: string) => {
|
|
30
30
|
const img = document.createElement("img");
|
|
@@ -35,6 +35,7 @@ function usePeekControl(canvas: fabric.Canvas) {
|
|
|
35
35
|
// 删除选中元素
|
|
36
36
|
const deleteObject = (mouseEvent: MouseEvent, target: fabric.Transform) => {
|
|
37
37
|
if (target.action === "rotate") return true;
|
|
38
|
+
if (hideConfig.hideDelete) return true
|
|
38
39
|
const activeObject = canvas.getActiveObjects();
|
|
39
40
|
if (activeObject) {
|
|
40
41
|
activeObject.map((item: any) => canvas.remove(item));
|
|
@@ -43,11 +44,11 @@ function usePeekControl(canvas: fabric.Canvas) {
|
|
|
43
44
|
}
|
|
44
45
|
return true;
|
|
45
46
|
};
|
|
46
|
-
const delImg = createIconElement(iconUrls.delete)
|
|
47
|
-
const zoomImg = createIconElement(iconUrls.zoom)
|
|
48
|
-
const muteImg = createIconElement(iconUrls.mute)
|
|
49
|
-
const volumeImg = createIconElement(iconUrls.volume)
|
|
50
|
-
const editImg = createIconElement(iconUrls.edit)
|
|
47
|
+
const delImg = createIconElement(iconUrls.delete)
|
|
48
|
+
const zoomImg = createIconElement(iconUrls.zoom)
|
|
49
|
+
const muteImg = createIconElement(iconUrls.mute)
|
|
50
|
+
const volumeImg = createIconElement(iconUrls.volume)
|
|
51
|
+
const editImg = createIconElement(iconUrls.edit)
|
|
51
52
|
//渲染删除图标
|
|
52
53
|
const renderDelIcon = (
|
|
53
54
|
ctx: CanvasRenderingContext2D,
|
|
@@ -56,7 +57,7 @@ function usePeekControl(canvas: fabric.Canvas) {
|
|
|
56
57
|
styleOverride: any,
|
|
57
58
|
fabricObject: fabric.Object,
|
|
58
59
|
) => {
|
|
59
|
-
drawImg(ctx, left, top, delImg, 28, 28, fabricObject.angle);
|
|
60
|
+
if (!hideConfig.hideDelete) drawImg(ctx, left, top, delImg, 28, 28, fabricObject.angle);
|
|
60
61
|
};
|
|
61
62
|
//渲染旋转缩放图标
|
|
62
63
|
const renderIconRotate = (
|
|
@@ -117,7 +118,7 @@ function usePeekControl(canvas: fabric.Canvas) {
|
|
|
117
118
|
) => {
|
|
118
119
|
if (!fabricObject.clipData) return false;
|
|
119
120
|
if (fabricObject.clipData.type === '文字') {
|
|
120
|
-
drawImg(ctx, left, top, editImg, 28, 28, fabricObject.angle);
|
|
121
|
+
if (!hideConfig.hideEdit) drawImg(ctx, left, top, editImg, 28, 28, fabricObject.angle);
|
|
121
122
|
}
|
|
122
123
|
};
|
|
123
124
|
const multiAction = (eventData: any, transform: any, x: any, y: any)=>{
|
|
@@ -139,6 +140,7 @@ function usePeekControl(canvas: fabric.Canvas) {
|
|
|
139
140
|
};
|
|
140
141
|
//暴露文字编辑方法
|
|
141
142
|
const editAction = (eventData: any, transform: any, x: any, y: any) => {
|
|
143
|
+
if (hideConfig.hideEdit) return true
|
|
142
144
|
if (transform.target.clipData.type === '文字') {
|
|
143
145
|
canvas.fire("object:textEdit", { target: transform.target });
|
|
144
146
|
}
|