mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 00:41:39 +08:00
17bf75e843
Closes: [BS-2216](https://linear.app/affine-design/issue/BS-2216/remove-global-types-in-command)
34 lines
825 B
TypeScript
34 lines
825 B
TypeScript
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);
|