mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
chore(editor): adjust size of synced doc (#12163)
Close [BS-3418](https://linear.app/affine-design/issue/BS-3418/折叠的embed-doc调整宽度时,会出现一个最小高度,不需要这个) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Improved resizing and folding interactions for embedded synced documents in edgeless mode, including dynamic height calculation and enhanced drag-handle styling. - **Bug Fixes** - Adjusted minimum height for synced document embeds to allow more compact display. - Ensured consistent width settings across embed cards. - **Tests** - Added end-to-end tests covering folding, unfolding, and resizing behaviors for edgeless synced document embeds. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -5,8 +5,6 @@ import { stopPropagation } from '@affine/core/utils';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { EmbedSyncedDocBlockComponent } from '@blocksuite/affine/blocks/embed-doc';
|
||||
import { isPeekable, peek } from '@blocksuite/affine/components/peek';
|
||||
import { DisposableGroup } from '@blocksuite/affine/global/disposable';
|
||||
import { Bound } from '@blocksuite/affine/global/gfx';
|
||||
import type { EmbedSyncedDocModel } from '@blocksuite/affine-model';
|
||||
import {
|
||||
ArrowDownSmallIcon,
|
||||
@@ -30,28 +28,10 @@ const ToggleButton = ({ model }: { model: EmbedSyncedDocModel }) => {
|
||||
const [isFolded, setIsFolded] = useState(model.isFolded);
|
||||
const t = useI18n();
|
||||
|
||||
useEffect(() => {
|
||||
const disposables = new DisposableGroup();
|
||||
disposables.add(
|
||||
model.props.preFoldHeight$.subscribe(value => setIsFolded(!!value))
|
||||
);
|
||||
// the height may be changed by dragging selected rect
|
||||
disposables.add(
|
||||
model.xywh$.subscribe(value => {
|
||||
const bound = Bound.deserialize(value);
|
||||
const preFoldHeight = model.props.preFoldHeight$.peek();
|
||||
if (
|
||||
bound.h !== styles.headerHeight &&
|
||||
preFoldHeight !== undefined &&
|
||||
bound.h !== preFoldHeight
|
||||
) {
|
||||
model.props.preFoldHeight$.value = 0;
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
return () => disposables.dispose();
|
||||
}, [model.props.preFoldHeight$, model.xywh$]);
|
||||
useEffect(
|
||||
() => model.props.preFoldHeight$.subscribe(value => setIsFolded(!!value)),
|
||||
[model.props.preFoldHeight$]
|
||||
);
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
model.store.captureSync();
|
||||
|
||||
Reference in New Issue
Block a user