-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add undo & redo functionality (#1225)
Co-authored-by: Pedro Ferreira <10789765+apedroferreira@users.noreply.github.com>
- Loading branch information
1 parent
ef5ad1b
commit 0c0b7f8
Showing
8 changed files
with
208 additions
and
11 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const SINGLE_ACTION_INPUT_TYPES = ['checkbox', 'radio', 'range', 'color']; | ||
|
||
export const hasFieldFocus = (documentTarget = document) => { | ||
const activeElement = documentTarget.activeElement as HTMLElement | HTMLInputElement; | ||
|
||
if (!activeElement) { | ||
return false; | ||
} | ||
const { nodeName, contentEditable } = activeElement; | ||
|
||
const type = activeElement.getAttribute('type') || ''; | ||
|
||
const focusedInput = nodeName === 'INPUT' && !SINGLE_ACTION_INPUT_TYPES.includes(type); | ||
const focusedTextarea = nodeName === 'TEXTAREA'; | ||
const focusedContentEditable = contentEditable === 'true'; | ||
|
||
return focusedInput || focusedTextarea || focusedContentEditable; | ||
}; |
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