Skip to content

Commit 9803294

Browse files
authored
Merge pull request #120 from boostcamp-2020/feat/118
BlockContent ์„œ๋ฒ„ ๋™๊ธฐํ™”
2 parents cbe614e + f750e3c commit 9803294

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

โ€Žfrontend/src/components/atoms/BlockContent/BlockContent.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/** @jsx jsx */
22
/** @jsxRuntime classic */
33
import { jsx, css, SerializedStyles } from '@emotion/react';
4-
import { useEffect, useRef, FormEvent, KeyboardEvent } from 'react';
4+
import { useEffect, useRef, FormEvent, KeyboardEvent, useState } from 'react';
55
import { useRecoilState, useRecoilValue } from 'recoil';
66

77
import { blockRefState, throttleState, blockMapState } from '@/stores';
88
import { Block, BlockType } from '@/schemes';
9+
import { updateBlock } from '@/utils';
910
import {
1011
regex,
1112
fontSize,
@@ -57,6 +58,7 @@ function BlockContent(blockDTO: Block) {
5758
const caretRef = useRef(0);
5859
const listCnt = useRef(1);
5960
const [Dispatcher] = useCommand();
61+
const [isBlur, setIsBlur] = useState(false);
6062

6163
const indexInSibling: number = blockMap[
6264
blockDTO.parentId
@@ -167,6 +169,13 @@ function BlockContent(blockDTO: Block) {
167169
}
168170
};
169171

172+
useEffect(() => {
173+
(async () => {
174+
const { block: updatedBlock } = await updateBlock(blockDTO);
175+
setBlockMap({ ...blockMap, [blockDTO.id]: updatedBlock });
176+
})();
177+
}, [isBlur]);
178+
170179
useEffect(() => {
171180
blockRefState[blockDTO.id] = contentEditableRef;
172181
return () => {
@@ -210,6 +219,7 @@ function BlockContent(blockDTO: Block) {
210219
placeholder={placeHolder[blockDTO.type]}
211220
onInput={handleValue}
212221
onKeyUp={handleKeyUp}
222+
onBlur={() => setIsBlur(!isBlur)}
213223
>
214224
{blockDTO.value}
215225
</div>

โ€Žfrontend/src/components/molecules/Title/Title.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ const titleCss = () => css`
3939
4040
font-family: inter, Helvetica, 'Apple Color Emoji', Arial, sans-serif,
4141
'Segoe UI Emoji', 'Segoe UI Symbol';
42-
42+
4343
&:empty:before {
4444
content: 'Untitled';
4545
color: rgba(55, 53, 47, 0.15);
4646
}
47-
}
4847
`;
4948

5049
function Title(): JSX.Element {

0 commit comments

Comments
ย (0)