-
Notifications
You must be signed in to change notification settings - Fork 126
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 to inline editable texts
While it would be nice to fully support undo/redo for all editor actions, inline editable text looks like a good place to start. For text blocks we reset the undo history when the value is altered from the outside (e.g., when splitting or merging text blocks by moving elements).
- Loading branch information
Showing
6 changed files
with
63 additions
and
6 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
18 changes: 18 additions & 0 deletions
18
entry_types/scrolled/package/src/frontend/inlineEditing/EditableInlineText/shortcuts.js
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 @@ | ||
import {useCallback} from 'react'; | ||
|
||
export function useShortcutHandler(editor) { | ||
return useCallback(event => { | ||
if (!event.ctrlKey) { | ||
return; | ||
} | ||
|
||
if (event.key === 'z') { | ||
event.preventDefault() | ||
editor.undo(); | ||
} | ||
else if (event.key === 'y') { | ||
event.preventDefault() | ||
editor.redo(); | ||
} | ||
}, [editor]); | ||
} |
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