MyGit

v0.8.0

toeverything/blocksuite

版本发布时间: 2023-08-29 22:46:56

toeverything/blocksuite最新发布版本:v0.9.0(2023-10-18 20:24:04)

🎉 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:

Doc Editing Functionalities

Edgeless Editing Functionalities

Database Editing Functionalities

Playground and Package Infra

Bugfixes

New Contributors

Full Changelog: https://github.com/toeverything/blocksuite/compare/v0.7.0...v0.8.0

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-08-29发行的版本