From f79d780d7ff31ceaffea5e6de9fdf0df09ed7282 Mon Sep 17 00:00:00 2001 From: domino8788 Date: Wed, 16 Dec 2020 19:01:36 +0900 Subject: [PATCH] =?UTF-8?q?[#122]=20feat:=20=EB=B9=84=EC=96=B4=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20Column,=20Grid=20=EB=B8=94=EB=A1=9D=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=EC=82=AD=EC=A0=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../atoms/BlockContent/BlockContent.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/atoms/BlockContent/BlockContent.tsx b/frontend/src/components/atoms/BlockContent/BlockContent.tsx index b4e990c..856752f 100644 --- a/frontend/src/components/atoms/BlockContent/BlockContent.tsx +++ b/frontend/src/components/atoms/BlockContent/BlockContent.tsx @@ -12,7 +12,7 @@ import { placeHolder, listComponent, } from '@utils/blockContent'; -import { useCommand } from '@/hooks'; +import { useCommand, useManager } from '@/hooks'; import { focusState } from '@/stores/page'; const isGridOrColumn = (block: Block): boolean => @@ -53,6 +53,9 @@ const editableDivCSS = (block: Block): SerializedStyles => css` function BlockContent(blockDTO: Block) { const contentEditableRef = useRef(null); const [blockMap, setBlockMap] = useRecoilState(blockMapState); + const [, { startTransaction, commitTransaction, deleteBlock }] = useManager( + blockDTO.id, + ); const focusId = useRecoilValue(focusState); const caretRef = useRef(0); const [Dispatcher] = useCommand(); @@ -126,6 +129,17 @@ function BlockContent(blockDTO: Block) { } }; + if ( + (blockDTO.type === BlockType.GRID || blockDTO.type === BlockType.COLUMN) && + !blockDTO.childIdList.length + ) { + setImmediate(() => { + startTransaction(); + deleteBlock(); + commitTransaction(); + }); + } + useEffect(() => { blockRefState[blockDTO.id] = contentEditableRef; return () => {