1+ /* global BFFEditorSettings */
2+
3+ /* Customize BFFEditorSettings in inc/Services/Editor.php or with `bff_editor_custom_settings` filter (see readme). */
4+
15import lazySizes from 'lazysizes'
26import 'lazysizes/plugins/native-loading/ls.native-loading'
37import 'lazysizes/plugins/object-fit/ls.object-fit'
@@ -15,14 +19,23 @@ lazySizes.cfg.nativeLoading = {
1519
1620// Native Gutenberg
1721domReady ( ( ) => {
18- unregisterBlockStyle ( 'core/separator' , [ 'wide' , 'dots' ] )
19- // whitelist core embeds
20- const allowedEmbedVariants = [ 'youtube' , 'vimeo' , 'dailymotion' ]
21- getBlockVariations ( 'core/embed' ) . forEach ( ( variant ) => {
22- if ( ! allowedEmbedVariants . includes ( variant . name ) ) {
23- unregisterBlockVariation ( 'core/embed' , variant . name )
24- }
25- } )
22+ // Disable specific block styles
23+ if ( BFFEditorSettings . disabledBlocksStyles ) {
24+ Object . entries ( BFFEditorSettings . disabledBlocksStyles ) . forEach ( ( [ block , styles ] ) => {
25+ unregisterBlockStyle ( block , styles )
26+ } )
27+ }
28+
29+ // Allow blocks variations
30+ if ( BFFEditorSettings . allowedBlocksVariations ) {
31+ Object . entries ( BFFEditorSettings . allowedBlocksVariations ) . forEach ( ( [ block , variations ] ) => {
32+ getBlockVariations ( block ) . forEach ( ( variant ) => {
33+ if ( ! variations . includes ( variant . name ) ) {
34+ unregisterBlockVariation ( block , variant . name )
35+ }
36+ } )
37+ } )
38+ }
2639} )
2740
2841// ACF Blocks
@@ -31,22 +44,9 @@ if (window.acf) {
3144}
3245
3346addFilter ( 'blocks.registerBlockType' , 'beapi-framework' , function ( settings , name ) {
34- if ( name === 'core/paragraph' ) {
35- settings . example . attributes . dropCap = false
36- }
37-
38- if ( name === 'core/separator' || name === 'core/quote' || name === 'core/pullquote' || name === 'core/table' ) {
39- // remove custom styles
40- settings . styles = [ ]
41- }
42-
43- if ( name === 'core/image' ) {
44- // remove custom styles
47+ // Disable all styles
48+ if ( BFFEditorSettings . disableAllBlocksStyles && BFFEditorSettings . disableAllBlocksStyles . includes ( name ) ) {
4549 settings . styles = [ ]
46- // set default aligment for images to null
47- settings . attributes . align = {
48- type : 'string' ,
49- }
5050 }
5151
5252 return settings
0 commit comments