diff --git a/libs/components/editor-blocks/src/blocks/group/GroupView.tsx b/libs/components/editor-blocks/src/blocks/group/GroupView.tsx index 694fe7820f..1c2ef04605 100644 --- a/libs/components/editor-blocks/src/blocks/group/GroupView.tsx +++ b/libs/components/editor-blocks/src/blocks/group/GroupView.tsx @@ -60,7 +60,7 @@ const GroupContainer = styled('div')<{ isSelect?: boolean }>( ({ isSelect, theme }) => ({ background: theme.affine.palette.white, border: '2px solid rgba(236,241,251,.5)', - padding: '15px 12px', + padding: `15px 16px 0 16px`, borderRadius: '10px', ...(isSelect ? { diff --git a/libs/components/editor-core/src/block-content-wrapper/BlockContentWrapper.tsx b/libs/components/editor-core/src/block-content-wrapper/BlockContentWrapper.tsx index 792b1a8455..e2d916cb8c 100644 --- a/libs/components/editor-core/src/block-content-wrapper/BlockContentWrapper.tsx +++ b/libs/components/editor-core/src/block-content-wrapper/BlockContentWrapper.tsx @@ -9,6 +9,7 @@ type BlockContentWrapperProps = { children: ReactElement | null; }; +// TODO: remove export const WrapperWithPendantAndDragDrop: FC = function ({ block, children, editor }) { return ( diff --git a/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx b/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx index 877c4e451a..66cf4001a0 100644 --- a/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx +++ b/libs/components/editor-core/src/block-pendant/BlockPendantProvider.tsx @@ -1,5 +1,4 @@ import type { FC, PropsWithChildren } from 'react'; -import React, { useState } from 'react'; import { styled } from '@toeverything/components/ui'; import type { AsyncBlock } from '../editor'; import { PendantPopover } from './pendant-popover'; @@ -11,74 +10,68 @@ interface BlockTagProps { block: AsyncBlock; } -/** - * @deprecated Need to be refactored - */ export const BlockPendantProvider: FC> = ({ block, children, }) => { - const [container, setContainer] = useState(null); - const [isHover, setIsHover] = useState(false); return ( - setContainer(dom)}> + {children} - {container && ( - { - setIsHover(visible); - }} - > - - - )} + + + + + ); }; -const Container = styled('div')({ +export const LINE_GAP = 16; +const TAG_GAP = 4; + +const StyledTriggerLine = styled('div')({ + padding: `${TAG_GAP}px 0`, + width: '100px', + cursor: 'default', + display: 'flex', + alignItems: 'flex-end', position: 'relative', - padding: '4px', - '&:hover .triggerLine::before': { - display: 'flex', + + '::before': { + content: "''", + width: '100%', + height: '2px', + background: '#dadada', + display: 'none', + position: 'absolute', + left: '0', + top: '4px', + }, + '::after': { + content: "''", + width: '0', + height: '2px', + background: '#aac4d5', + display: 'block', + position: 'absolute', + left: '0', + top: '4px', + transition: 'width .3s', }, }); -const StyledTriggerLine = styled('div')<{ isHover: boolean }>(({ isHover }) => { - return { - padding: '4px 0', - width: '100px', - cursor: 'default', - display: 'flex', - alignItems: 'flex-end', - position: 'relative', - - '::before': { - content: "''", - width: '100%', - height: '2px', - background: '#dadada', - display: 'none', - position: 'absolute', - left: '0', - top: '4px', +const Container = styled('div')({ + position: 'relative', + paddingBottom: `${LINE_GAP - TAG_GAP * 2}px`, + '&:hover': { + [StyledTriggerLine.toString()]: { + '&::before': { + display: 'flex', + }, + '&::after': { + width: '100%', + }, }, - '::after': { - content: "''", - width: isHover ? '100%' : '0', - height: '2px', - background: '#aac4d5', - display: 'block', - position: 'absolute', - left: '0', - top: '4px', - transition: 'width .3s', - }, - }; + }, }); diff --git a/libs/components/editor-core/src/block-pendant/pendant-popover/PendantPopover.tsx b/libs/components/editor-core/src/block-pendant/pendant-popover/PendantPopover.tsx index cdc06c07d9..70cb5115c6 100644 --- a/libs/components/editor-core/src/block-pendant/pendant-popover/PendantPopover.tsx +++ b/libs/components/editor-core/src/block-pendant/pendant-popover/PendantPopover.tsx @@ -1,4 +1,4 @@ -import React, { FC, useRef } from 'react'; +import { FC, useRef } from 'react'; import { AsyncBlock } from '../../editor'; import { PendantHistoryPanel } from '../pendant-history-panel'; import { @@ -21,8 +21,6 @@ export const PendantPopover: FC< pointerEnterDelay={300} pointerLeaveDelay={200} placement="bottom-start" - // visible={true} - // trigger="click" content={ ) => void; - onDragEnd: (event: React.DragEvent) => void; + children: ReactNode; + style: CSSProperties; + onDragStart: (event: DragEvent) => void; + onDragEnd: (event: DragEvent) => void; }) { const { style, children, onDragStart, onDragEnd } = props; return ( @@ -122,7 +131,7 @@ export const LeftMenuDraggable: FC = props => { const [block, setBlock] = useState(); const [line, setLine] = useState(undefined); - const handleDragStart = async (event: React.DragEvent) => { + const handleDragStart = async (event: DragEvent) => { event.stopPropagation(); setVisible(false); @@ -138,12 +147,12 @@ export const LeftMenuDraggable: FC = props => { } }; - const handleDragEnd = (event: React.DragEvent) => { + const handleDragEnd = (event: DragEvent) => { event.preventDefault(); setLine(undefined); }; - const onClick = (event: React.MouseEvent) => { + const onClick = (event: MouseEvent) => { if (block == null) return; const currentTarget = event.currentTarget; editor.selection.setSelectedNodesIds([block.blockId]); @@ -200,11 +209,10 @@ export const LeftMenuDraggable: FC = props => { style={{ position: 'absolute', left: - Math.min( - block.rect.left - - MENU_WIDTH - - MENU_BUTTON_OFFSET - ) - rootRect.left, + block.rect.left - + MENU_WIDTH - + MENU_BUTTON_OFFSET - + rootRect.left, top: block.rect.top - rootRect.top, opacity: visible ? 1 : 0, zIndex: 1, @@ -240,7 +248,7 @@ const Draggable = styled(Button)({ justifyContent: 'center', backgroundColor: 'transparent', width: '16px', - height: '20px', + height: '22px', '& svg': { fontSize: '20px', marginLeft: '-2px', @@ -253,5 +261,5 @@ const Draggable = styled(Button)({ const LigoLeftMenu = styled('div')({ backgroundColor: 'transparent', - marginRight: '4px', + // marginRight: '4px', }); diff --git a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx index 00d301287e..29c421f29f 100644 --- a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx +++ b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuPlugin.tsx @@ -1,5 +1,5 @@ import { BlockDomInfo, HookType } from '@toeverything/framework/virgo'; -import React, { StrictMode } from 'react'; +import { StrictMode } from 'react'; import { BasePlugin } from '../../base-plugin'; import { ignoreBlockTypes } from './menu-config'; import { LineInfoSubject, LeftMenuDraggable } from './LeftMenuDraggable'; diff --git a/libs/components/ui/src/popover/container.tsx b/libs/components/ui/src/popover/Container.tsx similarity index 92% rename from libs/components/ui/src/popover/container.tsx rename to libs/components/ui/src/popover/Container.tsx index f91e95b024..8fdfc5aea9 100644 --- a/libs/components/ui/src/popover/container.tsx +++ b/libs/components/ui/src/popover/Container.tsx @@ -15,11 +15,11 @@ export const PopoverContainer = styled('div')< const shadow = theme.affine.shadows.shadowSxDownLg; const white = theme.affine.palette.white; - const border_radius = + const borderRadius = border_radius_map[direction] || border_radius_map['left-top']; return { boxShadow: shadow, - borderRadius: border_radius, + borderRadius: borderRadius, padding: '8px 4px', backgroundColor: white, ...style, diff --git a/libs/components/ui/src/popover/Popover.tsx b/libs/components/ui/src/popover/Popover.tsx index 67ab3f3c29..d03a65f322 100644 --- a/libs/components/ui/src/popover/Popover.tsx +++ b/libs/components/ui/src/popover/Popover.tsx @@ -1,7 +1,7 @@ import type { MuiPopperPlacementType as PopperPlacementType } from '../mui'; import React, { forwardRef, type PropsWithChildren } from 'react'; import { type PopperHandler, Popper } from '../popper'; -import { PopoverContainer } from './container'; +import { PopoverContainer } from './Container'; import type { PopoverProps, PopoverDirection } from './interface'; export const placementToContainerDirection: Record< diff --git a/libs/components/ui/src/popover/index.tsx b/libs/components/ui/src/popover/index.ts similarity index 53% rename from libs/components/ui/src/popover/index.tsx rename to libs/components/ui/src/popover/index.ts index c829b413b6..718c074cce 100644 --- a/libs/components/ui/src/popover/index.tsx +++ b/libs/components/ui/src/popover/index.ts @@ -1,3 +1,3 @@ export * from './Popover'; export * from './interface'; -export { PopoverContainer } from './container'; +export { PopoverContainer } from './Container';