@@ -17,6 +17,7 @@ import {
1717 InspectorBottomTip ,
1818 AdvancedToggleControl ,
1919 useBlockCssGenerator ,
20+ ControlSeparator ,
2021} from '~stackable/components'
2122import {
2223 BlockDiv ,
@@ -46,6 +47,7 @@ import { InnerBlocks } from '@wordpress/block-editor'
4647import { __ } from '@wordpress/i18n'
4748import { addFilter } from '@wordpress/hooks'
4849import { memo } from '@wordpress/element'
50+ import { DatePicker } from '@wordpress/components'
4951
5052export const defaultIcon = '<svg data-prefix="fas" data-icon="play" class="svg-inline--fa fa-play fa-w-14" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" aria-hidden="true"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg>'
5153
@@ -104,7 +106,9 @@ const Edit = props => {
104106 setAttributes = { setAttributes }
105107 videoLink = { attributes . videoLink }
106108 videoId = { attributes . videoId }
107-
109+ videoName = { attributes . videoName }
110+ videoUploadDate = { attributes . videoUploadDate }
111+ videoDescription = { attributes . videoDescription }
108112 />
109113
110114 { blockCss && < style key = "block-css" > { blockCss } </ style > }
@@ -136,7 +140,7 @@ const InspectorControls = memo( props => {
136140 < InspectorStyleControls >
137141 < PanelAdvancedSettings
138142 title = { __ ( 'General' , i18n ) }
139- id = "general "
143+ id = "video-popup "
140144 initialOpen = { true }
141145 >
142146 < ImageControl2
@@ -146,11 +150,17 @@ const InspectorControls = memo( props => {
146150 onRemove = { ( ) => props . setAttributes ( {
147151 videoLink : '' ,
148152 videoId : '' ,
153+ videoName : '' ,
154+ videoDescription : '' ,
155+ videoUploadDate : '' ,
149156 } ) }
150157 onChange = { media => {
151158 props . setAttributes ( {
152159 videoLink : media . url ,
153160 videoId : media . url ,
161+ videoName : media . title , // Use title, description and date from media library for video schema
162+ videoDescription : media . description ,
163+ videoUploadDate : media . date . toISOString ( ) ,
154164 } )
155165 } }
156166 imageId = { urlIsVideo ( props . videoLink ) ? props . videoId : '' }
@@ -164,10 +174,16 @@ const InspectorControls = memo( props => {
164174 isFormatType = { false }
165175 placeholder = "https://"
166176 value = { ! urlIsVideo ( props . videoLink ) ? props . videoLink : '' }
167- onChange = { videoLink => props . setAttributes ( {
168- videoLink,
169- videoId : getVideoProviderFromURL ( videoLink ) . id ,
170- } ) }
177+ onChange = { videoLink => {
178+ const videoProvider = getVideoProviderFromURL ( videoLink )
179+ props . setAttributes ( {
180+ videoLink,
181+ videoId : videoProvider . id ,
182+ videoName : '' ,
183+ videoDescription : '' ,
184+ videoUploadDate : '' ,
185+ } )
186+ } }
171187 />
172188 { isVideoFile ( props . videoLink ) && < >
173189 < AdvancedToggleControl
@@ -186,6 +202,36 @@ const InspectorControls = memo( props => {
186202 defaultValue = { false }
187203 />
188204 </ > }
205+ { props . videoLink && < >
206+ < ControlSeparator />
207+ < AdvancedTextControl
208+ label = { __ ( 'Video name' , i18n ) }
209+ value = { props . videoName }
210+ onChange = { videoName => props . setAttributes ( { videoName } ) }
211+ />
212+ < AdvancedTextControl
213+ label = { __ ( 'Video description' , i18n ) }
214+ value = { props . videoDescription }
215+ onChange = { videoDescription => props . setAttributes ( { videoDescription } ) }
216+ isMultiline = { true }
217+ />
218+ < AdvancedTextControl
219+ // The date picker below always highlights a date even if there is no `videoUploadDate` attribute
220+ // This text control allows users to see if a date has been set/removed
221+ className = "stk-components-datetime__date-input"
222+ label = { __ ( 'Video upload date' , i18n ) }
223+ value = { props . videoUploadDate ? new Date ( props . videoUploadDate ) . toISOString ( ) . slice ( 0 , 10 ) : '' }
224+ inputType = "date"
225+ readOnly = { true }
226+ />
227+ < DatePicker
228+ currentDate = { props . videoUploadDate }
229+ onChange = { videoUploadDate => {
230+ props . setAttributes ( { videoUploadDate } )
231+ } }
232+ />
233+ </ > }
234+
189235 </ PanelAdvancedSettings >
190236
191237 </ InspectorStyleControls >
0 commit comments