fix(select): select rect position

This commit is contained in:
austaras
2022-07-25 11:15:14 +08:00
parent a4132f5f8a
commit 95629486b3
7 changed files with 44 additions and 54 deletions

View File

@@ -4,7 +4,7 @@ import { styled, usePatchNodes } from '@toeverything/components/ui';
import type { FC, PropsWithChildren } from 'react';
import React, { useEffect, useRef, useState, useCallback } from 'react';
import { RootContext } from './contexts';
import { SelectionRect, SelectionRef } from './selection';
import { SelectionRect, SelectionRef } from './Selection';
import {
Protocol,
services,
@@ -205,20 +205,17 @@ export const RenderRoot: FC<PropsWithChildren<RenderRootProps>> = ({
{children}
{patchedNodes}
</Content>
{editor.isWhiteboard ? null : <ScrollBlank editor={editor} />}
{/** TODO: remove selectionManager insert */}
{container && editor && (
<SelectionRect
ref={selectionRef}
container={container}
editor={editor}
/>
<SelectionRect ref={selectionRef} editor={editor} />
)}
{editor.isWhiteboard ? null : <ScrollBlank editor={editor} />}
</Container>
</RootContext.Provider>
);
};
// eslint-disable-next-line @typescript-eslint/naming-convention
function ScrollBlank({ editor }: { editor: BlockEditor }) {
const mouseMoved = useRef(false);
@@ -281,6 +278,7 @@ const Container = styled('div')(
overflowY: isWhiteboard ? 'unset' : 'auto',
padding: isWhiteboard ? 0 : '96px 150px 0 150px',
minWidth: isWhiteboard ? 'unset' : '940px',
position: 'relative',
})
);