@wordpress/editor 14.48.1 → 14.48.2-next.v.202606191442.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 (401) hide show
  1. package/build/bindings/pattern-overrides.cjs +1 -1
  2. package/build/bindings/pattern-overrides.cjs.map +2 -2
  3. package/build/components/collab-sidebar/note-byline.cjs +1 -1
  4. package/build/components/collab-sidebar/note-byline.cjs.map +2 -2
  5. package/build/components/collab-sidebar/note.cjs +49 -17
  6. package/build/components/collab-sidebar/note.cjs.map +3 -3
  7. package/build/components/collab-sidebar/notes.cjs.map +1 -1
  8. package/build/components/collab-sidebar/utils.cjs +1 -1
  9. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +1 -1
  11. package/build/components/collaborators-overlay/collaborator-styles.cjs.map +1 -1
  12. package/build/components/collaborators-overlay/compute-selection.cjs.map +1 -1
  13. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
  14. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +1 -1
  15. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +1 -1
  16. package/build/components/collaborators-presence/avatar/component.cjs.map +2 -2
  17. package/build/components/collaborators-presence/avatar/use-image-loading-status.cjs.map +1 -1
  18. package/build/components/document-bar/index.cjs +7 -5
  19. package/build/components/document-bar/index.cjs.map +2 -2
  20. package/build/components/global-keyboard-shortcuts/index.cjs +3 -2
  21. package/build/components/global-keyboard-shortcuts/index.cjs.map +2 -2
  22. package/build/components/global-styles-sidebar/welcome-guide.cjs +3 -3
  23. package/build/components/global-styles-sidebar/welcome-guide.cjs.map +1 -1
  24. package/build/components/local-autosave-monitor/index.cjs +14 -15
  25. package/build/components/local-autosave-monitor/index.cjs.map +2 -2
  26. package/build/components/page-attributes/parent.cjs +1 -1
  27. package/build/components/page-attributes/parent.cjs.map +2 -2
  28. package/build/components/post-card-panel/index.cjs +1 -1
  29. package/build/components/post-card-panel/index.cjs.map +2 -2
  30. package/build/components/post-excerpt/panel.cjs +1 -1
  31. package/build/components/post-excerpt/panel.cjs.map +2 -2
  32. package/build/components/post-locked-modal/index.cjs +3 -3
  33. package/build/components/post-locked-modal/index.cjs.map +1 -1
  34. package/build/components/post-preview-button/index.cjs +2 -2
  35. package/build/components/post-preview-button/index.cjs.map +2 -2
  36. package/build/components/post-publish-button/index.cjs +4 -3
  37. package/build/components/post-publish-button/index.cjs.map +2 -2
  38. package/build/components/post-publish-button/label.cjs +2 -2
  39. package/build/components/post-publish-button/label.cjs.map +2 -2
  40. package/build/components/post-publish-panel/index.cjs.map +1 -1
  41. package/build/components/post-publish-panel/postpublish.cjs +1 -1
  42. package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
  43. package/build/components/post-revisions-preview/block-diff.cjs.map +1 -1
  44. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  45. package/build/components/post-revisions-preview/revisions-slider.cjs +1 -1
  46. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  47. package/build/components/post-revisions-timeline/index.cjs +173 -0
  48. package/build/components/post-revisions-timeline/index.cjs.map +7 -0
  49. package/build/components/post-saved-state/index.cjs +17 -26
  50. package/build/components/post-saved-state/index.cjs.map +2 -2
  51. package/build/components/post-schedule/label.cjs +5 -5
  52. package/build/components/post-schedule/label.cjs.map +1 -1
  53. package/build/components/post-taxonomies/flat-term-selector.cjs +2 -1
  54. package/build/components/post-taxonomies/flat-term-selector.cjs.map +3 -3
  55. package/build/components/post-taxonomies/hierarchical-term-selector.cjs +1 -1
  56. package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
  57. package/build/components/post-text-editor/index.cjs +51 -0
  58. package/build/components/post-text-editor/index.cjs.map +2 -2
  59. package/build/components/post-text-editor/utils.cjs +150 -0
  60. package/build/components/post-text-editor/utils.cjs.map +7 -0
  61. package/build/components/post-url/index.cjs +1 -1
  62. package/build/components/post-url/index.cjs.map +2 -2
  63. package/build/components/post-view-link/index.cjs +1 -1
  64. package/build/components/post-view-link/index.cjs.map +2 -2
  65. package/build/components/provider/disable-non-page-content-blocks.cjs.map +1 -1
  66. package/build/components/provider/index.cjs +1 -1
  67. package/build/components/provider/index.cjs.map +2 -2
  68. package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
  69. package/build/components/revision-diff-panel/index.cjs +7 -2
  70. package/build/components/revision-diff-panel/index.cjs.map +2 -2
  71. package/build/components/revision-fields-diff/index.cjs +6 -2
  72. package/build/components/revision-fields-diff/index.cjs.map +2 -2
  73. package/build/components/sidebar/dataform-post-summary.cjs +125 -20
  74. package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
  75. package/build/components/sidebar/index.cjs +1 -11
  76. package/build/components/sidebar/index.cjs.map +3 -3
  77. package/build/components/sidebar/post-revision-summary.cjs +11 -17
  78. package/build/components/sidebar/post-revision-summary.cjs.map +3 -3
  79. package/build/components/sidebar/post-summary.cjs +1 -1
  80. package/build/components/sidebar/post-summary.cjs.map +2 -2
  81. package/build/components/style-book/examples.cjs +1 -1
  82. package/build/components/style-book/examples.cjs.map +1 -1
  83. package/build/components/style-book/index.cjs +1 -1
  84. package/build/components/style-book/index.cjs.map +2 -2
  85. package/build/components/sync-connection-error-modal/index.cjs +3 -3
  86. package/build/components/sync-connection-error-modal/index.cjs.map +1 -1
  87. package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
  88. package/build/components/template-actions-panel/index.cjs +0 -9
  89. package/build/components/template-actions-panel/index.cjs.map +3 -3
  90. package/build/components/template-validation-notice/index.cjs +1 -1
  91. package/build/components/template-validation-notice/index.cjs.map +1 -1
  92. package/build/components/upload-progress-snackbar/index.cjs +3 -3
  93. package/build/components/upload-progress-snackbar/index.cjs.map +2 -2
  94. package/build/components/upload-progress-snackbar/tracker.cjs.map +1 -1
  95. package/build/components/visual-editor/edit-template-blocks-notification.cjs +1 -1
  96. package/build/components/visual-editor/edit-template-blocks-notification.cjs.map +1 -1
  97. package/build/{components/revision-author-panel → dataviews/fields/revisions}/index.cjs +18 -26
  98. package/build/dataviews/fields/revisions/index.cjs.map +7 -0
  99. package/build/dataviews/fields/revisions/revisions-view.cjs +74 -0
  100. package/build/dataviews/fields/revisions/revisions-view.cjs.map +7 -0
  101. package/build/dataviews/store/private-actions.cjs +14 -4
  102. package/build/dataviews/store/private-actions.cjs.map +3 -3
  103. package/build/hooks/push-changes-to-global-styles/index.cjs +1 -1
  104. package/build/hooks/push-changes-to-global-styles/index.cjs.map +1 -1
  105. package/build/store/actions.cjs +1 -1
  106. package/build/store/actions.cjs.map +2 -2
  107. package/build/store/private-selectors.cjs +6 -1
  108. package/build/store/private-selectors.cjs.map +2 -2
  109. package/build/utils/media-upload/index.cjs.map +1 -1
  110. package/build/utils/set-nested-value.cjs.map +1 -1
  111. package/build-module/bindings/pattern-overrides.mjs +1 -1
  112. package/build-module/bindings/pattern-overrides.mjs.map +2 -2
  113. package/build-module/components/collab-sidebar/note-byline.mjs +1 -1
  114. package/build-module/components/collab-sidebar/note-byline.mjs.map +2 -2
  115. package/build-module/components/collab-sidebar/note.mjs +50 -18
  116. package/build-module/components/collab-sidebar/note.mjs.map +2 -2
  117. package/build-module/components/collab-sidebar/notes.mjs.map +1 -1
  118. package/build-module/components/collab-sidebar/utils.mjs +1 -1
  119. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  120. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +1 -1
  121. package/build-module/components/collaborators-overlay/collaborator-styles.mjs.map +1 -1
  122. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +1 -1
  123. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
  124. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +1 -1
  125. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +1 -1
  126. package/build-module/components/collaborators-presence/avatar/component.mjs.map +2 -2
  127. package/build-module/components/collaborators-presence/avatar/use-image-loading-status.mjs.map +1 -1
  128. package/build-module/components/document-bar/index.mjs +7 -5
  129. package/build-module/components/document-bar/index.mjs.map +2 -2
  130. package/build-module/components/global-keyboard-shortcuts/index.mjs +3 -2
  131. package/build-module/components/global-keyboard-shortcuts/index.mjs.map +2 -2
  132. package/build-module/components/global-styles-sidebar/welcome-guide.mjs +3 -3
  133. package/build-module/components/global-styles-sidebar/welcome-guide.mjs.map +1 -1
  134. package/build-module/components/local-autosave-monitor/index.mjs +15 -16
  135. package/build-module/components/local-autosave-monitor/index.mjs.map +2 -2
  136. package/build-module/components/page-attributes/parent.mjs +1 -1
  137. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  138. package/build-module/components/post-card-panel/index.mjs +1 -1
  139. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  140. package/build-module/components/post-excerpt/panel.mjs +1 -1
  141. package/build-module/components/post-excerpt/panel.mjs.map +2 -2
  142. package/build-module/components/post-locked-modal/index.mjs +3 -3
  143. package/build-module/components/post-locked-modal/index.mjs.map +1 -1
  144. package/build-module/components/post-preview-button/index.mjs +2 -2
  145. package/build-module/components/post-preview-button/index.mjs.map +2 -2
  146. package/build-module/components/post-publish-button/index.mjs +4 -3
  147. package/build-module/components/post-publish-button/index.mjs.map +2 -2
  148. package/build-module/components/post-publish-button/label.mjs +2 -2
  149. package/build-module/components/post-publish-button/label.mjs.map +2 -2
  150. package/build-module/components/post-publish-panel/index.mjs.map +1 -1
  151. package/build-module/components/post-publish-panel/postpublish.mjs +1 -1
  152. package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
  153. package/build-module/components/post-revisions-preview/block-diff.mjs.map +1 -1
  154. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  155. package/build-module/components/post-revisions-preview/revisions-slider.mjs +1 -1
  156. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  157. package/build-module/components/post-revisions-timeline/index.mjs +152 -0
  158. package/build-module/components/post-revisions-timeline/index.mjs.map +7 -0
  159. package/build-module/components/post-saved-state/index.mjs +17 -26
  160. package/build-module/components/post-saved-state/index.mjs.map +2 -2
  161. package/build-module/components/post-schedule/label.mjs +5 -5
  162. package/build-module/components/post-schedule/label.mjs.map +1 -1
  163. package/build-module/components/post-taxonomies/flat-term-selector.mjs +3 -6
  164. package/build-module/components/post-taxonomies/flat-term-selector.mjs.map +2 -2
  165. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +1 -1
  166. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
  167. package/build-module/components/post-text-editor/index.mjs +51 -0
  168. package/build-module/components/post-text-editor/index.mjs.map +2 -2
  169. package/build-module/components/post-text-editor/utils.mjs +123 -0
  170. package/build-module/components/post-text-editor/utils.mjs.map +7 -0
  171. package/build-module/components/post-url/index.mjs +1 -1
  172. package/build-module/components/post-url/index.mjs.map +2 -2
  173. package/build-module/components/post-view-link/index.mjs +1 -1
  174. package/build-module/components/post-view-link/index.mjs.map +2 -2
  175. package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +1 -1
  176. package/build-module/components/provider/index.mjs +1 -1
  177. package/build-module/components/provider/index.mjs.map +2 -2
  178. package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
  179. package/build-module/components/revision-diff-panel/index.mjs +7 -2
  180. package/build-module/components/revision-diff-panel/index.mjs.map +2 -2
  181. package/build-module/components/revision-fields-diff/index.mjs +6 -2
  182. package/build-module/components/revision-fields-diff/index.mjs.map +2 -2
  183. package/build-module/components/sidebar/dataform-post-summary.mjs +125 -20
  184. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  185. package/build-module/components/sidebar/index.mjs +1 -11
  186. package/build-module/components/sidebar/index.mjs.map +2 -2
  187. package/build-module/components/sidebar/post-revision-summary.mjs +11 -17
  188. package/build-module/components/sidebar/post-revision-summary.mjs.map +2 -2
  189. package/build-module/components/sidebar/post-summary.mjs +1 -1
  190. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  191. package/build-module/components/style-book/examples.mjs +1 -1
  192. package/build-module/components/style-book/examples.mjs.map +1 -1
  193. package/build-module/components/style-book/index.mjs +1 -1
  194. package/build-module/components/style-book/index.mjs.map +2 -2
  195. package/build-module/components/sync-connection-error-modal/index.mjs +3 -3
  196. package/build-module/components/sync-connection-error-modal/index.mjs.map +1 -1
  197. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
  198. package/build-module/components/template-actions-panel/index.mjs +0 -9
  199. package/build-module/components/template-actions-panel/index.mjs.map +2 -2
  200. package/build-module/components/template-validation-notice/index.mjs +1 -1
  201. package/build-module/components/template-validation-notice/index.mjs.map +1 -1
  202. package/build-module/components/upload-progress-snackbar/index.mjs +3 -3
  203. package/build-module/components/upload-progress-snackbar/index.mjs.map +2 -2
  204. package/build-module/components/upload-progress-snackbar/tracker.mjs.map +1 -1
  205. package/build-module/components/visual-editor/edit-template-blocks-notification.mjs +1 -1
  206. package/build-module/components/visual-editor/edit-template-blocks-notification.mjs.map +1 -1
  207. package/build-module/dataviews/fields/revisions/index.mjs +20 -0
  208. package/build-module/dataviews/fields/revisions/index.mjs.map +7 -0
  209. package/build-module/dataviews/fields/revisions/revisions-view.mjs +53 -0
  210. package/build-module/dataviews/fields/revisions/revisions-view.mjs.map +7 -0
  211. package/build-module/dataviews/store/private-actions.mjs +23 -7
  212. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  213. package/build-module/hooks/push-changes-to-global-styles/index.mjs +1 -1
  214. package/build-module/hooks/push-changes-to-global-styles/index.mjs.map +1 -1
  215. package/build-module/store/actions.mjs +1 -1
  216. package/build-module/store/actions.mjs.map +2 -2
  217. package/build-module/store/private-selectors.mjs +7 -1
  218. package/build-module/store/private-selectors.mjs.map +2 -2
  219. package/build-module/utils/media-upload/index.mjs.map +1 -1
  220. package/build-module/utils/set-nested-value.mjs.map +1 -1
  221. package/build-style/style-rtl.css +270 -206
  222. package/build-style/style.css +270 -206
  223. package/build-types/components/collab-sidebar/note-byline.d.ts +0 -3
  224. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -1
  225. package/build-types/components/collab-sidebar/note.d.ts.map +1 -1
  226. package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -1
  227. package/build-types/components/document-bar/index.d.ts +2 -2
  228. package/build-types/components/document-bar/index.d.ts.map +1 -1
  229. package/build-types/components/global-keyboard-shortcuts/index.d.ts.map +1 -1
  230. package/build-types/components/local-autosave-monitor/index.d.ts.map +1 -1
  231. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  232. package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
  233. package/build-types/components/post-revisions-timeline/index.d.ts +2 -0
  234. package/build-types/components/post-revisions-timeline/index.d.ts.map +1 -0
  235. package/build-types/components/post-saved-state/index.d.ts.map +1 -1
  236. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  237. package/build-types/components/post-text-editor/index.d.ts +1 -1
  238. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  239. package/build-types/components/provider/index.d.ts.map +1 -1
  240. package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
  241. package/build-types/components/revision-diff-panel/index.d.ts +3 -1
  242. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -1
  243. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
  244. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  245. package/build-types/components/sidebar/index.d.ts.map +1 -1
  246. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -1
  247. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
  248. package/build-types/components/template-actions-panel/index.d.ts.map +1 -1
  249. package/build-types/dataviews/fields/revisions/index.d.ts +8 -0
  250. package/build-types/dataviews/fields/revisions/index.d.ts.map +1 -0
  251. package/build-types/dataviews/fields/revisions/revisions-view.d.ts +2 -0
  252. package/build-types/dataviews/fields/revisions/revisions-view.d.ts.map +1 -0
  253. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  254. package/build-types/store/private-selectors.d.ts +1 -1
  255. package/build-types/store/private-selectors.d.ts.map +1 -1
  256. package/build-types/store/selectors.d.ts +1 -1
  257. package/build-types/store/selectors.d.ts.map +1 -1
  258. package/package.json +53 -47
  259. package/src/bindings/pattern-overrides.js +1 -1
  260. package/src/bindings/test/pattern-overrides.js +65 -0
  261. package/src/components/collab-sidebar/note-byline.js +0 -1
  262. package/src/components/collab-sidebar/note.js +64 -29
  263. package/src/components/collab-sidebar/style.scss +20 -0
  264. package/src/components/collaborators-presence/avatar/component.tsx +0 -1
  265. package/src/components/collaborators-presence/avatar/test/index.tsx +0 -1
  266. package/src/components/document-bar/index.js +8 -3
  267. package/src/components/document-bar/style.scss +4 -2
  268. package/src/components/global-keyboard-shortcuts/index.js +2 -1
  269. package/src/components/local-autosave-monitor/index.js +23 -21
  270. package/src/components/post-card-panel/index.js +1 -1
  271. package/src/components/post-publish-button/index.js +6 -3
  272. package/src/components/post-publish-button/test/index.js +13 -0
  273. package/src/components/post-revisions-preview/diff-markers.js +0 -1
  274. package/src/components/post-revisions-timeline/index.js +186 -0
  275. package/src/components/post-revisions-timeline/style.scss +43 -0
  276. package/src/components/post-saved-state/index.js +23 -26
  277. package/src/components/post-saved-state/test/index.js +18 -0
  278. package/src/components/post-taxonomies/flat-term-selector.js +4 -7
  279. package/src/components/post-text-editor/index.js +65 -0
  280. package/src/components/post-text-editor/test/utils.js +210 -0
  281. package/src/components/post-text-editor/utils.js +204 -0
  282. package/src/components/post-type-support-check/test/index.js +11 -0
  283. package/src/components/post-url/index.js +1 -1
  284. package/src/components/post-view-link/index.js +1 -1
  285. package/src/components/post-view-link/test/index.js +71 -0
  286. package/src/components/provider/index.js +2 -1
  287. package/src/components/resizable-editor/resize-handle.js +0 -1
  288. package/src/components/revision-diff-panel/index.js +8 -2
  289. package/src/components/revision-fields-diff/index.js +12 -1
  290. package/src/components/sidebar/dataform-post-summary.js +196 -25
  291. package/src/components/sidebar/index.js +2 -12
  292. package/src/components/sidebar/post-revision-summary.js +8 -15
  293. package/src/components/sidebar/post-summary.js +1 -1
  294. package/src/components/style-book/index.js +1 -1
  295. package/src/components/template-actions-panel/block-theme-content.js +0 -1
  296. package/src/components/template-actions-panel/index.js +0 -15
  297. package/src/dataviews/fields/revisions/index.tsx +28 -0
  298. package/src/dataviews/fields/revisions/revisions-view.tsx +59 -0
  299. package/src/dataviews/store/private-actions.ts +27 -6
  300. package/src/store/private-selectors.js +11 -1
  301. package/src/store/test/private-selectors.js +69 -0
  302. package/src/style.scss +1 -1
  303. package/build/components/post-revisions-panel/index.cjs +0 -173
  304. package/build/components/post-revisions-panel/index.cjs.map +0 -7
  305. package/build/components/revision-author-panel/index.cjs.map +0 -7
  306. package/build/components/revision-created-panel/index.cjs +0 -47
  307. package/build/components/revision-created-panel/index.cjs.map +0 -7
  308. package/build-module/components/post-revisions-panel/index.mjs +0 -148
  309. package/build-module/components/post-revisions-panel/index.mjs.map +0 -7
  310. package/build-module/components/revision-author-panel/index.mjs +0 -28
  311. package/build-module/components/revision-author-panel/index.mjs.map +0 -7
  312. package/build-module/components/revision-created-panel/index.mjs +0 -26
  313. package/build-module/components/revision-created-panel/index.mjs.map +0 -7
  314. package/build-types/components/collab-sidebar/add-comment.d.ts +0 -6
  315. package/build-types/components/collab-sidebar/add-comment.d.ts.map +0 -1
  316. package/build-types/components/collab-sidebar/comment-author-info.d.ts +0 -8
  317. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +0 -1
  318. package/build-types/components/collab-sidebar/comment-form.d.ts +0 -9
  319. package/build-types/components/collab-sidebar/comment-form.d.ts.map +0 -1
  320. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +0 -6
  321. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +0 -1
  322. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +0 -6
  323. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +0 -1
  324. package/build-types/components/collab-sidebar/comments.d.ts +0 -10
  325. package/build-types/components/collab-sidebar/comments.d.ts.map +0 -1
  326. package/build-types/components/global-styles-provider/index.d.ts +0 -16
  327. package/build-types/components/global-styles-provider/index.d.ts.map +0 -1
  328. package/build-types/components/media/index.d.ts +0 -3
  329. package/build-types/components/media/index.d.ts.map +0 -1
  330. package/build-types/components/media/metadata-panel.d.ts +0 -12
  331. package/build-types/components/media/metadata-panel.d.ts.map +0 -1
  332. package/build-types/components/media/preview.d.ts +0 -9
  333. package/build-types/components/media/preview.d.ts.map +0 -1
  334. package/build-types/components/post-revisions-panel/index.d.ts +0 -2
  335. package/build-types/components/post-revisions-panel/index.d.ts.map +0 -1
  336. package/build-types/components/revision-author-panel/index.d.ts +0 -2
  337. package/build-types/components/revision-author-panel/index.d.ts.map +0 -1
  338. package/build-types/components/revision-created-panel/index.d.ts +0 -2
  339. package/build-types/components/revision-created-panel/index.d.ts.map +0 -1
  340. package/src/components/editor-help/images/add-dark.png +0 -0
  341. package/src/components/editor-help/images/add-dark@2x.png +0 -0
  342. package/src/components/editor-help/images/add-dark@3x.png +0 -0
  343. package/src/components/editor-help/images/add-light.png +0 -0
  344. package/src/components/editor-help/images/add-light@2x.png +0 -0
  345. package/src/components/editor-help/images/add-light@3x.png +0 -0
  346. package/src/components/editor-help/images/block-layout-collage.png +0 -0
  347. package/src/components/editor-help/images/block-layout-collage@2x.png +0 -0
  348. package/src/components/editor-help/images/block-layout-collage@3x.png +0 -0
  349. package/src/components/editor-help/images/build-layouts-dark.png +0 -0
  350. package/src/components/editor-help/images/build-layouts-dark@2x.png +0 -0
  351. package/src/components/editor-help/images/build-layouts-dark@3x.png +0 -0
  352. package/src/components/editor-help/images/build-layouts-light.png +0 -0
  353. package/src/components/editor-help/images/build-layouts-light@2x.png +0 -0
  354. package/src/components/editor-help/images/build-layouts-light@3x.png +0 -0
  355. package/src/components/editor-help/images/drag-and-drop-dark.png +0 -0
  356. package/src/components/editor-help/images/drag-and-drop-dark@2x.png +0 -0
  357. package/src/components/editor-help/images/drag-and-drop-dark@3x.png +0 -0
  358. package/src/components/editor-help/images/drag-and-drop-light.png +0 -0
  359. package/src/components/editor-help/images/drag-and-drop-light@2x.png +0 -0
  360. package/src/components/editor-help/images/drag-and-drop-light@3x.png +0 -0
  361. package/src/components/editor-help/images/edit-media-dark.png +0 -0
  362. package/src/components/editor-help/images/edit-media-dark@2x.png +0 -0
  363. package/src/components/editor-help/images/edit-media-dark@3x.png +0 -0
  364. package/src/components/editor-help/images/edit-media-light.png +0 -0
  365. package/src/components/editor-help/images/edit-media-light@2x.png +0 -0
  366. package/src/components/editor-help/images/edit-media-light@3x.png +0 -0
  367. package/src/components/editor-help/images/embed-media-dark.png +0 -0
  368. package/src/components/editor-help/images/embed-media-dark@2x.png +0 -0
  369. package/src/components/editor-help/images/embed-media-dark@3x.png +0 -0
  370. package/src/components/editor-help/images/embed-media-light.png +0 -0
  371. package/src/components/editor-help/images/embed-media-light@2x.png +0 -0
  372. package/src/components/editor-help/images/embed-media-light@3x.png +0 -0
  373. package/src/components/editor-help/images/move-dark.png +0 -0
  374. package/src/components/editor-help/images/move-dark@2x.png +0 -0
  375. package/src/components/editor-help/images/move-dark@3x.png +0 -0
  376. package/src/components/editor-help/images/move-light.png +0 -0
  377. package/src/components/editor-help/images/move-light@2x.png +0 -0
  378. package/src/components/editor-help/images/move-light@3x.png +0 -0
  379. package/src/components/editor-help/images/options-dark.png +0 -0
  380. package/src/components/editor-help/images/options-dark@2x.png +0 -0
  381. package/src/components/editor-help/images/options-dark@3x.png +0 -0
  382. package/src/components/editor-help/images/options-light.png +0 -0
  383. package/src/components/editor-help/images/options-light@2x.png +0 -0
  384. package/src/components/editor-help/images/options-light@3x.png +0 -0
  385. package/src/components/editor-help/images/rich-text-dark.png +0 -0
  386. package/src/components/editor-help/images/rich-text-dark@2x.png +0 -0
  387. package/src/components/editor-help/images/rich-text-dark@3x.png +0 -0
  388. package/src/components/editor-help/images/rich-text-light.png +0 -0
  389. package/src/components/editor-help/images/rich-text-light@2x.png +0 -0
  390. package/src/components/editor-help/images/rich-text-light@3x.png +0 -0
  391. package/src/components/editor-help/images/settings-dark.png +0 -0
  392. package/src/components/editor-help/images/settings-dark@2x.png +0 -0
  393. package/src/components/editor-help/images/settings-dark@3x.png +0 -0
  394. package/src/components/editor-help/images/settings-light.png +0 -0
  395. package/src/components/editor-help/images/settings-light@2x.png +0 -0
  396. package/src/components/editor-help/images/settings-light@3x.png +0 -0
  397. package/src/components/editor-help/style.scss +0 -123
  398. package/src/components/post-revisions-panel/index.js +0 -161
  399. package/src/components/post-revisions-panel/style.scss +0 -16
  400. package/src/components/revision-author-panel/index.js +0 -36
  401. package/src/components/revision-created-panel/index.js +0 -36
@@ -48,7 +48,7 @@ function getFullPostScheduleLabel(dateAttribute) {
48
48
  const timezoneAbbreviation = getTimezoneAbbreviation();
49
49
  const formattedDate = (0, import_date.dateI18n)(
50
50
  // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
51
- (0, import_i18n._x)("F j, Y g:i\xA0a", "post schedule full date format"),
51
+ (0, import_i18n._x)("F j, Y g:i a", "post schedule full date format"),
52
52
  date
53
53
  );
54
54
  return (0, import_i18n.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
@@ -66,7 +66,7 @@ function getPostScheduleLabel(dateAttribute, { isFloating = false, now = /* @__P
66
66
  // translators: %s: Time of day the post is scheduled for.
67
67
  (0, import_i18n.__)("Today at %s"),
68
68
  // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
69
- (0, import_date.dateI18n)((0, import_i18n._x)("g:i\xA0a", "post schedule time format"), date)
69
+ (0, import_date.dateI18n)((0, import_i18n._x)("g:i a", "post schedule time format"), date)
70
70
  );
71
71
  }
72
72
  const tomorrow = new Date(now);
@@ -76,19 +76,19 @@ function getPostScheduleLabel(dateAttribute, { isFloating = false, now = /* @__P
76
76
  // translators: %s: Time of day the post is scheduled for.
77
77
  (0, import_i18n.__)("Tomorrow at %s"),
78
78
  // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
79
- (0, import_date.dateI18n)((0, import_i18n._x)("g:i\xA0a", "post schedule time format"), date)
79
+ (0, import_date.dateI18n)((0, import_i18n._x)("g:i a", "post schedule time format"), date)
80
80
  );
81
81
  }
82
82
  if (date.getFullYear() === now.getFullYear()) {
83
83
  return (0, import_date.dateI18n)(
84
84
  // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
85
- (0, import_i18n._x)("F j g:i\xA0a", "post schedule date format without year"),
85
+ (0, import_i18n._x)("F j g:i a", "post schedule date format without year"),
86
86
  date
87
87
  );
88
88
  }
89
89
  return (0, import_date.dateI18n)(
90
90
  // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
91
- (0, import_i18n._x)("F j, Y g:i\xA0a", "post schedule full date format"),
91
+ (0, import_i18n._x)("F j, Y g:i a", "post schedule full date format"),
92
92
  date
93
93
  );
94
94
  }
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-schedule/label.js"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf, isRTL } from '@wordpress/i18n';\nimport { getSettings, getDate, dateI18n } from '@wordpress/date';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Renders the PostScheduleLabel component.\n *\n * @param {Object} props Props.\n *\n * @return {React.ReactNode} The rendered component.\n */\nexport default function PostScheduleLabel( props ) {\n\treturn usePostScheduleLabel( props );\n}\n\n/**\n * Custom hook to get the label for post schedule.\n *\n * @param {Object} options Options for the hook.\n * @param {boolean} options.full Whether to get the full label or not. Default is false.\n *\n * @return {string} The label for post schedule.\n */\nexport function usePostScheduleLabel( { full = false } = {} ) {\n\tconst { date, isFloating } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdate: select( editorStore ).getEditedPostAttribute( 'date' ),\n\t\t\tisFloating: select( editorStore ).isEditedPostDateFloating(),\n\t\t} ),\n\t\t[]\n\t);\n\n\treturn full\n\t\t? getFullPostScheduleLabel( date )\n\t\t: getPostScheduleLabel( date, { isFloating } );\n}\n\nexport function getFullPostScheduleLabel( dateAttribute ) {\n\tconst date = getDate( dateAttribute );\n\n\tconst timezoneAbbreviation = getTimezoneAbbreviation();\n\tconst formattedDate = dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n\treturn isRTL()\n\t\t? `${ timezoneAbbreviation } ${ formattedDate }`\n\t\t: `${ formattedDate } ${ timezoneAbbreviation }`;\n}\n\nexport function getPostScheduleLabel(\n\tdateAttribute,\n\t{ isFloating = false, now = new Date() } = {}\n) {\n\tif ( ! dateAttribute || isFloating ) {\n\t\treturn __( 'Immediately' );\n\t}\n\n\t// If the user timezone does not equal the site timezone then using words\n\t// like 'tomorrow' is confusing, so show the full date.\n\tif ( ! isTimezoneSameAsSiteTimezone( now ) ) {\n\t\treturn getFullPostScheduleLabel( dateAttribute );\n\t}\n\n\tconst date = getDate( dateAttribute );\n\n\tif ( isSameDay( date, now ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Today at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tconst tomorrow = new Date( now );\n\ttomorrow.setDate( tomorrow.getDate() + 1 );\n\n\tif ( isSameDay( date, tomorrow ) ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: Time of day the post is scheduled for.\n\t\t\t__( 'Tomorrow at %s' ),\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\tdateI18n( _x( 'g:i\\xa0a', 'post schedule time format' ), date )\n\t\t);\n\t}\n\n\tif ( date.getFullYear() === now.getFullYear() ) {\n\t\treturn dateI18n(\n\t\t\t// translators: If using a space between 'g:i' and 'a', use a non-breaking space.\n\t\t\t_x( 'F j g:i\\xa0a', 'post schedule date format without year' ),\n\t\t\tdate\n\t\t);\n\t}\n\n\treturn dateI18n(\n\t\t// translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.\n\t\t_x( 'F j, Y g:i\\xa0a', 'post schedule full date format' ),\n\t\tdate\n\t);\n}\n\nfunction getTimezoneAbbreviation() {\n\tconst { timezone } = getSettings();\n\n\tif ( timezone.abbr && isNaN( Number( timezone.abbr ) ) ) {\n\t\treturn timezone.abbr;\n\t}\n\n\tconst symbol = timezone.offset < 0 ? '' : '+';\n\treturn `UTC${ symbol }${ timezone.offsetFormatted }`;\n}\n\nfunction isTimezoneSameAsSiteTimezone( date ) {\n\tconst { timezone } = getSettings();\n\n\tconst siteOffset = Number( timezone.offset );\n\tconst dateOffset = -1 * ( date.getTimezoneOffset() / 60 );\n\treturn siteOffset === dateOffset;\n}\n\nfunction isSameDay( left, right ) {\n\treturn (\n\t\tleft.getDate() === right.getDate() &&\n\t\tleft.getMonth() === right.getMonth() &&\n\t\tleft.getFullYear() === right.getFullYear()\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAuC;AACvC,kBAA+C;AAC/C,kBAA0B;AAK1B,mBAAqC;AAStB,SAAR,kBAAoC,OAAQ;AAClD,SAAO,qBAAsB,KAAM;AACpC;AAUO,SAAS,qBAAsB,EAAE,OAAO,MAAM,IAAI,CAAC,GAAI;AAC7D,QAAM,EAAE,MAAM,WAAW,QAAI;AAAA,IAC5B,CAAE,YAAc;AAAA,MACf,MAAM,OAAQ,aAAAA,KAAY,EAAE,uBAAwB,MAAO;AAAA,MAC3D,YAAY,OAAQ,aAAAA,KAAY,EAAE,yBAAyB;AAAA,IAC5D;AAAA,IACA,CAAC;AAAA,EACF;AAEA,SAAO,OACJ,yBAA0B,IAAK,IAC/B,qBAAs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AAO,GAAI,SAAS,eAAgB;AACnD;AAEA,SAAS,6BAA8B,MAAO;AAC7C,QAAM,EAAE,SAAS,QAAI,yBAAY;AAEjC,QAAM,aAAa,OAAQ,SAAS,MAAO;AAC3C,QAAM,aAAa,MAAO,KAAK,kBAAkB,IAAI;AACrD,SAAO,eAAe;AACvB;AAEA,SAAS,UAAW,MAAM,OAAQ;AACjC,SACC,KAAK,QAAQ,MAAM,MAAM,QAAQ,KACjC,KAAK,SAAS,MAAM,MAAM,SAAS,KACnC,KAAK,YAAY,MAAM,MAAM,YAAY;AAE3C;",
6
6
  "names": ["editorStore"]
7
7
  }
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(flat_term_selector_exports);
37
37
  var import_i18n = require("@wordpress/i18n");
38
38
  var import_element = require("@wordpress/element");
39
39
  var import_components = require("@wordpress/components");
40
+ var import_ui = require("@wordpress/ui");
40
41
  var import_data = require("@wordpress/data");
41
42
  var import_core_data = require("@wordpress/core-data");
42
43
  var import_compose = require("@wordpress/compose");
@@ -218,7 +219,7 @@ function FlatTermSelector({ slug }) {
218
219
  (0, import_i18n._x)("Remove %s", "term"),
219
220
  singularName
220
221
  );
221
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_components.__experimentalVStack, { spacing: 4, children: [
222
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "lg", children: [
222
223
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
223
224
  import_components.FormTokenField,
224
225
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-taxonomies/flat-term-selector.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport {\n\tFormTokenField,\n\twithFilters,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * How the max suggestions limit was chosen:\n * - Matches the `per_page` range set by the REST API.\n * - Can't use \"unbound\" query. The `FormTokenField` needs a fixed number.\n * - Matches default for `FormTokenField`.\n */\nconst MAX_TERMS_SUGGESTIONS = 100;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names\n\t\t.map(\n\t\t\t( termName ) =>\n\t\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) )\n\t\t\t\t\t?.id\n\t\t)\n\t\t.filter( ( id ) => id !== undefined );\n};\n\n/**\n * Renders a flat term selector component.\n *\n * @param {Object} props The component props.\n * @param {string} props.slug The slug of the taxonomy.\n *\n * @return {React.ReactNode} The rendered flat term selector component.\n */\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getEntityRecord( 'root', 'taxonomy', slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds?.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds?.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\tonUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\t// In case of a failure, try assigning available terms.\n\t\t\t\t// This will invalidate the optimistic update.\n\t\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add Tag' ) : __( 'Add Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<VStack spacing={ 4 }>\n\t\t\t<FormTokenField\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</VStack>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAChC,qBAA6C;AAC7C,wBAIO;AACP,kBAAuC;AACvC,uBAAmC;AACnC,qBAA4B;AAC5B,kBAAsB;AACtB,qBAAsC;AAKtC,mBAAqC;AACrC,mBAA6C;AAC7C,6BAA0B;AAqQxB;AA7PF,IAAM,cAAc,CAAC;AAQrB,IAAM,wBAAwB;AAC9B,IAAM,gBAAgB;AAAA,EACrB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,SAAS;AACV;AAEA,IAAM,iB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;AAEA,UAAM,aAAa,CAAE,GAAG,SAAS,QAAQ,EAAG;AAC5C,UAAM,cAAc,SAAS,iBAAa,gBAAI,KAAM,QAAI,gBAAI,MAAO;AACnE,UAAM,uBAAmB;AAAA;AAAA,UAExB,gBAAI,YAAY,MAAO;AAAA,MACvB,UAAU,QAAQ,iBAAiB;AAAA,IACpC;AAEA,2BAAO,kBAAkB,WAAY;AACrC,kBAAe,UAAW;AAAA,EAC3B;AAEA,QAAM,eACL,UAAU,QAAQ,iBAChB,SAAS,iBAAa,gBAAI,SAAU,QAAI,gBAAI,UAAW;AAC1D,QAAM,eACL,UAAU,QAAQ,kBAChB,SAAS,iBAAa,gBAAI,KAAM,QAAI,gBAAI,MAAO;AAClD,QAAM,qBAAiB;AAAA;AAAA,QAEtB,gBAAI,YAAY,MAAO;AAAA,IACvB;AAAA,EACD;AACA,QAAM,uBAAmB;AAAA;AAAA,QAExB,gBAAI,cAAc,MAAO;AAAA,IACzB;AAAA,EACD;AACA,QAAM,sBAAkB;AAAA;AAAA,QAEvB,gBAAI,aAAa,MAAO;AAAA,IACxB;AAAA,EACD;AAEA,SACC,6CAAC,kBAAAC,sBAAA,EAAO,SAAU,GACjB;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,eAAgB;AAAA,QAChB,gBAAiB;AAAA,QACjB,OAAQ;AAAA,QACR,UAAW;AAAA,UACV,OAAO;AAAA,UACP,SAAS;AAAA,UACT,QAAQ;AAAA,QACT;AAAA;AAAA,IACD;AAAA,IACA,4CAAC,uBAAAC,SAAA,EAAc,UAAsB,UAAW,YAAa;AAAA,KAC9D;AAEF;AAEA,IAAO,iCAAQ,+BAAa,yBAA0B,EAAG,gBAAiB;",
6
- "names": ["editorStore", "coreStore", "noticesStore", "VStack", "MostUsedTerms"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, withFilters } from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unescapeString, unescapeTerm } from '../../utils/terms';\nimport MostUsedTerms from './most-used-terms';\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * How the max suggestions limit was chosen:\n * - Matches the `per_page` range set by the REST API.\n * - Can't use \"unbound\" query. The `FormTokenField` needs a fixed number.\n * - Matches default for `FormTokenField`.\n */\nconst MAX_TERMS_SUGGESTIONS = 100;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names\n\t\t.map(\n\t\t\t( termName ) =>\n\t\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) )\n\t\t\t\t\t?.id\n\t\t)\n\t\t.filter( ( id ) => id !== undefined );\n};\n\n/**\n * Renders a flat term selector component.\n *\n * @param {Object} props The component props.\n * @param {string} props.slug The slug of the taxonomy.\n *\n * @return {React.ReactNode} The rendered flat term selector component.\n */\nexport function FlatTermSelector( { slug } ) {\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttermIds,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecords, getEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst post = getCurrentPost();\n\t\t\tconst _taxonomy = getEntityRecord( 'root', 'taxonomy', slug );\n\t\t\tconst _termIds = _taxonomy\n\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t: EMPTY_ARRAY;\n\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds?.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds?.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditPost( { [ taxonomy.rest_base ]: newTermIds } );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\tonUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t\t// In case of a failure, try assigning available terms.\n\t\t\t\t// This will invalidate the optimistic update.\n\t\t\t\tonUpdateTerms( termNamesToIds( uniqueTerms, availableTerms ) );\n\t\t\t} );\n\t}\n\n\tfunction appendTerm( newTerm ) {\n\t\tif ( termIds.includes( newTerm.id ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newTermIds = [ ...termIds, newTerm.id ];\n\t\tconst defaultName = slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tonUpdateTerms( newTermIds );\n\t}\n\n\tconst newTermLabel =\n\t\ttaxonomy?.labels?.add_new_item ??\n\t\t( slug === 'post_tag' ? __( 'Add Tag' ) : __( 'Add Term' ) );\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<Stack direction=\"column\" gap=\"lg\">\n\t\t\t<FormTokenField\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvalue={ values }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\tlabel={ newTermLabel }\n\t\t\t\tmessages={ {\n\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } />\n\t\t</Stack>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )( FlatTermSelector );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAgC;AAChC,qBAA6C;AAC7C,wBAA4C;AAC5C,gBAAsB;AACtB,kBAAuC;AACvC,uBAAmC;AACnC,qBAA4B;AAC5B,kBAAsB;AACtB,qBAAsC;AAKtC,mBAAqC;AACrC,mBAA6C;AAC7C,6B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Aa,yBAA0B,EAAG,gBAAiB;",
6
+ "names": ["editorStore", "coreStore", "noticesStore", "MostUsedTerms"]
7
7
  }
@@ -275,7 +275,7 @@ function HierarchicalTermSelector({ slug }) {
275
275
  (0, import_i18n.__)("Parent Category"),
276
276
  (0, import_i18n.__)("Parent Term")
277
277
  );
278
- const noParentOption = `\u2014 ${parentSelectLabel} \u2014`;
278
+ const noParentOption = `— ${parentSelectLabel} —`;
279
279
  const newTermSubmitLabel = newTermButtonLabel;
280
280
  const filterLabel = taxonomy?.labels?.search_items ?? (0, import_i18n.__)("Search Terms");
281
281
  const groupLabel = taxonomy?.name ?? (0, import_i18n.__)("Terms");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-taxonomies/hierarchical-term-selector.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\n\tFlex,\n\tFlexItem,\n\tSearchControl,\n\tSpinner,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useDebounce } from '@wordpress/compose';\nimport {\n\tstore as coreStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { normalizeTextString } = unlock( componentsPrivateApis );\nconst { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );\n\n/**\n * Module Constants\n */\nconst DEFAULT_QUERY = {\n\tper_page: -1,\n\torderby: 'name',\n\torder: 'asc',\n\t_fields: 'id,name,parent',\n\tcontext: 'view',\n\t[ RECEIVE_INTERMEDIATE_RESULTS ]: true,\n};\nconst MIN_TERMS_COUNT_FOR_FILTER = 8;\nconst EMPTY_ARRAY = [];\n\n/**\n * Sort Terms by Selected.\n *\n * @param {Object[]} termsTree Array of terms in tree format.\n * @param {number[]} terms Selected terms.\n *\n * @return {Object[]} Sorted array of terms.\n */\nexport function sortBySelected( termsTree, terms ) {\n\tconst treeHasSelection = ( termTree ) => {\n\t\tif ( terms.indexOf( termTree.id ) !== -1 ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( undefined === termTree.children ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\ttermTree.children\n\t\t\t\t.map( treeHasSelection )\n\t\t\t\t.filter( ( child ) => child ).length > 0\n\t\t);\n\t};\n\tconst termOrChildIsSelected = ( termA, termB ) => {\n\t\tconst termASelected = treeHasSelection( termA );\n\t\tconst termBSelected = treeHasSelection( termB );\n\n\t\tif ( termASelected === termBSelected ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif ( termASelected && ! termBSelected ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif ( ! termASelected && termBSelected ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn 0;\n\t};\n\tconst newTermTree = [ ...termsTree ];\n\tnewTermTree.sort( termOrChildIsSelected );\n\treturn newTermTree;\n}\n\n/**\n * Find term by parent id or name.\n *\n * @param {Object[]} terms Array of Terms.\n * @param {number|string} parent id.\n * @param {string} name Term name.\n * @return {Object} Term object.\n */\nexport function findTerm( terms, parent, name ) {\n\treturn terms.find( ( term ) => {\n\t\treturn (\n\t\t\t( ( ! term.parent && ! parent ) ||\n\t\t\t\tparseInt( term.parent ) === parseInt( parent ) ) &&\n\t\t\tterm.name.toLowerCase() === name.toLowerCase()\n\t\t);\n\t} );\n}\n\n/**\n * Get filter matcher function.\n *\n * @param {string} filterValue Filter value.\n * @return {(function(Object): (Object|boolean))} Matcher function.\n */\nexport function getFilterMatcher( filterValue ) {\n\tconst matchTermsForFilter = ( originalTerm ) => {\n\t\tif ( '' === filterValue ) {\n\t\t\treturn originalTerm;\n\t\t}\n\n\t\t// Shallow clone, because we'll be filtering the term's children and\n\t\t// don't want to modify the original term.\n\t\tconst term = { ...originalTerm };\n\n\t\t// Map and filter the children, recursive so we deal with grandchildren\n\t\t// and any deeper levels.\n\t\tif ( term.children.length > 0 ) {\n\t\t\tterm.children = term.children\n\t\t\t\t.map( matchTermsForFilter )\n\t\t\t\t.filter( ( child ) => child );\n\t\t}\n\n\t\t// If the term's name contains the filterValue, or it has children\n\t\t// (i.e. some child matched at some point in the tree) then return it.\n\t\tif (\n\t\t\t-1 !==\n\t\t\t\tnormalizeTextString( term.name ).indexOf(\n\t\t\t\t\tnormalizeTextString( filterValue )\n\t\t\t\t) ||\n\t\t\tterm.children.length > 0\n\t\t) {\n\t\t\treturn term;\n\t\t}\n\n\t\t// Otherwise, return false. After mapping, the list of terms will need\n\t\t// to have false values filtered out.\n\t\treturn false;\n\t};\n\treturn matchTermsForFilter;\n}\n\n/**\n * Hierarchical term selector.\n *\n * @param {Object} props Component props.\n * @param {string} props.slug Taxonomy slug.\n * @return {Element} Hierarchical term selector component.\n */\nexport function HierarchicalTermSelector( { slug } ) {\n\tconst [ adding, setAdding ] = useState( false );\n\tconst [ formName, setFormName ] = useState( '' );\n\t/**\n\t * @type {[number|'', Function]}\n\t */\n\tconst [ formParent, setFormParent ] = useState( '' );\n\tconst [ showForm, setShowForm ] = useState( false );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ filteredTermsTree, setFilteredTermsTree ] = useState( [] );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst {\n\t\thasCreateAction,\n\t\thasAssignAction,\n\t\tterms,\n\t\tloading,\n\t\tavailableTerms,\n\t\ttaxonomy,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecord, getEntityRecords, isResolving } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _taxonomy = getEntityRecord( 'root', 'taxonomy', slug );\n\t\t\tconst post = getCurrentPost();\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? !! post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ]\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? !! post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ]\n\t\t\t\t\t: false,\n\t\t\t\tterms: _taxonomy\n\t\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\tloading: isResolving( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tDEFAULT_QUERY,\n\t\t\t\t] ),\n\t\t\t\tavailableTerms:\n\t\t\t\t\tgetEntityRecords( 'taxonomy', slug, DEFAULT_QUERY ) ||\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst availableTermsTree = useMemo(\n\t\t() => sortBySelected( buildTermsTree( availableTerms ), terms ),\n\t\t// Remove `terms` from the dependency list to avoid reordering every time\n\t\t// checking or unchecking a term.\n\t\t[ availableTerms ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Append new term.\n\t *\n\t * @param {Object} term Term object.\n\t * @return {Promise} A promise that resolves to save term object.\n\t */\n\tconst addTerm = ( term ) => {\n\t\treturn saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\t/**\n\t * Update terms for post.\n\t *\n\t * @param {number[]} termIds Term ids.\n\t */\n\tconst onUpdateTerms = ( termIds ) => {\n\t\teditPost( { [ taxonomy.rest_base ]: termIds } );\n\t};\n\n\t/**\n\t * Handler for checking term.\n\t *\n\t * @param {number} termId\n\t */\n\tconst onChange = ( termId ) => {\n\t\tconst hasTerm = terms.includes( termId );\n\t\tconst newTerms = hasTerm\n\t\t\t? terms.filter( ( id ) => id !== termId )\n\t\t\t: [ ...terms, termId ];\n\t\tonUpdateTerms( newTerms );\n\t};\n\n\tconst onChangeFormName = ( value ) => {\n\t\tsetFormName( value );\n\t};\n\n\t/**\n\t * Handler for changing form parent.\n\t *\n\t * @param {number|''} parentId Parent post id.\n\t */\n\tconst onChangeFormParent = ( parentId ) => {\n\t\tsetFormParent( parentId );\n\t};\n\n\tconst onToggleForm = () => {\n\t\tsetShowForm( ! showForm );\n\t};\n\n\tconst onAddTerm = async ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( formName === '' || adding ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if the term we are adding already exists.\n\t\tconst existingTerm = findTerm( availableTerms, formParent, formName );\n\t\tif ( existingTerm ) {\n\t\t\t// If the term we are adding exists but is not selected select it.\n\t\t\tif ( ! terms.some( ( term ) => term === existingTerm.id ) ) {\n\t\t\t\tonUpdateTerms( [ ...terms, existingTerm.id ] );\n\t\t\t}\n\n\t\t\tsetFormName( '' );\n\t\t\tsetFormParent( '' );\n\n\t\t\treturn;\n\t\t}\n\t\tsetAdding( true );\n\t\tlet newTerm;\n\t\ttry {\n\t\t\tnewTerm = await addTerm( {\n\t\t\t\tname: formName,\n\t\t\t\tparent: formParent ? formParent : undefined,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\tconst defaultName =\n\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tsetAdding( false );\n\t\tsetFormName( '' );\n\t\tsetFormParent( '' );\n\t\tonUpdateTerms( [ ...terms, newTerm.id ] );\n\t};\n\n\tconst setFilter = ( value ) => {\n\t\tconst newFilteredTermsTree = availableTermsTree\n\t\t\t.map( getFilterMatcher( value ) )\n\t\t\t.filter( ( term ) => term );\n\t\tconst getResultCount = ( termsTree ) => {\n\t\t\tlet count = 0;\n\t\t\tfor ( let i = 0; i < termsTree.length; i++ ) {\n\t\t\t\tcount++;\n\t\t\t\tif ( undefined !== termsTree[ i ].children ) {\n\t\t\t\t\tcount += getResultCount( termsTree[ i ].children );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t};\n\n\t\tsetFilterValue( value );\n\t\tsetFilteredTermsTree( newFilteredTermsTree );\n\n\t\tconst resultCount = getResultCount( newFilteredTermsTree );\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', resultCount ),\n\t\t\tresultCount\n\t\t);\n\n\t\tdebouncedSpeak( resultsFoundMessage, 'assertive' );\n\t};\n\n\tconst renderTerms = ( renderedTerms ) => {\n\t\treturn renderedTerms.map( ( term ) => {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tkey={ term.id }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-choice\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tchecked={ terms.indexOf( term.id ) !== -1 }\n\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\tconst termId = parseInt( term.id, 10 );\n\t\t\t\t\t\t\tonChange( termId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ decodeEntities( term.name ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! term.children.length && (\n\t\t\t\t\t\t<div className=\"editor-post-taxonomies__hierarchical-terms-subchoices\">\n\t\t\t\t\t\t\t{ renderTerms( term.children ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t} );\n\t};\n\n\tconst labelWithFallback = (\n\t\tlabelProperty,\n\t\tfallbackIsCategory,\n\t\tfallbackIsNotCategory\n\t) =>\n\t\ttaxonomy?.labels?.[ labelProperty ] ??\n\t\t( slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory );\n\n\tconst newTermButtonLabel = labelWithFallback(\n\t\t'add_new_item',\n\t\t__( 'Add Category' ),\n\t\t__( 'Add Term' )\n\t);\n\tconst newTermLabel = labelWithFallback(\n\t\t'new_item_name',\n\t\t__( 'Add Category' ),\n\t\t__( 'Add Term' )\n\t);\n\tconst parentSelectLabel = labelWithFallback(\n\t\t'parent_item',\n\t\t__( 'Parent Category' ),\n\t\t__( 'Parent Term' )\n\t);\n\tconst noParentOption = `\u2014 ${ parentSelectLabel } \u2014`;\n\tconst newTermSubmitLabel = newTermButtonLabel;\n\tconst filterLabel = taxonomy?.labels?.search_items ?? __( 'Search Terms' );\n\tconst groupLabel = taxonomy?.name ?? __( 'Terms' );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t{ showFilter && ! loading && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ filterLabel }\n\t\t\t\t\tplaceholder={ filterLabel }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ setFilter }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ loading && (\n\t\t\t\t<Flex\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t// Match SearchControl height to prevent layout shift.\n\t\t\t\t\t\theight: '40px',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Flex>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-list\"\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ groupLabel }\n\t\t\t>\n\t\t\t\t{ renderTerms(\n\t\t\t\t\t'' !== filterValue ? filteredTermsTree : availableTermsTree\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ ! loading && hasCreateAction && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAoC;AACpC,qBAAkC;AAClC,qBAAsC;AACtC,wBAWO;AACP,kBAAuC;AACvC,qBAA4B;AAC5B,uBAGO;AACP,kBAAsB;AACtB,2BAA+B;AAK/B,mBAA+B;AAC/B,mBAAqC;AACrC,yBAAuB;AA4UnB;AA1UJ,IAAM,EAAE,oBAAoB,QAAI,2BAAQ,kBAAAA,WAAsB;AAC9D,IAAM,EAAE,6BAA6B,QAAI,2BAAQ,iBAAAC,WAAoB;AAKrE,IAAM,gBAAgB;AAAA,EACrB,UAAU;AAAA,EACV,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,CAAE,4BAA6B,GAAG;AACnC;AACA,IAAM,6BAA6B;AACnC,IAAM,cAAc,CAAC;AAUd,SAAS,eAAgB,WAAW,OAAQ;AAClD,QAAM,mBAAmB,CAAE,aAAc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A,QAEA,sDAAC,6BAAQ;AAAA;AAAA,IACV;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,UAAS;AAAA,QACT,MAAK;AAAA,QACL,cAAa;AAAA,QAEX;AAAA,UACD,OAAO,cAAc,oBAAoB;AAAA,QAC1C;AAAA;AAAA,IACD;AAAA,IACE,CAAE,WAAW,mBACd,4CAAC,8BACA;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,SAAU;AAAA,QACV,WAAU;AAAA,QACV,iBAAgB;AAAA,QAChB,SAAQ;AAAA,QAEN;AAAA;AAAA,IACH,GACD;AAAA,IAEC,YACD,4CAAC,UAAK,UAAW,WAChB,uDAAC,0BAAK,WAAU,UAAS,KAAI,KAC5B;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,WAAU;AAAA,UACV,OAAQ;AAAA,UACR,OAAQ;AAAA,UACR,UAAW;AAAA,UACX,UAAQ;AAAA;AAAA,MACT;AAAA,MACE,CAAC,CAAE,eAAe,UACnB;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,OAAQ;AAAA,UACR,eAAgB;AAAA,UAChB,UAAW;AAAA,UACX,YAAa;AAAA,UACb,MAAO;AAAA;AAAA,MACR;AAAA,MAED,4CAAC,8BACA;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,WAAU;AAAA,UAER;AAAA;AAAA,MACH,GACD;AAAA,OACD,GACD;AAAA,KAEF;AAEF;AAEA,IAAO,yCAAQ,+BAAa,yBAA0B;AAAA,EACrD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, _n, _x, sprintf } from '@wordpress/i18n';\nimport { useMemo, useState } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport {\n\tButton,\n\tCheckboxControl,\n\tTextControl,\n\tTreeSelect,\n\twithFilters,\n\tFlex,\n\tFlexItem,\n\tSearchControl,\n\tSpinner,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useDebounce } from '@wordpress/compose';\nimport {\n\tstore as coreStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { buildTermsTree } from '../../utils/terms';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { normalizeTextString } = unlock( componentsPrivateApis );\nconst { RECEIVE_INTERMEDIATE_RESULTS } = unlock( coreDataPrivateApis );\n\n/**\n * Module Constants\n */\nconst DEFAULT_QUERY = {\n\tper_page: -1,\n\torderby: 'name',\n\torder: 'asc',\n\t_fields: 'id,name,parent',\n\tcontext: 'view',\n\t[ RECEIVE_INTERMEDIATE_RESULTS ]: true,\n};\nconst MIN_TERMS_COUNT_FOR_FILTER = 8;\nconst EMPTY_ARRAY = [];\n\n/**\n * Sort Terms by Selected.\n *\n * @param {Object[]} termsTree Array of terms in tree format.\n * @param {number[]} terms Selected terms.\n *\n * @return {Object[]} Sorted array of terms.\n */\nexport function sortBySelected( termsTree, terms ) {\n\tconst treeHasSelection = ( termTree ) => {\n\t\tif ( terms.indexOf( termTree.id ) !== -1 ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( undefined === termTree.children ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn (\n\t\t\ttermTree.children\n\t\t\t\t.map( treeHasSelection )\n\t\t\t\t.filter( ( child ) => child ).length > 0\n\t\t);\n\t};\n\tconst termOrChildIsSelected = ( termA, termB ) => {\n\t\tconst termASelected = treeHasSelection( termA );\n\t\tconst termBSelected = treeHasSelection( termB );\n\n\t\tif ( termASelected === termBSelected ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif ( termASelected && ! termBSelected ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tif ( ! termASelected && termBSelected ) {\n\t\t\treturn 1;\n\t\t}\n\n\t\treturn 0;\n\t};\n\tconst newTermTree = [ ...termsTree ];\n\tnewTermTree.sort( termOrChildIsSelected );\n\treturn newTermTree;\n}\n\n/**\n * Find term by parent id or name.\n *\n * @param {Object[]} terms Array of Terms.\n * @param {number|string} parent id.\n * @param {string} name Term name.\n * @return {Object} Term object.\n */\nexport function findTerm( terms, parent, name ) {\n\treturn terms.find( ( term ) => {\n\t\treturn (\n\t\t\t( ( ! term.parent && ! parent ) ||\n\t\t\t\tparseInt( term.parent ) === parseInt( parent ) ) &&\n\t\t\tterm.name.toLowerCase() === name.toLowerCase()\n\t\t);\n\t} );\n}\n\n/**\n * Get filter matcher function.\n *\n * @param {string} filterValue Filter value.\n * @return {(function(Object): (Object|boolean))} Matcher function.\n */\nexport function getFilterMatcher( filterValue ) {\n\tconst matchTermsForFilter = ( originalTerm ) => {\n\t\tif ( '' === filterValue ) {\n\t\t\treturn originalTerm;\n\t\t}\n\n\t\t// Shallow clone, because we'll be filtering the term's children and\n\t\t// don't want to modify the original term.\n\t\tconst term = { ...originalTerm };\n\n\t\t// Map and filter the children, recursive so we deal with grandchildren\n\t\t// and any deeper levels.\n\t\tif ( term.children.length > 0 ) {\n\t\t\tterm.children = term.children\n\t\t\t\t.map( matchTermsForFilter )\n\t\t\t\t.filter( ( child ) => child );\n\t\t}\n\n\t\t// If the term's name contains the filterValue, or it has children\n\t\t// (i.e. some child matched at some point in the tree) then return it.\n\t\tif (\n\t\t\t-1 !==\n\t\t\t\tnormalizeTextString( term.name ).indexOf(\n\t\t\t\t\tnormalizeTextString( filterValue )\n\t\t\t\t) ||\n\t\t\tterm.children.length > 0\n\t\t) {\n\t\t\treturn term;\n\t\t}\n\n\t\t// Otherwise, return false. After mapping, the list of terms will need\n\t\t// to have false values filtered out.\n\t\treturn false;\n\t};\n\treturn matchTermsForFilter;\n}\n\n/**\n * Hierarchical term selector.\n *\n * @param {Object} props Component props.\n * @param {string} props.slug Taxonomy slug.\n * @return {Element} Hierarchical term selector component.\n */\nexport function HierarchicalTermSelector( { slug } ) {\n\tconst [ adding, setAdding ] = useState( false );\n\tconst [ formName, setFormName ] = useState( '' );\n\t/**\n\t * @type {[number|'', Function]}\n\t */\n\tconst [ formParent, setFormParent ] = useState( '' );\n\tconst [ showForm, setShowForm ] = useState( false );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ filteredTermsTree, setFilteredTermsTree ] = useState( [] );\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\tconst {\n\t\thasCreateAction,\n\t\thasAssignAction,\n\t\tterms,\n\t\tloading,\n\t\tavailableTerms,\n\t\ttaxonomy,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPost, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { getEntityRecord, getEntityRecords, isResolving } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _taxonomy = getEntityRecord( 'root', 'taxonomy', slug );\n\t\t\tconst post = getCurrentPost();\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? !! post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ]\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? !! post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ]\n\t\t\t\t\t: false,\n\t\t\t\tterms: _taxonomy\n\t\t\t\t\t? getEditedPostAttribute( _taxonomy.rest_base )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\tloading: isResolving( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tDEFAULT_QUERY,\n\t\t\t\t] ),\n\t\t\t\tavailableTerms:\n\t\t\t\t\tgetEntityRecords( 'taxonomy', slug, DEFAULT_QUERY ) ||\n\t\t\t\t\tEMPTY_ARRAY,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t};\n\t\t},\n\t\t[ slug ]\n\t);\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst availableTermsTree = useMemo(\n\t\t() => sortBySelected( buildTermsTree( availableTerms ), terms ),\n\t\t// Remove `terms` from the dependency list to avoid reordering every time\n\t\t// checking or unchecking a term.\n\t\t[ availableTerms ]\n\t);\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Append new term.\n\t *\n\t * @param {Object} term Term object.\n\t * @return {Promise} A promise that resolves to save term object.\n\t */\n\tconst addTerm = ( term ) => {\n\t\treturn saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\t/**\n\t * Update terms for post.\n\t *\n\t * @param {number[]} termIds Term ids.\n\t */\n\tconst onUpdateTerms = ( termIds ) => {\n\t\teditPost( { [ taxonomy.rest_base ]: termIds } );\n\t};\n\n\t/**\n\t * Handler for checking term.\n\t *\n\t * @param {number} termId\n\t */\n\tconst onChange = ( termId ) => {\n\t\tconst hasTerm = terms.includes( termId );\n\t\tconst newTerms = hasTerm\n\t\t\t? terms.filter( ( id ) => id !== termId )\n\t\t\t: [ ...terms, termId ];\n\t\tonUpdateTerms( newTerms );\n\t};\n\n\tconst onChangeFormName = ( value ) => {\n\t\tsetFormName( value );\n\t};\n\n\t/**\n\t * Handler for changing form parent.\n\t *\n\t * @param {number|''} parentId Parent post id.\n\t */\n\tconst onChangeFormParent = ( parentId ) => {\n\t\tsetFormParent( parentId );\n\t};\n\n\tconst onToggleForm = () => {\n\t\tsetShowForm( ! showForm );\n\t};\n\n\tconst onAddTerm = async ( event ) => {\n\t\tevent.preventDefault();\n\t\tif ( formName === '' || adding ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if the term we are adding already exists.\n\t\tconst existingTerm = findTerm( availableTerms, formParent, formName );\n\t\tif ( existingTerm ) {\n\t\t\t// If the term we are adding exists but is not selected select it.\n\t\t\tif ( ! terms.some( ( term ) => term === existingTerm.id ) ) {\n\t\t\t\tonUpdateTerms( [ ...terms, existingTerm.id ] );\n\t\t\t}\n\n\t\t\tsetFormName( '' );\n\t\t\tsetFormParent( '' );\n\n\t\t\treturn;\n\t\t}\n\t\tsetAdding( true );\n\t\tlet newTerm;\n\t\ttry {\n\t\t\tnewTerm = await addTerm( {\n\t\t\t\tname: formName,\n\t\t\t\tparent: formParent ? formParent : undefined,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\t\tconst defaultName =\n\t\t\tslug === 'category' ? __( 'Category' ) : __( 'Term' );\n\t\tconst termAddedMessage = sprintf(\n\t\t\t/* translators: %s: term name. */\n\t\t\t_x( '%s added', 'term' ),\n\t\t\ttaxonomy?.labels?.singular_name ?? defaultName\n\t\t);\n\t\tspeak( termAddedMessage, 'assertive' );\n\t\tsetAdding( false );\n\t\tsetFormName( '' );\n\t\tsetFormParent( '' );\n\t\tonUpdateTerms( [ ...terms, newTerm.id ] );\n\t};\n\n\tconst setFilter = ( value ) => {\n\t\tconst newFilteredTermsTree = availableTermsTree\n\t\t\t.map( getFilterMatcher( value ) )\n\t\t\t.filter( ( term ) => term );\n\t\tconst getResultCount = ( termsTree ) => {\n\t\t\tlet count = 0;\n\t\t\tfor ( let i = 0; i < termsTree.length; i++ ) {\n\t\t\t\tcount++;\n\t\t\t\tif ( undefined !== termsTree[ i ].children ) {\n\t\t\t\t\tcount += getResultCount( termsTree[ i ].children );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn count;\n\t\t};\n\n\t\tsetFilterValue( value );\n\t\tsetFilteredTermsTree( newFilteredTermsTree );\n\n\t\tconst resultCount = getResultCount( newFilteredTermsTree );\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', resultCount ),\n\t\t\tresultCount\n\t\t);\n\n\t\tdebouncedSpeak( resultsFoundMessage, 'assertive' );\n\t};\n\n\tconst renderTerms = ( renderedTerms ) => {\n\t\treturn renderedTerms.map( ( term ) => {\n\t\t\treturn (\n\t\t\t\t<div\n\t\t\t\t\tkey={ term.id }\n\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-choice\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tchecked={ terms.indexOf( term.id ) !== -1 }\n\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\tconst termId = parseInt( term.id, 10 );\n\t\t\t\t\t\t\tonChange( termId );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ decodeEntities( term.name ) }\n\t\t\t\t\t/>\n\t\t\t\t\t{ !! term.children.length && (\n\t\t\t\t\t\t<div className=\"editor-post-taxonomies__hierarchical-terms-subchoices\">\n\t\t\t\t\t\t\t{ renderTerms( term.children ) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t);\n\t\t} );\n\t};\n\n\tconst labelWithFallback = (\n\t\tlabelProperty,\n\t\tfallbackIsCategory,\n\t\tfallbackIsNotCategory\n\t) =>\n\t\ttaxonomy?.labels?.[ labelProperty ] ??\n\t\t( slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory );\n\n\tconst newTermButtonLabel = labelWithFallback(\n\t\t'add_new_item',\n\t\t__( 'Add Category' ),\n\t\t__( 'Add Term' )\n\t);\n\tconst newTermLabel = labelWithFallback(\n\t\t'new_item_name',\n\t\t__( 'Add Category' ),\n\t\t__( 'Add Term' )\n\t);\n\tconst parentSelectLabel = labelWithFallback(\n\t\t'parent_item',\n\t\t__( 'Parent Category' ),\n\t\t__( 'Parent Term' )\n\t);\n\tconst noParentOption = `— ${ parentSelectLabel } —`;\n\tconst newTermSubmitLabel = newTermButtonLabel;\n\tconst filterLabel = taxonomy?.labels?.search_items ?? __( 'Search Terms' );\n\tconst groupLabel = taxonomy?.name ?? __( 'Terms' );\n\tconst showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;\n\n\treturn (\n\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t{ showFilter && ! loading && (\n\t\t\t\t<SearchControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ filterLabel }\n\t\t\t\t\tplaceholder={ filterLabel }\n\t\t\t\t\tvalue={ filterValue }\n\t\t\t\t\tonChange={ setFilter }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ loading && (\n\t\t\t\t<Flex\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t// Match SearchControl height to prevent layout shift.\n\t\t\t\t\t\theight: '40px',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Flex>\n\t\t\t) }\n\t\t\t<div\n\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-list\"\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"group\"\n\t\t\t\taria-label={ groupLabel }\n\t\t\t>\n\t\t\t\t{ renderTerms(\n\t\t\t\t\t'' !== filterValue ? filteredTermsTree : availableTermsTree\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t{ ! loading && hasCreateAction && (\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tonClick={ onToggleForm }\n\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-add\"\n\t\t\t\t\t\taria-expanded={ showForm }\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ newTermButtonLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</FlexItem>\n\t\t\t) }\n\t\t\t{ showForm && (\n\t\t\t\t<form onSubmit={ onAddTerm }>\n\t\t\t\t\t<Flex direction=\"column\" gap=\"4\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-input\"\n\t\t\t\t\t\t\tlabel={ newTermLabel }\n\t\t\t\t\t\t\tvalue={ formName }\n\t\t\t\t\t\t\tonChange={ onChangeFormName }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ !! availableTerms.length && (\n\t\t\t\t\t\t\t<TreeSelect\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ parentSelectLabel }\n\t\t\t\t\t\t\t\tnoOptionLabel={ noParentOption }\n\t\t\t\t\t\t\t\tonChange={ onChangeFormParent }\n\t\t\t\t\t\t\t\tselectedId={ formParent }\n\t\t\t\t\t\t\t\ttree={ availableTermsTree }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\tclassName=\"editor-post-taxonomies__hierarchical-terms-submit\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ newTermSubmitLabel }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t</Flex>\n\t\t\t\t</form>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\nexport default withFilters( 'editor.PostTaxonomyType' )(\n\tHierarchicalTermSelector\n);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAoC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qB;AAAA,UACrB,OAAQ;AAAA,UACR,eAAgB;AAAA,UAChB,UAAW;AAAA,UACX,YAAa;AAAA,UACb,MAAO;AAAA;AAAA,MACR;AAAA,MAED,4CAAC,8BACA;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,WAAU;AAAA,UAER;AAAA;AAAA,MACH,GACD;AAAA,OACD,GACD;AAAA,KAEF;AAEF;AAEA,IAAO,yCAAQ,+BAAa,yBAA0B;AAAA,EACrD;AACD;",
6
6
  "names": ["componentsPrivateApis", "coreDataPrivateApis", "editorStore", "coreStore", "noticesStore"]
7
7
  }
@@ -34,15 +34,20 @@ __export(post_text_editor_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(post_text_editor_exports);
36
36
  var import_react_autosize_textarea = __toESM(require("react-autosize-textarea"));
37
+ var import_element = require("@wordpress/element");
37
38
  var import_i18n = require("@wordpress/i18n");
38
39
  var import_core_data = require("@wordpress/core-data");
39
40
  var import_data = require("@wordpress/data");
40
41
  var import_compose = require("@wordpress/compose");
41
42
  var import_ui = require("@wordpress/ui");
42
43
  var import_store = require("../../store/index.cjs");
44
+ var import_utils = require("./utils.cjs");
43
45
  var import_jsx_runtime = require("react/jsx-runtime");
44
46
  function PostTextEditor() {
45
47
  const instanceId = (0, import_compose.useInstanceId)(PostTextEditor);
48
+ const textareaRef = (0, import_element.useRef)();
49
+ const previousValueRef = (0, import_element.useRef)();
50
+ const selectionRef = (0, import_element.useRef)();
46
51
  const { value, type, id } = (0, import_data.useSelect)((select) => {
47
52
  const { getCurrentPostType, getCurrentPostId, getEditedPostContent } = select(import_store.store);
48
53
  return {
@@ -52,6 +57,46 @@ function PostTextEditor() {
52
57
  };
53
58
  }, []);
54
59
  const { editEntityRecord } = (0, import_data.useDispatch)(import_core_data.store);
60
+ (0, import_element.useLayoutEffect)(() => {
61
+ const textarea = textareaRef.current;
62
+ const previousValue = previousValueRef.current;
63
+ previousValueRef.current = value;
64
+ if (!textarea || previousValue === void 0 || previousValue === value || !selectionRef.current) {
65
+ return;
66
+ }
67
+ const { selectionStart, selectionEnd, selectionDirection } = selectionRef.current;
68
+ const changes = (0, import_utils.getDiff)(previousValue, value);
69
+ const adjustedSelectionStart = (0, import_utils.adjustPosition)(
70
+ selectionStart,
71
+ changes,
72
+ previousValue,
73
+ value
74
+ );
75
+ const adjustedSelectionEnd = (0, import_utils.adjustPosition)(
76
+ selectionEnd,
77
+ changes,
78
+ previousValue,
79
+ value
80
+ );
81
+ textarea.setSelectionRange(
82
+ adjustedSelectionStart,
83
+ adjustedSelectionEnd,
84
+ selectionDirection
85
+ );
86
+ selectionRef.current = {
87
+ selectionStart: adjustedSelectionStart,
88
+ selectionEnd: adjustedSelectionEnd,
89
+ selectionDirection
90
+ };
91
+ }, [value]);
92
+ const updateSelection = (event) => {
93
+ const { selectionStart, selectionEnd, selectionDirection } = event.target;
94
+ selectionRef.current = {
95
+ selectionStart,
96
+ selectionEnd,
97
+ selectionDirection
98
+ };
99
+ };
55
100
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
56
101
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
57
102
  import_ui.VisuallyHidden,
@@ -65,14 +110,20 @@ function PostTextEditor() {
65
110
  {
66
111
  autoComplete: "off",
67
112
  dir: "auto",
113
+ ref: textareaRef,
68
114
  value,
69
115
  onChange: (event) => {
116
+ updateSelection(event);
117
+ previousValueRef.current = event.target.value;
70
118
  editEntityRecord("postType", type, id, {
71
119
  content: event.target.value,
72
120
  blocks: void 0,
73
121
  selection: void 0
74
122
  });
75
123
  },
124
+ onFocus: updateSelection,
125
+ onMouseUp: updateSelection,
126
+ onKeyUp: updateSelection,
76
127
  className: "editor-post-text-editor",
77
128
  id: `post-content-${instanceId}`,
78
129
  placeholder: (0, import_i18n.__)("Start writing with text or HTML")
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/post-text-editor/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Displays the Post Text Editor along with content in Visual and Text mode.\n *\n * @return {React.ReactNode} The rendered PostTextEditor component.\n */\nexport default function PostTextEditor() {\n\tconst instanceId = useInstanceId( PostTextEditor );\n\tconst { value, type, id } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId, getEditedPostContent } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tvalue: getEditedPostContent(),\n\t\t\ttype: getCurrentPostType(),\n\t\t\tid: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\t// eslint-disable-next-line jsx-a11y/label-has-associated-control\n\t\t\t\trender={ <label htmlFor={ `post-content-${ instanceId }` } /> }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\teditEntityRecord( 'postType', type, id, {\n\t\t\t\t\t\tcontent: event.target.value,\n\t\t\t\t\t\tblocks: undefined,\n\t\t\t\t\t\tselection: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qCAAqB;AAKrB,kBAAmB;AACnB,uBAAmC;AACnC,kBAAuC;AACvC,qBAA8B;AAC9B,gBAA+B;AAK/B,mBAAqC;AAqBnC;AAda,SAAR,iBAAkC;AACxC,QAAM,iBAAa,8BAAe,cAAe;AACjD,QAAM,EAAE,OAAO,MAAM,GAAG,QAAI,uBAAW,CAAE,WAAY;AACpD,UAAM,EAAE,oBAAoB,kBAAkB,qBAAqB,IAClE,OAAQ,aAAAA,KAAY;AACrB,WAAO;AAAA,MACN,OAAO,qBAAqB;AAAA,MAC5B,MAAM,mBAAmB;AAAA,MACzB,IAAI,iBAAiB;AAAA,IACtB;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,iBAAiB,QAAI,yBAAa,iBAAAC,KAAU;AAEpD,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QAEA,QAAS,4CAAC,WAAM,SAAU,gBAAiB,UAAW,IAAK;AAAA,QAEzD,8BAAI,mBAAoB;AAAA;AAAA,IAC3B;AAAA,IACA;AAAA,MAAC,+BAAAC;AAAA,MAAA;AAAA,QACA,cAAa;AAAA,QACb,KAAI;AAAA,QACJ;AAAA,QACA,UAAW,CAAE,UAAW;AACvB,2BAAkB,YAAY,MAAM,IAAI;AAAA,YACvC,SAAS,MAAM,OAAO;AAAA,YACtB,QAAQ;AAAA,YACR,WAAW;AAAA,UACZ,CAAE;AAAA,QACH;AAAA,QACA,WAAU;AAAA,QACV,IAAK,gBAAiB,UAAW;AAAA,QACjC,iBAAc,gBAAI,iCAAkC;AAAA;AAAA,IACrD;AAAA,KACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { adjustPosition, getDiff } from './utils';\n\n/**\n * Displays the Post Text Editor along with content in Visual and Text mode.\n *\n * @return {React.ReactNode} The rendered PostTextEditor component.\n */\nexport default function PostTextEditor() {\n\tconst instanceId = useInstanceId( PostTextEditor );\n\tconst textareaRef = useRef();\n\tconst previousValueRef = useRef();\n\tconst selectionRef = useRef();\n\tconst { value, type, id } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId, getEditedPostContent } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tvalue: getEditedPostContent(),\n\t\t\ttype: getCurrentPostType(),\n\t\t\tid: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tuseLayoutEffect( () => {\n\t\tconst textarea = textareaRef.current;\n\t\tconst previousValue = previousValueRef.current;\n\t\tpreviousValueRef.current = value;\n\n\t\tif (\n\t\t\t! textarea ||\n\t\t\tpreviousValue === undefined ||\n\t\t\tpreviousValue === value ||\n\t\t\t! selectionRef.current\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { selectionStart, selectionEnd, selectionDirection } =\n\t\t\tselectionRef.current;\n\t\tconst changes = getDiff( previousValue, value );\n\t\tconst adjustedSelectionStart = adjustPosition(\n\t\t\tselectionStart,\n\t\t\tchanges,\n\t\t\tpreviousValue,\n\t\t\tvalue\n\t\t);\n\t\tconst adjustedSelectionEnd = adjustPosition(\n\t\t\tselectionEnd,\n\t\t\tchanges,\n\t\t\tpreviousValue,\n\t\t\tvalue\n\t\t);\n\n\t\ttextarea.setSelectionRange(\n\t\t\tadjustedSelectionStart,\n\t\t\tadjustedSelectionEnd,\n\t\t\tselectionDirection\n\t\t);\n\t\tselectionRef.current = {\n\t\t\tselectionStart: adjustedSelectionStart,\n\t\t\tselectionEnd: adjustedSelectionEnd,\n\t\t\tselectionDirection,\n\t\t};\n\t}, [ value ] );\n\n\tconst updateSelection = ( event ) => {\n\t\tconst { selectionStart, selectionEnd, selectionDirection } =\n\t\t\tevent.target;\n\t\tselectionRef.current = {\n\t\t\tselectionStart,\n\t\t\tselectionEnd,\n\t\t\tselectionDirection,\n\t\t};\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\t// eslint-disable-next-line jsx-a11y/label-has-associated-control\n\t\t\t\trender={ <label htmlFor={ `post-content-${ instanceId }` } /> }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tref={ textareaRef }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\tupdateSelection( event );\n\t\t\t\t\tpreviousValueRef.current = event.target.value;\n\t\t\t\t\teditEntityRecord( 'postType', type, id, {\n\t\t\t\t\t\tcontent: event.target.value,\n\t\t\t\t\t\tblocks: undefined,\n\t\t\t\t\t\tselection: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tonFocus={ updateSelection }\n\t\t\t\t// A click or arrow-key caret move does not fire `select` (only\n\t\t\t\t// range selections do), so track those moves via mouseup/keyup.\n\t\t\t\tonMouseUp={ updateSelection }\n\t\t\t\tonKeyUp={ updateSelection }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qCAAqB;AAKrB,qBAAwC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ACxD,MAAM;AACP,iBAAa,UAAU;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QAEA,QAAS,4CAAC,WAAM,SAAU,gBAAiB,UAAW,IAAK;AAAA,QAEzD,8BAAI,mBAAoB;AAAA;AAAA,IAC3B;AAAA,IACA;AAAA,MAAC,+BAAAC;AAAA,MAAA;AAAA,QACA,cAAa;AAAA,QACb,KAAI;AAAA,QACJ,KAAM;AAAA,QACN;AAAA,QACA,UAAW,CAAE,UAAW;AACvB,0BAAiB,KAAM;AACvB,2BAAiB,UAAU,MAAM,OAAO;AACxC,2BAAkB,YAAY,MAAM,IAAI;AAAA,YACvC,SAAS,MAAM,OAAO;AAAA,YACtB,QAAQ;AAAA,YACR,WAAW;AAAA,UACZ,CAAE;AAAA,QACH;AAAA,QACA,SAAU;AAAA,QAGV,WAAY;AAAA,QACZ,SAAU;AAAA,QACV,WAAU;AAAA,QACV,IAAK,gBAAiB,UAAW;AAAA,QACjC,iBAAc,gBAAI,iCAAkC;AAAA;AAAA,IACrD;AAAA,KACD;AAEF;",
6
6
  "names": ["editorStore", "coreStore", "Textarea"]
7
7
  }
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/editor/src/components/post-text-editor/utils.js
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ adjustPosition: () => adjustPosition,
24
+ getAdjustedCursorPosition: () => getAdjustedCursorPosition,
25
+ getDiff: () => getDiff
26
+ });
27
+ module.exports = __toCommonJS(utils_exports);
28
+ var import_character = require("diff/lib/diff/character");
29
+ var import_line = require("diff/lib/diff/line");
30
+ var STRING_TOO_LARGE_THRESHOLD = 1e3;
31
+ function getDiff(oldValue, newValue) {
32
+ const maxStringLength = Math.max(oldValue.length, newValue.length);
33
+ if (maxStringLength <= STRING_TOO_LARGE_THRESHOLD) {
34
+ return (0, import_character.diffChars)(oldValue, newValue);
35
+ }
36
+ let start = 0;
37
+ const minStringLength = Math.min(oldValue.length, newValue.length);
38
+ while (start < minStringLength && oldValue[start] === newValue[start]) {
39
+ start++;
40
+ }
41
+ let oldEnd = oldValue.length;
42
+ let newEnd = newValue.length;
43
+ while (oldEnd > start && newEnd > start && oldValue[oldEnd - 1] === newValue[newEnd - 1]) {
44
+ oldEnd--;
45
+ newEnd--;
46
+ }
47
+ const oldChangedValue = oldValue.slice(start, oldEnd);
48
+ const newChangedValue = newValue.slice(start, newEnd);
49
+ const maxChangedStringLength = Math.max(
50
+ oldChangedValue.length,
51
+ newChangedValue.length
52
+ );
53
+ let changes;
54
+ if (maxChangedStringLength <= STRING_TOO_LARGE_THRESHOLD) {
55
+ changes = (0, import_character.diffChars)(oldChangedValue, newChangedValue);
56
+ } else {
57
+ changes = (0, import_line.diffLines)(oldChangedValue, newChangedValue);
58
+ }
59
+ if (start > 0) {
60
+ changes.unshift({ value: oldValue.slice(0, start) });
61
+ }
62
+ if (oldEnd < oldValue.length) {
63
+ changes.push({ value: oldValue.slice(oldEnd) });
64
+ }
65
+ return changes;
66
+ }
67
+ function clampCursorPosition(position, value) {
68
+ return Math.max(0, Math.min(value.length, position));
69
+ }
70
+ function getCursorOffsetFromCommonTextBeforeCursor(oldValue, newValue, position) {
71
+ const oldValueBeforeCursor = oldValue.slice(0, position);
72
+ let low = 1;
73
+ let high = oldValueBeforeCursor.length;
74
+ let cursorOffset;
75
+ while (low <= high) {
76
+ const length = Math.floor((low + high) / 2);
77
+ const index = newValue.indexOf(
78
+ oldValueBeforeCursor.slice(oldValueBeforeCursor.length - length)
79
+ );
80
+ if (index === -1) {
81
+ high = length - 1;
82
+ } else {
83
+ cursorOffset = index + length;
84
+ low = length + 1;
85
+ }
86
+ }
87
+ return cursorOffset;
88
+ }
89
+ function adjustPosition(position, changes, oldValue, newValue) {
90
+ let oldIndex = 0;
91
+ let newIndex = 0;
92
+ let adjustedPosition = position;
93
+ for (let i = 0; i < changes.length; i++) {
94
+ const change = changes[i];
95
+ if (!change.added && !change.removed) {
96
+ oldIndex += change.value.length;
97
+ newIndex += change.value.length;
98
+ continue;
99
+ }
100
+ const oldStart = oldIndex;
101
+ const newStart = newIndex;
102
+ let oldLength = 0;
103
+ let newLength = 0;
104
+ while (i < changes.length && (changes[i].added || changes[i].removed)) {
105
+ if (changes[i].removed) {
106
+ oldLength += changes[i].value.length;
107
+ } else {
108
+ newLength += changes[i].value.length;
109
+ }
110
+ i++;
111
+ }
112
+ i--;
113
+ const oldEnd = oldStart + oldLength;
114
+ const newEnd = newStart + newLength;
115
+ if (position < oldStart) {
116
+ break;
117
+ }
118
+ if (oldLength === 0) {
119
+ adjustedPosition += newLength;
120
+ } else if (position <= oldEnd) {
121
+ const cursorOffset = getCursorOffsetFromCommonTextBeforeCursor(
122
+ oldValue.slice(oldStart, oldEnd),
123
+ newValue.slice(newStart, newEnd),
124
+ position - oldStart
125
+ );
126
+ adjustedPosition = cursorOffset === void 0 ? newEnd : newStart + cursorOffset;
127
+ break;
128
+ } else {
129
+ adjustedPosition += newLength - oldLength;
130
+ }
131
+ oldIndex += oldLength;
132
+ newIndex += newLength;
133
+ }
134
+ return clampCursorPosition(adjustedPosition, newValue);
135
+ }
136
+ function getAdjustedCursorPosition(position, oldValue, newValue) {
137
+ return adjustPosition(
138
+ position,
139
+ getDiff(oldValue, newValue),
140
+ oldValue,
141
+ newValue
142
+ );
143
+ }
144
+ // Annotate the CommonJS export names for ESM import in node:
145
+ 0 && (module.exports = {
146
+ adjustPosition,
147
+ getAdjustedCursorPosition,
148
+ getDiff
149
+ });
150
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/post-text-editor/utils.js"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { diffChars } from 'diff/lib/diff/character';\nimport { diffLines } from 'diff/lib/diff/line';\n\n// Character diffing (Myers) is cheap when the edit distance is small but\n// degrades toward O(n^2) as the two strings diverge: a full replacement of\n// ~10k differing chars blocks the main thread for seconds. Cap the input handed\n// to diffChars so the worst case stays small (~100ms); larger windows fall back\n// to a line diff, with the cursor remapped by getCursorOffsetFromCommonText...\nconst STRING_TOO_LARGE_THRESHOLD = 1000;\n\n/**\n * Diffs two strings into a list of `{ value, added?, removed? }` change parts.\n *\n * @param {string} oldValue The previous string.\n * @param {string} newValue The next string.\n * @return {Array<Object>} The diff change parts.\n */\nexport function getDiff( oldValue, newValue ) {\n\tconst maxStringLength = Math.max( oldValue.length, newValue.length );\n\n\tif ( maxStringLength <= STRING_TOO_LARGE_THRESHOLD ) {\n\t\treturn diffChars( oldValue, newValue );\n\t}\n\n\tlet start = 0;\n\tconst minStringLength = Math.min( oldValue.length, newValue.length );\n\n\twhile (\n\t\tstart < minStringLength &&\n\t\toldValue[ start ] === newValue[ start ]\n\t) {\n\t\tstart++;\n\t}\n\n\tlet oldEnd = oldValue.length;\n\tlet newEnd = newValue.length;\n\n\twhile (\n\t\toldEnd > start &&\n\t\tnewEnd > start &&\n\t\toldValue[ oldEnd - 1 ] === newValue[ newEnd - 1 ]\n\t) {\n\t\toldEnd--;\n\t\tnewEnd--;\n\t}\n\n\tconst oldChangedValue = oldValue.slice( start, oldEnd );\n\tconst newChangedValue = newValue.slice( start, newEnd );\n\tconst maxChangedStringLength = Math.max(\n\t\toldChangedValue.length,\n\t\tnewChangedValue.length\n\t);\n\tlet changes;\n\n\tif ( maxChangedStringLength <= STRING_TOO_LARGE_THRESHOLD ) {\n\t\tchanges = diffChars( oldChangedValue, newChangedValue );\n\t} else {\n\t\tchanges = diffLines( oldChangedValue, newChangedValue );\n\t}\n\n\tif ( start > 0 ) {\n\t\tchanges.unshift( { value: oldValue.slice( 0, start ) } );\n\t}\n\n\tif ( oldEnd < oldValue.length ) {\n\t\tchanges.push( { value: oldValue.slice( oldEnd ) } );\n\t}\n\n\treturn changes;\n}\n\nfunction clampCursorPosition( position, value ) {\n\treturn Math.max( 0, Math.min( value.length, position ) );\n}\n\n// A coarse (line-level) diff reports a whole changed region as one replacement,\n// which would otherwise snap the cursor to the region's end. Recover a precise\n// position by finding the longest run of text ending at the cursor that is\n// preserved in the replacement, then placing the cursor just past where that\n// run starts in the new text. This uses indexOf (near-linear in V8) rather than\n// a character diff, so it stays cheap even across a large single-line region.\nfunction getCursorOffsetFromCommonTextBeforeCursor(\n\toldValue,\n\tnewValue,\n\tposition\n) {\n\tconst oldValueBeforeCursor = oldValue.slice( 0, position );\n\tlet low = 1;\n\tlet high = oldValueBeforeCursor.length;\n\tlet cursorOffset;\n\n\twhile ( low <= high ) {\n\t\tconst length = Math.floor( ( low + high ) / 2 );\n\t\tconst index = newValue.indexOf(\n\t\t\toldValueBeforeCursor.slice( oldValueBeforeCursor.length - length )\n\t\t);\n\n\t\tif ( index === -1 ) {\n\t\t\thigh = length - 1;\n\t\t} else {\n\t\t\tcursorOffset = index + length;\n\t\t\tlow = length + 1;\n\t\t}\n\t}\n\n\treturn cursorOffset;\n}\n\n/**\n * Maps a cursor position from the old string to the new string given a diff.\n *\n * @param {number} position The cursor position in the old string.\n * @param {Array<Object>} changes The diff returned by `getDiff`.\n * @param {string} oldValue The previous string.\n * @param {string} newValue The next string.\n * @return {number} The adjusted cursor position in the new string.\n */\nexport function adjustPosition( position, changes, oldValue, newValue ) {\n\tlet oldIndex = 0;\n\tlet newIndex = 0;\n\tlet adjustedPosition = position;\n\n\tfor ( let i = 0; i < changes.length; i++ ) {\n\t\tconst change = changes[ i ];\n\t\tif ( ! change.added && ! change.removed ) {\n\t\t\toldIndex += change.value.length;\n\t\t\tnewIndex += change.value.length;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst oldStart = oldIndex;\n\t\tconst newStart = newIndex;\n\t\tlet oldLength = 0;\n\t\tlet newLength = 0;\n\n\t\twhile (\n\t\t\ti < changes.length &&\n\t\t\t( changes[ i ].added || changes[ i ].removed )\n\t\t) {\n\t\t\tif ( changes[ i ].removed ) {\n\t\t\t\toldLength += changes[ i ].value.length;\n\t\t\t} else {\n\t\t\t\tnewLength += changes[ i ].value.length;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\ti--;\n\n\t\tconst oldEnd = oldStart + oldLength;\n\t\tconst newEnd = newStart + newLength;\n\n\t\tif ( position < oldStart ) {\n\t\t\t// The cursor is before this change, so nothing here can move it.\n\t\t\tbreak;\n\t\t}\n\n\t\tif ( oldLength === 0 ) {\n\t\t\t// Pure insertion at or before the cursor: shift it right by the\n\t\t\t// inserted length.\n\t\t\tadjustedPosition += newLength;\n\t\t} else if ( position <= oldEnd ) {\n\t\t\t// The cursor falls inside a replaced region; recover its precise\n\t\t\t// spot from the text preserved around it.\n\t\t\tconst cursorOffset = getCursorOffsetFromCommonTextBeforeCursor(\n\t\t\t\toldValue.slice( oldStart, oldEnd ),\n\t\t\t\tnewValue.slice( newStart, newEnd ),\n\t\t\t\tposition - oldStart\n\t\t\t);\n\n\t\t\tadjustedPosition =\n\t\t\t\tcursorOffset === undefined ? newEnd : newStart + cursorOffset;\n\t\t\tbreak;\n\t\t} else {\n\t\t\t// The cursor is after this change: shift it by the net length delta.\n\t\t\tadjustedPosition += newLength - oldLength;\n\t\t}\n\n\t\toldIndex += oldLength;\n\t\tnewIndex += newLength;\n\t}\n\n\treturn clampCursorPosition( adjustedPosition, newValue );\n}\n\n/**\n * Diffs `oldValue` against `newValue` and maps a cursor `position` from the old\n * string to the new one.\n *\n * @param {number} position The cursor position in the old string.\n * @param {string} oldValue The previous string.\n * @param {string} newValue The next string.\n * @return {number} The adjusted cursor position in the new string.\n */\nexport function getAdjustedCursorPosition( position, oldValue, newValue ) {\n\treturn adjustPosition(\n\t\tposition,\n\t\tgetDiff( oldValue, newValue ),\n\t\toldValue,\n\t\tnewValue\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAA0B;AAC1B,kBAA0B;AAO1B,IAAM,6BAA6B;AAS5B,SAAS,QAAS,UAAU,UAAW;AAC7C,QAAM,kBAAkB,KAAK,IAAK,SAAS,QAAQ,SAAS,MAAO;AAEnE,MAAK,mBAAmB,4BAA6B;AACpD,eAAO,4BAAW,UAAU,QAAS;AAAA,EACtC;AAEA,MAAI,QAAQ;AACZ,QAAM,kBAAkB,KAAK,IAAK,SAAS,QAAQ,SAAS,MAAO;AAEnE,SACC,QAAQ,mBACR,SAAU,KAAM,MAAM,SAAU,KAAM,GACrC;AACD;AAAA,EACD;AAEA,MAAI,SAAS,SAAS;AACtB,MAAI,SAAS,SAAS;AAEtB,SACC,SAAS,SACT,SAAS,SACT,SAAU,SAAS,CAAE,MAAM,SAAU,SAAS,CAAE,GAC/C;AACD;AACA;AAAA,EACD;AAEA,QAAM,kBAAkB,SAAS,MAAO,OAAO,MAAO;AACtD,QAAM,kBAAkB,SAAS,MAAO,OAAO,MAAO;AACtD,QAAM,yBAAyB,KAAK;AAAA,IACnC,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,EACjB;AACA,MAAI;AAEJ,MAAK,0BAA0B,4BAA6B;AAC3D,kBAAU,4BAAW,iBAAiB,eAAgB;AAAA,EACvD,OAAO;AACN,kBAAU,uBAAW,iBAAi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AACD,UAAK,QAAS,CAAE,EAAE,SAAU;AAC3B,qBAAa,QAAS,CAAE,EAAE,MAAM;AAAA,MACjC,OAAO;AACN,qBAAa,QAAS,CAAE,EAAE,MAAM;AAAA,MACjC;AACA;AAAA,IACD;AACA;AAEA,UAAM,SAAS,WAAW;AAC1B,UAAM,SAAS,WAAW;AAE1B,QAAK,WAAW,UAAW;AAE1B;AAAA,IACD;AAEA,QAAK,cAAc,GAAI;AAGtB,0BAAoB;AAAA,IACrB,WAAY,YAAY,QAAS;AAGhC,YAAM,eAAe;AAAA,QACpB,SAAS,MAAO,UAAU,MAAO;AAAA,QACjC,SAAS,MAAO,UAAU,MAAO;AAAA,QACjC,WAAW;AAAA,MACZ;AAEA,yBACC,iBAAiB,SAAY,SAAS,WAAW;AAClD;AAAA,IACD,OAAO;AAEN,0BAAoB,YAAY;AAAA,IACjC;AAEA,gBAAY;AACZ,gBAAY;AAAA,EACb;AAEA,SAAO,oBAAqB,kBAAkB,QAAS;AACxD;AAWO,SAAS,0BAA2B,UAAU,UAAU,UAAW;AACzE,SAAO;AAAA,IACN;AAAA,IACA,QAAS,UAAU,QAAS;AAAA,IAC5B;AAAA,IACA;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -54,7 +54,7 @@ function PostURL({ onClose }) {
54
54
  postSlug: (0, import_url.safeDecodeURIComponent)(
55
55
  select(import_store.store).getEditedPostSlug()
56
56
  ),
57
- viewPostLabel: postType?.labels.view_item,
57
+ viewPostLabel: postType?.labels?.view_item,
58
58
  postLink: post.link,
59
59
  permalinkPrefix: permalinkParts?.prefix,
60
60
  permalinkSuffix: permalinkParts?.suffix,