@strapi/content-manager 5.59.0 → 5.61.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 (300) hide show
  1. package/dist/admin/constants/customOrder.js +14 -0
  2. package/dist/admin/constants/customOrder.js.map +1 -0
  3. package/dist/admin/constants/customOrder.mjs +10 -0
  4. package/dist/admin/constants/customOrder.mjs.map +1 -0
  5. package/dist/admin/history/components/VersionInputRenderer.js +2 -1
  6. package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
  7. package/dist/admin/history/components/VersionInputRenderer.mjs +2 -1
  8. package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
  9. package/dist/admin/hooks/useDocument.js +22 -11
  10. package/dist/admin/hooks/useDocument.js.map +1 -1
  11. package/dist/admin/hooks/useDocument.mjs +22 -11
  12. package/dist/admin/hooks/useDocument.mjs.map +1 -1
  13. package/dist/admin/hooks/useDocumentLayout.js.map +1 -1
  14. package/dist/admin/hooks/useDocumentLayout.mjs.map +1 -1
  15. package/dist/admin/hooks/useHasBeenNearViewport.js +70 -0
  16. package/dist/admin/hooks/useHasBeenNearViewport.js.map +1 -0
  17. package/dist/admin/hooks/useHasBeenNearViewport.mjs +46 -0
  18. package/dist/admin/hooks/useHasBeenNearViewport.mjs.map +1 -0
  19. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js +102 -32
  20. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs +104 -35
  22. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +20 -17
  24. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +20 -17
  26. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +15 -1
  28. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +17 -3
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js +21 -0
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs +22 -1
  34. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +1 -0
  36. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +1 -0
  38. package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +1 -0
  40. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +1 -0
  42. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +2 -0
  44. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +2 -0
  46. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +4 -7
  48. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +4 -7
  50. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  51. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +46 -10
  52. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  53. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +47 -11
  54. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  55. package/dist/admin/pages/EditView/components/FormLayout.js +201 -50
  56. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  57. package/dist/admin/pages/EditView/components/FormLayout.mjs +202 -52
  58. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  59. package/dist/admin/pages/EditView/components/InputRenderer.js +3 -1
  60. package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
  61. package/dist/admin/pages/EditView/components/InputRenderer.mjs +3 -1
  62. package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
  63. package/dist/admin/pages/ListConfiguration/components/Settings.js +31 -2
  64. package/dist/admin/pages/ListConfiguration/components/Settings.js.map +1 -1
  65. package/dist/admin/pages/ListConfiguration/components/Settings.mjs +31 -2
  66. package/dist/admin/pages/ListConfiguration/components/Settings.mjs.map +1 -1
  67. package/dist/admin/pages/ListView/ListViewPage.js +196 -132
  68. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  69. package/dist/admin/pages/ListView/ListViewPage.mjs +196 -132
  70. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  71. package/dist/admin/pages/ListView/components/CustomOrder.js +571 -0
  72. package/dist/admin/pages/ListView/components/CustomOrder.js.map +1 -0
  73. package/dist/admin/pages/ListView/components/CustomOrder.mjs +546 -0
  74. package/dist/admin/pages/ListView/components/CustomOrder.mjs.map +1 -0
  75. package/dist/admin/pages/ListView/components/TableActions.js +4 -1
  76. package/dist/admin/pages/ListView/components/TableActions.js.map +1 -1
  77. package/dist/admin/pages/ListView/components/TableActions.mjs +4 -1
  78. package/dist/admin/pages/ListView/components/TableActions.mjs.map +1 -1
  79. package/dist/admin/preview/components/PreviewSidePanel.js +2 -1
  80. package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
  81. package/dist/admin/preview/components/PreviewSidePanel.mjs +2 -1
  82. package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
  83. package/dist/admin/preview/utils/getPreviewUrlStatus.js +17 -0
  84. package/dist/admin/preview/utils/getPreviewUrlStatus.js.map +1 -0
  85. package/dist/admin/preview/utils/getPreviewUrlStatus.mjs +15 -0
  86. package/dist/admin/preview/utils/getPreviewUrlStatus.mjs.map +1 -0
  87. package/dist/admin/services/documents.js +22 -1
  88. package/dist/admin/services/documents.js.map +1 -1
  89. package/dist/admin/services/documents.mjs +21 -2
  90. package/dist/admin/services/documents.mjs.map +1 -1
  91. package/dist/admin/src/constants/customOrder.d.ts +8 -0
  92. package/dist/admin/src/exports.d.ts +1 -1
  93. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +3 -1
  94. package/dist/admin/src/hooks/useDocument.d.ts +4 -0
  95. package/dist/admin/src/hooks/useDocumentLayout.d.ts +6 -2
  96. package/dist/admin/src/hooks/useHasBeenNearViewport.d.ts +13 -0
  97. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.d.ts +13 -1
  98. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +11 -1
  99. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -0
  100. package/dist/admin/src/pages/ListView/components/CustomOrder.d.ts +72 -0
  101. package/dist/admin/src/preview/utils/getPreviewUrlStatus.d.ts +6 -0
  102. package/dist/admin/src/services/documents.d.ts +10 -2
  103. package/dist/admin/translations/en.json.js +9 -0
  104. package/dist/admin/translations/en.json.js.map +1 -1
  105. package/dist/admin/translations/en.json.mjs +9 -0
  106. package/dist/admin/translations/en.json.mjs.map +1 -1
  107. package/dist/server/audit-logs.js +36 -0
  108. package/dist/server/audit-logs.js.map +1 -0
  109. package/dist/server/audit-logs.mjs +33 -0
  110. package/dist/server/audit-logs.mjs.map +1 -0
  111. package/dist/server/bootstrap.js +8 -0
  112. package/dist/server/bootstrap.js.map +1 -1
  113. package/dist/server/bootstrap.mjs +8 -0
  114. package/dist/server/bootstrap.mjs.map +1 -1
  115. package/dist/server/controllers/collection-types.js +8 -0
  116. package/dist/server/controllers/collection-types.js.map +1 -1
  117. package/dist/server/controllers/collection-types.mjs +8 -0
  118. package/dist/server/controllers/collection-types.mjs.map +1 -1
  119. package/dist/server/controllers/content-types.js +15 -0
  120. package/dist/server/controllers/content-types.js.map +1 -1
  121. package/dist/server/controllers/content-types.mjs +16 -1
  122. package/dist/server/controllers/content-types.mjs.map +1 -1
  123. package/dist/server/controllers/index.js +3 -1
  124. package/dist/server/controllers/index.js.map +1 -1
  125. package/dist/server/controllers/index.mjs +2 -0
  126. package/dist/server/controllers/index.mjs.map +1 -1
  127. package/dist/server/controllers/relations.js +53 -17
  128. package/dist/server/controllers/relations.js.map +1 -1
  129. package/dist/server/controllers/relations.mjs +54 -18
  130. package/dist/server/controllers/relations.mjs.map +1 -1
  131. package/dist/server/controllers/single-types.js +10 -1
  132. package/dist/server/controllers/single-types.js.map +1 -1
  133. package/dist/server/controllers/single-types.mjs +10 -1
  134. package/dist/server/controllers/single-types.mjs.map +1 -1
  135. package/dist/server/controllers/validation/model-configuration.js +2 -1
  136. package/dist/server/controllers/validation/model-configuration.js.map +1 -1
  137. package/dist/server/controllers/validation/model-configuration.mjs +2 -1
  138. package/dist/server/controllers/validation/model-configuration.mjs.map +1 -1
  139. package/dist/server/custom-order/constants.js +21 -0
  140. package/dist/server/custom-order/constants.js.map +1 -0
  141. package/dist/server/custom-order/constants.mjs +17 -0
  142. package/dist/server/custom-order/constants.mjs.map +1 -0
  143. package/dist/server/custom-order/controllers/custom-order.js +77 -0
  144. package/dist/server/custom-order/controllers/custom-order.js.map +1 -0
  145. package/dist/server/custom-order/controllers/custom-order.mjs +75 -0
  146. package/dist/server/custom-order/controllers/custom-order.mjs.map +1 -0
  147. package/dist/server/custom-order/controllers/index.js +10 -0
  148. package/dist/server/custom-order/controllers/index.js.map +1 -0
  149. package/dist/server/custom-order/controllers/index.mjs +8 -0
  150. package/dist/server/custom-order/controllers/index.mjs.map +1 -0
  151. package/dist/server/custom-order/index.js +71 -0
  152. package/dist/server/custom-order/index.js.map +1 -0
  153. package/dist/server/custom-order/index.mjs +69 -0
  154. package/dist/server/custom-order/index.mjs.map +1 -0
  155. package/dist/server/custom-order/routes/custom-order.js +38 -0
  156. package/dist/server/custom-order/routes/custom-order.js.map +1 -0
  157. package/dist/server/custom-order/routes/custom-order.mjs +36 -0
  158. package/dist/server/custom-order/routes/custom-order.mjs.map +1 -0
  159. package/dist/server/custom-order/routes/index.js +13 -0
  160. package/dist/server/custom-order/routes/index.js.map +1 -0
  161. package/dist/server/custom-order/routes/index.mjs +11 -0
  162. package/dist/server/custom-order/routes/index.mjs.map +1 -0
  163. package/dist/server/custom-order/services/custom-order.js +286 -0
  164. package/dist/server/custom-order/services/custom-order.js.map +1 -0
  165. package/dist/server/custom-order/services/custom-order.mjs +284 -0
  166. package/dist/server/custom-order/services/custom-order.mjs.map +1 -0
  167. package/dist/server/custom-order/services/document-middleware.js +83 -0
  168. package/dist/server/custom-order/services/document-middleware.js.map +1 -0
  169. package/dist/server/custom-order/services/document-middleware.mjs +81 -0
  170. package/dist/server/custom-order/services/document-middleware.mjs.map +1 -0
  171. package/dist/server/custom-order/services/index.js +10 -0
  172. package/dist/server/custom-order/services/index.js.map +1 -0
  173. package/dist/server/custom-order/services/index.mjs +8 -0
  174. package/dist/server/custom-order/services/index.mjs.map +1 -0
  175. package/dist/server/custom-order/services/utils.js +152 -0
  176. package/dist/server/custom-order/services/utils.js.map +1 -0
  177. package/dist/server/custom-order/services/utils.mjs +148 -0
  178. package/dist/server/custom-order/services/utils.mjs.map +1 -0
  179. package/dist/server/custom-order/utils.js +13 -0
  180. package/dist/server/custom-order/utils.js.map +1 -0
  181. package/dist/server/custom-order/utils.mjs +10 -0
  182. package/dist/server/custom-order/utils.mjs.map +1 -0
  183. package/dist/server/history/constants.js +2 -1
  184. package/dist/server/history/constants.js.map +1 -1
  185. package/dist/server/history/constants.mjs +2 -1
  186. package/dist/server/history/constants.mjs.map +1 -1
  187. package/dist/server/history/controllers/history-version.js +6 -2
  188. package/dist/server/history/controllers/history-version.js.map +1 -1
  189. package/dist/server/history/controllers/history-version.mjs +6 -2
  190. package/dist/server/history/controllers/history-version.mjs.map +1 -1
  191. package/dist/server/history/services/history.js +24 -7
  192. package/dist/server/history/services/history.js.map +1 -1
  193. package/dist/server/history/services/history.mjs +25 -8
  194. package/dist/server/history/services/history.mjs.map +1 -1
  195. package/dist/server/history/services/lifecycles.js +2 -16
  196. package/dist/server/history/services/lifecycles.js.map +1 -1
  197. package/dist/server/history/services/lifecycles.mjs +2 -16
  198. package/dist/server/history/services/lifecycles.mjs.map +1 -1
  199. package/dist/server/mcp/schemas/filters-schema.js +10 -2
  200. package/dist/server/mcp/schemas/filters-schema.js.map +1 -1
  201. package/dist/server/mcp/schemas/filters-schema.mjs +10 -2
  202. package/dist/server/mcp/schemas/filters-schema.mjs.map +1 -1
  203. package/dist/server/preview/controllers/validation/preview.js +1 -1
  204. package/dist/server/preview/controllers/validation/preview.js.map +1 -1
  205. package/dist/server/preview/controllers/validation/preview.mjs +2 -2
  206. package/dist/server/preview/controllers/validation/preview.mjs.map +1 -1
  207. package/dist/server/register.js +4 -0
  208. package/dist/server/register.js.map +1 -1
  209. package/dist/server/register.mjs +4 -0
  210. package/dist/server/register.mjs.map +1 -1
  211. package/dist/server/routes/index.js +3 -1
  212. package/dist/server/routes/index.js.map +1 -1
  213. package/dist/server/routes/index.mjs +2 -0
  214. package/dist/server/routes/index.mjs.map +1 -1
  215. package/dist/server/services/content-types.js +2 -2
  216. package/dist/server/services/content-types.js.map +1 -1
  217. package/dist/server/services/content-types.mjs +2 -2
  218. package/dist/server/services/content-types.mjs.map +1 -1
  219. package/dist/server/services/document-manager.js +13 -0
  220. package/dist/server/services/document-manager.js.map +1 -1
  221. package/dist/server/services/document-manager.mjs +14 -1
  222. package/dist/server/services/document-manager.mjs.map +1 -1
  223. package/dist/server/services/document-metadata.js +1 -1
  224. package/dist/server/services/document-metadata.js.map +1 -1
  225. package/dist/server/services/document-metadata.mjs +1 -1
  226. package/dist/server/services/document-metadata.mjs.map +1 -1
  227. package/dist/server/services/index.js +3 -1
  228. package/dist/server/services/index.js.map +1 -1
  229. package/dist/server/services/index.mjs +2 -0
  230. package/dist/server/services/index.mjs.map +1 -1
  231. package/dist/server/services/utils/configuration/settings.js +2 -1
  232. package/dist/server/services/utils/configuration/settings.js.map +1 -1
  233. package/dist/server/services/utils/configuration/settings.mjs +2 -1
  234. package/dist/server/services/utils/configuration/settings.mjs.map +1 -1
  235. package/dist/server/src/audit-logs.d.ts +40 -0
  236. package/dist/server/src/audit-logs.d.ts.map +1 -0
  237. package/dist/server/src/bootstrap.d.ts.map +1 -1
  238. package/dist/server/src/controllers/collection-types.d.ts +1 -1
  239. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  240. package/dist/server/src/controllers/content-types.d.ts.map +1 -1
  241. package/dist/server/src/controllers/index.d.ts +21 -3
  242. package/dist/server/src/controllers/index.d.ts.map +1 -1
  243. package/dist/server/src/controllers/relations.d.ts +19 -1
  244. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  245. package/dist/server/src/controllers/single-types.d.ts +1 -1
  246. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  247. package/dist/server/src/custom-order/constants.d.ts +18 -0
  248. package/dist/server/src/custom-order/constants.d.ts.map +1 -0
  249. package/dist/server/src/custom-order/controllers/custom-order.d.ts +8 -0
  250. package/dist/server/src/custom-order/controllers/custom-order.d.ts.map +1 -0
  251. package/dist/server/src/custom-order/controllers/index.d.ts +3 -0
  252. package/dist/server/src/custom-order/controllers/index.d.ts.map +1 -0
  253. package/dist/server/src/custom-order/index.d.ts +8 -0
  254. package/dist/server/src/custom-order/index.d.ts.map +1 -0
  255. package/dist/server/src/custom-order/routes/custom-order.d.ts +4 -0
  256. package/dist/server/src/custom-order/routes/custom-order.d.ts.map +1 -0
  257. package/dist/server/src/custom-order/routes/index.d.ts +10 -0
  258. package/dist/server/src/custom-order/routes/index.d.ts.map +1 -0
  259. package/dist/server/src/custom-order/services/custom-order.d.ts +43 -0
  260. package/dist/server/src/custom-order/services/custom-order.d.ts.map +1 -0
  261. package/dist/server/src/custom-order/services/document-middleware.d.ts +16 -0
  262. package/dist/server/src/custom-order/services/document-middleware.d.ts.map +1 -0
  263. package/dist/server/src/custom-order/services/index.d.ts +24 -0
  264. package/dist/server/src/custom-order/services/index.d.ts.map +1 -0
  265. package/dist/server/src/custom-order/services/utils.d.ts +34 -0
  266. package/dist/server/src/custom-order/services/utils.d.ts.map +1 -0
  267. package/dist/server/src/custom-order/utils.d.ts +6 -0
  268. package/dist/server/src/custom-order/utils.d.ts.map +1 -0
  269. package/dist/server/src/history/constants.d.ts.map +1 -1
  270. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  271. package/dist/server/src/history/services/history.d.ts.map +1 -1
  272. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  273. package/dist/server/src/index.d.ts +22 -6
  274. package/dist/server/src/index.d.ts.map +1 -1
  275. package/dist/server/src/mcp/schemas/filters-schema.d.ts.map +1 -1
  276. package/dist/server/src/register.d.ts.map +1 -1
  277. package/dist/server/src/routes/index.d.ts.map +1 -1
  278. package/dist/server/src/services/content-types.d.ts +1 -3
  279. package/dist/server/src/services/content-types.d.ts.map +1 -1
  280. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  281. package/dist/server/src/services/index.d.ts +1 -3
  282. package/dist/server/src/services/index.d.ts.map +1 -1
  283. package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -1
  284. package/dist/shared/contracts/content-types.d.ts +5 -0
  285. package/dist/shared/contracts/content-types.d.ts.map +1 -1
  286. package/dist/shared/contracts/custom-order.d.ts +33 -0
  287. package/dist/shared/contracts/custom-order.d.ts.map +1 -0
  288. package/dist/shared/contracts/custom-order.js +3 -0
  289. package/dist/shared/contracts/custom-order.js.map +1 -0
  290. package/dist/shared/contracts/custom-order.mjs +2 -0
  291. package/dist/shared/contracts/custom-order.mjs.map +1 -0
  292. package/dist/shared/contracts/history-versions.d.ts +0 -1
  293. package/dist/shared/contracts/history-versions.d.ts.map +1 -1
  294. package/dist/shared/contracts/index.d.ts +1 -0
  295. package/dist/shared/contracts/index.d.ts.map +1 -1
  296. package/dist/shared/contracts/index.js +2 -0
  297. package/dist/shared/contracts/index.js.map +1 -1
  298. package/dist/shared/contracts/index.mjs +2 -0
  299. package/dist/shared/contracts/index.mjs.map +1 -1
  300. package/package.json +10 -10
@@ -3,8 +3,8 @@ import * as React from 'react';
3
3
  import { useStrapiApp } from '@strapi/admin/strapi-admin';
4
4
  import { Flex, Box } from '@strapi/design-system';
5
5
  import { Image as Image$1 } from '@strapi/icons';
6
- import { Transforms, Editor } from 'slate';
7
- import { useFocused, useSelected } from 'slate-react';
6
+ import { Editor, Node, Path, Transforms, Element, Range } from 'slate';
7
+ import { ReactEditor, useFocused, useSelected } from 'slate-react';
8
8
  import { css, styled } from 'styled-components';
9
9
  import { prefixFileUrlWithBackendUrl } from '../../../../../../utils/urls.mjs';
10
10
  import { useBlocksEditorContext } from '../BlocksEditor.mjs';
@@ -49,6 +49,75 @@ const pick = (object, keys)=>{
49
49
  ]);
50
50
  return Object.fromEntries(entries);
51
51
  };
52
+ /** A Media Library asset as an image block stores it. */ const toBlockImage = (asset)=>{
53
+ // Create an object with imageSchema defined and exclude unnecessary props coming from media library config
54
+ const expectedImage = pick(asset, IMAGE_SCHEMA_FIELDS);
55
+ return {
56
+ ...expectedImage,
57
+ alternativeText: expectedImage.alternativeText || expectedImage.name,
58
+ url: prefixFileUrlWithBackendUrl(asset.url)
59
+ };
60
+ };
61
+ const isEmptyParagraph = (node)=>Element.isElement(node) && node.type === 'paragraph' && Node.string(node) === '';
62
+ /**
63
+ * For files dropped onto the editor: returns what inserts each of them, once
64
+ * uploaded, as an image block below the block they were dropped on (or at the
65
+ * end, below the last block). An empty paragraph there is replaced instead.
66
+ * Each image goes below the previous one from the same drop, and a path ref
67
+ * keeps that position right while the content is edited during the upload.
68
+ */ const createDroppedImagesInserter = (editor, event)=>{
69
+ let targetPath = null;
70
+ try {
71
+ const range = ReactEditor.findEventRange(editor, event);
72
+ targetPath = [
73
+ range.anchor.path[0]
74
+ ];
75
+ } catch {
76
+ // Dropped below the content or on its padding: no block under the pointer.
77
+ }
78
+ const lastIndex = editor.children.length - 1;
79
+ const target = targetPath ?? (lastIndex >= 0 ? [
80
+ lastIndex
81
+ ] : null);
82
+ let previousRef = target ? Editor.pathRef(editor, target) : null;
83
+ let replacesTarget = target !== null && isEmptyParagraph(Node.get(editor, target));
84
+ return (asset)=>{
85
+ const imageNode = {
86
+ type: 'image',
87
+ image: toBlockImage(asset),
88
+ children: [
89
+ {
90
+ type: 'text',
91
+ text: ''
92
+ }
93
+ ]
94
+ };
95
+ const previousPath = previousRef?.current;
96
+ let at;
97
+ if (previousPath && replacesTarget && isEmptyParagraph(Node.get(editor, previousPath))) {
98
+ at = previousPath;
99
+ } else {
100
+ at = previousPath ? Path.next(previousPath) : [
101
+ editor.children.length
102
+ ];
103
+ }
104
+ // Same as the image dialog: normalize once the image is in, or replacing the only block
105
+ // leaves a paragraph after it
106
+ Editor.withoutNormalizing(editor, ()=>{
107
+ if (replacesTarget && previousPath && Path.equals(at, previousPath)) {
108
+ Transforms.removeNodes(editor, {
109
+ at
110
+ });
111
+ }
112
+ Transforms.insertNodes(editor, imageNode, {
113
+ at
114
+ });
115
+ });
116
+ replacesTarget = false;
117
+ previousRef?.unref();
118
+ previousRef = Editor.pathRef(editor, at);
119
+ };
120
+ };
52
121
  // Type guard to force TypeScript to narrow the type of the element in Blocks component
53
122
  const isImage = (element)=>{
54
123
  return element.type === 'image';
@@ -107,40 +176,34 @@ const ImageDialog = ()=>{
107
176
  });
108
177
  if (!nodeEntryBeingReplaced) return;
109
178
  const [, pathToInsert] = nodeEntryBeingReplaced;
110
- // Remove the previous node that is being replaced by an image
111
- Transforms.removeNodes(editor);
112
- // Convert images to nodes and insert them
113
- const nodesToInsert = images.map((image)=>{
114
- const imageNode = {
115
- type: 'image',
116
- image,
117
- children: [
118
- {
119
- type: 'text',
120
- text: ''
121
- }
122
- ]
123
- };
124
- return imageNode;
125
- });
126
- Transforms.insertNodes(editor, nodesToInsert, {
127
- at: pathToInsert
179
+ // Normalize once the images are in: replacing the only block would otherwise leave an empty
180
+ // document for a moment, which normalization fills with a paragraph that stays after the images
181
+ Editor.withoutNormalizing(editor, ()=>{
182
+ // Remove the previous node that is being replaced by an image
183
+ Transforms.removeNodes(editor);
184
+ // Convert images to nodes and insert them
185
+ const nodesToInsert = images.map((image)=>{
186
+ const imageNode = {
187
+ type: 'image',
188
+ image,
189
+ children: [
190
+ {
191
+ type: 'text',
192
+ text: ''
193
+ }
194
+ ]
195
+ };
196
+ return imageNode;
197
+ });
198
+ Transforms.insertNodes(editor, nodesToInsert, {
199
+ at: pathToInsert
200
+ });
201
+ // Set the selection on the image since it was cleared by calling removeNodes
202
+ Transforms.select(editor, pathToInsert);
128
203
  });
129
- // Set the selection on the image since it was cleared by calling removeNodes
130
- Transforms.select(editor, pathToInsert);
131
204
  };
132
205
  const handleSelectAssets = (images)=>{
133
- const formattedImages = images.map((image)=>{
134
- // Create an object with imageSchema defined and exclude unnecessary props coming from media library config
135
- const expectedImage = pick(image, IMAGE_SCHEMA_FIELDS);
136
- const nodeImage = {
137
- ...expectedImage,
138
- alternativeText: expectedImage.alternativeText || expectedImage.name,
139
- url: prefixFileUrlWithBackendUrl(image.url)
140
- };
141
- return nodeImage;
142
- });
143
- insertImages(formattedImages);
206
+ insertImages(images.map(toBlockImage));
144
207
  setIsOpen(false);
145
208
  };
146
209
  return /*#__PURE__*/ jsx(MediaLibraryDialog, {
@@ -175,7 +238,13 @@ const imageBlocks = {
175
238
  },
176
239
  matchNode: (node)=>node.type === 'image',
177
240
  isInBlocksSelector: true,
178
- handleBackspaceKey (editor) {
241
+ handleBackspaceKey (editor, event) {
242
+ // A selection across several blocks is Slate's own deletion to make
243
+ if (editor.selection && Range.isExpanded(editor.selection)) {
244
+ return;
245
+ }
246
+ // The image is removed here: Slate's own Backspace would then delete the block before it
247
+ event.preventDefault();
179
248
  // Prevent issue where the image remains when it's the only block in the document
180
249
  if (editor.children.length === 1) {
181
250
  Transforms.setNodes(editor, {
@@ -218,5 +287,5 @@ const imageBlocks = {
218
287
  }
219
288
  };
220
289
 
221
- export { imageBlocks };
290
+ export { createDroppedImagesInserter, imageBlocks };
222
291
  //# sourceMappingURL=Image.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Image.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useStrapiApp } from '@strapi/admin/strapi-admin';\nimport { Box, Flex, FlexComponent } from '@strapi/design-system';\nimport { Image as Picture } from '@strapi/icons';\nimport { type Element, Transforms, Editor } from 'slate';\nimport { useFocused, type RenderElementProps, useSelected } from 'slate-react';\nimport { styled, css } from 'styled-components';\n\nimport { prefixFileUrlWithBackendUrl } from '../../../../../../utils/urls';\nimport { useBlocksEditorContext, type BlocksStore } from '../BlocksEditor';\nimport { type Block } from '../utils/types';\n\nimport type { Schema } from '@strapi/types';\n\nconst ImageWrapper = styled<FlexComponent>(Flex)<{ $isFocused?: boolean }>`\n transition-property: box-shadow;\n transition-duration: 0.2s;\n ${(props) =>\n props.$isFocused &&\n css`\n box-shadow: ${props.theme.colors.primary600} 0px 0px 0px 3px;\n `}\n\n & > img {\n height: auto;\n // The max-height is decided with the design team, the 56px is the height of the toolbar\n max-height: calc(512px - 56px);\n max-width: 100%;\n object-fit: contain;\n }\n`;\n\nconst IMAGE_SCHEMA_FIELDS = [\n 'name',\n 'alternativeText',\n 'url',\n 'caption',\n 'width',\n 'height',\n 'formats',\n 'hash',\n 'ext',\n 'mime',\n 'size',\n 'previewUrl',\n 'provider',\n 'provider_metadata',\n 'createdAt',\n 'updatedAt',\n];\n\nconst pick = <T extends object, K extends keyof T>(object: T, keys: K[]): Pick<T, K> => {\n const entries = keys.map((key) => [key, object[key]]);\n return Object.fromEntries(entries);\n};\n\n// Type guard to force TypeScript to narrow the type of the element in Blocks component\nconst isImage = (element: Element): element is Block<'image'> => {\n return element.type === 'image';\n};\n\n// Added a background color to the image wrapper to make it easier to recognize the image block\nconst Image = ({ attributes, children, element }: RenderElementProps) => {\n const editorIsFocused = useFocused();\n const imageIsSelected = useSelected();\n\n if (!isImage(element)) {\n return null;\n }\n const { url, alternativeText, width, height } = element.image;\n\n return (\n <Box {...attributes}>\n {children}\n <ImageWrapper\n background=\"neutral100\"\n contentEditable={false}\n justifyContent=\"center\"\n $isFocused={editorIsFocused && imageIsSelected}\n hasRadius\n >\n <img src={url} alt={alternativeText} width={width} height={height} />\n </ImageWrapper>\n </Box>\n );\n};\n\nconst ImageDialog = () => {\n const [isOpen, setIsOpen] = React.useState(true);\n const { editor } = useBlocksEditorContext('ImageDialog');\n const components = useStrapiApp('ImageDialog', (state) => state.components);\n\n if (!components || !isOpen) return null;\n\n const MediaLibraryDialog = components['media-library'] as React.ComponentType<{\n allowedTypes: Schema.Attribute.MediaKind[];\n onClose: () => void;\n onSelectAssets: (_images: Schema.Attribute.MediaValue<true>) => void;\n }>;\n\n const insertImages = (images: Block<'image'>['image'][]) => {\n // If the selection is inside a list, split the list so that the modified block is outside of it\n Transforms.unwrapNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n split: true,\n });\n\n // Save the path of the node that is being replaced by an image to insert the images there later\n // It's the closest full block node above the selection\n const nodeEntryBeingReplaced = Editor.above(editor, {\n match(node) {\n if (Editor.isEditor(node)) return false;\n\n const isInlineNode = ['text', 'link'].includes(node.type);\n\n return !isInlineNode;\n },\n });\n\n if (!nodeEntryBeingReplaced) return;\n const [, pathToInsert] = nodeEntryBeingReplaced;\n\n // Remove the previous node that is being replaced by an image\n Transforms.removeNodes(editor);\n\n // Convert images to nodes and insert them\n const nodesToInsert = images.map((image) => {\n const imageNode: Block<'image'> = {\n type: 'image',\n image,\n children: [{ type: 'text', text: '' }],\n };\n return imageNode;\n });\n Transforms.insertNodes(editor, nodesToInsert, { at: pathToInsert });\n\n // Set the selection on the image since it was cleared by calling removeNodes\n Transforms.select(editor, pathToInsert);\n };\n\n const handleSelectAssets = (images: Schema.Attribute.MediaValue<true>) => {\n const formattedImages = images.map((image) => {\n // Create an object with imageSchema defined and exclude unnecessary props coming from media library config\n const expectedImage = pick(image, IMAGE_SCHEMA_FIELDS);\n\n const nodeImage: Block<'image'>['image'] = {\n ...expectedImage,\n alternativeText: expectedImage.alternativeText || expectedImage.name,\n url: prefixFileUrlWithBackendUrl(image.url),\n };\n\n return nodeImage;\n });\n\n insertImages(formattedImages);\n setIsOpen(false);\n };\n\n return (\n <MediaLibraryDialog\n allowedTypes={['images']}\n onClose={() => setIsOpen(false)}\n onSelectAssets={handleSelectAssets}\n />\n );\n};\n\n/**\n * Images are void elements. They handle the rendering of their children instead of Slate.\n * See the Slate documentation for more information:\n * - https://docs.slatejs.org/api/nodes/element#void-vs-not-void\n * - https://docs.slatejs.org/api/nodes/element#rendering-void-elements\n */\nconst withImages = (editor: Editor) => {\n const { isVoid } = editor;\n\n editor.isVoid = (element) => {\n return element.type === 'image' ? true : isVoid(element);\n };\n\n return editor;\n};\n\nconst imageBlocks: Pick<BlocksStore, 'image'> = {\n image: {\n renderElement: (props) => <Image {...props} />,\n icon: Picture,\n label: {\n id: 'components.Blocks.blocks.image',\n defaultMessage: 'Image',\n },\n matchNode: (node) => node.type === 'image',\n isInBlocksSelector: true,\n handleBackspaceKey(editor) {\n // Prevent issue where the image remains when it's the only block in the document\n if (editor.children.length === 1) {\n Transforms.setNodes(editor, {\n type: 'paragraph',\n // @ts-expect-error we're only setting image as null so that Slate deletes it\n image: null,\n children: [{ type: 'text', text: '' }],\n });\n } else {\n Transforms.removeNodes(editor);\n }\n },\n handleEnterKey(editor) {\n Transforms.insertNodes(editor, {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n });\n },\n handleConvert: () => {\n /**\n * All the logic is managed inside the ImageDialog component,\n * because the blocks are only created when the user selects images in the modal and submits\n * and if he closes the modal, then no changes are made to the editor\n */\n return () => <ImageDialog />;\n },\n snippets: ['!['],\n plugin: withImages,\n },\n};\n\nexport { imageBlocks };\n"],"names":["ImageWrapper","styled","Flex","props","$isFocused","css","theme","colors","primary600","IMAGE_SCHEMA_FIELDS","pick","object","keys","entries","map","key","Object","fromEntries","isImage","element","type","Image","attributes","children","editorIsFocused","useFocused","imageIsSelected","useSelected","url","alternativeText","width","height","image","_jsxs","Box","_jsx","background","contentEditable","justifyContent","hasRadius","img","src","alt","ImageDialog","isOpen","setIsOpen","React","useState","editor","useBlocksEditorContext","components","useStrapiApp","state","MediaLibraryDialog","insertImages","images","Transforms","unwrapNodes","match","node","Editor","isEditor","split","nodeEntryBeingReplaced","above","isInlineNode","includes","pathToInsert","removeNodes","nodesToInsert","imageNode","text","insertNodes","at","select","handleSelectAssets","formattedImages","expectedImage","nodeImage","name","prefixFileUrlWithBackendUrl","allowedTypes","onClose","onSelectAssets","withImages","isVoid","imageBlocks","renderElement","icon","Picture","label","id","defaultMessage","matchNode","isInBlocksSelector","handleBackspaceKey","length","setNodes","handleEnterKey","handleConvert","snippets","plugin"],"mappings":";;;;;;;;;;;AAeA,MAAMA,YAAAA,GAAeC,MAAAA,CAAsBC,IAAAA,CAA+B;;;AAGxE,EAAA,EAA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B,QAAQ,CAACyE,MAAM,KAAK,CAAA,EAAG;gBAChCxC,UAAAA,CAAWyC,QAAQ,CAACjD,MAAAA,EAAQ;oBAC1B5B,IAAAA,EAAM,WAAA;;oBAENY,KAAAA,EAAO,IAAA;oBACPT,QAAAA,EAAU;AAAC,wBAAA;4BAAEH,IAAAA,EAAM,MAAA;4BAAQmD,IAAAA,EAAM;AAAG;AAAE;AACxC,iBAAA,CAAA;YACF,CAAA,MAAO;AACLf,gBAAAA,UAAAA,CAAWY,WAAW,CAACpB,MAAAA,CAAAA;AACzB,YAAA;AACF,QAAA,CAAA;AACAkD,QAAAA,cAAAA,CAAAA,CAAelD,MAAM,EAAA;YACnBQ,UAAAA,CAAWgB,WAAW,CAACxB,MAAAA,EAAQ;gBAC7B5B,IAAAA,EAAM,WAAA;gBACNG,QAAAA,EAAU;AAAC,oBAAA;wBAAEH,IAAAA,EAAM,MAAA;wBAAQmD,IAAAA,EAAM;AAAG;AAAE;AACxC,aAAA,CAAA;AACF,QAAA,CAAA;QACA4B,aAAAA,EAAe,IAAA;AACb;;;;UAKA,OAAO,kBAAMhE,GAAA,CAACQ,WAAAA,EAAAA,EAAAA,CAAAA;AAChB,QAAA,CAAA;QACAyD,QAAAA,EAAU;AAAC,YAAA;AAAK,SAAA;QAChBC,MAAAA,EAAQjB;AACV;AACF;;;;"}
1
+ {"version":3,"file":"Image.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useStrapiApp } from '@strapi/admin/strapi-admin';\nimport { Box, Flex, FlexComponent } from '@strapi/design-system';\nimport { Image as Picture } from '@strapi/icons';\nimport { Element, Transforms, Editor, Node, Path, Range } from 'slate';\nimport { ReactEditor, useFocused, type RenderElementProps, useSelected } from 'slate-react';\nimport { styled, css } from 'styled-components';\n\nimport { prefixFileUrlWithBackendUrl } from '../../../../../../utils/urls';\nimport { useBlocksEditorContext, type BlocksStore } from '../BlocksEditor';\nimport { type Block } from '../utils/types';\n\nimport type { Schema } from '@strapi/types';\n\nconst ImageWrapper = styled<FlexComponent>(Flex)<{ $isFocused?: boolean }>`\n transition-property: box-shadow;\n transition-duration: 0.2s;\n ${(props) =>\n props.$isFocused &&\n css`\n box-shadow: ${props.theme.colors.primary600} 0px 0px 0px 3px;\n `}\n\n & > img {\n height: auto;\n // The max-height is decided with the design team, the 56px is the height of the toolbar\n max-height: calc(512px - 56px);\n max-width: 100%;\n object-fit: contain;\n }\n`;\n\nconst IMAGE_SCHEMA_FIELDS = [\n 'name',\n 'alternativeText',\n 'url',\n 'caption',\n 'width',\n 'height',\n 'formats',\n 'hash',\n 'ext',\n 'mime',\n 'size',\n 'previewUrl',\n 'provider',\n 'provider_metadata',\n 'createdAt',\n 'updatedAt',\n];\n\nconst pick = <T extends object, K extends keyof T>(object: T, keys: K[]): Pick<T, K> => {\n const entries = keys.map((key) => [key, object[key]]);\n return Object.fromEntries(entries);\n};\n\ntype MediaAsset = Schema.Attribute.MediaValue<true>[number];\n\n/** A Media Library asset as an image block stores it. */\nconst toBlockImage = (asset: MediaAsset): Block<'image'>['image'] => {\n // Create an object with imageSchema defined and exclude unnecessary props coming from media library config\n const expectedImage = pick(asset, IMAGE_SCHEMA_FIELDS);\n\n return {\n ...expectedImage,\n alternativeText: expectedImage.alternativeText || expectedImage.name,\n url: prefixFileUrlWithBackendUrl(asset.url),\n };\n};\n\nconst isEmptyParagraph = (node: Node) =>\n Element.isElement(node) && node.type === 'paragraph' && Node.string(node) === '';\n\n/**\n * For files dropped onto the editor: returns what inserts each of them, once\n * uploaded, as an image block below the block they were dropped on (or at the\n * end, below the last block). An empty paragraph there is replaced instead.\n * Each image goes below the previous one from the same drop, and a path ref\n * keeps that position right while the content is edited during the upload.\n */\nconst createDroppedImagesInserter = (editor: Editor, event: React.DragEvent) => {\n let targetPath: Path | null = null;\n\n try {\n const range = ReactEditor.findEventRange(editor, event);\n targetPath = [range.anchor.path[0]];\n } catch {\n // Dropped below the content or on its padding: no block under the pointer.\n }\n\n const lastIndex = editor.children.length - 1;\n const target = targetPath ?? (lastIndex >= 0 ? [lastIndex] : null);\n let previousRef = target ? Editor.pathRef(editor, target) : null;\n let replacesTarget = target !== null && isEmptyParagraph(Node.get(editor, target));\n\n return (asset: MediaAsset) => {\n const imageNode: Block<'image'> = {\n type: 'image',\n image: toBlockImage(asset),\n children: [{ type: 'text', text: '' }],\n };\n\n const previousPath = previousRef?.current;\n let at: Path;\n\n if (previousPath && replacesTarget && isEmptyParagraph(Node.get(editor, previousPath))) {\n at = previousPath;\n } else {\n at = previousPath ? Path.next(previousPath) : [editor.children.length];\n }\n\n // Same as the image dialog: normalize once the image is in, or replacing the only block\n // leaves a paragraph after it\n Editor.withoutNormalizing(editor, () => {\n if (replacesTarget && previousPath && Path.equals(at, previousPath)) {\n Transforms.removeNodes(editor, { at });\n }\n\n Transforms.insertNodes(editor, imageNode, { at });\n });\n replacesTarget = false;\n\n previousRef?.unref();\n previousRef = Editor.pathRef(editor, at);\n };\n};\n\n// Type guard to force TypeScript to narrow the type of the element in Blocks component\nconst isImage = (element: Element): element is Block<'image'> => {\n return element.type === 'image';\n};\n\n// Added a background color to the image wrapper to make it easier to recognize the image block\nconst Image = ({ attributes, children, element }: RenderElementProps) => {\n const editorIsFocused = useFocused();\n const imageIsSelected = useSelected();\n\n if (!isImage(element)) {\n return null;\n }\n const { url, alternativeText, width, height } = element.image;\n\n return (\n <Box {...attributes}>\n {children}\n <ImageWrapper\n background=\"neutral100\"\n contentEditable={false}\n justifyContent=\"center\"\n $isFocused={editorIsFocused && imageIsSelected}\n hasRadius\n >\n <img src={url} alt={alternativeText} width={width} height={height} />\n </ImageWrapper>\n </Box>\n );\n};\n\nconst ImageDialog = () => {\n const [isOpen, setIsOpen] = React.useState(true);\n const { editor } = useBlocksEditorContext('ImageDialog');\n const components = useStrapiApp('ImageDialog', (state) => state.components);\n\n if (!components || !isOpen) return null;\n\n const MediaLibraryDialog = components['media-library'] as React.ComponentType<{\n allowedTypes: Schema.Attribute.MediaKind[];\n onClose: () => void;\n onSelectAssets: (_images: Schema.Attribute.MediaValue<true>) => void;\n }>;\n\n const insertImages = (images: Block<'image'>['image'][]) => {\n // If the selection is inside a list, split the list so that the modified block is outside of it\n Transforms.unwrapNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n split: true,\n });\n\n // Save the path of the node that is being replaced by an image to insert the images there later\n // It's the closest full block node above the selection\n const nodeEntryBeingReplaced = Editor.above(editor, {\n match(node) {\n if (Editor.isEditor(node)) return false;\n\n const isInlineNode = ['text', 'link'].includes(node.type);\n\n return !isInlineNode;\n },\n });\n\n if (!nodeEntryBeingReplaced) return;\n const [, pathToInsert] = nodeEntryBeingReplaced;\n\n // Normalize once the images are in: replacing the only block would otherwise leave an empty\n // document for a moment, which normalization fills with a paragraph that stays after the images\n Editor.withoutNormalizing(editor, () => {\n // Remove the previous node that is being replaced by an image\n Transforms.removeNodes(editor);\n\n // Convert images to nodes and insert them\n const nodesToInsert = images.map((image) => {\n const imageNode: Block<'image'> = {\n type: 'image',\n image,\n children: [{ type: 'text', text: '' }],\n };\n return imageNode;\n });\n Transforms.insertNodes(editor, nodesToInsert, { at: pathToInsert });\n\n // Set the selection on the image since it was cleared by calling removeNodes\n Transforms.select(editor, pathToInsert);\n });\n };\n\n const handleSelectAssets = (images: Schema.Attribute.MediaValue<true>) => {\n insertImages(images.map(toBlockImage));\n setIsOpen(false);\n };\n\n return (\n <MediaLibraryDialog\n allowedTypes={['images']}\n onClose={() => setIsOpen(false)}\n onSelectAssets={handleSelectAssets}\n />\n );\n};\n\n/**\n * Images are void elements. They handle the rendering of their children instead of Slate.\n * See the Slate documentation for more information:\n * - https://docs.slatejs.org/api/nodes/element#void-vs-not-void\n * - https://docs.slatejs.org/api/nodes/element#rendering-void-elements\n */\nconst withImages = (editor: Editor) => {\n const { isVoid } = editor;\n\n editor.isVoid = (element) => {\n return element.type === 'image' ? true : isVoid(element);\n };\n\n return editor;\n};\n\nconst imageBlocks: Pick<BlocksStore, 'image'> = {\n image: {\n renderElement: (props) => <Image {...props} />,\n icon: Picture,\n label: {\n id: 'components.Blocks.blocks.image',\n defaultMessage: 'Image',\n },\n matchNode: (node) => node.type === 'image',\n isInBlocksSelector: true,\n handleBackspaceKey(editor, event) {\n // A selection across several blocks is Slate's own deletion to make\n if (editor.selection && Range.isExpanded(editor.selection)) {\n return;\n }\n\n // The image is removed here: Slate's own Backspace would then delete the block before it\n event.preventDefault();\n\n // Prevent issue where the image remains when it's the only block in the document\n if (editor.children.length === 1) {\n Transforms.setNodes(editor, {\n type: 'paragraph',\n // @ts-expect-error we're only setting image as null so that Slate deletes it\n image: null,\n children: [{ type: 'text', text: '' }],\n });\n } else {\n Transforms.removeNodes(editor);\n }\n },\n handleEnterKey(editor) {\n Transforms.insertNodes(editor, {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n });\n },\n handleConvert: () => {\n /**\n * All the logic is managed inside the ImageDialog component,\n * because the blocks are only created when the user selects images in the modal and submits\n * and if he closes the modal, then no changes are made to the editor\n */\n return () => <ImageDialog />;\n },\n snippets: ['!['],\n plugin: withImages,\n },\n};\n\nexport { imageBlocks, createDroppedImagesInserter };\n"],"names":["ImageWrapper","styled","Flex","props","$isFocused","css","theme","colors","primary600","IMAGE_SCHEMA_FIELDS","pick","object","keys","entries","map","key","Object","fromEntries","toBlockImage","asset","expectedImage","alternativeText","name","url","prefixFileUrlWithBackendUrl","isEmptyParagraph","node","Element","isElement","type","Node","string","createDroppedImagesInserter","editor","event","targetPath","range","ReactEditor","findEventRange","anchor","path","lastIndex","children","length","target","previousRef","Editor","pathRef","replacesTarget","get","imageNode","image","text","previousPath","current","at","Path","next","withoutNormalizing","equals","Transforms","removeNodes","insertNodes","unref","isImage","element","Image","attributes","editorIsFocused","useFocused","imageIsSelected","useSelected","width","height","_jsxs","Box","_jsx","background","contentEditable","justifyContent","hasRadius","img","src","alt","ImageDialog","isOpen","setIsOpen","React","useState","useBlocksEditorContext","components","useStrapiApp","state","MediaLibraryDialog","insertImages","images","unwrapNodes","match","isEditor","split","nodeEntryBeingReplaced","above","isInlineNode","includes","pathToInsert","nodesToInsert","select","handleSelectAssets","allowedTypes","onClose","onSelectAssets","withImages","isVoid","imageBlocks","renderElement","icon","Picture","label","id","defaultMessage","matchNode","isInBlocksSelector","handleBackspaceKey","selection","Range","isExpanded","preventDefault","setNodes","handleEnterKey","handleConvert","snippets","plugin"],"mappings":";;;;;;;;;;;AAeA,MAAMA,YAAAA,GAAeC,MAAAA,CAAsBC,IAAAA,CAA+B;;;AAGxE,EAAA,EAAE,CAACC,KAAAA,GACDA,KAAAA,CAAMC,UAAU,IAChBC,GAAG;AACW,kBAAA,EAAEF,MAAMG,KAAK,CAACC,MAAM,CAACC,UAAU,CAAC;AAC9C,IAAA,CAAC;;;;;;;;;AASL,CAAC;AAED,MAAMC,mBAAAA,GAAsB;AAC1B,IAAA,MAAA;AACA,IAAA,iBAAA;AACA,IAAA,KAAA;AACA,IAAA,SAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,SAAA;AACA,IAAA,MAAA;AACA,IAAA,KAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AACA,IAAA,YAAA;AACA,IAAA,UAAA;AACA,IAAA,mBAAA;AACA,IAAA,WAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,IAAAA,GAAO,CAAsCC,MAAAA,EAAWC,IAAAA,GAAAA;AAC5D,IAAA,MAAMC,OAAAA,GAAUD,IAAAA,CAAKE,GAAG,CAAC,CAACC,GAAAA,GAAQ;AAACA,YAAAA,GAAAA;AAAKJ,YAAAA,MAAM,CAACI,GAAAA;AAAK,SAAA,CAAA;IACpD,OAAOC,MAAAA,CAAOC,WAAW,CAACJ,OAAAA,CAAAA;AAC5B,CAAA;AAIA,0DACA,MAAMK,YAAAA,GAAe,CAACC,KAAAA,GAAAA;;IAEpB,MAAMC,aAAAA,GAAgBV,KAA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
72
  };
73
73
  const replaceListWithEmptyBlock = (editor, currentListPath)=>{
74
- // Delete the empty list
75
- slate.Transforms.removeNodes(editor, {
76
- at: currentListPath
77
- });
78
- if (currentListPath[0] === 0) {
79
- // If the list was the only (or first) block element then insert empty paragraph as editor needs default value
80
- slate.Transforms.insertNodes(editor, {
81
- type: 'paragraph',
82
- children: [
83
- {
84
- type: 'text',
85
- text: ''
86
- }
87
- ]
88
- }, {
74
+ // Normalize once the paragraph is in, or removing the only block adds a second paragraph
75
+ slate.Editor.withoutNormalizing(editor, ()=>{
76
+ // Delete the empty list
77
+ slate.Transforms.removeNodes(editor, {
89
78
  at: currentListPath
90
79
  });
91
- slate.Transforms.select(editor, currentListPath);
92
- }
80
+ if (currentListPath[0] === 0) {
81
+ // If the list was the only (or first) block element then insert empty paragraph as editor needs default value
82
+ slate.Transforms.insertNodes(editor, {
83
+ type: 'paragraph',
84
+ children: [
85
+ {
86
+ type: 'text',
87
+ text: ''
88
+ }
89
+ ]
90
+ }, {
91
+ at: currentListPath
92
+ });
93
+ slate.Transforms.select(editor, currentListPath);
94
+ }
95
+ });
93
96
  };
94
97
  const isText = (node)=>{
95
98
  return slate.Node.isNode(node) && !slate.Editor.isEditor(node) && node.type === 'text';
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Typography } from '@strapi/design-system';\nimport { BulletList, NumberList } from '@strapi/icons';\nimport { Schema } from '@strapi/types';\nimport { type Text, Editor, Node, Transforms, Path, Element } from 'slate';\nimport { type RenderElementProps, ReactEditor } from 'slate-react';\nimport { styled, type CSSProperties, css } from 'styled-components';\n\nimport { type BlocksStore } from '../BlocksEditor';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { type Block } from '../utils/types';\n\nconst listStyle = css`\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[2]};\n margin-inline-start: ${({ theme }) => theme.spaces[0]};\n margin-inline-end: ${({ theme }) => theme.spaces[0]};\n padding-inline-start: ${({ theme }) => theme.spaces[2]};\n\n ol,\n ul {\n margin-block-start: ${({ theme }) => theme.spaces[0]};\n margin-block-end: ${({ theme }) => theme.spaces[0]};\n }\n\n li {\n margin-inline-start: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Orderedlist = styled.ol<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst Unorderedlist = styled.ul<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst orderedStyles = ['decimal', 'lower-alpha', 'upper-roman'];\nconst unorderedStyles = ['disc', 'circle', 'square'];\n\nconst isListNode = (element: Element): element is Schema.Attribute.ListBlockNode => {\n return element.type === 'list';\n};\n\nconst List = ({ attributes, children, element }: RenderElementProps) => {\n if (!isListNode(element)) {\n return null;\n }\n\n // Decide the subsequent style by referencing the given styles according to the format,\n // allowing for infinite nested lists\n const listStyles = element.format === 'ordered' ? orderedStyles : unorderedStyles;\n const nextIndex = (element.indentLevel || 0) % listStyles!.length;\n const listStyleType = listStyles![nextIndex];\n\n if (element.format === 'ordered') {\n return (\n <Orderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Orderedlist>\n );\n }\n\n return (\n <Unorderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Unorderedlist>\n );\n};\n\nconst replaceListWithEmptyBlock = (editor: Editor, currentListPath: Path) => {\n // Delete the empty list\n Transforms.removeNodes(editor, { at: currentListPath });\n\n if (currentListPath[0] === 0) {\n // If the list was the only (or first) block element then insert empty paragraph as editor needs default value\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: currentListPath }\n );\n Transforms.select(editor, currentListPath);\n }\n};\n\nconst isText = (node: unknown): node is Text => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';\n};\n\n/**\n * Common handler for the backspace event on ordered and unordered lists\n */\nconst handleBackspaceKeyOnList = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const [currentListItem, currentListItemPath] = Editor.parent(editor, editor.selection.anchor);\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-2) === 0;\n\n if (isListEmpty) {\n const parentListEntry = Editor.above(editor, {\n at: currentListPath,\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n if (!parentListEntry) {\n event.preventDefault();\n replaceListWithEmptyBlock(editor, currentListPath);\n }\n } else if (isFocusAtTheBeginningOfAChild) {\n // If the focus is at the beginning of a child node we need to replace it with a paragraph\n Transforms.liftNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n Transforms.setNodes(editor, { type: 'paragraph' });\n } else if (isListItemEmpty) {\n const previousEntry = Editor.previous(editor, {\n at: currentListItemPath,\n });\n const nextEntry = Editor.next(editor, {\n at: currentListItemPath,\n });\n\n if (previousEntry && nextEntry) {\n // If previous and next nodes are lists or list-items, delete empty list item\n event.preventDefault();\n Transforms.removeNodes(editor, {\n at: currentListItemPath,\n });\n\n // If previous and next nodes are lists with same format and indent Levels, then merge the nodes\n const [previousList] = previousEntry;\n const [nextList] = nextEntry;\n if (\n !Editor.isEditor(previousList) &&\n !isText(previousList) &&\n isListNode(previousList) &&\n !Editor.isEditor(nextList) &&\n !isText(nextList) &&\n isListNode(nextList)\n ) {\n if (\n previousList.type === 'list' &&\n nextList.type === 'list' &&\n previousList.format === nextList.format &&\n previousList.indentLevel === nextList.indentLevel\n ) {\n Transforms.mergeNodes(editor, {\n at: currentListItemPath,\n });\n }\n }\n }\n }\n};\n\n/**\n * Common handler for the enter key on ordered and unordered lists\n */\nconst handleEnterKeyOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-1) === 0;\n\n if (isListEmpty) {\n replaceListWithEmptyBlock(editor, currentListPath);\n } else if (isFocusAtTheBeginningOfAChild && !isListItemEmpty) {\n // If the focus is at the beginning of a child node, shift below the list item and create a new list-item\n const currentNode = Editor.above(editor, { at: editor.selection.anchor });\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n if (currentNode) {\n const path = currentNode[1];\n const updatedPath = [...path.slice(0, -1), path[path.length - 1] + 1];\n Transforms.select(editor, {\n anchor: { path: updatedPath.concat(0), offset: 0 },\n focus: { path: updatedPath.concat(0), offset: 0 },\n });\n }\n } else if (isListItemEmpty) {\n // Check if there is a list above the current list and shift list-item under it\n if (\n !Editor.isEditor(currentList) &&\n isListNode(currentList) &&\n currentList?.indentLevel &&\n currentList.indentLevel > 0\n ) {\n const previousIndentLevel = currentList.indentLevel - 1;\n\n const parentListNodeEntry = Editor.above(editor, {\n match: (node) =>\n !Editor.isEditor(node) &&\n node.type === 'list' &&\n (node.indentLevel || 0) === previousIndentLevel,\n });\n\n if (parentListNodeEntry) {\n // Get the parent list path and add 1 to it to exit from the current list\n const modifiedPath = currentListItemPath.slice(0, -1);\n if (modifiedPath.length > 0) {\n modifiedPath[modifiedPath.length - 1] += 1;\n }\n\n // Shift list-item under parent list\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: modifiedPath,\n });\n return;\n }\n }\n\n // Otherwise delete the empty list item and create a new paragraph below the parent list\n Transforms.removeNodes(editor, { at: currentListItemPath });\n\n const createdParagraphPath = Path.next(currentListPath);\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: createdParagraphPath }\n );\n\n // Move the selection to the newly created paragraph\n Transforms.select(editor, createdParagraphPath);\n } else {\n // Check if the cursor is at the end of the list item\n const isNodeEnd = Editor.isEnd(editor, editor.selection.anchor, currentListItemPath);\n\n if (isNodeEnd) {\n // If there was nothing after the cursor, create a fresh new list item,\n // in order to avoid carrying over the modifiers from the previous list item\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n } else {\n // If there is something after the cursor, split the current list item,\n // so that we keep the content and the modifiers\n Transforms.splitNodes(editor);\n }\n }\n};\n\n/**\n * Common handler for converting a node to a list\n */\nconst handleConvertToList = (editor: Editor, format: Block<'list'>['format']) => {\n const convertedPath = baseHandleConvert<Block<'list-item'>>(editor, { type: 'list-item' });\n\n if (!convertedPath) return;\n\n Transforms.wrapNodes(editor, { type: 'list', format, children: [] }, { at: convertedPath });\n};\n\n/**\n * Common handler for the tab key on ordered and unordered lists\n */\nconst handleTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n // Skip tabbing if list-item is the first item in the list\n if (currentListItem === currentList.children[0]) return;\n\n const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);\n const previousNode = currentList.children[currentListItemIndex - 1];\n\n // If previous node is a list block then move the list-item under it\n if (previousNode.type === 'list') {\n const nodePath = ReactEditor.findPath(editor, previousNode);\n const insertAtPath = previousNode.children.length;\n\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: nodePath.concat(insertAtPath),\n });\n return;\n }\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Wrap list-item with list block on tab\n Transforms.wrapNodes(editor, {\n type: 'list',\n format: currentList.format,\n indentLevel: (currentList.indentLevel || 0) + 1,\n children: [],\n });\n }\n};\n\n/**\n * Common handler for the shift+tab key on ordered and unordered lists (un-indentation)\n */\n\nconst hasChildren = (node: unknown): node is { children: unknown[] } => {\n return typeof node === 'object' && node !== null && 'children' in node;\n};\n\nconst isNestedListNode = (node: unknown): node is { type: 'list'; children: unknown[] } => {\n return hasChildren(node) && 'type' in node && node.type === 'list';\n};\n\nconst handleShiftTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [, currentListItemPath] = currentListItemEntry;\n\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n if (!Editor.isEditor(currentList) && isNestedListNode(currentList)) {\n const parentListPath = Path.parent(currentListItemPath);\n\n const [parentList] = Editor.parent(editor, parentListPath);\n\n // Case 1: The parent of the current list is the editor itself.\n if (Editor.isEditor(parentList)) {\n // Lift the list item to the top level of the editor's children.\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n // Change the type of the newly lifted node from 'list-item' to 'paragraph'.\n Transforms.setNodes(editor, { type: 'paragraph' });\n return;\n }\n\n // Case 2: The parent of the current list is another list.\n if (isNestedListNode(parentList)) {\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n try {\n const [remainingList, remainingListPath] = Editor.node(editor, parentListPath);\n\n if (isNestedListNode(remainingList) && remainingList.children.length === 0) {\n Transforms.removeNodes(editor, { at: remainingListPath });\n }\n } catch {\n // The path might no longer exist if the structure changed, which is fine\n }\n }\n }\n};\n\n// All that's in common between ordered and unordered list blocks\nconst baseListBlock = {\n renderElement: (props) => <List {...props} />,\n isInBlocksSelector: true,\n handleEnterKey: handleEnterKeyOnList,\n handleBackspaceKey: handleBackspaceKeyOnList,\n handleTab: handleTabOnList,\n isDraggable: (element) => {\n if (!isListNode(element)) {\n throw Error();\n }\n const indentLevel = element.indentLevel ?? 0;\n return indentLevel === 0;\n },\n} satisfies Partial<BlocksStore['list-ordered' | 'list-unordered']>;\n\nconst listBlocks: Pick<BlocksStore, 'list-ordered' | 'list-unordered' | 'list-item'> = {\n 'list-ordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.orderedList',\n defaultMessage: 'Numbered list',\n },\n icon: NumberList,\n matchNode: (node) => node.type === 'list' && node.format === 'ordered',\n handleConvert: (editor) => handleConvertToList(editor, 'ordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['1.'],\n },\n 'list-unordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.unorderedList',\n defaultMessage: 'Bulleted list',\n },\n icon: BulletList,\n matchNode: (node) => node.type === 'list' && node.format === 'unordered',\n handleConvert: (editor) => handleConvertToList(editor, 'unordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['-', '*', '+'],\n },\n 'list-item': {\n renderElement: (props) => (\n <Typography tag=\"li\" {...props.attributes}>\n {props.children}\n </Typography>\n ),\n // No handleConvert, list items are created when converting to the parent list\n matchNode: (node) => node.type === 'list-item',\n isInBlocksSelector: false,\n dragHandleTopMargin: '-2px',\n isDraggable: () => false,\n },\n};\n\nexport { listBlocks };\n"],"names":["listStyle","css","theme","spaces","Orderedlist","styled","ol","props","$listStyleType","Unorderedlist","ul","orderedStyles","unorderedStyles","isListNode","element","type","List","attributes","children","listStyles","format","nextIndex","indentLevel","length","listStyleType","_jsx","replaceListWithEmptyBlock","editor","currentListPath","Transforms","removeNodes","at","insertNodes","text","select","isText","node","Node","isNode","Editor","isEditor","handleBackspaceKeyOnList","event","selection","currentListItem","currentListItemPath","parent","anchor","currentList","isListEmpty","isListItemEmpty","isFocusAtTheBeginningOfAChild","focus","offset","path","parentListEntry","above","match","preventDefault","liftNodes","setNodes","previousEntry","previous","nextEntry","next","previousList","nextList","mergeNodes","handleEnterKeyOnList","currentListItemEntry","currentNode","updatedPath","slice","concat","previousIndentLevel","parentListNodeEntry","modifiedPath","moveNodes","to","createdParagraphPath","Path","isNodeEnd","isEnd","splitNodes","handleConvertToList","convertedPath","baseHandleConvert","wrapNodes","handleTabOnList","currentListItemIndex","findIndex","item","previousNode","nodePath","ReactEditor","findPath","insertAtPath","hasChildren","isNestedListNode","handleShiftTabOnList","parentListPath","parentList","remainingList","remainingListPath","baseListBlock","renderElement","isInBlocksSelector","handleEnterKey","handleBackspaceKey","handleTab","isDraggable","Error","listBlocks","label","id","defaultMessage","icon","NumberList","matchNode","handleConvert","handleShiftTab","snippets","BulletList","Typography","tag","dragHandleTopMargin"],"mappings":";;;;;;;;;;;AAaA,MAAMA,SAAAA,GAAYC,oBAAG;;;OAGd,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;uBACjB,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;qBACnC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;wBAC9B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;;;wBAIjC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;sBACnC,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AAA;QACAC,IAAAA,EAAMM,gBAAAA;QACNJ,SAAAA,EAAW,CAAClF,OAASA,IAAAA,CAAKrB,IAAI,KAAK,MAAA,IAAUqB,IAAAA,CAAKhB,MAAM,KAAK,WAAA;QAC7DmG,aAAAA,EAAe,CAAC5F,MAAAA,GAAWyD,mBAAAA,CAAoBzD,MAAAA,EAAQ,WAAA,CAAA;QACvD6F,cAAAA,EAAgBrB,oBAAAA;QAChBsB,QAAAA,EAAU;AAAC,YAAA,GAAA;AAAK,YAAA,GAAA;AAAK,YAAA;AAAI;AAC3B,KAAA;IACA,WAAA,EAAa;QACXhB,aAAAA,EAAe,CAAClG,sBACdkB,cAAA,CAACkG,uBAAAA,EAAAA;gBAAWC,GAAAA,EAAI,IAAA;AAAM,gBAAA,GAAGrH,MAAMU,UAAU;AACtCV,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMW;;;AAIXoG,QAAAA,SAAAA,EAAW,CAAClF,IAAAA,GAASA,IAAAA,CAAKrB,IAAI,KAAK,WAAA;QACnC2F,kBAAAA,EAAoB,KAAA;QACpBmB,mBAAAA,EAAqB,MAAA;AACrBf,QAAAA,WAAAA,EAAa,IAAM;AACrB;AACF;;;;"}
1
+ {"version":3,"file":"List.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Typography } from '@strapi/design-system';\nimport { BulletList, NumberList } from '@strapi/icons';\nimport { Schema } from '@strapi/types';\nimport { type Text, Editor, Node, Transforms, Path, Element } from 'slate';\nimport { type RenderElementProps, ReactEditor } from 'slate-react';\nimport { styled, type CSSProperties, css } from 'styled-components';\n\nimport { type BlocksStore } from '../BlocksEditor';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { type Block } from '../utils/types';\n\nconst listStyle = css`\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[2]};\n margin-inline-start: ${({ theme }) => theme.spaces[0]};\n margin-inline-end: ${({ theme }) => theme.spaces[0]};\n padding-inline-start: ${({ theme }) => theme.spaces[2]};\n\n ol,\n ul {\n margin-block-start: ${({ theme }) => theme.spaces[0]};\n margin-block-end: ${({ theme }) => theme.spaces[0]};\n }\n\n li {\n margin-inline-start: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Orderedlist = styled.ol<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst Unorderedlist = styled.ul<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst orderedStyles = ['decimal', 'lower-alpha', 'upper-roman'];\nconst unorderedStyles = ['disc', 'circle', 'square'];\n\nconst isListNode = (element: Element): element is Schema.Attribute.ListBlockNode => {\n return element.type === 'list';\n};\n\nconst List = ({ attributes, children, element }: RenderElementProps) => {\n if (!isListNode(element)) {\n return null;\n }\n\n // Decide the subsequent style by referencing the given styles according to the format,\n // allowing for infinite nested lists\n const listStyles = element.format === 'ordered' ? orderedStyles : unorderedStyles;\n const nextIndex = (element.indentLevel || 0) % listStyles!.length;\n const listStyleType = listStyles![nextIndex];\n\n if (element.format === 'ordered') {\n return (\n <Orderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Orderedlist>\n );\n }\n\n return (\n <Unorderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Unorderedlist>\n );\n};\n\nconst replaceListWithEmptyBlock = (editor: Editor, currentListPath: Path) => {\n // Normalize once the paragraph is in, or removing the only block adds a second paragraph\n Editor.withoutNormalizing(editor, () => {\n // Delete the empty list\n Transforms.removeNodes(editor, { at: currentListPath });\n\n if (currentListPath[0] === 0) {\n // If the list was the only (or first) block element then insert empty paragraph as editor needs default value\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: currentListPath }\n );\n Transforms.select(editor, currentListPath);\n }\n });\n};\n\nconst isText = (node: unknown): node is Text => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';\n};\n\n/**\n * Common handler for the backspace event on ordered and unordered lists\n */\nconst handleBackspaceKeyOnList = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const [currentListItem, currentListItemPath] = Editor.parent(editor, editor.selection.anchor);\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-2) === 0;\n\n if (isListEmpty) {\n const parentListEntry = Editor.above(editor, {\n at: currentListPath,\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n if (!parentListEntry) {\n event.preventDefault();\n replaceListWithEmptyBlock(editor, currentListPath);\n }\n } else if (isFocusAtTheBeginningOfAChild) {\n // If the focus is at the beginning of a child node we need to replace it with a paragraph\n Transforms.liftNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n Transforms.setNodes(editor, { type: 'paragraph' });\n } else if (isListItemEmpty) {\n const previousEntry = Editor.previous(editor, {\n at: currentListItemPath,\n });\n const nextEntry = Editor.next(editor, {\n at: currentListItemPath,\n });\n\n if (previousEntry && nextEntry) {\n // If previous and next nodes are lists or list-items, delete empty list item\n event.preventDefault();\n Transforms.removeNodes(editor, {\n at: currentListItemPath,\n });\n\n // If previous and next nodes are lists with same format and indent Levels, then merge the nodes\n const [previousList] = previousEntry;\n const [nextList] = nextEntry;\n if (\n !Editor.isEditor(previousList) &&\n !isText(previousList) &&\n isListNode(previousList) &&\n !Editor.isEditor(nextList) &&\n !isText(nextList) &&\n isListNode(nextList)\n ) {\n if (\n previousList.type === 'list' &&\n nextList.type === 'list' &&\n previousList.format === nextList.format &&\n previousList.indentLevel === nextList.indentLevel\n ) {\n Transforms.mergeNodes(editor, {\n at: currentListItemPath,\n });\n }\n }\n }\n }\n};\n\n/**\n * Common handler for the enter key on ordered and unordered lists\n */\nconst handleEnterKeyOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-1) === 0;\n\n if (isListEmpty) {\n replaceListWithEmptyBlock(editor, currentListPath);\n } else if (isFocusAtTheBeginningOfAChild && !isListItemEmpty) {\n // If the focus is at the beginning of a child node, shift below the list item and create a new list-item\n const currentNode = Editor.above(editor, { at: editor.selection.anchor });\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n if (currentNode) {\n const path = currentNode[1];\n const updatedPath = [...path.slice(0, -1), path[path.length - 1] + 1];\n Transforms.select(editor, {\n anchor: { path: updatedPath.concat(0), offset: 0 },\n focus: { path: updatedPath.concat(0), offset: 0 },\n });\n }\n } else if (isListItemEmpty) {\n // Check if there is a list above the current list and shift list-item under it\n if (\n !Editor.isEditor(currentList) &&\n isListNode(currentList) &&\n currentList?.indentLevel &&\n currentList.indentLevel > 0\n ) {\n const previousIndentLevel = currentList.indentLevel - 1;\n\n const parentListNodeEntry = Editor.above(editor, {\n match: (node) =>\n !Editor.isEditor(node) &&\n node.type === 'list' &&\n (node.indentLevel || 0) === previousIndentLevel,\n });\n\n if (parentListNodeEntry) {\n // Get the parent list path and add 1 to it to exit from the current list\n const modifiedPath = currentListItemPath.slice(0, -1);\n if (modifiedPath.length > 0) {\n modifiedPath[modifiedPath.length - 1] += 1;\n }\n\n // Shift list-item under parent list\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: modifiedPath,\n });\n return;\n }\n }\n\n // Otherwise delete the empty list item and create a new paragraph below the parent list\n Transforms.removeNodes(editor, { at: currentListItemPath });\n\n const createdParagraphPath = Path.next(currentListPath);\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: createdParagraphPath }\n );\n\n // Move the selection to the newly created paragraph\n Transforms.select(editor, createdParagraphPath);\n } else {\n // Check if the cursor is at the end of the list item\n const isNodeEnd = Editor.isEnd(editor, editor.selection.anchor, currentListItemPath);\n\n if (isNodeEnd) {\n // If there was nothing after the cursor, create a fresh new list item,\n // in order to avoid carrying over the modifiers from the previous list item\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n } else {\n // If there is something after the cursor, split the current list item,\n // so that we keep the content and the modifiers\n Transforms.splitNodes(editor);\n }\n }\n};\n\n/**\n * Common handler for converting a node to a list\n */\nconst handleConvertToList = (editor: Editor, format: Block<'list'>['format']) => {\n const convertedPath = baseHandleConvert<Block<'list-item'>>(editor, { type: 'list-item' });\n\n if (!convertedPath) return;\n\n Transforms.wrapNodes(editor, { type: 'list', format, children: [] }, { at: convertedPath });\n};\n\n/**\n * Common handler for the tab key on ordered and unordered lists\n */\nconst handleTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n // Skip tabbing if list-item is the first item in the list\n if (currentListItem === currentList.children[0]) return;\n\n const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);\n const previousNode = currentList.children[currentListItemIndex - 1];\n\n // If previous node is a list block then move the list-item under it\n if (previousNode.type === 'list') {\n const nodePath = ReactEditor.findPath(editor, previousNode);\n const insertAtPath = previousNode.children.length;\n\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: nodePath.concat(insertAtPath),\n });\n return;\n }\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Wrap list-item with list block on tab\n Transforms.wrapNodes(editor, {\n type: 'list',\n format: currentList.format,\n indentLevel: (currentList.indentLevel || 0) + 1,\n children: [],\n });\n }\n};\n\n/**\n * Common handler for the shift+tab key on ordered and unordered lists (un-indentation)\n */\n\nconst hasChildren = (node: unknown): node is { children: unknown[] } => {\n return typeof node === 'object' && node !== null && 'children' in node;\n};\n\nconst isNestedListNode = (node: unknown): node is { type: 'list'; children: unknown[] } => {\n return hasChildren(node) && 'type' in node && node.type === 'list';\n};\n\nconst handleShiftTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [, currentListItemPath] = currentListItemEntry;\n\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n if (!Editor.isEditor(currentList) && isNestedListNode(currentList)) {\n const parentListPath = Path.parent(currentListItemPath);\n\n const [parentList] = Editor.parent(editor, parentListPath);\n\n // Case 1: The parent of the current list is the editor itself.\n if (Editor.isEditor(parentList)) {\n // Lift the list item to the top level of the editor's children.\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n // Change the type of the newly lifted node from 'list-item' to 'paragraph'.\n Transforms.setNodes(editor, { type: 'paragraph' });\n return;\n }\n\n // Case 2: The parent of the current list is another list.\n if (isNestedListNode(parentList)) {\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n try {\n const [remainingList, remainingListPath] = Editor.node(editor, parentListPath);\n\n if (isNestedListNode(remainingList) && remainingList.children.length === 0) {\n Transforms.removeNodes(editor, { at: remainingListPath });\n }\n } catch {\n // The path might no longer exist if the structure changed, which is fine\n }\n }\n }\n};\n\n// All that's in common between ordered and unordered list blocks\nconst baseListBlock = {\n renderElement: (props) => <List {...props} />,\n isInBlocksSelector: true,\n handleEnterKey: handleEnterKeyOnList,\n handleBackspaceKey: handleBackspaceKeyOnList,\n handleTab: handleTabOnList,\n isDraggable: (element) => {\n if (!isListNode(element)) {\n throw Error();\n }\n const indentLevel = element.indentLevel ?? 0;\n return indentLevel === 0;\n },\n} satisfies Partial<BlocksStore['list-ordered' | 'list-unordered']>;\n\nconst listBlocks: Pick<BlocksStore, 'list-ordered' | 'list-unordered' | 'list-item'> = {\n 'list-ordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.orderedList',\n defaultMessage: 'Numbered list',\n },\n icon: NumberList,\n matchNode: (node) => node.type === 'list' && node.format === 'ordered',\n handleConvert: (editor) => handleConvertToList(editor, 'ordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['1.'],\n },\n 'list-unordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.unorderedList',\n defaultMessage: 'Bulleted list',\n },\n icon: BulletList,\n matchNode: (node) => node.type === 'list' && node.format === 'unordered',\n handleConvert: (editor) => handleConvertToList(editor, 'unordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['-', '*', '+'],\n },\n 'list-item': {\n renderElement: (props) => (\n <Typography tag=\"li\" {...props.attributes}>\n {props.children}\n </Typography>\n ),\n // No handleConvert, list items are created when converting to the parent list\n matchNode: (node) => node.type === 'list-item',\n isInBlocksSelector: false,\n dragHandleTopMargin: '-2px',\n isDraggable: () => false,\n },\n};\n\nexport { listBlocks };\n"],"names":["listStyle","css","theme","spaces","Orderedlist","styled","ol","props","$listStyleType","Unorderedlist","ul","orderedStyles","unorderedStyles","isListNode","element","type","List","attributes","children","listStyles","format","nextIndex","indentLevel","length","listStyleType","_jsx","replaceListWithEmptyBlock","editor","currentListPath","Editor","withoutNormalizing","Transforms","removeNodes","at","insertNodes","text","select","isText","node","Node","isNode","isEditor","handleBackspaceKeyOnList","event","selection","currentListItem","currentListItemPath","parent","anchor","currentList","isListEmpty","isListItemEmpty","isFocusAtTheBeginningOfAChild","focus","offset","path","parentListEntry","above","match","preventDefault","liftNodes","setNodes","previousEntry","previous","nextEntry","next","previousList","nextList","mergeNodes","handleEnterKeyOnList","currentListItemEntry","currentNode","updatedPath","slice","concat","previousIndentLevel","parentListNodeEntry","modifiedPath","moveNodes","to","createdParagraphPath","Path","isNodeEnd","isEnd","splitNodes","handleConvertToList","convertedPath","baseHandleConvert","wrapNodes","handleTabOnList","currentListItemIndex","findIndex","item","previousNode","nodePath","ReactEditor","findPath","insertAtPath","hasChildren","isNestedListNode","handleShiftTabOnList","parentListPath","parentList","remainingList","remainingListPath","baseListBlock","renderElement","isInBlocksSelector","handleEnterKey","handleBackspaceKey","handleTab","isDraggable","Error","listBlocks","label","id","defaultMessage","icon","NumberList","matchNode","handleConvert","handleShiftTab","snippets","BulletList","Typography","tag","dragHandleTopMargin"],"mappings":";;;;;;;;;;;AAaA,MAAMA,SAAAA,GAAYC,oBAAG;;;OAGd,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;uBACjB,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;qBACnC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;wBAC9B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;;;wBAIjC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC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U;AAAC,YAAA;AAAK;AAClB,KAAA;IACA,gBAAA,EAAkB;AAChB,QAAA,GAAGjB,aAAa;QAChBS,KAAAA,EAAO;YACLC,EAAAA,EAAI,wCAAA;YACJC,cAAAA,EAAgB;AAClB,SAAA;QACAC,IAAAA,EAAMM,gBAAAA;QACNJ,SAAAA,EAAW,CAACjF,OAASA,IAAAA,CAAKvB,IAAI,KAAK,MAAA,IAAUuB,IAAAA,CAAKlB,MAAM,KAAK,WAAA;QAC7DoG,aAAAA,EAAe,CAAC7F,MAAAA,GAAW0D,mBAAAA,CAAoB1D,MAAAA,EAAQ,WAAA,CAAA;QACvD8F,cAAAA,EAAgBrB,oBAAAA;QAChBsB,QAAAA,EAAU;AAAC,YAAA,GAAA;AAAK,YAAA,GAAA;AAAK,YAAA;AAAI;AAC3B,KAAA;IACA,WAAA,EAAa;QACXhB,aAAAA,EAAe,CAACnG,sBACdkB,cAAA,CAACmG,uBAAAA,EAAAA;gBAAWC,GAAAA,EAAI,IAAA;AAAM,gBAAA,GAAGtH,MAAMU,UAAU;AACtCV,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMW;;;AAIXqG,QAAAA,SAAAA,EAAW,CAACjF,IAAAA,GAASA,IAAAA,CAAKvB,IAAI,KAAK,WAAA;QACnC4F,kBAAAA,EAAoB,KAAA;QACpBmB,mBAAAA,EAAqB,MAAA;AACrBf,QAAAA,WAAAA,EAAa,IAAM;AACrB;AACF;;;;"}
@@ -69,25 +69,28 @@ const List = ({ attributes, children, element })=>{
69
69
  });
70
70
  };
71
71
  const replaceListWithEmptyBlock = (editor, currentListPath)=>{
72
- // Delete the empty list
73
- Transforms.removeNodes(editor, {
74
- at: currentListPath
75
- });
76
- if (currentListPath[0] === 0) {
77
- // If the list was the only (or first) block element then insert empty paragraph as editor needs default value
78
- Transforms.insertNodes(editor, {
79
- type: 'paragraph',
80
- children: [
81
- {
82
- type: 'text',
83
- text: ''
84
- }
85
- ]
86
- }, {
72
+ // Normalize once the paragraph is in, or removing the only block adds a second paragraph
73
+ Editor.withoutNormalizing(editor, ()=>{
74
+ // Delete the empty list
75
+ Transforms.removeNodes(editor, {
87
76
  at: currentListPath
88
77
  });
89
- Transforms.select(editor, currentListPath);
90
- }
78
+ if (currentListPath[0] === 0) {
79
+ // If the list was the only (or first) block element then insert empty paragraph as editor needs default value
80
+ Transforms.insertNodes(editor, {
81
+ type: 'paragraph',
82
+ children: [
83
+ {
84
+ type: 'text',
85
+ text: ''
86
+ }
87
+ ]
88
+ }, {
89
+ at: currentListPath
90
+ });
91
+ Transforms.select(editor, currentListPath);
92
+ }
93
+ });
91
94
  };
92
95
  const isText = (node)=>{
93
96
  return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';