-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy patheditor.js
42 lines (35 loc) · 1.27 KB
/
editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* global BFFEditorSettings */
/* Customize BFFEditorSettings in inc/Services/Editor.php or with `bff_editor_custom_settings` filter (see readme). */
import domReady from '@wordpress/dom-ready'
import { addFilter } from '@wordpress/hooks'
import { unregisterBlockStyle, getBlockVariations, unregisterBlockVariation } from '@wordpress/blocks'
// Native Gutenberg
domReady(() => {
// Disable specific block styles
if (BFFEditorSettings.disabledBlocksStyles) {
Object.entries(BFFEditorSettings.disabledBlocksStyles).forEach(([block, styles]) => {
unregisterBlockStyle(block, styles)
})
}
// Allow blocks variations
if (BFFEditorSettings.allowedBlocksVariations) {
Object.entries(BFFEditorSettings.allowedBlocksVariations).forEach(([block, variations]) => {
getBlockVariations(block).forEach((variant) => {
if (!variations.includes(variant.name)) {
unregisterBlockVariation(block, variant.name)
}
})
})
}
})
// ACF Blocks
if (window.acf) {
// Do stuff
}
addFilter('blocks.registerBlockType', 'beapi-framework', function (settings, name) {
// Disable all styles
if (BFFEditorSettings.disableAllBlocksStyles && BFFEditorSettings.disableAllBlocksStyles.includes(name)) {
settings.styles = []
}
return settings
})