Daniel Richards
Forum Replies Created
-
Forum: Plugins
In reply to: [Gutenberg] Block Manager Embeds Bug@casparpt Thanks for noticing this.
This is due to a change in the way embeds have been implemented. They now use a feature called Block Variations.
I’ve put in a feature request to show these in the Block Manager again:
https://github.com/WordPress/gutenberg/issues/27708- This reply was modified 5 years, 8 months ago by Daniel Richards.
Forum: Plugins
In reply to: [Gutenberg] Gutenberg is not showing elementsGlad you managed to solve it.
Forum: Plugins
In reply to: [Gutenberg] JSON stored in raw wp_content for gutenberg blocks@jrotering The JSON structure you’re seeing is standard in the block editor.
The HTML comment is called a block delimiter, and that comment can also include a JSON object of data. The event organizer block looks like a dynamic block (rendered server-side), so it’s self closing and has no content. When a post is loaded the server-side render callback is triggered to produce the appropriate HTML content.
It’s difficult for me to advise on the given information, but you might consider using the block parser to retrieve data about blocks in a post:
https://github.com/WordPress/gutenberg/tree/master/packages/block-serialization-default-parserForum: Plugins
In reply to: [Gutenberg] Leaving a Gutenberg Page issues@dimalifragis If you or a plugin has enabled custom fields then it can trigger this behavior from what I recall. The problem is that the editor has no way to tell if a change has been made to a custom field, so shows the confirmation always.
I saw you created an issue for the second problem so let’s carry on troubleshooting there:
https://github.com/WordPress/gutenberg/issues/27696Forum: Plugins
In reply to: [Gutenberg] insertBlock Throws Error@nathan888 Here’s the API reference for
insertBlock:
https://developer.wordpress.org/block-editor/data/data-core-block-editor/#insertBlockAs your code snippet isn’t very complete it’s hard to provide feedback, but the error tells me that you’re trying to call something that’s an object as a function, quite possibly when you call
insertBlock. How are you referencinginsertBlock?If you try the following in your browser console, it should work and will hopefully get you started:
wp.data.dispatch( 'core/block-editor' ).insertBlock( wp.blocks.createBlock( 'core/paragraph' ) );If you have experience of
reduxyou might be familiar with dispatch and actions. The ‘core/block-editor’ part is required because the block editor is built in a modular way with multiple data stores, the ‘core/block-editor’ namespace makes sure you’re using the right store.The documentation for wordpress data is pretty long unfortunately:
https://developer.wordpress.org/block-editor/packages/packages-data/There are some other blog posts I found that might be useful:
– https://riad.blog/2018/06/07/efficient-client-data-management-for-wordpress-plugins/
– https://getwithgutenberg.com/2019/05/selecting-and-dispatching-with-the-data-store/But it’s worth noting that they’re a little older, for React components the recommended APIs are now
useSelectanduseDispatch:Forum: Plugins
In reply to: [Gutenberg] No obvious way to exit the editor in full screen modus@hanswitteprins Thanks for the feedback!
Gutenberg uses github as an issue tracker. There was an issue created here which seems similar to your feedback:
https://github.com/WordPress/gutenberg/issues/22178There was also a proposal to make the logo in the top-left corner display the admin side menu when clicked (without leaving the editor):
https://github.com/WordPress/gutenberg/pull/22191But this hasn’t really progressed and was closed. If you have a github account you could consider commenting on the first issue I linked to with your feedback.
Forum: Plugins
In reply to: [Gutenberg] Block templates using Reusable blocks?Can anyone tell me if and how a reusable block can be used in a block template?
You should be able to use a reusable block in a template, but you’d only be able to reference an existing reusable block that you’ve created.
The steps would be:
1. Create the reusable block.
2. Note the id of the reusable block. One way to do this is to go to the ‘Manage all reusable blocks’ page (http://localhost:8888/wp-admin/edit.php?post_type=wp_block), edit the block and grab the post id from the URL. The other is to add the reusable block to a post and switch to the code editor where you’ll be able to see the id next to where it says ‘ref’.
3. In your template add the following to reference your reusable block (if your reusable block id were 123):
array( 'core/block', array( 'ref' => 123 ) )Using the custom post type example from the docs that might look a bit like:
function myplugin_register_book_post_type() { $args = array( 'public' => true, 'label' => 'Books', 'show_in_rest' => true, 'template' => array( array( 'core/block', array( 'ref' => 123, ) ), array( 'core/heading', array( 'placeholder' => 'Add Author...', ) ), array( 'core/paragraph', array( 'placeholder' => 'Add Description...', ) ), ), ); register_post_type( 'book', $args ); } add_action( 'init', 'myplugin_register_book_post_type' );Forum: Alpha/Beta/RC
In reply to: Block editor: Search for url adds one ajax query for each keystrokeThanks for spotting this @zapfcarn. I’ve created a bug report for this:
https://github.com/WordPress/gutenberg/issues/26374Forum: Plugins
In reply to: [Gutenberg] Container Block> it’s not about the usecase of block but it’s about just customizing the html output of block.
@hozefasmile I’d politely disagree. Supporting bootstrap wasn’t a consideration for the group block during development, it’s not how it’s intended to be used. That’s the whole reason your situation exists. You could use a filter to remove the div (there are many block filters: https://developer.wordpress.org/block-editor/developers/filters/block-filters/), but there would always be a chance that future changes to the block would again cause compatibility issues. This is a block that hasn’t even been released yet in WordPress core.
On the other hand, a block from a plugin that’s intended to be used with bootstrap would hopefully be maintained with the goal that it’ll continue to work with bootstrap. You’re less likely to have future compatibility issues, which is why I think that’s the preferable solution to your issue.
Anyway, here’s some further background on why the extra
divwas added:
https://github.com/WordPress/gutenberg/pull/15210There’s also an issue here that looks relevant, though it was probably created before the extra
divwas released:
https://github.com/WordPress/gutenberg/issues/15926It might be worth adding your comment to that issue if you have a github account. I’ve already commented and linked to this forum thread.
Forum: Plugins
In reply to: [Gutenberg] Container Block@hozefasmile Sorry for the delayed response. That’s a shame that bootstrap is no longer supported. I don’t think it was considered to be the main use case of the group block, which is mainly about organising content rather than creating a grid system.
Have you considered looking at blocks on the plugin store? I did a search for ‘bootstrap grid block’ and it looks like there are a couple of plugins that might support your needs.
Forum: Plugins
In reply to: [Gutenberg] Container BlockHi @hozefasmile, the group block will be a bit like a single column. It has some additional features that set it apart from a column like the ability to set a background color, and also a few more planned (the ability to group a selection of blocks using a keyboard shortcut or menu option, possibly background images). The alignment options should also behave slightly differently, when aligning the block to full width, content should stay narrow (if the theme supports it).
Forum: Fixing WordPress
In reply to: Can’t add new images to gallery block from media libraryHi @moxie, there is a way to do this. If you click the pencil icon on the toolbar of the gallery block the media library interface is shown in a popover. On the left-hand side there’s an option ‘Add to Gallery’ which lets you choose existing images from the media library.
My understanding is that in WordPress 5.3 this will become clearer—there will be a ‘Media Library’ button at the bottom of the gallery block for selecting images from your library.
Forum: Plugins
In reply to: [Gutenberg] How to remove band from top and bottom of main site area?@memerunner This looks like it’s part of the theme you’re using rather than something to do with Gutenberg. The
margin-topisn’t responsible, the gap is caused by padding added tosite-innervia a stylesheet.You could override it in the Appearance > Customize > Additional CSS screen using a rule like:
.site-container .site-inner { padding: 0; }- This reply was modified 7 years, 3 months ago by Daniel Richards.
Forum: Developing with WordPress
In reply to: Pass block attributes without rerending treeHi @spuds10,
When you mention Redux, I guess you’re talking about optimizations within the
connectfunction from React-Redux, which I believe will prevent child component re-rendering if it detects no changes to the calculated props.There are various data modules within Gutenberg that are exposed to implementors, but as far as I know, none of them are really built specifically to help block builders with performance. There are some API docs in the handbook:
Gutenberg Handbook | Data Module ReferenceI personally wouldn’t consider 16+ components a lot unless you’re doing something computationally expensive. If you’re particularly concerned about performance I’d recommend using
React.memoorPureComponentto prevent re-renders, and only pass individual attributes through to your child components as props to aid with the memoization:
https://reactjs.org/docs/react-api.html#reactpurecomponentBuilding your own higher-order-component to help with this could also be an option.
- This reply was modified 7 years, 3 months ago by Daniel Richards.
Hi @jjbte, hopefully I’m understanding the problem correctly. I think some of the core dynamic blocks have a similar problem and a solution.
The archives block seems like it might be similar use case. It uses the
ServerSideRendercomponent to display the archives in the editor. However clicking on one of the archives there would cause the user to be navigated out of the editor and to that archive, which is undesirable.The solution there was to use the
Disabledcomponent (wp.components.Disabled) to wrapServerSideRender, which makes it so that the output from the server can’t be interacted with in the editor:
https://github.com/WordPress/gutenberg/blob/5494bc57fc77de6cada4295823a3fb047e168f89/packages/block-library/src/archives/edit.js#L32-L34- This reply was modified 7 years, 3 months ago by Daniel Richards.