@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
package/src/store/actions.js
CHANGED
|
@@ -7,7 +7,6 @@ import { store as interfaceStore } from '@wordpress/interface';
|
|
|
7
7
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
8
|
import { speak } from '@wordpress/a11y';
|
|
9
9
|
import { store as noticesStore } from '@wordpress/notices';
|
|
10
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
10
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
11
|
import { store as editorStore } from '@wordpress/editor';
|
|
13
12
|
import deprecated from '@wordpress/deprecated';
|
|
@@ -457,18 +456,27 @@ export function metaBoxUpdatesFailure() {
|
|
|
457
456
|
}
|
|
458
457
|
|
|
459
458
|
/**
|
|
460
|
-
*
|
|
459
|
+
* Action that changes the width of the editing canvas.
|
|
460
|
+
*
|
|
461
|
+
* @deprecated
|
|
461
462
|
*
|
|
462
463
|
* @param {string} deviceType
|
|
463
464
|
*
|
|
464
465
|
* @return {Object} Action object.
|
|
465
466
|
*/
|
|
466
|
-
export
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
export const __experimentalSetPreviewDeviceType =
|
|
468
|
+
( deviceType ) =>
|
|
469
|
+
( { registry } ) => {
|
|
470
|
+
deprecated(
|
|
471
|
+
"dispatch( 'core/edit-post' ).__experimentalSetPreviewDeviceType",
|
|
472
|
+
{
|
|
473
|
+
since: '6.5',
|
|
474
|
+
version: '6.7',
|
|
475
|
+
hint: 'registry.dispatch( editorStore ).setDeviceType',
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
registry.dispatch( editorStore ).setDeviceType( deviceType );
|
|
470
479
|
};
|
|
471
|
-
}
|
|
472
480
|
|
|
473
481
|
/**
|
|
474
482
|
* Returns an action object used to open/close the inserter.
|
|
@@ -513,58 +521,36 @@ export const setIsListViewOpened =
|
|
|
513
521
|
/**
|
|
514
522
|
* Returns an action object used to switch to template editing.
|
|
515
523
|
*
|
|
516
|
-
* @
|
|
517
|
-
* @return {Object} Action object.
|
|
524
|
+
* @deprecated
|
|
518
525
|
*/
|
|
519
|
-
export function setIsEditingTemplate(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
};
|
|
526
|
+
export function setIsEditingTemplate() {
|
|
527
|
+
deprecated( "dispatch( 'core/edit-post' ).setIsEditingTemplate", {
|
|
528
|
+
since: '6.5',
|
|
529
|
+
alternative: "dispatch( 'core/editor').setRenderingMode",
|
|
530
|
+
} );
|
|
531
|
+
return { type: 'NOTHING' };
|
|
524
532
|
}
|
|
525
533
|
|
|
526
534
|
/**
|
|
527
535
|
* Switches to the template mode.
|
|
528
|
-
*
|
|
529
|
-
* @param {boolean} newTemplate Is new template.
|
|
530
536
|
*/
|
|
531
537
|
export const __unstableSwitchToTemplateMode =
|
|
532
|
-
(
|
|
533
|
-
( { registry
|
|
534
|
-
dispatch(
|
|
535
|
-
const isWelcomeGuideActive = select.isFeatureActive(
|
|
536
|
-
'welcomeGuideTemplate'
|
|
537
|
-
);
|
|
538
|
-
if ( ! isWelcomeGuideActive ) {
|
|
539
|
-
const message = newTemplate
|
|
540
|
-
? __( "Custom template created. You're in template mode now." )
|
|
541
|
-
: __(
|
|
542
|
-
'Editing template. Changes made here affect all posts and pages that use the template.'
|
|
543
|
-
);
|
|
544
|
-
registry.dispatch( noticesStore ).createSuccessNotice( message, {
|
|
545
|
-
type: 'snackbar',
|
|
546
|
-
} );
|
|
547
|
-
}
|
|
538
|
+
() =>
|
|
539
|
+
( { registry } ) => {
|
|
540
|
+
registry.dispatch( editorStore ).setRenderingMode( 'template-only' );
|
|
548
541
|
};
|
|
549
542
|
|
|
550
543
|
/**
|
|
551
544
|
* Create a block based template.
|
|
552
545
|
*
|
|
553
|
-
* @
|
|
546
|
+
* @deprecated
|
|
554
547
|
*/
|
|
555
|
-
export
|
|
556
|
-
(
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const post = registry.select( editorStore ).getCurrentPost();
|
|
562
|
-
registry
|
|
563
|
-
.dispatch( coreStore )
|
|
564
|
-
.editEntityRecord( 'postType', post.type, post.id, {
|
|
565
|
-
template: savedTemplate.slug,
|
|
566
|
-
} );
|
|
567
|
-
};
|
|
548
|
+
export function __unstableCreateTemplate() {
|
|
549
|
+
deprecated( "dispatch( 'core/edit-post' ).__unstableCreateTemplate", {
|
|
550
|
+
since: '6.5',
|
|
551
|
+
} );
|
|
552
|
+
return { type: 'NOTHING' };
|
|
553
|
+
}
|
|
568
554
|
|
|
569
555
|
let metaBoxesInitialized = false;
|
|
570
556
|
|
package/src/store/reducer.js
CHANGED
|
@@ -98,23 +98,6 @@ export function metaBoxLocations( state = {}, action ) {
|
|
|
98
98
|
return state;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
/**
|
|
102
|
-
* Reducer returning the editing canvas device type.
|
|
103
|
-
*
|
|
104
|
-
* @param {Object} state Current state.
|
|
105
|
-
* @param {Object} action Dispatched action.
|
|
106
|
-
*
|
|
107
|
-
* @return {Object} Updated state.
|
|
108
|
-
*/
|
|
109
|
-
export function deviceType( state = 'Desktop', action ) {
|
|
110
|
-
switch ( action.type ) {
|
|
111
|
-
case 'SET_PREVIEW_DEVICE_TYPE':
|
|
112
|
-
return action.deviceType;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return state;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
101
|
/**
|
|
119
102
|
* Reducer to set the block inserter panel open or closed.
|
|
120
103
|
*
|
|
@@ -153,20 +136,6 @@ export function listViewPanel( state = false, action ) {
|
|
|
153
136
|
return state;
|
|
154
137
|
}
|
|
155
138
|
|
|
156
|
-
/**
|
|
157
|
-
* Reducer tracking whether template editing is on or off.
|
|
158
|
-
*
|
|
159
|
-
* @param {boolean} state
|
|
160
|
-
* @param {Object} action
|
|
161
|
-
*/
|
|
162
|
-
function isEditingTemplate( state = false, action ) {
|
|
163
|
-
switch ( action.type ) {
|
|
164
|
-
case 'SET_IS_EDITING_TEMPLATE':
|
|
165
|
-
return action.value;
|
|
166
|
-
}
|
|
167
|
-
return state;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
139
|
/**
|
|
171
140
|
* Reducer tracking whether meta boxes are initialized.
|
|
172
141
|
*
|
|
@@ -193,8 +162,6 @@ export default combineReducers( {
|
|
|
193
162
|
metaBoxes,
|
|
194
163
|
publishSidebarActive,
|
|
195
164
|
removedPanels,
|
|
196
|
-
deviceType,
|
|
197
165
|
blockInserterPanel,
|
|
198
166
|
listViewPanel,
|
|
199
|
-
isEditingTemplate,
|
|
200
167
|
} );
|
package/src/store/selectors.js
CHANGED
|
@@ -450,13 +450,25 @@ export function isSavingMetaBoxes( state ) {
|
|
|
450
450
|
/**
|
|
451
451
|
* Returns the current editing canvas device type.
|
|
452
452
|
*
|
|
453
|
+
* @deprecated
|
|
454
|
+
*
|
|
453
455
|
* @param {Object} state Global application state.
|
|
454
456
|
*
|
|
455
457
|
* @return {string} Device type.
|
|
456
458
|
*/
|
|
457
|
-
export
|
|
458
|
-
|
|
459
|
-
|
|
459
|
+
export const __experimentalGetPreviewDeviceType = createRegistrySelector(
|
|
460
|
+
( select ) => () => {
|
|
461
|
+
deprecated(
|
|
462
|
+
`select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`,
|
|
463
|
+
{
|
|
464
|
+
since: '6.5',
|
|
465
|
+
version: '6.7',
|
|
466
|
+
alternative: `select( 'core/editor' ).getDeviceType`,
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
return select( editorStore ).getDeviceType();
|
|
470
|
+
}
|
|
471
|
+
);
|
|
460
472
|
|
|
461
473
|
/**
|
|
462
474
|
* Returns true if the inserter is opened.
|
|
@@ -498,13 +510,15 @@ export function isListViewOpened( state ) {
|
|
|
498
510
|
/**
|
|
499
511
|
* Returns true if the template editing mode is enabled.
|
|
500
512
|
*
|
|
501
|
-
* @
|
|
502
|
-
*
|
|
503
|
-
* @return {boolean} Whether we're editing the template.
|
|
513
|
+
* @deprecated
|
|
504
514
|
*/
|
|
505
|
-
export
|
|
506
|
-
|
|
507
|
-
|
|
515
|
+
export const isEditingTemplate = createRegistrySelector( ( select ) => () => {
|
|
516
|
+
deprecated( `select( 'core/edit-post' ).isEditingTemplate`, {
|
|
517
|
+
since: '6.5',
|
|
518
|
+
alternative: `select( 'core/editor' ).getRenderingMode`,
|
|
519
|
+
} );
|
|
520
|
+
return select( editorStore ).getRenderingMode() !== 'post-only';
|
|
521
|
+
} );
|
|
508
522
|
|
|
509
523
|
/**
|
|
510
524
|
* Returns true if meta boxes are initialized.
|
|
@@ -146,34 +146,6 @@ describe( 'actions', () => {
|
|
|
146
146
|
).toBe( true );
|
|
147
147
|
} );
|
|
148
148
|
|
|
149
|
-
describe( '__unstableSwitchToTemplateMode', () => {
|
|
150
|
-
it( 'welcome guide is active', () => {
|
|
151
|
-
// Activate `welcomeGuideTemplate` feature.
|
|
152
|
-
registry
|
|
153
|
-
.dispatch( editPostStore )
|
|
154
|
-
.toggleFeature( 'welcomeGuideTemplate' );
|
|
155
|
-
registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
|
|
156
|
-
expect(
|
|
157
|
-
registry.select( editPostStore ).isEditingTemplate()
|
|
158
|
-
).toBeTruthy();
|
|
159
|
-
const notices = registry.select( noticesStore ).getNotices();
|
|
160
|
-
expect( notices ).toHaveLength( 0 );
|
|
161
|
-
} );
|
|
162
|
-
|
|
163
|
-
it( 'welcome guide is inactive', () => {
|
|
164
|
-
expect(
|
|
165
|
-
registry.select( editPostStore ).isEditingTemplate()
|
|
166
|
-
).toBeFalsy();
|
|
167
|
-
registry.dispatch( editPostStore ).__unstableSwitchToTemplateMode();
|
|
168
|
-
expect(
|
|
169
|
-
registry.select( editPostStore ).isEditingTemplate()
|
|
170
|
-
).toBeTruthy();
|
|
171
|
-
const notices = registry.select( noticesStore ).getNotices();
|
|
172
|
-
expect( notices ).toHaveLength( 1 );
|
|
173
|
-
expect( notices[ 0 ].content ).toMatch( 'template' );
|
|
174
|
-
} );
|
|
175
|
-
} );
|
|
176
|
-
|
|
177
149
|
describe( 'hideBlockTypes', () => {
|
|
178
150
|
it( 'adds the hidden block type to the preferences', () => {
|
|
179
151
|
registry
|
package/src/style.scss
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
@import "./components/header/style.scss";
|
|
3
3
|
@import "./components/header/fullscreen-mode-close/style.scss";
|
|
4
4
|
@import "./components/header/header-toolbar/style.scss";
|
|
5
|
-
@import "./components/header/document-actions/style.scss";
|
|
6
5
|
@import "./components/keyboard-shortcut-help-modal/style.scss";
|
|
7
6
|
@import "./components/layout/style.scss";
|
|
8
7
|
@import "./components/block-manager/style.scss";
|
|
@@ -12,9 +11,7 @@
|
|
|
12
11
|
@import "./components/sidebar/last-revision/style.scss";
|
|
13
12
|
@import "./components/sidebar/post-format/style.scss";
|
|
14
13
|
@import "./components/sidebar/post-slug/style.scss";
|
|
15
|
-
@import "./components/sidebar/post-template/style.scss";
|
|
16
14
|
@import "./components/sidebar/post-visibility/style.scss";
|
|
17
|
-
@import "./components/sidebar/settings-header/style.scss";
|
|
18
15
|
@import "./components/sidebar/template-summary/style.scss";
|
|
19
16
|
@import "./components/text-editor/style.scss";
|
|
20
17
|
@import "./components/visual-editor/style.scss";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Editor appends media correctly for allowed types 1`] = `
|
|
4
|
+
"<!-- wp:image -->
|
|
5
|
+
<figure class="wp-block-image"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt=""/></figure>
|
|
6
|
+
<!-- /wp:image -->
|
|
7
|
+
|
|
8
|
+
<!-- wp:image -->
|
|
9
|
+
<figure class="wp-block-image"><img src="https://test-site.files.wordpress.com/local-image-3.jpeg" alt=""/></figure>
|
|
10
|
+
<!-- /wp:image -->"
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`Editor appends media correctly for allowed types and skips unsupported ones 1`] = `
|
|
14
|
+
"<!-- wp:image -->
|
|
15
|
+
<figure class="wp-block-image"><img src="https://test-site.files.wordpress.com/local-image-1.jpeg" alt=""/></figure>
|
|
16
|
+
<!-- /wp:image -->
|
|
17
|
+
|
|
18
|
+
<!-- wp:video -->
|
|
19
|
+
<figure class="wp-block-video"><video controls src="file:///local-video-4.mp4"></video></figure>
|
|
20
|
+
<!-- /wp:video -->"
|
|
21
|
+
`;
|
|
@@ -6,93 +6,127 @@ import {
|
|
|
6
6
|
addBlock,
|
|
7
7
|
fireEvent,
|
|
8
8
|
getBlock,
|
|
9
|
+
getEditorHtml,
|
|
9
10
|
initializeEditor,
|
|
10
|
-
|
|
11
|
+
screen,
|
|
11
12
|
setupCoreBlocks,
|
|
12
13
|
} from 'test/helpers';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* WordPress dependencies
|
|
16
17
|
*/
|
|
17
|
-
import
|
|
18
|
+
import {
|
|
19
|
+
requestMediaImport,
|
|
20
|
+
subscribeMediaAppend,
|
|
18
21
|
subscribeParentToggleHTMLMode,
|
|
19
22
|
} from '@wordpress/react-native-bridge';
|
|
20
|
-
// Force register 'core/editor' store.
|
|
21
|
-
import { store } from '@wordpress/editor'; // eslint-disable-line no-unused-vars
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Internal dependencies
|
|
25
|
-
*/
|
|
26
|
-
import '..';
|
|
27
|
-
import Editor from '../editor';
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
<!-- wp:notablock -->
|
|
31
|
-
<p>Not supported</p>
|
|
32
|
-
<!-- /wp:notablock -->
|
|
33
|
-
`;
|
|
24
|
+
setupCoreBlocks();
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
let toggleModeCallback;
|
|
27
|
+
subscribeParentToggleHTMLMode.mockImplementation( ( callback ) => {
|
|
28
|
+
toggleModeCallback = callback;
|
|
37
29
|
} );
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
let mediaAppendCallback;
|
|
32
|
+
subscribeMediaAppend.mockImplementation( ( callback ) => {
|
|
33
|
+
mediaAppendCallback = callback;
|
|
42
34
|
} );
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
const MEDIA = [
|
|
37
|
+
{
|
|
38
|
+
localId: 1,
|
|
39
|
+
mediaUrl: 'file:///local-image-1.jpeg',
|
|
40
|
+
mediaType: 'image',
|
|
41
|
+
serverId: 2000,
|
|
42
|
+
serverUrl: 'https://test-site.files.wordpress.com/local-image-1.jpeg',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
localId: 2,
|
|
46
|
+
mediaUrl: 'file:///local-file-1.pdf',
|
|
47
|
+
mediaType: 'other',
|
|
48
|
+
serverId: 2001,
|
|
49
|
+
serverUrl: 'https://test-site.files.wordpress.com/local-file-1.pdf',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
localId: 3,
|
|
53
|
+
mediaUrl: 'file:///local-image-3.jpeg',
|
|
54
|
+
mediaType: 'image',
|
|
55
|
+
serverId: 2002,
|
|
56
|
+
serverUrl: 'https://test-site.files.wordpress.com/local-image-3.jpeg',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
localId: 4,
|
|
60
|
+
mediaUrl: 'file:///local-video-4.mp4',
|
|
61
|
+
mediaType: 'video',
|
|
62
|
+
serverId: 2003,
|
|
63
|
+
serverUrl: 'https://test-site.files.wordpress.com/local-video-4.mp4',
|
|
64
|
+
},
|
|
65
|
+
];
|
|
45
66
|
|
|
46
67
|
describe( 'Editor', () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const appContainer = renderEditorWith( unsupportedBlock );
|
|
51
|
-
// For some reason resetEditorBlocks() is asynchronous when dispatching editEntityRecord.
|
|
52
|
-
act( () => {
|
|
53
|
-
jest.runAllTicks();
|
|
54
|
-
} );
|
|
55
|
-
appContainer.unmount();
|
|
56
|
-
|
|
57
|
-
expect(
|
|
58
|
-
RNReactNativeGutenbergBridge.editorDidMount
|
|
59
|
-
).toHaveBeenCalledTimes( 1 );
|
|
60
|
-
expect(
|
|
61
|
-
RNReactNativeGutenbergBridge.editorDidMount
|
|
62
|
-
).toHaveBeenCalledWith( [ 'core/notablock' ] );
|
|
68
|
+
afterEach( () => {
|
|
69
|
+
jest.clearAllMocks();
|
|
63
70
|
} );
|
|
64
71
|
|
|
65
72
|
it( 'toggles the editor from Visual to HTML mode', async () => {
|
|
66
73
|
// Arrange
|
|
67
|
-
|
|
68
|
-
subscribeParentToggleHTMLMode.mockImplementation( ( callback ) => {
|
|
69
|
-
toggleMode = callback;
|
|
70
|
-
} );
|
|
71
|
-
const screen = await initializeEditor();
|
|
74
|
+
await initializeEditor();
|
|
72
75
|
await addBlock( screen, 'Paragraph' );
|
|
73
76
|
|
|
74
77
|
// Act
|
|
75
78
|
const paragraphBlock = getBlock( screen, 'Paragraph' );
|
|
76
79
|
fireEvent.press( paragraphBlock );
|
|
77
80
|
act( () => {
|
|
78
|
-
|
|
81
|
+
toggleModeCallback();
|
|
79
82
|
} );
|
|
80
83
|
|
|
81
84
|
// Assert
|
|
82
85
|
const htmlEditor = screen.getByLabelText( 'html-view-content' );
|
|
83
86
|
expect( htmlEditor ).toBeVisible();
|
|
87
|
+
|
|
88
|
+
act( () => {
|
|
89
|
+
toggleModeCallback();
|
|
90
|
+
} );
|
|
84
91
|
} );
|
|
85
|
-
} );
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
it( 'appends media correctly for allowed types', async () => {
|
|
94
|
+
// Arrange
|
|
95
|
+
requestMediaImport
|
|
96
|
+
.mockImplementationOnce( ( _, callback ) =>
|
|
97
|
+
callback( MEDIA[ 0 ].id, MEDIA[ 0 ].serverUrl )
|
|
98
|
+
)
|
|
99
|
+
.mockImplementationOnce( ( _, callback ) =>
|
|
100
|
+
callback( MEDIA[ 2 ].id, MEDIA[ 2 ].serverUrl )
|
|
101
|
+
);
|
|
102
|
+
await initializeEditor();
|
|
103
|
+
|
|
104
|
+
// Act
|
|
105
|
+
await act( () => mediaAppendCallback( MEDIA[ 0 ] ) );
|
|
106
|
+
await act( () => mediaAppendCallback( MEDIA[ 2 ] ) );
|
|
107
|
+
|
|
108
|
+
// Assert
|
|
109
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
it( 'appends media correctly for allowed types and skips unsupported ones', async () => {
|
|
113
|
+
// Arrange
|
|
114
|
+
requestMediaImport
|
|
115
|
+
.mockImplementationOnce( ( _, callback ) =>
|
|
116
|
+
callback( MEDIA[ 0 ].id, MEDIA[ 0 ].serverUrl )
|
|
117
|
+
)
|
|
118
|
+
.mockImplementationOnce( ( _, callback ) =>
|
|
119
|
+
callback( MEDIA[ 3 ].id, MEDIA[ 3 ].serverUrl )
|
|
120
|
+
);
|
|
121
|
+
await initializeEditor();
|
|
122
|
+
|
|
123
|
+
// Act
|
|
124
|
+
await act( () => mediaAppendCallback( MEDIA[ 0 ] ) );
|
|
125
|
+
// Unsupported type (PDF file)
|
|
126
|
+
await act( () => mediaAppendCallback( MEDIA[ 1 ] ) );
|
|
127
|
+
await act( () => mediaAppendCallback( MEDIA[ 3 ] ) );
|
|
128
|
+
|
|
129
|
+
// Assert
|
|
130
|
+
expect( getEditorHtml() ).toMatchSnapshot();
|
|
131
|
+
} );
|
|
132
|
+
} );
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = DevicePreview;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _components = require("@wordpress/components");
|
|
9
|
-
var _editor = require("@wordpress/editor");
|
|
10
|
-
var _icons = require("@wordpress/icons");
|
|
11
|
-
var _i18n = require("@wordpress/i18n");
|
|
12
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
13
|
-
var _data = require("@wordpress/data");
|
|
14
|
-
var _coreData = require("@wordpress/core-data");
|
|
15
|
-
var _store = require("../../store");
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function DevicePreview() {
|
|
25
|
-
const {
|
|
26
|
-
hasActiveMetaboxes,
|
|
27
|
-
isPostSaveable,
|
|
28
|
-
isViewable,
|
|
29
|
-
deviceType,
|
|
30
|
-
showIconLabels
|
|
31
|
-
} = (0, _data.useSelect)(select => {
|
|
32
|
-
var _postType$viewable;
|
|
33
|
-
const {
|
|
34
|
-
getEditedPostAttribute
|
|
35
|
-
} = select(_editor.store);
|
|
36
|
-
const {
|
|
37
|
-
getPostType
|
|
38
|
-
} = select(_coreData.store);
|
|
39
|
-
const postType = getPostType(getEditedPostAttribute('type'));
|
|
40
|
-
return {
|
|
41
|
-
hasActiveMetaboxes: select(_store.store).hasMetaBoxes(),
|
|
42
|
-
isPostSaveable: select(_editor.store).isEditedPostSaveable(),
|
|
43
|
-
isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false,
|
|
44
|
-
deviceType: select(_store.store).__experimentalGetPreviewDeviceType(),
|
|
45
|
-
showIconLabels: select(_store.store).isFeatureActive('showIconLabels')
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
48
|
-
const {
|
|
49
|
-
__experimentalSetPreviewDeviceType: setPreviewDeviceType
|
|
50
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
51
|
-
return (0, _react.createElement)(_blockEditor.__experimentalPreviewOptions, {
|
|
52
|
-
isEnabled: isPostSaveable,
|
|
53
|
-
className: "edit-post-post-preview-dropdown",
|
|
54
|
-
deviceType: deviceType,
|
|
55
|
-
setDeviceType: setPreviewDeviceType,
|
|
56
|
-
label: (0, _i18n.__)('Preview'),
|
|
57
|
-
showIconLabels: showIconLabels
|
|
58
|
-
}, ({
|
|
59
|
-
onClose
|
|
60
|
-
}) => isViewable && (0, _react.createElement)(_components.MenuGroup, null, (0, _react.createElement)("div", {
|
|
61
|
-
className: "edit-post-header-preview__grouping-external"
|
|
62
|
-
}, (0, _react.createElement)(_editor.PostPreviewButton, {
|
|
63
|
-
className: "edit-post-header-preview__button-external",
|
|
64
|
-
role: "menuitem",
|
|
65
|
-
forceIsAutosaveable: hasActiveMetaboxes,
|
|
66
|
-
textContent: (0, _react.createElement)(_react.Fragment, null, (0, _i18n.__)('Preview in new tab'), (0, _react.createElement)(_components.Icon, {
|
|
67
|
-
icon: _icons.external
|
|
68
|
-
})),
|
|
69
|
-
onPreview: onClose
|
|
70
|
-
}))));
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_editor","_icons","_i18n","_blockEditor","_data","_coreData","_store","DevicePreview","hasActiveMetaboxes","isPostSaveable","isViewable","deviceType","showIconLabels","useSelect","select","_postType$viewable","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","editPostStore","hasMetaBoxes","isEditedPostSaveable","viewable","__experimentalGetPreviewDeviceType","isFeatureActive","__experimentalSetPreviewDeviceType","setPreviewDeviceType","useDispatch","_react","createElement","__experimentalPreviewOptions","isEnabled","className","setDeviceType","label","__","onClose","MenuGroup","PostPreviewButton","role","forceIsAutosaveable","textContent","Fragment","Icon","icon","external","onPreview"],"sources":["@wordpress/edit-post/src/components/device-preview/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, MenuGroup } from '@wordpress/components';\nimport { PostPreviewButton, store as editorStore } from '@wordpress/editor';\nimport { external } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function DevicePreview() {\n\tconst {\n\t\thasActiveMetaboxes,\n\t\tisPostSaveable,\n\t\tisViewable,\n\t\tdeviceType,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\tisPostSaveable: select( editorStore ).isEditedPostSaveable(),\n\t\t\tisViewable: postType?.viewable ?? false,\n\t\t\tdeviceType:\n\t\t\t\tselect( editPostStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tshowIconLabels:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t};\n\t}, [] );\n\tconst { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =\n\t\tuseDispatch( editPostStore );\n\n\treturn (\n\t\t<PreviewOptions\n\t\t\tisEnabled={ isPostSaveable }\n\t\t\tclassName=\"edit-post-post-preview-dropdown\"\n\t\t\tdeviceType={ deviceType }\n\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\tlabel={ __( 'Preview' ) }\n\t\t\tshowIconLabels={ showIconLabels }\n\t\t>\n\t\t\t{ ( { onClose } ) =>\n\t\t\t\tisViewable && (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<div className=\"edit-post-header-preview__grouping-external\">\n\t\t\t\t\t\t\t<PostPreviewButton\n\t\t\t\t\t\t\t\tclassName=\"edit-post-header-preview__button-external\"\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t\t\t\t\ttextContent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Preview in new tab' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ external } />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonPreview={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t)\n\t\t\t}\n\t\t</PreviewOptions>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AAdA;AACA;AACA;;AASA;AACA;AACA;;AAGe,SAASQ,aAAaA,CAAA,EAAG;EACvC,MAAM;IACLC,kBAAkB;IAClBC,cAAc;IACdC,UAAU;IACVC,UAAU;IACVC;EACD,CAA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D,IAAAJ,MAAA,CAAAC,aAAA,EAAC/B,OAAA,CAAAwC,iBAAiB;IACjBN,SAAS,EAAC,2CAA2C;IACrDO,IAAI,EAAC,UAAU;IACfC,mBAAmB,EAAGlC,kBAAoB;IAC1CmC,WAAW,EACV,IAAAb,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAc,QAAA,QACG,IAAAP,QAAE,EAAE,oBAAqB,CAAC,EAC5B,IAAAP,MAAA,CAAAC,aAAA,EAACjC,WAAA,CAAA+C,IAAI;MAACC,IAAI,EAAGC;IAAU,CAAE,CACxB,CACF;IACDC,SAAS,EAAGV;EAAS,CACrB,CACG,CACK,CAGE,CAAC;AAEnB"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _i18n = require("@wordpress/i18n");
|
|
9
|
-
var _data = require("@wordpress/data");
|
|
10
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
var _components = require("@wordpress/components");
|
|
12
|
-
var _icons = require("@wordpress/icons");
|
|
13
|
-
var _commands = require("@wordpress/commands");
|
|
14
|
-
var _keycodes = require("@wordpress/keycodes");
|
|
15
|
-
var _store = require("../../../store");
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
function DocumentActions() {
|
|
25
|
-
const {
|
|
26
|
-
template
|
|
27
|
-
} = (0, _data.useSelect)(select => {
|
|
28
|
-
const {
|
|
29
|
-
getEditedPostTemplate
|
|
30
|
-
} = select(_store.store);
|
|
31
|
-
return {
|
|
32
|
-
template: getEditedPostTemplate()
|
|
33
|
-
};
|
|
34
|
-
}, []);
|
|
35
|
-
const {
|
|
36
|
-
clearSelectedBlock
|
|
37
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
38
|
-
const {
|
|
39
|
-
setIsEditingTemplate
|
|
40
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
41
|
-
const {
|
|
42
|
-
open: openCommandCenter
|
|
43
|
-
} = (0, _data.useDispatch)(_commands.store);
|
|
44
|
-
if (!template) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
let templateTitle = (0, _i18n.__)('Default');
|
|
48
|
-
if (template?.title) {
|
|
49
|
-
templateTitle = template.title;
|
|
50
|
-
} else if (!!template) {
|
|
51
|
-
templateTitle = template.slug;
|
|
52
|
-
}
|
|
53
|
-
return (0, _react.createElement)("div", {
|
|
54
|
-
className: "edit-post-document-actions"
|
|
55
|
-
}, (0, _react.createElement)(_components.Button, {
|
|
56
|
-
className: "edit-post-document-actions__back",
|
|
57
|
-
onClick: () => {
|
|
58
|
-
clearSelectedBlock();
|
|
59
|
-
setIsEditingTemplate(false);
|
|
60
|
-
},
|
|
61
|
-
icon: (0, _i18n.isRTL)() ? _icons.chevronRightSmall : _icons.chevronLeftSmall
|
|
62
|
-
}, (0, _i18n.__)('Back')), (0, _react.createElement)(_components.Button, {
|
|
63
|
-
className: "edit-post-document-actions__command",
|
|
64
|
-
onClick: () => openCommandCenter()
|
|
65
|
-
}, (0, _react.createElement)(_components.__experimentalHStack, {
|
|
66
|
-
className: "edit-post-document-actions__title",
|
|
67
|
-
spacing: 1,
|
|
68
|
-
justify: "center"
|
|
69
|
-
}, (0, _react.createElement)(_blockEditor.BlockIcon, {
|
|
70
|
-
icon: _icons.layout
|
|
71
|
-
}), (0, _react.createElement)(_components.__experimentalText, {
|
|
72
|
-
size: "body",
|
|
73
|
-
as: "h1"
|
|
74
|
-
}, (0, _react.createElement)(_components.VisuallyHidden, {
|
|
75
|
-
as: "span"
|
|
76
|
-
}, (0, _i18n.__)('Editing template: ')), templateTitle)), (0, _react.createElement)("span", {
|
|
77
|
-
className: "edit-post-document-actions__shortcut"
|
|
78
|
-
}, _keycodes.displayShortcut.primary('k'))));
|
|
79
|
-
}
|
|
80
|
-
var _default = DocumentActions;
|
|
81
|
-
exports.default = _default;
|
|
82
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_blockEditor","_components","_icons","_commands","_keycodes","_store","DocumentActions","template","useSelect","select","getEditedPostTemplate","editPostStore","clearSelectedBlock","useDispatch","blockEditorStore","setIsEditingTemplate","open","openCommandCenter","commandsStore","templateTitle","__","title","slug","_react","createElement","className","Button","onClick","icon","isRTL","chevronRightSmall","chevronLeftSmall","__experimentalHStack","spacing","justify","BlockIcon","layout","__experimentalText","size","as","VisuallyHidden","displayShortcut","primary","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/header/document-actions/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tVisuallyHidden,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { layout, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nfunction DocumentActions() {\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-post-document-actions\">\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-actions__back\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t} }\n\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t>\n\t\t\t\t{ __( 'Back' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-actions__command\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-post-document-actions__title\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t>\n\t\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{ __( 'Editing template: ' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t{ templateTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t</HStack>\n\t\t\t\t<span className=\"edit-post-document-actions__shortcut\">\n\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t</span>\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nexport default DocumentActions;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AAnB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