From f3108c88a15dd0ff2c4785f3686642fb6768ed39 Mon Sep 17 00:00:00 2001 From: celine Date: Wed, 14 Jan 2026 19:13:14 -0500 Subject: [PATCH] added move block up and down buttons to the block options buttons, refactored moveBlockUp/Down to be utility functions --- components/Blocks/Block.tsx | 54 +++++++++++++++--- components/Blocks/ImageBlock.tsx | 3 +- components/Icons/DeleteTiny.tsx | 19 +++++++ components/SelectionManager/index.tsx | 72 ++---------------------- components/Toolbar/BlockToolbar.tsx | 75 ++----------------------- src/replicache/mutations.ts | 39 ++++++++++--- src/utils/moveBlock.ts | 81 +++++++++++++++++++++++++++ 7 files changed, 189 insertions(+), 154 deletions(-) create mode 100644 components/Icons/DeleteTiny.tsx create mode 100644 src/utils/moveBlock.ts diff --git a/components/Blocks/Block.tsx b/components/Blocks/Block.tsx index 94f29c67..67f62860 100644 --- a/components/Blocks/Block.tsx +++ b/components/Blocks/Block.tsx @@ -34,6 +34,9 @@ import { deepEquals } from "src/utils/deepEquals"; import { isTextBlock } from "src/utils/isTextBlock"; import { focusPage } from "src/utils/focusPage"; import { DeleteTiny } from "components/Icons/DeleteTiny"; +import { ArrowDownTiny } from "components/Icons/ArrowDownTiny"; +import { Separator } from "components/Layout"; +import { moveBlockUp, moveBlockDown } from "src/utils/moveBlock"; export type Block = { factID: string; @@ -395,7 +398,9 @@ export const BlockLayout = (props: { }) => { // this is used to wrap non-text blocks in consistent selected styling, spacing, and top level options like delete return ( -
+
{props.children}
- {props.isSelected && } + {props.isSelected && }
); }; -const DeleteBlock = () => { +const NonTextBlockOptions = (props: { isCanvas?: boolean }) => { + let { rep } = useReplicache(); + let entity_set = useEntitySetContext(); + let focusedEntity = useUIState((s) => s.focusedEntity); + + let focusedEntityType = useEntity( + focusedEntity?.entityType === "page" + ? focusedEntity.entityID + : focusedEntity?.parent || null, + "page/type", + ); + + let isMultiselected = useUIState((s) => s.selectedBlocks.length > 1); + + if (isMultiselected) return; + return ( -
- + + + + )} +
diff --git a/components/Blocks/ImageBlock.tsx b/components/Blocks/ImageBlock.tsx index b374de53..e7cb3bab 100644 --- a/components/Blocks/ImageBlock.tsx +++ b/components/Blocks/ImageBlock.tsx @@ -90,10 +90,9 @@ export function ImageBlock(props: BlockProps & { preview?: boolean }) { >