-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Design endringer brevredigering & keyboard shortcuts for tekststil (#952
) * gjør brevredigering mer responsiv * fjern dokumenttado fra sakspart * keyboard shortcuts for endring av tekst-style * editor får focus ved manuell endring av tekststil & clean up * fiks test * fiks stylelint error
- Loading branch information
1 parent
e7f8617
commit c204082
Showing
7 changed files
with
141 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
skribenten-web/frontend/src/Brevredigering/LetterEditor/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { Dispatch, SetStateAction } from "react"; | ||
|
||
import Actions from "./actions"; | ||
import { applyAction } from "./lib/actions"; | ||
import type { LetterEditorState } from "./model/state"; | ||
|
||
export enum Typography { | ||
PARAGRAPH = "PARAGRAPH", | ||
TITLE1 = "TITLE1", | ||
TITLE2 = "TITLE2", | ||
} | ||
|
||
export const TypographyToText = { | ||
[Typography.PARAGRAPH]: "Normal (alt+1)", | ||
[Typography.TITLE1]: "Overskrift (alt+2)", | ||
[Typography.TITLE2]: "Underoverskrift (alt+3)", | ||
} as const; | ||
|
||
export const useEditorKeyboardShortcuts = ( | ||
editorState: LetterEditorState, | ||
setEditorState: Dispatch<SetStateAction<LetterEditorState>>, | ||
) => { | ||
return (event: React.KeyboardEvent<HTMLDivElement>) => { | ||
if (event.altKey && event.code === "Digit1") { | ||
event.preventDefault(); | ||
applyAction(Actions.switchTypography, setEditorState, editorState.focus, Typography.PARAGRAPH); | ||
} else if (event.altKey && event.code === "Digit2") { | ||
event.preventDefault(); | ||
applyAction(Actions.switchTypography, setEditorState, editorState.focus, Typography.TITLE1); | ||
} else if (event.altKey && event.code === "Digit3") { | ||
event.preventDefault(); | ||
applyAction(Actions.switchTypography, setEditorState, editorState.focus, Typography.TITLE2); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters