@wordpress/editor 13.1.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/error-boundary/index.js +24 -30
  4. package/build/components/error-boundary/index.js.map +1 -1
  5. package/build/components/media-categories/index.js +237 -0
  6. package/build/components/media-categories/index.js.map +1 -0
  7. package/build/components/page-attributes/parent.js +1 -1
  8. package/build/components/page-attributes/parent.js.map +1 -1
  9. package/build/components/post-author/select.js +1 -0
  10. package/build/components/post-author/select.js.map +1 -1
  11. package/build/components/post-format/index.js +1 -0
  12. package/build/components/post-format/index.js.map +1 -1
  13. package/build/components/post-publish-panel/postpublish.js +1 -0
  14. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  15. package/build/components/post-slug/index.js +1 -0
  16. package/build/components/post-slug/index.js.map +1 -1
  17. package/build/components/post-taxonomies/hierarchical-term-selector.js +7 -3
  18. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  19. package/build/components/post-template/index.js +8 -4
  20. package/build/components/post-template/index.js.map +1 -1
  21. package/build/components/post-url/index.js +1 -0
  22. package/build/components/post-url/index.js.map +1 -1
  23. package/build/components/provider/index.js +26 -8
  24. package/build/components/provider/index.js.map +1 -1
  25. package/build/components/provider/index.native.js +21 -14
  26. package/build/components/provider/index.native.js.map +1 -1
  27. package/build/components/provider/use-block-editor-settings.js +7 -4
  28. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  29. package/build/components/provider/use-block-editor-settings.native.js +1 -2
  30. package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
  31. package/build/components/table-of-contents/index.js +3 -1
  32. package/build/components/table-of-contents/index.js.map +1 -1
  33. package/build/components/unsaved-changes-warning/index.js +1 -1
  34. package/build/components/unsaved-changes-warning/index.js.map +1 -1
  35. package/build/experiments.js +20 -0
  36. package/build/experiments.js.map +1 -0
  37. package/build/hooks/custom-sources-backwards-compatibility.js +16 -8
  38. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  39. package/build/hooks/default-autocompleters.js +2 -7
  40. package/build/hooks/default-autocompleters.js.map +1 -1
  41. package/build/index.js +14 -0
  42. package/build/index.js.map +1 -1
  43. package/build/index.native.js +14 -0
  44. package/build/index.native.js.map +1 -1
  45. package/build/lockUnlock.js +19 -0
  46. package/build/lockUnlock.js.map +1 -0
  47. package/build/store/defaults.js +1 -2
  48. package/build/store/defaults.js.map +1 -1
  49. package/build/store/selectors.js +1 -1
  50. package/build/store/selectors.js.map +1 -1
  51. package/build/utils/terms.js +9 -5
  52. package/build/utils/terms.js.map +1 -1
  53. package/build-module/components/error-boundary/index.js +24 -30
  54. package/build-module/components/error-boundary/index.js.map +1 -1
  55. package/build-module/components/media-categories/index.js +225 -0
  56. package/build-module/components/media-categories/index.js.map +1 -0
  57. package/build-module/components/page-attributes/parent.js +2 -2
  58. package/build-module/components/page-attributes/parent.js.map +1 -1
  59. package/build-module/components/post-author/select.js +1 -0
  60. package/build-module/components/post-author/select.js.map +1 -1
  61. package/build-module/components/post-format/index.js +1 -0
  62. package/build-module/components/post-format/index.js.map +1 -1
  63. package/build-module/components/post-publish-panel/postpublish.js +1 -0
  64. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  65. package/build-module/components/post-slug/index.js +1 -0
  66. package/build-module/components/post-slug/index.js.map +1 -1
  67. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +8 -5
  68. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  69. package/build-module/components/post-template/index.js +9 -5
  70. package/build-module/components/post-template/index.js.map +1 -1
  71. package/build-module/components/post-url/index.js +1 -0
  72. package/build-module/components/post-url/index.js.map +1 -1
  73. package/build-module/components/provider/index.js +21 -9
  74. package/build-module/components/provider/index.js.map +1 -1
  75. package/build-module/components/provider/index.native.js +20 -12
  76. package/build-module/components/provider/index.native.js.map +1 -1
  77. package/build-module/components/provider/use-block-editor-settings.js +5 -5
  78. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  79. package/build-module/components/provider/use-block-editor-settings.native.js +1 -2
  80. package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
  81. package/build-module/components/table-of-contents/index.js +3 -1
  82. package/build-module/components/table-of-contents/index.js.map +1 -1
  83. package/build-module/components/unsaved-changes-warning/index.js +1 -1
  84. package/build-module/components/unsaved-changes-warning/index.js.map +1 -1
  85. package/build-module/experiments.js +10 -0
  86. package/build-module/experiments.js.map +1 -0
  87. package/build-module/hooks/custom-sources-backwards-compatibility.js +17 -9
  88. package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  89. package/build-module/hooks/default-autocompleters.js +2 -6
  90. package/build-module/hooks/default-autocompleters.js.map +1 -1
  91. package/build-module/index.js +1 -0
  92. package/build-module/index.js.map +1 -1
  93. package/build-module/index.native.js +1 -0
  94. package/build-module/index.native.js.map +1 -1
  95. package/build-module/lockUnlock.js +9 -0
  96. package/build-module/lockUnlock.js.map +1 -0
  97. package/build-module/store/defaults.js +1 -2
  98. package/build-module/store/defaults.js.map +1 -1
  99. package/build-module/store/selectors.js +1 -1
  100. package/build-module/store/selectors.js.map +1 -1
  101. package/build-module/utils/terms.js +9 -6
  102. package/build-module/utils/terms.js.map +1 -1
  103. package/build-style/style-rtl.css +0 -3
  104. package/build-style/style.css +0 -3
  105. package/package.json +30 -29
  106. package/src/components/autosave-monitor/test/index.js +8 -2
  107. package/src/components/editor-help/test/index.native.js +5 -5
  108. package/src/components/error-boundary/index.js +24 -37
  109. package/src/components/media-categories/index.js +247 -0
  110. package/src/components/page-attributes/parent.js +2 -2
  111. package/src/components/page-attributes/test/order.js +4 -14
  112. package/src/components/post-author/select.js +1 -0
  113. package/src/components/post-format/index.js +1 -0
  114. package/src/components/post-preview-button/test/index.js +5 -17
  115. package/src/components/post-publish-button/test/index.js +5 -17
  116. package/src/components/post-publish-panel/postpublish.js +1 -0
  117. package/src/components/post-publish-panel/style.scss +1 -5
  118. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -18
  119. package/src/components/post-saved-state/test/index.js +1 -5
  120. package/src/components/post-slug/index.js +1 -0
  121. package/src/components/post-taxonomies/hierarchical-term-selector.js +23 -17
  122. package/src/components/post-template/index.js +4 -4
  123. package/src/components/post-url/index.js +1 -0
  124. package/src/components/provider/index.js +120 -91
  125. package/src/components/provider/index.native.js +26 -17
  126. package/src/components/provider/use-block-editor-settings.js +60 -49
  127. package/src/components/provider/use-block-editor-settings.native.js +1 -2
  128. package/src/components/table-of-contents/index.js +3 -1
  129. package/src/components/unsaved-changes-warning/index.js +1 -1
  130. package/src/experiments.js +10 -0
  131. package/src/hooks/custom-sources-backwards-compatibility.js +16 -13
  132. package/src/hooks/default-autocompleters.js +1 -6
  133. package/src/index.js +1 -0
  134. package/src/index.native.js +1 -0
  135. package/src/lockUnlock.js +9 -0
  136. package/src/store/defaults.js +0 -1
  137. package/src/store/selectors.js +1 -1
  138. package/src/utils/terms.js +8 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 13.3.0 (2023-02-01)
6
+
7
+ ## 13.2.0 (2023-01-11)
8
+
5
9
  ## 13.1.0 (2023-01-02)
6
10
 
7
11
  ## 13.0.0 (2022-12-14)
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2022 by the contributors
3
+ Copyright 2016-2023 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
@@ -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
- reboot() {
61
- this.props.onError();
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: [(0, _element.createElement)(_components.Button, {
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":["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"]}
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,oBAAtB,EAAP;AACA,GARD,CAQE,OAAQC,KAAR,EAAgB,CAAE;AACpB;;AAED,SAASC,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,KAAL,GAAa;AACZT,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAEDU,EAAAA,iBAAiB,CAAEV,KAAF,EAAU;AAC1B,yBAAU,kCAAV,EAA8CA,KAA9C;AACA;;AAE8B,SAAxBW,wBAAwB,CAAEX,KAAF,EAAU;AACxC,WAAO;AAAEA,MAAAA;AAAF,KAAP;AACA;;AAEDY,EAAAA,MAAM,GAAG;AACR,UAAM;AAAEZ,MAAAA;AAAF,QAAY,KAAKS,KAAvB;;AACA,QAAK,CAAET,KAAP,EAAe;AACd,aAAO,KAAKa,KAAL,CAAWV,QAAlB;AACA;;AAED,UAAMW,OAAO,GAAG,CACf,4BAAC,UAAD;AAAY,MAAA,GAAG,EAAC,WAAhB;AAA4B,MAAA,IAAI,EAAGjB;AAAnC,OACG,cAAI,gBAAJ,CADH,CADe,EAIf,4BAAC,UAAD;AAAY,MAAA,GAAG,EAAC,YAAhB;AAA6B,MAAA,IAAI,EAAGG,KAAK,CAACe;AAA1C,OACG,cAAI,YAAJ,CADH,CAJe,CAAhB;AASA,WACC,4BAAC,oBAAD;AAAS,MAAA,SAAS,EAAC,uBAAnB;AAA2C,MAAA,OAAO,EAAGD;AAArD,OACG,cAAI,iDAAJ,CADH,CADD;AAKA;;AArCoC;;eAwCvBT,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 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,CAM1D;AACA;AACA;;;AACA,MAAKJ,cAAL,EAAsB;AACrBC,IAAAA,WAAW,IAAK,IAAID,cAAgB,EAApC;AACA,GAXyD,CAY1D;;;AACA,MAAK,CAAE,CAAE,KAAF,EAAS,KAAT,EAAiBK,QAAjB,CAA2BN,OAA3B,CAAP,EAA8C;AAC7CE,IAAAA,WAAW,GAAI,MAAMA,WAAa,EAAlC;A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,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, _lodash.unescape)(treeNode.name),
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,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,4BAAeF,IAAI,IAAI,EAAvB,EAA4BG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AAEiB,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;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,4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b,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"]}
@@ -58,6 +58,7 @@ function PostAuthorSelect() {
58
58
  };
59
59
 
60
60
  return (0, _element.createElement)(_components.SelectControl, {
61
+ __nextHasNoMarginBottom: true,
61
62
  className: "post-author-selector",
62
63
  label: (0, _i18n.__)('Author'),
63
64
  options: authorOptions,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-author/select.js"],"names":["PostAuthorSelect","editPost","editorStore","postAuthor","authors","select","getEditedPostAttribute","coreStore","getUsers","AUTHORS_QUERY","authorOptions","map","author","value","id","label","name","setAuthorId","Number"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;AAIA,SAASA,gBAAT,GAA4B;AAC3B,QAAM;AAAEC,IAAAA;AAAF,MAAe,uBAAaC,YAAb,CAArB;AACA,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA0B,qBAAaC,MAAF,IAAc;AACxD,WAAO;AACNF,MAAAA,UAAU,EACTE,MAAM,CAAEH,YAAF,CAAN,CAAsBI,sBAAtB,CAA8C,QAA9C,CAFK;AAGNF,MAAAA,OAAO,EAAEC,MAAM,CAAEE,eAAF,CAAN,CAAoBC,QAApB,CAA8BC,wBAA9B;AAHH,KAAP;AAKA,GAN+B,EAM7B,EAN6B,CAAhC;AAQA,QAAMC,aAAa,GAAG,sBAAS,MAAM;AACpC,WAAO,CAAEN,OAAF,aAAEA,OAAF,cAAEA,OAAF,GAAa,EAAb,EAAkBO,GAAlB,CAAyBC,MAAF,IAAc;AAC3C,aAAO;AACNC,QAAAA,KAAK,EAAED,MAAM,CAACE,EADR;AAENC,QAAAA,KAAK,EAAE,kCAAgBH,MAAM,CAACI,IAAvB;AAFD,OAAP;AAIA,KALM,CAAP;AAMA,GAPqB,EAOnB,CAAEZ,OAAF,CAPmB,CAAtB;;AASA,QAAMa,WAAW,GAAKJ,KAAF,IAAa;AAChC,UAAMD,MAAM,GAAGM,MAAM,CAAEL,KAAF,CAArB;AACAZ,IAAAA,QAAQ,CAAE;AAAEW,MAAAA;AAAF,KAAF,CAAR;AACA,GAHD;;AAKA,SACC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,sBADX;AAEC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAFT;AAGC,IAAA,OAAO,EAAGF,aAHX;AAIC,IAAA,QAAQ,EAAGO,WAJZ;AAKC,IAAA,KAAK,EAAGd;AALT,IADD;AASA;;eAEcH,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { SelectControl } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nfunction PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { postAuthor, authors } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostAuthor:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'author' ),\n\t\t\tauthors: select( coreStore ).getUsers( AUTHORS_QUERY ),\n\t\t};\n\t}, [] );\n\n\tconst authorOptions = useMemo( () => {\n\t\treturn ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\t}, [ authors ] );\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ postAuthor }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorSelect;\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-author/select.js"],"names":["PostAuthorSelect","editPost","editorStore","postAuthor","authors","select","getEditedPostAttribute","coreStore","getUsers","AUTHORS_QUERY","authorOptions","map","author","value","id","label","name","setAuthorId","Number"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAQA;AACA;AACA;AAIA,SAASA,gBAAT,GAA4B;AAC3B,QAAM;AAAEC,IAAAA;AAAF,MAAe,uBAAaC,YAAb,CAArB;AACA,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA0B,qBAAaC,MAAF,IAAc;AACxD,WAAO;AACNF,MAAAA,UAAU,EACTE,MAAM,CAAEH,YAAF,CAAN,CAAsBI,sBAAtB,CAA8C,QAA9C,CAFK;AAGNF,MAAAA,OAAO,EAAEC,MAAM,CAAEE,eAAF,CAAN,CAAoBC,QAApB,CAA8BC,wBAA9B;AAHH,KAAP;AAKA,GAN+B,EAM7B,EAN6B,CAAhC;AAQA,QAAMC,aAAa,GAAG,sBAAS,MAAM;AACpC,WAAO,CAAEN,OAAF,aAAEA,OAAF,cAAEA,OAAF,GAAa,EAAb,EAAkBO,GAAlB,CAAyBC,MAAF,IAAc;AAC3C,aAAO;AACNC,QAAAA,KAAK,EAAED,MAAM,CAACE,EADR;AAENC,QAAAA,KAAK,EAAE,kCAAgBH,MAAM,CAACI,IAAvB;AAFD,OAAP;AAIA,KALM,CAAP;AAMA,GAPqB,EAOnB,CAAEZ,OAAF,CAPmB,CAAtB;;AASA,QAAMa,WAAW,GAAKJ,KAAF,IAAa;AAChC,UAAMD,MAAM,GAAGM,MAAM,CAAEL,KAAF,CAArB;AACAZ,IAAAA,QAAQ,CAAE;AAAEW,MAAAA;AAAF,KAAF,CAAR;AACA,GAHD;;AAKA,SACC,4BAAC,yBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,SAAS,EAAC,sBAFX;AAGC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAHT;AAIC,IAAA,OAAO,EAAGF,aAJX;AAKC,IAAA,QAAQ,EAAGO,WALZ;AAMC,IAAA,KAAK,EAAGd;AANT,IADD;AAUA;;eAEcH,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { SelectControl } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { AUTHORS_QUERY } from './constants';\n\nfunction PostAuthorSelect() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { postAuthor, authors } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostAuthor:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'author' ),\n\t\t\tauthors: select( coreStore ).getUsers( AUTHORS_QUERY ),\n\t\t};\n\t}, [] );\n\n\tconst authorOptions = useMemo( () => {\n\t\treturn ( authors ?? [] ).map( ( author ) => {\n\t\t\treturn {\n\t\t\t\tvalue: author.id,\n\t\t\t\tlabel: decodeEntities( author.name ),\n\t\t\t};\n\t\t} );\n\t}, [ authors ] );\n\n\tconst setAuthorId = ( value ) => {\n\t\tconst author = Number( value );\n\t\teditPost( { author } );\n\t};\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName=\"post-author-selector\"\n\t\t\tlabel={ __( 'Author' ) }\n\t\t\toptions={ authorOptions }\n\t\t\tonChange={ setAuthorId }\n\t\t\tvalue={ postAuthor }\n\t\t/>\n\t);\n}\n\nexport default PostAuthorSelect;\n"]}
@@ -117,6 +117,7 @@ function PostFormat() {
117
117
  return (0, _element.createElement)(_check.default, null, (0, _element.createElement)("div", {
118
118
  className: "editor-post-format"
119
119
  }, (0, _element.createElement)(_components.SelectControl, {
120
+ __nextHasNoMarginBottom: true,
120
121
  label: (0, _i18n.__)('Post Format'),
121
122
  value: postFormat,
122
123
  onChange: format => onUpdatePostFormat(format),
@@ -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","includes","suggestion","find","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;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,OA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A,UAAU,CAAC1B,EAAX,KAAkBW,UAAhC,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,IAAA,OAAO,EAAG,MACTkB,kBAAkB,CAAEH,UAAU,CAAC1B,EAAb;AAHpB,KAMG;AACD;AACA,gBAAI,4BAAJ,CAFC,EAGD0B,UAAU,CAACzB,OAHV,CANH,CADD,CAZF,CADD,CADD;AAgCA","sourcesContent":["/**\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\tsupportedFormats?.includes( format.id ) || postFormat === format.id\n\t\t);\n\t} );\n\tconst suggestion = formats.find(\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"]}
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","includes","suggestion","find","editPost","onUpdatePostFormat","map","label","value"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;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,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;AACA,gBAAI,4BAAJ,CAFC,EAGD0B,UAAU,CAACzB,OAHV,CANH,CADD,CAbF,CADD,CADD;AAiCA","sourcesContent":["/**\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\tsupportedFormats?.includes( format.id ) || postFormat === format.id\n\t\t);\n\t} );\n\tconst suggestion = formats.find(\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\t__nextHasNoMarginBottom\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"]}
@@ -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,IAA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I,YAAJ,CAFO,EAGPR,SAHO,CAHT;AAQC,MAAA,KAAK,EAAG,iCAAwBG,IAAxB,CART;AASC,MAAA,OAAO,EAAG,KAAKrB;AAThB,MADD,EAaC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,UAAD;AAAY,MAAA,IAAI,EAAGqB,IAAnB;AAA0B,MAAA,MAAM,EAAG,KAAK/B;AAAxC,OACG,KAAKO,KAAL,CAAWC,oBAAX,GACC,cAAI,SAAJ,CADD,GAEC,cAAI,MAAJ,CAHJ,CADD,CAbD,CAJD,EA0BC;AAAK,MAAA,SAAS,EAAC;AAAf,OACG,CAAEkB,WAAF,IACD,4BAAC,kBAAD;AAAQ,MAAA,OAAO,EAAC,SAAhB;AAA0B,MAAA,IAAI,EAAGK;AAAjC,OACGF,aADH,CAFF,EAMC,4BAAC,kBAAD;AACC,MAAA,OAAO,EAAGH,WAAW,GAAG,SAAH,GAAe,WADrC;AAEC,MAAA,IAAI,EAAGO;AAFR,OAIGH,eAJH,CAND,CA1BD,CAPD,EA+CG7B,QA/CH,CADD;AAmDA;;AA7GkD;;eAgHrC,sBAAcuB,MAAF,IAAc;AACxC,QAAM;AAAEc,IAAAA,sBAAF;AAA0BC,IAAAA,cAA1B;AAA0CC,IAAAA;AAA1C,MACLhB,MAAM,CAAEiB,YAAF,CADP;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAkBlB,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\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"]}
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,aA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IAAI,EAAGK;AAAjC,OACGF,aADH,CAFF,EAMC,4BAAC,kBAAD;AACC,MAAA,OAAO,EAAGH,WAAW,GAAG,SAAH,GAAe,WADrC;AAEC,MAAA,IAAI,EAAGO;AAFR,OAIGH,eAJH,CAND,CA3BD,CAPD,EAgDG7B,QAhDH,CADD;AAoDA;;AA9GkD;;eAiHrC,sBAAcuB,MAAF,IAAc;AACxC,QAAM;AAAEc,IAAAA,sBAAF;AAA0BC,IAAAA,cAA1B;AAA0CC,IAAAA;AAA1C,MACLhB,MAAM,CAAEiB,YAAF,CADP;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAkBlB,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",