github toeverything/blocksuite v0.8.0

latest releases: v0.19.5, v0.19.4, v0.19.3...
16 months ago

🎉 Announcing BlockSuite 0.8.0! This version is bundled in AFFiNE 0.8.0, incorporating over 500 new merged pull requests and 12 new contributors. In the past weeks, we have refactored the selection data flow of the editor, together with multiple new editing functionalities. Highlights:

Selection Manager Refactoring

In 0.8.0, we rewrote the selection manager following the block spec RFC (#3165). All selections could be created, managed and shared by the same data flow now.

selection-manager

The new selection follows the unidirectional data flow. Which means all selections on page will be stored as a piece of selection data called selection model.

  1. The blocks can subscribe to the changes of the selection models and render them as what they want.
  2. Every time users select something else on the page, the selection model will be updated first.
  3. Then, the blocks know the models are updated and they will try to rerender the selections.

An example of selection model:

TextSelection {
  type: 'text',
  group: 'note',
  from: {
    path: ['some-block-parent-id', 'some-block-id'],
    index: 5,
    length: 20,
  },
  to: {
    path: ['some-other-block-parent-id', 'some-other-block-id'],
    index: 0,
    length: 30
  }
}

BlockSelection {
  type: 'block',
  group: 'note',
  path: ['some-block-id'],
}

SurfaceSelection {
  type: 'surface',
  group: 'edgeless',
  path: ['some-block-id'],
  elements: ['shape-circle'],
}

In BlockSuite, this piece of data is stored in the Yjs awareness store to make sure it can be shared between clients to support remote selection. This also makes the support of the undo and redo features work as expected.

Block Schema

The new block-level migration API is introduced, usage:

import { Schema, Workspace } from '@blocksuite/store';

const schema = new Schema();
schema.register(AffineBlocks);

// Migration can run without workspace
schema.upgradePage(oldBlockVersions, oldYDoc);

// create workspace with schema
const workspace = new Workspace({ schema });

See #3826 for the guide writing migrations.

Also, the model proxy now supports defining plain JSON types using NativeWrapper, instead of mapping nested array and objects into their Y-alternatives. See #4020 for the detailed usage.

Block UI Components

In @blocksuite/blocks, the new createLitPortal and createSimplePortal API can be used to create portals in editor (#3830 #4291). The new computePosition option is supported, so as to place the tooltips and popups in proper position.

In @blocksuite/virgo, there are also new APIs:

  • Introduced createVirgoKeyDownHandler, facilitating the development of logic for the keydown event (#4279).
  • Added hooks support, allowing for the injection of default behavior into Virgo (#4386).
  • Introduced isEmbed options that allows treating a text node as a unified entity, which can be selected or removed entirety (#3659).

Doc Editing Functionalities

  • Supported the new affine:attachment block flavour (#2952).
  • Updated the new drag handle (#3695 #3162 #4314).
  • Supported text highlight (#3961).
  • Supported image files in exported HTML and markdown (#3791).

Edgeless Editing Functionalities

  • Supported the new frame element (#3701).
  • Supported full screen presentation mode (#4101).
  • Supported ToC panel for notes (#3138).
  • Supported flowchart auto-complete creation (#3596).
  • Supported moving element using arrow keys (#4143).
  • Adapted to the new selection manager (#3693).
  • Reduced re-rendering (#4276 #3911 #3823).
  • Updated connector and shape toolbar UI (#3714).

Database Editing Functionalities

  • Added the new kanban view (#2401).
  • Added the new header UI (#3868).
  • Supported clipboard operations under custom database selection (#2309).

Playground and Package Infra

  • New local-first playground with multi-player collaboration support (#3589 #3776). This entry is localhost:5173 while the previous entry with different starter templates are located in localhost:5173/starter/.
  • The circular dependencies in the project has been fully cleared (4214).

Detailed Bugfixes

New Contributors

Full Changelog: v0.7.0...v0.8.0

Don't miss a new blocksuite release

NewReleases is sending notifications on new releases.