Skip to content

Commit

Permalink
#164 feat (blocks) : JS method to deregister embed blocks + core bloc…
Browse files Browse the repository at this point in the history
…ks variations
  • Loading branch information
francoistibo committed Sep 2, 2021
1 parent 3ee7dfc commit fd608ee
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 28 deletions.
2 changes: 1 addition & 1 deletion config/entries.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
app: ['./src/js/index.js', './src/scss/style.scss'],
editor: ['./src/js/editor.js', './src/scss/editor.scss'],
editor: ['./src/js/editor-script.js', './src/scss/editor-style.scss'],
}
8 changes: 4 additions & 4 deletions inc/Services/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ public function get_min_file( string $type ): string {
$file = $assets['app.css'];
break;
case 'editor-style':
$file = $assets['editor-style.css'];
break;
case 'admin-editor-script':
$file = $assets['gutenberg-editor.js'];
$file = $assets['editor.css'];
break;
case 'js':
$file = $assets['app.js'];
break;
case 'editor-script':
$file = $assets['editor.js'];
break;
default:
$file = null;
break;
Expand Down
85 changes: 85 additions & 0 deletions src/js/editor-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import lazySizes from 'lazysizes'
import 'lazysizes/plugins/native-loading/ls.native-loading'
import 'lazysizes/plugins/object-fit/ls.object-fit'

/**
* LazySizes configuration
* https://github.com/aFarkas/lazysizes/#js-api---options
*/
lazySizes.cfg.nativeLoading = {
setLoadingAttribute: false,
}

// Native Gutenberg
if (typeof wp !== 'undefined') {
wp.domReady(() => {
// Disable block styles

// block image
// wp.blocks.unregisterBlockStyle('core/image', 'rounded')
// wp.blocks.unregisterBlockStyle('core/image', 'default')

// block quote
// wp.blocks.unregisterBlockStyle('core/quote', 'default')
// wp.blocks.unregisterBlockStyle('core/quote', 'large')

// block pullquote
// wp.blocks.unregisterBlockStyle('core/pullquote', 'default')
// wp.blocks.unregisterBlockStyle('core/pullquote', 'solid-color')

// block separator
// wp.blocks.unregisterBlockStyle('core/separator', 'default')
// wp.blocks.unregisterBlockStyle('core/separator', 'wide')
// wp.blocks.unregisterBlockStyle('core/separator', 'dots')

// block table
// wp.blocks.unregisterBlockStyle('core/table', 'regular')
// wp.blocks.unregisterBlockStyle('core/table', 'stripes')

// Disable core embed blocks

var embedVariations = [
// 'amazon-kindle',
// 'animoto',
// 'cloudup',
// 'collegehumor',
// 'crowdsignal',
// 'dailymotion',
// 'facebook',
// 'flickr',
// 'imgur',
// 'instagram',
// 'issuu',
// 'kickstarter',
// 'meetup-com',
// 'mixcloud',
// 'reddit',
// 'reverbnation',
// 'screencast',
// 'scribd',
// 'slideshare',
// 'smugmug',
// 'soundcloud',
// 'speaker-deck',
// 'spotify',
// 'ted',
// 'tiktok',
// 'tumblr',
// 'twitter',
// 'videopress',
// 'vimeo',
// 'wordpress',
// 'wordpress-tv',
// 'youtube'
]

for (var i = embedVariations.length - 1; i >= 0; i--) {
wp.blocks.unregisterBlockVariation('core/embed', embedVariations[i])
}
})
}

// ACF Blocks
if (window.acf) {
// Do stuff
}
23 changes: 0 additions & 23 deletions src/js/editor.js

This file was deleted.

File renamed without changes.

0 comments on commit fd608ee

Please sign in to comment.