@wordpress/edit-post 5.0.2 → 5.0.3
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/README.md +1 -1
- package/build/components/header/header-toolbar/index.native.js +10 -3
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/template-title/index.js +1 -1
- package/build/components/header/template-title/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -8
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +1 -3
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +44 -17
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/template/actions.js +6 -1
- package/build/components/sidebar/template/actions.js.map +1 -1
- package/build/editor.js +5 -3
- package/build/editor.js.map +1 -1
- package/build/store/selectors.js +5 -3
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +11 -4
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/template-title/index.js +1 -1
- package/build-module/components/header/template-title/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -8
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +2 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +45 -19
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/template/actions.js +6 -1
- package/build-module/components/sidebar/template/actions.js.map +1 -1
- package/build-module/editor.js +4 -3
- package/build-module/editor.js.map +1 -1
- package/build-module/store/selectors.js +5 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +13 -18
- package/build-style/style.css +13 -18
- package/package.json +27 -27
- package/src/components/header/header-toolbar/index.native.js +8 -2
- package/src/components/header/template-title/index.js +3 -1
- package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +15 -12
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/src/components/keyboard-shortcuts/index.js +19 -32
- package/src/components/layout/index.js +2 -6
- package/src/components/preferences-modal/index.js +88 -32
- package/src/components/preferences-modal/style.scss +1 -17
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +294 -137
- package/src/components/secondary-sidebar/inserter-sidebar.js +1 -0
- package/src/components/sidebar/plugin-sidebar/index.js +1 -1
- package/src/components/sidebar/template/actions.js +6 -1
- package/src/components/welcome-guide/style.scss +5 -0
- package/src/editor.js +83 -76
- package/src/store/selectors.js +7 -3
|
@@ -63,6 +63,11 @@ function PostTemplateActions() {
|
|
|
63
63
|
|
|
64
64
|
async function onCreateTemplate( event ) {
|
|
65
65
|
event.preventDefault();
|
|
66
|
+
|
|
67
|
+
if ( isBusy ) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
66
71
|
setIsBusy( true );
|
|
67
72
|
|
|
68
73
|
const newTemplateContent =
|
|
@@ -137,7 +142,7 @@ function PostTemplateActions() {
|
|
|
137
142
|
} }
|
|
138
143
|
overlayClassName="edit-post-template__modal"
|
|
139
144
|
>
|
|
140
|
-
<form onSubmit={
|
|
145
|
+
<form onSubmit={ onCreateTemplate }>
|
|
141
146
|
<Flex align="flex-start" gap={ 8 }>
|
|
142
147
|
<FlexItem>
|
|
143
148
|
<TextControl
|
package/src/editor.js
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { StrictMode, useMemo } from '@wordpress/element';
|
|
18
18
|
import { KeyboardShortcuts, SlotFillProvider } from '@wordpress/components';
|
|
19
19
|
import { store as coreStore } from '@wordpress/core-data';
|
|
20
|
+
import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Internal dependencies
|
|
@@ -48,60 +49,64 @@ function Editor( {
|
|
|
48
49
|
keepCaretInsideBlock,
|
|
49
50
|
isTemplateMode,
|
|
50
51
|
template,
|
|
51
|
-
} = useSelect(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
52
|
+
} = useSelect(
|
|
53
|
+
( select ) => {
|
|
54
|
+
const {
|
|
55
|
+
isFeatureActive,
|
|
56
|
+
getPreference,
|
|
57
|
+
__experimentalGetPreviewDeviceType,
|
|
58
|
+
isEditingTemplate,
|
|
59
|
+
getEditedPostTemplate,
|
|
60
|
+
} = select( editPostStore );
|
|
61
|
+
const { getEntityRecord, getPostType, getEntityRecords } = select(
|
|
62
|
+
coreStore
|
|
63
|
+
);
|
|
64
|
+
const { getEditorSettings } = select( editorStore );
|
|
65
|
+
const { getBlockTypes } = select( blocksStore );
|
|
66
|
+
const isTemplate = [ 'wp_template', 'wp_template_part' ].includes(
|
|
67
|
+
postType
|
|
68
|
+
);
|
|
69
|
+
// Ideally the initializeEditor function should be called using the ID of the REST endpoint.
|
|
70
|
+
// to avoid the special case.
|
|
71
|
+
let postObject;
|
|
72
|
+
if ( isTemplate ) {
|
|
73
|
+
const posts = getEntityRecords( 'postType', postType, {
|
|
74
|
+
wp_id: postId,
|
|
75
|
+
} );
|
|
76
|
+
postObject = posts?.[ 0 ];
|
|
77
|
+
} else {
|
|
78
|
+
postObject = getEntityRecord( 'postType', postType, postId );
|
|
79
|
+
}
|
|
80
|
+
const supportsTemplateMode = getEditorSettings()
|
|
81
|
+
.supportsTemplateMode;
|
|
82
|
+
const isViewable = getPostType( postType )?.viewable ?? false;
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
84
|
+
return {
|
|
85
|
+
hasFixedToolbar:
|
|
86
|
+
isFeatureActive( 'fixedToolbar' ) ||
|
|
87
|
+
__experimentalGetPreviewDeviceType() !== 'Desktop',
|
|
88
|
+
focusMode: isFeatureActive( 'focusMode' ),
|
|
89
|
+
hasReducedUI: isFeatureActive( 'reducedUI' ),
|
|
90
|
+
hasThemeStyles: isFeatureActive( 'themeStyles' ),
|
|
91
|
+
preferredStyleVariations: getPreference(
|
|
92
|
+
'preferredStyleVariations'
|
|
93
|
+
),
|
|
94
|
+
hiddenBlockTypes: getPreference( 'hiddenBlockTypes' ),
|
|
95
|
+
blockTypes: getBlockTypes(),
|
|
96
|
+
__experimentalLocalAutosaveInterval: getPreference(
|
|
97
|
+
'localAutosaveInterval'
|
|
98
|
+
),
|
|
99
|
+
keepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),
|
|
100
|
+
isTemplateMode: isEditingTemplate(),
|
|
101
|
+
template:
|
|
102
|
+
supportsTemplateMode && isViewable
|
|
103
|
+
? getEditedPostTemplate()
|
|
104
|
+
: null,
|
|
105
|
+
post: postObject,
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
[ postType, postId ]
|
|
109
|
+
);
|
|
105
110
|
|
|
106
111
|
const { updatePreferredStyleVariations, setIsInserterOpened } = useDispatch(
|
|
107
112
|
editPostStore
|
|
@@ -167,29 +172,31 @@ function Editor( {
|
|
|
167
172
|
|
|
168
173
|
return (
|
|
169
174
|
<StrictMode>
|
|
170
|
-
<
|
|
171
|
-
<
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
175
|
+
<ShortcutProvider>
|
|
176
|
+
<EditPostSettings.Provider value={ settings }>
|
|
177
|
+
<SlotFillProvider>
|
|
178
|
+
<EditorProvider
|
|
179
|
+
settings={ editorSettings }
|
|
180
|
+
post={ post }
|
|
181
|
+
initialEdits={ initialEdits }
|
|
182
|
+
useSubRegistry={ false }
|
|
183
|
+
__unstableTemplate={
|
|
184
|
+
isTemplateMode ? template : undefined
|
|
185
|
+
}
|
|
186
|
+
{ ...props }
|
|
187
|
+
>
|
|
188
|
+
<ErrorBoundary onError={ onError }>
|
|
189
|
+
<EditorInitialization postId={ postId } />
|
|
190
|
+
<Layout styles={ styles } />
|
|
191
|
+
<KeyboardShortcuts
|
|
192
|
+
shortcuts={ preventEventDiscovery }
|
|
193
|
+
/>
|
|
194
|
+
</ErrorBoundary>
|
|
195
|
+
<PostLockedModal />
|
|
196
|
+
</EditorProvider>
|
|
197
|
+
</SlotFillProvider>
|
|
198
|
+
</EditPostSettings.Provider>
|
|
199
|
+
</ShortcutProvider>
|
|
193
200
|
</StrictMode>
|
|
194
201
|
);
|
|
195
202
|
}
|
package/src/store/selectors.js
CHANGED
|
@@ -338,11 +338,15 @@ export function isInserterOpened( state ) {
|
|
|
338
338
|
*
|
|
339
339
|
* @param {Object} state Global application state.
|
|
340
340
|
*
|
|
341
|
-
* @return {Object} The root client ID
|
|
341
|
+
* @return {Object} The root client ID, index to insert at and starting filter value.
|
|
342
342
|
*/
|
|
343
343
|
export function __experimentalGetInsertionPoint( state ) {
|
|
344
|
-
const {
|
|
345
|
-
|
|
344
|
+
const {
|
|
345
|
+
rootClientId,
|
|
346
|
+
insertionIndex,
|
|
347
|
+
filterValue,
|
|
348
|
+
} = state.blockInserterPanel;
|
|
349
|
+
return { rootClientId, insertionIndex, filterValue };
|
|
346
350
|
}
|
|
347
351
|
|
|
348
352
|
/**
|