@wordpress/editor 12.6.0 → 12.9.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 (103) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/editor-help/help-section-title.native.js +43 -0
  3. package/build/components/editor-help/help-section-title.native.js.map +1 -0
  4. package/build/components/editor-help/help-topic-row.native.js +3 -2
  5. package/build/components/editor-help/help-topic-row.native.js.map +1 -1
  6. package/build/components/editor-help/icon-move-blocks.native.js +23 -0
  7. package/build/components/editor-help/icon-move-blocks.native.js.map +1 -0
  8. package/build/components/editor-help/index.native.js +10 -11
  9. package/build/components/editor-help/index.native.js.map +1 -1
  10. package/build/components/editor-help/move-blocks.native.js +14 -2
  11. package/build/components/editor-help/move-blocks.native.js.map +1 -1
  12. package/build/components/editor-help/view-sections.native.js +21 -5
  13. package/build/components/editor-help/view-sections.native.js.map +1 -1
  14. package/build/components/post-featured-image/index.js +84 -41
  15. package/build/components/post-featured-image/index.js.map +1 -1
  16. package/build/components/post-schedule/index.js +11 -18
  17. package/build/components/post-schedule/index.js.map +1 -1
  18. package/build/components/post-taxonomies/flat-term-selector.js +2 -2
  19. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  20. package/build/components/post-taxonomies/index.js +7 -1
  21. package/build/components/post-taxonomies/index.js.map +1 -1
  22. package/build/components/post-text-editor/index.js +12 -1
  23. package/build/components/post-text-editor/index.js.map +1 -1
  24. package/build/components/post-visibility/index.js +132 -167
  25. package/build/components/post-visibility/index.js.map +1 -1
  26. package/build/components/post-visibility/label.js +5 -22
  27. package/build/components/post-visibility/label.js.map +1 -1
  28. package/build/components/post-visibility/utils.js +14 -13
  29. package/build/components/post-visibility/utils.js.map +1 -1
  30. package/build/components/provider/index.native.js +3 -1
  31. package/build/components/provider/index.native.js.map +1 -1
  32. package/build/components/provider/use-block-editor-settings.js +15 -9
  33. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  34. package/build/store/selectors.js +2 -2
  35. package/build/store/selectors.js.map +1 -1
  36. package/build-module/components/editor-help/help-section-title.native.js +31 -0
  37. package/build-module/components/editor-help/help-section-title.native.js.map +1 -0
  38. package/build-module/components/editor-help/help-topic-row.native.js +3 -2
  39. package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
  40. package/build-module/components/editor-help/icon-move-blocks.native.js +13 -0
  41. package/build-module/components/editor-help/icon-move-blocks.native.js.map +1 -0
  42. package/build-module/components/editor-help/index.native.js +10 -12
  43. package/build-module/components/editor-help/index.native.js.map +1 -1
  44. package/build-module/components/editor-help/move-blocks.native.js +15 -3
  45. package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
  46. package/build-module/components/editor-help/view-sections.native.js +22 -6
  47. package/build-module/components/editor-help/view-sections.native.js.map +1 -1
  48. package/build-module/components/post-featured-image/index.js +86 -42
  49. package/build-module/components/post-featured-image/index.js.map +1 -1
  50. package/build-module/components/post-schedule/index.js +12 -19
  51. package/build-module/components/post-schedule/index.js.map +1 -1
  52. package/build-module/components/post-taxonomies/flat-term-selector.js +2 -2
  53. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  54. package/build-module/components/post-taxonomies/index.js +7 -1
  55. package/build-module/components/post-taxonomies/index.js.map +1 -1
  56. package/build-module/components/post-text-editor/index.js +13 -2
  57. package/build-module/components/post-text-editor/index.js.map +1 -1
  58. package/build-module/components/post-visibility/index.js +132 -166
  59. package/build-module/components/post-visibility/index.js.map +1 -1
  60. package/build-module/components/post-visibility/label.js +5 -20
  61. package/build-module/components/post-visibility/label.js.map +1 -1
  62. package/build-module/components/post-visibility/utils.js +14 -13
  63. package/build-module/components/post-visibility/utils.js.map +1 -1
  64. package/build-module/components/provider/index.native.js +2 -1
  65. package/build-module/components/provider/index.native.js.map +1 -1
  66. package/build-module/components/provider/use-block-editor-settings.js +16 -10
  67. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  68. package/build-module/store/selectors.js +2 -2
  69. package/build-module/store/selectors.js.map +1 -1
  70. package/build-style/style-rtl.css +51 -52
  71. package/build-style/style.css +51 -52
  72. package/package.json +29 -28
  73. package/src/components/autosave-monitor/test/index.js +3 -0
  74. package/src/components/editor-help/help-section-title.native.js +29 -0
  75. package/src/components/editor-help/help-topic-row.native.js +2 -2
  76. package/src/components/editor-help/icon-move-blocks.native.js +10 -0
  77. package/src/components/editor-help/images/drag-and-drop-dark.png +0 -0
  78. package/src/components/editor-help/images/drag-and-drop-dark@2x.png +0 -0
  79. package/src/components/editor-help/images/drag-and-drop-dark@3x.png +0 -0
  80. package/src/components/editor-help/images/drag-and-drop-light.png +0 -0
  81. package/src/components/editor-help/images/drag-and-drop-light@2x.png +0 -0
  82. package/src/components/editor-help/images/drag-and-drop-light@3x.png +0 -0
  83. package/src/components/editor-help/index.native.js +20 -22
  84. package/src/components/editor-help/move-blocks.native.js +22 -2
  85. package/src/components/editor-help/style.scss +36 -4
  86. package/src/components/editor-help/test/index.native.js +1 -1
  87. package/src/components/editor-help/view-sections.native.js +23 -8
  88. package/src/components/post-featured-image/index.js +102 -69
  89. package/src/components/post-saved-state/style.scss +9 -0
  90. package/src/components/post-schedule/index.js +6 -13
  91. package/src/components/post-slug/test/index.js +4 -4
  92. package/src/components/post-taxonomies/flat-term-selector.js +5 -2
  93. package/src/components/post-taxonomies/index.js +3 -1
  94. package/src/components/post-text-editor/index.js +13 -1
  95. package/src/components/post-visibility/index.js +130 -150
  96. package/src/components/post-visibility/label.js +6 -15
  97. package/src/components/post-visibility/style.scss +25 -20
  98. package/src/components/post-visibility/utils.js +7 -12
  99. package/src/components/provider/index.native.js +2 -1
  100. package/src/components/provider/use-block-editor-settings.js +28 -12
  101. package/src/components/table-of-contents/style.scss +1 -3
  102. package/src/store/selectors.js +4 -2
  103. package/src/store/test/selectors.js +5 -5
@@ -11,7 +11,7 @@ var _date = require("@wordpress/date");
11
11
 
12
12
  var _data = require("@wordpress/data");
13
13
 
14
- var _components = require("@wordpress/components");
14
+ var _blockEditor = require("@wordpress/block-editor");
15
15
 
16
16
  var _coreData = require("@wordpress/core-data");
17
17
 
@@ -31,7 +31,10 @@ function getDayOfTheMonth() {
31
31
  return new Date(d.getFullYear(), d.getMonth() + (firstDay ? 0 : 1), firstDay ? 1 : 0).toISOString();
32
32
  }
33
33
 
34
- function PostSchedule() {
34
+ function PostSchedule(_ref) {
35
+ let {
36
+ onClose
37
+ } = _ref;
35
38
  const {
36
39
  postDate,
37
40
  postType
@@ -55,19 +58,18 @@ function PostSchedule() {
55
58
  before: getDayOfTheMonth(previewedMonth, false),
56
59
  exclude: [select(_store.store).getCurrentPostId()]
57
60
  }), [previewedMonth, postType]);
58
- const events = (0, _element.useMemo)(() => (eventsByPostType || []).map(_ref => {
61
+ const events = (0, _element.useMemo)(() => (eventsByPostType || []).map(_ref2 => {
59
62
  let {
60
63
  title,
61
64
  type,
62
65
  date: eventDate
63
- } = _ref;
66
+ } = _ref2;
64
67
  return {
65
68
  title: title === null || title === void 0 ? void 0 : title.rendered,
66
69
  type,
67
70
  date: new Date(eventDate)
68
71
  };
69
72
  }), [eventsByPostType]);
70
- const ref = (0, _element.useRef)();
71
73
  const settings = (0, _date.__experimentalGetSettings)(); // To know if the current timezone is a 12 hour time with look for "a" in the time format
72
74
  // We also make sure this a is not escaped by a "/"
73
75
 
@@ -75,22 +77,13 @@ function PostSchedule() {
75
77
  .replace(/\\\\/g, '') // Replace "//" with empty strings.
76
78
  .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
77
79
  );
78
-
79
- function onChange(newDate) {
80
- onUpdateDate(newDate);
81
- const {
82
- ownerDocument
83
- } = ref.current;
84
- ownerDocument.activeElement.blur();
85
- }
86
-
87
- return (0, _element.createElement)(_components.DateTimePicker, {
88
- ref: ref,
80
+ return (0, _element.createElement)(_blockEditor.__experimentalPublishDateTimePicker, {
89
81
  currentDate: postDate,
90
- onChange: onChange,
82
+ onChange: onUpdateDate,
91
83
  is12Hour: is12HourTime,
92
84
  events: events,
93
- onMonthPreviewed: setPreviewedMonth
85
+ onMonthPreviewed: setPreviewedMonth,
86
+ onClose: onClose
94
87
  });
95
88
  }
96
89
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["getDayOfTheMonth","date","Date","firstDay","d","getFullYear","getMonth","toISOString","PostSchedule","postDate","postType","select","editorStore","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","previewedMonth","setPreviewedMonth","eventsByPostType","coreStore","getEntityRecords","status","after","before","exclude","getCurrentPostId","events","map","title","type","eventDate","rendered","ref","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join","onChange","newDate","ownerDocument","current","activeElement","blur"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,SAASA,gBAAT,GAAgE;AAAA,MAArCC,IAAqC,uEAA9B,IAAIC,IAAJ,EAA8B;AAAA,MAAlBC,QAAkB,uEAAP,IAAO;AAC/D,QAAMC,CAAC,GAAG,IAAIF,IAAJ,CAAUD,IAAV,CAAV;AACA,SAAO,IAAIC,IAAJ,CACNE,CAAC,CAACC,WAAF,EADM,EAEND,CAAC,CAACE,QAAF,MAAiBH,QAAQ,GAAG,CAAH,GAAO,CAAhC,CAFM,EAGNA,QAAQ,GAAG,CAAH,GAAO,CAHT,EAILI,WAJK,EAAP;AAKA;;AAEc,SAASC,YAAT,GAAwB;AACtC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyB,qBAC5BC,MAAF,KAAgB;AACfF,IAAAA,QAAQ,EAAEE,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,MAA9C,CADK;AAEfH,IAAAA,QAAQ,EAAEC,MAAM,CAAEC,YAAF,CAAN,CAAsBE,kBAAtB;AAFK,GAAhB,CAD8B,EAK9B,EAL8B,CAA/B;AAQA,QAAM;AAAEC,IAAA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Q,CAACG,OAAT,CAAiBC,IAAjB,CACEC,WADF,GACgB;AADhB,GAEEC,OAFF,CAEW,OAFX,EAEoB,EAFpB,EAEyB;AAFzB,GAGEC,KAHF,CAGS,EAHT,EAIEC,OAJF,GAKEC,IALF,CAKQ,EALR,CADoB,CAMP;AANO,GAArB;;AASA,WAASC,QAAT,CAAmBC,OAAnB,EAA6B;AAC5B7B,IAAAA,YAAY,CAAE6B,OAAF,CAAZ;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAoBb,GAAG,CAACc,OAA9B;AACAD,IAAAA,aAAa,CAACE,aAAd,CAA4BC,IAA5B;AACA;;AAED,SACC,4BAAC,0BAAD;AACC,IAAA,GAAG,EAAGhB,GADP;AAEC,IAAA,WAAW,EAAGxB,QAFf;AAGC,IAAA,QAAQ,EAAGmC,QAHZ;AAIC,IAAA,QAAQ,EAAGT,YAJZ;AAKC,IAAA,MAAM,EAAGR,MALV;AAMC,IAAA,gBAAgB,EAAGT;AANpB,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalGetSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { DateTimePicker } from '@wordpress/components';\nimport { useRef, useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction getDayOfTheMonth( date = new Date(), firstDay = true ) {\n\tconst d = new Date( date );\n\treturn new Date(\n\t\td.getFullYear(),\n\t\td.getMonth() + ( firstDay ? 0 : 1 ),\n\t\tfirstDay ? 1 : 0\n\t).toISOString();\n}\n\nexport default function PostSchedule() {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tgetDayOfTheMonth( postDate )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: getDayOfTheMonth( previewedMonth ),\n\t\t\t\tbefore: getDayOfTheMonth( previewedMonth, false ),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map(\n\t\t\t\t( { title, type, date: eventDate } ) => ( {\n\t\t\t\t\ttitle: title?.rendered,\n\t\t\t\t\ttype,\n\t\t\t\t\tdate: new Date( eventDate ),\n\t\t\t\t} )\n\t\t\t),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst ref = useRef();\n\tconst settings = __experimentalGetSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\tfunction onChange( newDate ) {\n\t\tonUpdateDate( newDate );\n\t\tconst { ownerDocument } = ref.current;\n\t\townerDocument.activeElement.blur();\n\t}\n\n\treturn (\n\t\t<DateTimePicker\n\t\t\tref={ ref }\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onChange }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ setPreviewedMonth }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-schedule/index.js"],"names":["getDayOfTheMonth","date","Date","firstDay","d","getFullYear","getMonth","toISOString","PostSchedule","onClose","postDate","postType","select","editorStore","getEditedPostAttribute","getCurrentPostType","editPost","onUpdateDate","previewedMonth","setPreviewedMonth","eventsByPostType","coreStore","getEntityRecords","status","after","before","exclude","getCurrentPostId","events","map","title","type","eventDate","rendered","settings","is12HourTime","test","formats","time","toLowerCase","replace","split","reverse","join"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,SAASA,gBAAT,GAAgE;AAAA,MAArCC,IAAqC,uEAA9B,IAAIC,IAAJ,EAA8B;AAAA,MAAlBC,QAAkB,uEAAP,IAAO;AAC/D,QAAMC,CAAC,GAAG,IAAIF,IAAJ,CAAUD,IAAV,CAAV;AACA,SAAO,IAAIC,IAAJ,CACNE,CAAC,CAACC,WAAF,EADM,EAEND,CAAC,CAACE,QAAF,MAAiBH,QAAQ,GAAG,CAAH,GAAO,CAAhC,CAFM,EAGNA,QAAQ,GAAG,CAAH,GAAO,CAHT,EAILI,WAJK,EAAP;AAKA;;AAEc,SAASC,YAAT,OAAqC;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AACnD,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyB,qBAC5BC,MAAF,KAAgB;AACfF,IAAAA,QAAQ,EAAEE,MAAM,CAAEC,YAAF,CAAN,CAAsBC,sBAAtB,CAA8C,MAA9C,CADK;AAEfH,IAAAA,QAAQ,EAAEC,MAAM,CAAEC,YAAF,CAAN,CAAsBE,kBAAtB;AAFK,GAAhB,CAD8B,EAK9B,EAL8B,CAA/B;AAQA,QAAM;AAAEC,IAAAA;AAAF,MAAe,uBAAaH,YAAb,CAArB;;AACA,QAAMI,YAAY,GAAKhB,IAAF,IAAYe,QAAQ,CAAE;AAAEf,IAAAA;AAAF,GAAF,CAAzC;;AAEA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CAKQ,EALR,CADoB,CAMP;AANO,GAArB;AASA,SACC,4BAAC,gDAAD;AACC,IAAA,WAAW,EAAGjC,QADf;AAEC,IAAA,QAAQ,EAAGO,YAFZ;AAGC,IAAA,QAAQ,EAAGkB,YAHZ;AAIC,IAAA,MAAM,EAAGP,MAJV;AAKC,IAAA,gBAAgB,EAAGT,iBALpB;AAMC,IAAA,OAAO,EAAGV;AANX,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalGetSettings } from '@wordpress/date';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __experimentalPublishDateTimePicker as PublishDateTimePicker } from '@wordpress/block-editor';\nimport { useState, useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction getDayOfTheMonth( date = new Date(), firstDay = true ) {\n\tconst d = new Date( date );\n\treturn new Date(\n\t\td.getFullYear(),\n\t\td.getMonth() + ( firstDay ? 0 : 1 ),\n\t\tfirstDay ? 1 : 0\n\t).toISOString();\n}\n\nexport default function PostSchedule( { onClose } ) {\n\tconst { postDate, postType } = useSelect(\n\t\t( select ) => ( {\n\t\t\tpostDate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst onUpdateDate = ( date ) => editPost( { date } );\n\n\tconst [ previewedMonth, setPreviewedMonth ] = useState(\n\t\tgetDayOfTheMonth( postDate )\n\t);\n\n\t// Pick up published and schduled site posts.\n\tconst eventsByPostType = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords( 'postType', postType, {\n\t\t\t\tstatus: 'publish,future',\n\t\t\t\tafter: getDayOfTheMonth( previewedMonth ),\n\t\t\t\tbefore: getDayOfTheMonth( previewedMonth, false ),\n\t\t\t\texclude: [ select( editorStore ).getCurrentPostId() ],\n\t\t\t} ),\n\t\t[ previewedMonth, postType ]\n\t);\n\n\tconst events = useMemo(\n\t\t() =>\n\t\t\t( eventsByPostType || [] ).map(\n\t\t\t\t( { title, type, date: eventDate } ) => ( {\n\t\t\t\t\ttitle: title?.rendered,\n\t\t\t\t\ttype,\n\t\t\t\t\tdate: new Date( eventDate ),\n\t\t\t\t} )\n\t\t\t),\n\t\t[ eventsByPostType ]\n\t);\n\n\tconst settings = __experimentalGetSettings();\n\n\t// To know if the current timezone is a 12 hour time with look for \"a\" in the time format\n\t// We also make sure this a is not escaped by a \"/\"\n\tconst is12HourTime = /a(?!\\\\)/i.test(\n\t\tsettings.formats.time\n\t\t\t.toLowerCase() // Test only the lower case a.\n\t\t\t.replace( /\\\\\\\\/g, '' ) // Replace \"//\" with empty strings.\n\t\t\t.split( '' )\n\t\t\t.reverse()\n\t\t\t.join( '' ) // Reverse the string and test for \"a\" not followed by a slash.\n\t);\n\n\treturn (\n\t\t<PublishDateTimePicker\n\t\t\tcurrentDate={ postDate }\n\t\t\tonChange={ onUpdateDate }\n\t\t\tis12Hour={ is12HourTime }\n\t\t\tevents={ events }\n\t\t\tonMonthPreviewed={ setPreviewedMonth }\n\t\t\tonClose={ onClose }\n\t\t/>\n\t);\n}\n"]}
@@ -159,7 +159,7 @@ function FlatTermSelector(_ref) {
159
159
 
160
160
  (0, _element.useEffect)(() => {
161
161
  if (hasResolvedTerms) {
162
- const newValues = terms.map(term => (0, _terms.unescapeString)(term.name));
162
+ const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => (0, _terms.unescapeString)(term.name));
163
163
  setValues(newValues);
164
164
  }
165
165
  }, [terms, hasResolvedTerms]);
@@ -181,7 +181,7 @@ function FlatTermSelector(_ref) {
181
181
  }
182
182
 
183
183
  function onChange(termNames) {
184
- const availableTerms = [...terms, ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
184
+ const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
185
185
  const uniqueTerms = (0, _lodash.uniqBy)(termNames, term => term.toLowerCase());
186
186
  const newTermNames = uniqueTerms.filter(termName => !(0, _lodash.find)(availableTerms, term => isSameTermName(term.name, termName))); // Optimistically update term values.
187
187
  // The selector will always re-fetch terms later.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","orderby","order","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","term","name","id","findOrCreateTerm","restBase","escapedTermName","path","method","data","catch","error","errorCode","code","addRequest","search","then","unescapeTerms","searchResult","result","Promise","reject","unescapeTerm","FlatTermSelector","slug","values","setValues","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","newTermNames","filter","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","termAddedMessage","newTermLabel","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,QAAQ,EAAEF,qBADW;AAErBG,EAAAA,OAAO,EAAE,OAFY;AAGrBC,EAAAA,KAAK,EAAE,MAHc;AAIrBC,EA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G;AACvB;AACA,gBAAI,WAAJ,EAAiB,MAAjB,CAFuB,EAGvBH,YAHuB,CAAxB;AAMA,SACC,qDACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAG9C,MADT;AAEC,IAAA,WAAW,EAAG2B,WAFf;AAGC,IAAA,QAAQ,EAAGI,QAHZ;AAIC,IAAA,aAAa,EAAG5B,eAJjB;AAKC,IAAA,cAAc,EAAG3C,qBALlB;AAMC,IAAA,KAAK,EAAGqF,YANT;AAOC,IAAA,QAAQ,EAAG;AACVK,MAAAA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,4BAAC,sBAAD;AAAe,IAAA,QAAQ,EAAG5C,QAA1B;AAAqC,IAAA,QAAQ,EAAGoC;AAAhD,IAdD,CADD;AAkBA;;eAEc,6BAAa,yBAAb,EAA0C3C,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { escape as escapeString, find, get, uniqBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm, unescapeTerms } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\torderby: 'count',\n\torder: 'desc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tfind( terms, ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase ) {\n\tconst escapedTermName = escapeString( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/wp/v2/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tconst errorCode = error.code;\n\t\t\tif ( errorCode === 'term_exists' ) {\n\t\t\t\t// If the terms exist, fetch it instead of creating a new one.\n\t\t\t\tconst addRequest = apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( `/wp/v2/${ restBase }`, {\n\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\tsearch: escapedTermName,\n\t\t\t\t\t} ),\n\t\t\t\t} ).then( unescapeTerms );\n\n\t\t\t\treturn addRequest.then( ( searchResult ) => {\n\t\t\t\t\treturn find( searchResult, ( result ) =>\n\t\t\t\t\t\tisSameTermName( result.name, termName )\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn Promise.reject( error );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nfunction FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } = select(\n\t\t\t\teditorStore\n\t\t\t);\n\t\t\tconst {\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetTaxonomy,\n\t\t\t\thasFinishedResolution,\n\t\t\t} = select( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = terms.map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [ ...terms, ...( searchResults ?? [] ) ];\n\t\tconst uniqueTerms = uniqBy( termNames, ( term ) => term.toLowerCase() );\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! find( availableTerms, ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'add_new_item' ],\n\t\tslug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' )\n\t);\n\tconst singularName = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'singular_name' ],\n\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t);\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/flat-term-selector.js"],"names":["EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","orderby","order","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","term","name","id","findOrCreateTerm","restBase","escapedTermName","path","method","data","catch","error","errorCode","code","addRequest","search","then","unescapeTerms","searchResult","result","Promise","reject","unescapeTerm","FlatTermSelector","slug","values","setValues","setSearch","debouncedSearch","termIds","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","getCurrentPost","getEditedPostAttribute","editorStore","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","post","_taxonomy","_termIds","rest_base","query","include","join","length","searchResults","newValues","suggestions","editPost","onUpdateTerms","newTermIds","onChange","termNames","availableTerms","uniqueTerms","newTermNames","filter","all","newTerms","newAvailableTerms","concat","appendTerm","newTerm","includes","termAddedMessage","newTermLabel","singularName","termAddedLabel","termRemovedLabel","removeTermLabel","added","removed","remove"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,W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N,IAAI,KAAK,UAAT,GAAsB,cAAI,KAAJ,CAAtB,GAAoC,cAAI,MAAJ,CAHhB,CAArB;AAKA,QAAMgD,cAAc,GAAG;AACtB;AACA,gBAAI,UAAJ,EAAgB,MAAhB,CAFsB,EAGtBD,YAHsB,CAAvB;AAKA,QAAME,gBAAgB,GAAG;AACxB;AACA,gBAAI,YAAJ,EAAkB,MAAlB,CAFwB,EAGxBF,YAHwB,CAAzB;AAKA,QAAMG,eAAe,GAAG;AACvB;AACA,gBAAI,WAAJ,EAAiB,MAAjB,CAFuB,EAGvBH,YAHuB,CAAxB;AAMA,SACC,qDACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAG9C,MADT;AAEC,IAAA,WAAW,EAAG2B,WAFf;AAGC,IAAA,QAAQ,EAAGI,QAHZ;AAIC,IAAA,aAAa,EAAG5B,eAJjB;AAKC,IAAA,cAAc,EAAG3C,qBALlB;AAMC,IAAA,KAAK,EAAGqF,YANT;AAOC,IAAA,QAAQ,EAAG;AACVK,MAAAA,KAAK,EAAEH,cADG;AAEVI,MAAAA,OAAO,EAAEH,gBAFC;AAGVI,MAAAA,MAAM,EAAEH;AAHE;AAPZ,IADD,EAcC,4BAAC,sBAAD;AAAe,IAAA,QAAQ,EAAG5C,QAA1B;AAAqC,IAAA,QAAQ,EAAGoC;AAAhD,IAdD,CADD;AAkBA;;eAEc,6BAAa,yBAAb,EAA0C3C,gBAA1C,C","sourcesContent":["/**\n * External dependencies\n */\nimport { escape as escapeString, find, get, uniqBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm, unescapeTerms } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\torderby: 'count',\n\torder: 'desc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tfind( terms, ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\n// Tries to create a term or fetch it if it already exists.\nfunction findOrCreateTerm( termName, restBase ) {\n\tconst escapedTermName = escapeString( termName );\n\n\treturn apiFetch( {\n\t\tpath: `/wp/v2/${ restBase }`,\n\t\tmethod: 'POST',\n\t\tdata: { name: escapedTermName },\n\t} )\n\t\t.catch( ( error ) => {\n\t\t\tconst errorCode = error.code;\n\t\t\tif ( errorCode === 'term_exists' ) {\n\t\t\t\t// If the terms exist, fetch it instead of creating a new one.\n\t\t\t\tconst addRequest = apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( `/wp/v2/${ restBase }`, {\n\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\tsearch: escapedTermName,\n\t\t\t\t\t} ),\n\t\t\t\t} ).then( unescapeTerms );\n\n\t\t\t\treturn addRequest.then( ( searchResult ) => {\n\t\t\t\t\treturn find( searchResult, ( result ) =>\n\t\t\t\t\t\tisSameTermName( result.name, termName )\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn Promise.reject( error );\n\t\t} )\n\t\t.then( unescapeTerm );\n}\n\nfunction FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } = select(\n\t\t\t\teditorStore\n\t\t\t);\n\t\t\tconst {\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetTaxonomy,\n\t\t\t\thasFinishedResolution,\n\t\t\t} = select( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? get(\n\t\t\t\t\t\t\tpost,\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t )\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = uniqBy( termNames, ( term ) => term.toLowerCase() );\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! find( availableTerms, ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( termName, taxonomy.rest_base )\n\t\t\t)\n\t\t).then( ( newTerms ) => {\n\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t);\n\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\tget(\n\t\t\t\ttaxonomy,\n\t\t\t\t[ 'labels', 'singular_name' ],\n\t\t\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t\t\t)\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'add_new_item' ],\n\t\tslug === 'post_tag' ? __( 'Add new tag' ) : __( 'Add new Term' )\n\t);\n\tconst singularName = get(\n\t\ttaxonomy,\n\t\t[ 'labels', 'singular_name' ],\n\t\tslug === 'post_tag' ? __( 'Tag' ) : __( 'Term' )\n\t);\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<FormTokenField\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"]}
@@ -42,7 +42,13 @@ function PostTaxonomies(_ref) {
42
42
  taxonomyWrapper = _lodash.identity
43
43
  } = _ref;
44
44
  const availableTaxonomies = (0, _lodash.filter)(taxonomies, taxonomy => (0, _lodash.includes)(taxonomy.types, postType));
45
- const visibleTaxonomies = (0, _lodash.filter)(availableTaxonomies, taxonomy => taxonomy.visibility.show_ui);
45
+ const visibleTaxonomies = (0, _lodash.filter)(availableTaxonomies, // In some circumstances .visibility can end up as undefined so optional chaining operator required.
46
+ // https://github.com/WordPress/gutenberg/issues/40326
47
+ taxonomy => {
48
+ var _taxonomy$visibility;
49
+
50
+ return (_taxonomy$visibility = taxonomy.visibility) === null || _taxonomy$visibility === void 0 ? void 0 : _taxonomy$visibility.show_ui;
51
+ });
46
52
  return visibleTaxonomies.map(taxonomy => {
47
53
  const TaxonomyComponent = taxonomy.hierarchical ? _hierarchicalTermSelector.default : _flatTermSelector.default;
48
54
  return (0, _element.createElement)(_element.Fragment, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"names":["PostTaxonomies","postType","taxonomies","taxonomyWrapper","identity","availableTaxonomies","taxonomy","types","visibleTaxonomies","visibility","show_ui","map","TaxonomyComponent","hierarchical","HierarchicalTermSelector","FlatTermSelector","slug","select","editorStore","getCurrentPostType","coreStore","getTaxonomies","per_page"],"mappings":";;;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAKO,SAASA,cAAT,OAIH;AAAA,MAJ4B;AAC/BC,IAAAA,QAD+B;AAE/BC,IAAAA,UAF+B;AAG/BC,IAAAA,eAAe,GAAGC;AAHa,GAI5B;AACH,QAAMC,mBAAmB,GAAG,oBAAQH,UAAR,EAAsBI,QAAF,IAC/C,sBAAUA,QAAQ,CAACC,KAAnB,EAA0BN,QAA1B,CAD2B,CAA5B;AAGA,QAAMO,iBAAiB,GAAG,oBACzBH,mBADyB,EAEvBC,QAAF,IAAgBA,QAAQ,CAACG,UAAT,CAAoBC,OAFX,CAA1B;AAIA,SAAOF,iBAAiB,CAACG,GAAlB,CAAyBL,QAAF,IAAgB;AAC7C,UAAMM,iBAAiB,GAAGN,QAAQ,CAACO,YAAT,GACvBC,iCADuB,GAEvBC,yBAFH;AAGA,WACC,4BAAC,iBAAD;AAAU,MAAA,GAAG,EAAI,YAAYT,QAAQ,CAACU,IAAM;AAA5C,OACGb,eAAe,CAChB,4BAAC,iBAAD;AAAmB,MAAA,IAAI,EAAGG,QAAQ,CAACU;AAAnC,MADgB,EAEhBV,QAFgB,CADlB,CADD;AAQA,GAZM,CAAP;AAaA;;eAEc,sBAAS,CACvB,sBAAcW,MAAF,IAAc;AACzB,SAAO;AACNhB,IAAAA,QAAQ,EAAEgB,MAAM,CAAEC,YAAF,CAAN,CAAsBC,kBAAtB,EADJ;AAENjB,IAAAA,UAAU,EAAEe,MAAM,CAAEG,eAAF,CAAN,CAAoBC,aAApB,CAAmC;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAnC;AAFN,GAAP;AAIA,CALD,CADuB,CAAT,EAOVtB,cAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, identity, includes } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nexport function PostTaxonomies( {\n\tpostType,\n\ttaxonomies,\n\ttaxonomyWrapper = identity,\n} ) {\n\tconst availableTaxonomies = filter( taxonomies, ( taxonomy ) =>\n\t\tincludes( taxonomy.types, postType )\n\t);\n\tconst visibleTaxonomies = filter(\n\t\tavailableTaxonomies,\n\t\t( taxonomy ) => taxonomy.visibility.show_ui\n\t);\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomies );\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-taxonomies/index.js"],"names":["PostTaxonomies","postType","taxonomies","taxonomyWrapper","identity","availableTaxonomies","taxonomy","types","visibleTaxonomies","visibility","show_ui","map","TaxonomyComponent","hierarchical","HierarchicalTermSelector","FlatTermSelector","slug","select","editorStore","getCurrentPostType","coreStore","getTaxonomies","per_page"],"mappings":";;;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAKO,SAASA,cAAT,OAIH;AAAA,MAJ4B;AAC/BC,IAAAA,QAD+B;AAE/BC,IAAAA,UAF+B;AAG/BC,IAAAA,eAAe,GAAGC;AAHa,GAI5B;AACH,QAAMC,mBAAmB,GAAG,oBAAQH,UAAR,EAAsBI,QAAF,IAC/C,sBAAUA,QAAQ,CAACC,KAAnB,EAA0BN,QAA1B,CAD2B,CAA5B;AAGA,QAAMO,iBAAiB,GAAG,oBACzBH,mBADyB,EAEzB;AACA;AACEC,EAAAA,QAAF;AAAA;;AAAA,mCAAgBA,QAAQ,CAACG,UAAzB,yDAAgB,qBAAqBC,OAArC;AAAA,GAJyB,CAA1B;AAMA,SAAOF,iBAAiB,CAACG,GAAlB,CAAyBL,QAAF,IAAgB;AAC7C,UAAMM,iBAAiB,GAAGN,QAAQ,CAACO,YAAT,GACvBC,iCADuB,GAEvBC,yBAFH;AAGA,WACC,4BAAC,iBAAD;AAAU,MAAA,GAAG,EAAI,YAAYT,QAAQ,CAACU,IAAM;AAA5C,OACGb,eAAe,CAChB,4BAAC,iBAAD;AAAmB,MAAA,IAAI,EAAGG,QAAQ,CAACU;AAAnC,MADgB,EAEhBV,QAFgB,CADlB,CADD;AAQA,GAZM,CAAP;AAaA;;eAEc,sBAAS,CACvB,sBAAcW,MAAF,IAAc;AACzB,SAAO;AACNhB,IAAAA,QAAQ,EAAEgB,MAAM,CAAEC,YAAF,CAAN,CAAsBC,kBAAtB,EADJ;AAENjB,IAAAA,UAAU,EAAEe,MAAM,CAAEG,eAAF,CAAN,CAAoBC,aAApB,CAAmC;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAAnC;AAFN,GAAP;AAIA,CALD,CADuB,CAAT,EAOVtB,cAPU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, identity, includes } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Fragment } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport HierarchicalTermSelector from './hierarchical-term-selector';\nimport FlatTermSelector from './flat-term-selector';\nimport { store as editorStore } from '../../store';\n\nexport function PostTaxonomies( {\n\tpostType,\n\ttaxonomies,\n\ttaxonomyWrapper = identity,\n} ) {\n\tconst availableTaxonomies = filter( taxonomies, ( taxonomy ) =>\n\t\tincludes( taxonomy.types, postType )\n\t);\n\tconst visibleTaxonomies = filter(\n\t\tavailableTaxonomies,\n\t\t// In some circumstances .visibility can end up as undefined so optional chaining operator required.\n\t\t// https://github.com/WordPress/gutenberg/issues/40326\n\t\t( taxonomy ) => taxonomy.visibility?.show_ui\n\t);\n\treturn visibleTaxonomies.map( ( taxonomy ) => {\n\t\tconst TaxonomyComponent = taxonomy.hierarchical\n\t\t\t? HierarchicalTermSelector\n\t\t\t: FlatTermSelector;\n\t\treturn (\n\t\t\t<Fragment key={ `taxonomy-${ taxonomy.slug }` }>\n\t\t\t\t{ taxonomyWrapper(\n\t\t\t\t\t<TaxonomyComponent slug={ taxonomy.slug } />,\n\t\t\t\t\ttaxonomy\n\t\t\t\t) }\n\t\t\t</Fragment>\n\t\t);\n\t} );\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostType: select( editorStore ).getCurrentPostType(),\n\t\t\ttaxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),\n\t\t};\n\t} ),\n] )( PostTaxonomies );\n"]}
@@ -43,6 +43,7 @@ function PostTextEditor() {
43
43
  const [value, setValue] = (0, _element.useState)(postContent);
44
44
  const [isDirty, setIsDirty] = (0, _element.useState)(false);
45
45
  const instanceId = (0, _compose.useInstanceId)(PostTextEditor);
46
+ const valueRef = (0, _element.useRef)();
46
47
 
47
48
  if (!isDirty && value !== postContent) {
48
49
  setValue(postContent);
@@ -67,6 +68,7 @@ function PostTextEditor() {
67
68
  });
68
69
  setValue(newValue);
69
70
  setIsDirty(true);
71
+ valueRef.current = newValue;
70
72
  };
71
73
  /**
72
74
  * Function called when the user has completed their edits, responsible for
@@ -81,8 +83,17 @@ function PostTextEditor() {
81
83
  resetEditorBlocks(blocks);
82
84
  setIsDirty(false);
83
85
  }
84
- };
86
+ }; // Ensure changes aren't lost when component unmounts.
87
+
85
88
 
89
+ (0, _element.useEffect)(() => {
90
+ return () => {
91
+ if (valueRef.current) {
92
+ const blocks = (0, _blocks.parse)(valueRef.current);
93
+ resetEditorBlocks(blocks);
94
+ }
95
+ };
96
+ }, []);
86
97
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.VisuallyHidden, {
87
98
  as: "label",
88
99
  htmlFor: `post-content-${instanceId}`
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/editor/src/components/post-text-editor/index.js"],"names":["PostTextEditor","postContent","select","editorStore","getEditedPostContent","editPost","resetEditorBlocks","value","setValue","isDirty","setIsDirty","instanceId","onChange","event","newValue","target","content","stopEditing","blocks"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,cAAT,GAA0B;AACxC,QAAMC,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAsBC,oBAAtB,EADK,EAEnB,EAFmB,CAApB;AAKA,QAAM;AAAEC,IAAAA,QAAF;A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EAAI,gBAAgBN,UAAY,EAPnC;AAQC,IAAA,WAAW,EAAG,cAAI,iCAAJ;AARf,IAPD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostTextEditor() {\n\tconst postContent = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostContent(),\n\t\t[]\n\t);\n\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tconst [ value, setValue ] = useState( postContent );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst instanceId = useInstanceId( PostTextEditor );\n\n\tif ( ! isDirty && value !== postContent ) {\n\t\tsetValue( postContent );\n\t}\n\n\t/**\n\t * Handles a textarea change event to notify the onChange prop callback and\n\t * reflect the new value in the component's own state. This marks the start\n\t * of the user's edits, if not already changed, preventing future props\n\t * changes to value from replacing the rendered value. This is expected to\n\t * be followed by a reset to dirty state via `stopEditing`.\n\t *\n\t * @see stopEditing\n\t *\n\t * @param {Event} event Change event.\n\t */\n\tconst onChange = ( event ) => {\n\t\tconst newValue = event.target.value;\n\t\teditPost( { content: newValue } );\n\t\tsetValue( newValue );\n\t\tsetIsDirty( true );\n\t};\n\n\t/**\n\t * Function called when the user has completed their edits, responsible for\n\t * ensuring that changes, if made, are surfaced to the onPersist prop\n\t * callback and resetting dirty state.\n\t */\n\tconst stopEditing = () => {\n\t\tif ( isDirty ) {\n\t\t\tconst blocks = parse( value );\n\t\t\tresetEditorBlocks( blocks );\n\t\t\tsetIsDirty( false );\n\t\t}\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `post-content-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonBlur={ stopEditing }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/editor/src/components/post-text-editor/index.js"],"names":["PostTextEditor","postContent","select","editorStore","getEditedPostContent","editPost","resetEditorBlocks","value","setValue","isDirty","setIsDirty","instanceId","valueRef","onChange","event","newValue","target","content","current","stopEditing","blocks"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,cAAT,GAA0B;AACxC,QAAMC,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAsBC,oBAAtB,EADK,EAEnB,EAFmB,CAApB;AAKA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAkC,uBAAaH,YAAb,CAAxC;AAEA,QAAM,CAAEI,KAAF,EAASC,QAAT,IAAsB,uBAAUP,WAAV,CAA5B;AACA,QAAM,CAAEQ,OAAF,EAAWC,UAAX,IAA0B,uBAAU,KAAV,CAAhC;AACA,QAAMC,UAAU,GAAG,4BAAeX,cAAf,CAAnB;AACA,QAAMY,QAAQ,GAAG,sBAAjB;;AAEA,MAAK,CAAEH,OAAF,IAAaF,KAAK,KAAKN,WAA5B,EAA0C;AACzCO,IAAAA,QAAQ,CAAEP,WAAF,CAAR;AACA;AAED;AACD;A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J;AARf,IAPD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useState, useRef } from '@wordpress/element';\nimport { parse } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function PostTextEditor() {\n\tconst postContent = useSelect(\n\t\t( select ) => select( editorStore ).getEditedPostContent(),\n\t\t[]\n\t);\n\n\tconst { editPost, resetEditorBlocks } = useDispatch( editorStore );\n\n\tconst [ value, setValue ] = useState( postContent );\n\tconst [ isDirty, setIsDirty ] = useState( false );\n\tconst instanceId = useInstanceId( PostTextEditor );\n\tconst valueRef = useRef();\n\n\tif ( ! isDirty && value !== postContent ) {\n\t\tsetValue( postContent );\n\t}\n\n\t/**\n\t * Handles a textarea change event to notify the onChange prop callback and\n\t * reflect the new value in the component's own state. This marks the start\n\t * of the user's edits, if not already changed, preventing future props\n\t * changes to value from replacing the rendered value. This is expected to\n\t * be followed by a reset to dirty state via `stopEditing`.\n\t *\n\t * @see stopEditing\n\t *\n\t * @param {Event} event Change event.\n\t */\n\tconst onChange = ( event ) => {\n\t\tconst newValue = event.target.value;\n\t\teditPost( { content: newValue } );\n\t\tsetValue( newValue );\n\t\tsetIsDirty( true );\n\t\tvalueRef.current = newValue;\n\t};\n\n\t/**\n\t * Function called when the user has completed their edits, responsible for\n\t * ensuring that changes, if made, are surfaced to the onPersist prop\n\t * callback and resetting dirty state.\n\t */\n\tconst stopEditing = () => {\n\t\tif ( isDirty ) {\n\t\t\tconst blocks = parse( value );\n\t\t\tresetEditorBlocks( blocks );\n\t\t\tsetIsDirty( false );\n\t\t}\n\t};\n\n\t// Ensure changes aren't lost when component unmounts.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( valueRef.current ) {\n\t\t\t\tconst blocks = parse( valueRef.current );\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `post-content-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonBlur={ stopEditing }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
@@ -5,11 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = exports.PostVisibility = void 0;
8
+ exports.default = PostVisibility;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
14
  var _i18n = require("@wordpress/i18n");
15
15
 
@@ -19,6 +19,8 @@ var _compose = require("@wordpress/compose");
19
19
 
20
20
  var _data = require("@wordpress/data");
21
21
 
22
+ var _icons = require("@wordpress/icons");
23
+
22
24
  var _utils = require("./utils");
23
25
 
24
26
  var _store = require("../../store");
@@ -30,178 +32,141 @@ var _store = require("../../store");
30
32
  /**
31
33
  * Internal dependencies
32
34
  */
33
- class PostVisibility extends _element.Component {
34
- constructor(props) {
35
- super(...arguments);
36
- (0, _defineProperty2.default)(this, "confirmPrivate", () => {
37
- const {
38
- onUpdateVisibility,
39
- onSave
40
- } = this.props;
41
- onUpdateVisibility('private');
42
- this.setState({
43
- hasPassword: false,
44
- showPrivateConfirmDialog: false
45
- });
46
- onSave();
47
- });
48
- (0, _defineProperty2.default)(this, "handleDialogCancel", () => {
49
- this.setState({
50
- showPrivateConfirmDialog: false
51
- });
52
- });
53
- this.setPublic = this.setPublic.bind(this);
54
- this.setPrivate = this.setPrivate.bind(this);
55
- this.setPasswordProtected = this.setPasswordProtected.bind(this);
56
- this.updatePassword = this.updatePassword.bind(this);
57
- this.state = {
58
- hasPassword: !!props.password,
59
- showPrivateConfirmDialog: false
60
- };
61
- }
62
-
63
- setPublic() {
64
- const {
65
- visibility,
66
- onUpdateVisibility,
67
- status
68
- } = this.props;
69
- onUpdateVisibility(visibility === 'private' ? 'draft' : status);
70
- this.setState({
71
- hasPassword: false
35
+ function PostVisibility(_ref) {
36
+ let {
37
+ onClose
38
+ } = _ref;
39
+ const instanceId = (0, _compose.useInstanceId)(PostVisibility);
40
+ const {
41
+ status,
42
+ visibility,
43
+ password
44
+ } = (0, _data.useSelect)(select => ({
45
+ status: select(_store.store).getEditedPostAttribute('status'),
46
+ visibility: select(_store.store).getEditedPostVisibility(),
47
+ password: select(_store.store).getEditedPostAttribute('password')
48
+ }));
49
+ const {
50
+ editPost,
51
+ savePost
52
+ } = (0, _data.useDispatch)(_store.store);
53
+ const [hasPassword, setHasPassword] = (0, _element.useState)(!!password);
54
+ const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0, _element.useState)(false);
55
+
56
+ const setPublic = () => {
57
+ editPost({
58
+ status: visibility === 'private' ? 'draft' : status,
59
+ password: ''
72
60
  });
73
- }
61
+ setHasPassword(false);
62
+ };
74
63
 
75
- setPrivate() {
76
- this.setState({
77
- showPrivateConfirmDialog: true
78
- });
79
- }
80
-
81
- setPasswordProtected() {
82
- const {
83
- visibility,
84
- onUpdateVisibility,
85
- status,
86
- password
87
- } = this.props;
88
- onUpdateVisibility(visibility === 'private' ? 'draft' : status, password || '');
89
- this.setState({
90
- hasPassword: true
91
- });
92
- }
93
-
94
- updatePassword(event) {
95
- const {
96
- status,
97
- onUpdateVisibility
98
- } = this.props;
99
- onUpdateVisibility(status, event.target.value);
100
- }
101
-
102
- render() {
103
- const {
104
- visibility,
105
- password,
106
- instanceId
107
- } = this.props;
108
- const visibilityHandlers = {
109
- public: {
110
- onSelect: this.setPublic,
111
- checked: visibility === 'public' && !this.state.hasPassword
112
- },
113
- private: {
114
- onSelect: this.setPrivate,
115
- checked: visibility === 'private'
116
- },
117
- password: {
118
- onSelect: this.setPasswordProtected,
119
- checked: this.state.hasPassword
120
- }
121
- };
122
- return [(0, _element.createElement)("fieldset", {
123
- key: "visibility-selector",
124
- className: "editor-post-visibility__dialog-fieldset"
125
- }, (0, _element.createElement)("legend", {
126
- className: "editor-post-visibility__dialog-legend"
127
- }, (0, _i18n.__)('Post Visibility')), _utils.visibilityOptions.map(_ref => {
128
- let {
129
- value,
130
- label,
131
- info
132
- } = _ref;
133
- return (0, _element.createElement)("div", {
134
- key: value,
135
- className: "editor-post-visibility__choice"
136
- }, (0, _element.createElement)("input", {
137
- type: "radio",
138
- name: `editor-post-visibility__setting-${instanceId}`,
139
- value: value,
140
- onChange: visibilityHandlers[value].onSelect,
141
- checked: visibilityHandlers[value].checked,
142
- id: `editor-post-${value}-${instanceId}`,
143
- "aria-describedby": `editor-post-${value}-${instanceId}-description`,
144
- className: "editor-post-visibility__dialog-radio"
145
- }), (0, _element.createElement)("label", {
146
- htmlFor: `editor-post-${value}-${instanceId}`,
147
- className: "editor-post-visibility__dialog-label"
148
- }, label), (0, _element.createElement)("p", {
149
- id: `editor-post-${value}-${instanceId}-description`,
150
- className: "editor-post-visibility__dialog-info"
151
- }, info));
152
- })), this.state.hasPassword && (0, _element.createElement)("div", {
153
- className: "editor-post-visibility__dialog-password",
154
- key: "password-selector"
155
- }, (0, _element.createElement)(_components.VisuallyHidden, {
156
- as: "label",
157
- htmlFor: `editor-post-visibility__dialog-password-input-${instanceId}`
158
- }, (0, _i18n.__)('Create password')), (0, _element.createElement)("input", {
159
- className: "editor-post-visibility__dialog-password-input",
160
- id: `editor-post-visibility__dialog-password-input-${instanceId}`,
161
- type: "text",
162
- onChange: this.updatePassword,
163
- value: password,
164
- placeholder: (0, _i18n.__)('Use a secure password')
165
- })), (0, _element.createElement)(_components.__experimentalConfirmDialog, {
166
- key: "private-publish-confirmation",
167
- isOpen: this.state.showPrivateConfirmDialog,
168
- onConfirm: this.confirmPrivate,
169
- onCancel: this.handleDialogCancel
170
- }, (0, _i18n.__)('Would you like to privately publish this post now?'))];
171
- }
64
+ const setPrivate = () => {
65
+ setShowPrivateConfirmDialog(true);
66
+ };
172
67
 
173
- }
68
+ const confirmPrivate = () => {
69
+ editPost({
70
+ status: 'private',
71
+ password: ''
72
+ });
73
+ setHasPassword(false);
74
+ setShowPrivateConfirmDialog(false);
75
+ savePost();
76
+ };
174
77
 
175
- exports.PostVisibility = PostVisibility;
78
+ const handleDialogCancel = () => {
79
+ setShowPrivateConfirmDialog(false);
80
+ };
176
81
 
177
- var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
178
- const {
179
- getEditedPostAttribute,
180
- getEditedPostVisibility
181
- } = select(_store.store);
182
- return {
183
- status: getEditedPostAttribute('status'),
184
- visibility: getEditedPostVisibility(),
185
- password: getEditedPostAttribute('password')
82
+ const setPasswordProtected = () => {
83
+ editPost({
84
+ status: visibility === 'private' ? 'draft' : status,
85
+ password: password || ''
86
+ });
87
+ setHasPassword(true);
186
88
  };
187
- }), (0, _data.withDispatch)(dispatch => {
188
- const {
189
- savePost,
190
- editPost
191
- } = dispatch(_store.store);
192
- return {
193
- onSave: savePost,
194
-
195
- onUpdateVisibility(status) {
196
- let password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
197
- editPost({
198
- status,
199
- password
200
- });
201
- }
202
89
 
90
+ const updatePassword = event => {
91
+ editPost({
92
+ password: event.target.value
93
+ });
203
94
  };
204
- }), _compose.withInstanceId])(PostVisibility);
205
95
 
206
- exports.default = _default;
96
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.Button, {
97
+ className: "editor-post-visibility__close",
98
+ isSmall: true,
99
+ icon: _icons.close,
100
+ onClick: onClose
101
+ }), (0, _element.createElement)("fieldset", {
102
+ className: "editor-post-visibility__fieldset"
103
+ }, (0, _element.createElement)("legend", {
104
+ className: "editor-post-visibility__legend"
105
+ }, (0, _i18n.__)('Visibility')), (0, _element.createElement)("p", {
106
+ className: "editor-post-visibility__description"
107
+ }, (0, _i18n.__)('Control how this post is viewed.')), (0, _element.createElement)(PostVisibilityChoice, {
108
+ instanceId: instanceId,
109
+ value: "public",
110
+ label: _utils.visibilityOptions.public.label,
111
+ info: _utils.visibilityOptions.public.info,
112
+ checked: visibility === 'public' && !hasPassword,
113
+ onChange: setPublic
114
+ }), (0, _element.createElement)(PostVisibilityChoice, {
115
+ instanceId: instanceId,
116
+ value: "private",
117
+ label: _utils.visibilityOptions.private.label,
118
+ info: _utils.visibilityOptions.private.info,
119
+ checked: visibility === 'private',
120
+ onChange: setPrivate
121
+ }), (0, _element.createElement)(PostVisibilityChoice, {
122
+ instanceId: instanceId,
123
+ value: "password",
124
+ label: _utils.visibilityOptions.password.label,
125
+ info: _utils.visibilityOptions.password.info,
126
+ checked: hasPassword,
127
+ onChange: setPasswordProtected
128
+ }), hasPassword && (0, _element.createElement)("div", {
129
+ className: "editor-post-visibility__password"
130
+ }, (0, _element.createElement)(_components.VisuallyHidden, {
131
+ as: "label",
132
+ htmlFor: `editor-post-visibility__password-input-${instanceId}`
133
+ }, (0, _i18n.__)('Create password')), (0, _element.createElement)("input", {
134
+ className: "editor-post-visibility__password-input",
135
+ id: `editor-post-visibility__password-input-${instanceId}`,
136
+ type: "text",
137
+ onChange: updatePassword,
138
+ value: password,
139
+ placeholder: (0, _i18n.__)('Use a secure password')
140
+ }))), (0, _element.createElement)(_components.__experimentalConfirmDialog, {
141
+ isOpen: showPrivateConfirmDialog,
142
+ onConfirm: confirmPrivate,
143
+ onCancel: handleDialogCancel
144
+ }, (0, _i18n.__)('Would you like to privately publish this post now?')));
145
+ }
146
+
147
+ function PostVisibilityChoice(_ref2) {
148
+ let {
149
+ instanceId,
150
+ value,
151
+ label,
152
+ info,
153
+ ...props
154
+ } = _ref2;
155
+ return (0, _element.createElement)("div", {
156
+ className: "editor-post-visibility__choice"
157
+ }, (0, _element.createElement)("input", (0, _extends2.default)({
158
+ type: "radio",
159
+ name: `editor-post-visibility__setting-${instanceId}`,
160
+ value: value,
161
+ id: `editor-post-${value}-${instanceId}`,
162
+ "aria-describedby": `editor-post-${value}-${instanceId}-description`,
163
+ className: "editor-post-visibility__radio"
164
+ }, props)), (0, _element.createElement)("label", {
165
+ htmlFor: `editor-post-${value}-${instanceId}`,
166
+ className: "editor-post-visibility__label"
167
+ }, label), (0, _element.createElement)("p", {
168
+ id: `editor-post-${value}-${instanceId}-description`,
169
+ className: "editor-post-visibility__info"
170
+ }, info));
171
+ }
207
172
  //# sourceMappingURL=index.js.map