@wordpress/edit-post 6.9.0 → 6.12.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/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/delete-template.js +1 -1
- package/build/components/header/template-title/delete-template.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/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 +17 -14
- 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 +11 -5
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +7 -2
- package/build/editor.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/delete-template.js +1 -1
- package/build-module/components/header/template-title/delete-template.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 +16 -14
- 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 +12 -6
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +7 -2
- package/build-module/editor.js.map +1 -1
- package/build-style/style-rtl.css +35 -56
- package/build-style/style.css +35 -60
- 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/delete-template.js +1 -1
- 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/options/test/__snapshots__/enable-custom-fields.js.snap +28 -0
- 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 +13 -9
- 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 +26 -21
- package/src/editor.js +6 -2
- 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
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
__experimentalLayoutStyle as LayoutStyle,
|
|
28
28
|
__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,
|
|
29
29
|
__unstableIframe as Iframe,
|
|
30
|
-
|
|
30
|
+
__experimentalRecursionProvider as RecursionProvider,
|
|
31
31
|
} from '@wordpress/block-editor';
|
|
32
32
|
import { useEffect, useRef, useMemo } from '@wordpress/element';
|
|
33
33
|
import { Button, __unstableMotion as motion } from '@wordpress/components';
|
|
@@ -118,13 +118,15 @@ export default function VisualEditor( { styles } ) {
|
|
|
118
118
|
( select ) => select( editPostStore ).hasMetaBoxes(),
|
|
119
119
|
[]
|
|
120
120
|
);
|
|
121
|
-
const { themeSupportsLayout, assets } =
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
const { themeHasDisabledLayoutStyles, themeSupportsLayout, assets } =
|
|
122
|
+
useSelect( ( select ) => {
|
|
123
|
+
const _settings = select( blockEditorStore ).getSettings();
|
|
124
|
+
return {
|
|
125
|
+
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
126
|
+
themeSupportsLayout: _settings.supportsLayout,
|
|
127
|
+
assets: _settings.__unstableResolvedAssets,
|
|
128
|
+
};
|
|
129
|
+
}, [] );
|
|
128
130
|
const { clearSelectedBlock } = useDispatch( blockEditorStore );
|
|
129
131
|
const { setIsEditingTemplate } = useDispatch( editPostStore );
|
|
130
132
|
const desktopCanvasStyles = {
|
|
@@ -173,11 +175,6 @@ export default function VisualEditor( { styles } ) {
|
|
|
173
175
|
|
|
174
176
|
const blockSelectionClearerRef = useBlockSelectionClearer();
|
|
175
177
|
|
|
176
|
-
const [ , RecursionProvider ] = useNoRecursiveRenders(
|
|
177
|
-
wrapperUniqueId,
|
|
178
|
-
wrapperBlockName
|
|
179
|
-
);
|
|
180
|
-
|
|
181
178
|
const layout = useMemo( () => {
|
|
182
179
|
if ( isTemplateMode ) {
|
|
183
180
|
return { type: 'default' };
|
|
@@ -241,12 +238,17 @@ export default function VisualEditor( { styles } ) {
|
|
|
241
238
|
assets={ assets }
|
|
242
239
|
style={ { paddingBottom } }
|
|
243
240
|
>
|
|
244
|
-
{ themeSupportsLayout &&
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
241
|
+
{ themeSupportsLayout &&
|
|
242
|
+
! themeHasDisabledLayoutStyles &&
|
|
243
|
+
! isTemplateMode && (
|
|
244
|
+
<LayoutStyle
|
|
245
|
+
selector=".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container"
|
|
246
|
+
layout={ defaultLayout }
|
|
247
|
+
layoutDefinitions={
|
|
248
|
+
defaultLayout?.definitions
|
|
249
|
+
}
|
|
250
|
+
/>
|
|
251
|
+
) }
|
|
250
252
|
{ ! isTemplateMode && (
|
|
251
253
|
<div
|
|
252
254
|
className="edit-post-visual-editor__post-title-wrapper"
|
|
@@ -255,12 +257,15 @@ export default function VisualEditor( { styles } ) {
|
|
|
255
257
|
<PostTitle ref={ titleRef } />
|
|
256
258
|
</div>
|
|
257
259
|
) }
|
|
258
|
-
<RecursionProvider
|
|
260
|
+
<RecursionProvider
|
|
261
|
+
blockName={ wrapperBlockName }
|
|
262
|
+
uniqueId={ wrapperUniqueId }
|
|
263
|
+
>
|
|
259
264
|
<BlockList
|
|
260
265
|
className={
|
|
261
266
|
isTemplateMode
|
|
262
267
|
? 'wp-site-blocks'
|
|
263
|
-
:
|
|
268
|
+
: 'is-layout-flow' // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
264
269
|
}
|
|
265
270
|
__experimentalLayout={ layout }
|
|
266
271
|
/>
|
package/src/editor.js
CHANGED
|
@@ -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,
|
package/src/style.scss
CHANGED
|
@@ -11,11 +11,12 @@
|
|
|
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
18
|
@import "./components/sidebar/post-template/style.scss";
|
|
19
|
+
@import "./components/sidebar/post-url/style.scss";
|
|
19
20
|
@import "./components/sidebar/post-visibility/style.scss";
|
|
20
21
|
@import "./components/sidebar/settings-header/style.scss";
|
|
21
22
|
@import "./components/sidebar/template-summary/style.scss";
|
|
@@ -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,SAASC,QAAT,OAUI;AAAA,MAVe;AAClBC,IAAAA,QADkB;AAElBC,IAAAA,aAFkB;AAGlBC,IAAAA,UAHkB;AAIlBC,IAAAA,QAJkB;AAKlBC,IAAAA,eALkB;AAMlBC,IA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AAR,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,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,eALkB;AAMlBC,IAAAA,eANkB;AAOlBC,IAAAA,aAPkB;AAQlBC,IAAAA,QARkB;AASlBC,IAAAA;AATkB,GAUf;AACH,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0Cd,QAAQ,CAAE,KAAF,CAAxD;AAEA,MAAIe,aAAJ,EAAmBC,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/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"]}
|