@wordpress/edit-post 7.24.0 → 7.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/header/header-toolbar/index.js +8 -4
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js +13 -11
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +1 -1
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +2 -1
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +13 -12
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/layout/index.js +12 -12
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +65 -49
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +1 -2
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/settings-header/index.js +17 -43
- package/build/components/sidebar/settings-header/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +80 -20
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +3 -3
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/visual-editor/index.js +20 -257
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/welcome-guide/index.js +6 -3
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/editor.js +5 -6
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +1 -2
- package/build/editor.native.js.map +1 -1
- package/build/index.js +5 -4
- package/build/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +2 -6
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +35 -39
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +1 -34
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +22 -12
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +8 -4
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js +15 -13
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +1 -1
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +2 -1
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +14 -13
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/layout/index.js +13 -13
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +65 -49
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +2 -3
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/settings-header/index.js +20 -46
- package/build-module/components/sidebar/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +80 -21
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +3 -3
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +24 -261
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +6 -3
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/editor.js +5 -6
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +1 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/index.js +3 -2
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +2 -6
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +31 -36
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +1 -33
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +18 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +63 -200
- package/build-style/style.css +63 -200
- package/package.json +32 -32
- package/src/components/header/header-toolbar/index.js +4 -0
- package/src/components/header/header-toolbar/style.scss +15 -13
- package/src/components/header/index.js +28 -13
- package/src/components/header/mode-switcher/index.js +2 -1
- package/src/components/header/more-menu/index.js +1 -0
- package/src/components/header/style.scss +60 -34
- package/src/components/header/writing-menu/index.js +16 -18
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +1 -1
- package/src/components/layout/index.js +13 -12
- package/src/components/preferences-modal/index.js +109 -96
- package/src/components/preferences-modal/test/index.js +1 -52
- package/src/components/sidebar/post-status/index.js +2 -2
- package/src/components/sidebar/settings-header/index.js +19 -71
- package/src/components/sidebar/settings-sidebar/index.js +117 -54
- package/src/components/sidebar/style.scss +4 -12
- package/src/components/start-page-options/index.js +3 -3
- package/src/components/visual-editor/index.js +26 -359
- package/src/components/visual-editor/style.scss +0 -15
- package/src/components/welcome-guide/index.js +4 -2
- package/src/editor.js +7 -7
- package/src/editor.native.js +3 -9
- package/src/index.js +3 -2
- package/src/plugins/welcome-guide-menu-item/index.js +3 -6
- package/src/store/actions.js +32 -46
- package/src/store/reducer.js +0 -33
- package/src/store/selectors.js +23 -9
- package/src/store/test/actions.js +0 -28
- package/src/style.scss +0 -3
- package/src/test/__snapshots__/editor.native.js.snap +21 -0
- package/src/test/editor.native.js +90 -56
- package/build/components/device-preview/index.js +0 -72
- package/build/components/device-preview/index.js.map +0 -1
- package/build/components/header/document-actions/index.js +0 -82
- package/build/components/header/document-actions/index.js.map +0 -1
- package/build/components/sidebar/post-template/create-modal.js +0 -99
- package/build/components/sidebar/post-template/create-modal.js.map +0 -1
- package/build/components/sidebar/post-template/form.js +0 -110
- package/build/components/sidebar/post-template/form.js.map +0 -1
- package/build/components/sidebar/post-template/index.js +0 -106
- package/build/components/sidebar/post-template/index.js.map +0 -1
- package/build-module/components/device-preview/index.js +0 -65
- package/build-module/components/device-preview/index.js.map +0 -1
- package/build-module/components/header/document-actions/index.js +0 -74
- package/build-module/components/header/document-actions/index.js.map +0 -1
- package/build-module/components/sidebar/post-template/create-modal.js +0 -92
- package/build-module/components/sidebar/post-template/create-modal.js.map +0 -1
- package/build-module/components/sidebar/post-template/form.js +0 -102
- package/build-module/components/sidebar/post-template/form.js.map +0 -1
- package/build-module/components/sidebar/post-template/index.js +0 -98
- package/build-module/components/sidebar/post-template/index.js.map +0 -1
- package/src/components/device-preview/index.js +0 -73
- package/src/components/header/document-actions/index.js +0 -82
- package/src/components/header/document-actions/style.scss +0 -64
- package/src/components/sidebar/post-template/create-modal.js +0 -140
- package/src/components/sidebar/post-template/form.js +0 -141
- package/src/components/sidebar/post-template/index.js +0 -120
- package/src/components/sidebar/post-template/style.scss +0 -22
- package/src/components/sidebar/settings-header/style.scss +0 -74
- package/src/components/sidebar/template/style.scss +0 -35
|
@@ -6,24 +6,13 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { PostTitle, store as editorStore } from '@wordpress/editor';
|
|
10
9
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__unstableUseTypingObserver as useTypingObserver,
|
|
16
|
-
__experimentalUseResizeCanvas as useResizeCanvas,
|
|
17
|
-
useSettings,
|
|
18
|
-
__experimentalRecursionProvider as RecursionProvider,
|
|
19
|
-
privateApis as blockEditorPrivateApis,
|
|
20
|
-
} from '@wordpress/block-editor';
|
|
21
|
-
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
22
|
-
import { __unstableMotion as motion } from '@wordpress/components';
|
|
10
|
+
store as editorStore,
|
|
11
|
+
privateApis as editorPrivateApis,
|
|
12
|
+
} from '@wordpress/editor';
|
|
13
|
+
import { useMemo } from '@wordpress/element';
|
|
23
14
|
import { useSelect } from '@wordpress/data';
|
|
24
|
-
import {
|
|
25
|
-
import { parse, store as blocksStore } from '@wordpress/blocks';
|
|
26
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
15
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
27
16
|
|
|
28
17
|
/**
|
|
29
18
|
* Internal dependencies
|
|
@@ -31,398 +20,76 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
31
20
|
import { store as editPostStore } from '../../store';
|
|
32
21
|
import { unlock } from '../../lock-unlock';
|
|
33
22
|
|
|
34
|
-
const {
|
|
35
|
-
LayoutStyle,
|
|
36
|
-
useLayoutClasses,
|
|
37
|
-
useLayoutStyles,
|
|
38
|
-
ExperimentalBlockCanvas: BlockCanvas,
|
|
39
|
-
} = unlock( blockEditorPrivateApis );
|
|
23
|
+
const { EditorCanvas } = unlock( editorPrivateApis );
|
|
40
24
|
|
|
41
25
|
const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;
|
|
42
26
|
|
|
43
|
-
/**
|
|
44
|
-
* Given an array of nested blocks, find the first Post Content
|
|
45
|
-
* block inside it, recursing through any nesting levels,
|
|
46
|
-
* and return its attributes.
|
|
47
|
-
*
|
|
48
|
-
* @param {Array} blocks A list of blocks.
|
|
49
|
-
*
|
|
50
|
-
* @return {Object | undefined} The Post Content block.
|
|
51
|
-
*/
|
|
52
|
-
function getPostContentAttributes( blocks ) {
|
|
53
|
-
for ( let i = 0; i < blocks.length; i++ ) {
|
|
54
|
-
if ( blocks[ i ].name === 'core/post-content' ) {
|
|
55
|
-
return blocks[ i ].attributes;
|
|
56
|
-
}
|
|
57
|
-
if ( blocks[ i ].innerBlocks.length ) {
|
|
58
|
-
const nestedPostContent = getPostContentAttributes(
|
|
59
|
-
blocks[ i ].innerBlocks
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
if ( nestedPostContent ) {
|
|
63
|
-
return nestedPostContent;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function checkForPostContentAtRootLevel( blocks ) {
|
|
70
|
-
for ( let i = 0; i < blocks.length; i++ ) {
|
|
71
|
-
if ( blocks[ i ].name === 'core/post-content' ) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
27
|
export default function VisualEditor( { styles } ) {
|
|
79
28
|
const {
|
|
80
|
-
deviceType,
|
|
81
29
|
isWelcomeGuideVisible,
|
|
82
|
-
|
|
83
|
-
postContentAttributes,
|
|
84
|
-
editedPostTemplate = {},
|
|
85
|
-
wrapperBlockName,
|
|
86
|
-
wrapperUniqueId,
|
|
30
|
+
renderingMode,
|
|
87
31
|
isBlockBasedTheme,
|
|
88
32
|
hasV3BlocksOnly,
|
|
89
33
|
} = useSelect( ( select ) => {
|
|
90
|
-
const {
|
|
91
|
-
|
|
92
|
-
isEditingTemplate,
|
|
93
|
-
getEditedPostTemplate,
|
|
94
|
-
__experimentalGetPreviewDeviceType,
|
|
95
|
-
} = select( editPostStore );
|
|
96
|
-
const { getCurrentPostId, getCurrentPostType, getEditorSettings } =
|
|
97
|
-
select( editorStore );
|
|
34
|
+
const { isFeatureActive } = select( editPostStore );
|
|
35
|
+
const { getEditorSettings, getRenderingMode } = select( editorStore );
|
|
98
36
|
const { getBlockTypes } = select( blocksStore );
|
|
99
|
-
const _isTemplateMode = isEditingTemplate();
|
|
100
|
-
const postTypeSlug = getCurrentPostType();
|
|
101
|
-
let _wrapperBlockName;
|
|
102
|
-
|
|
103
|
-
if ( postTypeSlug === 'wp_block' ) {
|
|
104
|
-
_wrapperBlockName = 'core/block';
|
|
105
|
-
} else if ( ! _isTemplateMode ) {
|
|
106
|
-
_wrapperBlockName = 'core/post-content';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
37
|
const editorSettings = getEditorSettings();
|
|
110
|
-
const supportsTemplateMode = editorSettings.supportsTemplateMode;
|
|
111
|
-
const postType = select( coreStore ).getPostType( postTypeSlug );
|
|
112
|
-
const canEditTemplate = select( coreStore ).canUser(
|
|
113
|
-
'create',
|
|
114
|
-
'templates'
|
|
115
|
-
);
|
|
116
38
|
|
|
117
39
|
return {
|
|
118
|
-
deviceType: __experimentalGetPreviewDeviceType(),
|
|
119
40
|
isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),
|
|
120
|
-
|
|
121
|
-
postContentAttributes: getEditorSettings().postContentAttributes,
|
|
122
|
-
// Post template fetch returns a 404 on classic themes, which
|
|
123
|
-
// messes with e2e tests, so check it's a block theme first.
|
|
124
|
-
editedPostTemplate:
|
|
125
|
-
postType?.viewable && supportsTemplateMode && canEditTemplate
|
|
126
|
-
? getEditedPostTemplate()
|
|
127
|
-
: undefined,
|
|
128
|
-
wrapperBlockName: _wrapperBlockName,
|
|
129
|
-
wrapperUniqueId: getCurrentPostId(),
|
|
41
|
+
renderingMode: getRenderingMode(),
|
|
130
42
|
isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
|
|
131
43
|
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
|
|
132
44
|
return type.apiVersion >= 3;
|
|
133
45
|
} ),
|
|
134
46
|
};
|
|
135
47
|
}, [] );
|
|
136
|
-
const { isCleanNewPost } = useSelect( editorStore );
|
|
137
48
|
const hasMetaBoxes = useSelect(
|
|
138
49
|
( select ) => select( editPostStore ).hasMetaBoxes(),
|
|
139
50
|
[]
|
|
140
51
|
);
|
|
141
|
-
const {
|
|
142
|
-
hasRootPaddingAwareAlignments,
|
|
143
|
-
isFocusMode,
|
|
144
|
-
themeHasDisabledLayoutStyles,
|
|
145
|
-
themeSupportsLayout,
|
|
146
|
-
} = useSelect( ( select ) => {
|
|
147
|
-
const _settings = select( blockEditorStore ).getSettings();
|
|
148
|
-
return {
|
|
149
|
-
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
150
|
-
themeSupportsLayout: _settings.supportsLayout,
|
|
151
|
-
isFocusMode: _settings.focusMode,
|
|
152
|
-
hasRootPaddingAwareAlignments:
|
|
153
|
-
_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
|
|
154
|
-
};
|
|
155
|
-
}, [] );
|
|
156
|
-
const desktopCanvasStyles = {
|
|
157
|
-
height: '100%',
|
|
158
|
-
width: '100%',
|
|
159
|
-
marginLeft: 'auto',
|
|
160
|
-
marginRight: 'auto',
|
|
161
|
-
display: 'flex',
|
|
162
|
-
flexFlow: 'column',
|
|
163
|
-
// Default background color so that grey
|
|
164
|
-
// .edit-post-editor-regions__content color doesn't show through.
|
|
165
|
-
background: 'white',
|
|
166
|
-
};
|
|
167
|
-
const templateModeStyles = {
|
|
168
|
-
...desktopCanvasStyles,
|
|
169
|
-
borderRadius: '2px 2px 0 0',
|
|
170
|
-
border: '1px solid #ddd',
|
|
171
|
-
borderBottom: 0,
|
|
172
|
-
};
|
|
173
|
-
const resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );
|
|
174
|
-
const [ globalLayoutSettings ] = useSettings( 'layout' );
|
|
175
|
-
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
|
|
176
|
-
|
|
177
|
-
let animatedStyles = isTemplateMode
|
|
178
|
-
? templateModeStyles
|
|
179
|
-
: desktopCanvasStyles;
|
|
180
|
-
if ( resizedCanvasStyles ) {
|
|
181
|
-
animatedStyles = resizedCanvasStyles;
|
|
182
|
-
}
|
|
183
52
|
|
|
184
53
|
let paddingBottom;
|
|
185
54
|
|
|
186
55
|
// Add a constant padding for the typewritter effect. When typing at the
|
|
187
56
|
// bottom, there needs to be room to scroll up.
|
|
188
|
-
if ( ! hasMetaBoxes &&
|
|
57
|
+
if ( ! hasMetaBoxes && renderingMode === 'post-only' ) {
|
|
189
58
|
paddingBottom = '40vh';
|
|
190
59
|
}
|
|
191
60
|
|
|
192
|
-
const ref = useRef();
|
|
193
|
-
const contentRef = useMergeRefs( [ ref, useTypewriter() ] );
|
|
194
|
-
|
|
195
|
-
// fallbackLayout is used if there is no Post Content,
|
|
196
|
-
// and for Post Title.
|
|
197
|
-
const fallbackLayout = useMemo( () => {
|
|
198
|
-
if ( isTemplateMode ) {
|
|
199
|
-
return { type: 'default' };
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if ( themeSupportsLayout ) {
|
|
203
|
-
// We need to ensure support for wide and full alignments,
|
|
204
|
-
// so we add the constrained type.
|
|
205
|
-
return { ...globalLayoutSettings, type: 'constrained' };
|
|
206
|
-
}
|
|
207
|
-
// Set default layout for classic themes so all alignments are supported.
|
|
208
|
-
return { type: 'default' };
|
|
209
|
-
}, [ isTemplateMode, themeSupportsLayout, globalLayoutSettings ] );
|
|
210
|
-
|
|
211
|
-
const newestPostContentAttributes = useMemo( () => {
|
|
212
|
-
if ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {
|
|
213
|
-
return postContentAttributes;
|
|
214
|
-
}
|
|
215
|
-
// When in template editing mode, we can access the blocks directly.
|
|
216
|
-
if ( editedPostTemplate?.blocks ) {
|
|
217
|
-
return getPostContentAttributes( editedPostTemplate?.blocks );
|
|
218
|
-
}
|
|
219
|
-
// If there are no blocks, we have to parse the content string.
|
|
220
|
-
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
221
|
-
const parseableContent =
|
|
222
|
-
typeof editedPostTemplate?.content === 'string'
|
|
223
|
-
? editedPostTemplate?.content
|
|
224
|
-
: '';
|
|
225
|
-
|
|
226
|
-
return getPostContentAttributes( parse( parseableContent ) ) || {};
|
|
227
|
-
}, [
|
|
228
|
-
editedPostTemplate?.content,
|
|
229
|
-
editedPostTemplate?.blocks,
|
|
230
|
-
postContentAttributes,
|
|
231
|
-
] );
|
|
232
|
-
|
|
233
|
-
const hasPostContentAtRootLevel = useMemo( () => {
|
|
234
|
-
if ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
// When in template editing mode, we can access the blocks directly.
|
|
238
|
-
if ( editedPostTemplate?.blocks ) {
|
|
239
|
-
return checkForPostContentAtRootLevel( editedPostTemplate?.blocks );
|
|
240
|
-
}
|
|
241
|
-
// If there are no blocks, we have to parse the content string.
|
|
242
|
-
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
243
|
-
const parseableContent =
|
|
244
|
-
typeof editedPostTemplate?.content === 'string'
|
|
245
|
-
? editedPostTemplate?.content
|
|
246
|
-
: '';
|
|
247
|
-
|
|
248
|
-
return (
|
|
249
|
-
checkForPostContentAtRootLevel( parse( parseableContent ) ) || false
|
|
250
|
-
);
|
|
251
|
-
}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );
|
|
252
|
-
|
|
253
|
-
const { layout = {}, align = '' } = newestPostContentAttributes || {};
|
|
254
|
-
|
|
255
|
-
const postContentLayoutClasses = useLayoutClasses(
|
|
256
|
-
newestPostContentAttributes,
|
|
257
|
-
'core/post-content'
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
const blockListLayoutClass = classnames(
|
|
261
|
-
{
|
|
262
|
-
'is-layout-flow': ! themeSupportsLayout,
|
|
263
|
-
},
|
|
264
|
-
themeSupportsLayout && postContentLayoutClasses,
|
|
265
|
-
align && `align${ align }`
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
const postContentLayoutStyles = useLayoutStyles(
|
|
269
|
-
newestPostContentAttributes,
|
|
270
|
-
'core/post-content',
|
|
271
|
-
'.block-editor-block-list__layout.is-root-container'
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
// Update type for blocks using legacy layouts.
|
|
275
|
-
const postContentLayout = useMemo( () => {
|
|
276
|
-
return layout &&
|
|
277
|
-
( layout?.type === 'constrained' ||
|
|
278
|
-
layout?.inherit ||
|
|
279
|
-
layout?.contentSize ||
|
|
280
|
-
layout?.wideSize )
|
|
281
|
-
? { ...globalLayoutSettings, ...layout, type: 'constrained' }
|
|
282
|
-
: { ...globalLayoutSettings, ...layout, type: 'default' };
|
|
283
|
-
}, [
|
|
284
|
-
layout?.type,
|
|
285
|
-
layout?.inherit,
|
|
286
|
-
layout?.contentSize,
|
|
287
|
-
layout?.wideSize,
|
|
288
|
-
globalLayoutSettings,
|
|
289
|
-
] );
|
|
290
|
-
|
|
291
|
-
// If there is a Post Content block we use its layout for the block list;
|
|
292
|
-
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
293
|
-
const blockListLayout = postContentAttributes
|
|
294
|
-
? postContentLayout
|
|
295
|
-
: fallbackLayout;
|
|
296
|
-
|
|
297
|
-
const postEditorLayout =
|
|
298
|
-
blockListLayout?.type === 'default' && ! hasPostContentAtRootLevel
|
|
299
|
-
? fallbackLayout
|
|
300
|
-
: blockListLayout;
|
|
301
|
-
|
|
302
|
-
const observeTypingRef = useTypingObserver();
|
|
303
|
-
const titleRef = useRef();
|
|
304
|
-
useEffect( () => {
|
|
305
|
-
if ( isWelcomeGuideVisible || ! isCleanNewPost() ) {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
titleRef?.current?.focus();
|
|
309
|
-
}, [ isWelcomeGuideVisible, isCleanNewPost ] );
|
|
310
|
-
|
|
311
61
|
styles = useMemo(
|
|
312
62
|
() => [
|
|
313
63
|
...styles,
|
|
314
64
|
{
|
|
315
65
|
// We should move this in to future to the body.
|
|
316
|
-
css:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
? `body{padding-bottom:${ paddingBottom }}`
|
|
320
|
-
: '' ),
|
|
66
|
+
css: paddingBottom
|
|
67
|
+
? `body{padding-bottom:${ paddingBottom }}`
|
|
68
|
+
: '',
|
|
321
69
|
},
|
|
322
70
|
],
|
|
323
|
-
[ styles ]
|
|
71
|
+
[ styles, paddingBottom ]
|
|
324
72
|
);
|
|
325
73
|
|
|
326
|
-
// Add some styles for alignwide/alignfull Post Content and its children.
|
|
327
|
-
const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
|
|
328
|
-
.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
|
|
329
|
-
.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
|
|
330
|
-
.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
|
|
331
|
-
|
|
332
74
|
const isToBeIframed =
|
|
333
75
|
( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&
|
|
334
76
|
! hasMetaBoxes ) ||
|
|
335
|
-
|
|
336
|
-
deviceType === 'Tablet' ||
|
|
337
|
-
deviceType === 'Mobile';
|
|
77
|
+
renderingMode === 'template-only';
|
|
338
78
|
|
|
339
79
|
return (
|
|
340
|
-
<
|
|
341
|
-
__unstableContentRef={ ref }
|
|
80
|
+
<div
|
|
342
81
|
className={ classnames( 'edit-post-visual-editor', {
|
|
343
|
-
'is-template-mode':
|
|
82
|
+
'is-template-mode': renderingMode === 'template-only',
|
|
344
83
|
'has-inline-canvas': ! isToBeIframed,
|
|
345
84
|
} ) }
|
|
346
85
|
>
|
|
347
|
-
<
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
initial={ desktopCanvasStyles }
|
|
356
|
-
className={ previewMode }
|
|
357
|
-
>
|
|
358
|
-
<BlockCanvas
|
|
359
|
-
shouldIframe={ isToBeIframed }
|
|
360
|
-
contentRef={ contentRef }
|
|
361
|
-
styles={ styles }
|
|
362
|
-
height="100%"
|
|
363
|
-
>
|
|
364
|
-
{ themeSupportsLayout &&
|
|
365
|
-
! themeHasDisabledLayoutStyles &&
|
|
366
|
-
! isTemplateMode && (
|
|
367
|
-
<>
|
|
368
|
-
<LayoutStyle
|
|
369
|
-
selector=".edit-post-visual-editor__post-title-wrapper"
|
|
370
|
-
layout={ fallbackLayout }
|
|
371
|
-
/>
|
|
372
|
-
<LayoutStyle
|
|
373
|
-
selector=".block-editor-block-list__layout.is-root-container"
|
|
374
|
-
layout={ postEditorLayout }
|
|
375
|
-
/>
|
|
376
|
-
{ align && (
|
|
377
|
-
<LayoutStyle css={ alignCSS } />
|
|
378
|
-
) }
|
|
379
|
-
{ postContentLayoutStyles && (
|
|
380
|
-
<LayoutStyle
|
|
381
|
-
layout={ postContentLayout }
|
|
382
|
-
css={ postContentLayoutStyles }
|
|
383
|
-
/>
|
|
384
|
-
) }
|
|
385
|
-
</>
|
|
386
|
-
) }
|
|
387
|
-
{ ! isTemplateMode && (
|
|
388
|
-
<div
|
|
389
|
-
className={ classnames(
|
|
390
|
-
'edit-post-visual-editor__post-title-wrapper',
|
|
391
|
-
{
|
|
392
|
-
'is-focus-mode': isFocusMode,
|
|
393
|
-
'has-global-padding':
|
|
394
|
-
hasRootPaddingAwareAlignments,
|
|
395
|
-
}
|
|
396
|
-
) }
|
|
397
|
-
contentEditable={ false }
|
|
398
|
-
ref={ observeTypingRef }
|
|
399
|
-
>
|
|
400
|
-
<PostTitle ref={ titleRef } />
|
|
401
|
-
</div>
|
|
402
|
-
) }
|
|
403
|
-
<RecursionProvider
|
|
404
|
-
blockName={ wrapperBlockName }
|
|
405
|
-
uniqueId={ wrapperUniqueId }
|
|
406
|
-
>
|
|
407
|
-
<BlockList
|
|
408
|
-
className={
|
|
409
|
-
isTemplateMode
|
|
410
|
-
? 'wp-site-blocks'
|
|
411
|
-
: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
412
|
-
}
|
|
413
|
-
layout={ blockListLayout }
|
|
414
|
-
dropZoneElement={
|
|
415
|
-
// When iframed, pass in the html element of the iframe to
|
|
416
|
-
// ensure the drop zone extends to the edges of the iframe.
|
|
417
|
-
isToBeIframed
|
|
418
|
-
? ref.current?.parentNode
|
|
419
|
-
: ref.current
|
|
420
|
-
}
|
|
421
|
-
/>
|
|
422
|
-
</RecursionProvider>
|
|
423
|
-
</BlockCanvas>
|
|
424
|
-
</motion.div>
|
|
425
|
-
</motion.div>
|
|
426
|
-
</BlockTools>
|
|
86
|
+
<EditorCanvas
|
|
87
|
+
disableIframe={ ! isToBeIframed }
|
|
88
|
+
styles={ styles }
|
|
89
|
+
// We should auto-focus the canvas (title) on load.
|
|
90
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
91
|
+
autoFocus={ ! isWelcomeGuideVisible }
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
427
94
|
);
|
|
428
95
|
}
|
|
@@ -38,21 +38,6 @@
|
|
|
38
38
|
// See also https://www.w3.org/TR/CSS22/visudet.html#the-height-property.
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// Ideally this wrapper div is not needed but if we want to match the positioning of blocks
|
|
42
|
-
// .block-editor-block-list__layout and block-editor-block-list__block
|
|
43
|
-
// We need to have two DOM elements.
|
|
44
|
-
.edit-post-visual-editor__post-title-wrapper {
|
|
45
|
-
.editor-post-title {
|
|
46
|
-
// Center.
|
|
47
|
-
margin-left: auto;
|
|
48
|
-
margin-right: auto;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Add extra margin at the top, to push down the Title area in the post editor.
|
|
52
|
-
margin-top: 4rem;
|
|
53
|
-
margin-bottom: var(--wp--style--block-gap);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
41
|
.edit-post-visual-editor__content-area {
|
|
57
42
|
width: 100%;
|
|
58
43
|
height: 100%;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -12,8 +13,9 @@ import { store as editPostStore } from '../../store';
|
|
|
12
13
|
|
|
13
14
|
export default function WelcomeGuide() {
|
|
14
15
|
const { isActive, isTemplateMode } = useSelect( ( select ) => {
|
|
15
|
-
const { isFeatureActive
|
|
16
|
-
const
|
|
16
|
+
const { isFeatureActive } = select( editPostStore );
|
|
17
|
+
const { getRenderingMode } = select( editorStore );
|
|
18
|
+
const _isTemplateMode = getRenderingMode() === 'template-only';
|
|
17
19
|
const feature = _isTemplateMode
|
|
18
20
|
? 'welcomeGuideTemplate'
|
|
19
21
|
: 'welcomeGuide';
|
package/src/editor.js
CHANGED
|
@@ -14,6 +14,7 @@ import { SlotFillProvider } from '@wordpress/components';
|
|
|
14
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
15
15
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
16
16
|
import { CommandMenu } from '@wordpress/commands';
|
|
17
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
@@ -26,6 +27,8 @@ import { unlock } from './lock-unlock';
|
|
|
26
27
|
const { ExperimentalEditorProvider } = unlock( editorPrivateApis );
|
|
27
28
|
|
|
28
29
|
function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
30
|
+
const isLargeViewport = useViewportMatch( 'medium' );
|
|
31
|
+
|
|
29
32
|
const {
|
|
30
33
|
hasFixedToolbar,
|
|
31
34
|
focusMode,
|
|
@@ -36,13 +39,11 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
36
39
|
hiddenBlockTypes,
|
|
37
40
|
blockTypes,
|
|
38
41
|
keepCaretInsideBlock,
|
|
39
|
-
isTemplateMode,
|
|
40
42
|
template,
|
|
41
43
|
} = useSelect(
|
|
42
44
|
( select ) => {
|
|
43
45
|
const {
|
|
44
46
|
isFeatureActive,
|
|
45
|
-
isEditingTemplate,
|
|
46
47
|
getEditedPostTemplate,
|
|
47
48
|
getHiddenBlockTypes,
|
|
48
49
|
} = select( editPostStore );
|
|
@@ -68,9 +69,9 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
68
69
|
getEditorSettings().supportsTemplateMode;
|
|
69
70
|
const isViewable = getPostType( postType )?.viewable ?? false;
|
|
70
71
|
const canEditTemplate = canUser( 'create', 'templates' );
|
|
71
|
-
|
|
72
72
|
return {
|
|
73
|
-
hasFixedToolbar:
|
|
73
|
+
hasFixedToolbar:
|
|
74
|
+
isFeatureActive( 'fixedToolbar' ) || ! isLargeViewport,
|
|
74
75
|
focusMode: isFeatureActive( 'focusMode' ),
|
|
75
76
|
isDistractionFree: isFeatureActive( 'distractionFree' ),
|
|
76
77
|
hasInlineToolbar: isFeatureActive( 'inlineToolbar' ),
|
|
@@ -81,7 +82,6 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
81
82
|
hiddenBlockTypes: getHiddenBlockTypes(),
|
|
82
83
|
blockTypes: getBlockTypes(),
|
|
83
84
|
keepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),
|
|
84
|
-
isTemplateMode: isEditingTemplate(),
|
|
85
85
|
template:
|
|
86
86
|
supportsTemplateMode && isViewable && canEditTemplate
|
|
87
87
|
? getEditedPostTemplate()
|
|
@@ -89,7 +89,7 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
89
89
|
post: postObject,
|
|
90
90
|
};
|
|
91
91
|
},
|
|
92
|
-
[ postType, postId ]
|
|
92
|
+
[ postType, postId, isLargeViewport ]
|
|
93
93
|
);
|
|
94
94
|
|
|
95
95
|
const { updatePreferredStyleVariations, setIsInserterOpened } =
|
|
@@ -156,7 +156,7 @@ function Editor( { postId, postType, settings, initialEdits, ...props } ) {
|
|
|
156
156
|
post={ post }
|
|
157
157
|
initialEdits={ initialEdits }
|
|
158
158
|
useSubRegistry={ false }
|
|
159
|
-
__unstableTemplate={
|
|
159
|
+
__unstableTemplate={ template }
|
|
160
160
|
{ ...props }
|
|
161
161
|
>
|
|
162
162
|
<ErrorBoundary>
|
package/src/editor.native.js
CHANGED
|
@@ -192,18 +192,12 @@ class Editor extends Component {
|
|
|
192
192
|
|
|
193
193
|
export default compose( [
|
|
194
194
|
withSelect( ( select ) => {
|
|
195
|
-
const {
|
|
196
|
-
|
|
197
|
-
getEditorMode,
|
|
198
|
-
__experimentalGetPreviewDeviceType,
|
|
199
|
-
getHiddenBlockTypes,
|
|
200
|
-
} = select( editPostStore );
|
|
195
|
+
const { isFeatureActive, getEditorMode, getHiddenBlockTypes } =
|
|
196
|
+
select( editPostStore );
|
|
201
197
|
const { getBlockTypes } = select( blocksStore );
|
|
202
198
|
|
|
203
199
|
return {
|
|
204
|
-
hasFixedToolbar:
|
|
205
|
-
isFeatureActive( 'fixedToolbar' ) ||
|
|
206
|
-
__experimentalGetPreviewDeviceType() !== 'Desktop',
|
|
200
|
+
hasFixedToolbar: isFeatureActive( 'fixedToolbar' ),
|
|
207
201
|
focusMode: isFeatureActive( 'focusMode' ),
|
|
208
202
|
mode: getEditorMode(),
|
|
209
203
|
hiddenBlockTypes: getHiddenBlockTypes(),
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
registerLegacyWidgetBlock,
|
|
16
16
|
registerWidgetGroupBlock,
|
|
17
17
|
} from '@wordpress/widgets';
|
|
18
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
@@ -93,7 +94,7 @@ export function initializeEditor(
|
|
|
93
94
|
'removeTemplatePartsFromInserter',
|
|
94
95
|
( canInsert, blockType ) => {
|
|
95
96
|
if (
|
|
96
|
-
|
|
97
|
+
select( editorStore ).getRenderingMode() === 'post-only' &&
|
|
97
98
|
blockType.name === 'core/template-part'
|
|
98
99
|
) {
|
|
99
100
|
return false;
|
|
@@ -118,7 +119,7 @@ export function initializeEditor(
|
|
|
118
119
|
{ getBlockParentsByBlockName }
|
|
119
120
|
) => {
|
|
120
121
|
if (
|
|
121
|
-
|
|
122
|
+
select( editorStore ).getRenderingMode() === 'post-only' &&
|
|
122
123
|
blockType.name === 'core/post-content'
|
|
123
124
|
) {
|
|
124
125
|
return (
|
|
@@ -4,15 +4,12 @@
|
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import { PreferenceToggleMenuItem } from '@wordpress/preferences';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import { store as editPostStore } from '../../store';
|
|
7
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
12
8
|
|
|
13
9
|
export default function WelcomeGuideMenuItem() {
|
|
14
10
|
const isTemplateMode = useSelect(
|
|
15
|
-
( select ) =>
|
|
11
|
+
( select ) =>
|
|
12
|
+
select( editorStore ).getRenderingMode() === 'template-only',
|
|
16
13
|
[]
|
|
17
14
|
);
|
|
18
15
|
|