为导航添加子菜单。
块关系
父级块(直接):
– core/navigation
属性
通过 block.json 中的 attributes 属性定义。
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
label | string | — | 角色:content |
type | string | — | — |
description | string | — | — |
rel | string | — | — |
id | number | — | — |
opensInNewTab | boolean | false | — |
url | string | — | 角色:content |
title | string | — | — |
kind | string | — | — |
isTopLevelItem | boolean | — | — |
isParentSubmenu | boolean | true | — |
支持功能
通过 block.json 中的 supports 属性定义。
anchor:truereusable:falsehtml:falsetypography:fontSize:truelineHeight:true
shadow:trueinteractivity:clientNavigation:true
上下文
通过 block.json 中的 usesContext 和 providesContext 属性定义。
使用的上下文:
textColorcustomTextColorbackgroundColorcustomBackgroundColoroverlayTextColorcustomOverlayTextColoroverlayBackgroundColorcustomOverlayBackgroundColorfontSizecustomFontSizeshowSubmenuIconmaxNestingLevelopenSubmenusOnClicksubmenuVisibilitystyle
提供的上下文:
core/isInsideSubmenu→ 属性isParentSubmenu
CSS 选择器
通过 block.json 中的 selectors 属性定义。
- 阴影:
.wp-block-navigation-submenu > .wp-block-navigation__submenu-container
块标记
这是一个 混合块。它保存静态标记,服务器在渲染时可能会对其进行增强。
<!-- wp:navigation-submenu {"label":"A fine submenu","isTopLevelItem":true} -->
<!-- wp:navigation-link {"label":"WordPress","url":"https://wordpress.org/"} -->
<!-- /wp:navigation-link -->
<!-- /wp:navigation-submenu -->
来源
- block.json (参考)
- 源代码目录 — 浏览
edit和save源文件、index.php等。