mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 15:16:28 +08:00
@@ -0,0 +1,33 @@
|
||||
import { BaseSelection, SelectionExtension } from '@blocksuite/store';
|
||||
import z from 'zod';
|
||||
|
||||
const BlockSelectionSchema = z.object({
|
||||
blockId: z.string(),
|
||||
});
|
||||
|
||||
export class BlockSelection extends BaseSelection {
|
||||
static override group = 'note';
|
||||
|
||||
static override type = 'block';
|
||||
|
||||
static override fromJSON(json: Record<string, unknown>): BlockSelection {
|
||||
const result = BlockSelectionSchema.parse(json);
|
||||
return new BlockSelection(result);
|
||||
}
|
||||
|
||||
override equals(other: BaseSelection): boolean {
|
||||
if (other instanceof BlockSelection) {
|
||||
return this.blockId === other.blockId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override toJSON(): Record<string, unknown> {
|
||||
return {
|
||||
type: 'block',
|
||||
blockId: this.blockId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const BlockSelectionExtension = SelectionExtension(BlockSelection);
|
||||
Reference in New Issue
Block a user