Skip to content

配置

¥Configuration

当 mermaid 启动时,会提取配置以确定要用于图表的配置。有 3 个配置源:

¥When mermaid starts, configuration is extracted to determine a configuration to be used for a diagram. There are 3 sources for configuration:

  • 默认配置

    ¥The default configuration

  • 站点级别的覆盖由初始化调用设置,并将应用于站点/应用中的所有图表。这个术语是 siteConfig。

    ¥Overrides at the site level are set by the initialize call, and will be applied to all diagrams in the site/app. The term for this is the siteConfig.

  • Frontmatter (v10.5.0+) - 图表作者可以更新图表 frontmatter 中选定的配置参数。这些应用于渲染配置。

    ¥Frontmatter (v10.5.0+) - diagram authors can update selected configuration parameters in the frontmatter of the diagram. These are applied to the render config.

  • 指令(已被 Frontmatter 弃用) - 图表作者可以通过指令直接在图表代码中更新选定的配置参数。这些应用于渲染配置。

    ¥Directives (Deprecated by Frontmatter) - diagram authors can update selected configuration parameters directly in the diagram code via directives. These are applied to the render config.

渲染配置是在应用这些配置进行渲染时使用的配置。

¥The render config is configuration that is used when rendering by applying these configurations.

前端配置

¥Frontmatter config

整个 mermaid 配置(安全配置除外)可以由图表作者在图表的 frontmatter 中覆盖。Frontmatter 是图顶部的 YAML 块。

¥The entire mermaid configuration (except the secure configs) can be overridden by the diagram author in the frontmatter of the diagram. The frontmatter is a YAML block at the top of the diagram.

主题配置

¥Theme configuration

开始 Mermaid

¥Starting mermaid

初始化

¥Initialize

初始化调用仅应用一次。它由站点集成商调用,以便覆盖站点级别的默认配置。

¥The initialize call is applied only once. It is called by the site integrator in order to override the default configuration at a site level.

configApi.reset

此方法将图表的配置重置为整体站点配置,这是站点集成商提供的配置。每次绘制图表之前,都会从一开始就调用 reset。

¥This method resets the configuration for a diagram to the overall site configuration, which is the configuration provided by the site integrator. Before each rendering of a diagram, reset is called at the very beginning.