admin管理员组文章数量:1316616
I am trying to rebuild core/image block to add extra link in the caption, which would be a link to the extended description of object in the image on another page.
This requires both modifying block edit interface, as well as saved markup. So I opted to take core/image block from github (and necessary dependency in embed folder).
After little modifying of block (removing unneded exports in index.js of the block and adding registerBlock - because block registering for Gutenberg is done for all core blocks in single js file), block compiles fine. However, in the Wordpress Gutenberg editor, block throws an error. Error is:
Uncaught TypeError: Object(...) is not a function
I tracked down error to useBlockProps hook, which is undefined in javascript, although it is imported before (import { BlockAlignmentToolbar, BlockControls, BlockIcon, MediaPlaceholder, useBlockProps } from '@wordpress/block-editor';
) I am using @wordpress/create-block scaffold and mentioned imports resolve through webpack.
Why am I getting an error an how to fix it?
I am trying to rebuild core/image block to add extra link in the caption, which would be a link to the extended description of object in the image on another page.
This requires both modifying block edit interface, as well as saved markup. So I opted to take core/image block from github (and necessary dependency in embed folder).
After little modifying of block (removing unneded exports in index.js of the block and adding registerBlock - because block registering for Gutenberg is done for all core blocks in single js file), block compiles fine. However, in the Wordpress Gutenberg editor, block throws an error. Error is:
Uncaught TypeError: Object(...) is not a function
I tracked down error to useBlockProps hook, which is undefined in javascript, although it is imported before (import { BlockAlignmentToolbar, BlockControls, BlockIcon, MediaPlaceholder, useBlockProps } from '@wordpress/block-editor';
) I am using @wordpress/create-block scaffold and mentioned imports resolve through webpack.
Why am I getting an error an how to fix it?
Share Improve this question asked Dec 7, 2020 at 13:52 LovorLovor 9969 silver badges16 bronze badges1 Answer
Reset to default 0I discovered that I used master branch of github where I took core/image block source. Obviously, useBlockProps is yet not part of the core (or not implemented in @wordpress/create-blocks webpack setup).
After switching to wordpress 5.5 Gutenberg branch version of image block, everything was fine.
本文标签: Rebuilding core image block
版权声明:本文标题:Rebuilding core image block 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741934506a2405771.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论