-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify the code editor of edit-post (#52751)
- Loading branch information
1 parent
d27c43f
commit 2c78282
Showing
12 changed files
with
99 additions
and
456 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
137 changes: 0 additions & 137 deletions
137
packages/edit-site/src/components/keyboard-shortcuts/index.js
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
packages/editor/src/components/global-keyboard-shortcuts/index.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,49 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useShortcut } from '@wordpress/keyboard-shortcuts'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editorStore } from '../../store'; | ||
|
||
export default function EditorKeyboardShortcuts() { | ||
const { redo, undo, savePost } = useDispatch( editorStore ); | ||
const { isEditedPostDirty, isPostSavingLocked } = useSelect( editorStore ); | ||
|
||
useShortcut( 'core/editor/undo', ( event ) => { | ||
undo(); | ||
event.preventDefault(); | ||
} ); | ||
|
||
useShortcut( 'core/editor/redo', ( event ) => { | ||
redo(); | ||
event.preventDefault(); | ||
} ); | ||
|
||
useShortcut( 'core/editor/save', ( event ) => { | ||
event.preventDefault(); | ||
|
||
/** | ||
* Do not save the post if post saving is locked. | ||
*/ | ||
if ( isPostSavingLocked() ) { | ||
return; | ||
} | ||
|
||
// TODO: This should be handled in the `savePost` effect in | ||
// considering `isSaveable`. See note on `isEditedPostSaveable` | ||
// selector about dirtiness and meta-boxes. | ||
// | ||
// See: `isEditedPostSaveable` | ||
if ( ! isEditedPostDirty() ) { | ||
return; | ||
} | ||
|
||
savePost(); | ||
} ); | ||
|
||
return null; | ||
} |
55 changes: 0 additions & 55 deletions
55
packages/editor/src/components/global-keyboard-shortcuts/save-shortcut.js
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
packages/editor/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
packages/editor/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
2c78282
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 2c78282.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5597917221
📝 Reported issues:
/test/e2e/specs/editor/blocks/image.spec.js
/test/e2e/specs/editor/blocks/image.spec.js
/test/e2e/specs/editor/blocks/image.spec.js