@wordpress/editor 13.2.0 → 13.3.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/error-boundary/index.js +24 -30
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/media-categories/index.js +237 -0
- package/build/components/media-categories/index.js.map +1 -0
- package/build/components/page-attributes/parent.js +1 -1
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-publish-panel/postpublish.js +1 -0
- package/build/components/post-publish-panel/postpublish.js.map +1 -1
- package/build/components/post-slug/index.js +1 -0
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +7 -3
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-template/index.js +7 -4
- package/build/components/post-template/index.js.map +1 -1
- package/build/components/post-url/index.js +1 -0
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/provider/index.js +26 -8
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +21 -14
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +7 -4
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.native.js +1 -2
- package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build/components/table-of-contents/index.js +3 -1
- package/build/components/table-of-contents/index.js.map +1 -1
- package/build/components/unsaved-changes-warning/index.js +1 -1
- package/build/components/unsaved-changes-warning/index.js.map +1 -1
- package/build/experiments.js +20 -0
- package/build/experiments.js.map +1 -0
- package/build/hooks/default-autocompleters.js +2 -7
- package/build/hooks/default-autocompleters.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/index.native.js +14 -0
- package/build/index.native.js.map +1 -1
- package/build/lockUnlock.js +19 -0
- package/build/lockUnlock.js.map +1 -0
- package/build/store/defaults.js +1 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/terms.js +9 -5
- package/build/utils/terms.js.map +1 -1
- package/build-module/components/error-boundary/index.js +24 -30
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +225 -0
- package/build-module/components/media-categories/index.js.map +1 -0
- package/build-module/components/page-attributes/parent.js +2 -2
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/post-publish-panel/postpublish.js +1 -0
- package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
- package/build-module/components/post-slug/index.js +1 -0
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +8 -5
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-template/index.js +8 -5
- package/build-module/components/post-template/index.js.map +1 -1
- package/build-module/components/post-url/index.js +1 -0
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/provider/index.js +21 -9
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +20 -12
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +5 -5
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.native.js +1 -2
- package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build-module/components/table-of-contents/index.js +3 -1
- package/build-module/components/table-of-contents/index.js.map +1 -1
- package/build-module/components/unsaved-changes-warning/index.js +1 -1
- package/build-module/components/unsaved-changes-warning/index.js.map +1 -1
- package/build-module/experiments.js +10 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/hooks/default-autocompleters.js +2 -6
- package/build-module/hooks/default-autocompleters.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +1 -0
- package/build-module/index.native.js.map +1 -1
- package/build-module/lockUnlock.js +9 -0
- package/build-module/lockUnlock.js.map +1 -0
- package/build-module/store/defaults.js +1 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/terms.js +9 -6
- package/build-module/utils/terms.js.map +1 -1
- package/build-style/style-rtl.css +0 -3
- package/build-style/style.css +0 -3
- package/package.json +30 -29
- package/src/components/autosave-monitor/test/index.js +8 -2
- package/src/components/editor-help/test/index.native.js +5 -5
- package/src/components/error-boundary/index.js +24 -37
- package/src/components/media-categories/index.js +247 -0
- package/src/components/page-attributes/parent.js +2 -2
- package/src/components/page-attributes/test/order.js +4 -14
- package/src/components/post-preview-button/test/index.js +5 -17
- package/src/components/post-publish-button/test/index.js +5 -17
- package/src/components/post-publish-panel/postpublish.js +1 -0
- package/src/components/post-publish-panel/style.scss +1 -5
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -18
- package/src/components/post-saved-state/test/index.js +1 -5
- package/src/components/post-slug/index.js +1 -0
- package/src/components/post-taxonomies/hierarchical-term-selector.js +23 -17
- package/src/components/post-template/index.js +3 -4
- package/src/components/post-url/index.js +1 -0
- package/src/components/provider/index.js +120 -91
- package/src/components/provider/index.native.js +26 -17
- package/src/components/provider/use-block-editor-settings.js +60 -49
- package/src/components/provider/use-block-editor-settings.native.js +1 -2
- package/src/components/table-of-contents/index.js +3 -1
- package/src/components/unsaved-changes-warning/index.js +1 -1
- package/src/experiments.js +10 -0
- package/src/hooks/default-autocompleters.js +1 -6
- package/src/index.js +1 -0
- package/src/index.native.js +1 -0
- package/src/lockUnlock.js +9 -0
- package/src/store/defaults.js +0 -1
- package/src/store/selectors.js +1 -1
- package/src/utils/terms.js +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -28,6 +28,18 @@ var _store = require("../../store");
|
|
|
28
28
|
/**
|
|
29
29
|
* Internal dependencies
|
|
30
30
|
*/
|
|
31
|
+
function getContent() {
|
|
32
|
+
try {
|
|
33
|
+
// While `select` in a component is generally discouraged, it is
|
|
34
|
+
// used here because it (a) reduces the chance of data loss in the
|
|
35
|
+
// case of additional errors by performing a direct retrieval and
|
|
36
|
+
// (b) avoids the performance cost associated with unnecessary
|
|
37
|
+
// content serialization throughout the lifetime of a non-erroring
|
|
38
|
+
// application.
|
|
39
|
+
return (0, _data.select)(_store.store).getEditedPostContent();
|
|
40
|
+
} catch (error) {}
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
function CopyButton(_ref) {
|
|
32
44
|
let {
|
|
33
45
|
text,
|
|
@@ -43,34 +55,19 @@ function CopyButton(_ref) {
|
|
|
43
55
|
class ErrorBoundary extends _element.Component {
|
|
44
56
|
constructor() {
|
|
45
57
|
super(...arguments);
|
|
46
|
-
this.reboot = this.reboot.bind(this);
|
|
47
|
-
this.getContent = this.getContent.bind(this);
|
|
48
58
|
this.state = {
|
|
49
59
|
error: null
|
|
50
60
|
};
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
componentDidCatch(error) {
|
|
54
|
-
this.setState({
|
|
55
|
-
error
|
|
56
|
-
});
|
|
57
64
|
(0, _hooks.doAction)('editor.ErrorBoundary.errorLogged', error);
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
getContent() {
|
|
65
|
-
try {
|
|
66
|
-
// While `select` in a component is generally discouraged, it is
|
|
67
|
-
// used here because it (a) reduces the chance of data loss in the
|
|
68
|
-
// case of additional errors by performing a direct retrieval and
|
|
69
|
-
// (b) avoids the performance cost associated with unnecessary
|
|
70
|
-
// content serialization throughout the lifetime of a non-erroring
|
|
71
|
-
// application.
|
|
72
|
-
return (0, _data.select)(_store.store).getEditedPostContent();
|
|
73
|
-
} catch (error) {}
|
|
67
|
+
static getDerivedStateFromError(error) {
|
|
68
|
+
return {
|
|
69
|
+
error
|
|
70
|
+
};
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
render() {
|
|
@@ -82,19 +79,16 @@ class ErrorBoundary extends _element.Component {
|
|
|
82
79
|
return this.props.children;
|
|
83
80
|
}
|
|
84
81
|
|
|
82
|
+
const actions = [(0, _element.createElement)(CopyButton, {
|
|
83
|
+
key: "copy-post",
|
|
84
|
+
text: getContent
|
|
85
|
+
}, (0, _i18n.__)('Copy Post Text')), (0, _element.createElement)(CopyButton, {
|
|
86
|
+
key: "copy-error",
|
|
87
|
+
text: error.stack
|
|
88
|
+
}, (0, _i18n.__)('Copy Error'))];
|
|
85
89
|
return (0, _element.createElement)(_blockEditor.Warning, {
|
|
86
90
|
className: "editor-error-boundary",
|
|
87
|
-
actions:
|
|
88
|
-
key: "recovery",
|
|
89
|
-
onClick: this.reboot,
|
|
90
|
-
variant: "secondary"
|
|
91
|
-
}, (0, _i18n.__)('Attempt Recovery')), (0, _element.createElement)(CopyButton, {
|
|
92
|
-
key: "copy-post",
|
|
93
|
-
text: this.getContent
|
|
94
|
-
}, (0, _i18n.__)('Copy Post Text')), (0, _element.createElement)(CopyButton, {
|
|
95
|
-
key: "copy-error",
|
|
96
|
-
text: error.stack
|
|
97
|
-
}, (0, _i18n.__)('Copy Error'))]
|
|
91
|
+
actions: actions
|
|
98
92
|
}, (0, _i18n.__)('The editor has encountered an unexpected error.'));
|
|
99
93
|
}
|
|
100
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["getContent","editorStore","getEditedPostContent","error","CopyButton","text","children","ref","ErrorBoundary","Component","constructor","arguments","state","componentDidCatch","getDerivedStateFromError","render","props","actions","stack"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AAGA,SAASA,UAAT,GAAsB;AACrB,MAAI;AACH;AACA;AACA;AACA;AACA;AACA;AACA,WAAO,kBAAQC,YAAR,EAAsBC,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dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { select } from '@wordpress/data';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction getContent() {\n\ttry {\n\t\t// While `select` in a component is generally discouraged, it is\n\t\t// used here because it (a) reduces the chance of data loss in the\n\t\t// case of additional errors by performing a direct retrieval and\n\t\t// (b) avoids the performance cost associated with unnecessary\n\t\t// content serialization throughout the lifetime of a non-erroring\n\t\t// application.\n\t\treturn select( editorStore ).getEditedPostContent();\n\t} catch ( error ) {}\n}\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nclass ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst actions = [\n\t\t\t<CopyButton key=\"copy-post\" text={ getContent }>\n\t\t\t\t{ __( 'Copy Post Text' ) }\n\t\t\t</CopyButton>,\n\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t</CopyButton>,\n\t\t];\n\n\t\treturn (\n\t\t\t<Warning className=\"editor-error-boundary\" actions={ actions }>\n\t\t\t\t{ __( 'The editor has encountered an unexpected error.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n}\n\nexport default ErrorBoundary;\n"]}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
|
|
12
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
13
|
+
|
|
14
|
+
var _coreData = require("@wordpress/core-data");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The `editor` settings here need to be in sync with the corresponding ones in `editor` package.
|
|
18
|
+
* See `packages/editor/src/components/media-categories/index.js`.
|
|
19
|
+
*
|
|
20
|
+
* In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
|
|
21
|
+
* The rest of the settings would still need to be in sync though.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* WordPress dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
|
|
33
|
+
|
|
34
|
+
/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Interface for inserter media category labels.
|
|
38
|
+
*
|
|
39
|
+
* @typedef {Object} InserterMediaCategoryLabels
|
|
40
|
+
* @property {string} name General name of the media category. It's used in the inserter media items list.
|
|
41
|
+
* @property {string} [search_items='Search'] Label for searching items. Default is ‘Search Posts’ / ‘Search Pages’.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Interface for inserter media category.
|
|
46
|
+
*
|
|
47
|
+
* @typedef {Object} InserterMediaCategory
|
|
48
|
+
* @property {string} name The name of the media category, that should be unique among all media categories.
|
|
49
|
+
* @property {InserterMediaCategoryLabels} labels Labels for the media category.
|
|
50
|
+
* @property {('image'|'audio'|'video')} mediaType The media type of the media category.
|
|
51
|
+
* @property {(InserterMediaRequest) => Promise<InserterMediaItem[]>} fetch The function to fetch media items for the category.
|
|
52
|
+
* @property {(InserterMediaItem) => string} [getReportUrl] If the media category supports reporting media items, this function should return
|
|
53
|
+
* the report url for the media item. It accepts the `InserterMediaItem` as an argument.
|
|
54
|
+
* @property {boolean} [isExternalResource] If the media category is an external resource, this should be set to true.
|
|
55
|
+
* This is used to avoid making a request to the external resource when the user
|
|
56
|
+
* opens the inserter for the first time.
|
|
57
|
+
*/
|
|
58
|
+
const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
|
|
59
|
+
|
|
60
|
+
const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
|
|
61
|
+
|
|
62
|
+
const getOpenverseLicense = (license, licenseVersion) => {
|
|
63
|
+
let licenseName = license.trim(); // PDM has no abbreviation
|
|
64
|
+
|
|
65
|
+
if (license !== 'pdm') {
|
|
66
|
+
licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
|
|
67
|
+
} // If version is known, append version to the name.
|
|
68
|
+
// The license has to have a version to be valid. Only
|
|
69
|
+
// PDM (public domain mark) doesn't have a version.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if (licenseVersion) {
|
|
73
|
+
licenseName += ` ${licenseVersion}`;
|
|
74
|
+
} // For licenses other than public-domain marks, prepend 'CC' to the name.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if (!['pdm', 'cc0'].includes(license)) {
|
|
78
|
+
licenseName = `CC ${licenseName}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return licenseName;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const getOpenverseCaption = item => {
|
|
85
|
+
const {
|
|
86
|
+
title,
|
|
87
|
+
foreign_landing_url: foreignLandingUrl,
|
|
88
|
+
creator,
|
|
89
|
+
creator_url: creatorUrl,
|
|
90
|
+
license,
|
|
91
|
+
license_version: licenseVersion,
|
|
92
|
+
license_url: licenseUrl
|
|
93
|
+
} = item;
|
|
94
|
+
const fullLicense = getOpenverseLicense(license, licenseVersion);
|
|
95
|
+
|
|
96
|
+
const _creator = (0, _htmlEntities.decodeEntities)(creator);
|
|
97
|
+
|
|
98
|
+
let _caption;
|
|
99
|
+
|
|
100
|
+
if (_creator) {
|
|
101
|
+
_caption = title ? (0, _i18n.sprintf)( // translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: "CC0 1.0".
|
|
102
|
+
(0, _i18n._x)('"%1$s" by %2$s/ %3$s', 'caption'), getExternalLink(foreignLandingUrl, (0, _htmlEntities.decodeEntities)(title)), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0, _i18n.sprintf)( // translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: "CC0 1.0".
|
|
103
|
+
(0, _i18n._x)('<a %1$s>Work</a> by %2$s/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), creatorUrl ? getExternalLink(creatorUrl, _creator) : _creator, licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
|
|
104
|
+
} else {
|
|
105
|
+
_caption = title ? (0, _i18n.sprintf)( // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
|
|
106
|
+
(0, _i18n._x)('"%1$s"/ %2$s', 'caption'), getExternalLink(foreignLandingUrl, (0, _htmlEntities.decodeEntities)(title)), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense) : (0, _i18n.sprintf)( // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
|
|
107
|
+
(0, _i18n._x)('<a %1$s>Work</a>/ %3$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return _caption.replace(/\s{2}/g, ' ');
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const coreMediaFetch = async function () {
|
|
114
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
115
|
+
const mediaItems = await (0, _data.resolveSelect)(_coreData.store).getMediaItems({ ...query,
|
|
116
|
+
orderBy: !!(query !== null && query !== void 0 && query.search) ? 'relevance' : 'date'
|
|
117
|
+
});
|
|
118
|
+
return mediaItems.map(mediaItem => {
|
|
119
|
+
var _mediaItem$media_deta, _mediaItem$media_deta2, _mediaItem$media_deta3, _mediaItem$caption;
|
|
120
|
+
|
|
121
|
+
return { ...mediaItem,
|
|
122
|
+
alt: mediaItem.alt_text,
|
|
123
|
+
url: mediaItem.source_url,
|
|
124
|
+
previewUrl: (_mediaItem$media_deta = mediaItem.media_details) === null || _mediaItem$media_deta === void 0 ? void 0 : (_mediaItem$media_deta2 = _mediaItem$media_deta.sizes) === null || _mediaItem$media_deta2 === void 0 ? void 0 : (_mediaItem$media_deta3 = _mediaItem$media_deta2.medium) === null || _mediaItem$media_deta3 === void 0 ? void 0 : _mediaItem$media_deta3.source_url,
|
|
125
|
+
caption: (_mediaItem$caption = mediaItem.caption) === null || _mediaItem$caption === void 0 ? void 0 : _mediaItem$caption.raw
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/** @type {InserterMediaCategory[]} */
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
const inserterMediaCategories = [{
|
|
133
|
+
name: 'images',
|
|
134
|
+
labels: {
|
|
135
|
+
name: (0, _i18n.__)('Images'),
|
|
136
|
+
search_items: (0, _i18n.__)('Search images')
|
|
137
|
+
},
|
|
138
|
+
mediaType: 'image',
|
|
139
|
+
|
|
140
|
+
async fetch() {
|
|
141
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
142
|
+
return coreMediaFetch({ ...query,
|
|
143
|
+
media_type: 'image'
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}, {
|
|
148
|
+
name: 'videos',
|
|
149
|
+
labels: {
|
|
150
|
+
name: (0, _i18n.__)('Videos'),
|
|
151
|
+
search_items: (0, _i18n.__)('Search videos')
|
|
152
|
+
},
|
|
153
|
+
mediaType: 'video',
|
|
154
|
+
|
|
155
|
+
async fetch() {
|
|
156
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
157
|
+
return coreMediaFetch({ ...query,
|
|
158
|
+
media_type: 'video'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}, {
|
|
163
|
+
name: 'audio',
|
|
164
|
+
labels: {
|
|
165
|
+
name: (0, _i18n.__)('Audio'),
|
|
166
|
+
search_items: (0, _i18n.__)('Search audio')
|
|
167
|
+
},
|
|
168
|
+
mediaType: 'audio',
|
|
169
|
+
|
|
170
|
+
async fetch() {
|
|
171
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
172
|
+
return coreMediaFetch({ ...query,
|
|
173
|
+
media_type: 'audio'
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
}, {
|
|
178
|
+
name: 'openverse',
|
|
179
|
+
labels: {
|
|
180
|
+
name: (0, _i18n.__)('Openverse'),
|
|
181
|
+
search_items: (0, _i18n.__)('Search Openverse')
|
|
182
|
+
},
|
|
183
|
+
mediaType: 'image',
|
|
184
|
+
|
|
185
|
+
async fetch() {
|
|
186
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
187
|
+
const defaultArgs = {
|
|
188
|
+
mature: false,
|
|
189
|
+
excluded_source: 'flickr,inaturalist,wikimedia',
|
|
190
|
+
license: 'pdm,cc0'
|
|
191
|
+
};
|
|
192
|
+
const finalQuery = { ...query,
|
|
193
|
+
...defaultArgs
|
|
194
|
+
};
|
|
195
|
+
const mapFromInserterMediaRequest = {
|
|
196
|
+
per_page: 'page_size',
|
|
197
|
+
search: 'q'
|
|
198
|
+
};
|
|
199
|
+
const url = new URL('https://api.openverse.engineering/v1/images/');
|
|
200
|
+
Object.entries(finalQuery).forEach(_ref => {
|
|
201
|
+
let [key, value] = _ref;
|
|
202
|
+
const queryKey = mapFromInserterMediaRequest[key] || key;
|
|
203
|
+
url.searchParams.set(queryKey, value);
|
|
204
|
+
});
|
|
205
|
+
const response = await window.fetch(url, {
|
|
206
|
+
headers: {
|
|
207
|
+
'User-Agent': 'WordPress/inserter-media-fetch'
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
const jsonResponse = await response.json();
|
|
211
|
+
const results = jsonResponse.results;
|
|
212
|
+
return results.map(result => {
|
|
213
|
+
var _result$title;
|
|
214
|
+
|
|
215
|
+
return { ...result,
|
|
216
|
+
// This is a temp solution for better titles, until Openverse API
|
|
217
|
+
// completes the cleaning up of some titles of their upstream data.
|
|
218
|
+
title: (_result$title = result.title) !== null && _result$title !== void 0 && _result$title.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
|
|
219
|
+
sourceId: result.id,
|
|
220
|
+
id: undefined,
|
|
221
|
+
caption: getOpenverseCaption(result),
|
|
222
|
+
previewUrl: result.thumbnail
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
getReportUrl: _ref2 => {
|
|
228
|
+
let {
|
|
229
|
+
sourceId
|
|
230
|
+
} = _ref2;
|
|
231
|
+
return `https://wordpress.org/openverse/image/${sourceId}/report/`;
|
|
232
|
+
},
|
|
233
|
+
isExternalResource: true
|
|
234
|
+
}];
|
|
235
|
+
var _default = inserterMediaCategories;
|
|
236
|
+
exports.default = _default;
|
|
237
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/media-categories/index.js"],"names":["getExternalLink","url","text","getExternalLinkAttributes","getOpenverseLicense","license","licenseVersion","licenseName","trim","toUpperCase","replace","includes","getOpenverseCaption","item","title","foreign_landing_url","foreignLandingUrl","creator","creator_url","creatorUrl","license_version","license_url","licenseUrl","fullLicense","_creator","_caption","coreMediaFetch","query","mediaItems","coreStore","getMediaItems","orderBy","search","map","mediaItem","alt","alt_text","source_url","previewUrl","media_details","sizes","medium","caption","raw","inserterMediaCategories","name","labels","search_items","mediaType","fetch","media_type","defaultArgs","mature","excluded_source","finalQuery","mapFromInserterMediaRequest","per_page","URL","Object","entries","forEach","key","value","queryKey","searchParams","set","response","window","headers","jsonResponse","json","results","result","toLowerCase","startsWith","slice","sourceId","id","undefined","thumbnail","getReportUrl","isExternalResource"],"mappings":";;;;;;;AAWA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMA,eAAe,GAAG,CAAEC,GAAF,EAAOC,IAAP,KACtB,MAAMC,yBAAyB,CAAEF,GAAF,CAAS,IAAIC,IAAM,MADpD;;AAGA,MAAMC,yBAAyB,GAAKF,GAAF,IAChC,SAASA,GAAK,6CADhB;;AAGA,MAAMG,mBAAmB,GAAG,CAAEC,OAAF,EAAWC,cAAX,KAA+B;AAC1D,MAAIC,WAAW,GAAGF,OAAO,CAACG,IAAR,EAAlB,CAD0D,CAE1D;;AACA,MAAKH,OAAO,KAAK,KAAjB,EAAyB;AACxBE,IAAAA,WAAW,GAAGF,OAAO,CAACI,WAAR,GAAsBC,OAAtB,CAA+B,UAA/B,EAA2C,UAA3C,CAAd;AACA,GALyD,CAM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1D,KAAP,wDAAc2D,WAAd,GAA4BC,UAA5B,CAAwC,OAAxC,IACJF,MAAM,CAAC1D,KAAP,CAAa6D,KAAb,CAAoB,CAApB,CADI,GAEJH,MAAM,CAAC1D,KANyB;AAOnC8D,QAAAA,QAAQ,EAAEJ,MAAM,CAACK,EAPkB;AAQnCA,QAAAA,EAAE,EAAEC,SAR+B;AASnCpC,QAAAA,OAAO,EAAE9B,mBAAmB,CAAE4D,MAAF,CATO;AAUnClC,QAAAA,UAAU,EAAEkC,MAAM,CAACO;AAVgB,OAAhB;AAAA,KAAb,CAAP;AAYA,GA5CF;;AA6CCC,EAAAA,YAAY,EAAE;AAAA,QAAE;AAAEJ,MAAAA;AAAF,KAAF;AAAA,WACZ,yCAAyCA,QAAU,UADvC;AAAA,GA7Cf;AA+CCK,EAAAA,kBAAkB,EAAE;AA/CrB,CAlC+B,CAAhC;eAqFerC,uB","sourcesContent":["/**\n * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.\n * See `packages/editor/src/components/media-categories/index.js`.\n *\n * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.\n * The rest of the settings would still need to be in sync though.\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _x } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\n\n/** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */\n/** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */\n/**\n * Interface for inserter media category labels.\n *\n * @typedef {Object} InserterMediaCategoryLabels\n * @property {string} name General name of the media category. It's used in the inserter media items list.\n * @property {string} [search_items='Search'] Label for searching items. Default is ‘Search Posts’ / ‘Search Pages’.\n */\n/**\n * Interface for inserter media category.\n *\n * @typedef {Object} InserterMediaCategory\n * @property {string} name The name of the media category, that should be unique among all media categories.\n * @property {InserterMediaCategoryLabels} labels Labels for the media category.\n * @property {('image'|'audio'|'video')} mediaType The media type of the media category.\n * @property {(InserterMediaRequest) => Promise<InserterMediaItem[]>} fetch The function to fetch media items for the category.\n * @property {(InserterMediaItem) => string} [getReportUrl] If the media category supports reporting media items, this function should return\n * the report url for the media item. It accepts the `InserterMediaItem` as an argument.\n * @property {boolean} [isExternalResource] If the media category is an external resource, this should be set to true.\n * This is used to avoid making a request to the external resource when the user\n * opens the inserter for the first time.\n */\n\nconst getExternalLink = ( url, text ) =>\n\t`<a ${ getExternalLinkAttributes( url ) }>${ text }</a>`;\n\nconst getExternalLinkAttributes = ( url ) =>\n\t`href=\"${ url }\" target=\"_blank\" rel=\"noreferrer noopener\"`;\n\nconst getOpenverseLicense = ( license, licenseVersion ) => {\n\tlet licenseName = license.trim();\n\t// PDM has no abbreviation\n\tif ( license !== 'pdm' ) {\n\t\tlicenseName = license.toUpperCase().replace( 'SAMPLING', 'Sampling' );\n\t}\n\t// If version is known, append version to the name.\n\t// The license has to have a version to be valid. Only\n\t// PDM (public domain mark) doesn't have a version.\n\tif ( licenseVersion ) {\n\t\tlicenseName += ` ${ licenseVersion }`;\n\t}\n\t// For licenses other than public-domain marks, prepend 'CC' to the name.\n\tif ( ! [ 'pdm', 'cc0' ].includes( license ) ) {\n\t\tlicenseName = `CC ${ licenseName }`;\n\t}\n\treturn licenseName;\n};\n\nconst getOpenverseCaption = ( item ) => {\n\tconst {\n\t\ttitle,\n\t\tforeign_landing_url: foreignLandingUrl,\n\t\tcreator,\n\t\tcreator_url: creatorUrl,\n\t\tlicense,\n\t\tlicense_version: licenseVersion,\n\t\tlicense_url: licenseUrl,\n\t} = item;\n\tconst fullLicense = getOpenverseLicense( license, licenseVersion );\n\tconst _creator = decodeEntities( creator );\n\tlet _caption;\n\tif ( _creator ) {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Name of the work's creator; %3s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\" by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Name of the work's creator; %3s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a> by %2$s/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tcreatorUrl\n\t\t\t\t\t\t? getExternalLink( creatorUrl, _creator )\n\t\t\t\t\t\t: _creator,\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t} else {\n\t\t_caption = title\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '\"%1$s\"/ %2$s', 'caption' ),\n\t\t\t\t\tgetExternalLink(\n\t\t\t\t\t\tforeignLandingUrl,\n\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: \"CC0 1.0\".\n\t\t\t\t\t_x( '<a %1$s>Work</a>/ %3$s', 'caption' ),\n\t\t\t\t\tgetExternalLinkAttributes( foreignLandingUrl ),\n\t\t\t\t\tlicenseUrl\n\t\t\t\t\t\t? getExternalLink(\n\t\t\t\t\t\t\t\t`${ licenseUrl }?ref=openverse`,\n\t\t\t\t\t\t\t\tfullLicense\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: fullLicense\n\t\t\t );\n\t}\n\treturn _caption.replace( /\\s{2}/g, ' ' );\n};\n\nconst coreMediaFetch = async ( query = {} ) => {\n\tconst mediaItems = await resolveSelect( coreStore ).getMediaItems( {\n\t\t...query,\n\t\torderBy: !! query?.search ? 'relevance' : 'date',\n\t} );\n\treturn mediaItems.map( ( mediaItem ) => ( {\n\t\t...mediaItem,\n\t\talt: mediaItem.alt_text,\n\t\turl: mediaItem.source_url,\n\t\tpreviewUrl: mediaItem.media_details?.sizes?.medium?.source_url,\n\t\tcaption: mediaItem.caption?.raw,\n\t} ) );\n};\n\n/** @type {InserterMediaCategory[]} */\nconst inserterMediaCategories = [\n\t{\n\t\tname: 'images',\n\t\tlabels: {\n\t\t\tname: __( 'Images' ),\n\t\t\tsearch_items: __( 'Search images' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'image' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'videos',\n\t\tlabels: {\n\t\t\tname: __( 'Videos' ),\n\t\t\tsearch_items: __( 'Search videos' ),\n\t\t},\n\t\tmediaType: 'video',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'video' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'audio',\n\t\tlabels: {\n\t\t\tname: __( 'Audio' ),\n\t\t\tsearch_items: __( 'Search audio' ),\n\t\t},\n\t\tmediaType: 'audio',\n\t\tasync fetch( query = {} ) {\n\t\t\treturn coreMediaFetch( { ...query, media_type: 'audio' } );\n\t\t},\n\t},\n\t{\n\t\tname: 'openverse',\n\t\tlabels: {\n\t\t\tname: __( 'Openverse' ),\n\t\t\tsearch_items: __( 'Search Openverse' ),\n\t\t},\n\t\tmediaType: 'image',\n\t\tasync fetch( query = {} ) {\n\t\t\tconst defaultArgs = {\n\t\t\t\tmature: false,\n\t\t\t\texcluded_source: 'flickr,inaturalist,wikimedia',\n\t\t\t\tlicense: 'pdm,cc0',\n\t\t\t};\n\t\t\tconst finalQuery = { ...query, ...defaultArgs };\n\t\t\tconst mapFromInserterMediaRequest = {\n\t\t\t\tper_page: 'page_size',\n\t\t\t\tsearch: 'q',\n\t\t\t};\n\t\t\tconst url = new URL(\n\t\t\t\t'https://api.openverse.engineering/v1/images/'\n\t\t\t);\n\t\t\tObject.entries( finalQuery ).forEach( ( [ key, value ] ) => {\n\t\t\t\tconst queryKey = mapFromInserterMediaRequest[ key ] || key;\n\t\t\t\turl.searchParams.set( queryKey, value );\n\t\t\t} );\n\t\t\tconst response = await window.fetch( url, {\n\t\t\t\theaders: {\n\t\t\t\t\t'User-Agent': 'WordPress/inserter-media-fetch',\n\t\t\t\t},\n\t\t\t} );\n\t\t\tconst jsonResponse = await response.json();\n\t\t\tconst results = jsonResponse.results;\n\t\t\treturn results.map( ( result ) => ( {\n\t\t\t\t...result,\n\t\t\t\t// This is a temp solution for better titles, until Openverse API\n\t\t\t\t// completes the cleaning up of some titles of their upstream data.\n\t\t\t\ttitle: result.title?.toLowerCase().startsWith( 'file:' )\n\t\t\t\t\t? result.title.slice( 5 )\n\t\t\t\t\t: result.title,\n\t\t\t\tsourceId: result.id,\n\t\t\t\tid: undefined,\n\t\t\t\tcaption: getOpenverseCaption( result ),\n\t\t\t\tpreviewUrl: result.thumbnail,\n\t\t\t} ) );\n\t\t},\n\t\tgetReportUrl: ( { sourceId } ) =>\n\t\t\t`https://wordpress.org/openverse/image/${ sourceId }/report/`,\n\t\tisExternalResource: true,\n\t},\n];\n\nexport default inserterMediaCategories;\n"]}
|
|
@@ -117,7 +117,7 @@ function PageAttributesParent() {
|
|
|
117
117
|
let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
118
118
|
const mappedNodes = tree.map(treeNode => [{
|
|
119
119
|
value: treeNode.id,
|
|
120
|
-
label: '— '.repeat(level) + (0,
|
|
120
|
+
label: '— '.repeat(level) + (0, _htmlEntities.decodeEntities)(treeNode.name),
|
|
121
121
|
rawName: treeNode.name
|
|
122
122
|
}, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
|
|
123
123
|
const sortedNodes = mappedNodes.sort((_ref, _ref2) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"names":["getTitle","post","title","rendered","id","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","length","Infinity","PageAttributesParent","editPost","editorStore","fieldValue","setFieldValue","parentPost","parentPostId","items","postType","select","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","isHierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPageLabel","pageItems","parentOptions","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;;;;;;;;;AAYA;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,IAAnB,EAA0B;AAAA;;AACzB,SAAOA,IAAI,SAAJ,IAAAA,I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CAAtB;;AAGA,QAAKD,UAAU,IAAI,CAAEgD,aAArB,EAAqC;AACpCD,MAAAA,IAAI,CAACG,OAAL,CAAc;AACbjB,QAAAA,KAAK,EAAEhC,YADM;AAEbiC,QAAAA,KAAK,EAAErD,QAAQ,CAAEmB,UAAF;AAFF,OAAd;AAIA;;AACD,WAAO+C,IAAP;AACA,GA7CqB,EA6CnB,CAAEtB,SAAF,EAAa3B,UAAb,CA7CmB,CAAtB;;AA+CA,MAAK,CAAEiB,cAAF,IAAoB,CAAES,eAA3B,EAA6C;AAC5C,WAAO,IAAP;AACA;AACD;AACD;AACA;AACA;AACA;;;AACC,QAAM2B,aAAa,GAAKC,UAAF,IAAkB;AACvCrD,IAAAA,aAAa,CAAEqD,UAAF,CAAb;AACA,GAFD;AAIA;AACD;AACA;AACA;AACA;;;AACC,QAAMC,YAAY,GAAKC,cAAF,IAAsB;AAC1C1D,IAAAA,QAAQ,CAAE;AAAEkD,MAAAA,MAAM,EAAEQ;AAAV,KAAF,CAAR;AACA,GAFD;;AAIA,SACC,4BAAC,2BAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,gCAFX;AAGC,IAAA,KAAK,EAAG9B,eAHT;AAIC,IAAA,KAAK,EAAGvB,YAJT;AAKC,IAAA,OAAO,EAAGyB,aALX;AAMC,IAAA,mBAAmB,EAAG,uBAAUyB,aAAV,EAAyB,GAAzB,CANvB;AAOC,IAAA,QAAQ,EAAGE;AAPZ,IADD;AAWA;;eAEc1D,oB","sourcesContent":["/**\n * External dependencies\n */\nimport { get, unescape as unescapeString } from 'lodash';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { parentPost, parentPostId, items, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst isHierarchical = get( pType, [ 'hierarchical' ], false );\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPost: pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null,\n\t\t\t\titems: isHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: [],\n\t\t\t\tpostType: pType,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst isHierarchical = get( postType, [ 'hierarchical' ], false );\n\tconst parentPageLabel = get( postType, [ 'labels', 'parent_item_colon' ] );\n\tconst pageItems = items || [];\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + unescapeString( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPost && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: getTitle( parentPost ),\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue ] );\n\n\tif ( ! isHierarchical || ! parentPageLabel ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ parentPageLabel }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/page-attributes/parent.js"],"names":["getTitle","post","title","rendered","id","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","length","Infinity","PageAttributesParent","editPost","editorStore","fieldValue","setFieldValue","parentPost","parentPostId","items","postType","select","getPostType","getEntityRecords","getEntityRecord","coreStore","getCurrentPostId","getEditedPostAttribute","postTypeSlug","pageId","pType","postId","isHierarchical","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentPageLabel","pageItems","parentOptions","getOptionsFromTree","tree","level","mappedNodes","map","treeNode","value","label","repeat","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","opts","optsHasParent","find","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;;;;;;;;;AAYA;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,IAAnB,EAA0B;A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F,IAAYA,IAAI,CAACZ,KAAL,KAAehC,YADN,CAAtB;;AAGA,QAAKD,UAAU,IAAI,CAAEgD,aAArB,EAAqC;AACpCD,MAAAA,IAAI,CAACG,OAAL,CAAc;AACbjB,QAAAA,KAAK,EAAEhC,YADM;AAEbiC,QAAAA,KAAK,EAAErD,QAAQ,CAAEmB,UAAF;AAFF,OAAd;AAIA;;AACD,WAAO+C,IAAP;AACA,GA7CqB,EA6CnB,CAAEtB,SAAF,EAAa3B,UAAb,CA7CmB,CAAtB;;AA+CA,MAAK,CAAEiB,cAAF,IAAoB,CAAES,eAA3B,EAA6C;AAC5C,WAAO,IAAP;AACA;AACD;AACD;AACA;AACA;AACA;;;AACC,QAAM2B,aAAa,GAAKC,UAAF,IAAkB;AACvCrD,IAAAA,aAAa,CAAEqD,UAAF,CAAb;AACA,GAFD;AAIA;AACD;AACA;AACA;AACA;;;AACC,QAAMC,YAAY,GAAKC,cAAF,IAAsB;AAC1C1D,IAAAA,QAAQ,CAAE;AAAEkD,MAAAA,MAAM,EAAEQ;AAAV,KAAF,CAAR;AACA,GAFD;;AAIA,SACC,4BAAC,2BAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,gCAFX;AAGC,IAAA,KAAK,EAAG9B,eAHT;AAIC,IAAA,KAAK,EAAGvB,YAJT;AAKC,IAAA,OAAO,EAAGyB,aALX;AAMC,IAAA,mBAAmB,EAAG,uBAAUyB,aAAV,EAAyB,GAAzB,CANvB;AAOC,IAAA,QAAQ,EAAGE;AAPZ,IADD;AAWA;;eAEc1D,oB","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\n\nfunction getTitle( post ) {\n\treturn post?.title?.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post.id } (${ __( 'no title' ) })`;\n}\n\nexport const getItemPriority = ( name, searchValue ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst [ fieldValue, setFieldValue ] = useState( false );\n\tconst { parentPost, parentPostId, items, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostType, getEntityRecords, getEntityRecord } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getCurrentPostId, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst postTypeSlug = getEditedPostAttribute( 'type' );\n\t\t\tconst pageId = getEditedPostAttribute( 'parent' );\n\t\t\tconst pType = getPostType( postTypeSlug );\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst isHierarchical = get( pType, [ 'hierarchical' ], false );\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t};\n\n\t\t\t// Perform a search when the field is changed.\n\t\t\tif ( !! fieldValue ) {\n\t\t\t\tquery.search = fieldValue;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tparentPostId: pageId,\n\t\t\t\tparentPost: pageId\n\t\t\t\t\t? getEntityRecord( 'postType', postTypeSlug, pageId )\n\t\t\t\t\t: null,\n\t\t\t\titems: isHierarchical\n\t\t\t\t\t? getEntityRecords( 'postType', postTypeSlug, query )\n\t\t\t\t\t: [],\n\t\t\t\tpostType: pType,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue ]\n\t);\n\n\tconst isHierarchical = get( postType, [ 'hierarchical' ], false );\n\tconst parentPageLabel = get( postType, [ 'labels', 'parent_item_colon' ] );\n\tconst pageItems = items || [];\n\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = ( tree, level = 0 ) => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id,\n\t\t\tparent: item.parent,\n\t\t\tname: getTitle( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find(\n\t\t\t( item ) => item.value === parentPostId\n\t\t);\n\t\tif ( parentPost && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: parentPostId,\n\t\t\t\tlabel: getTitle( parentPost ),\n\t\t\t} );\n\t\t}\n\t\treturn opts;\n\t}, [ pageItems, fieldValue ] );\n\n\tif ( ! isHierarchical || ! parentPageLabel ) {\n\t\treturn null;\n\t}\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId ) => {\n\t\teditPost( { parent: selectedPostId } );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"editor-page-attributes__parent\"\n\t\t\tlabel={ parentPageLabel }\n\t\t\tvalue={ parentPostId }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce( handleKeydown, 300 ) }\n\t\t\tonChange={ handleChange }\n\t\t/>\n\t);\n}\n\nexport default PageAttributesParent;\n"]}
|
|
@@ -138,6 +138,7 @@ class PostPublishPanelPostpublish extends _element.Component {
|
|
|
138
138
|
}, (0, _element.createElement)("strong", null, (0, _i18n.__)('What’s next?'))), (0, _element.createElement)("div", {
|
|
139
139
|
className: "post-publish-panel__postpublish-post-address-container"
|
|
140
140
|
}, (0, _element.createElement)(_components.TextControl, {
|
|
141
|
+
__nextHasNoMarginBottom: true,
|
|
141
142
|
className: "post-publish-panel__postpublish-post-address",
|
|
142
143
|
readOnly: true,
|
|
143
144
|
label: (0, _i18n.sprintf)(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/postpublish.js"],"names":["POSTNAME","getFuturePostUrl","post","slug","permalink_template","includes","replace","CopyButton","text","onCopy","children","ref","PostPublishPanelPostpublish","Component","constructor","arguments","state","showCopyConfirmation","bind","onSelectInput","postLink","componentDidMount","props","focusOnMount","current","focus","componentWillUnmount","clearTimeout","dismissCopyConfirmation","setState","setTimeout","event","target","select","render","isScheduled","postType","postLabel","viewPostLabel","addNewPostLabel","link","status","addLink","post_type","type","postPublishNonLinkHeader","title","getEditedPostAttribute","getCurrentPost","isCurrentPostScheduled","editorStore","getPostType","coreStore"],"mappings":";;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG,YAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,gBAAgB,GAAKC,IAAF,IAAY;AACpC,QAAM;AAAEC,IAAAA;AAAF,MAAWD,IAAjB;;AAEA,MAAKA,IAAI,CAACE,kBAAL,CAAwBC,QAAxB,CAAkCL,QAAlC,CAAL,EAAoD;AACnD,WAAOE,IAAI,CAACE,kBAAL,CAAwBE,OAAxB,CAAiCN,QAAjC,EAA2CG,IAA3C,CAAP;AACA;;AAED,SAAOD,IAAI,CAACE,kBAAZ;AACA,CARD;;AAUA,SAASG,UAAT,OAAkD;AAAA,MAA7B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,MAAR;AAAgBC,IAAAA;AAAhB,GAA6B;AACjD,QAAMC,GAAG,GAAG,iCAAoBH,IAApB,EAA0BC,MAA1B,CAAZ;AACA,SACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,MAAME,2BAAN,SAA0CC,kBAA1C,CAAoD;AACnDC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AACA,SAAKC,KAAL,GAAa;AACZC,MAAAA,oBAAoB,EAAE;AADV,KAAb;AAGA,SAAKR,MAAL,GAAc,KAAKA,MAAL,CAAYS,IAAZ,CAAkB,IAAlB,CAAd;AACA,SAAKC,aAAL,GAAqB,KAAKA,aAAL,CAAmBD,IAAnB,CAAyB,IAAzB,CAArB;AACA,SAA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,IAAI,CAAC0C;AAD6B,KAA9B,CAAhB;AAIA,UAAMC,wBAAwB,GAAGV,WAAW,GAC3C,qDACG,cAAI,sCAAJ,CADH,EACmD,GADnD,EAEC,4BAAC,cAAD,OAFD,MAD2C,GAM3C,cAAI,cAAJ,CAND;AASA,WACC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,qBAAD;AAAW,MAAA,SAAS,EAAC;AAArB,OACC;AAAG,MAAA,GAAG,EAAG,KAAKf,QAAd;AAAyB,MAAA,IAAI,EAAGoB;AAAhC,OACG,kCAAgBtC,IAAI,CAAC4C,KAArB,KAAgC,cAAI,YAAJ,CADnC,CADD,EAGO,GAHP,EAIGD,wBAJH,CADD,EAOC,4BAAC,qBAAD,QACC;AAAG,MAAA,SAAS,EAAC;AAAb,OACC,4CAAU,cAAI,cAAJ,CAAV,CADD,CADD,EAIC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,uBAAD;AACC,MAAA,SAAS,EAAC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-publish-panel/postpublish.js"],"names":["POSTNAME","getFuturePostUrl","post","slug","permalink_template","includes","replace","CopyButton","text","onCopy","children","ref","PostPublishPanelPostpublish","Component","constructor","arguments","state","showCopyConfirmation","bind","onSelectInput","postLink","componentDidMount","props","focusOnMount","current","focus","componentWillUnmount","clearTimeout","dismissCopyConfirmation","setState","setTimeout","event","target","select","render","isScheduled","postType","postLabel","viewPostLabel","addNewPostLabel","link","status","addLink","post_type","type","postPublishNonLinkHeader","title","getEditedPostAttribute","getCurrentPost","isCurrentPostScheduled","editorStore","getPostType","coreStore"],"mappings":";;;;;;;;;AAUA;;AAPA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG,YAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC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BlB,MAAM,CAAEmB,eAAF,CAA9B;AAEA,SAAO;AACNlD,IAAAA,IAAI,EAAE8C,cAAc,EADd;AAENZ,IAAAA,QAAQ,EAAEe,WAAW,CAAEJ,sBAAsB,CAAE,MAAF,CAAxB,CAFf;AAGNZ,IAAAA,WAAW,EAAEc,sBAAsB;AAH7B,GAAP;AAKA,CAVc,EAUVrC,2BAVU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { PanelBody, Button, TextControl } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { addQueryArgs, safeDecodeURIComponent } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostScheduleLabel from '../post-schedule/label';\nimport { store as editorStore } from '../../store';\n\nconst POSTNAME = '%postname%';\n\n/**\n * Returns URL for a future post.\n *\n * @param {Object} post Post object.\n *\n * @return {string} PostPublish URL.\n */\n\nconst getFuturePostUrl = ( post ) => {\n\tconst { slug } = post;\n\n\tif ( post.permalink_template.includes( POSTNAME ) ) {\n\t\treturn post.permalink_template.replace( POSTNAME, slug );\n\t}\n\n\treturn post.permalink_template;\n};\n\nfunction CopyButton( { text, onCopy, children } ) {\n\tconst ref = useCopyToClipboard( text, onCopy );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nclass PostPublishPanelPostpublish extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\t\tthis.state = {\n\t\t\tshowCopyConfirmation: false,\n\t\t};\n\t\tthis.onCopy = this.onCopy.bind( this );\n\t\tthis.onSelectInput = this.onSelectInput.bind( this );\n\t\tthis.postLink = createRef();\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.props.focusOnMount ) {\n\t\t\tthis.postLink.current.focus();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tclearTimeout( this.dismissCopyConfirmation );\n\t}\n\n\tonCopy() {\n\t\tthis.setState( {\n\t\t\tshowCopyConfirmation: true,\n\t\t} );\n\n\t\tclearTimeout( this.dismissCopyConfirmation );\n\t\tthis.dismissCopyConfirmation = setTimeout( () => {\n\t\t\tthis.setState( {\n\t\t\t\tshowCopyConfirmation: false,\n\t\t\t} );\n\t\t}, 4000 );\n\t}\n\n\tonSelectInput( event ) {\n\t\tevent.target.select();\n\t}\n\n\trender() {\n\t\tconst { children, isScheduled, post, postType } = this.props;\n\t\tconst postLabel = get( postType, [ 'labels', 'singular_name' ] );\n\t\tconst viewPostLabel = get( postType, [ 'labels', 'view_item' ] );\n\t\tconst addNewPostLabel = get( postType, [ 'labels', 'add_new_item' ] );\n\t\tconst link =\n\t\t\tpost.status === 'future' ? getFuturePostUrl( post ) : post.link;\n\t\tconst addLink = addQueryArgs( 'post-new.php', {\n\t\t\tpost_type: post.type,\n\t\t} );\n\n\t\tconst postPublishNonLinkHeader = isScheduled ? (\n\t\t\t<>\n\t\t\t\t{ __( 'is now scheduled. It will go live on' ) }{ ' ' }\n\t\t\t\t<PostScheduleLabel />.\n\t\t\t</>\n\t\t) : (\n\t\t\t__( 'is now live.' )\n\t\t);\n\n\t\treturn (\n\t\t\t<div className=\"post-publish-panel__postpublish\">\n\t\t\t\t<PanelBody className=\"post-publish-panel__postpublish-header\">\n\t\t\t\t\t<a ref={ this.postLink } href={ link }>\n\t\t\t\t\t\t{ decodeEntities( post.title ) || __( '(no title)' ) }\n\t\t\t\t\t</a>{ ' ' }\n\t\t\t\t\t{ postPublishNonLinkHeader }\n\t\t\t\t</PanelBody>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<p className=\"post-publish-panel__postpublish-subheader\">\n\t\t\t\t\t\t<strong>{ __( 'What’s next?' ) }</strong>\n\t\t\t\t\t</p>\n\t\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address-container\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tclassName=\"post-publish-panel__postpublish-post-address\"\n\t\t\t\t\t\t\treadOnly\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: post type singular name */\n\t\t\t\t\t\t\t\t__( '%s address' ),\n\t\t\t\t\t\t\t\tpostLabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tvalue={ safeDecodeURIComponent( link ) }\n\t\t\t\t\t\t\tonFocus={ this.onSelectInput }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<div className=\"post-publish-panel__postpublish-post-address__copy-button-wrap\">\n\t\t\t\t\t\t\t<CopyButton text={ link } onCopy={ this.onCopy }>\n\t\t\t\t\t\t\t\t{ this.state.showCopyConfirmation\n\t\t\t\t\t\t\t\t\t? __( 'Copied!' )\n\t\t\t\t\t\t\t\t\t: __( 'Copy' ) }\n\t\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<div className=\"post-publish-panel__postpublish-buttons\">\n\t\t\t\t\t\t{ ! isScheduled && (\n\t\t\t\t\t\t\t<Button variant=\"primary\" href={ link }>\n\t\t\t\t\t\t\t\t{ viewPostLabel }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant={ isScheduled ? 'primary' : 'secondary' }\n\t\t\t\t\t\t\thref={ addLink }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ addNewPostLabel }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</PanelBody>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t);\n\t}\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getEditedPostAttribute, getCurrentPost, isCurrentPostScheduled } =\n\t\tselect( editorStore );\n\tconst { getPostType } = select( coreStore );\n\n\treturn {\n\t\tpost: getCurrentPost(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tisScheduled: isCurrentPostScheduled(),\n\t};\n} )( PostPublishPanelPostpublish );\n"]}
|
|
@@ -66,6 +66,7 @@ class PostSlug extends _element.Component {
|
|
|
66
66
|
editedSlug
|
|
67
67
|
} = this.state;
|
|
68
68
|
return (0, _element.createElement)(_check.default, null, (0, _element.createElement)(_components.TextControl, {
|
|
69
|
+
__nextHasNoMarginBottom: true,
|
|
69
70
|
label: (0, _i18n.__)('Slug'),
|
|
70
71
|
autoComplete: "off",
|
|
71
72
|
spellCheck: "false",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-slug/index.js"],"names":["PostSlug","Component","constructor","postSlug","postTitle","postID","arguments","state","editedSlug","setSlug","bind","event","onUpdateSlug","props","value","target","render","slug","setState","select","getCurrentPost","getEditedPostAttribute","editorStore","id","dispatch","editPost"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;AAIO,MAAMA,QAAN,SAAuBC,kBAAvB,CAAiC;AACvCC,EAAAA,WAAW,OAAoC;AAAA,QAAlC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,SAAZ;AAAuBC,MAAAA;AAAvB,KAAkC;AAC9C,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,UAAU,EACT,iCAAwBL,QAAxB,KACA,uBAAcC,SAAd,CADA,IAEAC;AAJW,KAAb;AAOA,SAAKI,OAAL,GAAe,KAAKA,OAAL,CAAaC,IAAb,CAAmB,IAAnB,CAAf;AACA;;AAEDD,EAAAA,OAAO,CAAEE,KAAF,EAAU;AAChB,UAAM;AAAER,MAAAA,QAAF;AAAYS,MAAAA;AAAZ,QAA6B,KAAKC,KAAxC;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAYH,KAAK,CAACI,MAAxB;AAEA,UAAMP,UAAU,GAAG,uBAAcM,KAAd,CAAnB;;AAEA,QAAKN,UAAU,KAAKL,QAApB,EAA+B;AAC9B;AACA;;AAEDS,IAAAA,YAAY,CAAEJ,UAAF,CAAZ;AACA;;AAEDQ,EAAAA,MAAM,GAAG;AACR,UAAM;AAAER,MAAAA;AAAF,QAAiB,KAAKD,KAA5B;AACA,WACC,4BAAC,cAAD,QACC,4BAAC,uBAAD;AACC,MAAA,KAAK,EAAG,cAAI,MAAJ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-slug/index.js"],"names":["PostSlug","Component","constructor","postSlug","postTitle","postID","arguments","state","editedSlug","setSlug","bind","event","onUpdateSlug","props","value","target","render","slug","setState","select","getCurrentPost","getEditedPostAttribute","editorStore","id","dispatch","editPost"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;AAIO,MAAMA,QAAN,SAAuBC,kBAAvB,CAAiC;AACvCC,EAAAA,WAAW,OAAoC;AAAA,QAAlC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,SAAZ;AAAuBC,MAAAA;AAAvB,KAAkC;AAC9C,UAAO,GAAGC,SAAV;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,UAAU,EACT,iCAAwBL,QAAxB,KACA,uBAAcC,SAAd,CADA,IAEAC;AAJW,KAAb;AAOA,SAAKI,OAAL,GAAe,KAAKA,OAAL,CAAaC,IAAb,CAAmB,IAAnB,CAAf;AACA;;AAEDD,EAAAA,OAAO,CAAEE,KAAF,EAAU;AAChB,UAAM;AAAER,MAAAA,QAAF;AAAYS,MAAAA;AAAZ,QAA6B,KAAKC,KAAxC;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAYH,KAAK,CAACI,MAAxB;AAEA,UAAMP,UAAU,GAA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BU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { compose } from '@wordpress/compose';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\nimport { TextControl } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport PostSlugCheck from './check';\nimport { store as editorStore } from '../../store';\n\nexport class PostSlug extends Component {\n\tconstructor( { postSlug, postTitle, postID } ) {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\teditedSlug:\n\t\t\t\tsafeDecodeURIComponent( postSlug ) ||\n\t\t\t\tcleanForSlug( postTitle ) ||\n\t\t\t\tpostID,\n\t\t};\n\n\t\tthis.setSlug = this.setSlug.bind( this );\n\t}\n\n\tsetSlug( event ) {\n\t\tconst { postSlug, onUpdateSlug } = this.props;\n\t\tconst { value } = event.target;\n\n\t\tconst editedSlug = cleanForSlug( value );\n\n\t\tif ( editedSlug === postSlug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonUpdateSlug( editedSlug );\n\t}\n\n\trender() {\n\t\tconst { editedSlug } = this.state;\n\t\treturn (\n\t\t\t<PostSlugCheck>\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Slug' ) }\n\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\tvalue={ editedSlug }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\tthis.setState( { editedSlug: slug } )\n\t\t\t\t\t}\n\t\t\t\t\tonBlur={ this.setSlug }\n\t\t\t\t\tclassName=\"editor-post-slug\"\n\t\t\t\t/>\n\t\t\t</PostSlugCheck>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\tselect( editorStore );\n\n\t\tconst { id } = getCurrentPost();\n\t\treturn {\n\t\t\tpostSlug: getEditedPostAttribute( 'slug' ),\n\t\t\tpostTitle: getEditedPostAttribute( 'title' ),\n\t\t\tpostID: id,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateSlug( slug ) {\n\t\t\t\teditPost( { slug } );\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostSlug );\n"]}
|
|
@@ -25,6 +25,8 @@ var _coreData = require("@wordpress/core-data");
|
|
|
25
25
|
|
|
26
26
|
var _a11y = require("@wordpress/a11y");
|
|
27
27
|
|
|
28
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
29
|
+
|
|
28
30
|
var _terms = require("../../utils/terms");
|
|
29
31
|
|
|
30
32
|
var _store = require("../../store");
|
|
@@ -344,7 +346,7 @@ function HierarchicalTermSelector(_ref) {
|
|
|
344
346
|
const termId = parseInt(term.id, 10);
|
|
345
347
|
onChange(termId);
|
|
346
348
|
},
|
|
347
|
-
label: (0,
|
|
349
|
+
label: (0, _htmlEntities.decodeEntities)(term.name)
|
|
348
350
|
}), !!term.children.length && (0, _element.createElement)("div", {
|
|
349
351
|
className: "editor-post-taxonomies__hierarchical-terms-subchoices"
|
|
350
352
|
}, renderTerms(term.children)));
|
|
@@ -362,6 +364,7 @@ function HierarchicalTermSelector(_ref) {
|
|
|
362
364
|
const groupLabel = (0, _lodash.get)(taxonomy, ['name'], (0, _i18n.__)('Terms'));
|
|
363
365
|
const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
|
|
364
366
|
return (0, _element.createElement)(_element.Fragment, null, showFilter && (0, _element.createElement)(_components.TextControl, {
|
|
367
|
+
__nextHasNoMarginBottom: true,
|
|
365
368
|
className: "editor-post-taxonomies__hierarchical-terms-filter",
|
|
366
369
|
label: filterLabel,
|
|
367
370
|
value: filterValue,
|
|
@@ -378,7 +381,8 @@ function HierarchicalTermSelector(_ref) {
|
|
|
378
381
|
variant: "link"
|
|
379
382
|
}, newTermButtonLabel), showForm && (0, _element.createElement)("form", {
|
|
380
383
|
onSubmit: onAddTerm
|
|
381
|
-
}, (0, _element.createElement)(_components.TextControl, {
|
|
384
|
+
}, (0, _element.createElement)(_components.__experimentalVStack, null, (0, _element.createElement)(_components.TextControl, {
|
|
385
|
+
__nextHasNoMarginBottom: true,
|
|
382
386
|
className: "editor-post-taxonomies__hierarchical-terms-input",
|
|
383
387
|
label: newTermLabel,
|
|
384
388
|
value: formName,
|
|
@@ -390,7 +394,7 @@ function HierarchicalTermSelector(_ref) {
|
|
|
390
394
|
onChange: onChangeFormParent,
|
|
391
395
|
selectedId: formParent,
|
|
392
396
|
tree: availableTermsTree
|
|
393
|
-
}), (0, _element.createElement)(_components.Button, {
|
|
397
|
+
})), (0, _element.createElement)(_components.Button, {
|
|
394
398
|
variant: "secondary",
|
|
395
399
|
type: "submit",
|
|
396
400
|
className: "editor-post-taxonomies__hierarchical-terms-submit"
|