How to make a block similar to another block

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

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

相关推荐

  • How to make a block similar to another block

    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

    2小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信