Files
AFFiNE-Mirror/blocksuite/affine/gfx/group/src/element-view.ts
T
Saul-Mirone 2200bd7b70 feat(editor): text gfx extension (#11951)
Closes: BS-3213
2025-04-24 03:21:54 +00:00

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);
}
});
}
}