Skip to content

v0.13.0 - API Overhaul and Rich Examples

Compare
Choose a tag to compare
@doodlewind doodlewind released this 19 Mar 04:32
· 415 commits to master since this release
b48b0e2

BlockSuite v0.13.0 is now released with 153 PRs landed and 4 new contributors. It's currently used in AFFiNE 0.13. This is a transitional version centered on bug fixes and the clearing of technical debt.

BlockSuite Examples

From 0.13, BlockSuite maintains multiple framework-specific examples demonstrating editor integration for major frameworks (currently including React, Vue, Angular, Preact, Svelte, Solid). There are also examples about using BlockSuite with Next.js and SQLite. You can checkout these examples in the quick start guide.

These examples are maintained in a standalone workspace. There'll be more examples incoming and feel free to make your own!

Framework Features and API Overhaul

  • Text Style Commands Enhancement (#6406, #6416): Added commands to facilitate operations on selected text content, including toggleBold, toggleItalic, toggleUnderline, toggleStrike, toggleCode, toggleLink, getTextStyle, and isTextStyleActive. These commands support chainable combination calls, simplifying common rich text style operations.
  • Format Bar Config API (#6433): Introduced a new format bar widget configuration API, allowing for the customization of format bar menu items. This supports the configuration of existing menu items and the registration of custom menu items, including paragraph dropdowns, style toggles (e.g., bold, italic), highlighter dropdowns, and block type switches with custom icons.
// In root spec:
const defaultSetup = rootSpec.setup;
const mySpec = {
  ...rootSpec,
  setup: (slots, disposableGroup) => {
    defaultSetup(slots, disposableGroup);

    const onFormatBarConnected = slots.widgetConnected.on(view => {
      if (view.component instanceof AffineFormatBarWidget) {
        configureFormatBar(view.component);
      }
    });

    disposableGroup.add(onFormatBarConnected);
  },
};

function configureFormatBar(formatBar: AffineFormatBarWidget) {
  formatBar
    .clearConfig()
    .addParagraphDropdown()
    .addDivider()
    .addTextStyleToggle({
      key: 'bold',
      action: chain => chain.toggleBold().run(),
      icon: BoldIcon,
    })
    .addTextStyleToggle({
      key: 'italic',
      action: chain => chain.toggleItalic().run(),
      icon: ItalicIcon,
    })
    .addDivider()
    .addHighlighterDropdown()
    .addDivider()
    .addBlockTypeSwitch({
      flavour: 'affine:paragraph',
      type: 'h1',
      name: 'Heading 1',
      icon: Heading1Icon,
    })
    .addBlockTypeSwitch({
      flavour: 'affine:paragraph',
      type: 'h2',
      name: 'Heading 2',
      icon: Heading2Icon,
    })
}
  • Standard Error Types and Handler (#6340): Introduced BlockSuiteError to facilitate application-level exception categorization.
  • Renaming page to doc (#6290): We now refer to BlockSuite documents as docs, aligning API concepts with this terminology change (e.g., page.addBlock -> doc.addBlock). This clarifies the document-centric nature of the API.
  • Renaming Workspace to DocCollection (#6436): Replaced the Workspace concept, which was more specific to AFFiNE product features, with DocCollection. This moves towards a more generalized framework structure (e.g., workspace.createDoc to collection.createDoc).
  • Command API Simplification (#6428, #6421, #6277): Streamlined command usage by eliminating the need for .withHost and .getChainCtx. The API for initiating command chains has been intuitively changed from .pipe to .chain, simplifying command execution syntax.
// before
std.command
  .pipe()
  .withHost()
  .getSelectedBlocks()
  .run();

// after
std.command
  .chain()
  .getSelectedBlocks()
  .run();
  • Schema Entry Renaming (#6312, #6319): Removed deprecated __unstableSchemas and enhanced consistency when importing default block schemas. This unifies the exposed schema, reinforcing a consistent framework for developers.
// Before
import { AffineSchemas, __unstableSchemas } from '@blocksuite/blocks/models';

// After
import { AffineSchemas } from '@blocksuite/blocks/schemas';
  • Typed getService (#6284): The getService API is now strongly typed with different service specific to block flavours.

Product Features

  • Batch Import (#6360): Enabled batch importing of multiple markdown or HTML files through the file picker.
  • Pressure Sensitivity for Brush Mode (#6348): Added pressure sensitivity support for the brush tool, offering more natural drawing experience on tablets.
  • Comment Feature POC (#6302): Introduced a preliminary support for a commenting feature, setting the stage for enhanced collaboration capabilities that will be further refined in future updates.

Detailed Bugfixes

Full Changelog: v0.12.0...v0.13.0