@wordpress/editor 12.11.0 → 12.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 +2 -0
- package/build/components/document-outline/index.js +7 -9
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/error-boundary/index.js +3 -0
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/index.js +49 -8
- package/build/components/index.js.map +1 -1
- package/build/components/page-attributes/order.js +3 -7
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/page-attributes/parent.js +1 -1
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-format/index.js +5 -8
- package/build/components/post-format/index.js.map +1 -1
- package/build/components/post-schedule/label.js +3 -3
- package/build/components/post-schedule/label.js.map +1 -1
- package/build/components/post-slug/index.js +8 -13
- package/build/components/post-slug/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +1 -0
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -0
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/index.js +3 -1
- package/build/components/post-taxonomies/index.js.map +1 -1
- package/build/components/post-template/index.js +1 -2
- package/build/components/post-template/index.js.map +1 -1
- package/build/components/post-url/check.js +54 -0
- package/build/components/post-url/check.js.map +1 -0
- package/build/components/post-url/index.js +115 -0
- package/build/components/post-url/index.js.map +1 -0
- package/build/components/post-url/label.js +30 -0
- package/build/components/post-url/label.js.map +1 -0
- package/build/components/post-visibility/label.js +5 -0
- package/build/components/post-visibility/label.js.map +1 -1
- package/build/components/table-of-contents/panel.js +5 -1
- package/build/components/table-of-contents/panel.js.map +1 -1
- package/build/components/time-to-read/index.js +60 -0
- package/build/components/time-to-read/index.js.map +1 -0
- package/build/store/selectors.js +2 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/document-outline/index.js +7 -8
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/error-boundary/index.js +2 -0
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/index.js +6 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/page-attributes/order.js +3 -6
- package/build-module/components/page-attributes/order.js.map +1 -1
- 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-format/index.js +5 -8
- package/build-module/components/post-format/index.js.map +1 -1
- package/build-module/components/post-schedule/label.js +3 -3
- package/build-module/components/post-schedule/label.js.map +1 -1
- package/build-module/components/post-slug/index.js +8 -14
- package/build-module/components/post-slug/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +1 -2
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +1 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/index.js +4 -1
- package/build-module/components/post-taxonomies/index.js.map +1 -1
- package/build-module/components/post-template/index.js +1 -2
- package/build-module/components/post-template/index.js.map +1 -1
- package/build-module/components/post-url/check.js +44 -0
- package/build-module/components/post-url/check.js.map +1 -0
- package/build-module/components/post-url/index.js +102 -0
- package/build-module/components/post-url/index.js.map +1 -0
- package/build-module/components/post-url/label.js +18 -0
- package/build-module/components/post-url/label.js.map +1 -0
- package/build-module/components/post-visibility/label.js +3 -0
- package/build-module/components/post-visibility/label.js.map +1 -1
- package/build-module/components/table-of-contents/panel.js +4 -1
- package/build-module/components/table-of-contents/panel.js.map +1 -1
- package/build-module/components/time-to-read/index.js +50 -0
- package/build-module/components/time-to-read/index.js.map +1 -0
- package/build-module/store/selectors.js +3 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +15 -17
- package/build-style/style.css +19 -17
- package/package.json +28 -28
- package/src/components/document-outline/index.js +9 -8
- package/src/components/error-boundary/index.js +3 -0
- package/src/components/index.js +9 -3
- package/src/components/page-attributes/order.js +1 -9
- package/src/components/page-attributes/parent.js +1 -2
- package/src/components/post-format/index.js +13 -19
- package/src/components/post-format/style.scss +2 -17
- package/src/components/post-schedule/label.js +1 -1
- package/src/components/post-slug/index.js +7 -13
- package/src/components/post-slug/test/index.js +7 -6
- package/src/components/post-taxonomies/flat-term-selector.js +1 -1
- package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -1
- package/src/components/post-taxonomies/index.js +3 -1
- package/src/components/post-template/index.js +1 -1
- package/src/components/post-url/check.js +38 -0
- package/src/components/post-url/index.js +122 -0
- package/src/components/post-url/label.js +22 -0
- package/src/components/post-url/style.scss +16 -0
- package/src/components/post-visibility/label.js +4 -0
- package/src/components/table-of-contents/panel.js +7 -2
- package/src/components/time-to-read/index.js +59 -0
- package/src/store/selectors.js +4 -5
- package/src/store/test/selectors.js +1 -1
- package/src/style.scss +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,8 +9,6 @@ exports.default = exports.DocumentOutline = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _i18n = require("@wordpress/i18n");
|
|
15
13
|
|
|
16
14
|
var _compose = require("@wordpress/compose");
|
|
@@ -27,10 +25,6 @@ var _item = _interopRequireDefault(require("./item"));
|
|
|
27
25
|
|
|
28
26
|
var _store = require("../../store");
|
|
29
27
|
|
|
30
|
-
/**
|
|
31
|
-
* External dependencies
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
28
|
/**
|
|
35
29
|
* WordPress dependencies
|
|
36
30
|
*/
|
|
@@ -70,7 +64,7 @@ const multipleH1Headings = [(0, _element.createElement)("br", {
|
|
|
70
64
|
|
|
71
65
|
const computeOutlineHeadings = function () {
|
|
72
66
|
let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
73
|
-
return
|
|
67
|
+
return blocks.flatMap(function () {
|
|
74
68
|
let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
69
|
|
|
76
70
|
if (block.name === 'core/heading') {
|
|
@@ -104,7 +98,9 @@ const DocumentOutline = _ref => {
|
|
|
104
98
|
|
|
105
99
|
const titleNode = document.querySelector('.editor-post-title__input');
|
|
106
100
|
const hasTitle = isTitleSupported && title && titleNode;
|
|
107
|
-
const countByLevel = (
|
|
101
|
+
const countByLevel = headings.reduce((acc, heading) => ({ ...acc,
|
|
102
|
+
[heading.level]: (acc[heading.level] || 0) + 1
|
|
103
|
+
}), {});
|
|
108
104
|
const hasMultipleH1 = countByLevel[1] > 1;
|
|
109
105
|
return (0, _element.createElement)("div", {
|
|
110
106
|
className: "document-outline"
|
|
@@ -136,6 +132,8 @@ const DocumentOutline = _ref => {
|
|
|
136
132
|
exports.DocumentOutline = DocumentOutline;
|
|
137
133
|
|
|
138
134
|
var _default = (0, _compose.compose)((0, _data.withSelect)(select => {
|
|
135
|
+
var _postType$supports$ti, _postType$supports;
|
|
136
|
+
|
|
139
137
|
const {
|
|
140
138
|
getBlocks
|
|
141
139
|
} = select(_blockEditor.store);
|
|
@@ -149,7 +147,7 @@ var _default = (0, _compose.compose)((0, _data.withSelect)(select => {
|
|
|
149
147
|
return {
|
|
150
148
|
title: getEditedPostAttribute('title'),
|
|
151
149
|
blocks: getBlocks(),
|
|
152
|
-
isTitleSupported: (0
|
|
150
|
+
isTitleSupported: (_postType$supports$ti = postType === null || postType === void 0 ? void 0 : (_postType$supports = postType.supports) === null || _postType$supports === void 0 ? void 0 : _postType$supports.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
|
|
153
151
|
};
|
|
154
152
|
}))(DocumentOutline);
|
|
155
153
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/document-outline/index.js"],"names":["emptyHeadingContent","incorrectLevelContent","singleH1Headings","multipleH1Headings","computeOutlineHeadings","blocks","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","length","DocumentOutline","title","onSelect","isTitleSupported","hasOutlineItemsDisabled","headings","prevHeadingLevel","titleNode","document","querySelector","hasTitle","countByLevel","hasMultipleH1","id","map","item","index","isIncorrectLevel","isValid","clientId","html","select","getBlocks","blockEditorStore","getEditedPostAttribute","editorStore","getPostType","coreStore","postType"],"mappings":";;;;;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/document-outline/index.js"],"names":["emptyHeadingContent","incorrectLevelContent","singleH1Headings","multipleH1Headings","computeOutlineHeadings","blocks","flatMap","block","name","level","attributes","isEmpty","isEmptyHeading","innerBlocks","heading","content","length","DocumentOutline","title","onSelect","isTitleSupported","hasOutlineItemsDisabled","headings","prevHeadingLevel","titleNode","document","querySelector","hasTitle","countByLevel","reduce","acc","hasMultipleH1","id","map","item","index","isIncorrectLevel","isValid","clientId","html","select","getBlocks","blockEditorStore","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","supports"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,wCAAM,cAAI,iBAAJ,CAAN,CAA5B;AACA,MAAMC,qBAAqB,GAAG,CAC7B;AAAI,EAAA,GAAG,EAAC;AAAR,EAD6B,EAE7B;AAAI,EAAA,GAAG,EAAC;AAAR,GAA8B,cAAI,2BAAJ,CAA9B,CAF6B,CAA9B;AAIA,MAAMC,gBAAgB,GAAG,CACxB;AAAI,EAAA,GAAG,EAAC;AAAR,EADwB,EAExB;AAAI,EAAA,GAAG,EAAC;AAAR,GACG,cAAI,sDAAJ,CADH,CAFwB,CAAzB;AAMA,MAAMC,kBAAkB,GAAG,CAC1B;AAAI,EAAA,GAAG,EAAC;AAAR,EAD0B,EAE1B;AAAI,EAAA,GAAG,EAAC;AAAR,GACG,cAAI,4CAAJ,CADH,CAF0B,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BAAQ;AACPuC,MAAAA,IAAI,EAAEL,IAAI,CAACxB,UAAL,CAAgBK;AADf,KAAR,CADA,CAVJ,EAeGqB,gBAAgB,IAAInC,qBAfvB,EAgBGiC,IAAI,CAACzB,KAAL,KAAe,CAAf,IACDsB,aADC,IAED5B,kBAlBF,EAmBGwB,QAAQ,IACTO,IAAI,CAACzB,KAAL,KAAe,CADd,IAED,CAAEsB,aAFD,IAGD7B,gBAtBF,CADD;AA0BA,GAvCC,CAZH,CADD,CADD;AAyDA,CApFM;;;;eAsFQ,sBACd,sBAAcsC,MAAF,IAAc;AAAA;;AACzB,QAAM;AAAEC,IAAAA;AAAF,MAAgBD,MAAM,CAAEE,kBAAF,CAA5B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA6BH,MAAM,CAAEI,YAAF,CAAzC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAkBL,MAAM,CAAEM,eAAF,CAA9B;AACA,QAAMC,QAAQ,GAAGF,WAAW,CAAEF,sBAAsB,CAAE,MAAF,CAAxB,CAA5B;AAEA,SAAO;AACNzB,IAAAA,KAAK,EAAEyB,sBAAsB,CAAE,OAAF,CADvB;AAENtC,IAAAA,MAAM,EAAEoC,SAAS,EAFX;AAGNrB,IAAAA,gBAAgB,2BAAE2B,QAAF,aAAEA,QAAF,6CAAEA,QAAQ,CAAEC,QAAZ,uDAAE,mBAAoB9B,KAAtB,yEAA+B;AAHzC,GAAP;AAKA,CAXD,CADc,EAaZD,eAbY,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { compose } from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { create, getTextContent } from '@wordpress/rich-text';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport DocumentOutlineItem from './item';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module constants\n */\nconst emptyHeadingContent = <em>{ __( '(Empty heading)' ) }</em>;\nconst incorrectLevelContent = [\n\t<br key=\"incorrect-break\" />,\n\t<em key=\"incorrect-message\">{ __( '(Incorrect heading level)' ) }</em>,\n];\nconst singleH1Headings = [\n\t<br key=\"incorrect-break-h1\" />,\n\t<em key=\"incorrect-message-h1\">\n\t\t{ __( '(Your theme may already use a H1 for the post title)' ) }\n\t</em>,\n];\nconst multipleH1Headings = [\n\t<br key=\"incorrect-break-multiple-h1\" />,\n\t<em key=\"incorrect-message-multiple-h1\">\n\t\t{ __( '(Multiple H1 headings are not recommended)' ) }\n\t</em>,\n];\n\n/**\n * Returns an array of heading blocks enhanced with the following properties:\n * level - An integer with the heading level.\n * isEmpty - Flag indicating if the heading has no content.\n *\n * @param {?Array} blocks An array of blocks.\n *\n * @return {Array} An array of heading blocks enhanced with the properties described above.\n */\nconst computeOutlineHeadings = ( blocks = [] ) => {\n\treturn blocks.flatMap( ( block = {} ) => {\n\t\tif ( block.name === 'core/heading' ) {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tlevel: block.attributes.level,\n\t\t\t\tisEmpty: isEmptyHeading( block ),\n\t\t\t};\n\t\t}\n\t\treturn computeOutlineHeadings( block.innerBlocks );\n\t} );\n};\n\nconst isEmptyHeading = ( heading ) =>\n\t! heading.attributes.content || heading.attributes.content.length === 0;\n\nexport const DocumentOutline = ( {\n\tblocks = [],\n\ttitle,\n\tonSelect,\n\tisTitleSupported,\n\thasOutlineItemsDisabled,\n} ) => {\n\tconst headings = computeOutlineHeadings( blocks );\n\n\tif ( headings.length < 1 ) {\n\t\treturn null;\n\t}\n\n\tlet prevHeadingLevel = 1;\n\n\t// Not great but it's the simplest way to locate the title right now.\n\tconst titleNode = document.querySelector( '.editor-post-title__input' );\n\tconst hasTitle = isTitleSupported && title && titleNode;\n\tconst countByLevel = headings.reduce(\n\t\t( acc, heading ) => ( {\n\t\t\t...acc,\n\t\t\t[ heading.level ]: ( acc[ heading.level ] || 0 ) + 1,\n\t\t} ),\n\t\t{}\n\t);\n\tconst hasMultipleH1 = countByLevel[ 1 ] > 1;\n\n\treturn (\n\t\t<div className=\"document-outline\">\n\t\t\t<ul>\n\t\t\t\t{ hasTitle && (\n\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\tlevel={ __( 'Title' ) }\n\t\t\t\t\t\tisValid\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\thref={ `#${ titleNode.id }` }\n\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ title }\n\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t) }\n\t\t\t\t{ headings.map( ( item, index ) => {\n\t\t\t\t\t// Headings remain the same, go up by one, or down by any amount.\n\t\t\t\t\t// Otherwise there are missing levels.\n\t\t\t\t\tconst isIncorrectLevel = item.level > prevHeadingLevel + 1;\n\n\t\t\t\t\tconst isValid =\n\t\t\t\t\t\t! item.isEmpty &&\n\t\t\t\t\t\t! isIncorrectLevel &&\n\t\t\t\t\t\t!! item.level &&\n\t\t\t\t\t\t( item.level !== 1 ||\n\t\t\t\t\t\t\t( ! hasMultipleH1 && ! hasTitle ) );\n\t\t\t\t\tprevHeadingLevel = item.level;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DocumentOutlineItem\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\tlevel={ `H${ item.level }` }\n\t\t\t\t\t\t\tisValid={ isValid }\n\t\t\t\t\t\t\tisDisabled={ hasOutlineItemsDisabled }\n\t\t\t\t\t\t\thref={ `#block-${ item.clientId }` }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ item.isEmpty\n\t\t\t\t\t\t\t\t? emptyHeadingContent\n\t\t\t\t\t\t\t\t: getTextContent(\n\t\t\t\t\t\t\t\t\t\tcreate( {\n\t\t\t\t\t\t\t\t\t\t\thtml: item.attributes.content,\n\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t{ isIncorrectLevel && incorrectLevelContent }\n\t\t\t\t\t\t\t{ item.level === 1 &&\n\t\t\t\t\t\t\t\thasMultipleH1 &&\n\t\t\t\t\t\t\t\tmultipleH1Headings }\n\t\t\t\t\t\t\t{ hasTitle &&\n\t\t\t\t\t\t\t\titem.level === 1 &&\n\t\t\t\t\t\t\t\t! hasMultipleH1 &&\n\t\t\t\t\t\t\t\tsingleH1Headings }\n\t\t\t\t\t\t</DocumentOutlineItem>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</ul>\n\t\t</div>\n\t);\n};\n\nexport default compose(\n\twithSelect( ( select ) => {\n\t\tconst { getBlocks } = select( blockEditorStore );\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tblocks: getBlocks(),\n\t\t\tisTitleSupported: postType?.supports?.title ?? false,\n\t\t};\n\t} )\n)( DocumentOutline );\n"]}
|
|
@@ -17,6 +17,8 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
17
17
|
|
|
18
18
|
var _compose = require("@wordpress/compose");
|
|
19
19
|
|
|
20
|
+
var _hooks = require("@wordpress/hooks");
|
|
21
|
+
|
|
20
22
|
var _store = require("../../store");
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -52,6 +54,7 @@ class ErrorBoundary extends _element.Component {
|
|
|
52
54
|
this.setState({
|
|
53
55
|
error
|
|
54
56
|
});
|
|
57
|
+
(0, _hooks.doAction)('editor.ErrorBoundary.errorLogged', error);
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
reboot() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["CopyButton","text","children","ref","ErrorBoundary","Component","constructor","arguments","reboot","bind","getContent","state","error","componentDidCatch","setState","props","onError","editorStore","getEditedPostContent","render","stack"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/error-boundary/index.js"],"names":["CopyButton","text","children","ref","ErrorBoundary","Component","constructor","arguments","reboot","bind","getContent","state","error","componentDidCatch","setState","props","onError","editorStore","getEditedPostContent","render","stack"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AAGA,SAASA,UAAT,OAA0C;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AACzC,QAAMC,GAAG,GAAG,iCAAoBF,IAApB,CAAZ;AACA,SACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,MAAME,aAAN,SAA4BC,kBAA5B,CAAsC;AACrCC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AACA,SAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBD,IAAhB,CAAsB,IAAtB,CAAlB;AAEA,SAAKE,KAAL,GAAa;AACZC,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAEDC,EAAAA,iBAAiB,CAAED,KAAF,EAAU;AAC1B,SAAKE,QAAL,CAAe;AAAEF,MAAAA;AAAF,KAAf;AAEA,yBAAU,kCAAV,EAA8CA,KAA9C;AACA;;AAEDJ,EAAAA,MAAM,GAAG;AACR,SAAKO,KAAL,CAAWC,OAAX;AACA;;AAEDN,EAAAA,UAAU,GAAG;AACZ,QAAI;AACH;AACA;AACA;AACA;AACA;AACA;AACA,aAAO,kBAAQO,YAAR,EAAsBC,oBAAtB,EAAP;AACA,KARD,CAQE,OAAQN,KAAR,EAAgB,CAAE;AACpB;;AAEDO,EAAAA,MAAM,GAAG;AACR,UAAM;AAAEP,MAAAA;AAAF,QAAY,KAAKD,KAAvB;;AACA,QAAK,CAAEC,KAAP,EAAe;AACd,aAAO,KAAKG,KAAL,CAAWb,QAAlB;AACA;;AAED,WACC,4BAAC,oBAAD;AACC,MAAA,SAAS,EAAC,uBADX;AAEC,MAAA,OAAO,EAAG,CACT,4BAAC,kBAAD;AACC,QAAA,GAAG,EAAC,UADL;AAEC,QAAA,OAAO,EAAG,KAAKM,MAFhB;AAGC,QAAA,OAAO,EAAC;AAHT,SAKG,cAAI,kBAAJ,CALH,CADS,EAQT,4BAAC,UAAD;AAAY,QAAA,GAAG,EAAC,WAAhB;AAA4B,QAAA,IAAI,EAAG,KAAKE;AAAxC,SACG,cAAI,gBAAJ,CADH,CARS,EAWT,4BAAC,UAAD;AAAY,QAAA,GAAG,EAAC,YAAhB;AAA6B,QAAA,IAAI,EAAGE,KAAK,CAACQ;AAA1C,SACG,cAAI,YAAJ,CADH,CAXS;AAFX,OAkBG,cAAI,iDAAJ,CAlBH,CADD;AAsBA;;AA9DoC;;eAiEvBhB,a","sourcesContent":["/**\n * WordPress 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 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.reboot = this.reboot.bind( this );\n\t\tthis.getContent = this.getContent.bind( this );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tthis.setState( { error } );\n\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error );\n\t}\n\n\treboot() {\n\t\tthis.props.onError();\n\t}\n\n\tgetContent() {\n\t\ttry {\n\t\t\t// While `select` in a component is generally discouraged, it is\n\t\t\t// used here because it (a) reduces the chance of data loss in the\n\t\t\t// case of additional errors by performing a direct retrieval and\n\t\t\t// (b) avoids the performance cost associated with unnecessary\n\t\t\t// content serialization throughout the lifetime of a non-erroring\n\t\t\t// application.\n\t\t\treturn select( editorStore ).getEditedPostContent();\n\t\t} catch ( 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\treturn (\n\t\t\t<Warning\n\t\t\t\tclassName=\"editor-error-boundary\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"recovery\"\n\t\t\t\t\t\tonClick={ this.reboot }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Attempt Recovery' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\t<CopyButton key=\"copy-post\" text={ this.getContent }>\n\t\t\t\t\t\t{ __( 'Copy Post Text' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t] }\n\t\t\t>\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"]}
|
|
@@ -61,8 +61,13 @@ var _exportNames = {
|
|
|
61
61
|
PostTrash: true,
|
|
62
62
|
PostTrashCheck: true,
|
|
63
63
|
PostTypeSupportCheck: true,
|
|
64
|
+
PostURL: true,
|
|
65
|
+
PostURLCheck: true,
|
|
66
|
+
PostURLLabel: true,
|
|
67
|
+
usePostURLLabel: true,
|
|
64
68
|
PostVisibility: true,
|
|
65
69
|
PostVisibilityLabel: true,
|
|
70
|
+
usePostVisibilityLabel: true,
|
|
66
71
|
PostVisibilityCheck: true,
|
|
67
72
|
TableOfContents: true,
|
|
68
73
|
ThemeSupportCheck: true,
|
|
@@ -349,13 +354,13 @@ Object.defineProperty(exports, "PostTaxonomiesCheck", {
|
|
|
349
354
|
Object.defineProperty(exports, "PostTaxonomiesFlatTermSelector", {
|
|
350
355
|
enumerable: true,
|
|
351
356
|
get: function () {
|
|
352
|
-
return _flatTermSelector.
|
|
357
|
+
return _flatTermSelector.FlatTermSelector;
|
|
353
358
|
}
|
|
354
359
|
});
|
|
355
360
|
Object.defineProperty(exports, "PostTaxonomiesHierarchicalTermSelector", {
|
|
356
361
|
enumerable: true,
|
|
357
362
|
get: function () {
|
|
358
|
-
return _hierarchicalTermSelector.
|
|
363
|
+
return _hierarchicalTermSelector.HierarchicalTermSelector;
|
|
359
364
|
}
|
|
360
365
|
});
|
|
361
366
|
Object.defineProperty(exports, "PostTextEditor", {
|
|
@@ -388,6 +393,24 @@ Object.defineProperty(exports, "PostTypeSupportCheck", {
|
|
|
388
393
|
return _postTypeSupportCheck.default;
|
|
389
394
|
}
|
|
390
395
|
});
|
|
396
|
+
Object.defineProperty(exports, "PostURL", {
|
|
397
|
+
enumerable: true,
|
|
398
|
+
get: function () {
|
|
399
|
+
return _postUrl.default;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
Object.defineProperty(exports, "PostURLCheck", {
|
|
403
|
+
enumerable: true,
|
|
404
|
+
get: function () {
|
|
405
|
+
return _check14.default;
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
Object.defineProperty(exports, "PostURLLabel", {
|
|
409
|
+
enumerable: true,
|
|
410
|
+
get: function () {
|
|
411
|
+
return _label3.default;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
391
414
|
Object.defineProperty(exports, "PostVisibility", {
|
|
392
415
|
enumerable: true,
|
|
393
416
|
get: function () {
|
|
@@ -397,13 +420,13 @@ Object.defineProperty(exports, "PostVisibility", {
|
|
|
397
420
|
Object.defineProperty(exports, "PostVisibilityCheck", {
|
|
398
421
|
enumerable: true,
|
|
399
422
|
get: function () {
|
|
400
|
-
return
|
|
423
|
+
return _check15.default;
|
|
401
424
|
}
|
|
402
425
|
});
|
|
403
426
|
Object.defineProperty(exports, "PostVisibilityLabel", {
|
|
404
427
|
enumerable: true,
|
|
405
428
|
get: function () {
|
|
406
|
-
return
|
|
429
|
+
return _label4.default;
|
|
407
430
|
}
|
|
408
431
|
});
|
|
409
432
|
Object.defineProperty(exports, "TableOfContents", {
|
|
@@ -448,6 +471,18 @@ Object.defineProperty(exports, "usePostScheduleLabel", {
|
|
|
448
471
|
return _label2.usePostScheduleLabel;
|
|
449
472
|
}
|
|
450
473
|
});
|
|
474
|
+
Object.defineProperty(exports, "usePostURLLabel", {
|
|
475
|
+
enumerable: true,
|
|
476
|
+
get: function () {
|
|
477
|
+
return _label3.usePostURLLabel;
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
Object.defineProperty(exports, "usePostVisibilityLabel", {
|
|
481
|
+
enumerable: true,
|
|
482
|
+
get: function () {
|
|
483
|
+
return _label4.usePostVisibilityLabel;
|
|
484
|
+
}
|
|
485
|
+
});
|
|
451
486
|
|
|
452
487
|
var _autocompleters = require("./autocompleters");
|
|
453
488
|
|
|
@@ -555,9 +590,9 @@ var _postSwitchToDraftButton = _interopRequireDefault(require("./post-switch-to-
|
|
|
555
590
|
|
|
556
591
|
var _postTaxonomies = _interopRequireDefault(require("./post-taxonomies"));
|
|
557
592
|
|
|
558
|
-
var _flatTermSelector =
|
|
593
|
+
var _flatTermSelector = require("./post-taxonomies/flat-term-selector");
|
|
559
594
|
|
|
560
|
-
var _hierarchicalTermSelector =
|
|
595
|
+
var _hierarchicalTermSelector = require("./post-taxonomies/hierarchical-term-selector");
|
|
561
596
|
|
|
562
597
|
var _check12 = _interopRequireDefault(require("./post-taxonomies/check"));
|
|
563
598
|
|
|
@@ -571,11 +606,17 @@ var _check13 = _interopRequireDefault(require("./post-trash/check"));
|
|
|
571
606
|
|
|
572
607
|
var _postTypeSupportCheck = _interopRequireDefault(require("./post-type-support-check"));
|
|
573
608
|
|
|
609
|
+
var _postUrl = _interopRequireDefault(require("./post-url"));
|
|
610
|
+
|
|
611
|
+
var _check14 = _interopRequireDefault(require("./post-url/check"));
|
|
612
|
+
|
|
613
|
+
var _label3 = _interopRequireWildcard(require("./post-url/label"));
|
|
614
|
+
|
|
574
615
|
var _postVisibility = _interopRequireDefault(require("./post-visibility"));
|
|
575
616
|
|
|
576
|
-
var
|
|
617
|
+
var _label4 = _interopRequireWildcard(require("./post-visibility/label"));
|
|
577
618
|
|
|
578
|
-
var
|
|
619
|
+
var _check15 = _interopRequireDefault(require("./post-visibility/check"));
|
|
579
620
|
|
|
580
621
|
var _tableOfContents = _interopRequireDefault(require("./table-of-contents"));
|
|
581
622
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// Block Creation Components.\nexport * from './autocompleters';\n\n// Post Related Components.\nexport { default as AutosaveMonitor } from './autosave-monitor';\nexport { default as DocumentOutline } from './document-outline';\nexport { default as DocumentOutlineCheck } from './document-outline/check';\nexport { default as VisualEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/visual-editor-shortcuts';\nexport { default as TextEditorGlobalKeyboardShortcuts } from './global-keyboard-shortcuts/text-editor-shortcuts';\nexport { default as EditorKeyboardShortcutsRegister } from './global-keyboard-shortcuts/register-shortcuts';\nexport { default as EditorHistoryRedo } from './editor-history/redo';\nexport { default as EditorHistoryUndo } from './editor-history/undo';\nexport { default as EditorNotices } from './editor-notices';\nexport { default as EditorSnackbars } from './editor-snackbars';\nexport { default as EntitiesSavedStates } from './entities-saved-states';\nexport { default as ErrorBoundary } from './error-boundary';\nexport { default as LocalAutosaveMonitor } from './local-autosave-monitor';\nexport { default as PageAttributesCheck } from './page-attributes/check';\nexport { default as PageAttributesOrder } from './page-attributes/order';\nexport { default as PageAttributesParent } from './page-attributes/parent';\nexport { default as PageTemplate } from './post-template';\nexport { default as PostAuthor } from './post-author';\nexport { default as PostAuthorCheck } from './post-author/check';\nexport { default as PostComments } from './post-comments';\nexport { default as PostExcerpt } from './post-excerpt';\nexport { default as PostExcerptCheck } from './post-excerpt/check';\nexport { default as PostFeaturedImage } from './post-featured-image';\nexport { default as PostFeaturedImageCheck } from './post-featured-image/check';\nexport { default as PostFormat } from './post-format';\nexport { default as PostFormatCheck } from './post-format/check';\nexport { default as PostLastRevision } from './post-last-revision';\nexport { default as PostLastRevisionCheck } from './post-last-revision/check';\nexport { default as PostLockedModal } from './post-locked-modal';\nexport { default as PostPendingStatus } from './post-pending-status';\nexport { default as PostPendingStatusCheck } from './post-pending-status/check';\nexport { default as PostPingbacks } from './post-pingbacks';\nexport { default as PostPreviewButton } from './post-preview-button';\nexport { default as PostPublishButton } from './post-publish-button';\nexport { default as PostPublishButtonLabel } from './post-publish-button/label';\nexport { default as PostPublishPanel } from './post-publish-panel';\nexport { default as PostSavedState } from './post-saved-state';\nexport { default as PostSchedule } from './post-schedule';\nexport { default as PostScheduleCheck } from './post-schedule/check';\nexport {\n\tdefault as PostScheduleLabel,\n\tusePostScheduleLabel,\n} from './post-schedule/label';\nexport { default as PostSlug } from './post-slug';\nexport { default as PostSlugCheck } from './post-slug/check';\nexport { default as PostSticky } from './post-sticky';\nexport { default as PostStickyCheck } from './post-sticky/check';\nexport { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';\nexport { default as PostTaxonomies } from './post-taxonomies';\nexport { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';\nexport { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';\nexport { default as PostTaxonomiesCheck } from './post-taxonomies/check';\nexport { default as PostTextEditor } from './post-text-editor';\nexport { default as PostTitle } from './post-title';\nexport { default as PostTrash } from './post-trash';\nexport { default as PostTrashCheck } from './post-trash/check';\nexport { default as PostTypeSupportCheck } from './post-type-support-check';\nexport { default as PostURL } from './post-url';\nexport { default as PostURLCheck } from './post-url/check';\nexport { default as PostURLLabel, usePostURLLabel } from './post-url/label';\nexport { default as PostVisibility } from './post-visibility';\nexport {\n\tdefault as PostVisibilityLabel,\n\tusePostVisibilityLabel,\n} from './post-visibility/label';\nexport { default as PostVisibilityCheck } from './post-visibility/check';\nexport { default as TableOfContents } from './table-of-contents';\nexport { default as ThemeSupportCheck } from './theme-support-check';\nexport { default as UnsavedChangesWarning } from './unsaved-changes-warning';\nexport { default as WordCount } from './word-count';\n\n// State Related Components.\nexport { default as EditorProvider } from './provider';\n\nexport * from './deprecated';\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = exports.PageAttributesOrder = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _i18n = require("@wordpress/i18n");
|
|
15
13
|
|
|
16
14
|
var _components = require("@wordpress/components");
|
|
@@ -23,10 +21,6 @@ var _postTypeSupportCheck = _interopRequireDefault(require("../post-type-support
|
|
|
23
21
|
|
|
24
22
|
var _store = require("../../store");
|
|
25
23
|
|
|
26
|
-
/**
|
|
27
|
-
* External dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
24
|
/**
|
|
31
25
|
* WordPress dependencies
|
|
32
26
|
*/
|
|
@@ -42,10 +36,12 @@ const PageAttributesOrder = _ref => {
|
|
|
42
36
|
const [orderInput, setOrderInput] = (0, _element.useState)(null);
|
|
43
37
|
|
|
44
38
|
const setUpdatedOrder = value => {
|
|
39
|
+
var _value$trim;
|
|
40
|
+
|
|
45
41
|
setOrderInput(value);
|
|
46
42
|
const newOrder = Number(value);
|
|
47
43
|
|
|
48
|
-
if (Number.isInteger(newOrder) && (0
|
|
44
|
+
if (Number.isInteger(newOrder) && ((_value$trim = value.trim) === null || _value$trim === void 0 ? void 0 : _value$trim.call(value)) !== '') {
|
|
49
45
|
onUpdateOrder(Number(value));
|
|
50
46
|
}
|
|
51
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/page-attributes/order.js"],"names":["PageAttributesOrder","onUpdateOrder","order","orderInput","setOrderInput","setUpdatedOrder","value","newOrder","Number","isInteger","PageAttributesOrderWithChecks","props","select","editorStore","getEditedPostAttribute","dispatch","editPost","menu_order"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/page-attributes/order.js"],"names":["PageAttributesOrder","onUpdateOrder","order","orderInput","setOrderInput","setUpdatedOrder","value","newOrder","Number","isInteger","trim","PageAttributesOrderWithChecks","props","select","editorStore","getEditedPostAttribute","dispatch","editPost","menu_order"],"mappings":";;;;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIO,MAAMA,mBAAmB,GAAG,QAAoC;AAAA,MAAlC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,KAAK,GAAG;AAAzB,GAAkC;AACtE,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU,IAAV,CAAtC;;AAEA,QAAMC,eAAe,GAAKC,KAAF,IAAa;AAAA;;AACpCF,IAAAA,aAAa,CAAEE,KAAF,CAAb;AACA,UAAMC,QAAQ,GAAGC,MAAM,CAAEF,KAAF,CAAvB;;AACA,QAAKE,MAAM,CAACC,SAAP,CAAkBF,QAAlB,KAAgC,gBAAAD,KAAK,CAACI,IAAN,iEAAAJ,KAAK,OAAc,EAAxD,EAA6D;AAC5DL,MAAAA,aAAa,CAAEO,MAAM,CAAEF,KAAF,CAAR,CAAb;AACA;AACD,GAND;;AAOA,QAAMA,KAAK,GAAGH,UAAU,KAAK,IAAf,GAAsBD,KAAtB,GAA8BC,UAA5C;AACA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,+BADX;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,KAAK,EAAG,cAAI,OAAJ,CAHT;AAIC,IAAA,KAAK,EAAGG,KAJT;AAKC,IAAA,QAAQ,EAAGD,eALZ;AAMC,IAAA,IAAI,EAAG,CANR;AAOC,IAAA,MAAM,EAAG,MAAM;AACdD,MAAAA,aAAa,CAAE,IAAF,CAAb;AACA;AATF,IADD;AAaA,CAxBM;;;;AA0BP,SAASO,6BAAT,CAAwCC,KAAxC,EAAgD;AAC/C,SACC,4BAAC,6BAAD;AAAsB,IAAA,WAAW,EAAC;AAAlC,KACC,4BAAC,mBAAD,EAA0BA,KAA1B,CADD,CADD;AAKA;;eAEc,sBAAS,CACvB,sBAAcC,MAAF,IAAc;AACzB,SAAO;AACNX,IAAAA,KAAK,EAAEW,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,YAA9C;AADD,GAAP;AAGA,CAJD,CADuB,EAMvB,wBAAgBC,QAAF,KAAkB;AAC/Bf,EAAAA,aAAa,CAAEC,KAAF,EAAU;AACtBc,IAAAA,QAAQ,CAAEF,YAAF,CAAR,CAAwBG,QAAxB,CAAkC;AACjCC,MAAAA,UAAU,EAAEhB;AADqB,KAAlC;AAGA;;AAL8B,CAAlB,CAAd,CANuB,CAAT,EAaVS,6BAbU,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\nexport const PageAttributesOrder = ( { onUpdateOrder, order = 0 } ) => {\n\tconst [ orderInput, setOrderInput ] = useState( null );\n\n\tconst setUpdatedOrder = ( value ) => {\n\t\tsetOrderInput( value );\n\t\tconst newOrder = Number( value );\n\t\tif ( Number.isInteger( newOrder ) && value.trim?.() !== '' ) {\n\t\t\tonUpdateOrder( Number( value ) );\n\t\t}\n\t};\n\tconst value = orderInput === null ? order : orderInput;\n\treturn (\n\t\t<TextControl\n\t\t\tclassName=\"editor-page-attributes__order\"\n\t\t\ttype=\"number\"\n\t\t\tlabel={ __( 'Order' ) }\n\t\t\tvalue={ value }\n\t\t\tonChange={ setUpdatedOrder }\n\t\t\tsize={ 6 }\n\t\t\tonBlur={ () => {\n\t\t\t\tsetOrderInput( null );\n\t\t\t} }\n\t\t/>\n\t);\n};\n\nfunction PageAttributesOrderWithChecks( props ) {\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"page-attributes\">\n\t\t\t<PageAttributesOrder { ...props } />\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\torder: select( editorStore ).getEditedPostAttribute( 'menu_order' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tonUpdateOrder( order ) {\n\t\t\tdispatch( editorStore ).editPost( {\n\t\t\t\tmenu_order: order,\n\t\t\t} );\n\t\t},\n\t} ) ),\n] )( PageAttributesOrderWithChecks );\n"]}
|
|
@@ -111,7 +111,7 @@ function PageAttributesParent() {
|
|
|
111
111
|
let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
112
112
|
const mappedNodes = tree.map(treeNode => [{
|
|
113
113
|
value: treeNode.id,
|
|
114
|
-
label:
|
|
114
|
+
label: '— '.repeat(level) + (0, _lodash.unescape)(treeNode.name),
|
|
115
115
|
rawName: treeNode.name
|
|
116
116
|
}, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
|
|
117
117
|
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","rawName","children","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","parent","opts","optsHasParent","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;;;;;;;AAiBA;;AAdA;;AAYA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAUA;AACA;AACA;;AAQA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,IAAnB,EAA0B;AAAA;;AACzB,SAAOA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,mBAAAA,IAAI,CAAEC,KAAN,oDAAaC,QAAb,GACJ,kCAAgBF,IAAI,CAACC,KAAL,CAAWC,QAA3B,CADI,GAEH,IAAIF,IAAI,CAACG,EAAI,KAAK,cAAI,UAAJ,CAAkB,GAFxC;AAGA;;AAEM,MAAMC,eAAe,GAAG,CAAEC,IAAF,EAAQC,WAAR,KAAyB;AACvD,QAAMC,cAAc,GAAG,oBAAQF,IAAR,EAAeG,WAAf,EAAvB;AACA,QAAMC,gBAAgB,GAAG,oBAAQH,WAAR,EAAsBE,WAAtB,EAAzB;;AACA,MAAKD,cAAc,KAAKE,gBAAxB,EAA2C;AAC1C,WAAO,CAAP;AACA;;AAED,MAAKF,cAAc,CAACG,UAAf,CAA2BD,gBAA3B,CAAL,EAAqD;AACpD,WAAOF,cAAc,CAACI,MAAtB;AACA;;AAED,SAAOC,QAAP;AACA,CAZM;;;;AA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M,EAAEO;AAAV,KAAF,CAAR;AACA,GAFD;;AAIA,SACC,4BAAC,2BAAD;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,KAAK,EAAG5B,eAFT;AAGC,IAAA,KAAK,EAAGvB,YAHT;AAIC,IAAA,OAAO,EAAGyB,aAJX;AAKC,IAAA,mBAAmB,EAAG,sBAAUuB,aAAV,EAAyB,GAAzB,CALvB;AAMC,IAAA,QAAQ,EAAGE;AANZ,IADD;AAUA;;eAEcxD,oB","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tget,\n\tunescape as unescapeString,\n\tdebounce,\n\trepeat,\n\tfind,\n\tdeburr,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\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 = deburr( name ).toLowerCase();\n\tconst normalizedSearch = deburr( 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\trepeat( '— ', 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 = find(\n\t\t\topts,\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\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","unshift","handleKeydown","inputValue","handleChange","selectedPostId"],"mappings":";;;;;;;;AAgBA;;AAbA;;AAWA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AAzBA;AACA;AACA;;AASA;AACA;AACA;;AAQA;AACA;AACA;AAIA,SAASA,QAAT,CAAmBC,IAAnB,EAA0B;AAAA;;AACzB,SAAOA,IAAI,SAAJ,IAAAA,IAAI,WAAJ,mBAAAA,IAAI,CAAEC,KAAN,oDAAaC,QAAb,GACJ,kCAAgBF,IAAI,CAACC,KAAL,CAAWC,QAA3B,CADI,GAEH,IAAIF,IAAI,CAACG,EAAI,KAAK,cAAI,UAAJ,CAAkB,GAFxC;AAGA;;AAEM,MAAMC,eAAe,GAAG,CAAEC,IAAF,EAAQC,WAAR,KAAyB;AACvD,QAAMC,cAAc,GAAG,oBAAQF,IAAR,EAAeG,WAAf,EAAvB;AACA,QAAMC,gBAAgB,GAAG,oBAAQH,WAAR,EAAsBE,WAAtB,EAAzB;;AACA,MAAKD,cAAc,KAAKE,gBAAxB,EAA2C;AAC1C,WAAO,CAAP;AACA;;AAED,MAAKF,cAAc,CAACG,UAAf,CAA2BD,gBAA3B,CAAL,EAAqD;AACpD,WAAOF,cAAc,CAACI,MAAtB;AACA;;AAED,SAAOC,QAAP;AACA,CAZM;;;;AAcA,SAASC,oBAAT,GAAgC;AACtC,QAAM;AAAEC,IAAAA;AAAF,M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C,2BAAD;AACC,IAAA,SAAS,EAAC,gCADX;AAEC,IAAA,KAAK,EAAG7B,eAFT;AAGC,IAAA,KAAK,EAAGvB,YAHT;AAIC,IAAA,OAAO,EAAGyB,aAJX;AAKC,IAAA,mBAAmB,EAAG,sBAAUwB,aAAV,EAAyB,GAAzB,CALvB;AAMC,IAAA,QAAQ,EAAGE;AANZ,IADD;AAUA;;eAEczD,oB","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tget,\n\tunescape as unescapeString,\n\tdebounce,\n\tfind,\n\tdeburr,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ComboboxControl } from '@wordpress/components';\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 = deburr( name ).toLowerCase();\n\tconst normalizedSearch = deburr( 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 = find(\n\t\t\topts,\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\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"]}
|
|
@@ -122,11 +122,8 @@ function PostFormat() {
|
|
|
122
122
|
|
|
123
123
|
return (0, _element.createElement)(_check.default, null, (0, _element.createElement)("div", {
|
|
124
124
|
className: "editor-post-format"
|
|
125
|
-
}, (0, _element.createElement)(
|
|
126
|
-
|
|
127
|
-
}, (0, _element.createElement)("label", {
|
|
128
|
-
htmlFor: postFormatSelectorId
|
|
129
|
-
}, (0, _i18n.__)('Post Format')), (0, _element.createElement)(_components.SelectControl, {
|
|
125
|
+
}, (0, _element.createElement)(_components.SelectControl, {
|
|
126
|
+
label: (0, _i18n.__)('Post Format'),
|
|
130
127
|
value: postFormat,
|
|
131
128
|
onChange: format => onUpdatePostFormat(format),
|
|
132
129
|
id: postFormatSelectorId,
|
|
@@ -134,13 +131,13 @@ function PostFormat() {
|
|
|
134
131
|
label: format.caption,
|
|
135
132
|
value: format.id
|
|
136
133
|
}))
|
|
137
|
-
})
|
|
134
|
+
}), suggestion && suggestion.id !== postFormat && (0, _element.createElement)("p", {
|
|
138
135
|
className: "editor-post-format__suggestion"
|
|
139
|
-
}, (0,
|
|
136
|
+
}, (0, _element.createElement)(_components.Button, {
|
|
140
137
|
variant: "link",
|
|
141
138
|
onClick: () => onUpdatePostFormat(suggestion.id)
|
|
142
139
|
}, (0, _i18n.sprintf)(
|
|
143
140
|
/* translators: %s: post format */
|
|
144
|
-
(0, _i18n.__)('Apply format: %s'), suggestion.caption)))));
|
|
141
|
+
(0, _i18n.__)('Apply suggested format: %s'), suggestion.caption)))));
|
|
145
142
|
}
|
|
146
143
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-format/index.js"],"names":["POST_FORMATS","id","caption","sort","a","b","normalizedA","toUpperCase","normalizedB","PostFormat","instanceId","postFormatSelectorId","postFormat","suggestedFormat","supportedFormats","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","_postFormat","themeSupports","coreStore","getThemeSupports","formats","filter","format","suggestion","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AA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AAK,IAAA,SAAS,EAAC;AAAf,KACC
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-format/index.js"],"names":["POST_FORMATS","id","caption","sort","a","b","normalizedA","toUpperCase","normalizedB","PostFormat","instanceId","postFormatSelectorId","postFormat","suggestedFormat","supportedFormats","select","getEditedPostAttribute","getSuggestedPostFormat","editorStore","_postFormat","themeSupports","coreStore","getThemeSupports","formats","filter","format","suggestion","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AAIA;AACO,MAAMA,YAAY,GAAG,CAC3B;AAAEC,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAD2B,EAE3B;AAAED,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAF2B,EAG3B;AAAED,EAAAA,EAAE,EAAE,MAAN;AAAcC,EAAAA,OAAO,EAAE,cAAI,MAAJ;AAAvB,CAH2B,EAI3B;AAAED,EAAAA,EAAE,EAAE,SAAN;AAAiBC,EAAAA,OAAO,EAAE,cAAI,SAAJ;AAA1B,CAJ2B,EAK3B;AAAED,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAL2B,EAM3B;AAAED,EAAAA,EAAE,EAAE,MAAN;AAAcC,EAAAA,OAAO,EAAE,cAAI,MAAJ;AAAvB,CAN2B,EAO3B;AAAED,EAAAA,EAAE,EAAE,OAAN;AAAeC,EAAAA,OAAO,EAAE,cAAI,OAAJ;AAAxB,CAP2B,EAQ3B;AAAED,EAAAA,EAAE,EAAE,UAAN;AAAkBC,EAAAA,OAAO,EAAE,cAAI,UAAJ;AAA3B,CAR2B,EAS3B;AAAED,EAAAA,EAAE,EAAE,QAA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AClD;AACA;AACA,WACC,sBAAUX,gBAAV,EAA4BW,MAAM,CAACxB,EAAnC,KAA2CW,UAAU,KAAKa,MAAM,CAACxB,EADlE;AAGA,GANe,CAAhB;AAOA,QAAMyB,UAAU,GAAG,kBAClBH,OADkB,EAEhBE,MAAF,IAAcA,MAAM,CAACxB,EAAP,KAAcY,eAFV,CAAnB;AAKA,QAAM;AAAEc,IAAAA;AAAF,MAAe,uBAAaT,YAAb,CAArB;;AAEA,QAAMU,kBAAkB,GAAKH,MAAF,IAAcE,QAAQ,CAAE;AAAEF,IAAAA;AAAF,GAAF,CAAjD;;AAEA,SACC,4BAAC,cAAD,QACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,IAAA,KAAK,EAAGb,UAFT;AAGC,IAAA,QAAQ,EAAKa,MAAF,IAAcG,kBAAkB,CAAEH,MAAF,CAH5C;AAIC,IAAA,EAAE,EAAGd,oBAJN;AAKC,IAAA,OAAO,EAAGY,OAAO,CAACM,GAAR,CAAeJ,MAAF,KAAgB;AACtCK,MAAAA,KAAK,EAAEL,MAAM,CAACvB,OADwB;AAEtC6B,MAAAA,KAAK,EAAEN,MAAM,CAACxB;AAFwB,KAAhB,CAAb;AALX,IADD,EAWGyB,UAAU,IAAIA,UAAU,CAACzB,EAAX,KAAkBW,UAAhC,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MACTgB,kBAAkB,CAAEF,UAAU,CAACzB,EAAb;AAHpB,KAMG;AACD;AACA,gBAAI,4BAAJ,CAFC,EAGDyB,UAAU,CAACxB,OAHV,CANH,CADD,CAZF,CADD,CADD;AAgCA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, includes } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button, SelectControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFormatCheck from './check';\nimport { store as editorStore } from '../../store';\n\n// All WP post formats, sorted alphabetically by translated name.\nexport const POST_FORMATS = [\n\t{ id: 'aside', caption: __( 'Aside' ) },\n\t{ id: 'audio', caption: __( 'Audio' ) },\n\t{ id: 'chat', caption: __( 'Chat' ) },\n\t{ id: 'gallery', caption: __( 'Gallery' ) },\n\t{ id: 'image', caption: __( 'Image' ) },\n\t{ id: 'link', caption: __( 'Link' ) },\n\t{ id: 'quote', caption: __( 'Quote' ) },\n\t{ id: 'standard', caption: __( 'Standard' ) },\n\t{ id: 'status', caption: __( 'Status' ) },\n\t{ id: 'video', caption: __( 'Video' ) },\n].sort( ( a, b ) => {\n\tconst normalizedA = a.caption.toUpperCase();\n\tconst normalizedB = b.caption.toUpperCase();\n\n\tif ( normalizedA < normalizedB ) {\n\t\treturn -1;\n\t}\n\tif ( normalizedA > normalizedB ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n} );\n\nexport default function PostFormat() {\n\tconst instanceId = useInstanceId( PostFormat );\n\tconst postFormatSelectorId = `post-format-selector-${ instanceId }`;\n\n\tconst { postFormat, suggestedFormat, supportedFormats } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostAttribute, getSuggestedPostFormat } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst _postFormat = getEditedPostAttribute( 'format' );\n\t\t\tconst themeSupports = select( coreStore ).getThemeSupports();\n\t\t\treturn {\n\t\t\t\tpostFormat: _postFormat ?? 'standard',\n\t\t\t\tsuggestedFormat: getSuggestedPostFormat(),\n\t\t\t\tsupportedFormats: themeSupports.formats,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst formats = POST_FORMATS.filter( ( format ) => {\n\t\t// Ensure current format is always in the set.\n\t\t// The current format may not be a format supported by the theme.\n\t\treturn (\n\t\t\tincludes( supportedFormats, format.id ) || postFormat === format.id\n\t\t);\n\t} );\n\tconst suggestion = find(\n\t\tformats,\n\t\t( format ) => format.id === suggestedFormat\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tconst onUpdatePostFormat = ( format ) => editPost( { format } );\n\n\treturn (\n\t\t<PostFormatCheck>\n\t\t\t<div className=\"editor-post-format\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'Post Format' ) }\n\t\t\t\t\tvalue={ postFormat }\n\t\t\t\t\tonChange={ ( format ) => onUpdatePostFormat( format ) }\n\t\t\t\t\tid={ postFormatSelectorId }\n\t\t\t\t\toptions={ formats.map( ( format ) => ( {\n\t\t\t\t\t\tlabel: format.caption,\n\t\t\t\t\t\tvalue: format.id,\n\t\t\t\t\t} ) ) }\n\t\t\t\t/>\n\t\t\t\t{ suggestion && suggestion.id !== postFormat && (\n\t\t\t\t\t<p className=\"editor-post-format__suggestion\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tonUpdatePostFormat( suggestion.id )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: post format */\n\t\t\t\t\t\t\t\t__( 'Apply suggested format: %s' ),\n\t\t\t\t\t\t\t\tsuggestion.caption\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</PostFormatCheck>\n\t);\n}\n"]}
|
|
@@ -27,10 +27,10 @@ function PostScheduleLabel(props) {
|
|
|
27
27
|
return usePostScheduleLabel(props);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function usePostScheduleLabel(
|
|
30
|
+
function usePostScheduleLabel() {
|
|
31
31
|
let {
|
|
32
|
-
full
|
|
33
|
-
} =
|
|
32
|
+
full = false
|
|
33
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
34
34
|
const {
|
|
35
35
|
date,
|
|
36
36
|
isFloating
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/label.js"],"names":["PostScheduleLabel","props","usePostScheduleLabel","full","date","isFloating","select","editorStore","getEditedPostAttribute","isEditedPostDateFloating","getFullPostScheduleLabel","getPostScheduleLabel","dateAttribute","timezoneAbbreviation","getTimezoneAbbreviation","formattedDate","now","Date","isTimezoneSameAsSiteTimezone","isSameDay","tomorrow","setDate","getDate","getFullYear","timezone","abbr","isNaN","Number","symbol","offset","siteOffset","dateOffset","getTimezoneOffset","left","right","getMonth"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,iBAAT,CAA4BC,KAA5B,EAAoC;AAClD,SAAOC,oBAAoB,CAAED,KAAF,CAA3B;AACA;;AAEM,SAASC,oBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/editor/src/components/post-schedule/label.js"],"names":["PostScheduleLabel","props","usePostScheduleLabel","full","date","isFloating","select","editorStore","getEditedPostAttribute","isEditedPostDateFloating","getFullPostScheduleLabel","getPostScheduleLabel","dateAttribute","timezoneAbbreviation","getTimezoneAbbreviation","formattedDate","now","Date","isTimezoneSameAsSiteTimezone","isSameDay","tomorrow","setDate","getDate","getFullYear","timezone","abbr","isNaN","Number","symbol","offset","siteOffset","dateOffset","getTimezoneOffset","left","right","getMonth"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,iBAAT,CAA4BC,KAA5B,EAAoC;AAClD,SAAOC,oBAAoB,CAAED,KAAF,CAA3B;AACA;;AAEM,SAASC,oBAAT,GAAuD;AAAA,MAAxB;AAAEC,IAAAA,IAAI,GA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X,CAAzB;AACA,QAAME,UAAU,GAAG,CAAC,CAAD,IAAO3B,IAAI,CAAC4B,iBAAL,KAA2B,EAAlC,CAAnB;AACA,SAAOF,UAAU,KAAKC,UAAtB;AACA;;AAED,SAASZ,SAAT,CAAoBc,IAApB,EAA0BC,KAA1B,EAAkC;AACjC,SACCD,IAAI,CAACX,OAAL,OAAmBY,KAAK,CAACZ,OAAN,EAAnB,IACAW,IAAI,CAACE,QAAL,OAAoBD,KAAK,CAACC,QAAN,EADpB,IAEAF,IAAI,CAACV,WAAL,OAAuBW,KAAK,CAACX,WAAN,EAHxB;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { __experimentalGetSettings, getDate, dateI18n } from '@wordpress/date';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostScheduleLabel( props ) {\n\treturn usePostScheduleLabel( props );\n}\n\nexport function usePostScheduleLabel( { full = false } = {} ) {\n\tconst { date, isFloating } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tisFloating: select( editorStore ).isEditedPostDateFloating(),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn full\n\t\t? getFullPostScheduleLabel( date )\n\t\t: getPostScheduleLabel( date, { isFloating } );\n}\n\nexport function getFullPostScheduleLabel( dateAttribute ) {\n\tconst date = getDate( dateAttribute );\n\n\tconst timezoneAbbreviation = getTimezoneAbbreviation();\n\tconst formattedDate = dateI18n(\n\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n\treturn isRTL()\n\t\t? `${ timezoneAbbreviation } ${ formattedDate }`\n\t\t: `${ formattedDate } ${ timezoneAbbreviation }`;\n}\n\nexport function getPostScheduleLabel(\n\tdateAttribute,\n\t{ isFloating = false, now = new Date() } = {}\n) {\n\tif ( ! dateAttribute || isFloating ) {\n\t\treturn __( 'Immediately' );\n\t}\n\n\t// If the user timezone does not equal the site timezone then using words\n\t// like 'tomorrow' is confusing, so show the full date.\n\tif ( ! isTimezoneSameAsSiteTimezone( now ) ) {\n\t\treturn getFullPostScheduleLabel( dateAttribute );\n\t}\n\n\tconst date = getDate( dateAttribute );\n\n\tif ( isSameDay( date, now ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Today at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tconst tomorrow = new Date( now );\n\ttomorrow.setDate( tomorrow.getDate() + 1 );\n\n\tif ( isSameDay( date, tomorrow ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Tomorrow at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tif ( date.getFullYear() === now.getFullYear() ) {\n\t\treturn dateI18n(\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking sapce.\n\t\t\t_x( 'F j g:i\\xa0a', 'post schedule date format without year' ),\n\t\t\tdate\n\t\t);\n\t}\n\n\treturn dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n}\n\nfunction getTimezoneAbbreviation() {\n\tconst { timezone } = __experimentalGetSettings();\n\n\tif ( timezone.abbr && isNaN( Number( timezone.abbr ) ) ) {\n\t\treturn timezone.abbr;\n\t}\n\n\tconst symbol = timezone.offset < 0 ? '' : '+';\n\treturn `UTC${ symbol }${ timezone.offset }`;\n}\n\nfunction isTimezoneSameAsSiteTimezone( date ) {\n\tconst { timezone } = __experimentalGetSettings();\n\n\tconst siteOffset = Number( timezone.offset );\n\tconst dateOffset = -1 * ( date.getTimezoneOffset() / 60 );\n\treturn siteOffset === dateOffset;\n}\n\nfunction isSameDay( left, right ) {\n\treturn (\n\t\tleft.getDate() === right.getDate() &&\n\t\tleft.getMonth() === right.getMonth() &&\n\t\tleft.getFullYear() === right.getFullYear()\n\t);\n}\n"]}
|
|
@@ -17,6 +17,8 @@ var _compose = require("@wordpress/compose");
|
|
|
17
17
|
|
|
18
18
|
var _url = require("@wordpress/url");
|
|
19
19
|
|
|
20
|
+
var _components = require("@wordpress/components");
|
|
21
|
+
|
|
20
22
|
var _check = _interopRequireDefault(require("./check"));
|
|
21
23
|
|
|
22
24
|
var _store = require("../../store");
|
|
@@ -60,26 +62,19 @@ class PostSlug extends _element.Component {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
render() {
|
|
63
|
-
const {
|
|
64
|
-
instanceId
|
|
65
|
-
} = this.props;
|
|
66
65
|
const {
|
|
67
66
|
editedSlug
|
|
68
67
|
} = this.state;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
htmlFor: inputId
|
|
72
|
-
}, (0, _i18n.__)('Slug')), (0, _element.createElement)("input", {
|
|
68
|
+
return (0, _element.createElement)(_check.default, null, (0, _element.createElement)(_components.TextControl, {
|
|
69
|
+
label: (0, _i18n.__)('Slug'),
|
|
73
70
|
autoComplete: "off",
|
|
74
71
|
spellCheck: "false",
|
|
75
|
-
type: "text",
|
|
76
|
-
id: inputId,
|
|
77
72
|
value: editedSlug,
|
|
78
|
-
onChange:
|
|
79
|
-
editedSlug:
|
|
73
|
+
onChange: slug => this.setState({
|
|
74
|
+
editedSlug: slug
|
|
80
75
|
}),
|
|
81
76
|
onBlur: this.setSlug,
|
|
82
|
-
className: "editor-post-
|
|
77
|
+
className: "editor-post-slug"
|
|
83
78
|
}));
|
|
84
79
|
}
|
|
85
80
|
|
|
@@ -112,7 +107,7 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
};
|
|
115
|
-
})
|
|
110
|
+
})])(PostSlug);
|
|
116
111
|
|
|
117
112
|
exports.default = _default;
|
|
118
113
|
//# sourceMappingURL=index.js.map
|