@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.
- package/build/columns/transforms.js +10 -1
- package/build/columns/transforms.js.map +1 -1
- package/build/cover/edit/block-controls.js +9 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/gallery/gap-styles.js +5 -4
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/home-link/index.js +14 -1
- package/build/home-link/index.js.map +1 -1
- package/build/image/edit.js +3 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/use-client-width.js +3 -1
- package/build/image/use-client-width.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js +3 -15
- package/build/index.native.js.map +1 -1
- package/build/latest-posts/deprecated.js +14 -1
- package/build/latest-posts/deprecated.js.map +1 -1
- package/build/latest-posts/index.js +14 -1
- package/build/latest-posts/index.js.map +1 -1
- package/build/list/deprecated.js +84 -1
- package/build/list/deprecated.js.map +1 -1
- package/build/list/edit.js +153 -134
- package/build/list/edit.js.map +1 -1
- package/build/list/index.js +29 -34
- package/build/list/index.js.map +1 -1
- package/build/list/save.js +1 -5
- package/build/list/save.js.map +1 -1
- package/build/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/build/list/tag-name.js.map +1 -0
- package/build/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/build/list/tag-name.native.js.map +1 -0
- package/build/list/transforms.js +61 -95
- package/build/list/transforms.js.map +1 -1
- package/build/list/{v2/migrate.js → utils.js} +3 -2
- package/build/list/utils.js.map +1 -0
- package/build/list-item/edit.native.js +21 -3
- package/build/list-item/edit.native.js.map +1 -1
- package/build/list-item/hooks/use-copy.js +2 -0
- package/build/list-item/hooks/use-copy.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +0 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +0 -1
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +10 -1
- package/build/list-item/hooks/use-space.js.map +1 -1
- package/build/list-item/index.js +0 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +0 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/navigation/edit/index.js +6 -3
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +6 -4
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -15
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/post-excerpt/index.js +4 -2
- package/build/post-excerpt/index.js.map +1 -1
- package/build/post-terms/edit.js +0 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/use-post-terms.js +4 -24
- package/build/post-terms/use-post-terms.js.map +1 -1
- package/build/query-no-results/index.js +13 -0
- package/build/query-no-results/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +4 -2
- package/build/query-pagination-numbers/index.js.map +1 -1
- package/build/query-title/index.js +1 -0
- package/build/query-title/index.js.map +1 -1
- package/build/quote/index.js +4 -2
- package/build/quote/index.js.map +1 -1
- package/build/term-description/index.js +6 -0
- package/build/term-description/index.js.map +1 -1
- package/build/verse/index.js +1 -0
- package/build/verse/index.js.map +1 -1
- package/build-module/columns/transforms.js +10 -1
- package/build-module/columns/transforms.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +10 -3
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/gallery/gap-styles.js +6 -5
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/home-link/index.js +14 -1
- package/build-module/home-link/index.js.map +1 -1
- package/build-module/image/edit.js +4 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/use-client-width.js +3 -1
- package/build-module/image/use-client-width.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +3 -15
- package/build-module/index.native.js.map +1 -1
- package/build-module/latest-posts/deprecated.js +14 -1
- package/build-module/latest-posts/deprecated.js.map +1 -1
- package/build-module/latest-posts/index.js +14 -1
- package/build-module/latest-posts/index.js.map +1 -1
- package/build-module/list/deprecated.js +83 -1
- package/build-module/list/deprecated.js.map +1 -1
- package/build-module/list/edit.js +151 -134
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/index.js +29 -29
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/save.js +2 -6
- package/build-module/list/save.js.map +1 -1
- package/build-module/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/build-module/list/tag-name.js.map +1 -0
- package/build-module/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/build-module/list/tag-name.native.js.map +1 -0
- package/build-module/list/transforms.js +62 -97
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/{v2/migrate.js → utils.js} +3 -2
- package/build-module/list/utils.js.map +1 -0
- package/build-module/list-item/edit.native.js +19 -3
- package/build-module/list-item/edit.native.js.map +1 -1
- package/build-module/list-item/hooks/use-copy.js +2 -0
- package/build-module/list-item/hooks/use-copy.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +0 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +0 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +10 -1
- package/build-module/list-item/hooks/use-space.js.map +1 -1
- package/build-module/list-item/index.js +0 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +0 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/navigation/edit/index.js +5 -3
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +6 -4
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -15
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/post-excerpt/index.js +4 -2
- package/build-module/post-excerpt/index.js.map +1 -1
- package/build-module/post-terms/edit.js +0 -1
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/use-post-terms.js +5 -25
- package/build-module/post-terms/use-post-terms.js.map +1 -1
- package/build-module/query-no-results/index.js +13 -0
- package/build-module/query-no-results/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +4 -2
- package/build-module/query-pagination-numbers/index.js.map +1 -1
- package/build-module/query-title/index.js +1 -0
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/quote/index.js +4 -2
- package/build-module/quote/index.js.map +1 -1
- package/build-module/term-description/index.js +6 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/verse/index.js +1 -0
- package/build-module/verse/index.js.map +1 -1
- package/build-style/button/style-rtl.css +1 -4
- package/build-style/button/style.css +1 -4
- package/build-style/code/editor-rtl.css +79 -0
- package/build-style/code/editor.css +79 -0
- package/build-style/cover/editor-rtl.css +0 -3
- package/build-style/cover/editor.css +0 -3
- package/build-style/editor-rtl.css +9 -44
- package/build-style/editor.css +9 -44
- package/build-style/group/editor-rtl.css +2 -22
- package/build-style/group/editor.css +2 -22
- package/build-style/navigation/editor-rtl.css +3 -19
- package/build-style/navigation/editor.css +3 -19
- package/build-style/navigation/style-rtl.css +8 -1
- package/build-style/navigation/style.css +8 -1
- package/build-style/style-rtl.css +9 -5
- package/build-style/style.css +9 -5
- package/package.json +28 -28
- package/src/button/style.scss +1 -8
- package/src/code/editor.scss +3 -0
- package/src/columns/transforms.js +17 -3
- package/src/cover/edit/block-controls.js +15 -3
- package/src/cover/editor.scss +0 -4
- package/src/editor.scss +1 -0
- package/src/gallery/gap-styles.js +10 -6
- package/src/gallery/index.php +23 -2
- package/src/group/editor.scss +1 -28
- package/src/home-link/block.json +14 -1
- package/src/image/edit.js +3 -3
- package/src/image/use-client-width.js +1 -1
- package/src/index.js +1 -4
- package/src/index.native.js +2 -13
- package/src/latest-posts/block.json +14 -1
- package/src/list/deprecated.js +71 -1
- package/src/list/edit.js +146 -133
- package/src/list/index.js +25 -24
- package/src/list/save.js +3 -4
- package/src/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/src/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/src/list/test/__snapshots__/edit.native.js.snap +14 -2
- package/src/list/test/edit.native.js +0 -154
- package/src/list/transforms.js +57 -111
- package/src/list/{v2/migrate.js → utils.js} +2 -2
- package/src/list-item/block.json +0 -1
- package/src/list-item/edit.native.js +32 -2
- package/src/list-item/hooks/use-copy.js +2 -0
- package/src/list-item/hooks/use-space.js +10 -2
- package/src/list-item/style.native.scss +8 -0
- package/src/navigation/edit/index.js +14 -4
- package/src/navigation/edit/responsive-wrapper.js +8 -3
- package/src/navigation/edit/unsaved-inner-blocks.js +14 -24
- package/src/navigation/editor.scss +2 -23
- package/src/navigation/index.php +13 -8
- package/src/navigation/style.scss +11 -2
- package/src/post-excerpt/block.json +4 -2
- package/src/post-terms/edit.js +0 -1
- package/src/post-terms/use-post-terms.js +10 -15
- package/src/query-no-results/block.json +13 -0
- package/src/query-pagination-numbers/block.json +4 -2
- package/src/query-title/block.json +1 -0
- package/src/quote/block.json +4 -2
- package/src/term-description/block.json +6 -0
- package/src/verse/block.json +1 -0
- package/build/list/v2/deprecated.js +0 -117
- package/build/list/v2/deprecated.js.map +0 -1
- package/build/list/v2/edit.js +0 -200
- package/build/list/v2/edit.js.map +0 -1
- package/build/list/v2/index.js +0 -36
- package/build/list/v2/index.js.map +0 -1
- package/build/list/v2/migrate.js.map +0 -1
- package/build/list/v2/save.js +0 -34
- package/build/list/v2/save.js.map +0 -1
- package/build/list/v2/tag-name.js.map +0 -1
- package/build/list/v2/tag-name.native.js.map +0 -1
- package/build/list/v2/transforms.js +0 -137
- package/build/list/v2/transforms.js.map +0 -1
- package/build-module/list/v2/deprecated.js +0 -104
- package/build-module/list/v2/deprecated.js.map +0 -1
- package/build-module/list/v2/edit.js +0 -179
- package/build-module/list/v2/edit.js.map +0 -1
- package/build-module/list/v2/index.js +0 -21
- package/build-module/list/v2/index.js.map +0 -1
- package/build-module/list/v2/migrate.js.map +0 -1
- package/build-module/list/v2/save.js +0 -23
- package/build-module/list/v2/save.js.map +0 -1
- package/build-module/list/v2/tag-name.js.map +0 -1
- package/build-module/list/v2/tag-name.native.js.map +0 -1
- package/build-module/list/v2/transforms.js +0 -127
- package/build-module/list/v2/transforms.js.map +0 -1
- package/src/list/test/migrate.js +0 -158
- package/src/list/v2/deprecated.js +0 -89
- package/src/list/v2/edit.js +0 -192
- package/src/list/v2/index.js +0 -22
- package/src/list/v2/save.js +0 -18
- package/src/list/v2/transforms.js +0 -120
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import initialDeprecations from '../deprecated';
|
|
10
|
-
import { migrateToListV2 } from './migrate';
|
|
11
|
-
|
|
12
|
-
const v1 = {
|
|
13
|
-
attributes: {
|
|
14
|
-
ordered: {
|
|
15
|
-
type: 'boolean',
|
|
16
|
-
default: false,
|
|
17
|
-
__experimentalRole: 'content',
|
|
18
|
-
},
|
|
19
|
-
values: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
source: 'html',
|
|
22
|
-
selector: 'ol,ul',
|
|
23
|
-
multiline: 'li',
|
|
24
|
-
__unstableMultilineWrapperTags: [ 'ol', 'ul' ],
|
|
25
|
-
default: '',
|
|
26
|
-
__experimentalRole: 'content',
|
|
27
|
-
},
|
|
28
|
-
type: {
|
|
29
|
-
type: 'string',
|
|
30
|
-
},
|
|
31
|
-
start: {
|
|
32
|
-
type: 'number',
|
|
33
|
-
},
|
|
34
|
-
reversed: {
|
|
35
|
-
type: 'boolean',
|
|
36
|
-
},
|
|
37
|
-
placeholder: {
|
|
38
|
-
type: 'string',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
supports: {
|
|
42
|
-
anchor: true,
|
|
43
|
-
className: false,
|
|
44
|
-
typography: {
|
|
45
|
-
fontSize: true,
|
|
46
|
-
__experimentalFontFamily: true,
|
|
47
|
-
lineHeight: true,
|
|
48
|
-
__experimentalFontStyle: true,
|
|
49
|
-
__experimentalFontWeight: true,
|
|
50
|
-
__experimentalLetterSpacing: true,
|
|
51
|
-
__experimentalTextTransform: true,
|
|
52
|
-
__experimentalDefaultControls: {
|
|
53
|
-
fontSize: true,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
color: {
|
|
57
|
-
gradients: true,
|
|
58
|
-
link: true,
|
|
59
|
-
__experimentalDefaultControls: {
|
|
60
|
-
background: true,
|
|
61
|
-
text: true,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
__unstablePasteTextInline: true,
|
|
65
|
-
__experimentalSelector: 'ol,ul',
|
|
66
|
-
__experimentalSlashInserter: true,
|
|
67
|
-
},
|
|
68
|
-
save( { attributes } ) {
|
|
69
|
-
const { ordered, values, type, reversed, start } = attributes;
|
|
70
|
-
const TagName = ordered ? 'ol' : 'ul';
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<TagName { ...useBlockProps.save( { type, reversed, start } ) }>
|
|
74
|
-
<RichText.Content value={ values } multiline="li" />
|
|
75
|
-
</TagName>
|
|
76
|
-
);
|
|
77
|
-
},
|
|
78
|
-
migrate: migrateToListV2,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* New deprecations need to be placed first
|
|
83
|
-
* for them to have higher priority.
|
|
84
|
-
*
|
|
85
|
-
* Old deprecations may need to be updated as well.
|
|
86
|
-
*
|
|
87
|
-
* See block-deprecation.md
|
|
88
|
-
*/
|
|
89
|
-
export default [ v1, ...initialDeprecations ];
|
package/src/list/v2/edit.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { last } from 'lodash';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import {
|
|
10
|
-
BlockControls,
|
|
11
|
-
useBlockProps,
|
|
12
|
-
useInnerBlocksProps,
|
|
13
|
-
store as blockEditorStore,
|
|
14
|
-
} from '@wordpress/block-editor';
|
|
15
|
-
import { ToolbarButton } from '@wordpress/components';
|
|
16
|
-
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
|
|
17
|
-
import { isRTL, __ } from '@wordpress/i18n';
|
|
18
|
-
import {
|
|
19
|
-
formatListBullets,
|
|
20
|
-
formatListBulletsRTL,
|
|
21
|
-
formatListNumbered,
|
|
22
|
-
formatListNumberedRTL,
|
|
23
|
-
formatOutdent,
|
|
24
|
-
formatOutdentRTL,
|
|
25
|
-
} from '@wordpress/icons';
|
|
26
|
-
import { createBlock } from '@wordpress/blocks';
|
|
27
|
-
import { useCallback, useEffect, Platform } from '@wordpress/element';
|
|
28
|
-
import deprecated from '@wordpress/deprecated';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Internal dependencies
|
|
32
|
-
*/
|
|
33
|
-
import OrderedListSettings from '../ordered-list-settings';
|
|
34
|
-
import { migrateToListV2 } from './migrate';
|
|
35
|
-
import TagName from './tag-name';
|
|
36
|
-
|
|
37
|
-
const TEMPLATE = [ [ 'core/list-item' ] ];
|
|
38
|
-
const NATIVE_MARGIN_SPACING = 8;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* At the moment, deprecations don't handle create blocks from attributes
|
|
42
|
-
* (like when using CPT templates). For this reason, this hook is necessary
|
|
43
|
-
* to avoid breaking templates using the old list block format.
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} attributes Block attributes.
|
|
46
|
-
* @param {string} clientId Block client ID.
|
|
47
|
-
*/
|
|
48
|
-
function useMigrateOnLoad( attributes, clientId ) {
|
|
49
|
-
const registry = useRegistry();
|
|
50
|
-
const { updateBlockAttributes, replaceInnerBlocks } =
|
|
51
|
-
useDispatch( blockEditorStore );
|
|
52
|
-
|
|
53
|
-
useEffect( () => {
|
|
54
|
-
// As soon as the block is loaded, migrate it to the new version.
|
|
55
|
-
|
|
56
|
-
if ( ! attributes.values ) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );
|
|
61
|
-
|
|
62
|
-
deprecated( 'Value attribute on the list block', {
|
|
63
|
-
since: '6.0',
|
|
64
|
-
version: '6.5',
|
|
65
|
-
alternative: 'inner blocks',
|
|
66
|
-
} );
|
|
67
|
-
|
|
68
|
-
registry.batch( () => {
|
|
69
|
-
updateBlockAttributes( clientId, newAttributes );
|
|
70
|
-
replaceInnerBlocks( clientId, newInnerBlocks );
|
|
71
|
-
} );
|
|
72
|
-
}, [ attributes.values ] );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function useOutdentList( clientId ) {
|
|
76
|
-
const { canOutdent } = useSelect(
|
|
77
|
-
( innerSelect ) => {
|
|
78
|
-
const { getBlockRootClientId, getBlock } =
|
|
79
|
-
innerSelect( blockEditorStore );
|
|
80
|
-
const parentId = getBlockRootClientId( clientId );
|
|
81
|
-
return {
|
|
82
|
-
canOutdent:
|
|
83
|
-
!! parentId &&
|
|
84
|
-
getBlock( parentId ).name === 'core/list-item',
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
[ clientId ]
|
|
88
|
-
);
|
|
89
|
-
const { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );
|
|
90
|
-
const { getBlockRootClientId, getBlockAttributes, getBlock } =
|
|
91
|
-
useSelect( blockEditorStore );
|
|
92
|
-
|
|
93
|
-
return [
|
|
94
|
-
canOutdent,
|
|
95
|
-
useCallback( () => {
|
|
96
|
-
const parentBlockId = getBlockRootClientId( clientId );
|
|
97
|
-
const parentBlockAttributes = getBlockAttributes( parentBlockId );
|
|
98
|
-
// Create a new parent block without the inner blocks.
|
|
99
|
-
const newParentBlock = createBlock(
|
|
100
|
-
'core/list-item',
|
|
101
|
-
parentBlockAttributes
|
|
102
|
-
);
|
|
103
|
-
const { innerBlocks } = getBlock( clientId );
|
|
104
|
-
// Replace the parent block with a new parent block without inner blocks,
|
|
105
|
-
// and make the inner blocks siblings of the parent.
|
|
106
|
-
replaceBlocks(
|
|
107
|
-
[ parentBlockId ],
|
|
108
|
-
[ newParentBlock, ...innerBlocks ]
|
|
109
|
-
);
|
|
110
|
-
// Select the last child of the list being outdent.
|
|
111
|
-
selectionChange( last( innerBlocks ).clientId );
|
|
112
|
-
}, [ clientId ] ),
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function IndentUI( { clientId } ) {
|
|
117
|
-
const [ canOutdent, outdentList ] = useOutdentList( clientId );
|
|
118
|
-
return (
|
|
119
|
-
<>
|
|
120
|
-
<ToolbarButton
|
|
121
|
-
icon={ isRTL() ? formatOutdentRTL : formatOutdent }
|
|
122
|
-
title={ __( 'Outdent' ) }
|
|
123
|
-
describedBy={ __( 'Outdent list item' ) }
|
|
124
|
-
disabled={ ! canOutdent }
|
|
125
|
-
onClick={ outdentList }
|
|
126
|
-
/>
|
|
127
|
-
</>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function Edit( { attributes, setAttributes, clientId, style } ) {
|
|
132
|
-
const blockProps = useBlockProps( {
|
|
133
|
-
...( Platform.isNative && { style } ),
|
|
134
|
-
} );
|
|
135
|
-
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
136
|
-
allowedBlocks: [ 'core/list-item' ],
|
|
137
|
-
template: TEMPLATE,
|
|
138
|
-
templateInsertUpdatesSelection: true,
|
|
139
|
-
...( Platform.isNative && {
|
|
140
|
-
marginVertical: NATIVE_MARGIN_SPACING,
|
|
141
|
-
marginHorizontal: NATIVE_MARGIN_SPACING,
|
|
142
|
-
} ),
|
|
143
|
-
} );
|
|
144
|
-
useMigrateOnLoad( attributes, clientId );
|
|
145
|
-
const { ordered, reversed, start } = attributes;
|
|
146
|
-
|
|
147
|
-
const controls = (
|
|
148
|
-
<BlockControls group="block">
|
|
149
|
-
<ToolbarButton
|
|
150
|
-
icon={ isRTL() ? formatListBulletsRTL : formatListBullets }
|
|
151
|
-
title={ __( 'Unordered' ) }
|
|
152
|
-
describedBy={ __( 'Convert to unordered list' ) }
|
|
153
|
-
isActive={ ordered === false }
|
|
154
|
-
onClick={ () => {
|
|
155
|
-
setAttributes( { ordered: false } );
|
|
156
|
-
} }
|
|
157
|
-
/>
|
|
158
|
-
<ToolbarButton
|
|
159
|
-
icon={ isRTL() ? formatListNumberedRTL : formatListNumbered }
|
|
160
|
-
title={ __( 'Ordered' ) }
|
|
161
|
-
describedBy={ __( 'Convert to ordered list' ) }
|
|
162
|
-
isActive={ ordered === true }
|
|
163
|
-
onClick={ () => {
|
|
164
|
-
setAttributes( { ordered: true } );
|
|
165
|
-
} }
|
|
166
|
-
/>
|
|
167
|
-
<IndentUI clientId={ clientId } />
|
|
168
|
-
</BlockControls>
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<>
|
|
173
|
-
<TagName
|
|
174
|
-
ordered={ ordered }
|
|
175
|
-
reversed={ reversed }
|
|
176
|
-
start={ start }
|
|
177
|
-
{ ...innerBlocksProps }
|
|
178
|
-
/>
|
|
179
|
-
{ controls }
|
|
180
|
-
{ ordered && (
|
|
181
|
-
<OrderedListSettings
|
|
182
|
-
setAttributes={ setAttributes }
|
|
183
|
-
ordered={ ordered }
|
|
184
|
-
reversed={ reversed }
|
|
185
|
-
start={ start }
|
|
186
|
-
/>
|
|
187
|
-
) }
|
|
188
|
-
</>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export default Edit;
|
package/src/list/v2/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { list as icon } from '@wordpress/icons';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import edit from './edit';
|
|
10
|
-
import save from './save';
|
|
11
|
-
import transforms from './transforms';
|
|
12
|
-
import deprecated from './deprecated';
|
|
13
|
-
|
|
14
|
-
const settings = {
|
|
15
|
-
icon,
|
|
16
|
-
edit,
|
|
17
|
-
save,
|
|
18
|
-
transforms,
|
|
19
|
-
deprecated,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default settings;
|
package/src/list/v2/save.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
|
|
5
|
-
|
|
6
|
-
export default function save( { attributes } ) {
|
|
7
|
-
const { ordered, reversed, start } = attributes;
|
|
8
|
-
const TagName = ordered ? 'ol' : 'ul';
|
|
9
|
-
return (
|
|
10
|
-
<TagName
|
|
11
|
-
reversed={ reversed }
|
|
12
|
-
start={ start }
|
|
13
|
-
{ ...useBlockProps.save() }
|
|
14
|
-
>
|
|
15
|
-
<InnerBlocks.Content />
|
|
16
|
-
</TagName>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createBlock } from '@wordpress/blocks';
|
|
5
|
-
import { create, split, toHTMLString } from '@wordpress/rich-text';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { createListBlockFromDOMElement } from './migrate';
|
|
11
|
-
|
|
12
|
-
function getListContentSchema( { phrasingContentSchema } ) {
|
|
13
|
-
const listContentSchema = {
|
|
14
|
-
...phrasingContentSchema,
|
|
15
|
-
ul: {},
|
|
16
|
-
ol: { attributes: [ 'type', 'start', 'reversed' ] },
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Recursion is needed.
|
|
20
|
-
// Possible: ul > li > ul.
|
|
21
|
-
// Impossible: ul > ul.
|
|
22
|
-
[ 'ul', 'ol' ].forEach( ( tag ) => {
|
|
23
|
-
listContentSchema[ tag ].children = {
|
|
24
|
-
li: {
|
|
25
|
-
children: listContentSchema,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
} );
|
|
29
|
-
|
|
30
|
-
return listContentSchema;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getListContentFlat( blocks ) {
|
|
34
|
-
return blocks.flatMap( ( { name, attributes, innerBlocks = [] } ) => {
|
|
35
|
-
if ( name === 'core/list-item' ) {
|
|
36
|
-
return [ attributes.content, ...getListContentFlat( innerBlocks ) ];
|
|
37
|
-
}
|
|
38
|
-
return getListContentFlat( innerBlocks );
|
|
39
|
-
} );
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const transforms = {
|
|
43
|
-
from: [
|
|
44
|
-
{
|
|
45
|
-
type: 'block',
|
|
46
|
-
isMultiBlock: true,
|
|
47
|
-
blocks: [ 'core/paragraph', 'core/heading' ],
|
|
48
|
-
transform: ( blockAttributes ) => {
|
|
49
|
-
let childBlocks = [];
|
|
50
|
-
if ( blockAttributes.length > 1 ) {
|
|
51
|
-
childBlocks = blockAttributes.map( ( { content } ) => {
|
|
52
|
-
return createBlock( 'core/list-item', { content } );
|
|
53
|
-
} );
|
|
54
|
-
} else if ( blockAttributes.length === 1 ) {
|
|
55
|
-
const value = create( {
|
|
56
|
-
html: blockAttributes[ 0 ].content,
|
|
57
|
-
} );
|
|
58
|
-
childBlocks = split( value, '\n' ).map( ( result ) => {
|
|
59
|
-
return createBlock( 'core/list-item', {
|
|
60
|
-
content: toHTMLString( { value: result } ),
|
|
61
|
-
} );
|
|
62
|
-
} );
|
|
63
|
-
}
|
|
64
|
-
return createBlock(
|
|
65
|
-
'core/list',
|
|
66
|
-
{
|
|
67
|
-
anchor: blockAttributes.anchor,
|
|
68
|
-
},
|
|
69
|
-
childBlocks
|
|
70
|
-
);
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
...[ '*', '-' ].map( ( prefix ) => ( {
|
|
74
|
-
type: 'prefix',
|
|
75
|
-
prefix,
|
|
76
|
-
transform( content ) {
|
|
77
|
-
return createBlock( 'core/list', {}, [
|
|
78
|
-
createBlock( 'core/list-item', { content } ),
|
|
79
|
-
] );
|
|
80
|
-
},
|
|
81
|
-
} ) ),
|
|
82
|
-
...[ '1.', '1)' ].map( ( prefix ) => ( {
|
|
83
|
-
type: 'prefix',
|
|
84
|
-
prefix,
|
|
85
|
-
transform( content ) {
|
|
86
|
-
return createBlock(
|
|
87
|
-
'core/list',
|
|
88
|
-
{
|
|
89
|
-
ordered: true,
|
|
90
|
-
},
|
|
91
|
-
[ createBlock( 'core/list-item', { content } ) ]
|
|
92
|
-
);
|
|
93
|
-
},
|
|
94
|
-
} ) ),
|
|
95
|
-
{
|
|
96
|
-
type: 'raw',
|
|
97
|
-
selector: 'ol,ul',
|
|
98
|
-
schema: ( args ) => ( {
|
|
99
|
-
ol: getListContentSchema( args ).ol,
|
|
100
|
-
ul: getListContentSchema( args ).ul,
|
|
101
|
-
} ),
|
|
102
|
-
transform: createListBlockFromDOMElement,
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
to: [
|
|
106
|
-
...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {
|
|
107
|
-
type: 'block',
|
|
108
|
-
blocks: [ block ],
|
|
109
|
-
transform: ( _attributes, childBlocks ) => {
|
|
110
|
-
return getListContentFlat( childBlocks ).map( ( content ) =>
|
|
111
|
-
createBlock( block, {
|
|
112
|
-
content,
|
|
113
|
-
} )
|
|
114
|
-
);
|
|
115
|
-
},
|
|
116
|
-
} ) ),
|
|
117
|
-
],
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export default transforms;
|