@wordpress/edit-post 6.9.0 → 6.10.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/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/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/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 +3 -1
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-template/create-modal.js +1 -1
- package/build/components/sidebar/post-template/create-modal.js.map +1 -1
- package/build/components/sidebar/post-template/form.js +1 -1
- package/build/components/sidebar/post-template/form.js.map +1 -1
- package/build/components/sidebar/post-template/index.js +4 -3
- package/build/components/sidebar/post-template/index.js.map +1 -1
- 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 -4
- package/build/components/sidebar/settings-sidebar/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-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/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/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 +31 -15
- 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 +2 -1
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js.map +1 -1
- package/build-module/components/sidebar/post-template/form.js +1 -1
- package/build-module/components/sidebar/post-template/form.js.map +1 -1
- package/build-module/components/sidebar/post-template/index.js +4 -3
- package/build-module/components/sidebar/post-template/index.js.map +1 -1
- 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 -3
- package/build-module/components/sidebar/settings-sidebar/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-style/style-rtl.css +34 -47
- package/build-style/style.css +34 -51
- package/package.json +27 -27
- package/src/components/header/template-title/edit-template-title.js +11 -1
- 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/preferences-modal/index.js +5 -23
- package/src/components/preferences-modal/test/index.js +3 -3
- 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 +26 -17
- package/src/components/sidebar/post-schedule/style.scss +0 -2
- 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 +3 -1
- package/src/components/sidebar/post-template/create-modal.js +1 -1
- package/src/components/sidebar/post-template/form.js +4 -1
- package/src/components/sidebar/post-template/index.js +4 -3
- package/src/components/sidebar/post-template/style.scss +0 -10
- 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/settings-sidebar/index.js +1 -3
- package/src/components/sidebar/template/style.scss +35 -0
- package/src/components/start-page-options/style.scss +0 -9
- package/src/components/visual-editor/index.js +2 -1
- package/src/style.scss +2 -1
- package/build/components/sidebar/post-link/index.js +0 -182
- package/build/components/sidebar/post-link/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/src/components/sidebar/post-link/index.js +0 -179
- package/src/components/sidebar/post-link/style.scss +0 -20
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { get } from 'lodash';
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import { PanelBody, TextControl, ExternalLink } from '@wordpress/components';
|
|
13
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
14
|
-
import { compose, ifCondition } from '@wordpress/compose';
|
|
15
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
16
|
-
import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
|
|
17
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
18
|
-
import { useState } from '@wordpress/element';
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { store as editPostStore } from '../../../store';
|
|
24
|
-
/**
|
|
25
|
-
* Module Constants
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
const PANEL_NAME = 'post-link';
|
|
29
|
-
|
|
30
|
-
function PostLink(_ref) {
|
|
31
|
-
let {
|
|
32
|
-
isOpened,
|
|
33
|
-
onTogglePanel,
|
|
34
|
-
isEditable,
|
|
35
|
-
postLink,
|
|
36
|
-
permalinkPrefix,
|
|
37
|
-
permalinkSuffix,
|
|
38
|
-
editPermalink,
|
|
39
|
-
postSlug,
|
|
40
|
-
postTypeLabel
|
|
41
|
-
} = _ref;
|
|
42
|
-
const [forceEmptyField, setForceEmptyField] = useState(false);
|
|
43
|
-
let prefixElement, postNameElement, suffixElement;
|
|
44
|
-
|
|
45
|
-
if (isEditable) {
|
|
46
|
-
prefixElement = permalinkPrefix && createElement("span", {
|
|
47
|
-
className: "edit-post-post-link__link-prefix"
|
|
48
|
-
}, permalinkPrefix);
|
|
49
|
-
postNameElement = postSlug && createElement("span", {
|
|
50
|
-
className: "edit-post-post-link__link-post-name"
|
|
51
|
-
}, postSlug);
|
|
52
|
-
suffixElement = permalinkSuffix && createElement("span", {
|
|
53
|
-
className: "edit-post-post-link__link-suffix"
|
|
54
|
-
}, permalinkSuffix);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return createElement(PanelBody, {
|
|
58
|
-
title: __('Permalink'),
|
|
59
|
-
opened: isOpened,
|
|
60
|
-
onToggle: onTogglePanel
|
|
61
|
-
}, isEditable && createElement("div", {
|
|
62
|
-
className: "editor-post-link"
|
|
63
|
-
}, createElement(TextControl, {
|
|
64
|
-
label: __('URL Slug'),
|
|
65
|
-
value: forceEmptyField ? '' : postSlug,
|
|
66
|
-
autoComplete: "off",
|
|
67
|
-
spellCheck: "false",
|
|
68
|
-
onChange: newValue => {
|
|
69
|
-
editPermalink(newValue); // When we delete the field the permalink gets
|
|
70
|
-
// reverted to the original value.
|
|
71
|
-
// The forceEmptyField logic allows the user to have
|
|
72
|
-
// the field temporarily empty while typing.
|
|
73
|
-
|
|
74
|
-
if (!newValue) {
|
|
75
|
-
if (!forceEmptyField) {
|
|
76
|
-
setForceEmptyField(true);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (forceEmptyField) {
|
|
83
|
-
setForceEmptyField(false);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
onBlur: event => {
|
|
87
|
-
editPermalink(cleanForSlug(event.target.value));
|
|
88
|
-
|
|
89
|
-
if (forceEmptyField) {
|
|
90
|
-
setForceEmptyField(false);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}), createElement("p", null, __('The last part of the URL.'), ' ', createElement(ExternalLink, {
|
|
94
|
-
href: __('https://wordpress.org/support/article/settings-sidebar/#permalink')
|
|
95
|
-
}, __('Read about permalinks')))), createElement("h3", {
|
|
96
|
-
className: "edit-post-post-link__preview-label"
|
|
97
|
-
}, postTypeLabel || __('View post')), createElement("div", {
|
|
98
|
-
className: "edit-post-post-link__preview-link-container"
|
|
99
|
-
}, createElement(ExternalLink, {
|
|
100
|
-
className: "edit-post-post-link__link",
|
|
101
|
-
href: postLink,
|
|
102
|
-
target: "_blank"
|
|
103
|
-
}, isEditable ? createElement(Fragment, null, prefixElement, postNameElement, suffixElement) : postLink)));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export default compose([withSelect(select => {
|
|
107
|
-
const {
|
|
108
|
-
isPermalinkEditable,
|
|
109
|
-
getCurrentPost,
|
|
110
|
-
isCurrentPostPublished,
|
|
111
|
-
getPermalinkParts,
|
|
112
|
-
getEditedPostAttribute,
|
|
113
|
-
getEditedPostSlug
|
|
114
|
-
} = select(editorStore);
|
|
115
|
-
const {
|
|
116
|
-
isEditorPanelEnabled,
|
|
117
|
-
isEditorPanelOpened
|
|
118
|
-
} = select(editPostStore);
|
|
119
|
-
const {
|
|
120
|
-
getPostType
|
|
121
|
-
} = select(coreStore);
|
|
122
|
-
const {
|
|
123
|
-
link
|
|
124
|
-
} = getCurrentPost();
|
|
125
|
-
const postTypeName = getEditedPostAttribute('type');
|
|
126
|
-
const postType = getPostType(postTypeName);
|
|
127
|
-
const permalinkParts = getPermalinkParts();
|
|
128
|
-
return {
|
|
129
|
-
postLink: link,
|
|
130
|
-
isEditable: isPermalinkEditable(),
|
|
131
|
-
isPublished: isCurrentPostPublished(),
|
|
132
|
-
isOpened: isEditorPanelOpened(PANEL_NAME),
|
|
133
|
-
isEnabled: isEditorPanelEnabled(PANEL_NAME),
|
|
134
|
-
isViewable: get(postType, ['viewable'], false),
|
|
135
|
-
postSlug: safeDecodeURIComponent(getEditedPostSlug()),
|
|
136
|
-
postTypeLabel: get(postType, ['labels', 'view_item']),
|
|
137
|
-
hasPermalinkParts: !!permalinkParts,
|
|
138
|
-
permalinkPrefix: permalinkParts === null || permalinkParts === void 0 ? void 0 : permalinkParts.prefix,
|
|
139
|
-
permalinkSuffix: permalinkParts === null || permalinkParts === void 0 ? void 0 : permalinkParts.suffix
|
|
140
|
-
};
|
|
141
|
-
}), ifCondition(_ref2 => {
|
|
142
|
-
let {
|
|
143
|
-
isEnabled,
|
|
144
|
-
postLink,
|
|
145
|
-
isViewable,
|
|
146
|
-
hasPermalinkParts
|
|
147
|
-
} = _ref2;
|
|
148
|
-
return isEnabled && postLink && isViewable && hasPermalinkParts;
|
|
149
|
-
}), withDispatch(dispatch => {
|
|
150
|
-
const {
|
|
151
|
-
toggleEditorPanelOpened
|
|
152
|
-
} = dispatch(editPostStore);
|
|
153
|
-
const {
|
|
154
|
-
editPost
|
|
155
|
-
} = dispatch(editorStore);
|
|
156
|
-
return {
|
|
157
|
-
onTogglePanel: () => toggleEditorPanelOpened(PANEL_NAME),
|
|
158
|
-
editPermalink: newSlug => {
|
|
159
|
-
editPost({
|
|
160
|
-
slug: newSlug
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
})])(PostLink);
|
|
165
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-link/index.js"],"names":["get","__","PanelBody","TextControl","ExternalLink","withSelect","withDispatch","compose","ifCondition","store","editorStore","safeDecodeURIComponent","cleanForSlug","coreStore","useState","editPostStore","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","isEditorPanelEnabled","isEditorPanelOpened","getPostType","link","postTypeName","postType","permalinkParts","isPublished","isEnabled","isViewable","hasPermalinkParts","prefix","suffix","dispatch","toggleEditorPanelOpened","editPost","newSlug","slug"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,sBAAT,EAAiCC,YAAjC,QAAqD,gBAArD;AACA,SAASH,KAAK,IAAII,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASL,KAAK,IAAIM,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG,WAAnB;;AAEA,SAASC,QAAT,OAUI;AAAA,MAVe;AAClBC,IAAAA,QADkB;AAElBC,IAAAA,aAFkB;AAGlBC,IAAAA,UAHkB;AAIlBC,IAAAA,QAJkB;AAKlBC,IAAAA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AMsC,uBAAuB,CAAEzC,UAAF,CADtC;AAENQ,IAAAA,aAAa,EAAImC,OAAF,IAAe;AAC7BD,MAAAA,QAAQ,CAAE;AAAEE,QAAAA,IAAI,EAAED;AAAR,OAAF,CAAR;AACA;AAJK,GAAP;AAMA,CATW,CArCW,CAAF,CAAP,CA+CV1C,QA/CU,CAAf","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,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 */
|