@@ -2,7 +2,8 @@ import { Node } from '@tiptap/core';
22
33import { VIDEO_SIZE } from '@/constants' ;
44import ActionVideoButton from '@/extensions/Video/components/ActiveVideoButton' ;
5- import type { GeneralOptions } from '@/types' ;
5+ import type { GeneralOptions , VideoAlignment } from '@/types' ;
6+
67import { getCssUnitWithDefault } from '@/utils/utils' ;
78
89/**
@@ -54,6 +55,8 @@ interface SetVideoOptions {
5455 src : string
5556 /** The width of the video */
5657 width : string | number
58+
59+ align : VideoAlignment ;
5760}
5861
5962declare module '@tiptap/core' {
@@ -113,7 +116,7 @@ export const Video = /* @__PURE__ */ Node.create<VideoOptions>({
113116 width : VIDEO_SIZE [ 'size-medium' ] ,
114117 HTMLAttributes : {
115118 class : 'iframe-wrapper' ,
116- style : 'display: flex;justify-content: center;' ,
119+ // style: 'display: flex;justify-content: center;',
117120 } ,
118121 button : ( { editor, t } : any ) => {
119122 return {
@@ -157,6 +160,12 @@ export const Video = /* @__PURE__ */ Node.create<VideoOptions>({
157160 default : this . options . allowFullscreen ,
158161 parseHTML : ( ) => this . options . allowFullscreen ,
159162 } ,
163+ align : {
164+ default : 'center' , // Default alignment
165+ renderHTML : ( { align } ) => ( {
166+ align : align ,
167+ } ) ,
168+ } ,
160169 } ;
161170 } ,
162171
@@ -169,27 +178,35 @@ export const Video = /* @__PURE__ */ Node.create<VideoOptions>({
169178 } ,
170179
171180 renderHTML ( { HTMLAttributes } ) {
172- const { width = '100%' } = HTMLAttributes ?? { } ;
181+ const { width = '100%' , align = 'center' } = HTMLAttributes ?? { } ;
173182
174- const iframeHTMLAttributes = {
183+ const iframeHTMLAttributes = {
175184 ...HTMLAttributes ,
176185 width : '100%' ,
177186 height : '100%' ,
178187 } ;
179188
180189 const responsiveStyle = `position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${ width } ;` ;
181190 const responsiveSizesStyle = `flex: 1;padding-bottom: ${ ( 9 / 16 ) * 100 } %;` ;
191+ const positionStyle = `display: flex; justify-content: ${ align } ;` ;
182192
183193 const iframeDOM = [ 'iframe' , iframeHTMLAttributes ] ;
184194 const sizesDOM = [ 'div' , { style : responsiveSizesStyle } ] ;
185- const responsiveDOM = [ 'div' , { style : responsiveStyle } , sizesDOM , iframeDOM ] ;
195+ const responsiveDOM = [
196+ 'div' ,
197+ { style : responsiveStyle } ,
198+ sizesDOM ,
199+ iframeDOM ,
200+ ] ;
201+ const positionDiv = [ 'div' , { style : positionStyle } , responsiveDOM ] ;
186202
187203 const divAttrs = {
188204 ...this . options . HTMLAttributes ,
205+ class : 'iframe-wrapper' ,
189206 'data-video' : '' ,
190207 } ;
191208
192- return [ 'div' , divAttrs , responsiveDOM ] ;
209+ return [ 'div' , divAttrs , positionDiv ] ;
193210 } ,
194211
195212 addCommands ( ) {
0 commit comments