Files
AFFiNE/libs/components/editor-core/src/recast-block
2022-08-25 15:26:20 +08:00
..
2022-08-16 18:41:04 +08:00
2022-08-25 15:26:20 +08:00
2022-07-27 16:15:21 +08:00
2022-08-25 15:26:20 +08:00
2022-08-02 17:03:01 +08:00

Recast Block

What's Recast block?

A recast block is a block that can be recast into other forms, such as list, kanban, table, and so on.

But now, we only have List and Kanban implementation.

Every recast block has some Property also call it "Meta Data"

Usage

In most cases, you do not need to use recast block API directly.

Context

  • RecastBlockProvider and withRecastBlock
const RecastComponent = () => {
  return (
    <RecastBlockProvider>
      <SomeBlock />
    </RecastBlockProvider>
  );

// or

const RecastComponent = withRecastBlock(SomeBlock);

Meta Data

const SomeBlock = () => {
    const {
        // Get meta data
        getProperty,
        // Get all meta data
        getProperties,
        // Set meta data
        addProperty,
        // Update meta data
        updateProperty,
        // Remove meta data
        removeProperty,
    } = useRecastBlockMeta();

    return <div>...</div>;
};