Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

825 B
Raw Blame
import { BaseSelection, SelectionExtension } from '@blocksuite/store';
import z from 'zod';

const ImageSelectionSchema = z.object({
  blockId: z.string(),
});

export class ImageSelection extends BaseSelection {
  static override group = 'note';

  static override type = 'image';

  static override fromJSON(json: Record<string, unknown>): ImageSelection {
    const result = ImageSelectionSchema.parse(json);
    return new ImageSelection(result);
  }

  override equals(other: BaseSelection): boolean {
    if (other instanceof ImageSelection) {
      return this.blockId === other.blockId;
    }
    return false;
  }

  override toJSON(): Record<string, unknown> {
    return {
      type: this.type,
      blockId: this.blockId,
    };
  }
}

export const ImageSelectionExtension = SelectionExtension(ImageSelection);