v2.27.0

codex-team/editor.jsv2.27.0May 15, 2023by github-actions[bot]

AI Summary

Introduces a new Toolbar API, improved event handling with batching, and a migration from Webpack to Vite. Refactors the Popover and Mutation Observer.

Key Highlights

  • New Toolbar API for toggling the toolbox.
  • Batching added to the `onChange` callback for performance.
  • Migration from Webpack to Vite as the build system.
  • Refactored Popover class for better performance.

New Features

  • Toolbar API method for toggling the toolbox.
  • Types for block mutation events.
  • Batched `onChange` callback accepting arrays of CustomEvents.
  • Mute `onChange` callback if mutations contain `data-mutation-free` nodes.
  • Optimized caret saving method calls.

Full Release Notes

## New Features

- **Toolbar API** — Added a new method for toggling the toolbox.
- **Types** — Added types for block mutation events
-  **onChange** — Batching added to the `onChange` callback. Now the second argument can contain an array of CustomEvents as well as a single one. Multiple changes made in a short period of time will be batched under a single `onChange` call.

## Improvements

- **Toolbox** — Number of `close()` method calls optimized.
- **onChange** — The `onChange` callback can be muted if all mutations contain nodes with the `data-mutation-free` attribute.
- **onChange** — Pressing "Enter" at the end of a Block won't lead to redundant `block-changed` event triggering. Only `block-added` event will be dispatched.
- **onChange** — The block mutation handler is now called on every block change (including background changes), instead of only when a block is focused
- **Optimization** — Number of caret saving method calls optimized for Block Tunes opening/closing.
- **Bundle** — Package size reduced by removing redundant files.

## Refactorings

- **Popover** — Refactored the Popover class for better performance and maintenance.
- **Build System** — Switched from Webpack to Vite as the build system.
- **Event Bus** — `EventDispatcher` types improved. Now we can pass `EventsMap` via generic to specify a map of event names and their payloads that can be used in a particular EventDispatcher instance.
- **Event Bus** — All events in common editor Event Bus now have own type declarations.
- **Mutation Observer** — Removed the block mutation observer from blocks and attached a single observer to the editor's blocks wrapper element.
- **Mutation Batching** — Removed the debounce from the block mutation handler and used batching instead.
- **Dependencies** — Upgraded Cypress to v12 and related libraries to the latest versions.
- **Dependencies** — Upgraded TypeScript to v5.
- **CI** — Ubuntu container is now used for Edge tests runner.
- **CI** — Node 16 is used for GitHib Actions.


## Bug Fixes

- Fixed several bugs caused by browser extensions. Removed the search for a block's container in the DOM on saving and kept it in memory instead, updating it when the tool changes a container element.
- The `onChange` callback won't trigger when block tunes are opened or closed.
- Resolved a compiler error caused by importing the `BlockToolData` type.
- Resolved a problem where the document would scroll to the beginning after moving a block above the viewport.
- **Tools API** — `pasteConfig` getter with `false` value could be used to disable paste handling by Editor.js core. Could be useful if your tool has its own paste handler.