fix: cannot exit editing mode when click frame body (#11603)

This commit is contained in:
doouding
2025-04-11 03:23:27 +00:00
parent bcd1cd2629
commit 714f2e79dc
6 changed files with 17 additions and 11 deletions
@@ -259,7 +259,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
};
}
override onSelected(context: SelectedContext) {
override onSelected(context: SelectedContext): void | boolean {
const { selected, multiSelect, event: e } = context;
const { editing } = this.gfx.selection;
const alreadySelected = this.gfx.selection.has(this.model.id);
@@ -318,7 +318,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
})
.catch(console.error);
} else {
super.onSelected(context);
return super.onSelected(context);
}
}
@@ -53,7 +53,7 @@ export class FrameBlockComponent extends GfxBlockComponent<FrameBlockModel> {
};
}
override onSelected(context: SelectedContext): void {
override onSelected(context: SelectedContext): boolean | void {
const { x, y } = context.position;
if (
@@ -63,10 +63,10 @@ export class FrameBlockComponent extends GfxBlockComponent<FrameBlockModel> {
// otherwise if the frame has title, then ignore it because in this case the frame cannot be selected by frame body
this.model.props.title.length)
) {
return;
return false;
}
super.onSelected(context);
return super.onSelected(context);
}
override renderGfxBlock() {
@@ -115,8 +115,8 @@ export class ElementTransformManager extends GfxExtension {
fallback: lockedElement !== picked,
};
view?.onSelected(context);
return true;
const selected = view?.onSelected(context);
return selected ?? true;
}
return false;
@@ -193,13 +193,15 @@ export class GfxElementModelView<
this.model.xywh = currentBound.moveDelta(dx, dy).serialize();
}
onSelected(context: SelectedContext) {
onSelected(context: SelectedContext): void | boolean {
if (this.model instanceof GfxPrimitiveElementModel) {
if (context.multiSelect) {
this.gfx.selection.toggle(this.model);
} else {
this.gfx.selection.set({ elements: [this.model.id] });
}
return true;
}
}
@@ -103,12 +103,14 @@ export abstract class GfxBlockComponent<
this.model.pop('xywh');
}
onSelected(context: SelectedContext) {
onSelected(context: SelectedContext): void | boolean {
if (context.multiSelect) {
this.gfx.selection.toggle(this.model);
} else {
this.gfx.selection.set({ elements: [this.model.id] });
}
return true;
}
onRotate() {}
@@ -219,12 +221,14 @@ export function toGfxBlockComponent<
}
// eslint-disable-next-line sonarjs/no-identical-functions
onSelected(context: SelectedContext) {
onSelected(context: SelectedContext): void | boolean {
if (context.multiSelect) {
this.gfx.selection.toggle(this.model);
} else {
this.gfx.selection.set({ elements: [this.model.id] });
}
return true;
}
onRotate() {}
@@ -184,7 +184,7 @@ test('paste surface-ref block to another doc as embed-linked-doc block', async (
// add a shape
await page.keyboard.press('s');
// click to add a shape
await container.click({ position: { x: 100, y: 500 } });
await container.click({ position: { x: 100, y: 300 } });
await page.waitForTimeout(50);
// add a frame
await page.keyboard.press('f');