@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
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { partial, isEmpty, map, fromPairs } from 'lodash';
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
12
|
-
import { useMemo } from '@wordpress/element';
|
|
13
|
-
import { Notice, PanelBody, SelectControl } from '@wordpress/components';
|
|
14
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
15
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
16
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import PostTemplateActions from './actions';
|
|
22
|
-
import { store as editPostStore } from '../../../store';
|
|
23
|
-
/**
|
|
24
|
-
* Module Constants
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
const PANEL_NAME = 'template';
|
|
28
|
-
export function TemplatePanel() {
|
|
29
|
-
const {
|
|
30
|
-
isEnabled,
|
|
31
|
-
isOpened,
|
|
32
|
-
isPostsPage,
|
|
33
|
-
selectedTemplate,
|
|
34
|
-
availableTemplates,
|
|
35
|
-
fetchedTemplates,
|
|
36
|
-
isViewable,
|
|
37
|
-
template,
|
|
38
|
-
supportsTemplateMode,
|
|
39
|
-
canUserCreate
|
|
40
|
-
} = useSelect(select => {
|
|
41
|
-
var _getPostType$viewable, _getPostType;
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
isEditorPanelEnabled,
|
|
45
|
-
isEditorPanelOpened,
|
|
46
|
-
getEditedPostTemplate
|
|
47
|
-
} = select(editPostStore);
|
|
48
|
-
const {
|
|
49
|
-
getEditedPostAttribute,
|
|
50
|
-
getEditorSettings,
|
|
51
|
-
getCurrentPostId,
|
|
52
|
-
getCurrentPostType
|
|
53
|
-
} = select(editorStore);
|
|
54
|
-
const {
|
|
55
|
-
getPostType,
|
|
56
|
-
getEntityRecord,
|
|
57
|
-
getEntityRecords,
|
|
58
|
-
canUser
|
|
59
|
-
} = select(coreStore);
|
|
60
|
-
const currentPostId = getCurrentPostId();
|
|
61
|
-
const currentPostType = getCurrentPostType();
|
|
62
|
-
const settings = getEntityRecord('root', 'site');
|
|
63
|
-
|
|
64
|
-
const _isViewable = (_getPostType$viewable = (_getPostType = getPostType(currentPostType)) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
|
|
65
|
-
|
|
66
|
-
const _supportsTemplateMode = select(editorStore).getEditorSettings().supportsTemplateMode && _isViewable;
|
|
67
|
-
|
|
68
|
-
const templateRecords = getEntityRecords('postType', 'wp_template', {
|
|
69
|
-
post_type: currentPostType,
|
|
70
|
-
per_page: -1
|
|
71
|
-
});
|
|
72
|
-
return {
|
|
73
|
-
isEnabled: isEditorPanelEnabled(PANEL_NAME),
|
|
74
|
-
isOpened: isEditorPanelOpened(PANEL_NAME),
|
|
75
|
-
isPostsPage: currentPostId === (settings === null || settings === void 0 ? void 0 : settings.page_for_posts),
|
|
76
|
-
selectedTemplate: getEditedPostAttribute('template'),
|
|
77
|
-
availableTemplates: getEditorSettings().availableTemplates,
|
|
78
|
-
fetchedTemplates: templateRecords,
|
|
79
|
-
template: _supportsTemplateMode && getEditedPostTemplate(),
|
|
80
|
-
isViewable: _isViewable,
|
|
81
|
-
supportsTemplateMode: _supportsTemplateMode,
|
|
82
|
-
canUserCreate: canUser('create', 'templates')
|
|
83
|
-
};
|
|
84
|
-
}, []);
|
|
85
|
-
const templates = useMemo(() => {
|
|
86
|
-
return { ...availableTemplates,
|
|
87
|
-
...fromPairs((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(_ref => {
|
|
88
|
-
let {
|
|
89
|
-
slug,
|
|
90
|
-
title
|
|
91
|
-
} = _ref;
|
|
92
|
-
return [slug, title.rendered];
|
|
93
|
-
}))
|
|
94
|
-
};
|
|
95
|
-
}, [availableTemplates, fetchedTemplates]);
|
|
96
|
-
const {
|
|
97
|
-
toggleEditorPanelOpened
|
|
98
|
-
} = useDispatch(editPostStore);
|
|
99
|
-
const {
|
|
100
|
-
editPost
|
|
101
|
-
} = useDispatch(editorStore);
|
|
102
|
-
|
|
103
|
-
if (!isEnabled || !isViewable || isEmpty(availableTemplates) && (!supportsTemplateMode || !canUserCreate)) {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const onTogglePanel = partial(toggleEditorPanelOpened, PANEL_NAME);
|
|
108
|
-
|
|
109
|
-
let panelTitle = __('Template');
|
|
110
|
-
|
|
111
|
-
if (!!template) {
|
|
112
|
-
var _template$title;
|
|
113
|
-
|
|
114
|
-
panelTitle = sprintf(
|
|
115
|
-
/* translators: %s: template title */
|
|
116
|
-
__('Template: %s'), (_template$title = template === null || template === void 0 ? void 0 : template.title) !== null && _template$title !== void 0 ? _template$title : template.slug);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return createElement(PanelBody, {
|
|
120
|
-
title: panelTitle,
|
|
121
|
-
opened: isOpened,
|
|
122
|
-
onToggle: onTogglePanel
|
|
123
|
-
}, isPostsPage ? createElement(Notice, {
|
|
124
|
-
className: "edit-post-template__notice",
|
|
125
|
-
status: "warning",
|
|
126
|
-
isDismissible: false
|
|
127
|
-
}, __('The posts page template cannot be changed.')) : createElement(SelectControl, {
|
|
128
|
-
hideLabelFromVision: true,
|
|
129
|
-
label: __('Template:'),
|
|
130
|
-
value: Object.keys(templates).includes(selectedTemplate) ? selectedTemplate : '',
|
|
131
|
-
onChange: templateSlug => {
|
|
132
|
-
editPost({
|
|
133
|
-
template: templateSlug || ''
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
options: map(templates, (templateName, templateSlug) => ({
|
|
137
|
-
value: templateSlug,
|
|
138
|
-
label: templateName
|
|
139
|
-
}))
|
|
140
|
-
}), canUserCreate && createElement(PostTemplateActions, {
|
|
141
|
-
isPostsPage: isPostsPage
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
export default TemplatePanel;
|
|
145
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/template/index.js"],"names":["partial","isEmpty","map","fromPairs","__","sprintf","useMemo","Notice","PanelBody","SelectControl","store","editorStore","useSelect","useDispatch","coreStore","PostTemplateActions","editPostStore","PANEL_NAME","TemplatePanel","isEnabled","isOpened","isPostsPage","selectedTemplate","availableTemplates","fetchedTemplates","isViewable","template","supportsTemplateMode","canUserCreate","select","isEditorPanelEnabled","isEditorPanelOpened","getEditedPostTemplate","getEditedPostAttribute","getEditorSettings","getCurrentPostId","getCurrentPostType","getPostType","getEntityRecord","getEntityRecords","canUser","currentPostId","currentPostType","settings","_isViewable","viewable","_supportsTemplateMode","templateRecords","post_type","per_page","page_for_posts","templates","slug","title","rendered","toggleEditorPanelOpened","editPost","onTogglePanel","panelTitle","Object","keys","includes","templateSlug","templateName","value","label"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { partial, isEmpty, map, fromPairs } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { Notice, PanelBody, SelectControl } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTemplateActions from './actions';\nimport { store as editPostStore } from '../../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'template';\n\nexport function TemplatePanel() {\n\tconst {\n\t\tisEnabled,\n\t\tisOpened,\n\t\tisPostsPage,\n\t\tselectedTemplate,\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tisViewable,\n\t\ttemplate,\n\t\tsupportsTemplateMode,\n\t\tcanUserCreate,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisEditorPanelEnabled,\n\t\t\tisEditorPanelOpened,\n\t\t\tgetEditedPostTemplate,\n\t\t} = select( editPostStore );\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditorSettings,\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t} = select( editorStore );\n\t\tconst { getPostType, getEntityRecord, getEntityRecords, canUser } =\n\t\t\tselect( coreStore );\n\n\t\tconst currentPostId = getCurrentPostId();\n\t\tconst currentPostType = getCurrentPostType();\n\t\tconst settings = getEntityRecord( 'root', 'site' );\n\t\tconst _isViewable = getPostType( currentPostType )?.viewable ?? false;\n\t\tconst _supportsTemplateMode =\n\t\t\tselect( editorStore ).getEditorSettings().supportsTemplateMode &&\n\t\t\t_isViewable;\n\n\t\tconst templateRecords = getEntityRecords( 'postType', 'wp_template', {\n\t\t\tpost_type: currentPostType,\n\t\t\tper_page: -1,\n\t\t} );\n\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisPostsPage: currentPostId === settings?.page_for_posts,\n\t\t\tselectedTemplate: getEditedPostAttribute( 'template' ),\n\t\t\tavailableTemplates: getEditorSettings().availableTemplates,\n\t\t\tfetchedTemplates: templateRecords,\n\t\t\ttemplate: _supportsTemplateMode && getEditedPostTemplate(),\n\t\t\tisViewable: _isViewable,\n\t\t\tsupportsTemplateMode: _supportsTemplateMode,\n\t\t\tcanUserCreate: canUser( 'create', 'templates' ),\n\t\t};\n\t}, [] );\n\n\tconst templates = useMemo( () => {\n\t\treturn {\n\t\t\t...availableTemplates,\n\t\t\t...fromPairs(\n\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\tslug,\n\t\t\t\t\ttitle.rendered,\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}, [ availableTemplates, fetchedTemplates ] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editPostStore );\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif (\n\t\t! isEnabled ||\n\t\t! isViewable ||\n\t\t( isEmpty( availableTemplates ) &&\n\t\t\t( ! supportsTemplateMode || ! canUserCreate ) )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onTogglePanel = partial( toggleEditorPanelOpened, PANEL_NAME );\n\n\tlet panelTitle = __( 'Template' );\n\tif ( !! template ) {\n\t\tpanelTitle = sprintf(\n\t\t\t/* translators: %s: template title */\n\t\t\t__( 'Template: %s' ),\n\t\t\ttemplate?.title ?? template.slug\n\t\t);\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ panelTitle }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ onTogglePanel }\n\t\t>\n\t\t\t{ isPostsPage ? (\n\t\t\t\t<Notice\n\t\t\t\t\tclassName=\"edit-post-template__notice\"\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template:' ) }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\tObject.keys( templates ).includes( selectedTemplate )\n\t\t\t\t\t\t\t? selectedTemplate\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( templateSlug ) => {\n\t\t\t\t\t\teditPost( {\n\t\t\t\t\t\t\ttemplate: templateSlug || '',\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\toptions={ map(\n\t\t\t\t\t\ttemplates,\n\t\t\t\t\t\t( templateName, templateSlug ) => ( {\n\t\t\t\t\t\t\tvalue: templateSlug,\n\t\t\t\t\t\t\tlabel: templateName,\n\t\t\t\t\t\t} )\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canUserCreate && (\n\t\t\t\t<PostTemplateActions isPostsPage={ isPostsPage } />\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n\nexport default TemplatePanel;\n"]}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { PanelBody, TextControl, ExternalLink } from '@wordpress/components';
|
|
11
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
12
|
-
import { compose, ifCondition } from '@wordpress/compose';
|
|
13
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
14
|
-
import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
|
|
15
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
16
|
-
import { useState } from '@wordpress/element';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Internal dependencies
|
|
20
|
-
*/
|
|
21
|
-
import { store as editPostStore } from '../../../store';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Module Constants
|
|
25
|
-
*/
|
|
26
|
-
const PANEL_NAME = 'post-link';
|
|
27
|
-
|
|
28
|
-
function PostLink( {
|
|
29
|
-
isOpened,
|
|
30
|
-
onTogglePanel,
|
|
31
|
-
isEditable,
|
|
32
|
-
postLink,
|
|
33
|
-
permalinkPrefix,
|
|
34
|
-
permalinkSuffix,
|
|
35
|
-
editPermalink,
|
|
36
|
-
postSlug,
|
|
37
|
-
postTypeLabel,
|
|
38
|
-
} ) {
|
|
39
|
-
const [ forceEmptyField, setForceEmptyField ] = useState( false );
|
|
40
|
-
|
|
41
|
-
let prefixElement, postNameElement, suffixElement;
|
|
42
|
-
if ( isEditable ) {
|
|
43
|
-
prefixElement = permalinkPrefix && (
|
|
44
|
-
<span className="edit-post-post-link__link-prefix">
|
|
45
|
-
{ permalinkPrefix }
|
|
46
|
-
</span>
|
|
47
|
-
);
|
|
48
|
-
postNameElement = postSlug && (
|
|
49
|
-
<span className="edit-post-post-link__link-post-name">
|
|
50
|
-
{ postSlug }
|
|
51
|
-
</span>
|
|
52
|
-
);
|
|
53
|
-
suffixElement = permalinkSuffix && (
|
|
54
|
-
<span className="edit-post-post-link__link-suffix">
|
|
55
|
-
{ permalinkSuffix }
|
|
56
|
-
</span>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<PanelBody
|
|
62
|
-
title={ __( 'Permalink' ) }
|
|
63
|
-
opened={ isOpened }
|
|
64
|
-
onToggle={ onTogglePanel }
|
|
65
|
-
>
|
|
66
|
-
{ isEditable && (
|
|
67
|
-
<div className="editor-post-link">
|
|
68
|
-
<TextControl
|
|
69
|
-
label={ __( 'URL Slug' ) }
|
|
70
|
-
value={ forceEmptyField ? '' : postSlug }
|
|
71
|
-
autoComplete="off"
|
|
72
|
-
spellCheck="false"
|
|
73
|
-
onChange={ ( newValue ) => {
|
|
74
|
-
editPermalink( newValue );
|
|
75
|
-
// When we delete the field the permalink gets
|
|
76
|
-
// reverted to the original value.
|
|
77
|
-
// The forceEmptyField logic allows the user to have
|
|
78
|
-
// the field temporarily empty while typing.
|
|
79
|
-
if ( ! newValue ) {
|
|
80
|
-
if ( ! forceEmptyField ) {
|
|
81
|
-
setForceEmptyField( true );
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if ( forceEmptyField ) {
|
|
86
|
-
setForceEmptyField( false );
|
|
87
|
-
}
|
|
88
|
-
} }
|
|
89
|
-
onBlur={ ( event ) => {
|
|
90
|
-
editPermalink( cleanForSlug( event.target.value ) );
|
|
91
|
-
if ( forceEmptyField ) {
|
|
92
|
-
setForceEmptyField( false );
|
|
93
|
-
}
|
|
94
|
-
} }
|
|
95
|
-
/>
|
|
96
|
-
<p>
|
|
97
|
-
{ __( 'The last part of the URL.' ) }{ ' ' }
|
|
98
|
-
<ExternalLink
|
|
99
|
-
href={ __(
|
|
100
|
-
'https://wordpress.org/support/article/settings-sidebar/#permalink'
|
|
101
|
-
) }
|
|
102
|
-
>
|
|
103
|
-
{ __( 'Read about permalinks' ) }
|
|
104
|
-
</ExternalLink>
|
|
105
|
-
</p>
|
|
106
|
-
</div>
|
|
107
|
-
) }
|
|
108
|
-
<h3 className="edit-post-post-link__preview-label">
|
|
109
|
-
{ postTypeLabel || __( 'View post' ) }
|
|
110
|
-
</h3>
|
|
111
|
-
<div className="edit-post-post-link__preview-link-container">
|
|
112
|
-
<ExternalLink
|
|
113
|
-
className="edit-post-post-link__link"
|
|
114
|
-
href={ postLink }
|
|
115
|
-
target="_blank"
|
|
116
|
-
>
|
|
117
|
-
{ isEditable ? (
|
|
118
|
-
<>
|
|
119
|
-
{ prefixElement }
|
|
120
|
-
{ postNameElement }
|
|
121
|
-
{ suffixElement }
|
|
122
|
-
</>
|
|
123
|
-
) : (
|
|
124
|
-
postLink
|
|
125
|
-
) }
|
|
126
|
-
</ExternalLink>
|
|
127
|
-
</div>
|
|
128
|
-
</PanelBody>
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export default compose( [
|
|
133
|
-
withSelect( ( select ) => {
|
|
134
|
-
const {
|
|
135
|
-
isPermalinkEditable,
|
|
136
|
-
getCurrentPost,
|
|
137
|
-
isCurrentPostPublished,
|
|
138
|
-
getPermalinkParts,
|
|
139
|
-
getEditedPostAttribute,
|
|
140
|
-
getEditedPostSlug,
|
|
141
|
-
} = select( editorStore );
|
|
142
|
-
const { isEditorPanelEnabled, isEditorPanelOpened } =
|
|
143
|
-
select( editPostStore );
|
|
144
|
-
const { getPostType } = select( coreStore );
|
|
145
|
-
|
|
146
|
-
const { link } = getCurrentPost();
|
|
147
|
-
|
|
148
|
-
const postTypeName = getEditedPostAttribute( 'type' );
|
|
149
|
-
const postType = getPostType( postTypeName );
|
|
150
|
-
const permalinkParts = getPermalinkParts();
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
postLink: link,
|
|
154
|
-
isEditable: isPermalinkEditable(),
|
|
155
|
-
isPublished: isCurrentPostPublished(),
|
|
156
|
-
isOpened: isEditorPanelOpened( PANEL_NAME ),
|
|
157
|
-
isEnabled: isEditorPanelEnabled( PANEL_NAME ),
|
|
158
|
-
isViewable: get( postType, [ 'viewable' ], false ),
|
|
159
|
-
postSlug: safeDecodeURIComponent( getEditedPostSlug() ),
|
|
160
|
-
postTypeLabel: get( postType, [ 'labels', 'view_item' ] ),
|
|
161
|
-
hasPermalinkParts: !! permalinkParts,
|
|
162
|
-
permalinkPrefix: permalinkParts?.prefix,
|
|
163
|
-
permalinkSuffix: permalinkParts?.suffix,
|
|
164
|
-
};
|
|
165
|
-
} ),
|
|
166
|
-
ifCondition( ( { isEnabled, postLink, isViewable, hasPermalinkParts } ) => {
|
|
167
|
-
return isEnabled && postLink && isViewable && hasPermalinkParts;
|
|
168
|
-
} ),
|
|
169
|
-
withDispatch( ( dispatch ) => {
|
|
170
|
-
const { toggleEditorPanelOpened } = dispatch( editPostStore );
|
|
171
|
-
const { editPost } = dispatch( editorStore );
|
|
172
|
-
return {
|
|
173
|
-
onTogglePanel: () => toggleEditorPanelOpened( PANEL_NAME ),
|
|
174
|
-
editPermalink: ( newSlug ) => {
|
|
175
|
-
editPost( { slug: newSlug } );
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
} ),
|
|
179
|
-
] )( PostLink );
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
.edit-post-post-link__link-post-name {
|
|
2
|
-
font-weight: 600;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.edit-post-post-link__preview-label {
|
|
6
|
-
font-weight: 400;
|
|
7
|
-
margin: 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.edit-post-post-link__link {
|
|
11
|
-
text-align: left;
|
|
12
|
-
word-wrap: break-word;
|
|
13
|
-
display: block;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* rtl:begin:ignore */
|
|
17
|
-
.edit-post-post-link__preview-link-container {
|
|
18
|
-
direction: ltr;
|
|
19
|
-
}
|
|
20
|
-
/* rtl:end:ignore */
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { kebabCase } from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
11
|
-
Button,
|
|
12
|
-
Modal,
|
|
13
|
-
TextControl,
|
|
14
|
-
Flex,
|
|
15
|
-
FlexItem,
|
|
16
|
-
} from '@wordpress/components';
|
|
17
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
18
|
-
import { useState } from '@wordpress/element';
|
|
19
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
20
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
|
-
import { store as editPostStore } from '../../../store';
|
|
26
|
-
import { createBlock, serialize } from '@wordpress/blocks';
|
|
27
|
-
|
|
28
|
-
function PostTemplateActions( { isPostsPage } ) {
|
|
29
|
-
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
30
|
-
const [ isBusy, setIsBusy ] = useState( false );
|
|
31
|
-
const [ title, setTitle ] = useState( '' );
|
|
32
|
-
const { template, supportsTemplateMode, defaultTemplate } = useSelect(
|
|
33
|
-
( select ) => {
|
|
34
|
-
const { getCurrentPostType, getEditorSettings } =
|
|
35
|
-
select( editorStore );
|
|
36
|
-
const { getPostType } = select( coreStore );
|
|
37
|
-
const { getEditedPostTemplate } = select( editPostStore );
|
|
38
|
-
|
|
39
|
-
const isViewable =
|
|
40
|
-
getPostType( getCurrentPostType() )?.viewable ?? false;
|
|
41
|
-
const _supportsTemplateMode =
|
|
42
|
-
getEditorSettings().supportsTemplateMode && isViewable;
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
template: _supportsTemplateMode && getEditedPostTemplate(),
|
|
46
|
-
supportsTemplateMode: _supportsTemplateMode,
|
|
47
|
-
defaultTemplate: getEditorSettings().defaultBlockTemplate,
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
[]
|
|
51
|
-
);
|
|
52
|
-
const { __unstableCreateTemplate, __unstableSwitchToTemplateMode } =
|
|
53
|
-
useDispatch( editPostStore );
|
|
54
|
-
|
|
55
|
-
if ( ! supportsTemplateMode ) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const defaultTitle = __( 'Custom Template' );
|
|
60
|
-
|
|
61
|
-
async function onCreateTemplate( event ) {
|
|
62
|
-
event.preventDefault();
|
|
63
|
-
|
|
64
|
-
if ( isBusy ) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
setIsBusy( true );
|
|
69
|
-
|
|
70
|
-
const newTemplateContent =
|
|
71
|
-
defaultTemplate ??
|
|
72
|
-
serialize( [
|
|
73
|
-
createBlock(
|
|
74
|
-
'core/group',
|
|
75
|
-
{
|
|
76
|
-
tagName: 'header',
|
|
77
|
-
layout: { inherit: true },
|
|
78
|
-
},
|
|
79
|
-
[
|
|
80
|
-
createBlock( 'core/site-title' ),
|
|
81
|
-
createBlock( 'core/site-tagline' ),
|
|
82
|
-
]
|
|
83
|
-
),
|
|
84
|
-
createBlock( 'core/separator' ),
|
|
85
|
-
createBlock(
|
|
86
|
-
'core/group',
|
|
87
|
-
{
|
|
88
|
-
tagName: 'main',
|
|
89
|
-
},
|
|
90
|
-
[
|
|
91
|
-
createBlock(
|
|
92
|
-
'core/group',
|
|
93
|
-
{
|
|
94
|
-
layout: { inherit: true },
|
|
95
|
-
},
|
|
96
|
-
[ createBlock( 'core/post-title' ) ]
|
|
97
|
-
),
|
|
98
|
-
createBlock( 'core/post-content', {
|
|
99
|
-
layout: { inherit: true },
|
|
100
|
-
} ),
|
|
101
|
-
]
|
|
102
|
-
),
|
|
103
|
-
] );
|
|
104
|
-
|
|
105
|
-
await __unstableCreateTemplate( {
|
|
106
|
-
slug: 'wp-custom-template-' + kebabCase( title || defaultTitle ),
|
|
107
|
-
content: newTemplateContent,
|
|
108
|
-
title: title || defaultTitle,
|
|
109
|
-
} );
|
|
110
|
-
|
|
111
|
-
setIsBusy( false );
|
|
112
|
-
setIsModalOpen( false );
|
|
113
|
-
|
|
114
|
-
__unstableSwitchToTemplateMode( true );
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<>
|
|
119
|
-
<div className="edit-post-template__actions">
|
|
120
|
-
{ !! template && (
|
|
121
|
-
<Button
|
|
122
|
-
variant="link"
|
|
123
|
-
onClick={ () => __unstableSwitchToTemplateMode() }
|
|
124
|
-
label={ sprintf(
|
|
125
|
-
// Translators: 1: The title or the slug of the currently selected template.
|
|
126
|
-
__( 'Edit template: %s' ),
|
|
127
|
-
template?.title.toLowerCase() ?? template.slug
|
|
128
|
-
) }
|
|
129
|
-
>
|
|
130
|
-
{ __( 'Edit' ) }
|
|
131
|
-
</Button>
|
|
132
|
-
) }
|
|
133
|
-
{ ! isPostsPage && (
|
|
134
|
-
<Button
|
|
135
|
-
variant="link"
|
|
136
|
-
onClick={ () => setIsModalOpen( true ) }
|
|
137
|
-
label={ _x( 'New template', 'action' ) }
|
|
138
|
-
>
|
|
139
|
-
{
|
|
140
|
-
/* translators: button to create a new template */
|
|
141
|
-
_x( 'New', 'action' )
|
|
142
|
-
}
|
|
143
|
-
</Button>
|
|
144
|
-
) }
|
|
145
|
-
</div>
|
|
146
|
-
{ isModalOpen && (
|
|
147
|
-
<Modal
|
|
148
|
-
title={ __( 'Create custom template' ) }
|
|
149
|
-
closeLabel={ __( 'Close' ) }
|
|
150
|
-
onRequestClose={ () => {
|
|
151
|
-
setIsModalOpen( false );
|
|
152
|
-
setTitle( '' );
|
|
153
|
-
} }
|
|
154
|
-
overlayClassName="edit-post-template__modal"
|
|
155
|
-
>
|
|
156
|
-
<form onSubmit={ onCreateTemplate }>
|
|
157
|
-
<Flex align="flex-start" gap={ 8 }>
|
|
158
|
-
<FlexItem>
|
|
159
|
-
<TextControl
|
|
160
|
-
label={ __( 'Name' ) }
|
|
161
|
-
value={ title }
|
|
162
|
-
onChange={ setTitle }
|
|
163
|
-
placeholder={ defaultTitle }
|
|
164
|
-
disabled={ isBusy }
|
|
165
|
-
help={ __(
|
|
166
|
-
'Describe the purpose of the template, e.g. "Full Width". Custom templates can be applied to any post or page.'
|
|
167
|
-
) }
|
|
168
|
-
/>
|
|
169
|
-
</FlexItem>
|
|
170
|
-
</Flex>
|
|
171
|
-
|
|
172
|
-
<Flex
|
|
173
|
-
className="edit-post-template__modal-actions"
|
|
174
|
-
justify="flex-end"
|
|
175
|
-
expanded={ false }
|
|
176
|
-
>
|
|
177
|
-
<FlexItem>
|
|
178
|
-
<Button
|
|
179
|
-
variant="tertiary"
|
|
180
|
-
onClick={ () => {
|
|
181
|
-
setIsModalOpen( false );
|
|
182
|
-
setTitle( '' );
|
|
183
|
-
} }
|
|
184
|
-
>
|
|
185
|
-
{ __( 'Cancel' ) }
|
|
186
|
-
</Button>
|
|
187
|
-
</FlexItem>
|
|
188
|
-
<FlexItem>
|
|
189
|
-
<Button
|
|
190
|
-
variant="primary"
|
|
191
|
-
type="submit"
|
|
192
|
-
isBusy={ isBusy }
|
|
193
|
-
aria-disabled={ isBusy }
|
|
194
|
-
>
|
|
195
|
-
{ __( 'Create' ) }
|
|
196
|
-
</Button>
|
|
197
|
-
</FlexItem>
|
|
198
|
-
</Flex>
|
|
199
|
-
</form>
|
|
200
|
-
</Modal>
|
|
201
|
-
) }
|
|
202
|
-
</>
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export default PostTemplateActions;
|