块编辑器开发文档

NUX(新用户体验)数据

💡 云策文档标注

概述

本文档介绍了 WordPress 核心中 NUX(新用户体验)数据的相关功能,包括选择器和动作,用于管理用户引导提示和指南的显示状态。

关键要点

  • 选择器:提供状态查询功能,如检查提示是否全局启用、获取关联指南信息、判断提示是否可见。
  • 动作:包括禁用提示、关闭提示、启用提示和触发指南,用于控制提示的显示和用户引导流程。
  • 参数和返回值:详细说明了每个函数所需的参数(如状态对象、提示ID)和返回类型(如布尔值、对象)。

📄 原文内容

Namespace: core/nux.

Selectors

areTipsEnabled

Returns whether or not tips are globally enabled.

Parameters

  • state Object: Global application state.

Returns

  • boolean: Whether tips are globally enabled.

getAssociatedGuide

Returns an object describing the guide, if any, that the given tip is a part of.

Parameters

  • state Object: Global application state.
  • tipId string: The tip to query.

Returns

  • ?NUXGuideInfo: Information about the associated guide.

isTipVisible

Determines whether or not the given tip is showing. Tips are hidden if they are disabled, have been dismissed, or are not the current tip in any guide that they have been added to.

Parameters

  • state Object: Global application state.
  • tipId string: The tip to query.

Returns

  • boolean: Whether or not the given tip is showing.

Actions

disableTips

Returns an action object that, when dispatched, prevents all tips from showing again.

Returns

  • Object: Action object.

dismissTip

Returns an action object that, when dispatched, dismisses the given tip. A dismissed tip will not show again.

Parameters

  • id string: The tip to dismiss.

Returns

  • Object: Action object.

enableTips

Returns an action object that, when dispatched, makes all tips show again.

Returns

  • Object: Action object.

triggerGuide

Returns an action object that, when dispatched, presents a guide that takes the user through a series of tips step by step.

Parameters

  • tipIds string[]: Which tips to show in the guide.

Returns

  • Object: Action object.