Skip to content

Commit f7c7253

Browse files
authored
Merge branch 'dev' into style/#271-K
2 parents eef3437 + 14cdc7d commit f7c7253

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

β€Ž.github/workflows/ci.ymlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
- name: Cache dependencies
2626
id: cache
2727
uses: actions/cache@v3
28+
if: runner.os != 'Windows'
2829
with:
2930
path: '**/node_modules'
3031
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

β€Žclient/src/components/Block/TextBlock.tsxβ€Ž

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ee from '../Mom/EventEmitter';
1515
interface BlockProps {
1616
id: string;
1717
index: number;
18-
onKeyDown: React.KeyboardEventHandler;
18+
onHandleBlock: React.KeyboardEventHandler;
1919
type: BlockType;
2020
setType: (arg: BlockType) => void;
2121
registerRef: (arg: React.RefObject<HTMLElement>) => void;
@@ -24,7 +24,7 @@ interface BlockProps {
2424
function TextBlock({
2525
id,
2626
index,
27-
onKeyDown,
27+
onHandleBlock,
2828
type,
2929
setType,
3030
registerRef,
@@ -43,7 +43,7 @@ function TextBlock({
4343

4444
const blockRef = useRef<HTMLParagraphElement>(null);
4545

46-
const { offsetRef, setOffset, clearOffset, offsetHandlers } =
46+
const { offsetRef, setOffset, clearOffset, onArrowKeyDown, offsetHandlers } =
4747
useOffset(blockRef);
4848

4949
// 리λͺ¨νŠΈ μ—°μ‚° μˆ˜ν–‰κ²°κ³Όλ‘œ innerText λ³€κ²½ μ‹œ μ»€μ„œμ˜ μœ„μΉ˜ μ‘°μ •
@@ -205,19 +205,23 @@ function TextBlock({
205205
updateCaretPosition(pastedText.length);
206206
};
207207

208-
const onKeyDownComposite: React.KeyboardEventHandler<HTMLParagraphElement> = (
209-
e,
210-
) => {
211-
offsetHandlers.onKeyDown(e);
212-
onKeyDown(e);
208+
const onKeyDown: React.KeyboardEventHandler<HTMLParagraphElement> = (e) => {
209+
onArrowKeyDown(e);
210+
onHandleBlock(e);
211+
};
212+
213+
const onBlur = () => {
214+
clearOffset();
215+
setIsOpen(false);
213216
};
214217

215218
const commonHandlers = {
216219
onInput,
217220
onCompositionEnd,
218221
...offsetHandlers,
219-
onKeyDown: onKeyDownComposite,
222+
onKeyDown,
220223
onPaste,
224+
onBlur,
221225
};
222226

223227
const BLOCK_TYPES = Object.values(BlockType)

β€Žclient/src/components/Block/index.tsxβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export enum BlockType {
1919
interface BlockProps {
2020
id: string;
2121
index: number;
22-
onKeyDown: React.KeyboardEventHandler;
22+
onHandleBlock: React.KeyboardEventHandler;
2323
registerRef: (arg: React.RefObject<HTMLElement>) => void;
2424
}
2525

26-
function Block({ id, index, onKeyDown, registerRef }: BlockProps) {
26+
function Block({ id, index, onHandleBlock, registerRef }: BlockProps) {
2727
const { momSocket: socket } = useSocketContext();
2828

2929
const [type, setType] = useState<BlockType>();
@@ -58,7 +58,7 @@ function Block({ id, index, onKeyDown, registerRef }: BlockProps) {
5858
<TextBlock
5959
id={id}
6060
index={index}
61-
onKeyDown={onKeyDown}
61+
onHandleBlock={onHandleBlock}
6262
type={type}
6363
setType={setBlockType}
6464
registerRef={registerRef}

β€Žclient/src/components/Mom/index.tsxβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function Mom() {
7171
range.collapse();
7272
};
7373

74-
const onKeyDown: React.KeyboardEventHandler = (e) => {
74+
const onHandleBlock: React.KeyboardEventHandler = (e) => {
7575
const target = e.target as HTMLParagraphElement;
7676

7777
const { index: indexString } = target.dataset;
@@ -205,7 +205,7 @@ function Mom() {
205205
key={id}
206206
id={id}
207207
index={index}
208-
onKeyDown={onKeyDown}
208+
onHandleBlock={onHandleBlock}
209209
registerRef={(ref: React.RefObject<HTMLElement>) => {
210210
blockRefs.current[index] = ref;
211211
}}

β€Žclient/src/hooks/useOffset.tsxβ€Ž

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function useOffset(blockRef: React.RefObject<HTMLParagraphElement>) {
2929
};
3030

3131
// keydown μ΄λ²€νŠΈλŠ” ν‚€ μž…λ ₯의 λ‚΄μš© 반영 이전에 λ°œμƒ
32-
const onKeyDown: React.KeyboardEventHandler = (e) => {
32+
const onArrowKeyDown: React.KeyboardEventHandler = (e) => {
3333
const ARROW_LEFT = 'ArrowLeft';
3434
const ARROW_RIGHT = 'ArrowRight';
3535

@@ -43,8 +43,8 @@ export function useOffset(blockRef: React.RefObject<HTMLParagraphElement>) {
4343
}
4444
};
4545

46-
// μœ„ μ•„λž˜ λ°©ν–₯ν‚€ 이동은 ν•Έλ“€λ§ν•˜μ§€ μ•ŠμŒ
47-
const onKeyUp: React.KeyboardEventHandler = (e) => {
46+
// μœ„ μ•„λž˜ λ°©ν–₯ν‚€ 이동은 keyDownμ—μ„œ ν•Έλ“€λ§ν•˜μ§€ μ•ŠμŒ
47+
const onArrowKeyup: React.KeyboardEventHandler = (e) => {
4848
const ARROW_DOWN = 'ArrowDown';
4949
const ARROW_UP = 'ArrowUp';
5050

@@ -58,15 +58,14 @@ export function useOffset(blockRef: React.RefObject<HTMLParagraphElement>) {
5858
setOffset as unknown as React.FocusEventHandler<HTMLParagraphElement>,
5959
onClick:
6060
setOffset as unknown as React.MouseEventHandler<HTMLParagraphElement>,
61-
onBlur: clearOffset,
62-
onKeyDown,
63-
onKeyUp,
61+
onKeyUp: onArrowKeyup,
6462
};
6563

6664
return {
6765
offsetRef,
6866
setOffset,
6967
clearOffset,
68+
onArrowKeyDown,
7069
offsetHandlers,
7170
};
7271
}

0 commit comments

Comments
Β (0)