mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-17 20:51:55 +01:00
Make the drag preview always use the tech frame (#87)
Overrides the frameless block frame if generating a drag preview. Also fixes a type issue with BlockFrame_Tech
This commit is contained in:
parent
c9cf88eb5e
commit
f1c8d63ab2
@ -210,8 +210,15 @@ interface BlockFrameProps {
|
||||
dragHandleRef?: React.RefObject<HTMLDivElement>;
|
||||
}
|
||||
|
||||
const BlockFrame_Tech = React.memo(
|
||||
({ blockId, onClose, onClick, preview, blockRef, dragHandleRef, children }: BlockFrameProps) => {
|
||||
const BlockFrame_Tech_Component = ({
|
||||
blockId,
|
||||
onClose,
|
||||
onClick,
|
||||
preview,
|
||||
blockRef,
|
||||
dragHandleRef,
|
||||
children,
|
||||
}: BlockFrameProps) => {
|
||||
const [blockData] = WOS.useWaveObjectValue<Block>(WOS.makeORef("block", blockId));
|
||||
const settingsConfig = jotai.useAtomValue(atoms.settingsConfigAtom);
|
||||
const isFocusedAtom = useBlockAtom<boolean>(blockId, "isFocused", () => {
|
||||
@ -257,8 +264,9 @@ const BlockFrame_Tech = React.memo(
|
||||
{preview ? <div className="block-frame-preview" /> : children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const BlockFrame_Tech = React.memo(BlockFrame_Tech_Component) as typeof BlockFrame_Tech_Component;
|
||||
|
||||
const BlockFrame_Frameless = ({
|
||||
blockId,
|
||||
@ -343,6 +351,8 @@ const BlockFrame = React.memo((props: BlockFrameProps) => {
|
||||
return null;
|
||||
}
|
||||
let FrameElem = BlockFrame_Tech;
|
||||
// Preview should always render as the full tech frame
|
||||
if (!props.preview) {
|
||||
// if 0 or 1 blocks, use frameless, otherwise use tech
|
||||
const numBlocks = tabData?.blockids?.length ?? 0;
|
||||
if (numBlocks <= 1) {
|
||||
@ -353,6 +363,7 @@ const BlockFrame = React.memo((props: BlockFrameProps) => {
|
||||
} else if (blockData?.meta?.["frame"] === "frameless") {
|
||||
FrameElem = BlockFrame_Frameless;
|
||||
}
|
||||
}
|
||||
return <FrameElem {...props} />;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user