mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 03:26:47 +08:00
feat(editor): simple table block (#9740)
close: BS-2122, BS-2125, BS-2124, BS-2420, PD-2073, BS-2126, BS-2469, BS-2470, BS-2478, BS-2471
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import type { BlockComponent } from '@blocksuite/block-std';
|
||||
import { autoUpdate } from '@floating-ui/dom';
|
||||
import { signal } from '@preact/signals-core';
|
||||
import type { ReactiveController } from 'lit';
|
||||
|
||||
import { DocModeProvider } from '../services/doc-mode-service';
|
||||
|
||||
export class VirtualPaddingController implements ReactiveController {
|
||||
public readonly virtualPadding$ = signal(0);
|
||||
constructor(private readonly block: BlockComponent) {
|
||||
block.addController(this);
|
||||
}
|
||||
|
||||
get std() {
|
||||
return this.host.std;
|
||||
}
|
||||
|
||||
get host() {
|
||||
return this.block.host;
|
||||
}
|
||||
|
||||
hostConnected(): void {
|
||||
if (this.std.get(DocModeProvider).getEditorMode() === 'edgeless') {
|
||||
return;
|
||||
}
|
||||
this.block.disposables.add(
|
||||
autoUpdate(this.host, this.block, () => {
|
||||
const padding =
|
||||
this.block.getBoundingClientRect().left -
|
||||
this.host.getBoundingClientRect().left;
|
||||
this.virtualPadding$.value = Math.max(0, padding - 72);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user