@wordpress/edit-post 6.8.0 → 6.11.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 +6 -0
- package/README.md +1 -1
- package/build/components/header/header-toolbar/index.js +7 -6
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/template-title/edit-template-title.js +11 -2
- package/build/components/header/template-title/edit-template-title.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build/components/keyboard-shortcut-help-modal/config.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/preferences-modal/index.js +3 -26
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/build/components/sidebar/plugin-post-status-info/index.js.map +1 -1
- package/build/components/sidebar/post-format/index.js +3 -1
- package/build/components/sidebar/post-format/index.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +28 -12
- package/build/components/sidebar/post-schedule/index.js.map +1 -1
- package/build/components/sidebar/post-slug/index.js +3 -1
- package/build/components/sidebar/post-slug/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +6 -2
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-template/create-modal.js +116 -0
- package/build/components/sidebar/post-template/create-modal.js.map +1 -0
- package/build/components/sidebar/post-template/form.js +123 -0
- package/build/components/sidebar/post-template/form.js.map +1 -0
- package/build/components/sidebar/post-template/index.js +128 -0
- package/build/components/sidebar/post-template/index.js.map +1 -0
- package/build/components/sidebar/post-url/index.js +68 -0
- package/build/components/sidebar/post-url/index.js.map +1 -0
- package/build/components/sidebar/post-visibility/index.js +21 -6
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +2 -6
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +31 -13
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/visual-editor/index.js +4 -2
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +8 -3
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +1 -1
- package/build/editor.native.js.map +1 -1
- package/build/store/selectors.js +8 -8
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js +8 -6
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/template-title/edit-template-title.js +12 -2
- package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +3 -25
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/build-module/components/sidebar/plugin-post-status-info/index.js.map +1 -1
- package/build-module/components/sidebar/post-format/index.js +3 -1
- package/build-module/components/sidebar/post-format/index.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +32 -13
- package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
- package/build-module/components/sidebar/post-slug/index.js +3 -1
- package/build-module/components/sidebar/post-slug/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +4 -2
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js +104 -0
- package/build-module/components/sidebar/post-template/create-modal.js.map +1 -0
- package/build-module/components/sidebar/post-template/form.js +106 -0
- package/build-module/components/sidebar/post-template/form.js.map +1 -0
- package/build-module/components/sidebar/post-template/index.js +114 -0
- package/build-module/components/sidebar/post-template/index.js.map +1 -0
- package/build-module/components/sidebar/post-url/index.js +59 -0
- package/build-module/components/sidebar/post-url/index.js.map +1 -0
- package/build-module/components/sidebar/post-visibility/index.js +24 -8
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +2 -4
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +32 -14
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +4 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +9 -4
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +2 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/store/selectors.js +8 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +82 -91
- package/build-style/style.css +81 -94
- package/package.json +27 -27
- package/src/components/header/header-toolbar/index.js +10 -10
- package/src/components/header/header-toolbar/style.scss +2 -5
- package/src/components/header/style.scss +0 -6
- package/src/components/header/template-title/edit-template-title.js +11 -1
- package/src/components/keyboard-shortcut-help-modal/config.js +8 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +14 -0
- package/src/components/preferences-modal/index.js +5 -23
- package/src/components/preferences-modal/test/index.js +3 -3
- package/src/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/src/components/sidebar/post-author/style.scss +4 -10
- package/src/components/sidebar/post-format/index.js +1 -1
- package/src/components/sidebar/post-format/style.scss +5 -0
- package/src/components/sidebar/post-schedule/index.js +27 -16
- package/src/components/sidebar/post-schedule/style.scss +16 -3
- package/src/components/sidebar/post-slug/index.js +1 -1
- package/src/components/sidebar/post-slug/style.scss +4 -3
- package/src/components/sidebar/post-status/index.js +6 -2
- package/src/components/sidebar/post-template/create-modal.js +146 -0
- package/src/components/sidebar/post-template/form.js +143 -0
- package/src/components/sidebar/post-template/index.js +106 -0
- package/src/components/sidebar/post-template/style.scss +36 -0
- package/src/components/sidebar/post-url/index.js +51 -0
- package/src/components/sidebar/post-url/style.scss +23 -0
- package/src/components/sidebar/post-visibility/index.js +22 -8
- package/src/components/sidebar/post-visibility/style.scss +4 -4
- package/src/components/sidebar/settings-sidebar/index.js +1 -5
- package/src/components/sidebar/template/style.scss +0 -8
- package/src/components/start-page-options/index.js +46 -22
- package/src/components/start-page-options/style.scss +0 -9
- package/src/components/visual-editor/index.js +2 -1
- package/src/editor.js +8 -4
- package/src/editor.native.js +2 -2
- package/src/store/selectors.js +5 -8
- package/src/style.scss +3 -2
- package/src/test/editor.native.js +1 -3
- package/build/components/sidebar/post-link/index.js +0 -182
- package/build/components/sidebar/post-link/index.js.map +0 -1
- package/build/components/sidebar/template/actions.js +0 -172
- package/build/components/sidebar/template/actions.js.map +0 -1
- package/build/components/sidebar/template/index.js +0 -164
- package/build/components/sidebar/template/index.js.map +0 -1
- package/build-module/components/sidebar/post-link/index.js +0 -165
- package/build-module/components/sidebar/post-link/index.js.map +0 -1
- package/build-module/components/sidebar/template/actions.js +0 -158
- package/build-module/components/sidebar/template/actions.js.map +0 -1
- package/build-module/components/sidebar/template/index.js +0 -145
- package/build-module/components/sidebar/template/index.js.map +0 -1
- package/src/components/sidebar/post-link/index.js +0 -179
- package/src/components/sidebar/post-link/style.scss +0 -20
- package/src/components/sidebar/template/actions.js +0 -206
- package/src/components/sidebar/template/index.js +0 -160
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Modal } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
6
|
+
import { useState, useEffect, useMemo } from '@wordpress/element';
|
|
7
7
|
import {
|
|
8
8
|
store as blockEditorStore,
|
|
9
9
|
__experimentalBlockPatternsList as BlockPatternsList,
|
|
@@ -17,15 +17,42 @@ import { store as editorStore } from '@wordpress/editor';
|
|
|
17
17
|
*/
|
|
18
18
|
import { store as editPostStore } from '../../store';
|
|
19
19
|
|
|
20
|
+
function useStartPatterns() {
|
|
21
|
+
// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
|
|
22
|
+
// and it has no postTypes declares and the current post type is page or if
|
|
23
|
+
// the current post type is part of the postTypes declared.
|
|
24
|
+
const { blockPatternsWithPostContentBlockType, postType } = useSelect(
|
|
25
|
+
( select ) => {
|
|
26
|
+
const { __experimentalGetPatternsByBlockTypes } =
|
|
27
|
+
select( blockEditorStore );
|
|
28
|
+
const { getCurrentPostType } = select( editorStore );
|
|
29
|
+
return {
|
|
30
|
+
// get pa
|
|
31
|
+
blockPatternsWithPostContentBlockType:
|
|
32
|
+
__experimentalGetPatternsByBlockTypes(
|
|
33
|
+
'core/post-content'
|
|
34
|
+
),
|
|
35
|
+
postType: getCurrentPostType(),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return useMemo( () => {
|
|
42
|
+
// filter patterns without postTypes declared if the current postType is page
|
|
43
|
+
// or patterns that declare the current postType in its post type array.
|
|
44
|
+
return blockPatternsWithPostContentBlockType.filter( ( pattern ) => {
|
|
45
|
+
return (
|
|
46
|
+
( postType === 'page' && ! pattern.postTypes ) ||
|
|
47
|
+
( Array.isArray( pattern.postTypes ) &&
|
|
48
|
+
pattern.postTypes.includes( postType ) )
|
|
49
|
+
);
|
|
50
|
+
} );
|
|
51
|
+
}, [ postType, blockPatternsWithPostContentBlockType ] );
|
|
52
|
+
}
|
|
53
|
+
|
|
20
54
|
function PatternSelection( { onChoosePattern } ) {
|
|
21
|
-
const
|
|
22
|
-
const { __experimentalGetPatternsByBlockTypes } =
|
|
23
|
-
select( blockEditorStore );
|
|
24
|
-
return {
|
|
25
|
-
blockPatterns:
|
|
26
|
-
__experimentalGetPatternsByBlockTypes( 'core/post-content' ),
|
|
27
|
-
};
|
|
28
|
-
}, [] );
|
|
55
|
+
const blockPatterns = useStartPatterns();
|
|
29
56
|
const shownBlockPatterns = useAsyncList( blockPatterns );
|
|
30
57
|
const { resetEditorBlocks } = useDispatch( editorStore );
|
|
31
58
|
return (
|
|
@@ -50,31 +77,28 @@ export default function StartPageOptions() {
|
|
|
50
77
|
const [ modalState, setModalState ] = useState(
|
|
51
78
|
START_PAGE_MODAL_STATES.INITIAL
|
|
52
79
|
);
|
|
80
|
+
const blockPatterns = useStartPatterns();
|
|
81
|
+
const hasStartPattern = blockPatterns.length > 0;
|
|
53
82
|
const shouldOpenModel = useSelect(
|
|
54
83
|
( select ) => {
|
|
55
|
-
if (
|
|
84
|
+
if (
|
|
85
|
+
! hasStartPattern ||
|
|
86
|
+
modalState !== START_PAGE_MODAL_STATES.INITIAL
|
|
87
|
+
) {
|
|
56
88
|
return false;
|
|
57
89
|
}
|
|
58
|
-
const {
|
|
59
|
-
select(
|
|
60
|
-
const {
|
|
61
|
-
getCurrentPostType,
|
|
62
|
-
getEditedPostContent,
|
|
63
|
-
isEditedPostSaveable,
|
|
64
|
-
} = select( editorStore );
|
|
90
|
+
const { getEditedPostContent, isEditedPostSaveable } =
|
|
91
|
+
select( editorStore );
|
|
65
92
|
const { isEditingTemplate, isFeatureActive } =
|
|
66
93
|
select( editPostStore );
|
|
67
94
|
return (
|
|
68
|
-
getCurrentPostType() === 'page' &&
|
|
69
95
|
! isEditedPostSaveable() &&
|
|
70
96
|
'' === getEditedPostContent() &&
|
|
71
97
|
! isEditingTemplate() &&
|
|
72
|
-
! isFeatureActive( 'welcomeGuide' )
|
|
73
|
-
__experimentalGetPatternsByBlockTypes( 'core/post-content' )
|
|
74
|
-
.length >= 1
|
|
98
|
+
! isFeatureActive( 'welcomeGuide' )
|
|
75
99
|
);
|
|
76
100
|
},
|
|
77
|
-
[ modalState ]
|
|
101
|
+
[ modalState, hasStartPattern ]
|
|
78
102
|
);
|
|
79
103
|
|
|
80
104
|
useEffect( () => {
|
|
@@ -11,15 +11,6 @@
|
|
|
11
11
|
@include break-large() {
|
|
12
12
|
height: 70%;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
// @todo: Consider this for a minimal modal prop.
|
|
16
|
-
.components-modal__header {
|
|
17
|
-
border-bottom: none;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.components-modal__content::before {
|
|
21
|
-
content: none;
|
|
22
|
-
}
|
|
23
14
|
}
|
|
24
15
|
|
|
25
16
|
// 2 column masonry layout.
|
|
@@ -245,6 +245,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
245
245
|
<LayoutStyle
|
|
246
246
|
selector=".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container"
|
|
247
247
|
layout={ defaultLayout }
|
|
248
|
+
layoutDefinitions={ defaultLayout?.definitions }
|
|
248
249
|
/>
|
|
249
250
|
) }
|
|
250
251
|
{ ! isTemplateMode && (
|
|
@@ -260,7 +261,7 @@ export default function VisualEditor( { styles } ) {
|
|
|
260
261
|
className={
|
|
261
262
|
isTemplateMode
|
|
262
263
|
? 'wp-site-blocks'
|
|
263
|
-
:
|
|
264
|
+
: 'is-layout-flow' // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
264
265
|
}
|
|
265
266
|
__experimentalLayout={ layout }
|
|
266
267
|
/>
|
package/src/editor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { forEach,
|
|
4
|
+
import { forEach, map, without } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -39,6 +39,7 @@ function Editor( {
|
|
|
39
39
|
hasFixedToolbar,
|
|
40
40
|
focusMode,
|
|
41
41
|
hasReducedUI,
|
|
42
|
+
hasInlineToolbar,
|
|
42
43
|
hasThemeStyles,
|
|
43
44
|
post,
|
|
44
45
|
preferredStyleVariations,
|
|
@@ -56,7 +57,7 @@ function Editor( {
|
|
|
56
57
|
getEditedPostTemplate,
|
|
57
58
|
getHiddenBlockTypes,
|
|
58
59
|
} = select( editPostStore );
|
|
59
|
-
const { getEntityRecord, getPostType, getEntityRecords } =
|
|
60
|
+
const { getEntityRecord, getPostType, getEntityRecords, canUser } =
|
|
60
61
|
select( coreStore );
|
|
61
62
|
const { getEditorSettings } = select( editorStore );
|
|
62
63
|
const { getBlockTypes } = select( blocksStore );
|
|
@@ -77,6 +78,7 @@ function Editor( {
|
|
|
77
78
|
const supportsTemplateMode =
|
|
78
79
|
getEditorSettings().supportsTemplateMode;
|
|
79
80
|
const isViewable = getPostType( postType )?.viewable ?? false;
|
|
81
|
+
const canEditTemplate = canUser( 'create', 'templates' );
|
|
80
82
|
|
|
81
83
|
return {
|
|
82
84
|
hasFixedToolbar:
|
|
@@ -84,6 +86,7 @@ function Editor( {
|
|
|
84
86
|
__experimentalGetPreviewDeviceType() !== 'Desktop',
|
|
85
87
|
focusMode: isFeatureActive( 'focusMode' ),
|
|
86
88
|
hasReducedUI: isFeatureActive( 'reducedUI' ),
|
|
89
|
+
hasInlineToolbar: isFeatureActive( 'inlineToolbar' ),
|
|
87
90
|
hasThemeStyles: isFeatureActive( 'themeStyles' ),
|
|
88
91
|
preferredStyleVariations: select( preferencesStore ).get(
|
|
89
92
|
'core/edit-post',
|
|
@@ -94,7 +97,7 @@ function Editor( {
|
|
|
94
97
|
keepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),
|
|
95
98
|
isTemplateMode: isEditingTemplate(),
|
|
96
99
|
template:
|
|
97
|
-
supportsTemplateMode && isViewable
|
|
100
|
+
supportsTemplateMode && isViewable && canEditTemplate
|
|
98
101
|
? getEditedPostTemplate()
|
|
99
102
|
: null,
|
|
100
103
|
post: postObject,
|
|
@@ -116,6 +119,7 @@ function Editor( {
|
|
|
116
119
|
hasFixedToolbar,
|
|
117
120
|
focusMode,
|
|
118
121
|
hasReducedUI,
|
|
122
|
+
hasInlineToolbar,
|
|
119
123
|
|
|
120
124
|
// This is marked as experimental to give time for the quick inserter to mature.
|
|
121
125
|
__experimentalSetIsInserterOpened: setIsInserterOpened,
|
|
@@ -126,7 +130,7 @@ function Editor( {
|
|
|
126
130
|
};
|
|
127
131
|
|
|
128
132
|
// Omit hidden block types if exists and non-empty.
|
|
129
|
-
if (
|
|
133
|
+
if ( hiddenBlockTypes.length > 0 ) {
|
|
130
134
|
// Defer to passed setting for `allowedBlockTypes` if provided as
|
|
131
135
|
// anything other than `true` (where `true` is equivalent to allow
|
|
132
136
|
// all block types).
|
package/src/editor.native.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import memize from 'memize';
|
|
5
|
-
import {
|
|
5
|
+
import { map, without } from 'lodash';
|
|
6
6
|
import { I18nManager } from 'react-native';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -62,7 +62,7 @@ class Editor extends Component {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// Omit hidden block types if exists and non-empty.
|
|
65
|
-
if (
|
|
65
|
+
if ( hiddenBlockTypes.length > 0 ) {
|
|
66
66
|
if ( settings.allowedBlockTypes === undefined ) {
|
|
67
67
|
// If no specific flags for allowedBlockTypes are set, assume `true`
|
|
68
68
|
// meaning allow all block types.
|
package/src/store/selectors.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import createSelector from 'rememo';
|
|
5
|
-
import { includes, some, flatten, values } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -43,8 +42,7 @@ export const isEditorSidebarOpened = createRegistrySelector(
|
|
|
43
42
|
select( interfaceStore ).getActiveComplementaryArea(
|
|
44
43
|
'core/edit-post'
|
|
45
44
|
);
|
|
46
|
-
return includes(
|
|
47
|
-
[ 'edit-post/document', 'edit-post/block' ],
|
|
45
|
+
return [ 'edit-post/document', 'edit-post/block' ].includes(
|
|
48
46
|
activeGeneralSidebar
|
|
49
47
|
);
|
|
50
48
|
}
|
|
@@ -65,8 +63,7 @@ export const isPluginSidebarOpened = createRegistrySelector(
|
|
|
65
63
|
);
|
|
66
64
|
return (
|
|
67
65
|
!! activeGeneralSidebar &&
|
|
68
|
-
! includes(
|
|
69
|
-
[ 'edit-post/document', 'edit-post/block' ],
|
|
66
|
+
! [ 'edit-post/document', 'edit-post/block' ].includes(
|
|
70
67
|
activeGeneralSidebar
|
|
71
68
|
)
|
|
72
69
|
);
|
|
@@ -254,7 +251,7 @@ export function isPublishSidebarOpened( state ) {
|
|
|
254
251
|
* @return {boolean} Whether or not the panel is removed.
|
|
255
252
|
*/
|
|
256
253
|
export function isEditorPanelRemoved( state, panelName ) {
|
|
257
|
-
return
|
|
254
|
+
return state.removedPanels.includes( panelName );
|
|
258
255
|
}
|
|
259
256
|
|
|
260
257
|
/**
|
|
@@ -369,7 +366,7 @@ export const getActiveMetaBoxLocations = createSelector(
|
|
|
369
366
|
export function isMetaBoxLocationVisible( state, location ) {
|
|
370
367
|
return (
|
|
371
368
|
isMetaBoxLocationActive( state, location ) &&
|
|
372
|
-
|
|
369
|
+
getMetaBoxesPerLocation( state, location )?.some( ( { id } ) => {
|
|
373
370
|
return isEditorPanelEnabled( state, `meta-box-${ id }` );
|
|
374
371
|
} )
|
|
375
372
|
);
|
|
@@ -410,7 +407,7 @@ export function getMetaBoxesPerLocation( state, location ) {
|
|
|
410
407
|
*/
|
|
411
408
|
export const getAllMetaBoxes = createSelector(
|
|
412
409
|
( state ) => {
|
|
413
|
-
return
|
|
410
|
+
return Object.values( state.metaBoxes.locations ).flat();
|
|
414
411
|
},
|
|
415
412
|
( state ) => [ state.metaBoxes.locations ]
|
|
416
413
|
);
|
package/src/style.scss
CHANGED
|
@@ -11,13 +11,14 @@
|
|
|
11
11
|
@import "./components/sidebar/style.scss";
|
|
12
12
|
@import "./components/sidebar/last-revision/style.scss";
|
|
13
13
|
@import "./components/sidebar/post-author/style.scss";
|
|
14
|
-
@import "./components/sidebar/post-
|
|
14
|
+
@import "./components/sidebar/post-format/style.scss";
|
|
15
15
|
@import "./components/sidebar/post-schedule/style.scss";
|
|
16
16
|
@import "./components/sidebar/post-slug/style.scss";
|
|
17
17
|
@import "./components/sidebar/post-status/style.scss";
|
|
18
|
+
@import "./components/sidebar/post-template/style.scss";
|
|
19
|
+
@import "./components/sidebar/post-url/style.scss";
|
|
18
20
|
@import "./components/sidebar/post-visibility/style.scss";
|
|
19
21
|
@import "./components/sidebar/settings-header/style.scss";
|
|
20
|
-
@import "./components/sidebar/template/style.scss";
|
|
21
22
|
@import "./components/sidebar/template-summary/style.scss";
|
|
22
23
|
@import "./components/text-editor/style.scss";
|
|
23
24
|
@import "./components/visual-editor/style.scss";
|
|
@@ -35,9 +35,7 @@ afterAll( () => {
|
|
|
35
35
|
} );
|
|
36
36
|
|
|
37
37
|
describe( 'Editor', () => {
|
|
38
|
-
beforeAll(
|
|
39
|
-
registerCoreBlocks();
|
|
40
|
-
} );
|
|
38
|
+
beforeAll( registerCoreBlocks );
|
|
41
39
|
|
|
42
40
|
it( 'detects unsupported block and sends hasUnsupportedBlocks true to native', () => {
|
|
43
41
|
RNReactNativeGutenbergBridge.editorDidMount = jest.fn();
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
|
-
var _i18n = require("@wordpress/i18n");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _compose = require("@wordpress/compose");
|
|
19
|
-
|
|
20
|
-
var _editor = require("@wordpress/editor");
|
|
21
|
-
|
|
22
|
-
var _url = require("@wordpress/url");
|
|
23
|
-
|
|
24
|
-
var _coreData = require("@wordpress/core-data");
|
|
25
|
-
|
|
26
|
-
var _store = require("../../../store");
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* External dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* WordPress dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Module Constants
|
|
42
|
-
*/
|
|
43
|
-
const PANEL_NAME = 'post-link';
|
|
44
|
-
|
|
45
|
-
function PostLink(_ref) {
|
|
46
|
-
let {
|
|
47
|
-
isOpened,
|
|
48
|
-
onTogglePanel,
|
|
49
|
-
isEditable,
|
|
50
|
-
postLink,
|
|
51
|
-
permalinkPrefix,
|
|
52
|
-
permalinkSuffix,
|
|
53
|
-
editPermalink,
|
|
54
|
-
postSlug,
|
|
55
|
-
postTypeLabel
|
|
56
|
-
} = _ref;
|
|
57
|
-
const [forceEmptyField, setForceEmptyField] = (0, _element.useState)(false);
|
|
58
|
-
let prefixElement, postNameElement, suffixElement;
|
|
59
|
-
|
|
60
|
-
if (isEditable) {
|
|
61
|
-
prefixElement = permalinkPrefix && (0, _element.createElement)("span", {
|
|
62
|
-
className: "edit-post-post-link__link-prefix"
|
|
63
|
-
}, permalinkPrefix);
|
|
64
|
-
postNameElement = postSlug && (0, _element.createElement)("span", {
|
|
65
|
-
className: "edit-post-post-link__link-post-name"
|
|
66
|
-
}, postSlug);
|
|
67
|
-
suffixElement = permalinkSuffix && (0, _element.createElement)("span", {
|
|
68
|
-
className: "edit-post-post-link__link-suffix"
|
|
69
|
-
}, permalinkSuffix);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (0, _element.createElement)(_components.PanelBody, {
|
|
73
|
-
title: (0, _i18n.__)('Permalink'),
|
|
74
|
-
opened: isOpened,
|
|
75
|
-
onToggle: onTogglePanel
|
|
76
|
-
}, isEditable && (0, _element.createElement)("div", {
|
|
77
|
-
className: "editor-post-link"
|
|
78
|
-
}, (0, _element.createElement)(_components.TextControl, {
|
|
79
|
-
label: (0, _i18n.__)('URL Slug'),
|
|
80
|
-
value: forceEmptyField ? '' : postSlug,
|
|
81
|
-
autoComplete: "off",
|
|
82
|
-
spellCheck: "false",
|
|
83
|
-
onChange: newValue => {
|
|
84
|
-
editPermalink(newValue); // When we delete the field the permalink gets
|
|
85
|
-
// reverted to the original value.
|
|
86
|
-
// The forceEmptyField logic allows the user to have
|
|
87
|
-
// the field temporarily empty while typing.
|
|
88
|
-
|
|
89
|
-
if (!newValue) {
|
|
90
|
-
if (!forceEmptyField) {
|
|
91
|
-
setForceEmptyField(true);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (forceEmptyField) {
|
|
98
|
-
setForceEmptyField(false);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
onBlur: event => {
|
|
102
|
-
editPermalink((0, _url.cleanForSlug)(event.target.value));
|
|
103
|
-
|
|
104
|
-
if (forceEmptyField) {
|
|
105
|
-
setForceEmptyField(false);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}), (0, _element.createElement)("p", null, (0, _i18n.__)('The last part of the URL.'), ' ', (0, _element.createElement)(_components.ExternalLink, {
|
|
109
|
-
href: (0, _i18n.__)('https://wordpress.org/support/article/settings-sidebar/#permalink')
|
|
110
|
-
}, (0, _i18n.__)('Read about permalinks')))), (0, _element.createElement)("h3", {
|
|
111
|
-
className: "edit-post-post-link__preview-label"
|
|
112
|
-
}, postTypeLabel || (0, _i18n.__)('View post')), (0, _element.createElement)("div", {
|
|
113
|
-
className: "edit-post-post-link__preview-link-container"
|
|
114
|
-
}, (0, _element.createElement)(_components.ExternalLink, {
|
|
115
|
-
className: "edit-post-post-link__link",
|
|
116
|
-
href: postLink,
|
|
117
|
-
target: "_blank"
|
|
118
|
-
}, isEditable ? (0, _element.createElement)(_element.Fragment, null, prefixElement, postNameElement, suffixElement) : postLink)));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
122
|
-
const {
|
|
123
|
-
isPermalinkEditable,
|
|
124
|
-
getCurrentPost,
|
|
125
|
-
isCurrentPostPublished,
|
|
126
|
-
getPermalinkParts,
|
|
127
|
-
getEditedPostAttribute,
|
|
128
|
-
getEditedPostSlug
|
|
129
|
-
} = select(_editor.store);
|
|
130
|
-
const {
|
|
131
|
-
isEditorPanelEnabled,
|
|
132
|
-
isEditorPanelOpened
|
|
133
|
-
} = select(_store.store);
|
|
134
|
-
const {
|
|
135
|
-
getPostType
|
|
136
|
-
} = select(_coreData.store);
|
|
137
|
-
const {
|
|
138
|
-
link
|
|
139
|
-
} = getCurrentPost();
|
|
140
|
-
const postTypeName = getEditedPostAttribute('type');
|
|
141
|
-
const postType = getPostType(postTypeName);
|
|
142
|
-
const permalinkParts = getPermalinkParts();
|
|
143
|
-
return {
|
|
144
|
-
postLink: link,
|
|
145
|
-
isEditable: isPermalinkEditable(),
|
|
146
|
-
isPublished: isCurrentPostPublished(),
|
|
147
|
-
isOpened: isEditorPanelOpened(PANEL_NAME),
|
|
148
|
-
isEnabled: isEditorPanelEnabled(PANEL_NAME),
|
|
149
|
-
isViewable: (0, _lodash.get)(postType, ['viewable'], false),
|
|
150
|
-
postSlug: (0, _url.safeDecodeURIComponent)(getEditedPostSlug()),
|
|
151
|
-
postTypeLabel: (0, _lodash.get)(postType, ['labels', 'view_item']),
|
|
152
|
-
hasPermalinkParts: !!permalinkParts,
|
|
153
|
-
permalinkPrefix: permalinkParts === null || permalinkParts === void 0 ? void 0 : permalinkParts.prefix,
|
|
154
|
-
permalinkSuffix: permalinkParts === null || permalinkParts === void 0 ? void 0 : permalinkParts.suffix
|
|
155
|
-
};
|
|
156
|
-
}), (0, _compose.ifCondition)(_ref2 => {
|
|
157
|
-
let {
|
|
158
|
-
isEnabled,
|
|
159
|
-
postLink,
|
|
160
|
-
isViewable,
|
|
161
|
-
hasPermalinkParts
|
|
162
|
-
} = _ref2;
|
|
163
|
-
return isEnabled && postLink && isViewable && hasPermalinkParts;
|
|
164
|
-
}), (0, _data.withDispatch)(dispatch => {
|
|
165
|
-
const {
|
|
166
|
-
toggleEditorPanelOpened
|
|
167
|
-
} = dispatch(_store.store);
|
|
168
|
-
const {
|
|
169
|
-
editPost
|
|
170
|
-
} = dispatch(_editor.store);
|
|
171
|
-
return {
|
|
172
|
-
onTogglePanel: () => toggleEditorPanelOpened(PANEL_NAME),
|
|
173
|
-
editPermalink: newSlug => {
|
|
174
|
-
editPost({
|
|
175
|
-
slug: newSlug
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
})])(PostLink);
|
|
180
|
-
|
|
181
|
-
exports.default = _default;
|
|
182
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-link/index.js"],"names":["PANEL_NAME","PostLink","isOpened","onTogglePanel","isEditable","postLink","permalinkPrefix","permalinkSuffix","editPermalink","postSlug","postTypeLabel","forceEmptyField","setForceEmptyField","prefixElement","postNameElement","suffixElement","newValue","event","target","value","select","isPermalinkEditable","getCurrentPost","isCurrentPostPublished","getPermalinkParts","getEditedPostAttribute","getEditedPostSlug","editorStore","isEditorPanelEnabled","isEditorPanelOpened","editPostStore","getPostType","coreStore","link","postTypeName","postType","permalinkParts","isPublished","isEnabled","isViewable","hasPermalinkParts","prefix","suffix","dispatch","toggleEditorPanelOpened","editPost","newSlug","slug"],"mappings":";;;;;;;AAeA;;AAZA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAGA;AACA;AACA;AACA,MAAMA,UAAU,GAAG,WAAnB;;AAEA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AAA,aAAa,EAAE,MAAMyC,uBAAuB,CAAE5C,UAAF,CADtC;AAENQ,IAAAA,aAAa,EAAIsC,OAAF,IAAe;AAC7BD,MAAAA,QAAQ,CAAE;AAAEE,QAAAA,IAAI,EAAED;AAAR,OAAF,CAAR;AACA;AAJK,GAAP;AAMA,CATD,CArCuB,CAAT,EA+CV7C,QA/CU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-link';\n\nfunction PostLink( {\n\tisOpened,\n\tonTogglePanel,\n\tisEditable,\n\tpostLink,\n\tpermalinkPrefix,\n\tpermalinkSuffix,\n\teditPermalink,\n\tpostSlug,\n\tpostTypeLabel,\n} ) {\n\tconst [ forceEmptyField, setForceEmptyField ] = useState( false );\n\n\tlet prefixElement, postNameElement, suffixElement;\n\tif ( isEditable ) {\n\t\tprefixElement = permalinkPrefix && (\n\t\t\t<span className=\"edit-post-post-link__link-prefix\">\n\t\t\t\t{ permalinkPrefix }\n\t\t\t</span>\n\t\t);\n\t\tpostNameElement = postSlug && (\n\t\t\t<span className=\"edit-post-post-link__link-post-name\">\n\t\t\t\t{ postSlug }\n\t\t\t</span>\n\t\t);\n\t\tsuffixElement = permalinkSuffix && (\n\t\t\t<span className=\"edit-post-post-link__link-suffix\">\n\t\t\t\t{ permalinkSuffix }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ __( 'Permalink' ) }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ onTogglePanel }\n\t\t>\n\t\t\t{ isEditable && (\n\t\t\t\t<div className=\"editor-post-link\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'URL Slug' ) }\n\t\t\t\t\t\tvalue={ forceEmptyField ? '' : postSlug }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\teditPermalink( newValue );\n\t\t\t\t\t\t\t// When we delete the field the permalink gets\n\t\t\t\t\t\t\t// reverted to the original value.\n\t\t\t\t\t\t\t// The forceEmptyField logic allows the user to have\n\t\t\t\t\t\t\t// the field temporarily empty while typing.\n\t\t\t\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t\t\t\tif ( ! forceEmptyField ) {\n\t\t\t\t\t\t\t\t\tsetForceEmptyField( true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\tsetForceEmptyField( false );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonBlur={ ( event ) => {\n\t\t\t\t\t\t\teditPermalink( cleanForSlug( event.target.value ) );\n\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\tsetForceEmptyField( false );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __( 'The last part of the URL.' ) }{ ' ' }\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/settings-sidebar/#permalink'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Read about permalinks' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<h3 className=\"edit-post-post-link__preview-label\">\n\t\t\t\t{ postTypeLabel || __( 'View post' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"edit-post-post-link__preview-link-container\">\n\t\t\t\t<ExternalLink\n\t\t\t\t\tclassName=\"edit-post-post-link__link\"\n\t\t\t\t\thref={ postLink }\n\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t>\n\t\t\t\t\t{ isEditable ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ prefixElement }\n\t\t\t\t\t\t\t{ postNameElement }\n\t\t\t\t\t\t\t{ suffixElement }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tpostLink\n\t\t\t\t\t) }\n\t\t\t\t</ExternalLink>\n\t\t\t</div>\n\t\t</PanelBody>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPermalinkEditable,\n\t\t\tgetCurrentPost,\n\t\t\tisCurrentPostPublished,\n\t\t\tgetPermalinkParts,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostSlug,\n\t\t} = select( editorStore );\n\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } =\n\t\t\tselect( editPostStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\tconst { link } = getCurrentPost();\n\n\t\tconst postTypeName = getEditedPostAttribute( 'type' );\n\t\tconst postType = getPostType( postTypeName );\n\t\tconst permalinkParts = getPermalinkParts();\n\n\t\treturn {\n\t\t\tpostLink: link,\n\t\t\tisEditable: isPermalinkEditable(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisViewable: get( postType, [ 'viewable' ], false ),\n\t\t\tpostSlug: safeDecodeURIComponent( getEditedPostSlug() ),\n\t\t\tpostTypeLabel: get( postType, [ 'labels', 'view_item' ] ),\n\t\t\thasPermalinkParts: !! permalinkParts,\n\t\t\tpermalinkPrefix: permalinkParts?.prefix,\n\t\t\tpermalinkSuffix: permalinkParts?.suffix,\n\t\t};\n\t} ),\n\tifCondition( ( { isEnabled, postLink, isViewable, hasPermalinkParts } ) => {\n\t\treturn isEnabled && postLink && isViewable && hasPermalinkParts;\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { toggleEditorPanelOpened } = dispatch( editPostStore );\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonTogglePanel: () => toggleEditorPanelOpened( PANEL_NAME ),\n\t\t\teditPermalink: ( newSlug ) => {\n\t\t\t\teditPost( { slug: newSlug } );\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostLink );\n"]}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
|
-
var _i18n = require("@wordpress/i18n");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _editor = require("@wordpress/editor");
|
|
19
|
-
|
|
20
|
-
var _coreData = require("@wordpress/core-data");
|
|
21
|
-
|
|
22
|
-
var _store = require("../../../store");
|
|
23
|
-
|
|
24
|
-
var _blocks = require("@wordpress/blocks");
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* External dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* WordPress dependencies
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Internal dependencies
|
|
36
|
-
*/
|
|
37
|
-
function PostTemplateActions(_ref) {
|
|
38
|
-
var _template$title$toLow;
|
|
39
|
-
|
|
40
|
-
let {
|
|
41
|
-
isPostsPage
|
|
42
|
-
} = _ref;
|
|
43
|
-
const [isModalOpen, setIsModalOpen] = (0, _element.useState)(false);
|
|
44
|
-
const [isBusy, setIsBusy] = (0, _element.useState)(false);
|
|
45
|
-
const [title, setTitle] = (0, _element.useState)('');
|
|
46
|
-
const {
|
|
47
|
-
template,
|
|
48
|
-
supportsTemplateMode,
|
|
49
|
-
defaultTemplate
|
|
50
|
-
} = (0, _data.useSelect)(select => {
|
|
51
|
-
var _getPostType$viewable, _getPostType;
|
|
52
|
-
|
|
53
|
-
const {
|
|
54
|
-
getCurrentPostType,
|
|
55
|
-
getEditorSettings
|
|
56
|
-
} = select(_editor.store);
|
|
57
|
-
const {
|
|
58
|
-
getPostType
|
|
59
|
-
} = select(_coreData.store);
|
|
60
|
-
const {
|
|
61
|
-
getEditedPostTemplate
|
|
62
|
-
} = select(_store.store);
|
|
63
|
-
const isViewable = (_getPostType$viewable = (_getPostType = getPostType(getCurrentPostType())) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
|
|
64
|
-
|
|
65
|
-
const _supportsTemplateMode = getEditorSettings().supportsTemplateMode && isViewable;
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
template: _supportsTemplateMode && getEditedPostTemplate(),
|
|
69
|
-
supportsTemplateMode: _supportsTemplateMode,
|
|
70
|
-
defaultTemplate: getEditorSettings().defaultBlockTemplate
|
|
71
|
-
};
|
|
72
|
-
}, []);
|
|
73
|
-
const {
|
|
74
|
-
__unstableCreateTemplate,
|
|
75
|
-
__unstableSwitchToTemplateMode
|
|
76
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
77
|
-
|
|
78
|
-
if (!supportsTemplateMode) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const defaultTitle = (0, _i18n.__)('Custom Template');
|
|
83
|
-
|
|
84
|
-
async function onCreateTemplate(event) {
|
|
85
|
-
event.preventDefault();
|
|
86
|
-
|
|
87
|
-
if (isBusy) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setIsBusy(true);
|
|
92
|
-
const newTemplateContent = defaultTemplate !== null && defaultTemplate !== void 0 ? defaultTemplate : (0, _blocks.serialize)([(0, _blocks.createBlock)('core/group', {
|
|
93
|
-
tagName: 'header',
|
|
94
|
-
layout: {
|
|
95
|
-
inherit: true
|
|
96
|
-
}
|
|
97
|
-
}, [(0, _blocks.createBlock)('core/site-title'), (0, _blocks.createBlock)('core/site-tagline')]), (0, _blocks.createBlock)('core/separator'), (0, _blocks.createBlock)('core/group', {
|
|
98
|
-
tagName: 'main'
|
|
99
|
-
}, [(0, _blocks.createBlock)('core/group', {
|
|
100
|
-
layout: {
|
|
101
|
-
inherit: true
|
|
102
|
-
}
|
|
103
|
-
}, [(0, _blocks.createBlock)('core/post-title')]), (0, _blocks.createBlock)('core/post-content', {
|
|
104
|
-
layout: {
|
|
105
|
-
inherit: true
|
|
106
|
-
}
|
|
107
|
-
})])]);
|
|
108
|
-
await __unstableCreateTemplate({
|
|
109
|
-
slug: 'wp-custom-template-' + (0, _lodash.kebabCase)(title || defaultTitle),
|
|
110
|
-
content: newTemplateContent,
|
|
111
|
-
title: title || defaultTitle
|
|
112
|
-
});
|
|
113
|
-
setIsBusy(false);
|
|
114
|
-
setIsModalOpen(false);
|
|
115
|
-
|
|
116
|
-
__unstableSwitchToTemplateMode(true);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
|
|
120
|
-
className: "edit-post-template__actions"
|
|
121
|
-
}, !!template && (0, _element.createElement)(_components.Button, {
|
|
122
|
-
variant: "link",
|
|
123
|
-
onClick: () => __unstableSwitchToTemplateMode(),
|
|
124
|
-
label: (0, _i18n.sprintf)( // Translators: 1: The title or the slug of the currently selected template.
|
|
125
|
-
(0, _i18n.__)('Edit template: %s'), (_template$title$toLow = template === null || template === void 0 ? void 0 : template.title.toLowerCase()) !== null && _template$title$toLow !== void 0 ? _template$title$toLow : template.slug)
|
|
126
|
-
}, (0, _i18n.__)('Edit')), !isPostsPage && (0, _element.createElement)(_components.Button, {
|
|
127
|
-
variant: "link",
|
|
128
|
-
onClick: () => setIsModalOpen(true),
|
|
129
|
-
label: (0, _i18n._x)('New template', 'action')
|
|
130
|
-
},
|
|
131
|
-
/* translators: button to create a new template */
|
|
132
|
-
(0, _i18n._x)('New', 'action'))), isModalOpen && (0, _element.createElement)(_components.Modal, {
|
|
133
|
-
title: (0, _i18n.__)('Create custom template'),
|
|
134
|
-
closeLabel: (0, _i18n.__)('Close'),
|
|
135
|
-
onRequestClose: () => {
|
|
136
|
-
setIsModalOpen(false);
|
|
137
|
-
setTitle('');
|
|
138
|
-
},
|
|
139
|
-
overlayClassName: "edit-post-template__modal"
|
|
140
|
-
}, (0, _element.createElement)("form", {
|
|
141
|
-
onSubmit: onCreateTemplate
|
|
142
|
-
}, (0, _element.createElement)(_components.Flex, {
|
|
143
|
-
align: "flex-start",
|
|
144
|
-
gap: 8
|
|
145
|
-
}, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.TextControl, {
|
|
146
|
-
label: (0, _i18n.__)('Name'),
|
|
147
|
-
value: title,
|
|
148
|
-
onChange: setTitle,
|
|
149
|
-
placeholder: defaultTitle,
|
|
150
|
-
disabled: isBusy,
|
|
151
|
-
help: (0, _i18n.__)('Describe the purpose of the template, e.g. "Full Width". Custom templates can be applied to any post or page.')
|
|
152
|
-
}))), (0, _element.createElement)(_components.Flex, {
|
|
153
|
-
className: "edit-post-template__modal-actions",
|
|
154
|
-
justify: "flex-end",
|
|
155
|
-
expanded: false
|
|
156
|
-
}, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
157
|
-
variant: "tertiary",
|
|
158
|
-
onClick: () => {
|
|
159
|
-
setIsModalOpen(false);
|
|
160
|
-
setTitle('');
|
|
161
|
-
}
|
|
162
|
-
}, (0, _i18n.__)('Cancel'))), (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
163
|
-
variant: "primary",
|
|
164
|
-
type: "submit",
|
|
165
|
-
isBusy: isBusy,
|
|
166
|
-
"aria-disabled": isBusy
|
|
167
|
-
}, (0, _i18n.__)('Create')))))));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var _default = PostTemplateActions;
|
|
171
|
-
exports.default = _default;
|
|
172
|
-
//# sourceMappingURL=actions.js.map
|