Yes, but you have to do it Redux- way. Subscribe to post saving action (there are separate actions for save and auto-save) and dispatch a message using dispatch function.
Edit:
Inside blocks, there are better hooks to use, like useSelect. But, outside the block, in general block editor environmentm you have to use subscribe. In subsbscribe you are subscribed to every action dispatched to block editor. Inside the listener function you use wp.data.select to test current state of the store. You want to test isSavingPost and isAutosavingPost selectors.
https://developer.wordpress.org/block-editor/reference-guides
https://developer.wordpress.org/block-editor/reference-guides/data/data-core-editor/#issavingpost/data/data-core-editor/#isautosavingpost
To wrap everything up:
const unsuscribe = wp.data.subscribe(() =>
{
if (wp.data.select('core/editor').isSavingPost() || wp.data.select('core/editor').isAutosavingPost()) {
// your code
}
});
Related Posts:
- lodash dependency in a Gutenberg plugin
- creating elements/innerblocks via rangecontrol
- Looking for callback function after Gutenberg is rendered?
- Gutenberg: useDispatch is not a function – @wordpress/data included
- Make a list with header and subtext in Gutenberg blocks
- Gutenberg – What is the best way to save/update post meta?
- How to prevent UNDO on guternberg block editor
- Do I have to worry about useState causing a re-render?
- Creating a custom Gutenberg block with columns
- Gutenberg: import dependency or assign from global variable?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- Developing the save function in Gutenberg blocks
- Gutenberg – is it ok to load dependencies multiple times?
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- What happens/fires when you select a block in the editor?
- Is “document loaded” different on admin side than public side?
- How to use setAttributes outside of the edit function return
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Reading plugin settings in esnext wordpress block
- How can i add insertion point between inner blocks in my custom block like core blocks
- Reinitiate Gutenburg’s blocks using javascript
- Insert text programmatically in WordPress Gutenberg Editor
- Javascript function defined in view.js not reachable from save.js
- How to move custom gutenberg block controls from settings to styles tab?
- How to use useSelect to retrieve the currently default fontFamily?
- Event when Modal is opened/visible
- useBlockProps() nests wrapper with class name inside block wrapper in the editor
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- How to implement color picker from wordpress in my plugin?
- Add async script
- API to trigger prompt on leaving page
- Using Primary Color in Plugin Block
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- How to Add a .js file Only in one specific Page Dynamically to Head
- How to prevent loading of all plugin’s resources?
- How to trap “Publish” button to check for meta box validation?
- Pass javascript result to shortcode executer function
- Plugin Sidebar is not Saving Meta Attribute to Post/Page after “Update”
- Use js script from one plugin in another plugin
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- What’s the better way to add an inline script?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Gutenberg Block add element in the Editor inside InnerBlocks after div – editor-block-list
- Prevent Javascript Facebook SDK Conflicts in plugin
- how to include javascript file and css file in wordpress
- How do you render_callback for register_block_type to a method in another class?
- Why is my javascript not invoked in my hooks except wp_head?
- WordPress Block Development – trouble importing from @wordpress/icons
- Is there an event or an other method that tells me the preview is loaded?
- How to access noticeOperations from withNotices
- How to get boolean value from register_meta properly?
- jQuery selectors for editor elements safe to use?
- There is a problem in the gutenberg block I developed. Problem is with withInstanceId
- My WordPress plugin cannot load my JavaScript file
- How to only load css for used blocks on frontend
- Additional classes `undefined` after saving post in Gutenberg
- How do you submit a Gutenberg plugin?
- Invalid hook call on save, not edit when using swiper slider
- Proper way to use useSelect
- How to save post meta as an array in Gutenberg?
- Need help about understand api, wp, $ syntax in WordPress plugin script
- WordPress Gutenberg InnerBlocks renderAppender not showing with template
- How to insert HTML/CSS/JS into my iframe plugin?
- Is there a WordPress plugin to design WebGL? [closed]
- How to write a shopping queue line plugin with a queue button?
- Set Button in PluginDocumentSettingPanel Content (WordPress Gutenberg)
- Console errors in 6.0-RC1 Widget screen
- How to use attributes in competent of Gutenberg
- wp.media gallery collection sometimes undefined
- WPGut – Updating failed and shortcode?
- Fixed: Console.log twice in the edit function
- Gutenberg – Call google map render function in save after DOM has been rendered
- Where do I hook to have the server do something in PHP on block attribute change?
- WordPress with React: Saving and Using Data Collected with fetch
- How to get access the ID of all posts of custom post type in Gutenberg editor
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- Uncaught ReferenceError: kpoejy is not defined
- Remove from a div by class name from post page if post author role is not administrator
- On one of my sites a file is shown as 404 but the file IS there
- How react js and other Javascript Technologies works on WordPress plugin?
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Build a dynamic block using the default attributes
- Add custom data-attribute to core Gutenberg block within an template
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- Trouble Importing whatsapp-web.js in a WordPress Plugin Development
- Remove Gutenberg Buttons Block
- Multiple php files in dynamic gutenberg block
- How to detect when the user clicks the publish/update button in Gutenberg Editor
- Gutenberg Static blocks: viewScript doesn’t import css for frontend?
- Output HTML Tags In Gutenberg Block
- Can you nest columns/column in a gutenberg custom template?
- Can we write custom DOM manipulation inside edit.js file while developing custom Gutenberg block?
- User set default settings for a Block in Site Editor
- render_block_context filter and block context inheritance