| 1 |
|
| 2 |
const wpssoBlockEditor = ( function(){ |
| 3 |
|
| 4 |
const pluginId = 'wpsso'; |
| 5 |
const adminPageL10n = 'wpssoAdminPageL10n'; |
| 6 |
const postId = wp.data.select( 'core/editor' ).getCurrentPostId; |
| 7 |
const isSavingMetaBoxes = wp.data.select( 'core/edit-post' ).isSavingMetaBoxes; |
| 8 |
|
| 9 |
var wasSavingMb = false; |
| 10 |
|
| 11 |
sucomBlockEditorNotices( pluginId, adminPageL10n ); // Update the notices on startup. |
| 12 |
|
| 13 |
return { |
| 14 |
|
| 15 |
refreshPostbox: function(){ // Called by wp.data.subscribe(). |
| 16 |
|
| 17 |
var isSavingMb = isSavingMetaBoxes(); // Check if saving metaboxes. |
| 18 |
|
| 19 |
if ( isSavingMb && ! wasSavingMb ) { // Check if starting to save metaboxes. |
| 20 |
|
| 21 |
sucomEditorUnchanged( pluginId, adminPageL10n ); // Disable unchanged fields in 'table.sucom-settings'. |
| 22 |
} |
| 23 |
|
| 24 |
if ( wasSavingMb && ! isSavingMb ) { // Check if done saving metaboxes. |
| 25 |
|
| 26 |
sucomEditorPostbox( pluginId, adminPageL10n, postId ); // Refresh our metabox(es). |
| 27 |
|
| 28 |
sucomBlockEditorNotices( pluginId, adminPageL10n ); // Refresh the block editor and toolbar notices. |
| 29 |
|
| 30 |
sucomToolbarValidators( pluginId, adminPageL10n, postId ); // Refresh the toolbar validators. |
| 31 |
} |
| 32 |
|
| 33 |
wasSavingMb = isSavingMb; |
| 34 |
}, |
| 35 |
} |
| 36 |
})(); |
| 37 |
|
| 38 |
wp.data.subscribe( wpssoBlockEditor.refreshPostbox ); |
| 39 |
|
| 40 |
|