@eeacms/volto-object-widget

中文文档
9.1.1发布于 2026/04/28MITCommonJS近 30 天下载 3333

volto-object-widget: Volto add-on

原始使用文档
文档目录11 节
  1. Features
  2. FlatListObject
  3. Mapping Widget
  4. Object by type
  5. Getting started
  6. Try volto-object-widget with Docker
  7. Add volto-object-widget to your Volto project
  8. Release
  9. How to contribute
  10. Copyright and license
  11. Funding

volto-object-widget

Releases

Pipeline Lines of Code Coverage Bugs Duplicated Lines (%)

Pipeline Lines of Code Coverage Bugs Duplicated Lines (%)

Volto add-on: Various Volto schema-based widgets.

Features

This Volto addon provides several "abstract" widgets, to allow complex information to be editable by the schema-based forms. It centers around the concept: "we can create a form to edit a JSON object by using a schema" and so it provides, right now, widgets to edit "list of JSON objects", a "mapping of JSON objects" and a single "JSON object, but I choose the schema for it".

FlatListObject

Flat List object

This widget allows you to edit a list of objects by creating, editing and deleting instances of objects editable with the provided schema parameter. The list is sortable with drag&drop. You can also provide a schema extender, a function with signature (schema, data) => schema, which will adjust, per instance of object, its schema. To use this widget, in the schema, set the widget field to object_list_inline.

Example of how the data could look like for a block:

"a55c5053-ba81-4f73-ab29-7cdea74df20f": {
    "@type": "dataTable",
    "columns": [
        {
            "@id": "f899ca76-68be-4ded-aa0b-669c04c27309",
            "column": " PERC_HA_07\n(in %)",
            "renderer": "progress",
            "title": "21"
        },
        {
            "@id": "94315c5a-e031-4b7e-acb2-93887878a252",
            "column": " PERC_HA_07\n(in %)",
            "title": "12"
        }
    ],
}

The columns field, in this case, is data generated by the FlatListObject. The schema for this field could look like (ColumnSchema() just generates another instance of a schema, suitable for the column definition of our specific use case):

columns: {
  title: 'Columns',
  description: 'Leave empty to show all columns',
  schema: ColumnSchema(),
  widget: 'object_list_inline',
},

Mapping Widget

Mapping widget

This widget allows editing the properties of an object. For example, in the following block data, the row_colors value is generated by an instance of the MappingWidget.

"4430a32a-a266-497b-88e7-72fead5ab718": {
  "@type": "dottedTableChart",
  "column_data": "habitat_group",
  "row_colors": {
    "Bad": "#ed1834",
    "F - Heathland, scrub and tundra": "#88c24f",
    "Good": "#3c8000",
    "Poor": "#f2a70e",
    "Unknown": "#8d8d8d"
  },
  "row_data": "assessment",
  "size_data": "quantity"
},

You need to provide the options, which is a list of objects with {id, title} and the field_props, which are parameters for the actual field that will be used to edit the values. In our case the schema definition that was used to edit the above value is (note, the options are empty, we're populating them in the edit component, before passing the schema to the form):

row_colors: {
  title: 'Colors',
  widget: 'option_mapping',
  field_props: {
    widget: 'simple_color',
    available_colors: settings.available_colors,
  },
  options: [],
}

To use this widget, in the schema, set the widget field to option_mapping.

Object by type

Object by type

With this widget you can choose the type of value that will be used, from a predefined list of schemas. A schema that would use this type of widget could look like:

const LinkEditSchema = {
  title: 'Link',
  fieldsets: [
    {
      id: 'default',
      title: 'Default',
      fields: ['link'],
    },
  ],
  properties: {
    link: {
      title: 'Link',
      widget: 'object_by_type',
      schemas: [
        {
          id: 'internal',
          icon: internalSVG,
          schema: InternalLinkSchema,
        },
        {
          id: 'external',
          icon: externalSVG,
          schema: ExternalLinkSchema,
        },
        {
          id: 'email',
          icon: emailSVG,
          schema: EmailLinkSchema,
        },
      ],
    },
  },
  required: [],
};

To use this widget, in the schema, set the widget field to object_by_type.

Getting started

Try volto-object-widget with Docker

  git clone https://github.com/eea/volto-object-widget.git
  cd volto-object-widget
  make
  make start

Go to http://localhost:3000

make start now defaults to Volto 18. To run the same setup against Volto 17, use:

  VOLTO_VERSION=17 make
  VOLTO_VERSION=17 make start

Add volto-object-widget to your Volto project

  1. Make sure you have a Plone backend up-and-running at http://localhost:8080/Plone

    docker compose up backend
    
  2. Start Volto frontend

  • If you already have a volto project, just update package.json:

    "dependencies": {
        "@eeacms/volto-object-widget": "*"
    }
    

and volto.config.js:

const addons = ['@eeacms/volto-object-widget'];
  • If not, create one with Cookieplone, as recommended by the official Plone documentation for Volto 18+:

    uvx cookieplone project
    cd project-title
    
  1. Install or update dependencies, then start the project:

    make install
    

    For a Cookieplone project, start the backend and frontend in separate terminals:

    make backend-start
    make frontend-start
    

    For a legacy Volto 17 project, install the package with yarn and restart the frontend as usual.

  2. Go to http://localhost:3000

  3. Happy editing!

Release

See RELEASE.md.

How to contribute

See DEVELOP.md.

The Initial Owner of the Original Code is European Environment Agency (EEA). All Rights Reserved.

See LICENSE.md for details.

Funding

European Environment Agency (EU)

版本与发布记录

@eeacms/volto-object-widget 共发布 34 个版本,首次发布于 2020/11/10;过去 12 个月发布了 4 个版本。

版本发布日期距今
9.1.1latest2026/04/286 个月前
9.1.02026/04/156 个月前
9.0.12026/04/097 个月前
9.0.02026/03/317 个月前
8.0.02025/07/251.3 年前
7.0.02024/04/232 年前

关于 @eeacms/volto-object-widget 的常见问题

@eeacms/volto-object-widget 是什么?

volto-object-widget: Volto add-on

如何安装 @eeacms/volto-object-widget?

在项目目录运行 npm install @eeacms/volto-object-widget,或使用 pnpm add / yarn add / bun add。

@eeacms/volto-object-widget 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/eeacms__volto-object-widget 是否存在。

@eeacms/volto-object-widget 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@eeacms/volto-object-widget 可以商用吗?

@eeacms/volto-object-widget 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@eeacms/volto-object-widget 的下载量有多少?

根据 npm 官方下载统计,@eeacms/volto-object-widget 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,333 次,日均约 111 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eeacms/volto-object-widget 还在维护吗?

最新版本 9.1.1 发布于 2026/04/28(6 个月前);至今共发布 34 个版本,其中过去 12 个月发布了 4 个;首次发布于 2020/11/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。