mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-23 20:18:42 +08:00
fix: cannot exit editing mode when click frame body (#11603)
This commit is contained in:
@@ -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 { selected, multiSelect, event: e } = context;
|
||||||
const { editing } = this.gfx.selection;
|
const { editing } = this.gfx.selection;
|
||||||
const alreadySelected = this.gfx.selection.has(this.model.id);
|
const alreadySelected = this.gfx.selection.has(this.model.id);
|
||||||
@@ -318,7 +318,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
|||||||
})
|
})
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
} else {
|
} 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;
|
const { x, y } = context.position;
|
||||||
|
|
||||||
if (
|
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
|
// 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)
|
this.model.props.title.length)
|
||||||
) {
|
) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onSelected(context);
|
return super.onSelected(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
override renderGfxBlock() {
|
override renderGfxBlock() {
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ export class ElementTransformManager extends GfxExtension {
|
|||||||
fallback: lockedElement !== picked,
|
fallback: lockedElement !== picked,
|
||||||
};
|
};
|
||||||
|
|
||||||
view?.onSelected(context);
|
const selected = view?.onSelected(context);
|
||||||
return true;
|
return selected ?? true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -193,13 +193,15 @@ export class GfxElementModelView<
|
|||||||
this.model.xywh = currentBound.moveDelta(dx, dy).serialize();
|
this.model.xywh = currentBound.moveDelta(dx, dy).serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelected(context: SelectedContext) {
|
onSelected(context: SelectedContext): void | boolean {
|
||||||
if (this.model instanceof GfxPrimitiveElementModel) {
|
if (this.model instanceof GfxPrimitiveElementModel) {
|
||||||
if (context.multiSelect) {
|
if (context.multiSelect) {
|
||||||
this.gfx.selection.toggle(this.model);
|
this.gfx.selection.toggle(this.model);
|
||||||
} else {
|
} else {
|
||||||
this.gfx.selection.set({ elements: [this.model.id] });
|
this.gfx.selection.set({ elements: [this.model.id] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,12 +103,14 @@ export abstract class GfxBlockComponent<
|
|||||||
this.model.pop('xywh');
|
this.model.pop('xywh');
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelected(context: SelectedContext) {
|
onSelected(context: SelectedContext): void | boolean {
|
||||||
if (context.multiSelect) {
|
if (context.multiSelect) {
|
||||||
this.gfx.selection.toggle(this.model);
|
this.gfx.selection.toggle(this.model);
|
||||||
} else {
|
} else {
|
||||||
this.gfx.selection.set({ elements: [this.model.id] });
|
this.gfx.selection.set({ elements: [this.model.id] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onRotate() {}
|
onRotate() {}
|
||||||
@@ -219,12 +221,14 @@ export function toGfxBlockComponent<
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||||
onSelected(context: SelectedContext) {
|
onSelected(context: SelectedContext): void | boolean {
|
||||||
if (context.multiSelect) {
|
if (context.multiSelect) {
|
||||||
this.gfx.selection.toggle(this.model);
|
this.gfx.selection.toggle(this.model);
|
||||||
} else {
|
} else {
|
||||||
this.gfx.selection.set({ elements: [this.model.id] });
|
this.gfx.selection.set({ elements: [this.model.id] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onRotate() {}
|
onRotate() {}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ test('paste surface-ref block to another doc as embed-linked-doc block', async (
|
|||||||
// add a shape
|
// add a shape
|
||||||
await page.keyboard.press('s');
|
await page.keyboard.press('s');
|
||||||
// click to add a shape
|
// 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);
|
await page.waitForTimeout(50);
|
||||||
// add a frame
|
// add a frame
|
||||||
await page.keyboard.press('f');
|
await page.keyboard.press('f');
|
||||||
|
|||||||
Reference in New Issue
Block a user