### `core/edit-post` 存储库 私有选择器: - `getEditedPostTemplateId` ## edit-site ### `core/edit-site` 存储库 私有操作: - `registerRoute` - `setEditorCanvasContainerView` 私有选择器: - `getRoutes` - `getEditorCanvasContainerView` # Gutenberg 私有 API 本文概述了 Gutenberg 包暴露的私有 API。这些 API 用于实现 Gutenberg 编辑器(文章编辑器、站点编辑器、核心区块及其他功能)的组成部分,但未向插件和主题开发者或自定义 Gutenberg 集成的开发者公开。 本文档旨在展示我们拥有多少私有 API,以及如何利用 `@wordpress/*` 系列包提供的库和框架来构建 Gutenberg 编辑器应用。 ## data 注册器包含两个私有方法: - `privateActionsOf` - `privateSelectorsOf` 每个存储库均提供用于注册私有选择器/操作的私有 API: - `privateActions` - `registerPrivateActions` - `privateSelectors` - `registerPrivateSelectors` ## blocks ### `core/blocks` 存储库 私有操作: - `addBlockBindingsSource` - `removeBlockBindingsSource` - `addBootstrappedBlockType` - `addUnprocessedBlockType` 私有选择器: - `getAllBlockBindingsSources` - `getBlockBindingsSource` - `getBootstrappedBlockType` - `getSupportedStyles` - `getUnprocessedBlockTypes` - `hasContentRoleAttribute` ## components 私有导出项: - `__experimentalPopoverLegacyPositionToPlacement` - `ComponentsContext` - `Tabs` - `Theme` - `Menu` - `kebabCase` ## commands 私有导出项: - `useCommandContext`(2023 年 5 月通过 #50543 添加) ### `core/commands` 存储库 私有操作: - `setContext`(与 `useCommandContext` 同时添加) ## preferences 私有导出项(2024 年 1 月通过 #57639 添加): - `PreferenceBaseOption` - `PreferenceToggleControl` - `PreferencesModal` - `PreferencesModalSection` - `PreferencesModalTabs` 仅有一个公开导出的组件! - `PreferenceToggleMenuItem` ## block-editor 私有导出项: - `AdvancedPanel` - `BackgroundPanel` - `BorderPanel` - `ColorPanel` - `DimensionsPanel` - `FiltersPanel` - `GlobalStylesContext` - `ImageSettingsPanel` - `TypographyPanel` - `areGlobalStyleConfigsEqual` - `getBlockCSSSelector` - `getBlockSelectors` - `getGlobalStylesChanges` - `getLayoutStyles` - `toStyles` - `useGlobalSetting` - `useGlobalStyle` - `useGlobalStylesOutput` - `useGlobalStylesOutputWithConfig` - `useGlobalStylesReset` - `useHasBackgroundPanel` - `useHasBorderPanel` - `useHasBorderPanelControls` - `useHasColorPanel` - `useHasDimensionsPanel` - `useHasFiltersPanel` - `useHasImageSettingsPanel` - `useHasTypographyPanel` - `useSettingsForBlockElement` - `ExperimentalBlockCanvas`:公共 `BlockCanvas` 的变体,包含多个额外属性:`contentRef`、`shouldIframe`、`iframeProps`。 - `ExperimentalBlockEditorProvider`:公共 `BlockEditorProvider` 的变体,过滤掉若干私有/实验性设置。另请参阅 `__experimentalUpdateSettings`。 - `getDuotoneFilter` - `getRichTextValues` - `PrivateQuickInserter` - `extractWords` - `getNormalizedSearchTerms` - `normalizeString` - `PrivateListView` - `ResizableBoxPopover` - `BlockInfo` - `useHasBlockToolbar` - `cleanEmptyObject` - `BlockQuickNavigation` - `LayoutStyle` - `BlockRemovalWarningModal` - `useLayoutClasses` - `useLayoutStyles` - `DimensionsTool` - `ResolutionTool` - `TabbedSidebar` - `TextAlignmentControl` - `usesContextKey` - `useFlashEditableBlocks` - `useZoomOut` - `globalStylesDataKey` - `globalStylesLinksDataKey` - `selectBlockPatternsKey` - `requiresWrapperOnCopy` - `PrivateRichText`:额外属性 `readOnly` 于 #58916 和 #60327(2024 年 2 月和 3 月)添加。 - `PrivateInserterLibrary`:额外属性 `onPatternCategorySelection` 于 #62130(2024 年 5 月)添加。 - `reusableBlocksSelectKey` - `PrivateBlockPopover`:包含两个额外属性 `__unstableContentRef` 和 `__unstablePopoverSlot`。 - `PrivatePublishDateTimePicker`:公共 `PublishDateTimePicker` 的变体,包含两个额外属性:`isCompact` 和 `showPopoverHeaderActions`。 - `useSpacingSizes` - `useBlockDisplayTitle` - `__unstableBlockStyleVariationOverridesWithConfig` - `setBackgroundStyleDefaults` - `sectionRootClientIdKey` - `__unstableCommentIconFill` - `__unstableCommentIconToolbarFill` ### `core/block-editor` 存储库 私有操作: - `__experimentalUpdateSettings`:公共 `updateSettings` 操作的实验版本,用于过滤部分私有/实验性设置。 - `clearBlockRemovalPrompt`:清除区块移除提示 - `deleteStyleOverride`:删除样式覆盖 - `ensureDefaultBlock`:确保默认区块存在 - `expandBlock`:展开区块 - `hideBlockInterface`:隐藏区块界面 - `modifyContentLockBlock`:修改内容锁定区块 - `privateRemoveBlocks`:私有移除区块 - `resetZoomLevel`:重置缩放级别 - `setBlockRemovalRules`:设置区块移除规则 - `setInsertionPoint`:设置插入点 - `setLastFocus`:设置最后焦点 - `setOpenedBlockSettingsMenu`:设置已打开的区块设置菜单 - `setStyleOverride`:设置样式覆盖 - `setZoomLevel`:设置缩放级别 - `showBlockInterface`:显示区块界面 - `startDragging`:开始拖拽 - `stopDragging`:停止拖拽 - `stopEditingAsBlocks`:停止以区块形式编辑 私有选择器: - `getAllPatterns`:获取所有模式 - `getBlockRemovalRules`:获取区块移除规则 - `getBlockSettings`:获取区块设置 - `getBlockStyles`:获取区块样式 - `getBlockWithoutAttributes`:获取无属性区块 - `getClosestAllowedInsertionPoint`:获取最近允许插入点 - `getClosestAllowedInsertionPointForPattern`:获取模式最近允许插入点 - `getContentLockingParent`:获取内容锁定父级 - `getEnabledBlockParents`:获取启用区块父级 - `getEnabledClientIdsTree`:获取启用的客户端ID树 - `getExpandedBlock`:获取已展开区块 - `getInserterMediaCategories`:获取插入器媒体分类 - `getInsertionPoint`:获取插入点 - `getLastFocus`:获取最后焦点 - `getLastInsertedBlocksClientIds`:获取最后插入区块客户端ID - `getOpenedBlockSettingsMenu`:获取已打开区块设置菜单 - `getParentSectionBlock`:获取父级区块区域 - `getPatternBySlug`:通过别名获取模式 - `getRegisteredInserterMediaCategories`:获取已注册插入器媒体分类 - `getRemovalPromptData`:获取移除提示数据 - `getReusableBlocks`:获取可重用区块 - `getSectionRootClientId`:获取区域根客户端ID - `getStyleOverrides`:获取样式覆盖 - `getTemporarilyEditingAsBlocks`:获取临时以区块形式编辑状态 - `getTemporarilyEditingFocusModeToRevert`:获取待恢复的临时编辑焦点模式 - `getZoomLevel`:获取缩放级别 - `hasAllowedPatterns`:检查是否存在允许模式 - `isBlockInterfaceHidden`:检查区块界面是否隐藏 - `isBlockSubtreeDisabled`:检查区块子树是否禁用 - `isDragging`:检查是否正在拖拽 - `isResolvingPatterns`:检查是否正在解析模式 - `isSectionBlock`:检查是否为区域区块 - `isZoomOut`:检查是否处于缩小状态 ## core-data 私有导出: - `useEntityRecordsWithPermissions`:带权限的实体记录钩子 ### `core` 存储库 私有操作: - `receiveRegisteredPostMeta`:接收已注册文章元数据 - `editMediaEntity`:编辑媒体实体 私有选择器: - `getBlockPatternsForPostType`:获取文章类型区块模式 - `getEntityRecordPermissions`:获取实体记录权限 - `getEntityRecordsPermissions`:获取实体记录集权限 - `getNavigationFallbackId`:获取导航回退ID - `getRegisteredPostMeta`:获取已注册文章元数据 - `getUndoManager`:获取撤销管理器 ## patterns(2023年8月创建的包,无公开导出,所有内容均为私有) 私有导出: - `OverridesPanel`:覆盖面板 - `CreatePatternModal`:创建模式模态框 - `CreatePatternModalContents`:创建模式模态框内容 - `DuplicatePatternModal`:复制模式模态框 - `isOverridableBlock`:检查是否为可覆盖区块 - `hasOverridableBlocks`:检查是否存在可覆盖区块 - `useDuplicatePatternProps`:复制模式属性钩子 - `RenamePatternModal`:重命名模式模态框 - `PatternsMenuItems`:模式菜单项 - `RenamePatternCategoryModal`:重命名模式分类模态框 - `PatternOverridesControls`:模式覆盖控件 - `ResetOverridesControl`:重置覆盖控件 - `PatternOverridesBlockControls`:模式覆盖区块控件 - `useAddPatternCategory`:添加模式分类钩子 - `PATTERN_TYPES`:模式类型 - `PATTERN_DEFAULT_CATEGORY`:模式默认分类 - `PATTERN_USER_CATEGORY`:模式用户分类 - `EXCLUDED_PATTERN_SOURCES`:排除的模式来源 - `PATTERN_SYNC_TYPES`:模式同步类型 - `PARTIAL_SYNCING_SUPPORTED_BLOCKS`:支持部分同步的区块 ### `core/patterns` 存储库 私有操作: - `convertSyncedPatternToStatic`:将同步模式转换为静态 - `createPattern`:创建模式 - `createPatternFromFile`:从文件创建模式 - `setEditingPattern`:设置编辑模式 私有选择器: - `isEditingPattern`:检查是否正在编辑模式 ## block-library 私有导出: - `BlockKeyboardShortcuts`:区块键盘快捷键 ## router(仅私有导出) 私有导出: - `useHistory`:历史记录钩子 - `useLocation`:位置钩子 - `RouterProvider`:路由提供者 ## core-commands(仅私有导出) 私有导出: - `useCommands`:命令钩子 ## editor 私有导出: - `CreateTemplatePartModal`:创建模板部件模态框 - `BackButton`:返回按钮 - `EntitiesSavedStatesExtensible`:可扩展实体保存状态 - `Editor`:编辑器 - `EditorContentSlotFill`:编辑器内容插槽填充 - `GlobalStylesProvider`:全局样式提供者 - `mergeBaseAndUserConfigs`:合并基础与用户配置 - `PluginPostExcerpt`:插件文章摘要 - `PostCardPanel`:文章卡片面板 - `PreferencesModal`:偏好设置模态框 - `usePostActions`:文章操作钩子 - `ToolsMoreMenuGroup`:工具更多菜单组 - `ViewMoreMenuGroup`:视图更多菜单组 - `ResizableEditor`:可调整大小编辑器 - `registerCoreBlockBindingsSources`:注册核心区块绑定源 - `interfaceStore`:界面存储库 - `ActionItem`:操作项 - `ComplementaryArea`:补充区域 - `ComplementaryAreaMoreMenuItem`:补充区域更多菜单项 - `FullscreenMode`:全屏模式 - `InterfaceSkeleton`:界面骨架 - `PinnedItems`:固定项目 ### `core/editor` 存储库 私有操作: - `createTemplate`:创建模板 - `hideBlockTypes`:隐藏区块类型 - `registerEntityAction`:注册实体操作 - `registerPostTypeActions`:注册文章类型操作 - `removeTemplates`:移除模板 - `revertTemplate`:恢复模板 - `saveDirtyEntities`:保存未保存实体 - `setCurrentTemplateId`:设置当前模板ID - `setIsReady`:设置就绪状态 - `showBlockTypes`:显示区块类型 - `unregisterEntityAction`:取消注册实体操作 私有选择器: - `getEntityActions`:获取实体操作 - `getInserter`:获取插入器 - `getInserterSidebarToggleRef`:获取插入器侧边栏切换引用 - `getListViewToggleRef`:获取列表视图切换引用 - `getPostBlocksByName`:通过名称获取文章区块 - `getPostIcon`:获取文章图标 - `hasPostMetaChanges`:检查文章元数据是否有变更 - `isEntityReady`:检查实体是否就绪 ## edit-post