@wordpress/edit-post 7.24.1 → 7.26.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 (267) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/browser-url/index.js +3 -2
  4. package/build/components/browser-url/index.js.map +1 -1
  5. package/build/components/header/index.js +35 -33
  6. package/build/components/header/index.js.map +1 -1
  7. package/build/components/header/mode-switcher/index.js +1 -1
  8. package/build/components/header/mode-switcher/index.js.map +1 -1
  9. package/build/components/header/more-menu/index.js +2 -1
  10. package/build/components/header/more-menu/index.js.map +1 -1
  11. package/build/components/header/writing-menu/index.js +22 -18
  12. package/build/components/header/writing-menu/index.js.map +1 -1
  13. package/build/components/keyboard-shortcuts/index.js +1 -20
  14. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  15. package/build/components/layout/index.js +45 -38
  16. package/build/components/layout/index.js.map +1 -1
  17. package/build/components/layout/index.native.js +3 -1
  18. package/build/components/layout/index.native.js.map +1 -1
  19. package/build/components/meta-boxes/meta-box-visibility.js +2 -6
  20. package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
  21. package/build/components/preferences-modal/index.js +87 -54
  22. package/build/components/preferences-modal/index.js.map +1 -1
  23. package/build/components/preferences-modal/options/enable-feature.js +23 -23
  24. package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
  25. package/build/components/preferences-modal/options/enable-panel.js +3 -6
  26. package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
  27. package/build/components/sidebar/plugin-document-setting-panel/index.js +3 -3
  28. package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
  29. package/build/components/sidebar/plugin-sidebar/index.js +2 -10
  30. package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
  31. package/build/components/sidebar/post-status/index.js +3 -5
  32. package/build/components/sidebar/post-status/index.js.map +1 -1
  33. package/build/components/sidebar/settings-header/index.js +17 -43
  34. package/build/components/sidebar/settings-header/index.js.map +1 -1
  35. package/build/components/sidebar/settings-sidebar/index.js +80 -26
  36. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  37. package/build/components/start-page-options/index.js +3 -3
  38. package/build/components/start-page-options/index.js.map +1 -1
  39. package/build/components/visual-editor/index.js +20 -257
  40. package/build/components/visual-editor/index.js.map +1 -1
  41. package/build/components/welcome-guide/index.js +6 -3
  42. package/build/components/welcome-guide/index.js.map +1 -1
  43. package/build/editor.js +20 -30
  44. package/build/editor.js.map +1 -1
  45. package/build/editor.native.js +3 -11
  46. package/build/editor.native.js.map +1 -1
  47. package/build/hooks/commands/use-common-commands.js +16 -12
  48. package/build/hooks/commands/use-common-commands.js.map +1 -1
  49. package/build/hooks/use-post-history.js +79 -0
  50. package/build/hooks/use-post-history.js.map +1 -0
  51. package/build/index.js +24 -20
  52. package/build/index.js.map +1 -1
  53. package/build/index.native.js +7 -1
  54. package/build/index.native.js.map +1 -1
  55. package/build/plugins/welcome-guide-menu-item/index.js +2 -6
  56. package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
  57. package/build/store/actions.js +94 -112
  58. package/build/store/actions.js.map +1 -1
  59. package/build/store/reducer.js +1 -95
  60. package/build/store/reducer.js.map +1 -1
  61. package/build/store/selectors.js +86 -48
  62. package/build/store/selectors.js.map +1 -1
  63. package/build-module/components/browser-url/index.js +3 -2
  64. package/build-module/components/browser-url/index.js.map +1 -1
  65. package/build-module/components/header/index.js +37 -35
  66. package/build-module/components/header/index.js.map +1 -1
  67. package/build-module/components/header/mode-switcher/index.js +1 -1
  68. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  69. package/build-module/components/header/more-menu/index.js +2 -1
  70. package/build-module/components/header/more-menu/index.js.map +1 -1
  71. package/build-module/components/header/writing-menu/index.js +23 -19
  72. package/build-module/components/header/writing-menu/index.js.map +1 -1
  73. package/build-module/components/keyboard-shortcuts/index.js +1 -20
  74. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  75. package/build-module/components/layout/index.js +46 -38
  76. package/build-module/components/layout/index.js.map +1 -1
  77. package/build-module/components/layout/index.native.js +4 -2
  78. package/build-module/components/layout/index.native.js.map +1 -1
  79. package/build-module/components/meta-boxes/meta-box-visibility.js +2 -6
  80. package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
  81. package/build-module/components/preferences-modal/index.js +87 -54
  82. package/build-module/components/preferences-modal/index.js.map +1 -1
  83. package/build-module/components/preferences-modal/options/enable-feature.js +22 -23
  84. package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
  85. package/build-module/components/preferences-modal/options/enable-panel.js +3 -7
  86. package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
  87. package/build-module/components/sidebar/plugin-document-setting-panel/index.js +3 -3
  88. package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
  89. package/build-module/components/sidebar/plugin-sidebar/index.js +2 -10
  90. package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
  91. package/build-module/components/sidebar/post-status/index.js +4 -6
  92. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  93. package/build-module/components/sidebar/settings-header/index.js +20 -46
  94. package/build-module/components/sidebar/settings-header/index.js.map +1 -1
  95. package/build-module/components/sidebar/settings-sidebar/index.js +80 -27
  96. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  97. package/build-module/components/start-page-options/index.js +3 -3
  98. package/build-module/components/start-page-options/index.js.map +1 -1
  99. package/build-module/components/visual-editor/index.js +24 -261
  100. package/build-module/components/visual-editor/index.js.map +1 -1
  101. package/build-module/components/welcome-guide/index.js +6 -3
  102. package/build-module/components/welcome-guide/index.js.map +1 -1
  103. package/build-module/editor.js +20 -30
  104. package/build-module/editor.js.map +1 -1
  105. package/build-module/editor.native.js +3 -11
  106. package/build-module/editor.native.js.map +1 -1
  107. package/build-module/hooks/commands/use-common-commands.js +16 -12
  108. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  109. package/build-module/hooks/use-post-history.js +73 -0
  110. package/build-module/hooks/use-post-history.js.map +1 -0
  111. package/build-module/index.js +19 -12
  112. package/build-module/index.js.map +1 -1
  113. package/build-module/index.native.js +7 -1
  114. package/build-module/index.native.js.map +1 -1
  115. package/build-module/plugins/welcome-guide-menu-item/index.js +2 -6
  116. package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
  117. package/build-module/store/actions.js +86 -105
  118. package/build-module/store/actions.js.map +1 -1
  119. package/build-module/store/reducer.js +1 -92
  120. package/build-module/store/reducer.js.map +1 -1
  121. package/build-module/store/selectors.js +76 -38
  122. package/build-module/store/selectors.js.map +1 -1
  123. package/build-style/style-rtl.css +65 -473
  124. package/build-style/style.css +65 -473
  125. package/package.json +32 -32
  126. package/src/components/browser-url/index.js +4 -2
  127. package/src/components/header/index.js +45 -46
  128. package/src/components/header/mode-switcher/index.js +2 -1
  129. package/src/components/header/more-menu/index.js +1 -0
  130. package/src/components/header/style.scss +63 -37
  131. package/src/components/header/writing-menu/index.js +24 -24
  132. package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -15
  133. package/src/components/keyboard-shortcuts/index.js +1 -23
  134. package/src/components/layout/index.js +31 -39
  135. package/src/components/layout/index.native.js +9 -1
  136. package/src/components/meta-boxes/meta-box-visibility.js +2 -8
  137. package/src/components/preferences-modal/index.js +128 -97
  138. package/src/components/preferences-modal/options/enable-feature.js +26 -21
  139. package/src/components/preferences-modal/options/enable-panel.js +3 -7
  140. package/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap +187 -175
  141. package/src/components/preferences-modal/test/index.js +1 -52
  142. package/src/components/sidebar/plugin-document-setting-panel/index.js +3 -3
  143. package/src/components/sidebar/plugin-sidebar/index.js +1 -9
  144. package/src/components/sidebar/post-status/index.js +5 -5
  145. package/src/components/sidebar/settings-header/index.js +19 -71
  146. package/src/components/sidebar/settings-sidebar/index.js +125 -60
  147. package/src/components/sidebar/style.scss +4 -12
  148. package/src/components/start-page-options/index.js +3 -3
  149. package/src/components/text-editor/style.scss +0 -6
  150. package/src/components/visual-editor/index.js +26 -359
  151. package/src/components/visual-editor/style.scss +0 -15
  152. package/src/components/welcome-guide/index.js +4 -2
  153. package/src/editor.js +36 -35
  154. package/src/editor.native.js +2 -23
  155. package/src/hooks/commands/use-common-commands.js +14 -16
  156. package/src/hooks/use-post-history.js +73 -0
  157. package/src/index.js +24 -13
  158. package/src/index.native.js +8 -1
  159. package/src/plugins/welcome-guide-menu-item/index.js +3 -6
  160. package/src/store/actions.js +80 -131
  161. package/src/store/reducer.js +0 -93
  162. package/src/store/selectors.js +97 -55
  163. package/src/store/test/actions.js +10 -131
  164. package/src/store/test/reducer.js +1 -108
  165. package/src/store/test/selectors.js +0 -50
  166. package/src/style.scss +1 -8
  167. package/src/test/__snapshots__/editor.native.js.snap +21 -0
  168. package/src/test/editor.native.js +107 -56
  169. package/build/components/device-preview/index.js +0 -72
  170. package/build/components/device-preview/index.js.map +0 -1
  171. package/build/components/header/document-actions/index.js +0 -82
  172. package/build/components/header/document-actions/index.js.map +0 -1
  173. package/build/components/header/header-toolbar/index.js +0 -156
  174. package/build/components/header/header-toolbar/index.js.map +0 -1
  175. package/build/components/secondary-sidebar/inserter-sidebar.js +0 -73
  176. package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  177. package/build/components/secondary-sidebar/list-view-outline.js +0 -112
  178. package/build/components/secondary-sidebar/list-view-outline.js.map +0 -1
  179. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -148
  180. package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  181. package/build/components/sidebar/discussion-panel/index.js +0 -59
  182. package/build/components/sidebar/discussion-panel/index.js.map +0 -1
  183. package/build/components/sidebar/featured-image/index.js +0 -70
  184. package/build/components/sidebar/featured-image/index.js.map +0 -1
  185. package/build/components/sidebar/last-revision/index.js +0 -21
  186. package/build/components/sidebar/last-revision/index.js.map +0 -1
  187. package/build/components/sidebar/page-attributes/index.js +0 -65
  188. package/build/components/sidebar/page-attributes/index.js.map +0 -1
  189. package/build/components/sidebar/plugin-post-excerpt/index.js +0 -72
  190. package/build/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
  191. package/build/components/sidebar/post-excerpt/index.js +0 -54
  192. package/build/components/sidebar/post-excerpt/index.js.map +0 -1
  193. package/build/components/sidebar/post-taxonomies/index.js +0 -30
  194. package/build/components/sidebar/post-taxonomies/index.js.map +0 -1
  195. package/build/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -56
  196. package/build/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
  197. package/build/components/sidebar/post-template/create-modal.js +0 -99
  198. package/build/components/sidebar/post-template/create-modal.js.map +0 -1
  199. package/build/components/sidebar/post-template/form.js +0 -110
  200. package/build/components/sidebar/post-template/form.js.map +0 -1
  201. package/build/components/sidebar/post-template/index.js +0 -106
  202. package/build/components/sidebar/post-template/index.js.map +0 -1
  203. package/build/components/view-link/index.js +0 -53
  204. package/build/components/view-link/index.js.map +0 -1
  205. package/build-module/components/device-preview/index.js +0 -65
  206. package/build-module/components/device-preview/index.js.map +0 -1
  207. package/build-module/components/header/document-actions/index.js +0 -74
  208. package/build-module/components/header/document-actions/index.js.map +0 -1
  209. package/build-module/components/header/header-toolbar/index.js +0 -148
  210. package/build-module/components/header/header-toolbar/index.js.map +0 -1
  211. package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -66
  212. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  213. package/build-module/components/secondary-sidebar/list-view-outline.js +0 -105
  214. package/build-module/components/secondary-sidebar/list-view-outline.js.map +0 -1
  215. package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -140
  216. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  217. package/build-module/components/sidebar/discussion-panel/index.js +0 -52
  218. package/build-module/components/sidebar/discussion-panel/index.js.map +0 -1
  219. package/build-module/components/sidebar/featured-image/index.js +0 -63
  220. package/build-module/components/sidebar/featured-image/index.js.map +0 -1
  221. package/build-module/components/sidebar/last-revision/index.js +0 -13
  222. package/build-module/components/sidebar/last-revision/index.js.map +0 -1
  223. package/build-module/components/sidebar/page-attributes/index.js +0 -57
  224. package/build-module/components/sidebar/page-attributes/index.js.map +0 -1
  225. package/build-module/components/sidebar/plugin-post-excerpt/index.js +0 -64
  226. package/build-module/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
  227. package/build-module/components/sidebar/post-excerpt/index.js +0 -47
  228. package/build-module/components/sidebar/post-excerpt/index.js.map +0 -1
  229. package/build-module/components/sidebar/post-taxonomies/index.js +0 -21
  230. package/build-module/components/sidebar/post-taxonomies/index.js.map +0 -1
  231. package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
  232. package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
  233. package/build-module/components/sidebar/post-template/create-modal.js +0 -92
  234. package/build-module/components/sidebar/post-template/create-modal.js.map +0 -1
  235. package/build-module/components/sidebar/post-template/form.js +0 -102
  236. package/build-module/components/sidebar/post-template/form.js.map +0 -1
  237. package/build-module/components/sidebar/post-template/index.js +0 -98
  238. package/build-module/components/sidebar/post-template/index.js.map +0 -1
  239. package/build-module/components/view-link/index.js +0 -46
  240. package/build-module/components/view-link/index.js.map +0 -1
  241. package/src/components/device-preview/index.js +0 -73
  242. package/src/components/header/document-actions/index.js +0 -82
  243. package/src/components/header/document-actions/style.scss +0 -64
  244. package/src/components/header/header-toolbar/index.js +0 -182
  245. package/src/components/header/header-toolbar/style.scss +0 -114
  246. package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +0 -929
  247. package/src/components/secondary-sidebar/inserter-sidebar.js +0 -71
  248. package/src/components/secondary-sidebar/list-view-outline.js +0 -98
  249. package/src/components/secondary-sidebar/list-view-sidebar.js +0 -170
  250. package/src/components/secondary-sidebar/style.scss +0 -120
  251. package/src/components/sidebar/discussion-panel/index.js +0 -62
  252. package/src/components/sidebar/featured-image/index.js +0 -67
  253. package/src/components/sidebar/last-revision/index.js +0 -17
  254. package/src/components/sidebar/last-revision/style.scss +0 -10
  255. package/src/components/sidebar/page-attributes/index.js +0 -65
  256. package/src/components/sidebar/plugin-post-excerpt/index.js +0 -61
  257. package/src/components/sidebar/plugin-post-excerpt/test/index.js +0 -36
  258. package/src/components/sidebar/post-excerpt/index.js +0 -59
  259. package/src/components/sidebar/post-taxonomies/index.js +0 -30
  260. package/src/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
  261. package/src/components/sidebar/post-template/create-modal.js +0 -140
  262. package/src/components/sidebar/post-template/form.js +0 -141
  263. package/src/components/sidebar/post-template/index.js +0 -120
  264. package/src/components/sidebar/post-template/style.scss +0 -22
  265. package/src/components/sidebar/settings-header/style.scss +0 -74
  266. package/src/components/sidebar/template/style.scss +0 -35
  267. package/src/components/view-link/index.js +0 -48
@@ -1 +0,0 @@
1
- {"version":3,"names":["__","PanelBody","PostExcerpt","PostExcerptForm","PostExcerptCheck","useDispatch","useSelect","store","editPostStore","PluginPostExcerpt","PANEL_NAME","isOpened","isEnabled","select","isEditorPanelOpened","isEditorPanelEnabled","toggleEditorPanelOpened","toggleExcerptPanel","createElement","title","opened","onToggle","Slot","fills","Fragment"],"sources":["@wordpress/edit-post/src/components/sidebar/post-excerpt/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport {\n\tPostExcerpt as PostExcerptForm,\n\tPostExcerptCheck,\n} from '@wordpress/editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport PluginPostExcerpt from '../plugin-post-excerpt';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-excerpt';\n\nexport default function PostExcerpt() {\n\tconst { isOpened, isEnabled } = useSelect( ( select ) => {\n\t\tconst { isEditorPanelOpened, isEditorPanelEnabled } =\n\t\t\tselect( editPostStore );\n\n\t\treturn {\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editPostStore );\n\tconst toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ __( 'Excerpt' ) }\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ toggleExcerptPanel }\n\t\t\t>\n\t\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<PostExcerptForm />\n\t\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PluginPostExcerpt.Slot>\n\t\t\t</PanelBody>\n\t\t</PostExcerptCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SACCC,WAAW,IAAIC,eAAe,EAC9BC,gBAAgB,QACV,mBAAmB;AAC1B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,gBAAgB;AACvD,OAAOC,iBAAiB,MAAM,wBAAwB;;AAEtD;AACA;AACA;AACA,MAAMC,UAAU,GAAG,cAAc;AAEjC,eAAe,SAASR,WAAWA,CAAA,EAAG;EACrC,MAAM;IAAES,QAAQ;IAAEC;EAAU,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IACxD,MAAM;MAAEC,mBAAmB;MAAEC;IAAqB,CAAC,GAClDF,MAAM,CAAEL,aAAc,CAAC;IAExB,OAAO;MACNG,QAAQ,EAAEG,mBAAmB,CAAEJ,UAAW,CAAC;MAC3CE,SAAS,EAAEG,oBAAoB,CAAEL,UAAW;IAC7C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAEM;EAAwB,CAAC,GAAGX,WAAW,CAAEG,aAAc,CAAC;EAChE,MAAMS,kBAAkB,GAAGA,CAAA,KAAMD,uBAAuB,CAAEN,UAAW,CAAC;EAEtE,IAAK,CAAEE,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OACCM,aAAA,CAACd,gBAAgB,QAChBc,aAAA,CAACjB,SAAS;IACTkB,KAAK,EAAGnB,EAAE,CAAE,SAAU,CAAG;IACzBoB,MAAM,EAAGT,QAAU;IACnBU,QAAQ,EAAGJ;EAAoB,GAE/BC,aAAA,CAACT,iBAAiB,CAACa,IAAI,QAClBC,KAAK,IACRL,aAAA,CAAAM,QAAA,QACCN,aAAA,CAACf,eAAe,MAAE,CAAC,EACjBoB,KACD,CAEoB,CACd,CACM,CAAC;AAErB"}
@@ -1,21 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { PostTaxonomies as PostTaxonomiesForm, PostTaxonomiesCheck } from '@wordpress/editor';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import TaxonomyPanel from './taxonomy-panel';
11
- function PostTaxonomies() {
12
- return createElement(PostTaxonomiesCheck, null, createElement(PostTaxonomiesForm, {
13
- taxonomyWrapper: (content, taxonomy) => {
14
- return createElement(TaxonomyPanel, {
15
- taxonomy: taxonomy
16
- }, content);
17
- }
18
- }));
19
- }
20
- export default PostTaxonomies;
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["PostTaxonomies","PostTaxonomiesForm","PostTaxonomiesCheck","TaxonomyPanel","createElement","taxonomyWrapper","content","taxonomy"],"sources":["@wordpress/edit-post/src/components/sidebar/post-taxonomies/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPostTaxonomies as PostTaxonomiesForm,\n\tPostTaxonomiesCheck,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport TaxonomyPanel from './taxonomy-panel';\n\nfunction PostTaxonomies() {\n\treturn (\n\t\t<PostTaxonomiesCheck>\n\t\t\t<PostTaxonomiesForm\n\t\t\t\ttaxonomyWrapper={ ( content, taxonomy ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TaxonomyPanel taxonomy={ taxonomy }>\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</TaxonomyPanel>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t</PostTaxonomiesCheck>\n\t);\n}\n\nexport default PostTaxonomies;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,cAAc,IAAIC,kBAAkB,EACpCC,mBAAmB,QACb,mBAAmB;;AAE1B;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAE5C,SAASH,cAAcA,CAAA,EAAG;EACzB,OACCI,aAAA,CAACF,mBAAmB,QACnBE,aAAA,CAACH,kBAAkB;IAClBI,eAAe,EAAGA,CAAEC,OAAO,EAAEC,QAAQ,KAAM;MAC1C,OACCH,aAAA,CAACD,aAAa;QAACI,QAAQ,EAAGA;MAAU,GACjCD,OACY,CAAC;IAElB;EAAG,CACH,CACmB,CAAC;AAExB;AAEA,eAAeN,cAAc"}
@@ -1,48 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { PanelBody } from '@wordpress/components';
6
- import { useSelect, useDispatch } from '@wordpress/data';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import { store as editPostStore } from '../../../store';
12
- function TaxonomyPanel({
13
- taxonomy,
14
- children
15
- }) {
16
- const slug = taxonomy?.slug;
17
- const panelName = slug ? `taxonomy-panel-${slug}` : '';
18
- const {
19
- isEnabled,
20
- isOpened
21
- } = useSelect(select => {
22
- const {
23
- isEditorPanelEnabled,
24
- isEditorPanelOpened
25
- } = select(editPostStore);
26
- return {
27
- isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
28
- isOpened: slug ? isEditorPanelOpened(panelName) : false
29
- };
30
- }, [panelName, slug]);
31
- const {
32
- toggleEditorPanelOpened
33
- } = useDispatch(editPostStore);
34
- if (!isEnabled) {
35
- return null;
36
- }
37
- const taxonomyMenuName = taxonomy?.labels?.menu_name;
38
- if (!taxonomyMenuName) {
39
- return null;
40
- }
41
- return createElement(PanelBody, {
42
- title: taxonomyMenuName,
43
- opened: isOpened,
44
- onToggle: () => toggleEditorPanelOpened(panelName)
45
- }, children);
46
- }
47
- export default TaxonomyPanel;
48
- //# sourceMappingURL=taxonomy-panel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["PanelBody","useSelect","useDispatch","store","editPostStore","TaxonomyPanel","taxonomy","children","slug","panelName","isEnabled","isOpened","select","isEditorPanelEnabled","isEditorPanelOpened","toggleEditorPanelOpened","taxonomyMenuName","labels","menu_name","createElement","title","opened","onToggle"],"sources":["@wordpress/edit-post/src/components/sidebar/post-taxonomies/taxonomy-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nfunction TaxonomyPanel( { taxonomy, children } ) {\n\tconst slug = taxonomy?.slug;\n\tconst panelName = slug ? `taxonomy-panel-${ slug }` : '';\n\tconst { isEnabled, isOpened } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } =\n\t\t\t\tselect( editPostStore );\n\t\t\treturn {\n\t\t\t\tisEnabled: slug ? isEditorPanelEnabled( panelName ) : false,\n\t\t\t\tisOpened: slug ? isEditorPanelOpened( panelName ) : false,\n\t\t\t};\n\t\t},\n\t\t[ panelName, slug ]\n\t);\n\tconst { toggleEditorPanelOpened } = useDispatch( editPostStore );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst taxonomyMenuName = taxonomy?.labels?.menu_name;\n\tif ( ! taxonomyMenuName ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ taxonomyMenuName }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ () => toggleEditorPanelOpened( panelName ) }\n\t\t>\n\t\t\t{ children }\n\t\t</PanelBody>\n\t);\n}\n\nexport default TaxonomyPanel;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,gBAAgB;AAEvD,SAASC,aAAaA,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EAChD,MAAMC,IAAI,GAAGF,QAAQ,EAAEE,IAAI;EAC3B,MAAMC,SAAS,GAAGD,IAAI,GAAI,kBAAkBA,IAAM,EAAC,GAAG,EAAE;EACxD,MAAM;IAAEE,SAAS;IAAEC;EAAS,CAAC,GAAGV,SAAS,CACtCW,MAAM,IAAM;IACb,MAAM;MAAEC,oBAAoB;MAAEC;IAAoB,CAAC,GAClDF,MAAM,CAAER,aAAc,CAAC;IACxB,OAAO;MACNM,SAAS,EAAEF,IAAI,GAAGK,oBAAoB,CAAEJ,SAAU,CAAC,GAAG,KAAK;MAC3DE,QAAQ,EAAEH,IAAI,GAAGM,mBAAmB,CAAEL,SAAU,CAAC,GAAG;IACrD,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,EAAED,IAAI,CAClB,CAAC;EACD,MAAM;IAAEO;EAAwB,CAAC,GAAGb,WAAW,CAAEE,aAAc,CAAC;EAEhE,IAAK,CAAEM,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,MAAMM,gBAAgB,GAAGV,QAAQ,EAAEW,MAAM,EAAEC,SAAS;EACpD,IAAK,CAAEF,gBAAgB,EAAG;IACzB,OAAO,IAAI;EACZ;EAEA,OACCG,aAAA,CAACnB,SAAS;IACToB,KAAK,EAAGJ,gBAAkB;IAC1BK,MAAM,EAAGV,QAAU;IACnBW,QAAQ,EAAGA,CAAA,KAAMP,uBAAuB,CAAEN,SAAU;EAAG,GAErDF,QACQ,CAAC;AAEd;AAEA,eAAeF,aAAa"}
@@ -1,92 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { useSelect, useDispatch } from '@wordpress/data';
6
- import { store as editorStore } from '@wordpress/editor';
7
- import { useState } from '@wordpress/element';
8
- import { serialize, createBlock } from '@wordpress/blocks';
9
- import { Modal, TextControl, Button, __experimentalHStack as HStack, __experimentalVStack as VStack } from '@wordpress/components';
10
- import { __ } from '@wordpress/i18n';
11
- import { cleanForSlug } from '@wordpress/url';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { store as editPostStore } from '../../../store';
17
- const DEFAULT_TITLE = __('Custom Template');
18
- export default function PostTemplateCreateModal({
19
- onClose
20
- }) {
21
- const defaultBlockTemplate = useSelect(select => select(editorStore).getEditorSettings().defaultBlockTemplate, []);
22
- const {
23
- __unstableCreateTemplate,
24
- __unstableSwitchToTemplateMode
25
- } = useDispatch(editPostStore);
26
- const [title, setTitle] = useState('');
27
- const [isBusy, setIsBusy] = useState(false);
28
- const cancel = () => {
29
- setTitle('');
30
- onClose();
31
- };
32
- const submit = async event => {
33
- event.preventDefault();
34
- if (isBusy) {
35
- return;
36
- }
37
- setIsBusy(true);
38
- const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : serialize([createBlock('core/group', {
39
- tagName: 'header',
40
- layout: {
41
- inherit: true
42
- }
43
- }, [createBlock('core/site-title'), createBlock('core/site-tagline')]), createBlock('core/separator'), createBlock('core/group', {
44
- tagName: 'main'
45
- }, [createBlock('core/group', {
46
- layout: {
47
- inherit: true
48
- }
49
- }, [createBlock('core/post-title')]), createBlock('core/post-content', {
50
- layout: {
51
- inherit: true
52
- }
53
- })])]);
54
- await __unstableCreateTemplate({
55
- slug: cleanForSlug(title || DEFAULT_TITLE),
56
- content: newTemplateContent,
57
- title: title || DEFAULT_TITLE
58
- });
59
- setIsBusy(false);
60
- cancel();
61
- __unstableSwitchToTemplateMode(true);
62
- };
63
- return createElement(Modal, {
64
- title: __('Create custom template'),
65
- onRequestClose: cancel,
66
- className: "edit-post-post-template__create-modal"
67
- }, createElement("form", {
68
- className: "edit-post-post-template__create-form",
69
- onSubmit: submit
70
- }, createElement(VStack, {
71
- spacing: "3"
72
- }, createElement(TextControl, {
73
- __nextHasNoMarginBottom: true,
74
- label: __('Name'),
75
- value: title,
76
- onChange: setTitle,
77
- placeholder: DEFAULT_TITLE,
78
- disabled: isBusy,
79
- help: __('Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.')
80
- }), createElement(HStack, {
81
- justify: "right"
82
- }, createElement(Button, {
83
- variant: "tertiary",
84
- onClick: cancel
85
- }, __('Cancel')), createElement(Button, {
86
- variant: "primary",
87
- type: "submit",
88
- isBusy: isBusy,
89
- "aria-disabled": isBusy
90
- }, __('Create'))))));
91
- }
92
- //# sourceMappingURL=create-modal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useSelect","useDispatch","store","editorStore","useState","serialize","createBlock","Modal","TextControl","Button","__experimentalHStack","HStack","__experimentalVStack","VStack","__","cleanForSlug","editPostStore","DEFAULT_TITLE","PostTemplateCreateModal","onClose","defaultBlockTemplate","select","getEditorSettings","__unstableCreateTemplate","__unstableSwitchToTemplateMode","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","slug","content","createElement","onRequestClose","className","onSubmit","spacing","__nextHasNoMarginBottom","label","value","onChange","placeholder","disabled","help","justify","variant","onClick","type"],"sources":["@wordpress/edit-post/src/components/sidebar/post-template/create-modal.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tTextControl,\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function PostTemplateCreateModal( { onClose } ) {\n\tconst defaultBlockTemplate = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditorSettings().defaultBlockTemplate,\n\t\t[]\n\t);\n\n\tconst { __unstableCreateTemplate, __unstableSwitchToTemplateMode } =\n\t\tuseDispatch( editPostStore );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tawait __unstableCreateTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tcancel();\n\n\t\t__unstableSwitchToTemplateMode( true );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tclassName=\"edit-post-post-template__create-modal\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"edit-post-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<VStack spacing=\"3\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". A custom template can be manually applied to any post or page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ cancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype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AS,EAAC;EAAuC,GAEjDF,aAAA;IACCE,SAAS,EAAC,sCAAsC;IAChDC,QAAQ,EAAGZ;EAAQ,GAEnBS,aAAA,CAAC1B,MAAM;IAAC8B,OAAO,EAAC;EAAG,GAClBJ,aAAA,CAAC/B,WAAW;IACXoC,uBAAuB;IACvBC,KAAK,EAAG/B,EAAE,CAAE,MAAO,CAAG;IACtBgC,KAAK,EAAGrB,KAAO;IACfsB,QAAQ,EAAGrB,QAAU;IACrBsB,WAAW,EAAG/B,aAAe;IAC7BgC,QAAQ,EAAGtB,MAAQ;IACnBuB,IAAI,EAAGpC,EAAE,CACR,iHACD;EAAG,CACH,CAAC,EACFyB,aAAA,CAAC5B,MAAM;IAACwC,OAAO,EAAC;EAAO,GACtBZ,aAAA,CAAC9B,MAAM;IAAC2C,OAAO,EAAC,UAAU;IAACC,OAAO,EAAGxB;EAAQ,GAC1Cf,EAAE,CAAE,QAAS,CACR,CAAC,EAETyB,aAAA,CAAC9B,MAAM;IACN2C,OAAO,EAAC,SAAS;IACjBE,IAAI,EAAC,QAAQ;IACb3B,MAAM,EAAGA,MAAQ;IACjB,iBAAgBA;EAAQ,GAEtBb,EAAE,CAAE,QAAS,CACR,CACD,CACD,CACH,CACA,CAAC;AAEV"}
@@ -1,102 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { useState, useMemo } from '@wordpress/element';
6
- import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
7
- import { __ } from '@wordpress/i18n';
8
- import { addTemplate } from '@wordpress/icons';
9
- import { Notice, SelectControl, Button } from '@wordpress/components';
10
- import { useSelect, useDispatch } from '@wordpress/data';
11
- import { store as editorStore } from '@wordpress/editor';
12
- import { store as coreStore } from '@wordpress/core-data';
13
-
14
- /**
15
- * Internal dependencies
16
- */
17
- import { store as editPostStore } from '../../../store';
18
- import PostTemplateCreateModal from './create-modal';
19
- export default function PostTemplateForm({
20
- onClose
21
- }) {
22
- var _options$find, _selectedOption$value;
23
- const {
24
- isPostsPage,
25
- availableTemplates,
26
- fetchedTemplates,
27
- selectedTemplateSlug,
28
- canCreate,
29
- canEdit
30
- } = useSelect(select => {
31
- const {
32
- canUser,
33
- getEntityRecord,
34
- getEntityRecords
35
- } = select(coreStore);
36
- const editorSettings = select(editorStore).getEditorSettings();
37
- const siteSettings = canUser('read', 'settings') ? getEntityRecord('root', 'site') : undefined;
38
- const _isPostsPage = select(editorStore).getCurrentPostId() === siteSettings?.page_for_posts;
39
- const canCreateTemplates = canUser('create', 'templates');
40
- return {
41
- isPostsPage: _isPostsPage,
42
- availableTemplates: editorSettings.availableTemplates,
43
- fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
44
- post_type: select(editorStore).getCurrentPostType(),
45
- per_page: -1
46
- }) : undefined,
47
- selectedTemplateSlug: select(editorStore).getEditedPostAttribute('template'),
48
- canCreate: canCreateTemplates && !_isPostsPage && editorSettings.supportsTemplateMode,
49
- canEdit: canCreateTemplates && editorSettings.supportsTemplateMode && !!select(editPostStore).getEditedPostTemplate()
50
- };
51
- }, []);
52
- const options = useMemo(() => Object.entries({
53
- ...availableTemplates,
54
- ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
55
- slug,
56
- title
57
- }) => [slug, title.rendered]))
58
- }).map(([slug, title]) => ({
59
- value: slug,
60
- label: title
61
- })), [availableTemplates, fetchedTemplates]);
62
- const selectedOption = (_options$find = options.find(option => option.value === selectedTemplateSlug)) !== null && _options$find !== void 0 ? _options$find : options.find(option => !option.value); // The default option has '' value.
63
-
64
- const {
65
- editPost
66
- } = useDispatch(editorStore);
67
- const {
68
- __unstableSwitchToTemplateMode
69
- } = useDispatch(editPostStore);
70
- const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
71
- return createElement("div", {
72
- className: "edit-post-post-template__form"
73
- }, createElement(InspectorPopoverHeader, {
74
- title: __('Template'),
75
- help: __('Templates define the way content is displayed when viewing your site.'),
76
- actions: canCreate ? [{
77
- icon: addTemplate,
78
- label: __('Add template'),
79
- onClick: () => setIsCreateModalOpen(true)
80
- }] : [],
81
- onClose: onClose
82
- }), isPostsPage ? createElement(Notice, {
83
- className: "edit-post-post-template__notice",
84
- status: "warning",
85
- isDismissible: false
86
- }, __('The posts page template cannot be changed.')) : createElement(SelectControl, {
87
- __nextHasNoMarginBottom: true,
88
- hideLabelFromVision: true,
89
- label: __('Template'),
90
- value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
91
- options: options,
92
- onChange: slug => editPost({
93
- template: slug || ''
94
- })
95
- }), canEdit && createElement("p", null, createElement(Button, {
96
- variant: "link",
97
- onClick: () => __unstableSwitchToTemplateMode()
98
- }, __('Edit template'))), isCreateModalOpen && createElement(PostTemplateCreateModal, {
99
- onClose: () => setIsCreateModalOpen(false)
100
- }));
101
- }
102
- //# sourceMappingURL=form.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useState","useMemo","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","__","addTemplate","Notice","SelectControl","Button","useSelect","useDispatch","store","editorStore","coreStore","editPostStore","PostTemplateCreateModal","PostTemplateForm","onClose","_options$find","_selectedOption$value","isPostsPage","availableTemplates","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","select","canUser","getEntityRecord","getEntityRecords","editorSettings","getEditorSettings","siteSettings","undefined","_isPostsPage","getCurrentPostId","page_for_posts","canCreateTemplates","post_type","getCurrentPostType","per_page","getEditedPostAttribute","supportsTemplateMode","getEditedPostTemplate","options","Object","entries","fromEntries","map","slug","title","rendered","value","label","selectedOption","find","option","editPost","__unstableSwitchToTemplateMode","isCreateModalOpen","setIsCreateModalOpen","createElement","className","help","actions","icon","onClick","status","isDismissible","__nextHasNoMarginBottom","hideLabelFromVision","onChange","template","variant"],"sources":["@wordpress/edit-post/src/components/sidebar/post-template/form.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { addTemplate } from '@wordpress/icons';\nimport { Notice, SelectControl, Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport PostTemplateCreateModal from './create-modal';\n\nexport default function PostTemplateForm( { onClose } ) {\n\tconst {\n\t\tisPostsPage,\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\tconst _isPostsPage =\n\t\t\tselect( editorStore ).getCurrentPostId() ===\n\t\t\tsiteSettings?.page_for_posts;\n\t\tconst canCreateTemplates = canUser( 'create', 'templates' );\n\n\t\treturn {\n\t\t\tisPostsPage: _isPostsPage,\n\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\tfetchedTemplates: canCreateTemplates\n\t\t\t\t? getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\t\tpost_type: select( editorStore ).getCurrentPostType(),\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t } )\n\t\t\t\t: undefined,\n\t\t\tselectedTemplateSlug:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\tcanCreate:\n\t\t\t\tcanCreateTemplates &&\n\t\t\t\t! _isPostsPage &&\n\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\tcanEdit:\n\t\t\t\tcanCreateTemplates &&\n\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t!! select( editPostStore ).getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { __unstableSwitchToTemplateMode } = useDispatch( editPostStore );\n\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"edit-post-post-template__form\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ isPostsPage ? (\n\t\t\t\t<Notice\n\t\t\t\t\tclassName=\"edit-post-post-template__notice\"\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => __unstableSwitchToTemplateMode() }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<PostTemplateCreateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,oCAAoC,IAAIC,sBAAsB,QAAQ,yBAAyB;AACxG,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,MAAM,EAAEC,aAAa,EAAEC,MAAM,QAAQ,uBAAuB;AACrE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASF,KAAK,IAAIG,aAAa,QAAQ,gBAAgB;AACvD,OAAOC,uBAAuB,MAAM,gBAAgB;AAEpD,eAAe,SAASC,gBA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A;MACCyC,IAAI,EAAE5D,WAAW;MACjBgD,KAAK,EAAEjD,EAAE,CAAE,cAAe,CAAC;MAC3B8D,OAAO,EAAEA,CAAA,KAAMN,oBAAoB,CAAE,IAAK;IAC3C,CAAC,CACA,GACD,EACH;IACD3C,OAAO,EAAGA;EAAS,CACnB,CAAC,EACAG,WAAW,GACZyC,aAAA,CAACvD,MAAM;IACNwD,SAAS,EAAC,iCAAiC;IAC3CK,MAAM,EAAC,SAAS;IAChBC,aAAa,EAAG;EAAO,GAErBhE,EAAE,CAAE,4CAA6C,CAC5C,CAAC,GAETyD,aAAA,CAACtD,aAAa;IACb8D,uBAAuB;IACvBC,mBAAmB;IACnBjB,KAAK,EAAGjD,EAAE,CAAE,UAAW,CAAG;IAC1BgD,KAAK,GAAAjC,qBAAA,GAAGmC,cAAc,EAAEF,KAAK,cAAAjC,qBAAA,cAAAA,qBAAA,GAAI,EAAI;IACrCyB,OAAO,EAAGA,OAAS;IACnB2B,QAAQ,EAAKtB,IAAI,IAChBQ,QAAQ,CAAE;MAAEe,QAAQ,EAAEvB,IAAI,IAAI;IAAG,CAAE;EACnC,CACD,CACD,EACCxB,OAAO,IACRoC,aAAA,YACCA,aAAA,CAACrD,MAAM;IACNiE,OAAO,EAAC,MAAM;IACdP,OAAO,EAAGA,CAAA,KAAMR,8BAA8B,CAAC;EAAG,GAEhDtD,EAAE,CAAE,eAAgB,CACf,CACN,CACH,EACCuD,iBAAiB,IAClBE,aAAA,CAAC9C,uBAAuB;IACvBE,OAAO,EAAGA,CAAA,KAAM2C,oBAAoB,CAAE,KAAM;EAAG,CAC/C,CAEE,CAAC;AAER"}
@@ -1,98 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { useState, useMemo } from '@wordpress/element';
6
- import { Dropdown, Button } from '@wordpress/components';
7
- import { __, sprintf } from '@wordpress/i18n';
8
- import { useSelect } from '@wordpress/data';
9
- import { store as editorStore, privateApis as editorPrivateApis } from '@wordpress/editor';
10
- import { store as coreStore } from '@wordpress/core-data';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import PostTemplateForm from './form';
16
- import { store as editPostStore } from '../../../store';
17
- import { unlock } from '../../../lock-unlock';
18
- const {
19
- PostPanelRow
20
- } = unlock(editorPrivateApis);
21
- export default function PostTemplate() {
22
- // Use internal state instead of a ref to make sure that the component
23
- // re-renders when the popover's anchor updates.
24
- const [popoverAnchor, setPopoverAnchor] = useState(null);
25
- // Memoize popoverProps to avoid returning a new object every time.
26
- const popoverProps = useMemo(() => ({
27
- anchor: popoverAnchor,
28
- placement: 'bottom-end'
29
- }), [popoverAnchor]);
30
- const isVisible = useSelect(select => {
31
- var _select$canUser;
32
- const postTypeSlug = select(editorStore).getCurrentPostType();
33
- const postType = select(coreStore).getPostType(postTypeSlug);
34
- if (!postType?.viewable) {
35
- return false;
36
- }
37
- const settings = select(editorStore).getEditorSettings();
38
- const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
39
- if (hasTemplates) {
40
- return true;
41
- }
42
- if (!settings.supportsTemplateMode) {
43
- return false;
44
- }
45
- const canCreateTemplates = (_select$canUser = select(coreStore).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
46
- return canCreateTemplates;
47
- }, []);
48
- if (!isVisible) {
49
- return null;
50
- }
51
- return createElement(PostPanelRow, {
52
- label: __('Template'),
53
- ref: setPopoverAnchor
54
- }, createElement(Dropdown, {
55
- popoverProps: popoverProps,
56
- contentClassName: "edit-post-post-template__dialog",
57
- focusOnMount: true,
58
- renderToggle: ({
59
- isOpen,
60
- onToggle
61
- }) => createElement(PostTemplateToggle, {
62
- isOpen: isOpen,
63
- onClick: onToggle
64
- }),
65
- renderContent: ({
66
- onClose
67
- }) => createElement(PostTemplateForm, {
68
- onClose: onClose
69
- })
70
- }));
71
- }
72
- function PostTemplateToggle({
73
- isOpen,
74
- onClick
75
- }) {
76
- const templateTitle = useSelect(select => {
77
- const templateSlug = select(editorStore).getEditedPostAttribute('template');
78
- const {
79
- supportsTemplateMode,
80
- availableTemplates
81
- } = select(editorStore).getEditorSettings();
82
- if (!supportsTemplateMode && availableTemplates[templateSlug]) {
83
- return availableTemplates[templateSlug];
84
- }
85
- const template = select(coreStore).canUser('create', 'templates') && select(editPostStore).getEditedPostTemplate();
86
- return template?.title || template?.slug || availableTemplates?.[templateSlug];
87
- }, []);
88
- return createElement(Button, {
89
- className: "edit-post-post-template__toggle",
90
- variant: "tertiary",
91
- "aria-expanded": isOpen,
92
- "aria-label": templateTitle ? sprintf(
93
- // translators: %s: Name of the currently selected template.
94
- __('Select template: %s'), templateTitle) : __('Select template'),
95
- onClick: onClick
96
- }, templateTitle !== null && templateTitle !== void 0 ? templateTitle : __('Default template'));
97
- }
98
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["useState","useMemo","Dropdown","Button","__","sprintf","useSelect","store","editorStore","privateApis","editorPrivateApis","coreStore","PostTemplateForm","editPostStore","unlock","PostPanelRow","PostTemplate","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","isVisible","select","_select$canUser","postTypeSlug","getCurrentPostType","postType","getPostType","viewable","settings","getEditorSettings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","createElement","label","ref","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","PostTemplateToggle","onClick","renderContent","onClose","templateTitle","templateSlug","getEditedPostAttribute","template","getEditedPostTemplate","title","slug","className","variant"],"sources":["@wordpress/edit-post/src/components/sidebar/post-template/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTemplateForm from './form';\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { PostPanelRow } = unlock( editorPrivateApis );\n\nexport default function PostTemplate() {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tconst isVisible = useSelect( ( select ) => {\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tif ( ! postType?.viewable ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tif ( hasTemplates ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! settings.supportsTemplateMode ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst canCreateTemplates =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostPanelRow label={ __( 'Template' ) } ref={ setPopoverAnchor }>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\tcontentClassName=\"edit-post-post-template__dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostTemplateToggle\n\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<PostTemplateForm onClose={ onClose } />\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PostPanelRow>\n\t);\n}\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst { supportsTemplateMode, availableTemplates } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\tif ( ! supportsTemplateMode && availableTemplates[ templateSlug ] ) {\n\t\t\treturn availableTemplates[ templateSlug ];\n\t\t}\n\t\tconst template =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) &&\n\t\t\tselect( editPostStore ).getEditedPostTemplate();\n\t\treturn (\n\t\t\ttemplate?.title ||\n\t\t\ttemplate?.slug ||\n\t\t\tavailableTemplates?.[ templateSlug ]\n\t\t);\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\ttemplateTitle\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the currently selected template.\n\t\t\t\t\t\t\t__( 'Select template: %s' ),\n\t\t\t\t\t\t\ttemplateTitle\n\t\t\t\t\t )\n\t\t\t\t\t: __( 'Select template' )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SAASC,QAAQ,EAAEC,MAAM,QAAQ,uBAAuB;AACxD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,KAAK,IAAIC,WAAW,EACpBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASH,KAAK,IAAII,SAA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AAC,IACpDhB,MAAM,CAAEV,aAAc,CAAC,CAAC2C,qBAAqB,CAAC,CAAC;IAChD,OACCD,QAAQ,EAAEE,KAAK,IACfF,QAAQ,EAAEG,IAAI,IACdzB,kBAAkB,GAAIoB,YAAY,CAAE;EAEtC,CAAC,EAAE,EAAG,CAAC;EAEP,OACCb,aAAA,CAACrC,MAAM;IACNwD,SAAS,EAAC,iCAAiC;IAC3CC,OAAO,EAAC,UAAU;IAClB,iBAAgBd,MAAQ;IACxB,cACCM,aAAa,GACV/C,OAAO;IACP;IACAD,EAAE,CAAE,qBAAsB,CAAC,EAC3BgD,aACA,CAAC,GACDhD,EAAE,CAAE,iBAAkB,CACzB;IACD6C,OAAO,EAAGA;EAAS,GAEjBG,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAIhD,EAAE,CAAE,kBAAmB,CACnC,CAAC;AAEX"}
@@ -1,46 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { __ } from '@wordpress/i18n';
6
- import { Button } from '@wordpress/components';
7
- import { external } from '@wordpress/icons';
8
- import { store as editorStore } from '@wordpress/editor';
9
- import { store as coreStore } from '@wordpress/core-data';
10
- import { useSelect } from '@wordpress/data';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import { store as editPostStore } from '../../store';
16
- export default function ViewLink() {
17
- const {
18
- permalink,
19
- isPublished,
20
- label,
21
- showIconLabels
22
- } = useSelect(select => {
23
- // Grab post type to retrieve the view_item label.
24
- const postTypeSlug = select(editorStore).getCurrentPostType();
25
- const postType = select(coreStore).getPostType(postTypeSlug);
26
- return {
27
- permalink: select(editorStore).getPermalink(),
28
- isPublished: select(editorStore).isCurrentPostPublished(),
29
- label: postType?.labels.view_item,
30
- showIconLabels: select(editPostStore).isFeatureActive('showIconLabels')
31
- };
32
- }, []);
33
-
34
- // Only render the view button if the post is published and has a permalink.
35
- if (!isPublished || !permalink) {
36
- return null;
37
- }
38
- return createElement(Button, {
39
- icon: external,
40
- label: label || __('View post'),
41
- href: permalink,
42
- target: "_blank",
43
- showTooltip: !showIconLabels
44
- });
45
- }
46
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__","Button","external","store","editorStore","coreStore","useSelect","editPostStore","ViewLink","permalink","isPublished","label","showIconLabels","select","postTypeSlug","getCurrentPostType","postType","getPostType","getPermalink","isCurrentPostPublished","labels","view_item","isFeatureActive","createElement","icon","href","target","showTooltip"],"sources":["@wordpress/edit-post/src/components/view-link/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { external } from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function ViewLink() {\n\tconst { permalink, isPublished, label, showIconLabels } = useSelect(\n\t\t( select ) => {\n\t\t\t// Grab post type to retrieve the view_item label.\n\t\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\n\t\t\treturn {\n\t\t\t\tpermalink: select( editorStore ).getPermalink(),\n\t\t\t\tisPublished: select( editorStore ).isCurrentPostPublished(),\n\t\t\t\tlabel: postType?.labels.view_item,\n\t\t\t\tshowIconLabels:\n\t\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\t// Only render the view button if the post is published and has a permalink.\n\tif ( ! isPublished || ! permalink ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\ticon={ external }\n\t\t\tlabel={ label || __( 'View post' ) }\n\t\t\thref={ permalink }\n\t\t\ttarget=\"_blank\"\n\t\t\tshowTooltip={ ! showIconLabels }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,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
- /**
2
- * WordPress dependencies
3
- */
4
- import { Icon, MenuGroup } from '@wordpress/components';
5
- import { PostPreviewButton, store as editorStore } from '@wordpress/editor';
6
- import { external } from '@wordpress/icons';
7
- import { __ } from '@wordpress/i18n';
8
- import { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';
9
- import { useDispatch, useSelect } from '@wordpress/data';
10
- import { store as coreStore } from '@wordpress/core-data';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import { store as editPostStore } from '../../store';
16
-
17
- export default function DevicePreview() {
18
- const {
19
- hasActiveMetaboxes,
20
- isPostSaveable,
21
- isViewable,
22
- deviceType,
23
- showIconLabels,
24
- } = useSelect( ( select ) => {
25
- const { getEditedPostAttribute } = select( editorStore );
26
- const { getPostType } = select( coreStore );
27
- const postType = getPostType( getEditedPostAttribute( 'type' ) );
28
-
29
- return {
30
- hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
31
- isPostSaveable: select( editorStore ).isEditedPostSaveable(),
32
- isViewable: postType?.viewable ?? false,
33
- deviceType:
34
- select( editPostStore ).__experimentalGetPreviewDeviceType(),
35
- showIconLabels:
36
- select( editPostStore ).isFeatureActive( 'showIconLabels' ),
37
- };
38
- }, [] );
39
- const { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =
40
- useDispatch( editPostStore );
41
-
42
- return (
43
- <PreviewOptions
44
- isEnabled={ isPostSaveable }
45
- className="edit-post-post-preview-dropdown"
46
- deviceType={ deviceType }
47
- setDeviceType={ setPreviewDeviceType }
48
- label={ __( 'Preview' ) }
49
- showIconLabels={ showIconLabels }
50
- >
51
- { ( { onClose } ) =>
52
- isViewable && (
53
- <MenuGroup>
54
- <div className="edit-post-header-preview__grouping-external">
55
- <PostPreviewButton
56
- className="edit-post-header-preview__button-external"
57
- role="menuitem"
58
- forceIsAutosaveable={ hasActiveMetaboxes }
59
- textContent={
60
- <>
61
- { __( 'Preview in new tab' ) }
62
- <Icon icon={ external } />
63
- </>
64
- }
65
- onPreview={ onClose }
66
- />
67
- </div>
68
- </MenuGroup>
69
- )
70
- }
71
- </PreviewOptions>
72
- );
73
- }