My immediate goal is to add a block type that's the same as an existing block type, except for the name. Then I can use CSS to style it appropriately. This would be used (via the block editor) by non-technical folks, so telling them to add a block of the initial type, then go to Advanced -> Additional CSS Class
is not a good idea. I've tried several ways to reach my goal, but come to a roadblock for each, so the question is: is there a simple way, or do I need to create a custom block type from scratch?
(Below attempts are hypothetically in PHP in a plugin, or in some simple JavaScript code.)
First, I thought there would something simple in the API that would directly do what I want. But I didn't see anything.
Then I thought I'd do it myself by getting some block type object, copying and modifying it, then giving that to registerBlockType
. But I couldn't find a function to get info about a block type.
Finally, I thought I'd create a block template out of some container block enclosing the block I wanted to base things off of. Again, CSS could easily be used to make the template look as I desired. But there don't seem to be any suitable container blocks.
The various approaches could be questions in their own right. As often is the case, it's hard to be sure of the best question granularity.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745468745a4629035.html
评论列表(0条)