11/**
22 * Block
33 *
4- * @package
4+ * @package cloudflare-stream
55 */
66
77// Import CSS.
@@ -19,7 +19,7 @@ import { streamIframeSource } from './lib';
1919/* Deprecated version of block */
2020import { deprecated_108 } from './deprecated_108' ;
2121
22- const { __ } = wp . i18n ; // Import __() from wp.i18n.
22+ const { __ } = wp . i18n ; // Import __() from wp.i18n.
2323const { registerBlockType } = wp . blocks ; // Import registerBlockType() from wp.blocks.
2424
2525/**
@@ -33,12 +33,18 @@ cloudflareStream.icon = wp.element.createElement(
3333 viewBox : '0 0 68.66 49.14' ,
3434 className : 'cls-1 dashicon' ,
3535 } ,
36- wp . element . createElement ( 'path' , {
37- d : 'M61.05,42.28H1.75A.76.76,0,0,1,1,41.52V1.73A.75.75,0,0,1,1.75,1h59.3a.75.75,0,0,1,.76.75V41.52A.76.76,0,0,1,61.05,42.28ZM2.51,40.77H60.3V2.49H2.51Z' ,
38- } ) ,
39- wp . element . createElement ( 'path' , {
40- d : 'M45.6,26.09,31.44,17.91a1.17,1.17,0,0,0-1.19-.09,1.19,1.19,0,0,0-.51,1.07V35.25a1.17,1.17,0,0,0,.51,1.06.91.91,0,0,0,.48.13,1.41,1.41,0,0,0,.71-.21L45.6,28.05a1.05,1.05,0,0,0,0-2ZM65.13,48.14H7.86a2.52,2.52,0,0,1-2.52-2.52V7.86A2.52,2.52,0,0,1,7.86,5.34H65.13a2.52,2.52,0,0,1,2.53,2.52V45.62A2.52,2.52,0,0,1,65.13,48.14Zm-56.77-3H64.63V8.36H8.36Z' ,
41- } )
36+ wp . element . createElement (
37+ 'path' ,
38+ {
39+ d : 'M61.05,42.28H1.75A.76.76,0,0,1,1,41.52V1.73A.75.75,0,0,1,1.75,1h59.3a.75.75,0,0,1,.76.75V41.52A.76.76,0,0,1,61.05,42.28ZM2.51,40.77H60.3V2.49H2.51Z' ,
40+ }
41+ ) ,
42+ wp . element . createElement (
43+ 'path' ,
44+ {
45+ d : 'M45.6,26.09,31.44,17.91a1.17,1.17,0,0,0-1.19-.09,1.19,1.19,0,0,0-.51,1.07V35.25a1.17,1.17,0,0,0,.51,1.06.91.91,0,0,0,.48.13,1.41,1.41,0,0,0,.71-.21L45.6,28.05a1.05,1.05,0,0,0,0-2ZM65.13,48.14H7.86a2.52,2.52,0,0,1-2.52-2.52V7.86A2.52,2.52,0,0,1,7.86,5.34H65.13a2.52,2.52,0,0,1,2.53,2.52V45.62A2.52,2.52,0,0,1,65.13,48.14Zm-56.77-3H64.63V8.36H8.36Z' ,
46+ }
47+ )
4248) ;
4349
4450/**
@@ -55,109 +61,118 @@ cloudflareStream.icon = wp.element.createElement(
5561 * registered; otherwise `undefined`.
5662 */
5763// phpcs:disable Generic.WhiteSpace.ScopeIndent.IncorrectExact,Generic.WhiteSpace.ScopeIndent.Incorrect
58- registerBlockType ( 'cloudflare-stream/block-video' , {
59- title : __ ( 'Cloudflare Stream Video' , 'cloudflare-stream' ) ,
60- icon : cloudflareStream . icon ,
61- render_callback : 'cloudflare_stream_render_block' ,
62- category : 'embed' ,
63- keywords : [
64- __ ( 'Cloudflare' , 'cloudflare-stream' ) ,
65- __ ( 'Stream' , 'cloudflare-stream' ) ,
66- __ ( 'video' , 'cloudflare-stream' ) ,
67- ] ,
68- deprecated : [ deprecated_108 ] ,
69- attributes : {
70- alignment : {
71- type : 'string' ,
72- } ,
73- uid : {
74- type : 'string' ,
75- default : false ,
76- } ,
77- fingerprint : {
78- type : 'string' ,
79- default : false ,
80- } ,
81- thumbnail : {
82- type : 'string' ,
83- default : false ,
84- } ,
85- autoplay : {
86- type : 'boolean' ,
87- default : false ,
88- } ,
89- loop : {
90- type : 'boolean' ,
91- default : false ,
92- } ,
93- muted : {
94- type : 'boolean' ,
95- default : false ,
96- } ,
97- controls : {
98- type : 'boolean' ,
99- default : true ,
64+ registerBlockType (
65+ 'cloudflare-stream/block-video' ,
66+ {
67+ title : __ ( 'Cloudflare Stream Video' , 'cloudflare-stream' ) ,
68+ icon : cloudflareStream . icon ,
69+ render_callback : 'cloudflare_stream_render_block' ,
70+ category : 'embed' ,
71+ keywords : [
72+ __ ( 'Cloudflare' , 'cloudflare-stream' ) ,
73+ __ ( 'Stream' , 'cloudflare-stream' ) ,
74+ __ ( 'video' , 'cloudflare-stream' ) ,
75+ ] ,
76+ deprecated : [ deprecated_108 ] ,
77+ attributes : {
78+ alignment : {
79+ type : 'string' ,
80+ } ,
81+ uid : {
82+ type : 'string' ,
83+ default : false ,
84+ } ,
85+ fingerprint : {
86+ type : 'string' ,
87+ default : false ,
88+ } ,
89+ thumbnail : {
90+ type : 'string' ,
91+ default : false ,
92+ } ,
93+ autoplay : {
94+ type : 'boolean' ,
95+ default : false ,
96+ } ,
97+ loop : {
98+ type : 'boolean' ,
99+ default : false ,
100+ } ,
101+ muted : {
102+ type : 'boolean' ,
103+ default : false ,
104+ } ,
105+ controls : {
106+ type : 'boolean' ,
107+ default : true ,
108+ } ,
109+ transform : {
110+ type : 'boolean' ,
111+ default : false ,
112+ } ,
100113 } ,
101- transform : {
102- type : 'boolean' ,
103- default : false ,
114+ supports : {
115+ align : true ,
104116 } ,
105- } ,
106- supports : {
107- align : true ,
108- } ,
109117
110- /**
111- * The edit function describes the structure of your block in the context of the editor.
112- * This represents what the editor will render when the block is used.
113- *
114- * The "edit" property must be a valid function.
115- *
116- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
117- */
118- edit,
118+ /**
119+ * The edit function describes the structure of your block in the context of the editor.
120+ * This represents what the editor will render when the block is used.
121+ *
122+ * The "edit" property must be a valid function.
123+ *
124+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
125+ */
126+ edit,
119127
120- /**
121- * The save function defines the way in which the different attributes should be combined
122- * into the final markup, which is then serialized by Gutenberg into post_content.
123- *
124- * The "save" property must be specified and must be a valid function.
125- *
126- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
127- * @param {Object } props Block Properties.
128- * @return {Object } A WordPress block.
129- */
130- save ( props ) {
131- const { uid, controls, autoplay, loop, muted, className } =
132- props . attributes ;
133- if ( uid !== false ) {
134- // Create block UI using WordPress createElement.
128+ /**
129+ * The save function defines the way in which the different attributes should be combined
130+ * into the final markup, which is then serialized by Gutenberg into post_content.
131+ *
132+ * The "save" property must be specified and must be a valid function.
133+ *
134+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
135+ * @param {Object } props Block Properties.
136+ * @return {Object } A WordPress block.
137+ */
138+ save ( props ) {
139+ const { uid, controls, autoplay, loop, muted, className } =
140+ props . attributes ;
141+ if ( uid !== false ) {
142+ // Create block UI using WordPress createElement.
143+ return wp . element . createElement (
144+ 'figure' ,
145+ {
146+ className,
147+ key : uid ,
148+ } ,
149+ [
150+ wp . element . createElement (
151+ 'div' ,
152+ {
153+ className : 'player-wrapper' ,
154+ } ,
155+ [
156+ wp . element . createElement (
157+ 'iframe' ,
158+ {
159+ className : 'player-frame' ,
160+ src : streamIframeSource ( props . attributes ) ,
161+ allow : 'accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;' ,
162+ allowfullscreen : 'true' ,
163+ }
164+ ) ,
165+ ]
166+ ) ,
167+ ]
168+ ) ;
169+ }
135170 return wp . element . createElement (
136171 'figure' ,
137172 {
138173 className,
139- key : uid ,
140- } ,
141- [
142- wp . element . createElement (
143- 'div' ,
144- {
145- className : 'player-wrapper' ,
146- } ,
147- [
148- wp . element . createElement ( 'iframe' , {
149- className : 'player-frame' ,
150- src : streamIframeSource ( props . attributes ) ,
151- allow : 'accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;' ,
152- allowfullscreen : 'true' ,
153- } ) ,
154- ]
155- ) ,
156- ]
174+ }
157175 ) ;
158- }
159- return wp . element . createElement ( 'figure' , {
160- className,
161- } ) ;
162- } ,
163- } ) ;
176+ } ,
177+ }
178+ ) ;
0 commit comments