UNPKG

@wordpress/edit-post

Version:
45 lines (40 loc) 1.46 kB
import { createElement } from "@wordpress/element"; /** * WordPress dependencies */ import { PostTextEditor, PostTitle, TextEditorGlobalKeyboardShortcuts } from '@wordpress/editor'; import { Button } from '@wordpress/components'; import { withDispatch, withSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { displayShortcut } from '@wordpress/keycodes'; import { compose } from '@wordpress/compose'; /** * Internal dependencies */ import { store as editPostStore } from '../../store'; function TextEditor({ onExit, isRichEditingEnabled }) { return createElement("div", { className: "edit-post-text-editor" }, isRichEditingEnabled && createElement("div", { className: "edit-post-text-editor__toolbar" }, createElement("h2", null, __('Editing code')), createElement(Button, { isTertiary: true, onClick: onExit, shortcut: displayShortcut.secondary('m') }, __('Exit code editor')), createElement(TextEditorGlobalKeyboardShortcuts, null)), createElement("div", { className: "edit-post-text-editor__body" }, createElement(PostTitle, null), createElement(PostTextEditor, null))); } export default compose(withSelect(select => ({ isRichEditingEnabled: select('core/editor').getEditorSettings().richEditingEnabled })), withDispatch(dispatch => { return { onExit() { dispatch(editPostStore).switchEditorMode('visual'); } }; }))(TextEditor); //# sourceMappingURL=index.js.map