@wordpress/editor 13.14.0 → 13.15.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/entities-saved-states/entity-record-item.js +3 -37
- package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +2 -4
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +0 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/{save-shortcut.js → index.js} +13 -25
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -0
- package/build/components/index.js +32 -19
- package/build/components/index.js.map +1 -1
- package/build/components/post-preview-button/index.js +62 -157
- package/build/components/post-preview-button/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +4 -9
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-button/label.js +2 -4
- package/build/components/post-publish-button/label.js.map +1 -1
- package/build/components/post-publish-panel/index.js +1 -3
- package/build/components/post-publish-panel/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +2 -5
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/label.js +4 -4
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-sync-status/index.js +84 -5
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-text-editor/index.js +51 -58
- package/build/components/post-text-editor/index.js.map +1 -1
- package/build/store/actions.js +37 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +53 -61
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-record-item.js +6 -40
- package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +2 -4
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +0 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/{save-shortcut.js → index.js} +12 -23
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -0
- package/build-module/components/index.js +9 -4
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-preview-button/index.js +63 -149
- package/build-module/components/post-preview-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +4 -9
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-button/label.js +2 -4
- package/build-module/components/post-publish-button/label.js.map +1 -1
- package/build-module/components/post-publish-panel/index.js +1 -3
- package/build-module/components/post-publish-panel/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +2 -5
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +4 -4
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +84 -8
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-text-editor/index.js +48 -56
- package/build-module/components/post-text-editor/index.js.map +1 -1
- package/build-module/store/actions.js +31 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +46 -55
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +0 -18
- package/build-style/style.css +0 -18
- package/package.json +30 -30
- package/src/components/entities-saved-states/entity-record-item.js +3 -61
- package/src/components/entities-saved-states/entity-type-list.js +0 -2
- package/src/components/entities-saved-states/index.js +0 -1
- package/src/components/entities-saved-states/style.scss +0 -15
- package/src/components/global-keyboard-shortcuts/index.js +49 -0
- package/src/components/index.js +12 -3
- package/src/components/post-preview-button/index.js +73 -156
- package/src/components/post-preview-button/test/index.js +94 -158
- package/src/components/post-publish-button/index.js +2 -7
- package/src/components/post-publish-button/label.js +2 -2
- package/src/components/post-publish-button/test/index.js +0 -10
- package/src/components/post-publish-panel/index.js +1 -3
- package/src/components/post-saved-state/index.js +2 -5
- package/src/components/post-schedule/label.js +4 -4
- package/src/components/post-sync-status/index.js +100 -7
- package/src/components/post-text-editor/index.js +34 -57
- package/src/components/post-title/style.native.scss +5 -5
- package/src/store/actions.js +34 -2
- package/src/store/selectors.js +45 -41
- package/src/store/test/selectors.js +36 -25
- package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +0 -1
- package/build/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -22
- package/build/components/global-keyboard-shortcuts/text-editor-shortcuts.js.map +0 -1
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -45
- package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -12
- package/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js.map +0 -1
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -32
- package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +0 -1
- package/src/components/global-keyboard-shortcuts/save-shortcut.js +0 -55
- package/src/components/global-keyboard-shortcuts/text-editor-shortcuts.js +0 -8
- package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -29
- package/src/components/post-text-editor/test/index.js +0 -156
|
@@ -31,7 +31,6 @@ export default function EntityTypeList( {
|
|
|
31
31
|
list,
|
|
32
32
|
unselectedEntities,
|
|
33
33
|
setUnselectedEntities,
|
|
34
|
-
closePanel,
|
|
35
34
|
} ) {
|
|
36
35
|
const count = list.length;
|
|
37
36
|
const firstRecord = list[ 0 ];
|
|
@@ -73,7 +72,6 @@ export default function EntityTypeList( {
|
|
|
73
72
|
onChange={ ( value ) =>
|
|
74
73
|
setUnselectedEntities( record, value )
|
|
75
74
|
}
|
|
76
|
-
closePanel={ closePanel }
|
|
77
75
|
/>
|
|
78
76
|
);
|
|
79
77
|
} ) }
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
.entities-saved-states__find-entity {
|
|
2
|
-
display: none;
|
|
3
|
-
|
|
4
|
-
@include break-medium() {
|
|
5
|
-
display: block;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
.entities-saved-states__find-entity-small {
|
|
9
|
-
display: block;
|
|
10
|
-
|
|
11
|
-
@include break-medium() {
|
|
12
|
-
display: none;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
.entities-saved-states__panel-header {
|
|
17
2
|
box-sizing: border-box;
|
|
18
3
|
background: $white;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as editorStore } from '../../store';
|
|
11
|
+
|
|
12
|
+
export default function EditorKeyboardShortcuts() {
|
|
13
|
+
const { redo, undo, savePost } = useDispatch( editorStore );
|
|
14
|
+
const { isEditedPostDirty, isPostSavingLocked } = useSelect( editorStore );
|
|
15
|
+
|
|
16
|
+
useShortcut( 'core/editor/undo', ( event ) => {
|
|
17
|
+
undo();
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
} );
|
|
20
|
+
|
|
21
|
+
useShortcut( 'core/editor/redo', ( event ) => {
|
|
22
|
+
redo();
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
} );
|
|
25
|
+
|
|
26
|
+
useShortcut( 'core/editor/save', ( event ) => {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Do not save the post if post saving is locked.
|
|
31
|
+
*/
|
|
32
|
+
if ( isPostSavingLocked() ) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// TODO: This should be handled in the `savePost` effect in
|
|
37
|
+
// considering `isSaveable`. See note on `isEditedPostSaveable`
|
|
38
|
+
// selector about dirtiness and meta-boxes.
|
|
39
|
+
//
|
|
40
|
+
// See: `isEditedPostSaveable`
|
|
41
|
+
if ( ! isEditedPostDirty() ) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
savePost();
|
|
46
|
+
} );
|
|
47
|
+
|
|
48
|
+
return null;
|
|
49
|
+
}
|
package/src/components/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import EditorKeyboardShortcuts from './global-keyboard-shortcuts';
|
|
5
|
+
|
|
1
6
|
// Block Creation Components.
|
|
2
7
|
export * from './autocompleters';
|
|
3
8
|
|
|
@@ -5,8 +10,7 @@ export * from './autocompleters';
|
|
|
5
10
|
export { default as AutosaveMonitor } from './autosave-monitor';
|
|
6
11
|
export { default as DocumentOutline } from './document-outline';
|
|
7
12
|
export { default as DocumentOutlineCheck } from './document-outline/check';
|
|
8
|
-
export {
|
|
9
|
-
export { default as TextEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/text-editor-shortcuts';
|
|
13
|
+
export { EditorKeyboardShortcuts };
|
|
10
14
|
export { default as EditorKeyboardShortcutsRegister } from './global-keyboard-shortcuts/register-shortcuts';
|
|
11
15
|
export { default as EditorHistoryRedo } from './editor-history/redo';
|
|
12
16
|
export { default as EditorHistoryUndo } from './editor-history/undo';
|
|
@@ -51,7 +55,10 @@ export { default as PostSlugCheck } from './post-slug/check';
|
|
|
51
55
|
export { default as PostSticky } from './post-sticky';
|
|
52
56
|
export { default as PostStickyCheck } from './post-sticky/check';
|
|
53
57
|
export { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';
|
|
54
|
-
export {
|
|
58
|
+
export {
|
|
59
|
+
default as PostSyncStatus,
|
|
60
|
+
PostSyncStatusModal,
|
|
61
|
+
} from './post-sync-status';
|
|
55
62
|
export { default as PostTaxonomies } from './post-taxonomies';
|
|
56
63
|
export { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
|
|
57
64
|
export { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
|
|
@@ -81,3 +88,5 @@ export { default as CharacterCount } from './character-count';
|
|
|
81
88
|
export { default as EditorProvider } from './provider';
|
|
82
89
|
|
|
83
90
|
export * from './deprecated';
|
|
91
|
+
export const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
|
|
92
|
+
export const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
4
|
+
import { renderToString } from '@wordpress/element';
|
|
10
5
|
import { Button, Path, SVG, VisuallyHidden } from '@wordpress/components';
|
|
11
6
|
import { __, _x } from '@wordpress/i18n';
|
|
12
|
-
import {
|
|
13
|
-
import { ifCondition, compose } from '@wordpress/compose';
|
|
7
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
14
8
|
import { applyFilters } from '@wordpress/hooks';
|
|
15
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
16
10
|
|
|
@@ -105,48 +99,40 @@ function writeInterstitialMessage( targetDocument ) {
|
|
|
105
99
|
targetDocument.close();
|
|
106
100
|
}
|
|
107
101
|
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
previewWindow.location = url;
|
|
138
|
-
if ( this.buttonRef.current ) {
|
|
139
|
-
this.buttonRef.current.focus();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
102
|
+
export default function PostPreviewButton( {
|
|
103
|
+
className,
|
|
104
|
+
textContent,
|
|
105
|
+
forceIsAutosaveable,
|
|
106
|
+
role,
|
|
107
|
+
onPreview,
|
|
108
|
+
} ) {
|
|
109
|
+
const { postId, currentPostLink, previewLink, isSaveable, isViewable } =
|
|
110
|
+
useSelect( ( select ) => {
|
|
111
|
+
const editor = select( editorStore );
|
|
112
|
+
const core = select( coreStore );
|
|
113
|
+
|
|
114
|
+
const postType = core.getPostType(
|
|
115
|
+
editor.getCurrentPostType( 'type' )
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
postId: editor.getCurrentPostId(),
|
|
120
|
+
currentPostLink: editor.getCurrentPostAttribute( 'link' ),
|
|
121
|
+
previewLink: editor.getEditedPostPreviewLink(),
|
|
122
|
+
isSaveable: editor.isEditedPostSaveable(),
|
|
123
|
+
isViewable: postType?.viewable ?? false,
|
|
124
|
+
};
|
|
125
|
+
}, [] );
|
|
126
|
+
|
|
127
|
+
const { __unstableSaveForPreview } = useDispatch( editorStore );
|
|
128
|
+
|
|
129
|
+
if ( ! isViewable ) {
|
|
130
|
+
return null;
|
|
142
131
|
}
|
|
143
132
|
|
|
144
|
-
|
|
145
|
-
const { postId } = this.props;
|
|
146
|
-
return `wp-preview-${ postId }`;
|
|
147
|
-
}
|
|
133
|
+
const targetId = `wp-preview-${ postId }`;
|
|
148
134
|
|
|
149
|
-
openPreviewWindow( event ) {
|
|
135
|
+
const openPreviewWindow = async ( event ) => {
|
|
150
136
|
// Our Preview button has its 'href' and 'target' set correctly for a11y
|
|
151
137
|
// purposes. Unfortunately, though, we can't rely on the default 'click'
|
|
152
138
|
// handler since sometimes it incorrectly opens a new tab instead of reusing
|
|
@@ -155,117 +141,48 @@ export class PostPreviewButton extends Component {
|
|
|
155
141
|
event.preventDefault();
|
|
156
142
|
|
|
157
143
|
// Open up a Preview tab if needed. This is where we'll show the preview.
|
|
158
|
-
|
|
159
|
-
this.previewWindow = window.open( '', this.getWindowTarget() );
|
|
160
|
-
}
|
|
144
|
+
const previewWindow = window.open( '', targetId );
|
|
161
145
|
|
|
162
146
|
// Focus the Preview tab. This might not do anything, depending on the browser's
|
|
163
147
|
// and user's preferences.
|
|
164
148
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<Button
|
|
208
|
-
variant={ ! this.props.className ? 'tertiary' : undefined }
|
|
209
|
-
className={ classNames }
|
|
210
|
-
href={ href }
|
|
211
|
-
target={ this.getWindowTarget() }
|
|
212
|
-
disabled={ ! isSaveable }
|
|
213
|
-
onClick={ this.openPreviewWindow }
|
|
214
|
-
ref={ this.buttonRef }
|
|
215
|
-
role={ role }
|
|
216
|
-
>
|
|
217
|
-
{ this.props.textContent ? (
|
|
218
|
-
this.props.textContent
|
|
219
|
-
) : (
|
|
220
|
-
<>
|
|
221
|
-
{ _x( 'Preview', 'imperative verb' ) }
|
|
222
|
-
<VisuallyHidden as="span">
|
|
223
|
-
{
|
|
224
|
-
/* translators: accessibility text */
|
|
225
|
-
__( '(opens in a new tab)' )
|
|
226
|
-
}
|
|
227
|
-
</VisuallyHidden>
|
|
228
|
-
</>
|
|
229
|
-
) }
|
|
230
|
-
</Button>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
149
|
+
previewWindow.focus();
|
|
150
|
+
|
|
151
|
+
writeInterstitialMessage( previewWindow.document );
|
|
152
|
+
|
|
153
|
+
const link = await __unstableSaveForPreview( { forceIsAutosaveable } );
|
|
154
|
+
|
|
155
|
+
previewWindow.location = link;
|
|
156
|
+
|
|
157
|
+
onPreview?.();
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Link to the `?preview=true` URL if we have it, since this lets us see
|
|
161
|
+
// changes that were autosaved since the post was last published. Otherwise,
|
|
162
|
+
// just link to the post's URL.
|
|
163
|
+
const href = previewLink || currentPostLink;
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<Button
|
|
167
|
+
variant={ ! className ? 'tertiary' : undefined }
|
|
168
|
+
className={ className || 'editor-post-preview' }
|
|
169
|
+
href={ href }
|
|
170
|
+
target={ targetId }
|
|
171
|
+
disabled={ ! isSaveable }
|
|
172
|
+
onClick={ openPreviewWindow }
|
|
173
|
+
role={ role }
|
|
174
|
+
>
|
|
175
|
+
{ textContent || (
|
|
176
|
+
<>
|
|
177
|
+
{ _x( 'Preview', 'imperative verb' ) }
|
|
178
|
+
<VisuallyHidden as="span">
|
|
179
|
+
{
|
|
180
|
+
/* translators: accessibility text */
|
|
181
|
+
__( '(opens in a new tab)' )
|
|
182
|
+
}
|
|
183
|
+
</VisuallyHidden>
|
|
184
|
+
</>
|
|
185
|
+
) }
|
|
186
|
+
</Button>
|
|
187
|
+
);
|
|
233
188
|
}
|
|
234
|
-
|
|
235
|
-
export default compose( [
|
|
236
|
-
withSelect( ( select, { forcePreviewLink, forceIsAutosaveable } ) => {
|
|
237
|
-
const {
|
|
238
|
-
getCurrentPostId,
|
|
239
|
-
getCurrentPostAttribute,
|
|
240
|
-
getEditedPostAttribute,
|
|
241
|
-
isEditedPostSaveable,
|
|
242
|
-
isEditedPostAutosaveable,
|
|
243
|
-
getEditedPostPreviewLink,
|
|
244
|
-
isPostLocked,
|
|
245
|
-
} = select( editorStore );
|
|
246
|
-
const { getPostType } = select( coreStore );
|
|
247
|
-
|
|
248
|
-
const previewLink = getEditedPostPreviewLink();
|
|
249
|
-
const postType = getPostType( getEditedPostAttribute( 'type' ) );
|
|
250
|
-
|
|
251
|
-
return {
|
|
252
|
-
postId: getCurrentPostId(),
|
|
253
|
-
currentPostLink: getCurrentPostAttribute( 'link' ),
|
|
254
|
-
previewLink:
|
|
255
|
-
forcePreviewLink !== undefined ? forcePreviewLink : previewLink,
|
|
256
|
-
isSaveable: isEditedPostSaveable(),
|
|
257
|
-
isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),
|
|
258
|
-
isViewable: postType?.viewable ?? false,
|
|
259
|
-
isDraft:
|
|
260
|
-
[ 'draft', 'auto-draft' ].indexOf(
|
|
261
|
-
getEditedPostAttribute( 'status' )
|
|
262
|
-
) !== -1,
|
|
263
|
-
isPostLocked: isPostLocked(),
|
|
264
|
-
};
|
|
265
|
-
} ),
|
|
266
|
-
withDispatch( ( dispatch ) => ( {
|
|
267
|
-
autosave: dispatch( editorStore ).autosave,
|
|
268
|
-
savePost: dispatch( editorStore ).savePost,
|
|
269
|
-
} ) ),
|
|
270
|
-
ifCondition( ( { isViewable } ) => isViewable ),
|
|
271
|
-
] )( PostPreviewButton );
|