@wordpress/editor 14.41.0 → 14.41.2-next.v.202603161435.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 (326) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/collab-sidebar/index.cjs +7 -4
  3. package/build/components/collab-sidebar/index.cjs.map +2 -2
  4. package/build/components/collab-sidebar/utils.cjs +13 -15
  5. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  6. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs +141 -0
  7. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +7 -0
  8. package/build/components/collaborators-overlay/collaborator-styles.cjs +38 -2
  9. package/build/components/collaborators-overlay/collaborator-styles.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/compute-selection.cjs +181 -0
  11. package/build/components/collaborators-overlay/compute-selection.cjs.map +7 -0
  12. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +243 -0
  13. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +7 -0
  14. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +148 -0
  15. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +7 -0
  16. package/build/components/collaborators-overlay/overlay.cjs +100 -229
  17. package/build/components/collaborators-overlay/overlay.cjs.map +3 -3
  18. package/build/components/collaborators-overlay/use-block-highlighting.cjs +90 -42
  19. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
  20. package/build/components/collaborators-overlay/use-debounced-recompute.cjs +49 -0
  21. package/build/components/collaborators-overlay/use-debounced-recompute.cjs.map +7 -0
  22. package/build/components/collaborators-overlay/use-render-cursors.cjs +80 -171
  23. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  24. package/build/components/collaborators-presence/avatar/component.cjs +121 -0
  25. package/build/components/collaborators-presence/avatar/component.cjs.map +7 -0
  26. package/build/components/collaborators-presence/avatar/index.cjs +37 -0
  27. package/build/components/collaborators-presence/avatar/index.cjs.map +7 -0
  28. package/build/components/collaborators-presence/avatar/types.cjs +19 -0
  29. package/build/components/collaborators-presence/avatar/types.cjs.map +7 -0
  30. package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs +44 -0
  31. package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs.map +7 -0
  32. package/build/components/collaborators-presence/avatar-group/component.cjs +78 -0
  33. package/build/components/collaborators-presence/avatar-group/component.cjs.map +7 -0
  34. package/build/components/collaborators-presence/avatar-group/index.cjs +37 -0
  35. package/build/components/collaborators-presence/avatar-group/index.cjs.map +7 -0
  36. package/build/components/collaborators-presence/avatar-group/types.cjs +19 -0
  37. package/build/components/collaborators-presence/avatar-group/types.cjs.map +7 -0
  38. package/build/components/collaborators-presence/index.cjs +54 -17
  39. package/build/components/collaborators-presence/index.cjs.map +3 -3
  40. package/build/components/collaborators-presence/list.cjs +43 -37
  41. package/build/components/collaborators-presence/list.cjs.map +3 -3
  42. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +79 -107
  43. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +3 -3
  44. package/build/components/editor-interface/index.cjs +9 -6
  45. package/build/components/editor-interface/index.cjs.map +2 -2
  46. package/build/components/entities-saved-states/hooks/use-is-dirty.cjs +14 -5
  47. package/build/components/entities-saved-states/hooks/use-is-dirty.cjs.map +2 -2
  48. package/build/components/global-styles/index.cjs +15 -24
  49. package/build/components/global-styles/index.cjs.map +3 -3
  50. package/build/components/global-styles-sidebar/index.cjs +6 -3
  51. package/build/components/global-styles-sidebar/index.cjs.map +2 -2
  52. package/build/components/inserter-sidebar/index.cjs +2 -1
  53. package/build/components/inserter-sidebar/index.cjs.map +2 -2
  54. package/build/components/page-attributes/parent.cjs +2 -1
  55. package/build/components/page-attributes/parent.cjs.map +2 -2
  56. package/build/components/post-revisions-preview/revisions-canvas.cjs +8 -58
  57. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +3 -3
  58. package/build/components/post-revisions-preview/revisions-slider.cjs +5 -1
  59. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  60. package/build/components/post-url/panel.cjs +1 -0
  61. package/build/components/post-url/panel.cjs.map +2 -2
  62. package/build/components/preferences-modal/index.cjs +24 -0
  63. package/build/components/preferences-modal/index.cjs.map +2 -2
  64. package/build/components/provider/disable-non-page-content-blocks.cjs +31 -28
  65. package/build/components/provider/disable-non-page-content-blocks.cjs.map +3 -3
  66. package/build/components/provider/index.cjs +17 -5
  67. package/build/components/provider/index.cjs.map +2 -2
  68. package/build/components/provider/use-block-editor-settings.cjs +21 -6
  69. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  70. package/build/components/provider/{use-post-content-blocks.cjs → use-post-content-block-types.cjs} +8 -19
  71. package/build/components/provider/use-post-content-block-types.cjs.map +7 -0
  72. package/build/components/provider/use-revision-blocks.cjs +106 -0
  73. package/build/components/provider/use-revision-blocks.cjs.map +7 -0
  74. package/build/components/sidebar/dataform-post-summary.cjs +182 -0
  75. package/build/components/sidebar/dataform-post-summary.cjs.map +7 -0
  76. package/build/components/sidebar/header.cjs +1 -1
  77. package/build/components/sidebar/header.cjs.map +2 -2
  78. package/build/components/sidebar/post-summary.cjs +11 -0
  79. package/build/components/sidebar/post-summary.cjs.map +3 -3
  80. package/build/components/sync-connection-modal/index.cjs +8 -5
  81. package/build/components/sync-connection-modal/index.cjs.map +2 -2
  82. package/build/components/template-content-panel/index.cjs +35 -31
  83. package/build/components/template-content-panel/index.cjs.map +3 -3
  84. package/build/components/visual-editor/index.cjs +1 -1
  85. package/build/components/visual-editor/index.cjs.map +2 -2
  86. package/build/dataviews/store/private-actions.cjs +4 -0
  87. package/build/dataviews/store/private-actions.cjs.map +2 -2
  88. package/build/store/private-actions.cjs +11 -2
  89. package/build/store/private-actions.cjs.map +2 -2
  90. package/build/store/private-selectors.cjs +52 -13
  91. package/build/store/private-selectors.cjs.map +2 -2
  92. package/build/store/reducer.cjs +12 -0
  93. package/build/store/reducer.cjs.map +2 -2
  94. package/build/utils/media-upload/on-success.cjs +46 -0
  95. package/build/utils/media-upload/on-success.cjs.map +7 -0
  96. package/build-module/components/collab-sidebar/index.mjs +7 -4
  97. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  98. package/build-module/components/collab-sidebar/utils.mjs +13 -15
  99. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  100. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs +128 -0
  101. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +7 -0
  102. package/build-module/components/collaborators-overlay/collaborator-styles.mjs +25 -1
  103. package/build-module/components/collaborators-overlay/collaborator-styles.mjs.map +2 -2
  104. package/build-module/components/collaborators-overlay/compute-selection.mjs +162 -0
  105. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +7 -0
  106. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +213 -0
  107. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +7 -0
  108. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +130 -0
  109. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +7 -0
  110. package/build-module/components/collaborators-overlay/overlay.mjs +91 -230
  111. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  112. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +91 -43
  113. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  114. package/build-module/components/collaborators-overlay/use-debounced-recompute.mjs +24 -0
  115. package/build-module/components/collaborators-overlay/use-debounced-recompute.mjs.map +7 -0
  116. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +81 -172
  117. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  118. package/build-module/components/collaborators-presence/avatar/component.mjs +90 -0
  119. package/build-module/components/collaborators-presence/avatar/component.mjs.map +7 -0
  120. package/build-module/components/collaborators-presence/avatar/index.mjs +6 -0
  121. package/build-module/components/collaborators-presence/avatar/index.mjs.map +7 -0
  122. package/build-module/components/collaborators-presence/avatar/types.mjs +1 -0
  123. package/build-module/components/collaborators-presence/avatar/types.mjs.map +7 -0
  124. package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs +19 -0
  125. package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs.map +7 -0
  126. package/build-module/components/collaborators-presence/avatar-group/component.mjs +47 -0
  127. package/build-module/components/collaborators-presence/avatar-group/component.mjs.map +7 -0
  128. package/build-module/components/collaborators-presence/avatar-group/index.mjs +6 -0
  129. package/build-module/components/collaborators-presence/avatar-group/index.mjs.map +7 -0
  130. package/build-module/components/collaborators-presence/avatar-group/types.mjs +1 -0
  131. package/build-module/components/collaborators-presence/avatar-group/types.mjs.map +7 -0
  132. package/build-module/components/collaborators-presence/index.mjs +45 -21
  133. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  134. package/build-module/components/collaborators-presence/list.mjs +35 -43
  135. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  136. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +80 -108
  137. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
  138. package/build-module/components/editor-interface/index.mjs +10 -7
  139. package/build-module/components/editor-interface/index.mjs.map +2 -2
  140. package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs +14 -5
  141. package/build-module/components/entities-saved-states/hooks/use-is-dirty.mjs.map +2 -2
  142. package/build-module/components/global-styles/index.mjs +15 -24
  143. package/build-module/components/global-styles/index.mjs.map +2 -2
  144. package/build-module/components/global-styles-sidebar/index.mjs +6 -3
  145. package/build-module/components/global-styles-sidebar/index.mjs.map +2 -2
  146. package/build-module/components/inserter-sidebar/index.mjs +2 -1
  147. package/build-module/components/inserter-sidebar/index.mjs.map +2 -2
  148. package/build-module/components/page-attributes/parent.mjs +2 -1
  149. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  150. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +10 -63
  151. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  152. package/build-module/components/post-revisions-preview/revisions-slider.mjs +5 -1
  153. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  154. package/build-module/components/post-url/panel.mjs +1 -0
  155. package/build-module/components/post-url/panel.mjs.map +2 -2
  156. package/build-module/components/preferences-modal/index.mjs +24 -0
  157. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  158. package/build-module/components/provider/disable-non-page-content-blocks.mjs +31 -28
  159. package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
  160. package/build-module/components/provider/index.mjs +17 -5
  161. package/build-module/components/provider/index.mjs.map +2 -2
  162. package/build-module/components/provider/use-block-editor-settings.mjs +21 -6
  163. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  164. package/build-module/components/provider/use-post-content-block-types.mjs +23 -0
  165. package/build-module/components/provider/use-post-content-block-types.mjs.map +7 -0
  166. package/build-module/components/provider/use-revision-blocks.mjs +81 -0
  167. package/build-module/components/provider/use-revision-blocks.mjs.map +7 -0
  168. package/build-module/components/sidebar/dataform-post-summary.mjs +151 -0
  169. package/build-module/components/sidebar/dataform-post-summary.mjs.map +7 -0
  170. package/build-module/components/sidebar/header.mjs +1 -1
  171. package/build-module/components/sidebar/header.mjs.map +2 -2
  172. package/build-module/components/sidebar/post-summary.mjs +11 -0
  173. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  174. package/build-module/components/sync-connection-modal/index.mjs +8 -5
  175. package/build-module/components/sync-connection-modal/index.mjs.map +2 -2
  176. package/build-module/components/template-content-panel/index.mjs +25 -31
  177. package/build-module/components/template-content-panel/index.mjs.map +2 -2
  178. package/build-module/components/visual-editor/index.mjs +1 -1
  179. package/build-module/components/visual-editor/index.mjs.map +2 -2
  180. package/build-module/dataviews/store/private-actions.mjs +8 -1
  181. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  182. package/build-module/store/private-actions.mjs +10 -2
  183. package/build-module/store/private-actions.mjs.map +2 -2
  184. package/build-module/store/private-selectors.mjs +50 -12
  185. package/build-module/store/private-selectors.mjs.map +2 -2
  186. package/build-module/store/reducer.mjs +11 -0
  187. package/build-module/store/reducer.mjs.map +2 -2
  188. package/build-module/utils/media-upload/on-success.mjs +25 -0
  189. package/build-module/utils/media-upload/on-success.mjs.map +7 -0
  190. package/build-style/style-rtl.css +961 -159
  191. package/build-style/style.css +961 -159
  192. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  193. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  194. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts +11 -0
  195. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts.map +1 -0
  196. package/build-types/components/collaborators-overlay/collaborator-styles.d.ts +17 -2
  197. package/build-types/components/collaborators-overlay/collaborator-styles.d.ts.map +1 -1
  198. package/build-types/components/collaborators-overlay/compute-selection.d.ts +24 -0
  199. package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -0
  200. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts +72 -0
  201. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -0
  202. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +6 -0
  203. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -0
  204. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  205. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +21 -5
  206. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  207. package/build-types/components/collaborators-overlay/use-debounced-recompute.d.ts +10 -0
  208. package/build-types/components/collaborators-overlay/use-debounced-recompute.d.ts.map +1 -0
  209. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts +6 -1
  210. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  211. package/build-types/components/collaborators-presence/avatar/component.d.ts +7 -0
  212. package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -0
  213. package/build-types/components/collaborators-presence/avatar/index.d.ts +3 -0
  214. package/build-types/components/collaborators-presence/avatar/index.d.ts.map +1 -0
  215. package/build-types/components/collaborators-presence/avatar/types.d.ts +66 -0
  216. package/build-types/components/collaborators-presence/avatar/types.d.ts.map +1 -0
  217. package/build-types/components/collaborators-presence/avatar/use-image-loading-status.d.ts +17 -0
  218. package/build-types/components/collaborators-presence/avatar/use-image-loading-status.d.ts.map +1 -0
  219. package/build-types/components/collaborators-presence/avatar-group/component.d.ts +7 -0
  220. package/build-types/components/collaborators-presence/avatar-group/component.d.ts.map +1 -0
  221. package/build-types/components/collaborators-presence/avatar-group/index.d.ts +3 -0
  222. package/build-types/components/collaborators-presence/avatar-group/index.d.ts.map +1 -0
  223. package/build-types/components/collaborators-presence/avatar-group/types.d.ts +14 -0
  224. package/build-types/components/collaborators-presence/avatar-group/types.d.ts.map +1 -0
  225. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  226. package/build-types/components/collaborators-presence/list.d.ts +2 -1
  227. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  228. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
  229. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  230. package/build-types/components/entities-saved-states/hooks/use-is-dirty.d.ts.map +1 -1
  231. package/build-types/components/global-styles/index.d.ts +2 -1
  232. package/build-types/components/global-styles/index.d.ts.map +1 -1
  233. package/build-types/components/global-styles-sidebar/index.d.ts.map +1 -1
  234. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  235. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  236. package/build-types/components/post-author/hook.d.ts +1 -1
  237. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +2 -5
  238. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
  239. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  240. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  241. package/build-types/components/provider/index.d.ts.map +1 -1
  242. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  243. package/build-types/components/provider/use-post-content-block-types.d.ts +9 -0
  244. package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -0
  245. package/build-types/components/provider/use-revision-blocks.d.ts +10 -0
  246. package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -0
  247. package/build-types/components/sidebar/dataform-post-summary.d.ts +4 -0
  248. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -0
  249. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  250. package/build-types/components/sync-connection-modal/index.d.ts.map +1 -1
  251. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  252. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  253. package/build-types/store/private-actions.d.ts +7 -0
  254. package/build-types/store/private-actions.d.ts.map +1 -1
  255. package/build-types/store/private-selectors.d.ts +7 -0
  256. package/build-types/store/private-selectors.d.ts.map +1 -1
  257. package/build-types/store/reducer.d.ts +14 -3
  258. package/build-types/store/reducer.d.ts.map +1 -1
  259. package/build-types/utils/media-upload/on-success.d.ts +9 -0
  260. package/build-types/utils/media-upload/on-success.d.ts.map +1 -0
  261. package/package.json +45 -44
  262. package/src/components/collab-sidebar/index.js +7 -4
  263. package/src/components/collab-sidebar/utils.js +9 -10
  264. package/src/components/collaborators-overlay/avatar-iframe-styles.ts +134 -0
  265. package/src/components/collaborators-overlay/collaborator-styles.ts +43 -2
  266. package/src/components/collaborators-overlay/compute-selection.ts +307 -0
  267. package/src/components/collaborators-overlay/cursor-dom-utils.ts +382 -0
  268. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +131 -0
  269. package/src/components/collaborators-overlay/overlay.tsx +86 -226
  270. package/src/components/collaborators-overlay/use-block-highlighting.ts +147 -63
  271. package/src/components/collaborators-overlay/use-debounced-recompute.ts +32 -0
  272. package/src/components/collaborators-overlay/use-render-cursors.ts +113 -279
  273. package/src/components/collaborators-presence/avatar/component.tsx +123 -0
  274. package/src/components/collaborators-presence/avatar/index.ts +2 -0
  275. package/src/components/collaborators-presence/avatar/styles.scss +184 -0
  276. package/src/components/collaborators-presence/avatar/test/index.tsx +389 -0
  277. package/src/components/collaborators-presence/avatar/types.ts +66 -0
  278. package/src/components/collaborators-presence/avatar/use-image-loading-status.ts +36 -0
  279. package/src/components/collaborators-presence/avatar-group/component.tsx +55 -0
  280. package/src/components/collaborators-presence/avatar-group/index.ts +2 -0
  281. package/src/components/collaborators-presence/avatar-group/styles.scss +33 -0
  282. package/src/components/collaborators-presence/avatar-group/test/index.tsx +139 -0
  283. package/src/components/collaborators-presence/avatar-group/types.ts +13 -0
  284. package/src/components/collaborators-presence/index.tsx +34 -11
  285. package/src/components/collaborators-presence/list.tsx +44 -40
  286. package/src/components/collaborators-presence/styles/collaborators-list.scss +26 -19
  287. package/src/components/collaborators-presence/styles/collaborators-presence.scss +6 -2
  288. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +188 -246
  289. package/src/components/collaborators-presence/use-collaborator-notifications.ts +109 -166
  290. package/src/components/document-bar/style.scss +1 -1
  291. package/src/components/editor-interface/index.js +8 -6
  292. package/src/components/entities-saved-states/hooks/use-is-dirty.js +14 -5
  293. package/src/components/global-styles/index.js +20 -27
  294. package/src/components/global-styles-sidebar/index.js +3 -0
  295. package/src/components/inserter-sidebar/index.js +4 -1
  296. package/src/components/page-attributes/parent.js +2 -1
  297. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  298. package/src/components/post-revisions-preview/revisions-canvas.js +15 -84
  299. package/src/components/post-revisions-preview/revisions-slider.js +6 -1
  300. package/src/components/post-url/panel.js +1 -0
  301. package/src/components/post-url/style.scss +5 -0
  302. package/src/components/preferences-modal/index.js +18 -0
  303. package/src/components/provider/disable-non-page-content-blocks.js +42 -40
  304. package/src/components/provider/index.js +20 -2
  305. package/src/components/provider/use-block-editor-settings.js +24 -8
  306. package/src/components/provider/use-post-content-block-types.js +30 -0
  307. package/src/components/provider/use-revision-blocks.js +105 -0
  308. package/src/components/sidebar/dataform-post-summary.js +170 -0
  309. package/src/components/sidebar/header.js +1 -1
  310. package/src/components/sidebar/post-summary.js +15 -0
  311. package/src/components/sync-connection-modal/index.js +12 -6
  312. package/src/components/sync-connection-modal/style.scss +5 -0
  313. package/src/components/template-content-panel/index.js +30 -38
  314. package/src/components/visual-editor/index.js +1 -1
  315. package/src/dataviews/store/private-actions.ts +14 -0
  316. package/src/store/private-actions.js +21 -2
  317. package/src/store/private-selectors.js +75 -10
  318. package/src/store/reducer.js +19 -0
  319. package/src/style.scss +3 -0
  320. package/src/utils/media-upload/on-success.js +34 -0
  321. package/build/components/provider/use-post-content-blocks.cjs.map +0 -7
  322. package/build-module/components/provider/use-post-content-blocks.mjs +0 -34
  323. package/build-module/components/provider/use-post-content-blocks.mjs.map +0 -7
  324. package/build-types/components/provider/use-post-content-blocks.d.ts +0 -2
  325. package/build-types/components/provider/use-post-content-blocks.d.ts.map +0 -1
  326. package/src/components/provider/use-post-content-blocks.js +0 -42
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/private-actions.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\nexport * from '../dataviews/store/private-actions';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {?Object} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n * @param {string} [options.successNoticeContent] Optional custom success notice content. Defaults to 'Site updated.'.\n */\nexport const saveDirtyEntities =\n\t( {\n\t\tonSave,\n\t\tdirtyEntityRecords = [],\n\t\tentitiesToSkip = [],\n\t\tclose,\n\t\tsuccessNoticeContent,\n\t} = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityRecord( 'root', '__unstableBase' )?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice(\n\t\t\t\t\t\t\tsuccessNoticeContent || __( 'Site updated.' ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t\t\topenInNewTab: true,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: template.origin }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst isResetting = items.every( ( item ) => item?.has_theme_file );\n\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tlet title;\n\t\t\t\tif ( typeof items[ 0 ].title === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.rendered === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.rendered;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.raw === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.raw;\n\t\t\t\t}\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t_x( '\"%s\" deleted.', 'template part' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t );\n\t\t\t} else {\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? __( 'An error occurred while reverting the item.' )\n\t\t\t\t\t\t: __( 'An error occurred while deleting the item.' );\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Set the default rendering mode preference for the current post type.\n *\n * @param {string} mode The rendering mode to set as default.\n */\nexport const setDefaultRenderingMode =\n\t( mode ) =>\n\t( { select, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst theme = registry\n\t\t\t.select( coreStore )\n\t\t\t.getCurrentTheme()?.stylesheet;\n\t\tconst renderingModes =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'renderingModes' )?.[ theme ] ?? {};\n\n\t\tif ( renderingModes[ postType ] === mode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newModes = {\n\t\t\t[ theme ]: {\n\t\t\t\t...renderingModes,\n\t\t\t\t[ postType ]: mode,\n\t\t\t},\n\t\t};\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'renderingModes', newModes );\n\t};\n\n/**\n * Set the current global styles navigation path.\n *\n * @param {string} path The navigation path.\n * @return {Object} Action object.\n */\nexport function setStylesPath( path ) {\n\treturn {\n\t\ttype: 'SET_STYLES_PATH',\n\t\tpath,\n\t};\n}\n\n/**\n * Set whether the stylebook is visible.\n *\n * @param {boolean} show Whether to show the stylebook.\n * @return {Object} Action object.\n */\nexport function setShowStylebook( show ) {\n\treturn {\n\t\ttype: 'SET_SHOW_STYLEBOOK',\n\t\tshow,\n\t};\n}\n\n/**\n * Reset the global styles navigation to initial state.\n *\n * @return {Object} Action object.\n */\nexport function resetStylesNavigation() {\n\treturn {\n\t\ttype: 'RESET_STYLES_NAVIGATION',\n\t};\n}\n\n/**\n * Set the minimum height of the canvas.\n *\n * @param {number} minHeight\n * @return {Object} Action object.\n */\nexport function setCanvasMinHeight( minHeight ) {\n\treturn {\n\t\ttype: 'SET_CANVAS_MIN_HEIGHT',\n\t\tminHeight,\n\t};\n}\n\n/**\n * Set the current revision ID for revisions preview mode.\n * Pass a revision ID to enter revisions mode, or null to exit.\n *\n * @param {number|null} revisionId The revision ID, or null to exit revisions mode.\n * @return {Object} Action object.\n */\nexport function setCurrentRevisionId( revisionId ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_REVISION_ID',\n\t\trevisionId,\n\t};\n}\n\n/**\n * Restore a revision by replacing the current content with the revision's content\n * and auto-saving.\n *\n * @param {number} revisionId The revision ID to restore.\n */\nexport const restoreRevision =\n\t( revisionId ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst postId = select.getCurrentPostId();\n\n\t\tconst revision = registry\n\t\t\t.select( coreStore )\n\t\t\t.getRevision( 'postType', postType, postId, revisionId, {\n\t\t\t\tcontext: 'edit',\n\t\t\t} );\n\n\t\tif ( ! revision ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Build the edits object with all restorable fields from the revision.\n\t\tconst edits = {\n\t\t\tblocks: undefined,\n\t\t\tcontent: revision.content.raw,\n\t\t};\n\t\tif ( revision.title?.raw !== undefined ) {\n\t\t\tedits.title = revision.title.raw;\n\t\t}\n\t\tif ( revision.excerpt?.raw !== undefined ) {\n\t\t\tedits.excerpt = revision.excerpt.raw;\n\t\t}\n\t\tif ( revision.meta !== undefined ) {\n\t\t\tedits.meta = revision.meta;\n\t\t}\n\n\t\t// Apply edits and save.\n\t\tdispatch.editPost( edits );\n\n\t\t// Exit revisions mode.\n\t\tdispatch.setCurrentRevisionId( null );\n\n\t\t// Save the post to persist the restored revision.\n\t\tawait dispatch.savePost();\n\n\t\t// Show success notice.\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: Date and time of the revision. */\n\t\t\t\t__( 'Restored to revision from %s.' ),\n\t\t\t\tdateI18n( getDateSettings().formats.datetime, revision.date )\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'editor-revision-restored',\n\t\t\t}\n\t\t);\n\t};\n\n/**\n * Select a note by its ID, or clear the selection.\n *\n * @param {undefined|number|'new'} noteId The note ID to select, 'new' to open the new note form, or undefined to clear.\n * @param {Object} [options] Optional options for the selection.\n * @param {boolean} [options.focus] Whether to focus the selected note. Default false.\n * @return {Object} Action object.\n */\nexport function selectNote( noteId, options = { focus: false } ) {\n\treturn {\n\t\ttype: 'SELECT_NOTE',\n\t\tnoteId,\n\t\toptions,\n\t};\n}\n"],
5
- "mappings": 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dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { dateI18n, getSettings as getDateSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\nexport * from '../dataviews/store/private-actions';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {?Object} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n * @param {string} [options.successNoticeContent] Optional custom success notice content. Defaults to 'Site updated.'.\n */\nexport const saveDirtyEntities =\n\t( {\n\t\tonSave,\n\t\tdirtyEntityRecords = [],\n\t\tentitiesToSkip = [],\n\t\tclose,\n\t\tsuccessNoticeContent,\n\t} = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityRecord( 'root', '__unstableBase' )?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice(\n\t\t\t\t\t\t\tsuccessNoticeContent || __( 'Site updated.' ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t\t\topenInNewTab: true,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: template.origin }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst isResetting = items.every( ( item ) => item?.has_theme_file );\n\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tlet title;\n\t\t\t\tif ( typeof items[ 0 ].title === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.rendered === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.rendered;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.raw === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.raw;\n\t\t\t\t}\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t_x( '\"%s\" deleted.', 'template part' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t );\n\t\t\t} else {\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? __( 'An error occurred while reverting the item.' )\n\t\t\t\t\t\t: __( 'An error occurred while deleting the item.' );\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Set the default rendering mode preference for the current post type.\n *\n * @param {string} mode The rendering mode to set as default.\n */\nexport const setDefaultRenderingMode =\n\t( mode ) =>\n\t( { select, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst theme = registry\n\t\t\t.select( coreStore )\n\t\t\t.getCurrentTheme()?.stylesheet;\n\t\tconst renderingModes =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'renderingModes' )?.[ theme ] ?? {};\n\n\t\tif ( renderingModes[ postType ] === mode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newModes = {\n\t\t\t[ theme ]: {\n\t\t\t\t...renderingModes,\n\t\t\t\t[ postType ]: mode,\n\t\t\t},\n\t\t};\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'renderingModes', newModes );\n\t};\n\n/**\n * Set the current global styles navigation path.\n *\n * @param {string} path The navigation path.\n * @return {Object} Action object.\n */\nexport function setStylesPath( path ) {\n\treturn {\n\t\ttype: 'SET_STYLES_PATH',\n\t\tpath,\n\t};\n}\n\n/**\n * Set whether the stylebook is visible.\n *\n * @param {boolean} show Whether to show the stylebook.\n * @return {Object} Action object.\n */\nexport function setShowStylebook( show ) {\n\treturn {\n\t\ttype: 'SET_SHOW_STYLEBOOK',\n\t\tshow,\n\t};\n}\n\n/**\n * Reset the global styles navigation to initial state.\n *\n * @return {Object} Action object.\n */\nexport function resetStylesNavigation() {\n\treturn {\n\t\ttype: 'RESET_STYLES_NAVIGATION',\n\t};\n}\n\n/**\n * Set the minimum height of the canvas.\n *\n * @param {number} minHeight\n * @return {Object} Action object.\n */\nexport function setCanvasMinHeight( minHeight ) {\n\treturn {\n\t\ttype: 'SET_CANVAS_MIN_HEIGHT',\n\t\tminHeight,\n\t};\n}\n\n/**\n * Set the current revision ID for revisions preview mode.\n * Pass a revision ID to enter revisions mode, or null to exit.\n *\n * @param {number|null} revisionId The revision ID, or null to exit revisions mode.\n * @return {Object} Action object.\n */\nexport function setCurrentRevisionId( revisionId ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_REVISION_ID',\n\t\trevisionId,\n\t};\n}\n\n/**\n * Set whether the revision diff highlighting is shown.\n *\n * @param {boolean} showDiff Whether to show diff highlighting.\n * @return {Object} Action object.\n */\nexport function setShowRevisionDiff( showDiff ) {\n\treturn {\n\t\ttype: 'SET_SHOW_REVISION_DIFF',\n\t\tshowDiff,\n\t};\n}\n\n/**\n * Restore a revision by replacing the current content with the revision's content\n * and auto-saving.\n *\n * @param {number} revisionId The revision ID to restore.\n */\nexport const restoreRevision =\n\t( revisionId ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst postId = select.getCurrentPostId();\n\n\t\t// Use resolveSelect to ensure the revision is fetched if not yet\n\t\t// in the store. The _fields parameter matches the query used by\n\t\t// getRevisions so the result is served from cache without an\n\t\t// extra API call.\n\t\tconst revision = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getRevision( 'postType', postType, postId, revisionId, {\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields:\n\t\t\t\t\t'id,date,author,meta,title.raw,excerpt.raw,content.raw',\n\t\t\t} );\n\n\t\tif ( ! revision ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Build the edits object with all restorable fields from the revision.\n\t\tconst edits = {\n\t\t\tblocks: undefined,\n\t\t\tcontent: revision.content.raw,\n\t\t};\n\t\tif ( revision.title?.raw !== undefined ) {\n\t\t\tedits.title = revision.title.raw;\n\t\t}\n\t\tif ( revision.excerpt?.raw !== undefined ) {\n\t\t\tedits.excerpt = revision.excerpt.raw;\n\t\t}\n\t\tif ( revision.meta !== undefined ) {\n\t\t\tedits.meta = revision.meta;\n\t\t}\n\n\t\t// Apply edits and save.\n\t\tdispatch.editPost( edits );\n\n\t\t// Exit revisions mode.\n\t\tdispatch.setCurrentRevisionId( null );\n\n\t\t// Save the post to persist the restored revision.\n\t\tawait dispatch.savePost();\n\n\t\t// Show success notice.\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: Date and time of the revision. */\n\t\t\t\t__( 'Restored to revision from %s.' ),\n\t\t\t\tdateI18n( getDateSettings().formats.datetime, revision.date )\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'editor-revision-restored',\n\t\t\t}\n\t\t);\n\t};\n\n/**\n * Select a note by its ID, or clear the selection.\n *\n * @param {undefined|number|'new'} noteId The note ID to select, 'new' to open the new note form, or undefined to clear.\n * @param {Object} [options] Optional options for the selection.\n * @param {boolean} [options.focus] Whether to focus the selected note. Default false.\n * @return {Object} Action object.\n */\nexport function selectNote( noteId, options = { focus: false } ) {\n\treturn {\n\t\ttype: 'SELECT_NOTE',\n\t\tnoteId,\n\t\toptions,\n\t};\n}\n"],
5
+ "mappings": ";AAGA,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,wBAAwB;AAC1C,SAAS,oBAAoB;AAC7B,OAAO,cAAc;AACrB,SAAS,OAAO,mCAAmC;AACnD,SAAS,sBAAsB;AAC/B,SAAS,UAAU,eAAe,uBAAuB;AAKzD,OAAO,0BAA0B;AACjC,cAAc;AASP,SAAS,qBAAsB,IAAK;AAC1C,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,EACD;AACD;A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;AAC3C,QAAM,SAAS,OAAO,iBAAiB;AAMvC,QAAM,WAAW,MAAM,SACrB,cAAe,SAAU,EACzB,YAAa,YAAY,UAAU,QAAQ,YAAY;AAAA,IACvD,SAAS;AAAA,IACT,SACC;AAAA,EACF,CAAE;AAEH,MAAK,CAAE,UAAW;AACjB;AAAA,EACD;AAGA,QAAM,QAAQ;AAAA,IACb,QAAQ;AAAA,IACR,SAAS,SAAS,QAAQ;AAAA,EAC3B;AACA,MAAK,SAAS,OAAO,QAAQ,QAAY;AACxC,UAAM,QAAQ,SAAS,MAAM;AAAA,EAC9B;AACA,MAAK,SAAS,SAAS,QAAQ,QAAY;AAC1C,UAAM,UAAU,SAAS,QAAQ;AAAA,EAClC;AACA,MAAK,SAAS,SAAS,QAAY;AAClC,UAAM,OAAO,SAAS;AAAA,EACvB;AAGA,WAAS,SAAU,KAAM;AAGzB,WAAS,qBAAsB,IAAK;AAGpC,QAAM,SAAS,SAAS;AAGxB,WAAS,SAAU,YAAa,EAAE;AAAA,IACjC;AAAA;AAAA,MAEC,GAAI,+BAAgC;AAAA,MACpC,SAAU,gBAAgB,EAAE,QAAQ,UAAU,SAAS,IAAK;AAAA,IAC7D;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,IAAI;AAAA,IACL;AAAA,EACD;AACD;AAUM,SAAS,WAAY,QAAQ,UAAU,EAAE,OAAO,MAAM,GAAI;AAChE,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -31,13 +31,23 @@ var getInserter = createRegistrySelector(
31
31
  return state.blockInserterPanel;
32
32
  }
33
33
  if (getRenderingMode(state) === "template-locked") {
34
- const [postContentClientId] = select(blockEditorStore).getBlocksByName(
35
- "core/post-content"
36
- );
34
+ const {
35
+ getBlocksByName,
36
+ getSelectedBlockClientId,
37
+ getBlockParents,
38
+ getBlockOrder
39
+ } = select(blockEditorStore);
40
+ const [postContentClientId] = getBlocksByName("core/post-content");
37
41
  if (postContentClientId) {
42
+ const selectedBlockClientId = getSelectedBlockClientId();
43
+ if (selectedBlockClientId && selectedBlockClientId !== postContentClientId && getBlockParents(selectedBlockClientId).includes(
44
+ postContentClientId
45
+ )) {
46
+ return EMPTY_INSERTION_POINT;
47
+ }
38
48
  return {
39
49
  rootClientId: postContentClientId,
40
- insertionIndex: void 0,
50
+ insertionIndex: getBlockOrder(postContentClientId).length,
41
51
  filterValue: void 0
42
52
  };
43
53
  }
@@ -45,13 +55,21 @@ var getInserter = createRegistrySelector(
45
55
  return EMPTY_INSERTION_POINT;
46
56
  },
47
57
  (state) => {
48
- const [postContentClientId] = select(blockEditorStore).getBlocksByName(
49
- "core/post-content"
50
- );
58
+ const {
59
+ getBlocksByName,
60
+ getSelectedBlockClientId,
61
+ getBlockParents,
62
+ getBlockOrder
63
+ } = select(blockEditorStore);
64
+ const [postContentClientId] = getBlocksByName("core/post-content");
65
+ const selectedBlockClientId = getSelectedBlockClientId();
51
66
  return [
52
67
  state.blockInserterPanel,
53
68
  getRenderingMode(state),
54
- postContentClientId
69
+ postContentClientId,
70
+ selectedBlockClientId,
71
+ selectedBlockClientId ? getBlockParents(selectedBlockClientId) : void 0,
72
+ postContentClientId ? getBlockOrder(postContentClientId).length : void 0
55
73
  ];
56
74
  }
57
75
  )
@@ -139,7 +157,15 @@ var getPostBlocksByName = createRegistrySelector(
139
157
  })
140
158
  );
141
159
  },
142
- () => [select(blockEditorStore).getBlocks()]
160
+ (state, blockNames) => {
161
+ blockNames = Array.isArray(blockNames) ? blockNames : [blockNames];
162
+ const { getBlocksByName, getBlockParents } = select(blockEditorStore);
163
+ const clientIds = getBlocksByName(blockNames);
164
+ const parentsOfClientIds = clientIds.map(
165
+ (id) => getBlockParents(id)
166
+ );
167
+ return [clientIds, ...parentsOfClientIds];
168
+ }
143
169
  )
144
170
  );
145
171
  var getDefaultRenderingMode = createRegistrySelector(
@@ -179,6 +205,9 @@ function getCanvasMinHeight(state) {
179
205
  function isRevisionsMode(state) {
180
206
  return state.revisionId !== null;
181
207
  }
208
+ function isShowingRevisionDiff(state) {
209
+ return state.showRevisionDiff;
210
+ }
182
211
  function getCurrentRevisionId(state) {
183
212
  return state.revisionId;
184
213
  }
@@ -193,7 +222,11 @@ var getCurrentRevision = createRegistrySelector(
193
222
  "postType",
194
223
  postType,
195
224
  postId,
196
- { per_page: -1, context: "edit" }
225
+ {
226
+ per_page: -1,
227
+ context: "edit",
228
+ _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
229
+ }
197
230
  );
198
231
  if (!revisions) {
199
232
  return null;
@@ -223,7 +256,11 @@ var getPreviousRevision = createRegistrySelector(
223
256
  "postType",
224
257
  postType,
225
258
  postId,
226
- { per_page: -1, context: "edit" }
259
+ {
260
+ per_page: -1,
261
+ context: "edit",
262
+ _fields: "id,date,author,meta,title.raw,excerpt.raw,content.raw"
263
+ }
227
264
  );
228
265
  if (!revisions) {
229
266
  return null;
@@ -264,6 +301,7 @@ export {
264
301
  hasPostMetaChanges,
265
302
  isEntityReady,
266
303
  isNoteFocused,
267
- isRevisionsMode
304
+ isRevisionsMode,
305
+ isShowingRevisionDiff
268
306
  };
269
307
  //# sourceMappingURL=private-selectors.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/private-selectors.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\nimport { getTemplatePartIcon } from '../utils';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * These are rendering modes that the editor supports.\n */\nconst RENDERING_MODES = [ 'post-only', 'template-locked' ];\n\n/**\n * Get the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t\t'core/post-content'\n\t\t\t\t\t);\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\tconst templateAreas =\n\t\t\t\t\tselect( coreStore ).getCurrentTheme()\n\t\t\t\t\t\t?.default_template_part_areas || [];\n\n\t\t\t\tconst areaData = templateAreas.find(\n\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t);\n\n\t\t\t\tif ( areaData?.icon ) {\n\t\t\t\t\treturn getTemplatePartIcon( areaData.icon );\n\t\t\t\t}\n\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t() => [ select( blockEditorStore ).getBlocks() ]\n\t)\n);\n\n/**\n * Returns the default rendering mode for a post type by user preference or post type configuration.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type.\n *\n * @return {string} The default rendering mode. Returns `undefined` while resolving value.\n */\nexport const getDefaultRenderingMode = createRegistrySelector(\n\t( select ) => ( state, postType ) => {\n\t\tconst { getPostType, getCurrentTheme, hasFinishedResolution } =\n\t\t\tselect( coreStore );\n\n\t\t// This needs to be called before `hasFinishedResolution`.\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst currentTheme = getCurrentTheme();\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst postTypeEntity = getPostType( postType );\n\n\t\t// Wait for the post type and theme resolution.\n\t\tif (\n\t\t\t! hasFinishedResolution( 'getPostType', [ postType ] ) ||\n\t\t\t! hasFinishedResolution( 'getCurrentTheme' )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst theme = currentTheme?.stylesheet;\n\t\tconst defaultModePreference = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'renderingModes'\n\t\t)?.[ theme ]?.[ postType ];\n\t\tconst postTypeDefaultMode = Array.isArray(\n\t\t\tpostTypeEntity?.supports?.editor\n\t\t)\n\t\t\t? postTypeEntity.supports.editor.find(\n\t\t\t\t\t( features ) => 'default-mode' in features\n\t\t\t )?.[ 'default-mode' ]\n\t\t\t: undefined;\n\n\t\tconst defaultMode = defaultModePreference || postTypeDefaultMode;\n\n\t\t// Fallback gracefully to 'post-only' when rendering mode is not supported.\n\t\tif ( ! RENDERING_MODES.includes( defaultMode ) ) {\n\t\t\treturn 'post-only';\n\t\t}\n\n\t\treturn defaultMode;\n\t}\n);\n\n/**\n * Get the current global styles navigation path.\n *\n * @param {Object} state Global application state.\n * @return {string} The current styles path.\n */\nexport function getStylesPath( state ) {\n\treturn state.stylesPath ?? '/';\n}\n\n/**\n * Get whether the stylebook is currently visible.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the stylebook is visible.\n */\nexport function getShowStylebook( state ) {\n\treturn state.showStylebook ?? false;\n}\n\n/**\n * Get the canvas minimum height.\n *\n * @param {Object} state Global application state.\n * @return {number} The canvas minimum height.\n */\nexport function getCanvasMinHeight( state ) {\n\treturn state.canvasMinHeight;\n}\n\n/**\n * Returns whether the editor is in revisions preview mode.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether revisions mode is active.\n */\nexport function isRevisionsMode( state ) {\n\treturn state.revisionId !== null;\n}\n\n/**\n * Returns the current revision ID in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {number|null} The revision ID, or null if not in revisions mode.\n */\nexport function getCurrentRevisionId( state ) {\n\treturn state.revisionId;\n}\n\n/**\n * Returns the current revision object in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The revision object, null if loading, or undefined if not in revisions mode.\n */\nexport const getCurrentRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst revisionId = getCurrentRevisionId( state );\n\t\tif ( ! revisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\t// - Use getRevisions (plural) instead of getRevision (singular) to\n\t\t// avoid a race condition where both API calls complete around the\n\t\t// same time and the single revision fetch overwrites the list in the\n\t\t// store.\n\t\t// - getRevision also needs to be updated to check if there's any\n\t\t// received revisions from the collection API call to avoid unnecessary\n\t\t// API calls.\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ per_page: -1, context: 'edit' }\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revKey = entityConfig?.revisionKey || 'id';\n\t\treturn revisions.find( ( r ) => r[ revKey ] === revisionId ) ?? null;\n\t}\n);\n\n/**\n * Returns the currently selected note ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {undefined|number|'new'} The selected note ID, 'new' for the new note form, or undefined if none.\n */\nexport function getSelectedNote( state ) {\n\treturn state.selectedNote?.noteId;\n}\n\n/**\n * Returns whether the selected note should be focused.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the selected note should be focused.\n */\nexport function isNoteFocused( state ) {\n\treturn !! state.selectedNote?.options?.focus;\n}\n\n/**\n * Returns the previous revision (the one before the current revision).\n * Used for diffing between revisions.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The previous revision object, null if loading or no previous revision, or undefined if not in revisions mode.\n */\nexport const getPreviousRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst currentRevisionId = getCurrentRevisionId( state );\n\t\tif ( ! currentRevisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{ per_page: -1, context: 'edit' }\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Sort by date ascending (oldest first).\n\t\tconst sortedRevisions = [ ...revisions ].sort(\n\t\t\t( a, b ) => new Date( a.date ) - new Date( b.date )\n\t\t);\n\n\t\t// Find current revision index.\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revKey = entityConfig?.revisionKey || 'id';\n\t\tconst currentIndex = sortedRevisions.findIndex(\n\t\t\t( r ) => r[ revKey ] === currentRevisionId\n\t\t);\n\n\t\t// Return the previous revision (older one) if it exists.\n\t\tif ( currentIndex > 0 ) {\n\t\t\treturn sortedRevisions[ currentIndex - 1 ];\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"],
5
- "mappings": ";AAGA,OAAO,mBAAmB;AAK1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,gBAAgB,8BAA8B;AACvD;AAAA,EACC;AAAA,EACA;AAAA,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YAAY,OAAQ,SAAU,EAAE;AAAA,MACrC;AAAA,MACA;AAAA,MACA;AAAA,MACA,EAAE,UAAU,IAAI,SAAS,OAAO;AAAA,IACjC;AACA,QAAK,CAAE,WAAY;AAClB,aAAO;AAAA,IACR;AAGA,UAAM,kBAAkB,CAAE,GAAG,SAAU,EAAE;AAAA,MACxC,CAAE,GAAG,MAAO,IAAI,KAAM,EAAE,IAAK,IAAI,IAAI,KAAM,EAAE,IAAK;AAAA,IACnD;AAGA,UAAM,eAAe,OAAQ,SAAU,EAAE;AAAA,MACxC;AAAA,MACA;AAAA,IACD;AACA,UAAM,SAAS,cAAc,eAAe;AAC5C,UAAM,eAAe,gBAAgB;AAAA,MACpC,CAAE,MAAO,EAAG,MAAO,MAAM;AAAA,IAC1B;AAGA,QAAK,eAAe,GAAI;AACvB,aAAO,gBAAiB,eAAe,CAAE;AAAA,IAC1C;AAEA,WAAO;AAAA,EACR;AACD;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\nimport { getTemplatePartIcon } from '../utils';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * These are rendering modes that the editor supports.\n */\nconst RENDERING_MODES = [ 'post-only', 'template-locked' ];\n\n/**\n * Get the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst {\n\t\t\t\t\tgetBlocksByName,\n\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\tgetBlockParents,\n\t\t\t\t\tgetBlockOrder,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tgetBlocksByName( 'core/post-content' );\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\t\t\t// If a block inside Post Content is selected,\n\t\t\t\t\t// let the inserter use its default logic for determining the\n\t\t\t\t\t// insertion position by returning an empty insertion point.\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectedBlockClientId &&\n\t\t\t\t\t\tselectedBlockClientId !== postContentClientId &&\n\t\t\t\t\t\tgetBlockParents( selectedBlockClientId ).includes(\n\t\t\t\t\t\t\tpostContentClientId\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise (no selection, or Post Content itself\n\t\t\t\t\t// is selected), insert at the end of Post Content.\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex:\n\t\t\t\t\t\t\tgetBlockOrder( postContentClientId ).length,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst {\n\t\t\t\tgetBlocksByName,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParents,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tgetBlocksByName( 'core/post-content' );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t\tselectedBlockClientId,\n\t\t\t\tselectedBlockClientId\n\t\t\t\t\t? getBlockParents( selectedBlockClientId )\n\t\t\t\t\t: undefined,\n\t\t\t\tpostContentClientId\n\t\t\t\t\t? getBlockOrder( postContentClientId ).length\n\t\t\t\t\t: undefined,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\tconst templateAreas =\n\t\t\t\t\tselect( coreStore ).getCurrentTheme()\n\t\t\t\t\t\t?.default_template_part_areas || [];\n\n\t\t\t\tconst areaData = templateAreas.find(\n\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t);\n\n\t\t\t\tif ( areaData?.icon ) {\n\t\t\t\t\treturn getTemplatePartIcon( areaData.icon );\n\t\t\t\t}\n\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst clientIds = getBlocksByName( blockNames );\n\t\t\tconst parentsOfClientIds = clientIds.map( ( id ) =>\n\t\t\t\tgetBlockParents( id )\n\t\t\t);\n\t\t\treturn [ clientIds, ...parentsOfClientIds ];\n\t\t}\n\t)\n);\n\n/**\n * Returns the default rendering mode for a post type by user preference or post type configuration.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type.\n *\n * @return {string} The default rendering mode. Returns `undefined` while resolving value.\n */\nexport const getDefaultRenderingMode = createRegistrySelector(\n\t( select ) => ( state, postType ) => {\n\t\tconst { getPostType, getCurrentTheme, hasFinishedResolution } =\n\t\t\tselect( coreStore );\n\n\t\t// This needs to be called before `hasFinishedResolution`.\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst currentTheme = getCurrentTheme();\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst postTypeEntity = getPostType( postType );\n\n\t\t// Wait for the post type and theme resolution.\n\t\tif (\n\t\t\t! hasFinishedResolution( 'getPostType', [ postType ] ) ||\n\t\t\t! hasFinishedResolution( 'getCurrentTheme' )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst theme = currentTheme?.stylesheet;\n\t\tconst defaultModePreference = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'renderingModes'\n\t\t)?.[ theme ]?.[ postType ];\n\t\tconst postTypeDefaultMode = Array.isArray(\n\t\t\tpostTypeEntity?.supports?.editor\n\t\t)\n\t\t\t? postTypeEntity.supports.editor.find(\n\t\t\t\t\t( features ) => 'default-mode' in features\n\t\t\t )?.[ 'default-mode' ]\n\t\t\t: undefined;\n\n\t\tconst defaultMode = defaultModePreference || postTypeDefaultMode;\n\n\t\t// Fallback gracefully to 'post-only' when rendering mode is not supported.\n\t\tif ( ! RENDERING_MODES.includes( defaultMode ) ) {\n\t\t\treturn 'post-only';\n\t\t}\n\n\t\treturn defaultMode;\n\t}\n);\n\n/**\n * Get the current global styles navigation path.\n *\n * @param {Object} state Global application state.\n * @return {string} The current styles path.\n */\nexport function getStylesPath( state ) {\n\treturn state.stylesPath ?? '/';\n}\n\n/**\n * Get whether the stylebook is currently visible.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether the stylebook is visible.\n */\nexport function getShowStylebook( state ) {\n\treturn state.showStylebook ?? false;\n}\n\n/**\n * Get the canvas minimum height.\n *\n * @param {Object} state Global application state.\n * @return {number} The canvas minimum height.\n */\nexport function getCanvasMinHeight( state ) {\n\treturn state.canvasMinHeight;\n}\n\n/**\n * Returns whether the editor is in revisions preview mode.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether revisions mode is active.\n */\nexport function isRevisionsMode( state ) {\n\treturn state.revisionId !== null;\n}\n\n/**\n * Returns whether the revision diff highlighting is shown.\n *\n * @param {Object} state Global application state.\n * @return {boolean} Whether revision diff is being shown.\n */\nexport function isShowingRevisionDiff( state ) {\n\treturn state.showRevisionDiff;\n}\n\n/**\n * Returns the current revision ID in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {number|null} The revision ID, or null if not in revisions mode.\n */\nexport function getCurrentRevisionId( state ) {\n\treturn state.revisionId;\n}\n\n/**\n * Returns the current revision object in revisions mode.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The revision object, null if loading, or undefined if not in revisions mode.\n */\nexport const getCurrentRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst revisionId = getCurrentRevisionId( state );\n\t\tif ( ! revisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\t// - Use getRevisions (plural) instead of getRevision (singular) to\n\t\t// avoid a race condition where both API calls complete around the\n\t\t// same time and the single revision fetch overwrites the list in the\n\t\t// store.\n\t\t// - getRevision also needs to be updated to check if there's any\n\t\t// received revisions from the collection API call to avoid unnecessary\n\t\t// API calls.\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields:\n\t\t\t\t\t'id,date,author,meta,title.raw,excerpt.raw,content.raw',\n\t\t\t}\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revKey = entityConfig?.revisionKey || 'id';\n\t\treturn revisions.find( ( r ) => r[ revKey ] === revisionId ) ?? null;\n\t}\n);\n\n/**\n * Returns the currently selected note ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {undefined|number|'new'} The selected note ID, 'new' for the new note form, or undefined if none.\n */\nexport function getSelectedNote( state ) {\n\treturn state.selectedNote?.noteId;\n}\n\n/**\n * Returns whether the selected note should be focused.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the selected note should be focused.\n */\nexport function isNoteFocused( state ) {\n\treturn !! state.selectedNote?.options?.focus;\n}\n\n/**\n * Returns the previous revision (the one before the current revision).\n * Used for diffing between revisions.\n *\n * @param {Object} state Global application state.\n * @return {Object|null|undefined} The previous revision object, null if loading or no previous revision, or undefined if not in revisions mode.\n */\nexport const getPreviousRevision = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst currentRevisionId = getCurrentRevisionId( state );\n\t\tif ( ! currentRevisionId ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { type: postType, id: postId } = getCurrentPost( state );\n\t\tconst revisions = select( coreStore ).getRevisions(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'edit',\n\t\t\t\t_fields:\n\t\t\t\t\t'id,date,author,meta,title.raw,excerpt.raw,content.raw',\n\t\t\t}\n\t\t);\n\t\tif ( ! revisions ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Sort by date ascending (oldest first).\n\t\tconst sortedRevisions = [ ...revisions ].sort(\n\t\t\t( a, b ) => new Date( a.date ) - new Date( b.date )\n\t\t);\n\n\t\t// Find current revision index.\n\t\tconst entityConfig = select( coreStore ).getEntityConfig(\n\t\t\t'postType',\n\t\t\tpostType\n\t\t);\n\t\tconst revKey = entityConfig?.revisionKey || 'id';\n\t\tconst currentIndex = sortedRevisions.findIndex(\n\t\t\t( r ) => r[ revKey ] === currentRevisionId\n\t\t);\n\n\t\t// Return the previous revision (older one) if it exists.\n\t\tif ( currentIndex > 0 ) {\n\t\t\treturn sortedRevisions[ currentIndex - 1 ];\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"],
5
+ "mappings": ";AAGA,OAAO,mBAAmB;AAK1B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,gBAAgB,8BAA8B;A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AE,MAAO,EAAG,MAAO,MAAM;AAAA,IAC1B;AAGA,QAAK,eAAe,GAAI;AACvB,aAAO,gBAAiB,eAAe,CAAE;AAAA,IAC1C;AAEA,WAAO;AAAA,EACR;AACD;",
6
6
  "names": []
7
7
  }
@@ -206,6 +206,15 @@ function revisionId(state = null, action) {
206
206
  }
207
207
  return state;
208
208
  }
209
+ function showRevisionDiff(state = true, action) {
210
+ switch (action.type) {
211
+ case "SET_SHOW_REVISION_DIFF":
212
+ return action.showDiff;
213
+ case "SET_CURRENT_REVISION_ID":
214
+ return true;
215
+ }
216
+ return state;
217
+ }
209
218
  function selectedNote(state = {}, action) {
210
219
  switch (action.type) {
211
220
  case "SELECT_NOTE":
@@ -236,6 +245,7 @@ var reducer_default = combineReducers({
236
245
  showStylebook,
237
246
  canvasMinHeight,
238
247
  revisionId,
248
+ showRevisionDiff,
239
249
  selectedNote,
240
250
  dataviews: dataviewsReducer
241
251
  });
@@ -264,6 +274,7 @@ export {
264
274
  saving,
265
275
  selectedNote,
266
276
  shouldOverwriteState,
277
+ showRevisionDiff,
267
278
  showStylebook,
268
279
  stylesPath,
269
280
  template,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { EDITOR_SETTINGS_DEFAULTS } from './defaults';\nimport dataviewsReducer from '../dataviews/store/reducer';\n\n/**\n * Returns a post attribute value, flattening nested rendered content using its\n * raw value in place of its original object form.\n *\n * @param {*} value Original value.\n *\n * @return {*} Raw value.\n */\nexport function getPostRawValue( value ) {\n\tif ( value && 'object' === typeof value && 'raw' in value ) {\n\t\treturn value.raw;\n\t}\n\n\treturn value;\n}\n\n/**\n * Returns true if the two object arguments have the same keys, or false\n * otherwise.\n *\n * @param {Object} a First object.\n * @param {Object} b Second object.\n *\n * @return {boolean} Whether the two objects have the same keys.\n */\nexport function hasSameKeys( a, b ) {\n\tconst keysA = Object.keys( a ).sort();\n\tconst keysB = Object.keys( b ).sort();\n\treturn (\n\t\tkeysA.length === keysB.length &&\n\t\tkeysA.every( ( key, index ) => keysB[ index ] === key )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are editing the same post property, or\n * false otherwise.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether actions are updating the same post property.\n */\nexport function isUpdatingSamePostProperty( action, previousAction ) {\n\treturn (\n\t\taction.type === 'EDIT_POST' &&\n\t\thasSameKeys( action.edits, previousAction.edits )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are modifying the same property such that\n * undo history should be batched.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether to overwrite present state.\n */\nexport function shouldOverwriteState( action, previousAction ) {\n\tif ( action.type === 'RESET_EDITOR_BLOCKS' ) {\n\t\treturn ! action.shouldCreateUndoLevel;\n\t}\n\n\tif ( ! previousAction || action.type !== previousAction.type ) {\n\t\treturn false;\n\t}\n\n\treturn isUpdatingSamePostProperty( action, previousAction );\n}\n\nexport function postId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postId;\n\t}\n\n\treturn state;\n}\n\nexport function templateId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CURRENT_TEMPLATE_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\nexport function postType( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning whether the post blocks match the defined template or not.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nexport function template( state = { isValid: true }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE_VALIDITY':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisValid: action.isValid,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning current network request state (whether a request to\n * the WP REST API is in progress, successful, or failed).\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function saving( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_UPDATE_START':\n\t\tcase 'REQUEST_POST_UPDATE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_UPDATE_START',\n\t\t\t\toptions: action.options || {},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning deleting post request state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deleting( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_DELETE_START':\n\t\tcase 'REQUEST_POST_DELETE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_DELETE_START',\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Post Lock State.\n *\n * @typedef {Object} PostLockState\n *\n * @property {boolean} isLocked Whether the post is locked.\n * @property {?boolean} isTakeover Whether the post editing has been taken over.\n * @property {?boolean} activePostLock Active post lock value.\n * @property {?Object} user User that took over the post.\n */\n\n/**\n * Reducer returning the post lock status.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postLock( state = { isLocked: false }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_POST_LOCK':\n\t\t\treturn action.lock;\n\t}\n\n\treturn state;\n}\n\n/**\n * Post saving lock.\n *\n * When post saving is locked, the post cannot be published or updated.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postSavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_SAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_SAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Post autosaving lock.\n *\n * When post autosaving is locked, the post will not autosave.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postAutosavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_AUTOSAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_AUTOSAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Reducer returning the post editor setting.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_EDITOR_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function renderingMode( state = 'post-only', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_RENDERING_MODE':\n\t\t\treturn action.mode;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer storing the list of all programmatically removed panels.\n *\n * @param {Array} state Current state.\n * @param {Object} action Action object.\n *\n * @return {Array} Updated state.\n */\nexport function removedPanels( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REMOVE_PANEL':\n\t\t\tif ( ! state.includes( action.panelName ) ) {\n\t\t\t\treturn [ ...state, action.panelName ];\n\t\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the list view toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the list view toggle button.\n */\nexport function listViewToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the inserter sidebar toggle button.\n */\nexport function inserterSidebarToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\nexport function publishSidebarActive( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_PUBLISH_SIDEBAR':\n\t\t\treturn true;\n\t\tcase 'CLOSE_PUBLISH_SIDEBAR':\n\t\t\treturn false;\n\t\tcase 'TOGGLE_PUBLISH_SIDEBAR':\n\t\t\treturn ! state;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for the current global styles navigation path.\n *\n * @param {string} state Current state.\n * @param {Object} action Dispatched action.\n * @return {string} Updated state.\n */\nexport function stylesPath( state = '/', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_STYLES_PATH':\n\t\t\treturn action.path;\n\t\tcase 'RESET_STYLES_NAVIGATION':\n\t\t\treturn '/';\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for whether the stylebook is visible.\n *\n * @param {boolean} state Current state.\n * @param {Object} action Dispatched action.\n * @return {boolean} Updated state.\n */\nexport function showStylebook( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_SHOW_STYLEBOOK':\n\t\t\treturn action.show;\n\t\tcase 'RESET_STYLES_NAVIGATION':\n\t\t\treturn false;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for the canvas minimum height.\n *\n * @param {number} state Current state.\n * @param {Object} action Dispatched action.\n * @return {number} Updated state.\n */\nexport function canvasMinHeight( state = 0, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CANVAS_MIN_HEIGHT':\n\t\t\treturn action.minHeight;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for the revisions preview mode.\n * Stores the current revision ID, or null if not in revisions mode.\n *\n * @param {number|null} state Current revision ID.\n * @param {Object} action Dispatched action.\n * @return {number|null} Updated state.\n */\nexport function revisionId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CURRENT_REVISION_ID':\n\t\t\treturn action.revisionId;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer returning the currently selected note and its options.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n * @return {Object} Updated state.\n */\nexport function selectedNote( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SELECT_NOTE':\n\t\t\treturn { noteId: action.noteId, options: action.options };\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tpostId,\n\tpostType,\n\ttemplateId,\n\tsaving,\n\tdeleting,\n\tpostLock,\n\ttemplate,\n\tpostSavingLock,\n\teditorSettings,\n\tpostAutosavingLock,\n\trenderingMode,\n\tdeviceType,\n\tremovedPanels,\n\tblockInserterPanel,\n\tinserterSidebarToggleRef,\n\tlistViewPanel,\n\tlistViewToggleRef,\n\tpublishSidebarActive,\n\tstylesPath,\n\tshowStylebook,\n\tcanvasMinHeight,\n\trevisionId,\n\tselectedNote,\n\tdataviews: dataviewsReducer,\n} );\n"],
5
- "mappings": ";AAGA,SAAS,uBAAuB;AAKhC,SAAS,gCAAgC;AACzC,OAAO,sBAAsB;AAUtB,SAAS,gBAAiB,OAAQ;AACxC,MAAK,SAAS,aAAa,OAAO,SAAS,SAAS,OAAQ;AAC3D,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAWO,SAAS,YAAa,GAAG,GAAI;AACnC,QAAM,QAAQ,OAAO,KAAM,CAAE,EAAE,KAAK;AACpC,QAAM,QAAQ,OAAO,KAAM,CAAE,EAAE,KAAK;AACpC,SACC,MAAM,WAAW,MAAM,UACvB,MAAM,MAAO,CAAE,KAAK,UAAW,MAAO,KAAM,MAAM,GAAI;AAExD;AAYO,SAAS,2BAA4B,QAAQ,gBAAiB;AACpE,SACC,OAAO,SAAS,eAChB,YAAa,OAAO,OAAO,eAAe,KAAM;AAElD;AAYO,SAAS,qBAAsB,QAAQ,gBAAiB;AAC9D,MAAK,OAAO,SAAS,uBAAwB;AAC5C,WAAO,CAAE,OAAO;AAAA,EACjB;AAEA,MAAK,CAAE,kBAAkB,OAAO,SAAS,eAAe,MAAO;AAC9D,WAAO;AAAA,EACR;AAEA,SAAO,2BAA4B,QAAQ,cAAe;AAC3D;AAEO,SAAS,OAAQ,QAAQ,MAAM,QAAS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AAA,EAC1D;AACA,SAAO;AACR;AAEA,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,CAAE;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { EDITOR_SETTINGS_DEFAULTS } from './defaults';\nimport dataviewsReducer from '../dataviews/store/reducer';\n\n/**\n * Returns a post attribute value, flattening nested rendered content using its\n * raw value in place of its original object form.\n *\n * @param {*} value Original value.\n *\n * @return {*} Raw value.\n */\nexport function getPostRawValue( value ) {\n\tif ( value && 'object' === typeof value && 'raw' in value ) {\n\t\treturn value.raw;\n\t}\n\n\treturn value;\n}\n\n/**\n * Returns true if the two object arguments have the same keys, or false\n * otherwise.\n *\n * @param {Object} a First object.\n * @param {Object} b Second object.\n *\n * @return {boolean} Whether the two objects have the same keys.\n */\nexport function hasSameKeys( a, b ) {\n\tconst keysA = Object.keys( a ).sort();\n\tconst keysB = Object.keys( b ).sort();\n\treturn (\n\t\tkeysA.length === keysB.length &&\n\t\tkeysA.every( ( key, index ) => keysB[ index ] === key )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are editing the same post property, or\n * false otherwise.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether actions are updating the same post property.\n */\nexport function isUpdatingSamePostProperty( action, previousAction ) {\n\treturn (\n\t\taction.type === 'EDIT_POST' &&\n\t\thasSameKeys( action.edits, previousAction.edits )\n\t);\n}\n\n/**\n * Returns true if, given the currently dispatching action and the previously\n * dispatched action, the two actions are modifying the same property such that\n * undo history should be batched.\n *\n * @param {Object} action Currently dispatching action.\n * @param {Object} previousAction Previously dispatched action.\n *\n * @return {boolean} Whether to overwrite present state.\n */\nexport function shouldOverwriteState( action, previousAction ) {\n\tif ( action.type === 'RESET_EDITOR_BLOCKS' ) {\n\t\treturn ! action.shouldCreateUndoLevel;\n\t}\n\n\tif ( ! previousAction || action.type !== previousAction.type ) {\n\t\treturn false;\n\t}\n\n\treturn isUpdatingSamePostProperty( action, previousAction );\n}\n\nexport function postId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postId;\n\t}\n\n\treturn state;\n}\n\nexport function templateId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CURRENT_TEMPLATE_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\nexport function postType( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_EDITED_POST':\n\t\t\treturn action.postType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning whether the post blocks match the defined template or not.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nexport function template( state = { isValid: true }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_TEMPLATE_VALIDITY':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tisValid: action.isValid,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning current network request state (whether a request to\n * the WP REST API is in progress, successful, or failed).\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function saving( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_UPDATE_START':\n\t\tcase 'REQUEST_POST_UPDATE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_UPDATE_START',\n\t\t\t\toptions: action.options || {},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning deleting post request state.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deleting( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_POST_DELETE_START':\n\t\tcase 'REQUEST_POST_DELETE_FINISH':\n\t\t\treturn {\n\t\t\t\tpending: action.type === 'REQUEST_POST_DELETE_START',\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Post Lock State.\n *\n * @typedef {Object} PostLockState\n *\n * @property {boolean} isLocked Whether the post is locked.\n * @property {?boolean} isTakeover Whether the post editing has been taken over.\n * @property {?boolean} activePostLock Active post lock value.\n * @property {?Object} user User that took over the post.\n */\n\n/**\n * Reducer returning the post lock status.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postLock( state = { isLocked: false }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_POST_LOCK':\n\t\t\treturn action.lock;\n\t}\n\n\treturn state;\n}\n\n/**\n * Post saving lock.\n *\n * When post saving is locked, the post cannot be published or updated.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postSavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_SAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_SAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Post autosaving lock.\n *\n * When post autosaving is locked, the post will not autosave.\n *\n * @param {PostLockState} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {PostLockState} Updated state.\n */\nexport function postAutosavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_POST_AUTOSAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_POST_AUTOSAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Reducer returning the post editor setting.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'UPDATE_EDITOR_SETTINGS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.settings,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function renderingMode( state = 'post-only', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_RENDERING_MODE':\n\t\t\treturn action.mode;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer storing the list of all programmatically removed panels.\n *\n * @param {Array} state Current state.\n * @param {Object} action Action object.\n *\n * @return {Array} Updated state.\n */\nexport function removedPanels( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REMOVE_PANEL':\n\t\t\tif ( ! state.includes( action.panelName ) ) {\n\t\t\t\treturn [ ...state, action.panelName ];\n\t\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the list view toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the list view toggle button.\n */\nexport function listViewToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the inserter sidebar toggle button.\n */\nexport function inserterSidebarToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\nexport function publishSidebarActive( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_PUBLISH_SIDEBAR':\n\t\t\treturn true;\n\t\tcase 'CLOSE_PUBLISH_SIDEBAR':\n\t\t\treturn false;\n\t\tcase 'TOGGLE_PUBLISH_SIDEBAR':\n\t\t\treturn ! state;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for the current global styles navigation path.\n *\n * @param {string} state Current state.\n * @param {Object} action Dispatched action.\n * @return {string} Updated state.\n */\nexport function stylesPath( state = '/', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_STYLES_PATH':\n\t\t\treturn action.path;\n\t\tcase 'RESET_STYLES_NAVIGATION':\n\t\t\treturn '/';\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for whether the stylebook is visible.\n *\n * @param {boolean} state Current state.\n * @param {Object} action Dispatched action.\n * @return {boolean} Updated state.\n */\nexport function showStylebook( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_SHOW_STYLEBOOK':\n\t\t\treturn action.show;\n\t\tcase 'RESET_STYLES_NAVIGATION':\n\t\t\treturn false;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for the canvas minimum height.\n *\n * @param {number} state Current state.\n * @param {Object} action Dispatched action.\n * @return {number} Updated state.\n */\nexport function canvasMinHeight( state = 0, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CANVAS_MIN_HEIGHT':\n\t\t\treturn action.minHeight;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer for the revisions preview mode.\n * Stores the current revision ID, or null if not in revisions mode.\n *\n * @param {number|null} state Current revision ID.\n * @param {Object} action Dispatched action.\n * @return {number|null} Updated state.\n */\nexport function revisionId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_CURRENT_REVISION_ID':\n\t\t\treturn action.revisionId;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer returning the currently selected note and its options.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n * @return {Object} Updated state.\n */\n/**\n * Reducer for whether the revision diff is shown.\n * Resets to true when entering/exiting revisions mode.\n *\n * @param {boolean} state Current state.\n * @param {Object} action Dispatched action.\n * @return {boolean} Updated state.\n */\nexport function showRevisionDiff( state = true, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_SHOW_REVISION_DIFF':\n\t\t\treturn action.showDiff;\n\t\tcase 'SET_CURRENT_REVISION_ID':\n\t\t\treturn true; // reset on enter/exit revisions\n\t}\n\treturn state;\n}\n\nexport function selectedNote( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SELECT_NOTE':\n\t\t\treturn { noteId: action.noteId, options: action.options };\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tpostId,\n\tpostType,\n\ttemplateId,\n\tsaving,\n\tdeleting,\n\tpostLock,\n\ttemplate,\n\tpostSavingLock,\n\teditorSettings,\n\tpostAutosavingLock,\n\trenderingMode,\n\tdeviceType,\n\tremovedPanels,\n\tblockInserterPanel,\n\tinserterSidebarToggleRef,\n\tlistViewPanel,\n\tlistViewToggleRef,\n\tpublishSidebarActive,\n\tstylesPath,\n\tshowStylebook,\n\tcanvasMinHeight,\n\trevisionId,\n\tshowRevisionDiff,\n\tselectedNote,\n\tdataviews: dataviewsReducer,\n} );\n"],
5
+ "mappings": ";AAGA,SAAS,uBAAuB;AAKhC,SAAS,gCAAgC;AACzC,OAAO,sBAAsB;AAUtB,SAAS,gBAAiB,OAAQ;AACxC,MAAK,SAAS,aAAa,OAAO,SAAS,SAAS,OAAQ;AAC3D,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAWO,SAAS,YAAa,GAAG,GAAI;AACnC,QAAM,QAAQ,OAAO,KAAM,CAAE,EAAE,KAAK;AACpC,QAAM,QAAQ,OAAO,KAAM,CAAE,EAAE,KAAK;AACpC,SACC,MAAM,WAAW,MAAM,UACvB,MAAM,MAAO,CAAE,KAAK,UAAW,MAAO,KAAM,MAAM,GAAI;AAExD;AAYO,SAAS,2BAA4B,QAAQ,gBAAiB;AACpE,SACC,OAAO,SAAS,eAChB,YAAa,OAAO,OAAO,eAAe,KAAM;AAElD;AAYO,SAAS,qBAAsB,QAAQ,gBAAiB;AAC9D,MAAK,OAAO,SAAS,uBAAwB;AAC5C,WAAO,CAAE,OAAO;AAAA,EACjB;AAEA,MAAK,CAAE,kBAAkB,OAAO,SAAS,eAAe,MAAO;AAC9D,WAAO;AAAA,EACR;AAEA,SAAO,2BAA4B,QAAQ,cAAe;AAC3D;AAEO,SAAS,OAAQ,QAAQ,MAAM,QAAS;AAC9C,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AAEA,SAAO;AACR;AAEO,SAAS,WAAY,QAAQ,MAAM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,OAAO,QAAQ,SAAS,OAAO,QAAQ;AAAA,EAC1D;AACA,SAAO;AACR;AAEA,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,CAAE;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,25 @@
1
+ // packages/editor/src/utils/media-upload/on-success.js
2
+ import { dispatch } from "@wordpress/data";
3
+ import { store as coreDataStore } from "@wordpress/core-data";
4
+ function mediaUploadOnSuccess(attachments) {
5
+ const { invalidateResolution } = dispatch(coreDataStore);
6
+ for (const attachment of attachments) {
7
+ if (attachment.id) {
8
+ invalidateResolution("getEntityRecord", [
9
+ "postType",
10
+ "attachment",
11
+ attachment.id,
12
+ { context: "view" }
13
+ ]);
14
+ invalidateResolution("getEntityRecord", [
15
+ "postType",
16
+ "attachment",
17
+ attachment.id
18
+ ]);
19
+ }
20
+ }
21
+ }
22
+ export {
23
+ mediaUploadOnSuccess as default
24
+ };
25
+ //# sourceMappingURL=on-success.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/media-upload/on-success.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Invalidates core-data entity records for uploaded attachments so that\n * blocks re-fetch updated data (e.g. `media_details.sizes` after\n * thumbnails have been generated via client-side media processing).\n *\n * @param {Object[]} attachments Array of attachment objects from the upload queue.\n */\nexport default function mediaUploadOnSuccess( attachments ) {\n\tconst { invalidateResolution } = dispatch( coreDataStore );\n\tfor ( const attachment of attachments ) {\n\t\tif ( attachment.id ) {\n\t\t\t// Invalidate with and without the query argument, since\n\t\t\t// resolution keys must exactly match the args used by\n\t\t\t// each consumer's getEntityRecord() call.\n\t\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tattachment.id,\n\t\t\t\t{ context: 'view' },\n\t\t\t] );\n\t\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tattachment.id,\n\t\t\t] );\n\t\t}\n\t}\n}\n"],
5
+ "mappings": ";AAGA,SAAS,gBAAgB;AACzB,SAAS,SAAS,qBAAqB;AASxB,SAAR,qBAAuC,aAAc;AAC3D,QAAM,EAAE,qBAAqB,IAAI,SAAU,aAAc;AACzD,aAAY,cAAc,aAAc;AACvC,QAAK,WAAW,IAAK;AAIpB,2BAAsB,mBAAmB;AAAA,QACxC;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,EAAE,SAAS,OAAO;AAAA,MACnB,CAAE;AACF,2BAAsB,mBAAmB;AAAA,QACxC;AAAA,QACA;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }