@versa_ai/vmml-editor 1.0.30 → 1.0.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versa_ai/vmml-editor",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "module": "dist/index.mjs",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",
@@ -78,98 +78,101 @@
78
78
  width: 100%;
79
79
  height: 100%;
80
80
  }
81
- .controls-box {
81
+
82
+ }
83
+
84
+ .controls-box {
85
+ position: relative;
82
86
  height: 12vw;
83
- position: absolute;
84
- bottom: 0;
87
+ // position: absolute;
88
+ // bottom: 0;
85
89
  width: 100%;
86
90
  border-radius: 3.2vw;
91
+ }
92
+ .player-controls {
93
+ display: flex;
94
+ align-items: center;
95
+ width: 100%;
96
+ height: 100%;
97
+ padding: 0 2.13vw;
98
+ box-sizing: border-box;
99
+ background: linear-gradient( 180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.6) 100%);
100
+ .mr-16 {
101
+ margin-right: 2.13vw;
87
102
  }
88
- .player-controls {
89
- display: flex;
90
- align-items: center;
91
- width: 100%;
92
- height: 100%;
93
- padding: 0 2.13vw;
94
- box-sizing: border-box;
95
- background: linear-gradient( 180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.6) 100%);
96
- .mr-16 {
97
- margin-right: 2.13vw;
98
- }
99
- .player-controls-toggle {
100
- >img {
101
- display: block;
102
- width: 4.8vw;
103
- height: 4.8vw;
104
- cursor: pointer;
105
- }
103
+ .player-controls-toggle {
104
+ >img {
105
+ display: block;
106
+ width: 4.8vw;
107
+ height: 4.8vw;
108
+ cursor: pointer;
106
109
  }
107
- .player-controls-seekbar {
108
- flex: 1;
110
+ }
111
+ .player-controls-seekbar {
112
+ flex: 1;
113
+ position: relative;
114
+ .seekbar-container {
115
+ height: 100%;
116
+ user-select: none;
117
+ touch-action: none;
109
118
  position: relative;
110
- .seekbar-container {
111
- height: 100%;
119
+ cursor: pointer;
120
+ box-sizing: border-box;
121
+ .seekbar-background {
112
122
  user-select: none;
113
- touch-action: none;
114
- position: relative;
115
- cursor: pointer;
116
- box-sizing: border-box;
117
- .seekbar-background {
123
+ height: 1.6vw;
124
+ width: 100%;
125
+ background-color: rgba(255, 255, 255, 0.2);
126
+ border-radius: 1vw;
127
+ .seekbar-fill {
128
+ position: absolute;
118
129
  user-select: none;
119
- height: 1.6vw;
120
130
  width: 100%;
121
- background-color: rgba(255, 255, 255, 0.2);
131
+ height: 100%;
122
132
  border-radius: 1vw;
123
- .seekbar-fill {
124
- position: absolute;
125
- user-select: none;
126
- width: 100%;
127
- height: 100%;
128
- border-radius: 1vw;
129
- }
130
- .seekbar-line {
131
- height: 100%;
132
- border-radius: 1vw;
133
- background-color: #eeeeee;
134
- }
135
- .seekbar-sign {
136
- width: 10px;
137
- position: absolute;
138
- top: 50%;
139
- margin-top: -6px;
140
- }
141
- .seekbar-cirle {
142
- position: absolute;
143
- top: -0.8vw;
144
- width: 3.2vw;
145
- height: 3.2vw;
146
- border-radius: 50%;
147
- background: #eeeeee;
148
- }
133
+ }
134
+ .seekbar-line {
135
+ height: 100%;
136
+ border-radius: 1vw;
137
+ background-color: #eeeeee;
138
+ }
139
+ .seekbar-sign {
140
+ width: 10px;
141
+ position: absolute;
142
+ top: 50%;
143
+ margin-top: -6px;
144
+ }
145
+ .seekbar-cirle {
146
+ position: absolute;
147
+ top: -0.8vw;
148
+ width: 3.2vw;
149
+ height: 3.2vw;
150
+ border-radius: 50%;
151
+ background: #eeeeee;
149
152
  }
150
153
  }
151
154
  }
152
- .player-controls-time {
153
- width: 10vw;
154
- color: #fff;
155
- }
156
155
  }
157
- .play-btn {
158
- position: absolute;
159
- bottom: 4vw;
160
- left: 3vw;
161
- width: 4.8vw;
162
- height: 4.8vw;
163
- img {
164
- width: 100%;
165
- height: 100%;
166
- display: block;
167
- }
156
+ .player-controls-time {
157
+ width: 10vw;
158
+ color: #fff;
168
159
  }
169
- .opacity-06 {
170
- opacity: 0.6;
160
+ }
161
+ .play-btn {
162
+ position: absolute;
163
+ bottom: 4vw;
164
+ left: 3vw;
165
+ width: 4.8vw;
166
+ height: 4.8vw;
167
+ img {
168
+ width: 100%;
169
+ height: 100%;
170
+ display: block;
171
171
  }
172
172
  }
173
+ .opacity-06 {
174
+ opacity: 0.6;
175
+ }
173
176
 
174
177
  //底部
175
178
  .footer{
@@ -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, editClips = [], onVideoChange, isBatchModify, hideConfig }: any, ref: any) => {
11
+ ({ previewState, showCanvas, canvasSize, enterPreview, intoTextEdit, frame, vmml, dragState, initFcObjs, editClips = [], onVideoChange, isBatchModify, hideConfig, textWarapCenter }: any, ref: any) => {
12
12
  const [fc, setFc] = useState<any>(null);
13
13
  const [history, setHistory] = useState<any>(null);
14
14
  const [canvasReady, setCanvasReady] = useState(false);
@@ -480,6 +480,7 @@ const EditorCanvas = forwardRef(
480
480
  lines.forEach((line: string) => {
481
481
  const p = document.createElement('p');
482
482
  p.style.position = 'relative';
483
+ p.style.display = 'flex';
483
484
  p.style.fontSize = '22px';
484
485
  p.style.lineHeight = '22px';
485
486
  p.style.fontFamily = fontFamily;
@@ -488,6 +489,7 @@ const EditorCanvas = forwardRef(
488
489
  p.style.padding = '0';
489
490
  if (letterSpacing) p.style.letterSpacing = `${letterSpacing}px`;
490
491
  p.style.zIndex = '2'
492
+ if (textWarapCenter) p.style.justifyContent = 'center'
491
493
 
492
494
  const fill = document.createElement('span');
493
495
  fill.textContent = line || ' ';
@@ -498,11 +500,18 @@ const EditorCanvas = forwardRef(
498
500
  const stroke = document.createElement('span');
499
501
  stroke.textContent = line || ' ';
500
502
  stroke.style.position = 'absolute';
501
- stroke.style.left = '0';
502
- stroke.style.top = '0';
503
+
503
504
  stroke.style.color = 'transparent';
504
505
  stroke.style.webkitTextStrokeWidth = `${strokeW}px`;
505
506
  stroke.style.webkitTextStrokeColor = stColor;
507
+ if (textWarapCenter) {
508
+ stroke.style.left = "50%";
509
+ stroke.style.top = "50%";
510
+ stroke.style.transform = 'translate(-50%, -50%)';
511
+ } else {
512
+ stroke.style.left = '0';
513
+ stroke.style.top = '0';
514
+ }
506
515
  stroke.style.zIndex = '-1'
507
516
 
508
517
  p.appendChild(fill);
package/src/index.tsx CHANGED
@@ -29,6 +29,7 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
29
29
  height = '100vh',
30
30
  pauseWhenBuffering = false,
31
31
  isBatchModify = false,
32
+ textWarapCenter = false,
32
33
  hideConfig = null // { hideDelete: false, hideEdit: false, hideMute: false, hideVolume: false }
33
34
  }: any,
34
35
  ref: any,
@@ -435,6 +436,7 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
435
436
  console.log(v, vmmlState, isSame, '判断vmml是否相同')
436
437
 
437
438
  needPlay.current = false
439
+ once.current = false
438
440
 
439
441
  const convertedVmml = convertVmmlTextScaleByForbidden(v);
440
442
  if (!isSame) { // vmml改变再重新刷新canvas
@@ -504,6 +506,7 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
504
506
  }}>
505
507
  <section className={`main ${menuState === 'text' ? 'text-style' : ''}`}>
506
508
  <div className="vessel" onClick={onClickMain}>
509
+ {/* 编辑器 */}
507
510
  <VmmlPlayer
508
511
  ref={vmmlPlayerRef}
509
512
  vmml={vmmlState}
@@ -516,42 +519,47 @@ const EditorFn = <Schema extends AnyZodObject, Props>(
516
519
  premountFor={40}
517
520
  pauseWhenBuffering={pauseWhenBuffering}
518
521
  filterIds={filterIds}
522
+ textWarapCenter={textWarapCenter}
519
523
  />
520
524
  </div>
521
- <EditorCanvas
522
- ref={canvasRef}
523
- previewState={previewState}
524
- showCanvas={showCanvas}
525
- canvasSize={canvasSize}
526
- enterPreview={enterPreview}
527
- intoTextEdit={intoTextEdit}
528
- frame={frame}
529
- vmml={vmmlState}
530
- dragState={dragState}
531
- initFcObjs={initFcObjs}
532
- editClips={editClips}
533
- onVideoChange={onVideoChange}
534
- isBatchModify={isBatchModify}
535
- hideConfig={hideConfig}
536
- // textInfoReset={textInfoReset}
537
- />
538
- <div className="controls-box">
539
- <Controls
540
- player={player}
541
- vmmlRef={vmmlPlayerRef}
542
- fps={fps}
543
- durationInFrames={durationInFrames}
544
- intoEdit={intoEdit}
545
- frame={frame}
546
- isPlaying={isPlaying}
547
- setDragState={setDragState}
548
- onControlsClick={onControlsClick}
549
- signList={signList}
550
- />
551
- </div>
525
+ {/* 编辑器 */}
526
+ <EditorCanvas
527
+ ref={canvasRef}
528
+ previewState={previewState}
529
+ showCanvas={showCanvas}
530
+ canvasSize={canvasSize}
531
+ enterPreview={enterPreview}
532
+ intoTextEdit={intoTextEdit}
533
+ frame={frame}
534
+ vmml={vmmlState}
535
+ dragState={dragState}
536
+ initFcObjs={initFcObjs}
537
+ editClips={editClips}
538
+ onVideoChange={onVideoChange}
539
+ isBatchModify={isBatchModify}
540
+ hideConfig={hideConfig}
541
+ textWarapCenter={textWarapCenter}
542
+ // textInfoReset={textInfoReset}
543
+ />
544
+
552
545
  <Loaidng show={loading} />
553
546
  </section>
554
547
  </div>
548
+ {/* 控制器 */}
549
+ <div className="controls-box">
550
+ <Controls
551
+ player={player}
552
+ vmmlRef={vmmlPlayerRef}
553
+ fps={fps}
554
+ durationInFrames={durationInFrames}
555
+ intoEdit={intoEdit}
556
+ frame={frame}
557
+ isPlaying={isPlaying}
558
+ setDragState={setDragState}
559
+ onControlsClick={onControlsClick}
560
+ signList={signList}
561
+ />
562
+ </div>
555
563
  <div className="padding-box"></div>
556
564
  {
557
565
  (maxText > 0 || maxVideo > 0) && <section style={menuStyles} className={`footer ${menuState === 'text' ? 'text-style' : ''}`}>
@@ -618,5 +626,6 @@ export const Editor = forward(EditorFn);
618
626
  * @param pauseWhenBuffering 播放是否有缓冲状态,默认:false.
619
627
  * @param isBatchModify 是否批量更新 默认:false.
620
628
  * @param hideConfig 编辑框四个角的显示配置 默认:{ hideDelete: false, hideEdit: false, hideMute: false, hideVolume: false }
629
+ * @param textWarapCenter 文字是否居中 默认:false
621
630
  */
622
631