mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 20:16:26 +08:00
2200bd7b70
Closes: BS-3213
32 lines
866 B
TypeScript
32 lines
866 B
TypeScript
import type { GroupElementModel } from '@blocksuite/affine-model';
|
|
import { GfxElementModelView } from '@blocksuite/std/gfx';
|
|
|
|
import { mountGroupTitleEditor } from './text/edgeless-group-title-editor';
|
|
|
|
export class GroupElementView extends GfxElementModelView<GroupElementModel> {
|
|
static override type: string = 'group';
|
|
|
|
override onCreated(): void {
|
|
super.onCreated();
|
|
|
|
this._initDblClickToEdit();
|
|
}
|
|
|
|
private _initDblClickToEdit(): void {
|
|
this.on('dblclick', () => {
|
|
const rootId = this.std.store.root?.id;
|
|
if (!rootId) {
|
|
console.error(
|
|
'GroupElementView: rootId is not found when dblclick to edit'
|
|
);
|
|
return;
|
|
}
|
|
const edgeless = this.std.view.getBlock(rootId);
|
|
|
|
if (edgeless && !this.model.isLocked()) {
|
|
mountGroupTitleEditor(this.model, edgeless);
|
|
}
|
|
});
|
|
}
|
|
}
|