mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
Close [BS-3029](https://linear.app/affine-design/issue/BS-3029/frame-里面的-shape-没办法进入文本编辑模式) Close [BS-3082](https://linear.app/affine-design/issue/BS-3082/按s切换至shape工具,在白板上点击会创建两个shape) Close [BS-3091](https://linear.app/affine-design/issue/BS-3082/按s切换至shape工具,在白板上点击会创建两个shape) ## Fix Shape Tool Issues This PR addresses several issues with the shape and mindmap tools functionality in the editor: 1. **Fix text editing after mode switching**: Resolves an issue where users couldn't edit text in shapes after switching editor modes. The fix ensures the edgeless block is properly retrieved when double-clicking on a shape. 2. **Improve tool switching behavior**: Fixes issues with tool overlays not showing or being repeated when switching between tools. This includes: - Properly handling tool overlay visibility - Ensuring only one tool is active at a time when using keyboard shortcuts - Adding proper cleanup when switching tools 3. **Add comprehensive tests**: Adds new test cases to verify: - Shape creation with keyboard shortcuts - Shape text editing after mode switching - Tool switching behavior with keyboard shortcuts
25 lines
683 B
TypeScript
25 lines
683 B
TypeScript
import type { ShapeElementModel } from '@blocksuite/affine-model';
|
|
import { GfxElementModelView } from '@blocksuite/std/gfx';
|
|
|
|
import { mountShapeTextEditor } from './text/edgeless-shape-text-editor';
|
|
|
|
export class ShapeElementView extends GfxElementModelView<ShapeElementModel> {
|
|
static override type: string = 'shape';
|
|
|
|
override onCreated(): void {
|
|
super.onCreated();
|
|
|
|
this._initDblClickToEdit();
|
|
}
|
|
|
|
private _initDblClickToEdit(): void {
|
|
this.on('dblclick', () => {
|
|
const edgeless = this.std.view.getBlock(this.std.store.root!.id);
|
|
|
|
if (edgeless && !this.model.isLocked()) {
|
|
mountShapeTextEditor(this.model, edgeless);
|
|
}
|
|
});
|
|
}
|
|
}
|