Skip to content

Commit

Permalink
Merge pull request #120 from boostcamp-2020/feat/118
Browse files Browse the repository at this point in the history
BlockContent ์„œ๋ฒ„ ๋™๊ธฐํ™”
  • Loading branch information
domino8788 authored Dec 16, 2020
2 parents cbe614e + f750e3c commit 9803294
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion frontend/src/components/atoms/BlockContent/BlockContent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/** @jsx jsx */
/** @jsxRuntime classic */
import { jsx, css, SerializedStyles } from '@emotion/react';
import { useEffect, useRef, FormEvent, KeyboardEvent } from 'react';
import { useEffect, useRef, FormEvent, KeyboardEvent, useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';

import { blockRefState, throttleState, blockMapState } from '@/stores';
import { Block, BlockType } from '@/schemes';
import { updateBlock } from '@/utils';
import {
regex,
fontSize,
Expand Down Expand Up @@ -57,6 +58,7 @@ function BlockContent(blockDTO: Block) {
const caretRef = useRef(0);
const listCnt = useRef(1);
const [Dispatcher] = useCommand();
const [isBlur, setIsBlur] = useState(false);

const indexInSibling: number = blockMap[
blockDTO.parentId
Expand Down Expand Up @@ -167,6 +169,13 @@ function BlockContent(blockDTO: Block) {
}
};

useEffect(() => {
(async () => {
const { block: updatedBlock } = await updateBlock(blockDTO);
setBlockMap({ ...blockMap, [blockDTO.id]: updatedBlock });
})();
}, [isBlur]);

useEffect(() => {
blockRefState[blockDTO.id] = contentEditableRef;
return () => {
Expand Down Expand Up @@ -210,6 +219,7 @@ function BlockContent(blockDTO: Block) {
placeholder={placeHolder[blockDTO.type]}
onInput={handleValue}
onKeyUp={handleKeyUp}
onBlur={() => setIsBlur(!isBlur)}
>
{blockDTO.value}
</div>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/molecules/Title/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ const titleCss = () => css`
font-family: inter, Helvetica, 'Apple Color Emoji', Arial, sans-serif,
'Segoe UI Emoji', 'Segoe UI Symbol';
&:empty:before {
content: 'Untitled';
color: rgba(55, 53, 47, 0.15);
}
}
`;

function Title(): JSX.Element {
Expand Down

0 comments on commit 9803294

Please sign in to comment.