void
+) {
if (info.mode === 'edgeless' && info.xywh) {
- return
;
+ return (
+
+ );
}
return (
@@ -31,15 +42,32 @@ export const PeekViewManagerModal = () => {
const peekViewEntity = useService(PeekViewService).peekView;
const activePeekView = useLiveData(peekViewEntity.active$);
const show = useLiveData(peekViewEntity.show$);
+ const peekViewRef = useRef
(null);
const preview = useMemo(() => {
- return activePeekView ? renderPeekView(activePeekView) : null;
+ return activePeekView
+ ? renderPeekView(activePeekView, editor => {
+ peekViewRef.current = editor;
+ })
+ : null;
}, [activePeekView]);
const controls = useMemo(() => {
return activePeekView ? renderControls(activePeekView) : null;
}, [activePeekView]);
+ useEffect(() => {
+ const subscription = peekViewEntity.show$.subscribe(() => {
+ if (activePeekView?.target instanceof BlockElement) {
+ activePeekView.target.requestUpdate();
+ }
+ });
+
+ return () => {
+ subscription.unsubscribe();
+ };
+ }, [activePeekView, peekViewEntity]);
+
return (
{
: undefined
}
controls={controls}
- // there is a bug for edgeless mode when showing the peek view during start up animation
- hideOnEntering={
- !activePeekView?.info.mode || activePeekView?.info.mode === 'edgeless'
- }
onOpenChange={open => {
if (!open) {
peekViewEntity.close();
}
}}
+ onAnimateEnd={() => {
+ peekViewRef.current?.fitViewportToTarget();
+ }}
>
{preview}