首页 文章

Gutenberg模板:核心块属性

提问于
浏览
0

古腾堡手册目前有一个简短的条目,用于创建所用的块的整个模板,例如:用于自定义帖子类型等 .

https://wordpress.org/gutenberg/handbook/templates/

它似乎缺少核心/ -Blocks的全面概述 . 特别是可用属性在这里很有趣 . 有没有参考条目,我只是缺少?

详细说明:

通过玩游戏,我发现了一些东西 . 例如 . 预先格式化的块确实采用了php文件的格式,如换行符,indends和tabs,这使得它们有点敏感 .

array( 'core/preformatted', array(
                            'content' => 'Grundlegende Fakten:

Operator: Max Mustermann
Wo: City, Country
Wer: 99999 Kinder
Wieviel: 99999 Angestellte',
                            ) ),

这确实转化为:(请注意,之后的行之前的每个制表符或缩进都会被接管)

Screenshot

那么 - 我还有什么其他可能来修改'内容'和'占位符'属性?我可以利用它们是数组和插入选择器或其他类似html这一事实 . 这不起作用:

array( 'core/preformatted', array(
    'content' => array('selector' => 'h1', 'content' => 'Does this do anything?'),
) ),

..但是这样做:

array( 'core/preformatted', array(
    'content' => array('Does', 'this', 'do', 'anything?'),
) ),

我在哪里可以找到一个完整的一阶属性列表,因为例如,核心/块是否采用“文本”字符串或“内容”数组等并不总是很清楚 .

2 回答

  • 0

    另一个信息来源:

    The Git-Project of Gutenberg holds all core blocks和他们的属性可以访问

    Name-of-Block/index.js

    然后找: const blockAttributes =

  • 0

    部分回答我自己的问题:

    this git issue中所述,您可以使用

    console.log(wp.blocks.getBlockTypes());
    

    在所有Gutenberg魔法加载后(例如在帖子的编辑器窗口中)显示所有当前注册的块,包括它们的属性,在浏览器控制台中 .

    绝对是一个有用的工具!

相关问题