@wordpress/block-library 7.13.0 → 7.13.1-next.957ca95e4c.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 (242) hide show
  1. package/build/columns/transforms.js +10 -1
  2. package/build/columns/transforms.js.map +1 -1
  3. package/build/cover/edit/block-controls.js +9 -2
  4. package/build/cover/edit/block-controls.js.map +1 -1
  5. package/build/gallery/gap-styles.js +5 -4
  6. package/build/gallery/gap-styles.js.map +1 -1
  7. package/build/home-link/index.js +14 -1
  8. package/build/home-link/index.js.map +1 -1
  9. package/build/image/edit.js +3 -1
  10. package/build/image/edit.js.map +1 -1
  11. package/build/image/use-client-width.js +3 -1
  12. package/build/image/use-client-width.js.map +1 -1
  13. package/build/index.js +1 -1
  14. package/build/index.js.map +1 -1
  15. package/build/index.native.js +3 -15
  16. package/build/index.native.js.map +1 -1
  17. package/build/latest-posts/deprecated.js +14 -1
  18. package/build/latest-posts/deprecated.js.map +1 -1
  19. package/build/latest-posts/index.js +14 -1
  20. package/build/latest-posts/index.js.map +1 -1
  21. package/build/list/deprecated.js +84 -1
  22. package/build/list/deprecated.js.map +1 -1
  23. package/build/list/edit.js +153 -134
  24. package/build/list/edit.js.map +1 -1
  25. package/build/list/index.js +29 -34
  26. package/build/list/index.js.map +1 -1
  27. package/build/list/save.js +1 -5
  28. package/build/list/save.js.map +1 -1
  29. package/build/list/{v2/tag-name.js → tag-name.js} +0 -0
  30. package/build/list/tag-name.js.map +1 -0
  31. package/build/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
  32. package/build/list/tag-name.native.js.map +1 -0
  33. package/build/list/transforms.js +61 -95
  34. package/build/list/transforms.js.map +1 -1
  35. package/build/list/{v2/migrate.js → utils.js} +3 -2
  36. package/build/list/utils.js.map +1 -0
  37. package/build/list-item/edit.native.js +21 -3
  38. package/build/list-item/edit.native.js.map +1 -1
  39. package/build/list-item/hooks/use-copy.js +2 -0
  40. package/build/list-item/hooks/use-copy.js.map +1 -1
  41. package/build/list-item/hooks/use-merge.js +0 -1
  42. package/build/list-item/hooks/use-merge.js.map +1 -1
  43. package/build/list-item/hooks/use-outdent-list-item.js +0 -1
  44. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  45. package/build/list-item/hooks/use-space.js +10 -1
  46. package/build/list-item/hooks/use-space.js.map +1 -1
  47. package/build/list-item/index.js +0 -1
  48. package/build/list-item/index.js.map +1 -1
  49. package/build/list-item/utils.js +0 -1
  50. package/build/list-item/utils.js.map +1 -1
  51. package/build/navigation/edit/index.js +6 -3
  52. package/build/navigation/edit/index.js.map +1 -1
  53. package/build/navigation/edit/responsive-wrapper.js +6 -4
  54. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  55. package/build/navigation/edit/unsaved-inner-blocks.js +4 -15
  56. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  57. package/build/post-excerpt/index.js +4 -2
  58. package/build/post-excerpt/index.js.map +1 -1
  59. package/build/post-terms/edit.js +0 -1
  60. package/build/post-terms/edit.js.map +1 -1
  61. package/build/post-terms/use-post-terms.js +4 -24
  62. package/build/post-terms/use-post-terms.js.map +1 -1
  63. package/build/query-no-results/index.js +13 -0
  64. package/build/query-no-results/index.js.map +1 -1
  65. package/build/query-pagination-numbers/index.js +4 -2
  66. package/build/query-pagination-numbers/index.js.map +1 -1
  67. package/build/query-title/index.js +1 -0
  68. package/build/query-title/index.js.map +1 -1
  69. package/build/quote/index.js +4 -2
  70. package/build/quote/index.js.map +1 -1
  71. package/build/term-description/index.js +6 -0
  72. package/build/term-description/index.js.map +1 -1
  73. package/build/verse/index.js +1 -0
  74. package/build/verse/index.js.map +1 -1
  75. package/build-module/columns/transforms.js +10 -1
  76. package/build-module/columns/transforms.js.map +1 -1
  77. package/build-module/cover/edit/block-controls.js +10 -3
  78. package/build-module/cover/edit/block-controls.js.map +1 -1
  79. package/build-module/gallery/gap-styles.js +6 -5
  80. package/build-module/gallery/gap-styles.js.map +1 -1
  81. package/build-module/home-link/index.js +14 -1
  82. package/build-module/home-link/index.js.map +1 -1
  83. package/build-module/image/edit.js +4 -2
  84. package/build-module/image/edit.js.map +1 -1
  85. package/build-module/image/use-client-width.js +3 -1
  86. package/build-module/image/use-client-width.js.map +1 -1
  87. package/build-module/index.js +1 -1
  88. package/build-module/index.js.map +1 -1
  89. package/build-module/index.native.js +3 -15
  90. package/build-module/index.native.js.map +1 -1
  91. package/build-module/latest-posts/deprecated.js +14 -1
  92. package/build-module/latest-posts/deprecated.js.map +1 -1
  93. package/build-module/latest-posts/index.js +14 -1
  94. package/build-module/latest-posts/index.js.map +1 -1
  95. package/build-module/list/deprecated.js +83 -1
  96. package/build-module/list/deprecated.js.map +1 -1
  97. package/build-module/list/edit.js +151 -134
  98. package/build-module/list/edit.js.map +1 -1
  99. package/build-module/list/index.js +29 -29
  100. package/build-module/list/index.js.map +1 -1
  101. package/build-module/list/save.js +2 -6
  102. package/build-module/list/save.js.map +1 -1
  103. package/build-module/list/{v2/tag-name.js → tag-name.js} +0 -0
  104. package/build-module/list/tag-name.js.map +1 -0
  105. package/build-module/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
  106. package/build-module/list/tag-name.native.js.map +1 -0
  107. package/build-module/list/transforms.js +62 -97
  108. package/build-module/list/transforms.js.map +1 -1
  109. package/build-module/list/{v2/migrate.js → utils.js} +3 -2
  110. package/build-module/list/utils.js.map +1 -0
  111. package/build-module/list-item/edit.native.js +19 -3
  112. package/build-module/list-item/edit.native.js.map +1 -1
  113. package/build-module/list-item/hooks/use-copy.js +2 -0
  114. package/build-module/list-item/hooks/use-copy.js.map +1 -1
  115. package/build-module/list-item/hooks/use-merge.js +0 -1
  116. package/build-module/list-item/hooks/use-merge.js.map +1 -1
  117. package/build-module/list-item/hooks/use-outdent-list-item.js +0 -1
  118. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  119. package/build-module/list-item/hooks/use-space.js +10 -1
  120. package/build-module/list-item/hooks/use-space.js.map +1 -1
  121. package/build-module/list-item/index.js +0 -1
  122. package/build-module/list-item/index.js.map +1 -1
  123. package/build-module/list-item/utils.js +0 -1
  124. package/build-module/list-item/utils.js.map +1 -1
  125. package/build-module/navigation/edit/index.js +5 -3
  126. package/build-module/navigation/edit/index.js.map +1 -1
  127. package/build-module/navigation/edit/responsive-wrapper.js +6 -4
  128. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  129. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -15
  130. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  131. package/build-module/post-excerpt/index.js +4 -2
  132. package/build-module/post-excerpt/index.js.map +1 -1
  133. package/build-module/post-terms/edit.js +0 -1
  134. package/build-module/post-terms/edit.js.map +1 -1
  135. package/build-module/post-terms/use-post-terms.js +5 -25
  136. package/build-module/post-terms/use-post-terms.js.map +1 -1
  137. package/build-module/query-no-results/index.js +13 -0
  138. package/build-module/query-no-results/index.js.map +1 -1
  139. package/build-module/query-pagination-numbers/index.js +4 -2
  140. package/build-module/query-pagination-numbers/index.js.map +1 -1
  141. package/build-module/query-title/index.js +1 -0
  142. package/build-module/query-title/index.js.map +1 -1
  143. package/build-module/quote/index.js +4 -2
  144. package/build-module/quote/index.js.map +1 -1
  145. package/build-module/term-description/index.js +6 -0
  146. package/build-module/term-description/index.js.map +1 -1
  147. package/build-module/verse/index.js +1 -0
  148. package/build-module/verse/index.js.map +1 -1
  149. package/build-style/button/style-rtl.css +1 -4
  150. package/build-style/button/style.css +1 -4
  151. package/build-style/code/editor-rtl.css +79 -0
  152. package/build-style/code/editor.css +79 -0
  153. package/build-style/cover/editor-rtl.css +0 -3
  154. package/build-style/cover/editor.css +0 -3
  155. package/build-style/editor-rtl.css +9 -44
  156. package/build-style/editor.css +9 -44
  157. package/build-style/group/editor-rtl.css +2 -22
  158. package/build-style/group/editor.css +2 -22
  159. package/build-style/navigation/editor-rtl.css +3 -19
  160. package/build-style/navigation/editor.css +3 -19
  161. package/build-style/navigation/style-rtl.css +8 -1
  162. package/build-style/navigation/style.css +8 -1
  163. package/build-style/style-rtl.css +9 -5
  164. package/build-style/style.css +9 -5
  165. package/package.json +28 -28
  166. package/src/button/style.scss +1 -8
  167. package/src/code/editor.scss +3 -0
  168. package/src/columns/transforms.js +17 -3
  169. package/src/cover/edit/block-controls.js +15 -3
  170. package/src/cover/editor.scss +0 -4
  171. package/src/editor.scss +1 -0
  172. package/src/gallery/gap-styles.js +10 -6
  173. package/src/gallery/index.php +23 -2
  174. package/src/group/editor.scss +1 -28
  175. package/src/home-link/block.json +14 -1
  176. package/src/image/edit.js +3 -3
  177. package/src/image/use-client-width.js +1 -1
  178. package/src/index.js +1 -4
  179. package/src/index.native.js +2 -13
  180. package/src/latest-posts/block.json +14 -1
  181. package/src/list/deprecated.js +71 -1
  182. package/src/list/edit.js +146 -133
  183. package/src/list/index.js +25 -24
  184. package/src/list/save.js +3 -4
  185. package/src/list/{v2/tag-name.js → tag-name.js} +0 -0
  186. package/src/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
  187. package/src/list/test/__snapshots__/edit.native.js.snap +14 -2
  188. package/src/list/test/edit.native.js +0 -154
  189. package/src/list/transforms.js +57 -111
  190. package/src/list/{v2/migrate.js → utils.js} +2 -2
  191. package/src/list-item/block.json +0 -1
  192. package/src/list-item/edit.native.js +32 -2
  193. package/src/list-item/hooks/use-copy.js +2 -0
  194. package/src/list-item/hooks/use-space.js +10 -2
  195. package/src/list-item/style.native.scss +8 -0
  196. package/src/navigation/edit/index.js +14 -4
  197. package/src/navigation/edit/responsive-wrapper.js +8 -3
  198. package/src/navigation/edit/unsaved-inner-blocks.js +14 -24
  199. package/src/navigation/editor.scss +2 -23
  200. package/src/navigation/index.php +13 -8
  201. package/src/navigation/style.scss +11 -2
  202. package/src/post-excerpt/block.json +4 -2
  203. package/src/post-terms/edit.js +0 -1
  204. package/src/post-terms/use-post-terms.js +10 -15
  205. package/src/query-no-results/block.json +13 -0
  206. package/src/query-pagination-numbers/block.json +4 -2
  207. package/src/query-title/block.json +1 -0
  208. package/src/quote/block.json +4 -2
  209. package/src/term-description/block.json +6 -0
  210. package/src/verse/block.json +1 -0
  211. package/build/list/v2/deprecated.js +0 -117
  212. package/build/list/v2/deprecated.js.map +0 -1
  213. package/build/list/v2/edit.js +0 -200
  214. package/build/list/v2/edit.js.map +0 -1
  215. package/build/list/v2/index.js +0 -36
  216. package/build/list/v2/index.js.map +0 -1
  217. package/build/list/v2/migrate.js.map +0 -1
  218. package/build/list/v2/save.js +0 -34
  219. package/build/list/v2/save.js.map +0 -1
  220. package/build/list/v2/tag-name.js.map +0 -1
  221. package/build/list/v2/tag-name.native.js.map +0 -1
  222. package/build/list/v2/transforms.js +0 -137
  223. package/build/list/v2/transforms.js.map +0 -1
  224. package/build-module/list/v2/deprecated.js +0 -104
  225. package/build-module/list/v2/deprecated.js.map +0 -1
  226. package/build-module/list/v2/edit.js +0 -179
  227. package/build-module/list/v2/edit.js.map +0 -1
  228. package/build-module/list/v2/index.js +0 -21
  229. package/build-module/list/v2/index.js.map +0 -1
  230. package/build-module/list/v2/migrate.js.map +0 -1
  231. package/build-module/list/v2/save.js +0 -23
  232. package/build-module/list/v2/save.js.map +0 -1
  233. package/build-module/list/v2/tag-name.js.map +0 -1
  234. package/build-module/list/v2/tag-name.native.js.map +0 -1
  235. package/build-module/list/v2/transforms.js +0 -127
  236. package/build-module/list/v2/transforms.js.map +0 -1
  237. package/src/list/test/migrate.js +0 -158
  238. package/src/list/v2/deprecated.js +0 -89
  239. package/src/list/v2/edit.js +0 -192
  240. package/src/list/v2/index.js +0 -22
  241. package/src/list/v2/save.js +0 -18
  242. package/src/list/v2/transforms.js +0 -120
@@ -1,179 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement, Fragment } from "@wordpress/element";
3
-
4
- /**
5
- * External dependencies
6
- */
7
- import { last } from 'lodash';
8
- /**
9
- * WordPress dependencies
10
- */
11
-
12
- import { BlockControls, useBlockProps, useInnerBlocksProps, store as blockEditorStore } from '@wordpress/block-editor';
13
- import { ToolbarButton } from '@wordpress/components';
14
- import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
15
- import { isRTL, __ } from '@wordpress/i18n';
16
- import { formatListBullets, formatListBulletsRTL, formatListNumbered, formatListNumberedRTL, formatOutdent, formatOutdentRTL } from '@wordpress/icons';
17
- import { createBlock } from '@wordpress/blocks';
18
- import { useCallback, useEffect, Platform } from '@wordpress/element';
19
- import deprecated from '@wordpress/deprecated';
20
- /**
21
- * Internal dependencies
22
- */
23
-
24
- import OrderedListSettings from '../ordered-list-settings';
25
- import { migrateToListV2 } from './migrate';
26
- import TagName from './tag-name';
27
- const TEMPLATE = [['core/list-item']];
28
- const NATIVE_MARGIN_SPACING = 8;
29
- /**
30
- * At the moment, deprecations don't handle create blocks from attributes
31
- * (like when using CPT templates). For this reason, this hook is necessary
32
- * to avoid breaking templates using the old list block format.
33
- *
34
- * @param {Object} attributes Block attributes.
35
- * @param {string} clientId Block client ID.
36
- */
37
-
38
- function useMigrateOnLoad(attributes, clientId) {
39
- const registry = useRegistry();
40
- const {
41
- updateBlockAttributes,
42
- replaceInnerBlocks
43
- } = useDispatch(blockEditorStore);
44
- useEffect(() => {
45
- // As soon as the block is loaded, migrate it to the new version.
46
- if (!attributes.values) {
47
- return;
48
- }
49
-
50
- const [newAttributes, newInnerBlocks] = migrateToListV2(attributes);
51
- deprecated('Value attribute on the list block', {
52
- since: '6.0',
53
- version: '6.5',
54
- alternative: 'inner blocks'
55
- });
56
- registry.batch(() => {
57
- updateBlockAttributes(clientId, newAttributes);
58
- replaceInnerBlocks(clientId, newInnerBlocks);
59
- });
60
- }, [attributes.values]);
61
- }
62
-
63
- function useOutdentList(clientId) {
64
- const {
65
- canOutdent
66
- } = useSelect(innerSelect => {
67
- const {
68
- getBlockRootClientId,
69
- getBlock
70
- } = innerSelect(blockEditorStore);
71
- const parentId = getBlockRootClientId(clientId);
72
- return {
73
- canOutdent: !!parentId && getBlock(parentId).name === 'core/list-item'
74
- };
75
- }, [clientId]);
76
- const {
77
- replaceBlocks,
78
- selectionChange
79
- } = useDispatch(blockEditorStore);
80
- const {
81
- getBlockRootClientId,
82
- getBlockAttributes,
83
- getBlock
84
- } = useSelect(blockEditorStore);
85
- return [canOutdent, useCallback(() => {
86
- const parentBlockId = getBlockRootClientId(clientId);
87
- const parentBlockAttributes = getBlockAttributes(parentBlockId); // Create a new parent block without the inner blocks.
88
-
89
- const newParentBlock = createBlock('core/list-item', parentBlockAttributes);
90
- const {
91
- innerBlocks
92
- } = getBlock(clientId); // Replace the parent block with a new parent block without inner blocks,
93
- // and make the inner blocks siblings of the parent.
94
-
95
- replaceBlocks([parentBlockId], [newParentBlock, ...innerBlocks]); // Select the last child of the list being outdent.
96
-
97
- selectionChange(last(innerBlocks).clientId);
98
- }, [clientId])];
99
- }
100
-
101
- function IndentUI(_ref) {
102
- let {
103
- clientId
104
- } = _ref;
105
- const [canOutdent, outdentList] = useOutdentList(clientId);
106
- return createElement(Fragment, null, createElement(ToolbarButton, {
107
- icon: isRTL() ? formatOutdentRTL : formatOutdent,
108
- title: __('Outdent'),
109
- describedBy: __('Outdent list item'),
110
- disabled: !canOutdent,
111
- onClick: outdentList
112
- }));
113
- }
114
-
115
- function Edit(_ref2) {
116
- let {
117
- attributes,
118
- setAttributes,
119
- clientId,
120
- style
121
- } = _ref2;
122
- const blockProps = useBlockProps({ ...(Platform.isNative && {
123
- style
124
- })
125
- });
126
- const innerBlocksProps = useInnerBlocksProps(blockProps, {
127
- allowedBlocks: ['core/list-item'],
128
- template: TEMPLATE,
129
- templateInsertUpdatesSelection: true,
130
- ...(Platform.isNative && {
131
- marginVertical: NATIVE_MARGIN_SPACING,
132
- marginHorizontal: NATIVE_MARGIN_SPACING
133
- })
134
- });
135
- useMigrateOnLoad(attributes, clientId);
136
- const {
137
- ordered,
138
- reversed,
139
- start
140
- } = attributes;
141
- const controls = createElement(BlockControls, {
142
- group: "block"
143
- }, createElement(ToolbarButton, {
144
- icon: isRTL() ? formatListBulletsRTL : formatListBullets,
145
- title: __('Unordered'),
146
- describedBy: __('Convert to unordered list'),
147
- isActive: ordered === false,
148
- onClick: () => {
149
- setAttributes({
150
- ordered: false
151
- });
152
- }
153
- }), createElement(ToolbarButton, {
154
- icon: isRTL() ? formatListNumberedRTL : formatListNumbered,
155
- title: __('Ordered'),
156
- describedBy: __('Convert to ordered list'),
157
- isActive: ordered === true,
158
- onClick: () => {
159
- setAttributes({
160
- ordered: true
161
- });
162
- }
163
- }), createElement(IndentUI, {
164
- clientId: clientId
165
- }));
166
- return createElement(Fragment, null, createElement(TagName, _extends({
167
- ordered: ordered,
168
- reversed: reversed,
169
- start: start
170
- }, innerBlocksProps)), controls, ordered && createElement(OrderedListSettings, {
171
- setAttributes: setAttributes,
172
- ordered: ordered,
173
- reversed: reversed,
174
- start: start
175
- }));
176
- }
177
-
178
- export default Edit;
179
- //# sourceMappingURL=edit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/edit.js"],"names":["last","BlockControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","ToolbarButton","useDispatch","useSelect","useRegistry","isRTL","__","formatListBullets","formatListBulletsRTL","formatListNumbered","formatListNumberedRTL","formatOutdent","formatOutdentRTL","createBlock","useCallback","useEffect","Platform","deprecated","OrderedListSettings","migrateToListV2","TagName","TEMPLATE","NATIVE_MARGIN_SPACING","useMigrateOnLoad","attributes","clientId","registry","updateBlockAttributes","replaceInnerBlocks","values","newAttributes","newInnerBlocks","since","version","alternative","batch","useOutdentList","canOutdent","innerSelect","getBlockRootClientId","getBlock","parentId","name","replaceBlocks","selectionChange","getBlockAttributes","parentBlockId","parentBlockAttributes","newParentBlock","innerBlocks","IndentUI","outdentList","Edit","setAttributes","style","blockProps","isNative","innerBlocksProps","allowedBlocks","template","templateInsertUpdatesSelection","marginVertical","marginHorizontal","ordered","reversed","start","controls"],"mappings":";;;AAAA;AACA;AACA;AACA,S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AO,EAAGU,OAFX;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,KAAK,EAAGC;AAJT,IATF,CADD;AAmBA;;AAED,eAAeb,IAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n\tformatOutdent,\n\tformatOutdentRTL,\n} from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback, useEffect, Platform } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport OrderedListSettings from '../ordered-list-settings';\nimport { migrateToListV2 } from './migrate';\nimport TagName from './tag-name';\n\nconst TEMPLATE = [ [ 'core/list-item' ] ];\nconst NATIVE_MARGIN_SPACING = 8;\n\n/**\n * At the moment, deprecations don't handle create blocks from attributes\n * (like when using CPT templates). For this reason, this hook is necessary\n * to avoid breaking templates using the old list block format.\n *\n * @param {Object} attributes Block attributes.\n * @param {string} clientId Block client ID.\n */\nfunction useMigrateOnLoad( attributes, clientId ) {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// As soon as the block is loaded, migrate it to the new version.\n\n\t\tif ( ! attributes.values ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );\n\n\t\tdeprecated( 'Value attribute on the list block', {\n\t\t\tsince: '6.0',\n\t\t\tversion: '6.5',\n\t\t\talternative: 'inner blocks',\n\t\t} );\n\n\t\tregistry.batch( () => {\n\t\t\tupdateBlockAttributes( clientId, newAttributes );\n\t\t\treplaceInnerBlocks( clientId, newInnerBlocks );\n\t\t} );\n\t}, [ attributes.values ] );\n}\n\nfunction useOutdentList( clientId ) {\n\tconst { canOutdent } = useSelect(\n\t\t( innerSelect ) => {\n\t\t\tconst { getBlockRootClientId, getBlock } =\n\t\t\t\tinnerSelect( blockEditorStore );\n\t\t\tconst parentId = getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tcanOutdent:\n\t\t\t\t\t!! parentId &&\n\t\t\t\t\tgetBlock( parentId ).name === 'core/list-item',\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockAttributes, getBlock } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn [\n\t\tcanOutdent,\n\t\tuseCallback( () => {\n\t\t\tconst parentBlockId = getBlockRootClientId( clientId );\n\t\t\tconst parentBlockAttributes = getBlockAttributes( parentBlockId );\n\t\t\t// Create a new parent block without the inner blocks.\n\t\t\tconst newParentBlock = createBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\tparentBlockAttributes\n\t\t\t);\n\t\t\tconst { innerBlocks } = getBlock( clientId );\n\t\t\t// Replace the parent block with a new parent block without inner blocks,\n\t\t\t// and make the inner blocks siblings of the parent.\n\t\t\treplaceBlocks(\n\t\t\t\t[ parentBlockId ],\n\t\t\t\t[ newParentBlock, ...innerBlocks ]\n\t\t\t);\n\t\t\t// Select the last child of the list being outdent.\n\t\t\tselectionChange( last( innerBlocks ).clientId );\n\t\t}, [ clientId ] ),\n\t];\n}\n\nfunction IndentUI( { clientId } ) {\n\tconst [ canOutdent, outdentList ] = useOutdentList( clientId );\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentList }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nfunction Edit( { attributes, setAttributes, clientId, style } ) {\n\tconst blockProps = useBlockProps( {\n\t\t...( Platform.isNative && { style } ),\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list-item' ],\n\t\ttemplate: TEMPLATE,\n\t\ttemplateInsertUpdatesSelection: true,\n\t\t...( Platform.isNative && {\n\t\t\tmarginVertical: NATIVE_MARGIN_SPACING,\n\t\t\tmarginHorizontal: NATIVE_MARGIN_SPACING,\n\t\t} ),\n\t} );\n\tuseMigrateOnLoad( attributes, clientId );\n\tconst { ordered, reversed, start } = attributes;\n\n\tconst controls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to unordered list' ) }\n\t\t\t\tisActive={ ordered === false }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: false } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListNumberedRTL : formatListNumbered }\n\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to ordered list' ) }\n\t\t\t\tisActive={ ordered === true }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: true } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<IndentUI clientId={ clientId } />\n\t\t</BlockControls>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TagName\n\t\t\t\tordered={ ordered }\n\t\t\t\treversed={ reversed }\n\t\t\t\tstart={ start }\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t/>\n\t\t\t{ controls }\n\t\t\t{ ordered && (\n\t\t\t\t<OrderedListSettings\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tordered={ ordered }\n\t\t\t\t\treversed={ reversed }\n\t\t\t\t\tstart={ start }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default Edit;\n"]}
@@ -1,21 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { list as icon } from '@wordpress/icons';
5
- /**
6
- * Internal dependencies
7
- */
8
-
9
- import edit from './edit';
10
- import save from './save';
11
- import transforms from './transforms';
12
- import deprecated from './deprecated';
13
- const settings = {
14
- icon,
15
- edit,
16
- save,
17
- transforms,
18
- deprecated
19
- };
20
- export default settings;
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/index.js"],"names":["list","icon","edit","save","transforms","deprecated","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,IAAjB,QAA6B,kBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAMC,QAAQ,GAAG;AAChBL,EAAAA,IADgB;AAEhBC,EAAAA,IAFgB;AAGhBC,EAAAA,IAHgB;AAIhBC,EAAAA,UAJgB;AAKhBC,EAAAA;AALgB,CAAjB;AAQA,eAAeC,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { list as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\nimport deprecated from './deprecated';\n\nconst settings = {\n\ticon,\n\tedit,\n\tsave,\n\ttransforms,\n\tdeprecated,\n};\n\nexport default settings;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/migrate.js"],"names":["omit","createBlock","createListBlockFromDOMElement","listElement","listAttributes","ordered","tagName","start","getAttribute","parseInt","undefined","reversed","type","innerBlocks","Array","from","children","map","listItem","childNodes","filter","node","nodeType","TEXT_NODE","textContent","trim","length","reverse","nestedList","nodes","hasNestedList","content","innerHTML","htmlNodes","outerHTML","childAttributes","join","childInnerBlocks","migrateToListV2","attributes","values","list","document","createElement","setAttribute","listBlock"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA,OAAO,SAASC,6BAAT,CAAwCC,WAAxC,EAAsD;AAAA;;AAC5D,QAAMC,cAAc,GAAG;AACtBC,IAAAA,OAAO,EAAE,SAASF,WAAW,CAACG,OADR;AAEtBC,IAAAA,KAAK,EAAEJ,WAAW,CAACK,YAAZ,CAA0B,OAA1B,IACJC,QAAQ,CAAEN,WAAW,CAACK,YAAZ,CAA0B,OAA1B,CAAF,EAAuC,EAAvC,CADJ,GAEJE,SAJmB;AAKtBC,IAAAA,QAAQ,EACPR,WAAW,CAACK,YAAZ,CAA0B,UAA1B,MAA2C,IAA3C,GAAkD,IAAlD,GAAyDE,SANpC;AAOtBE,IAAAA,IAAI,2BAAET,WAAW,CAACK,YAAZ,CAA0B,MAA1B,CAAF,yEAAwCE;AAPtB,GAAvB;AAUA,QAAMG,WAAW,GAAGC,KAAK,CAACC,IAAN,CAAYZ,WAAW,CAACa,QAAxB,EAAmCC,GAAnC,CACjBC,QAAF,IAAgB;AACf,UAAMF,QAAQ,GAAGF,KAAK,CAACC,IAAN,CAAYG,QAAQ,CAACC,UAArB,EAAkCC,MAAlC,CACdC,IAAF,IACCA,IAAI,CAACC,QAAL,KAAkBD,IAAI,CAACE,SAAvB,IACAF,IAAI,CAACG,WAAL,CAAiBC,IAAjB,GAAwBC,MAAxB,KAAmC,CAHpB,CAAjB;AAKAV,IAAAA,QAAQ,CAACW,OAAT;AACA,UAAM,CAAEC,UAAF,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AAL,EAAa;AACZkC,IAAAA,IAAI,CAACG,YAAL,CAAmB,OAAnB,EAA4BrC,KAA5B;AACA;;AACD,MAAKI,QAAL,EAAgB;AACf8B,IAAAA,IAAI,CAACG,YAAL,CAAmB,UAAnB,EAA+B,IAA/B;AACA;;AACD,MAAKhC,IAAL,EAAY;AACX6B,IAAAA,IAAI,CAACG,YAAL,CAAmB,MAAnB,EAA2BhC,IAA3B;AACA;;AAED,QAAMiC,SAAS,GAAG3C,6BAA6B,CAAEuC,IAAF,CAA/C;AAEA,SAAO,CACN,EACC,GAAGzC,IAAI,CAAEuC,UAAF,EAAc,CAAE,QAAF,CAAd,CADR;AAEC,OAAGM,SAAS,CAACN;AAFd,GADM,EAKNM,SAAS,CAAChC,WALJ,CAAP;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport { omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\n\nexport function createListBlockFromDOMElement( listElement ) {\n\tconst listAttributes = {\n\t\tordered: 'OL' === listElement.tagName,\n\t\tstart: listElement.getAttribute( 'start' )\n\t\t\t? parseInt( listElement.getAttribute( 'start' ), 10 )\n\t\t\t: undefined,\n\t\treversed:\n\t\t\tlistElement.getAttribute( 'reversed' ) === true ? true : undefined,\n\t\ttype: listElement.getAttribute( 'type' ) ?? undefined,\n\t};\n\n\tconst innerBlocks = Array.from( listElement.children ).map(\n\t\t( listItem ) => {\n\t\t\tconst children = Array.from( listItem.childNodes ).filter(\n\t\t\t\t( node ) =>\n\t\t\t\t\tnode.nodeType !== node.TEXT_NODE ||\n\t\t\t\t\tnode.textContent.trim().length !== 0\n\t\t\t);\n\t\t\tchildren.reverse();\n\t\t\tconst [ nestedList, ...nodes ] = children;\n\n\t\t\tconst hasNestedList =\n\t\t\t\tnestedList.tagName === 'UL' || nestedList.tagName === 'OL';\n\t\t\tif ( ! hasNestedList ) {\n\t\t\t\treturn createBlock( 'core/list-item', {\n\t\t\t\t\tcontent: listItem.innerHTML,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tconst htmlNodes = nodes.map( ( node ) => {\n\t\t\t\tif ( node.nodeType === node.TEXT_NODE ) {\n\t\t\t\t\treturn node.textContent;\n\t\t\t\t}\n\t\t\t\treturn node.outerHTML;\n\t\t\t} );\n\t\t\thtmlNodes.reverse();\n\t\t\tconst childAttributes = {\n\t\t\t\tcontent: htmlNodes.join( '' ).trim(),\n\t\t\t};\n\t\t\tconst childInnerBlocks = [\n\t\t\t\tcreateListBlockFromDOMElement( nestedList ),\n\t\t\t];\n\t\t\treturn createBlock(\n\t\t\t\t'core/list-item',\n\t\t\t\tchildAttributes,\n\t\t\t\tchildInnerBlocks\n\t\t\t);\n\t\t}\n\t);\n\n\treturn createBlock( 'core/list', listAttributes, innerBlocks );\n}\n\nexport function migrateToListV2( attributes ) {\n\tconst { values, start, reversed, ordered, type } = attributes;\n\n\tconst list = document.createElement( ordered ? 'ol' : 'ul' );\n\tlist.innerHTML = values;\n\tif ( start ) {\n\t\tlist.setAttribute( 'start', start );\n\t}\n\tif ( reversed ) {\n\t\tlist.setAttribute( 'reversed', true );\n\t}\n\tif ( type ) {\n\t\tlist.setAttribute( 'type', type );\n\t}\n\n\tconst listBlock = createListBlockFromDOMElement( list );\n\n\treturn [\n\t\t{\n\t\t\t...omit( attributes, [ 'values' ] ),\n\t\t\t...listBlock.attributes,\n\t\t},\n\t\tlistBlock.innerBlocks,\n\t];\n}\n"]}
@@ -1,23 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { createElement } from "@wordpress/element";
3
-
4
- /**
5
- * WordPress dependencies
6
- */
7
- import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
8
- export default function save(_ref) {
9
- let {
10
- attributes
11
- } = _ref;
12
- const {
13
- ordered,
14
- reversed,
15
- start
16
- } = attributes;
17
- const TagName = ordered ? 'ol' : 'ul';
18
- return createElement(TagName, _extends({
19
- reversed: reversed,
20
- start: start
21
- }, useBlockProps.save()), createElement(InnerBlocks.Content, null));
22
- }
23
- //# sourceMappingURL=save.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/save.js"],"names":["InnerBlocks","useBlockProps","save","attributes","ordered","reversed","start","TagName"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,aAAtB,QAA2C,yBAA3C;AAEA,eAAe,SAASC,IAAT,OAAgC;AAAA,MAAjB;AAAEC,IAAAA;AAAF,GAAiB;AAC9C,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAX;AAAqBC,IAAAA;AAArB,MAA+BH,UAArC;AACA,QAAMI,OAAO,GAAGH,OAAO,GAAG,IAAH,GAAU,IAAjC;AACA,SACC,cAAC,OAAD;AACC,IAAA,QAAQ,EAAGC,QADZ;AAEC,IAAA,KAAK,EAAGC;AAFT,KAGML,aAAa,CAACC,IAAd,EAHN,GAKC,cAAC,WAAD,CAAa,OAAb,OALD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { InnerBlocks, useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes } ) {\n\tconst { ordered, reversed, start } = attributes;\n\tconst TagName = ordered ? 'ol' : 'ul';\n\treturn (\n\t\t<TagName\n\t\t\treversed={ reversed }\n\t\t\tstart={ start }\n\t\t\t{ ...useBlockProps.save() }\n\t\t>\n\t\t\t<InnerBlocks.Content />\n\t\t</TagName>\n\t);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/tag-name.js"],"names":["forwardRef","TagName","props","ref","ordered","extraProps","Tag"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;;AAEA,SAASC,OAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA+B;AAC9B,QAAM;AAAEC,IAAAA,OAAF;AAAW,OAAGC;AAAd,MAA6BH,KAAnC;AACA,QAAMI,GAAG,GAAGF,OAAO,GAAG,IAAH,GAAU,IAA7B;AAEA,SAAO,cAAC,GAAD;AAAK,IAAA,GAAG,EAAGD;AAAX,KAAsBE,UAAtB,EAAP;AACA;;AAED,eAAeL,UAAU,CAAEC,OAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\nfunction TagName( props, ref ) {\n\tconst { ordered, ...extraProps } = props;\n\tconst Tag = ordered ? 'ol' : 'ul';\n\n\treturn <Tag ref={ ref } { ...extraProps } />;\n}\n\nexport default forwardRef( TagName );\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/tag-name.native.js"],"names":["forwardRef","View","TagName","props","ref","start","extraProps"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AACA,SAASC,IAAT,QAAqB,uBAArB;;AAEA,SAASC,OAAT,CAAkBC,KAAlB,EAAyBC,GAAzB,EAA+B;AAC9B,QAAM;AAAEC,IAAAA,KAAF;AAAS,OAAGC;AAAZ,MAA2BH,KAAjC;AACA,SAAO,cAAC,IAAD;AAAM,IAAA,GAAG,EAAGC;AAAZ,KAAuBE,UAAvB,EAAP;AACA;;AAED,eAAeN,UAAU,CAAEE,OAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\n\nfunction TagName( props, ref ) {\n\tconst { start, ...extraProps } = props;\n\treturn <View ref={ ref } { ...extraProps } />;\n}\n\nexport default forwardRef( TagName );\n"]}
@@ -1,127 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createBlock } from '@wordpress/blocks';
5
- import { create, split, toHTMLString } from '@wordpress/rich-text';
6
- /**
7
- * Internal dependencies
8
- */
9
-
10
- import { createListBlockFromDOMElement } from './migrate';
11
-
12
- function getListContentSchema(_ref) {
13
- let {
14
- phrasingContentSchema
15
- } = _ref;
16
- const listContentSchema = { ...phrasingContentSchema,
17
- ul: {},
18
- ol: {
19
- attributes: ['type', 'start', 'reversed']
20
- }
21
- }; // Recursion is needed.
22
- // Possible: ul > li > ul.
23
- // Impossible: ul > ul.
24
-
25
- ['ul', 'ol'].forEach(tag => {
26
- listContentSchema[tag].children = {
27
- li: {
28
- children: listContentSchema
29
- }
30
- };
31
- });
32
- return listContentSchema;
33
- }
34
-
35
- function getListContentFlat(blocks) {
36
- return blocks.flatMap(_ref2 => {
37
- let {
38
- name,
39
- attributes,
40
- innerBlocks = []
41
- } = _ref2;
42
-
43
- if (name === 'core/list-item') {
44
- return [attributes.content, ...getListContentFlat(innerBlocks)];
45
- }
46
-
47
- return getListContentFlat(innerBlocks);
48
- });
49
- }
50
-
51
- const transforms = {
52
- from: [{
53
- type: 'block',
54
- isMultiBlock: true,
55
- blocks: ['core/paragraph', 'core/heading'],
56
- transform: blockAttributes => {
57
- let childBlocks = [];
58
-
59
- if (blockAttributes.length > 1) {
60
- childBlocks = blockAttributes.map(_ref3 => {
61
- let {
62
- content
63
- } = _ref3;
64
- return createBlock('core/list-item', {
65
- content
66
- });
67
- });
68
- } else if (blockAttributes.length === 1) {
69
- const value = create({
70
- html: blockAttributes[0].content
71
- });
72
- childBlocks = split(value, '\n').map(result => {
73
- return createBlock('core/list-item', {
74
- content: toHTMLString({
75
- value: result
76
- })
77
- });
78
- });
79
- }
80
-
81
- return createBlock('core/list', {
82
- anchor: blockAttributes.anchor
83
- }, childBlocks);
84
- }
85
- }, ...['*', '-'].map(prefix => ({
86
- type: 'prefix',
87
- prefix,
88
-
89
- transform(content) {
90
- return createBlock('core/list', {}, [createBlock('core/list-item', {
91
- content
92
- })]);
93
- }
94
-
95
- })), ...['1.', '1)'].map(prefix => ({
96
- type: 'prefix',
97
- prefix,
98
-
99
- transform(content) {
100
- return createBlock('core/list', {
101
- ordered: true
102
- }, [createBlock('core/list-item', {
103
- content
104
- })]);
105
- }
106
-
107
- })), {
108
- type: 'raw',
109
- selector: 'ol,ul',
110
- schema: args => ({
111
- ol: getListContentSchema(args).ol,
112
- ul: getListContentSchema(args).ul
113
- }),
114
- transform: createListBlockFromDOMElement
115
- }],
116
- to: [...['core/paragraph', 'core/heading'].map(block => ({
117
- type: 'block',
118
- blocks: [block],
119
- transform: (_attributes, childBlocks) => {
120
- return getListContentFlat(childBlocks).map(content => createBlock(block, {
121
- content
122
- }));
123
- }
124
- }))]
125
- };
126
- export default transforms;
127
- //# sourceMappingURL=transforms.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/list/v2/transforms.js"],"names":["createBlock","create","split","toHTMLString","createListBlockFromDOMElement","getListContentSchema","phrasingContentSchema","listContentSchema","ul","ol","attributes","forEach","tag","children","li","getListContentFlat","blocks","flatMap","name","innerBlocks","content","transforms","from","type","isMultiBlock","transform","blockAttributes","childBlocks","length","map","value","html","result","anchor","prefix","ordered","selector","schema","args","to","block","_attributes"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,MAAT,EAAiBC,KAAjB,EAAwBC,YAAxB,QAA4C,sBAA5C;AAEA;AACA;AACA;;AACA,SAASC,6BAAT,QAA8C,WAA9C;;AAEA,SAASC,oBAAT,OAA2D;AAAA,MAA5B;AAAEC,IAAAA;AAAF,GAA4B;AAC1D,QAAMC,iBAAiB,GAAG,EACzB,GAAGD,qBADsB;AAEzBE,IAAAA,EAAE,EAAE,EAFqB;AAGzBC,IAAAA,EAAE,EAAE;AAAEC,MAAAA,UAAU,EAAE,CAAE,MAAF,EAAU,OAAV,EAAmB,UAAnB;AAAd;AAHqB,GAA1B,CAD0D,CAO1D;AACA;AACA;;AACA,GAAE,IAAF,EAAQ,IAAR,EAAeC,OAAf,CAA0BC,GAAF,IAAW;AAClCL,IAAAA,iBAAiB,CAAEK,GAAF,CAAjB,CAAyBC,QAAzB,GAAoC;AACnCC,MAAAA,EAAE,EAAE;AACHD,QAAAA,QAAQ,EAAEN;AADP;AAD+B,KAApC;AAKA,GAND;AAQA,SAAO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AOCiB,IAAAA,SAAS,EAAErB;AAPZ,GApDK,CADY;AA+DlBmC,EAAAA,EAAE,EAAE,CACH,GAAG,CAAE,gBAAF,EAAoB,cAApB,EAAqCV,GAArC,CAA4CW,KAAF,KAAe;AAC3DjB,IAAAA,IAAI,EAAE,OADqD;AAE3DP,IAAAA,MAAM,EAAE,CAAEwB,KAAF,CAFmD;AAG3Df,IAAAA,SAAS,EAAE,CAAEgB,WAAF,EAAed,WAAf,KAAgC;AAC1C,aAAOZ,kBAAkB,CAAEY,WAAF,CAAlB,CAAkCE,GAAlC,CAAyCT,OAAF,IAC7CpB,WAAW,CAAEwC,KAAF,EAAS;AACnBpB,QAAAA;AADmB,OAAT,CADL,CAAP;AAKA;AAT0D,GAAf,CAA1C,CADA;AA/Dc,CAAnB;AA8EA,eAAeC,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, split, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { createListBlockFromDOMElement } from './migrate';\n\nfunction getListContentSchema( { phrasingContentSchema } ) {\n\tconst listContentSchema = {\n\t\t...phrasingContentSchema,\n\t\tul: {},\n\t\tol: { attributes: [ 'type', 'start', 'reversed' ] },\n\t};\n\n\t// Recursion is needed.\n\t// Possible: ul > li > ul.\n\t// Impossible: ul > ul.\n\t[ 'ul', 'ol' ].forEach( ( tag ) => {\n\t\tlistContentSchema[ tag ].children = {\n\t\t\tli: {\n\t\t\t\tchildren: listContentSchema,\n\t\t\t},\n\t\t};\n\t} );\n\n\treturn listContentSchema;\n}\n\nfunction getListContentFlat( blocks ) {\n\treturn blocks.flatMap( ( { name, attributes, innerBlocks = [] } ) => {\n\t\tif ( name === 'core/list-item' ) {\n\t\t\treturn [ attributes.content, ...getListContentFlat( innerBlocks ) ];\n\t\t}\n\t\treturn getListContentFlat( innerBlocks );\n\t} );\n}\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph', 'core/heading' ],\n\t\t\ttransform: ( blockAttributes ) => {\n\t\t\t\tlet childBlocks = [];\n\t\t\t\tif ( blockAttributes.length > 1 ) {\n\t\t\t\t\tchildBlocks = blockAttributes.map( ( { content } ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', { content } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( blockAttributes.length === 1 ) {\n\t\t\t\t\tconst value = create( {\n\t\t\t\t\t\thtml: blockAttributes[ 0 ].content,\n\t\t\t\t\t} );\n\t\t\t\t\tchildBlocks = split( value, '\\n' ).map( ( result ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', {\n\t\t\t\t\t\t\tcontent: toHTMLString( { value: result } ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tanchor: blockAttributes.anchor,\n\t\t\t\t\t},\n\t\t\t\t\tchildBlocks\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t...[ '*', '-' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock( 'core/list', {}, [\n\t\t\t\t\tcreateBlock( 'core/list-item', { content } ),\n\t\t\t\t] );\n\t\t\t},\n\t\t} ) ),\n\t\t...[ '1.', '1)' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tordered: true,\n\t\t\t\t\t},\n\t\t\t\t\t[ createBlock( 'core/list-item', { content } ) ]\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tselector: 'ol,ul',\n\t\t\tschema: ( args ) => ( {\n\t\t\t\tol: getListContentSchema( args ).ol,\n\t\t\t\tul: getListContentSchema( args ).ul,\n\t\t\t} ),\n\t\t\ttransform: createListBlockFromDOMElement,\n\t\t},\n\t],\n\tto: [\n\t\t...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {\n\t\t\ttype: 'block',\n\t\t\tblocks: [ block ],\n\t\t\ttransform: ( _attributes, childBlocks ) => {\n\t\t\t\treturn getListContentFlat( childBlocks ).map( ( content ) =>\n\t\t\t\t\tcreateBlock( block, {\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t],\n};\n\nexport default transforms;\n"]}
@@ -1,158 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { registerBlockType, serialize } from '@wordpress/blocks';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { migrateToListV2 } from '../v2/migrate';
10
- import * as listItem from '../../list-item';
11
- import * as list from '../../list';
12
- import listV2 from '../../list/v2';
13
-
14
- describe( 'Migrate list block', () => {
15
- beforeAll( () => {
16
- const prev = window.__experimentalEnableListBlockV2;
17
-
18
- // force list and list item block registration.
19
- registerBlockType(
20
- { name: listItem.name, ...listItem.metadata },
21
- listItem.settings
22
- );
23
- registerBlockType( { name: list.name, ...list.metadata }, listV2 );
24
-
25
- window.__experimentalEnableListBlockV2 = prev;
26
- } );
27
-
28
- it( 'should migrate the values attribute to inner blocks', () => {
29
- const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
30
- values: '<li>test</li><li>test</li><li>test<ol><li>test test</li><li>test est eesssss</li></ol></li>',
31
- ordered: false,
32
- } );
33
-
34
- expect( updatedAttributes ).toEqual( {
35
- ordered: false,
36
- // Ideally the values attributes shouldn't be here
37
- // but since we didn't enable v2 by default yet,
38
- // we're keeping the old default value in block.json
39
- values: '',
40
- } );
41
- expect( serialize( updatedInnerBlocks ) )
42
- .toEqual( `<!-- wp:list-item -->
43
- <li>test</li>
44
- <!-- /wp:list-item -->
45
-
46
- <!-- wp:list-item -->
47
- <li>test</li>
48
- <!-- /wp:list-item -->
49
-
50
- <!-- wp:list-item -->
51
- <li>test<!-- wp:list {\"ordered\":true} -->
52
- <ol><!-- wp:list-item -->
53
- <li>test test</li>
54
- <!-- /wp:list-item -->
55
-
56
- <!-- wp:list-item -->
57
- <li>test est eesssss</li>
58
- <!-- /wp:list-item --></ol>
59
- <!-- /wp:list --></li>
60
- <!-- /wp:list-item -->` );
61
- } );
62
-
63
- it( 'should handle empty space properly', () => {
64
- const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
65
- values: `<li>Europe</li>
66
- <li>
67
- \tAfrica
68
- <ol>
69
- <li>Algeria</li>
70
- </ol>
71
- \t
72
- </li>`,
73
- ordered: false,
74
- } );
75
-
76
- expect( updatedAttributes ).toEqual( {
77
- ordered: false,
78
- // Ideally the values attributes shouldn't be here
79
- // but since we didn't enable v2 by default yet,
80
- // we're keeping the old default value in block.json
81
- values: '',
82
- } );
83
- expect( serialize( updatedInnerBlocks ) )
84
- .toEqual( `<!-- wp:list-item -->
85
- <li>Europe</li>
86
- <!-- /wp:list-item -->
87
-
88
- <!-- wp:list-item -->
89
- <li>Africa<!-- wp:list {\"ordered\":true} -->
90
- <ol><!-- wp:list-item -->
91
- <li>Algeria</li>
92
- <!-- /wp:list-item --></ol>
93
- <!-- /wp:list --></li>
94
- <!-- /wp:list-item -->` );
95
- } );
96
-
97
- it( 'should handle formats properly', () => {
98
- const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
99
- values: `<li>Europe<ul><li>France<ul><li>Lyon <strong>Rhone</strong>s</li><li>Paris <em>Ile de france</em><ul><li><em>1er</em></li></ul></li></ul></li></ul></li></ul></li>`,
100
- ordered: false,
101
- } );
102
-
103
- expect( updatedAttributes ).toEqual( {
104
- ordered: false,
105
- // Ideally the values attributes shouldn't be here
106
- // but since we didn't enable v2 by default yet,
107
- // we're keeping the old default value in block.json
108
- values: '',
109
- } );
110
- expect( serialize( updatedInnerBlocks ) )
111
- .toEqual( `<!-- wp:list-item -->
112
- <li>Europe<!-- wp:list -->
113
- <ul><!-- wp:list-item -->
114
- <li>France<!-- wp:list -->
115
- <ul><!-- wp:list-item -->
116
- <li>Lyon <strong>Rhone</strong>s</li>
117
- <!-- /wp:list-item -->
118
-
119
- <!-- wp:list-item -->
120
- <li>Paris <em>Ile de france</em><!-- wp:list -->
121
- <ul><!-- wp:list-item -->
122
- <li><em>1er</em></li>
123
- <!-- /wp:list-item --></ul>
124
- <!-- /wp:list --></li>
125
- <!-- /wp:list-item --></ul>
126
- <!-- /wp:list --></li>
127
- <!-- /wp:list-item --></ul>
128
- <!-- /wp:list --></li>
129
- <!-- /wp:list-item -->` );
130
- } );
131
-
132
- it( 'should not add random space', () => {
133
- const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
134
- values: `<li>Europe<ul><li>F<strong>ranc</strong>e<ul><li>Paris</li></ul></li></ul></li>`,
135
- ordered: false,
136
- } );
137
-
138
- expect( updatedAttributes ).toEqual( {
139
- ordered: false,
140
- // Ideally the values attributes shouldn't be here
141
- // but since we didn't enable v2 by default yet,
142
- // we're keeping the old default value in block.json
143
- values: '',
144
- } );
145
- expect( serialize( updatedInnerBlocks ) )
146
- .toEqual( `<!-- wp:list-item -->
147
- <li>Europe<!-- wp:list -->
148
- <ul><!-- wp:list-item -->
149
- <li>F<strong>ranc</strong>e<!-- wp:list -->
150
- <ul><!-- wp:list-item -->
151
- <li>Paris</li>
152
- <!-- /wp:list-item --></ul>
153
- <!-- /wp:list --></li>
154
- <!-- /wp:list-item --></ul>
155
- <!-- /wp:list --></li>
156
- <!-- /wp:list-item -->` );
157
- } );
158
- } );