块编辑器开发文档

@wordpress/edit-site

💡 云策文档标注

概述

@wordpress/edit-site 是 WordPress 核心的站点编辑页面模块,用于初始化站点编辑器。它主要面向 WordPress 开发者,需在 ES2015+ 环境中使用。

关键要点

  • 该包专为 WordPress 核心设计,可用于其他项目但可能缺乏完整文档。
  • 通过 npm 安装:npm install @wordpress/edit-site。
  • 使用 initialize 函数初始化编辑器,传入 DOM 元素选择器和 blockEditorSettings。
  • 依赖 ES2015+ 环境,否则需包含 @wordpress/babel-preset-default 的 polyfill。
  • 作为 Gutenberg 项目的一部分,采用 monorepo 结构,贡献需参考项目指南。

📄 原文内容

Edit Site Page Module for WordPress.

This package is meant to be used only with WordPress core. Feel free to use it in your own project but please keep in mind that it might never get fully documented.

Installation

npm install @wordpress/edit-site

Usage

/**
 * WordPress dependencies
 */
import { initialize } from '@wordpress/edit-site';

/**
 * Internal dependencies
 */
import blockEditorSettings from './block-editor-settings';

initialize( '#editor-root', blockEditorSettings );

This package assumes that your code will run in an ES2015+ environment. If you’re using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @wordpress/babel-preset-default in your code.

Contributing to this package

This is an individual package that’s part of the Gutenberg project. The project is organized as a monorepo. It’s made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project’s main contributor guide.