mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 02:26:21 +08:00
fix: block should not be selectable when dragged into note (#10664)
### Changed - Fixed the issue that block can still be selected when dragged into note - Rewrite grid and layer with extension infra
This commit is contained in:
@@ -38,18 +38,22 @@ export class GfxController extends LifeCycleWatcher {
|
||||
|
||||
private readonly _disposables: DisposableGroup = new DisposableGroup();
|
||||
|
||||
private _surface: SurfaceBlockModel | null = null;
|
||||
private readonly _surface$ = new Signal<SurfaceBlockModel | null>(null);
|
||||
|
||||
readonly cursor$ = new Signal<CursorType>();
|
||||
|
||||
readonly grid: GridManager;
|
||||
|
||||
readonly keyboard: KeyboardController;
|
||||
|
||||
readonly layer: LayerManager;
|
||||
|
||||
readonly viewport: Viewport = new Viewport();
|
||||
|
||||
get grid() {
|
||||
return this.std.get(GridManager);
|
||||
}
|
||||
|
||||
get layer() {
|
||||
return this.std.get(LayerManager);
|
||||
}
|
||||
|
||||
get doc() {
|
||||
return this.std.store;
|
||||
}
|
||||
@@ -62,8 +66,12 @@ export class GfxController extends LifeCycleWatcher {
|
||||
return [...this.layer.blocks, ...this.layer.canvasElements];
|
||||
}
|
||||
|
||||
get surface$() {
|
||||
return this._surface$;
|
||||
}
|
||||
|
||||
get surface() {
|
||||
return this._surface;
|
||||
return this._surface$.peek();
|
||||
}
|
||||
|
||||
get surfaceComponent(): BlockComponent | null {
|
||||
@@ -75,22 +83,13 @@ export class GfxController extends LifeCycleWatcher {
|
||||
constructor(std: BlockStdScope) {
|
||||
super(std);
|
||||
|
||||
this.grid = new GridManager();
|
||||
this.layer = new LayerManager(this.doc, null);
|
||||
this.keyboard = new KeyboardController(std);
|
||||
|
||||
this._disposables.add(
|
||||
onSurfaceAdded(this.doc, surface => {
|
||||
this._surface = surface;
|
||||
|
||||
if (surface) {
|
||||
this._disposables.add(this.grid.watch({ surface }));
|
||||
this.layer.watch({ surface });
|
||||
}
|
||||
this._surface$.value = surface;
|
||||
})
|
||||
);
|
||||
this._disposables.add(this.grid.watch({ doc: this.doc }));
|
||||
this._disposables.add(this.layer);
|
||||
this._disposables.add(this.viewport);
|
||||
this._disposables.add(this.keyboard);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user