@wordpress/block-library 7.11.0 → 7.12.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/CHANGELOG.md +2 -0
- package/build/archives/edit.js +7 -0
- package/build/archives/edit.js.map +1 -1
- package/build/archives/index.js +4 -0
- package/build/archives/index.js.map +1 -1
- package/build/block/edit.js +4 -2
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +4 -2
- package/build/block/edit.native.js.map +1 -1
- package/build/calendar/edit.js +12 -5
- package/build/calendar/edit.js.map +1 -1
- package/build/columns/edit.native.js +2 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/cover/edit/resizable-cover.js +6 -0
- package/build/cover/edit/resizable-cover.js.map +1 -1
- package/build/group/transforms.js +5 -0
- package/build/group/transforms.js.map +1 -1
- package/build/index.native.js +17 -4
- package/build/index.native.js.map +1 -1
- package/build/list/index.js +6 -0
- package/build/list/index.js.map +1 -1
- package/build/list/v2/edit.js +16 -5
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/tag-name.js +31 -0
- package/build/list/v2/tag-name.js.map +1 -0
- package/build/list/v2/tag-name.native.js +32 -0
- package/build/list/v2/tag-name.native.js.map +1 -0
- package/build/list/v2/transforms.js +1 -11
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +1 -0
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +158 -0
- package/build/list-item/edit.native.js.map +1 -0
- package/build/list-item/icons.native.js +53 -0
- package/build/list-item/icons.native.js.map +1 -0
- package/build/list-item/list-style-type.native.js +136 -0
- package/build/list-item/list-style-type.native.js.map +1 -0
- package/build/media-text/deprecated.js +188 -66
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +2 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/media-container.js +1 -1
- package/build/media-text/media-container.js.map +1 -1
- package/build/navigation/edit/index.js +68 -123
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +11 -14
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +4 -2
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +13 -3
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-inner-blocks.js +43 -0
- package/build/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build/navigation/edit/utils.js +28 -0
- package/build/navigation/edit/utils.js.map +1 -0
- package/build/navigation/use-navigation-menu.js +7 -3
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/post-author/edit.js +5 -2
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-biography/edit.js +7 -1
- package/build/post-author-biography/edit.js.map +1 -1
- package/build/post-content/edit.js +4 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +16 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +9 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +42 -9
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +21 -14
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query-title/edit.js +20 -7
- package/build/query-title/edit.js.map +1 -1
- package/build/query-title/index.js +4 -0
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/variations.js +10 -0
- package/build/query-title/variations.js.map +1 -1
- package/build/quote/transforms.js +2 -2
- package/build/quote/transforms.js.map +1 -1
- package/build/separator/edit.js +1 -1
- package/build/separator/edit.js.map +1 -1
- package/build/social-links/edit.js +1 -0
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/index.js +4 -2
- package/build/template-part/edit/index.js.map +1 -1
- package/build-module/archives/edit.js +7 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/archives/index.js +4 -0
- package/build-module/archives/index.js.map +1 -1
- package/build-module/block/edit.js +5 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +5 -3
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/calendar/edit.js +12 -4
- package/build-module/calendar/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +3 -2
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/cover/edit/resizable-cover.js +6 -0
- package/build-module/cover/edit/resizable-cover.js.map +1 -1
- package/build-module/group/transforms.js +5 -0
- package/build-module/group/transforms.js.map +1 -1
- package/build-module/index.native.js +16 -4
- package/build-module/index.native.js.map +1 -1
- package/build-module/list/index.js +1 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/v2/edit.js +15 -5
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/tag-name.js +21 -0
- package/build-module/list/v2/tag-name.js.map +1 -0
- package/build-module/list/v2/tag-name.native.js +21 -0
- package/build-module/list/v2/tag-name.native.js.map +1 -0
- package/build-module/list/v2/transforms.js +1 -10
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +1 -3
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +141 -0
- package/build-module/list-item/edit.native.js.map +1 -0
- package/build-module/list-item/icons.native.js +37 -0
- package/build-module/list-item/icons.native.js.map +1 -0
- package/build-module/list-item/list-style-type.native.js +124 -0
- package/build-module/list-item/list-style-type.native.js.map +1 -0
- package/build-module/media-text/deprecated.js +189 -65
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +2 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/media-container.js +1 -1
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/navigation/edit/index.js +66 -122
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +12 -15
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +4 -2
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +12 -3
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-inner-blocks.js +33 -0
- package/build-module/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build-module/navigation/edit/utils.js +21 -0
- package/build-module/navigation/edit/utils.js.map +1 -0
- package/build-module/navigation/use-navigation-menu.js +7 -3
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/post-author/edit.js +5 -2
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-biography/edit.js +6 -1
- package/build-module/post-author-biography/edit.js.map +1 -1
- package/build-module/post-content/edit.js +5 -3
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +17 -3
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +9 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +42 -9
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +16 -12
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query-title/edit.js +20 -8
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/query-title/index.js +4 -0
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/variations.js +10 -0
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/quote/transforms.js +3 -3
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/separator/edit.js +1 -1
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/social-links/edit.js +1 -0
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +5 -3
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-style/editor-rtl.css +10 -0
- package/build-style/editor.css +10 -0
- package/build-style/latest-posts/editor-rtl.css +3 -0
- package/build-style/latest-posts/editor.css +3 -0
- package/build-style/navigation/style-rtl.css +17 -19
- package/build-style/navigation/style.css +17 -19
- package/build-style/query/editor-rtl.css +7 -0
- package/build-style/query/editor.css +7 -0
- package/build-style/query-pagination/style-rtl.css +6 -0
- package/build-style/query-pagination/style.css +6 -0
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/style-rtl.css +26 -19
- package/build-style/style.css +26 -19
- package/build-style/tag-cloud/style-rtl.css +1 -0
- package/build-style/tag-cloud/style.css +1 -0
- package/package.json +28 -29
- package/src/archives/block.json +4 -0
- package/src/archives/edit.js +12 -1
- package/src/archives/index.php +5 -3
- package/src/audio/test/__snapshots__/edit.native.js.snap +16 -2
- package/src/block/edit.js +4 -4
- package/src/block/edit.native.js +4 -4
- package/src/calendar/edit.js +11 -4
- package/src/columns/edit.native.js +4 -2
- package/src/cover/edit/resizable-cover.js +6 -0
- package/src/cover/index.php +2 -2
- package/src/file/test/__snapshots__/edit.native.js.snap +32 -4
- package/src/group/transforms.js +7 -0
- package/src/home-link/index.php +8 -17
- package/src/image/test/edit.native.js +6 -10
- package/src/index.native.js +15 -2
- package/src/latest-posts/editor.scss +5 -0
- package/src/list/index.js +1 -1
- package/src/list/test/__snapshots__/edit.native.js.snap +133 -0
- package/src/list/test/edit.native.js +511 -7
- package/src/list/v2/edit.js +12 -4
- package/src/list/v2/tag-name.js +13 -0
- package/src/list/v2/tag-name.native.js +12 -0
- package/src/list/v2/transforms.js +1 -9
- package/src/list-item/edit.js +1 -1
- package/src/list-item/edit.native.js +148 -0
- package/src/list-item/icons.native.js +34 -0
- package/src/list-item/list-style-type.native.js +139 -0
- package/src/list-item/style.native.scss +45 -0
- package/src/media-text/deprecated.js +561 -415
- package/src/media-text/edit.js +1 -0
- package/src/media-text/media-container.js +3 -1
- package/src/media-text/test/media-container.js +24 -0
- package/src/navigation/edit/index.js +83 -164
- package/src/navigation/edit/navigation-menu-selector.js +12 -26
- package/src/navigation/edit/placeholder/index.js +4 -2
- package/src/navigation/edit/responsive-wrapper.js +24 -3
- package/src/navigation/edit/use-create-navigation-menu.js +4 -0
- package/src/navigation/edit/use-inner-blocks.js +39 -0
- package/src/navigation/edit/utils.js +30 -0
- package/src/navigation/index.php +6 -0
- package/src/navigation/style.scss +12 -22
- package/src/navigation/use-navigation-menu.js +9 -5
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/index.php +1 -1
- package/src/page-list/index.php +4 -4
- package/src/post-author/edit.js +6 -3
- package/src/post-author-biography/edit.js +4 -1
- package/src/post-content/edit.js +4 -4
- package/src/post-featured-image/block.json +9 -0
- package/src/post-featured-image/edit.js +23 -1
- package/src/post-featured-image/index.php +3 -1
- package/src/post-title/index.php +2 -1
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +16 -2
- package/src/query/edit/inspector-controls/index.js +129 -65
- package/src/query/edit/inspector-controls/taxonomy-controls.js +17 -10
- package/src/query/editor.scss +9 -0
- package/src/query-pagination/style.scss +14 -0
- package/src/query-title/block.json +4 -0
- package/src/query-title/edit.js +33 -6
- package/src/query-title/index.php +17 -1
- package/src/query-title/variations.js +13 -0
- package/src/quote/transforms.js +3 -7
- package/src/search/style.scss +2 -0
- package/src/search/test/__snapshots__/edit.native.js.snap +56 -7
- package/src/separator/edit.js +1 -1
- package/src/separator/test/edit.js +5 -3
- package/src/site-title/index.php +8 -9
- package/src/social-link/index.php +1 -1
- package/src/social-links/edit.js +1 -0
- package/src/tag-cloud/style.scss +1 -0
- package/src/template-part/edit/index.js +4 -4
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import {
|
|
10
|
+
RichText,
|
|
11
|
+
useBlockProps,
|
|
12
|
+
useInnerBlocksProps,
|
|
13
|
+
BlockControls,
|
|
14
|
+
store as blockEditorStore,
|
|
15
|
+
} from '@wordpress/block-editor';
|
|
16
|
+
import { __ } from '@wordpress/i18n';
|
|
17
|
+
import { useSelect } from '@wordpress/data';
|
|
18
|
+
import { useState, useCallback } from '@wordpress/element';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
import { useSplit, useMerge } from './hooks';
|
|
24
|
+
import { convertToListItems } from './utils';
|
|
25
|
+
import { IndentUI } from './edit.js';
|
|
26
|
+
import styles from './style.scss';
|
|
27
|
+
import ListStyleType from './list-style-type';
|
|
28
|
+
|
|
29
|
+
export default function ListItemEdit( {
|
|
30
|
+
attributes,
|
|
31
|
+
setAttributes,
|
|
32
|
+
onReplace,
|
|
33
|
+
clientId,
|
|
34
|
+
style,
|
|
35
|
+
} ) {
|
|
36
|
+
const [ contentWidth, setContentWidth ] = useState();
|
|
37
|
+
const { placeholder, content } = attributes;
|
|
38
|
+
const {
|
|
39
|
+
blockIndex,
|
|
40
|
+
hasInnerBlocks,
|
|
41
|
+
indentationLevel,
|
|
42
|
+
numberOfListItems,
|
|
43
|
+
ordered,
|
|
44
|
+
reversed,
|
|
45
|
+
start,
|
|
46
|
+
} = useSelect(
|
|
47
|
+
( select ) => {
|
|
48
|
+
const {
|
|
49
|
+
getBlockAttributes,
|
|
50
|
+
getBlockCount,
|
|
51
|
+
getBlockIndex,
|
|
52
|
+
getBlockParentsByBlockName,
|
|
53
|
+
getBlockRootClientId,
|
|
54
|
+
} = select( blockEditorStore );
|
|
55
|
+
const currentIdentationLevel = getBlockParentsByBlockName(
|
|
56
|
+
clientId,
|
|
57
|
+
'core/list-item',
|
|
58
|
+
true
|
|
59
|
+
).length;
|
|
60
|
+
const currentBlockIndex = getBlockIndex( clientId );
|
|
61
|
+
const blockWithInnerBlocks = getBlockCount( clientId ) > 0;
|
|
62
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
63
|
+
const blockAttributes = getBlockAttributes( rootClientId );
|
|
64
|
+
const totalListItems = getBlockCount( rootClientId );
|
|
65
|
+
const {
|
|
66
|
+
ordered: isOrdered,
|
|
67
|
+
reversed: isReversed,
|
|
68
|
+
start: startValue,
|
|
69
|
+
} = blockAttributes || {};
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
blockIndex: currentBlockIndex,
|
|
73
|
+
hasInnerBlocks: blockWithInnerBlocks,
|
|
74
|
+
indentationLevel: currentIdentationLevel,
|
|
75
|
+
numberOfListItems: totalListItems,
|
|
76
|
+
ordered: isOrdered,
|
|
77
|
+
reversed: isReversed,
|
|
78
|
+
start: startValue,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
[ clientId ]
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const blockProps = useBlockProps( {
|
|
85
|
+
...( hasInnerBlocks && styles[ 'wp-block-list-item__nested-blocks' ] ),
|
|
86
|
+
} );
|
|
87
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
88
|
+
allowedBlocks: [ 'core/list' ],
|
|
89
|
+
renderAppender: false,
|
|
90
|
+
} );
|
|
91
|
+
|
|
92
|
+
const onSplit = useSplit( clientId );
|
|
93
|
+
const onMerge = useMerge( clientId );
|
|
94
|
+
const onLayout = useCallback( ( { nativeEvent } ) => {
|
|
95
|
+
setContentWidth( ( prevState ) => {
|
|
96
|
+
const { width } = nativeEvent.layout;
|
|
97
|
+
|
|
98
|
+
if ( ! prevState || prevState.width !== width ) {
|
|
99
|
+
return Math.floor( width );
|
|
100
|
+
}
|
|
101
|
+
return prevState;
|
|
102
|
+
} );
|
|
103
|
+
}, [] );
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<View style={ styles[ 'wp-block-list-item__list-item-parent' ] }>
|
|
107
|
+
<View style={ styles[ 'wp-block-list-item__list-item' ] }>
|
|
108
|
+
<View style={ styles[ 'wp-block-list-item__list-item-icon' ] }>
|
|
109
|
+
<ListStyleType
|
|
110
|
+
blockIndex={ blockIndex }
|
|
111
|
+
indentationLevel={ indentationLevel }
|
|
112
|
+
numberOfListItems={ numberOfListItems }
|
|
113
|
+
ordered={ ordered }
|
|
114
|
+
reversed={ reversed }
|
|
115
|
+
start={ start }
|
|
116
|
+
style={ style }
|
|
117
|
+
/>
|
|
118
|
+
</View>
|
|
119
|
+
<View
|
|
120
|
+
style={ styles[ 'wp-block-list-item__list-item-content' ] }
|
|
121
|
+
onLayout={ onLayout }
|
|
122
|
+
>
|
|
123
|
+
<RichText
|
|
124
|
+
identifier="content"
|
|
125
|
+
tagName="p"
|
|
126
|
+
onChange={ ( nextContent ) =>
|
|
127
|
+
setAttributes( { content: nextContent } )
|
|
128
|
+
}
|
|
129
|
+
value={ content }
|
|
130
|
+
placeholder={ placeholder || __( 'List' ) }
|
|
131
|
+
onSplit={ onSplit }
|
|
132
|
+
onMerge={ onMerge }
|
|
133
|
+
onReplace={ ( blocks, ...args ) => {
|
|
134
|
+
onReplace( convertToListItems( blocks ), ...args );
|
|
135
|
+
} }
|
|
136
|
+
style={ style }
|
|
137
|
+
deleteEnter={ true }
|
|
138
|
+
containerWidth={ contentWidth }
|
|
139
|
+
/>
|
|
140
|
+
</View>
|
|
141
|
+
</View>
|
|
142
|
+
<View { ...innerBlocksProps }></View>
|
|
143
|
+
<BlockControls group="block">
|
|
144
|
+
<IndentUI clientId={ clientId } />
|
|
145
|
+
</BlockControls>
|
|
146
|
+
</View>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Rect } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
export const circle = ( size, color ) => (
|
|
7
|
+
<SVG fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8
|
+
<Rect width={ size } height={ size } rx={ size / 2 } fill={ color } />
|
|
9
|
+
</SVG>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const circleOutline = ( size, color ) => (
|
|
13
|
+
<SVG
|
|
14
|
+
width={ size }
|
|
15
|
+
height={ size }
|
|
16
|
+
fill="none"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
>
|
|
19
|
+
<Rect
|
|
20
|
+
x="0.5"
|
|
21
|
+
y="0.5"
|
|
22
|
+
width={ size - 1 }
|
|
23
|
+
height={ size - 1 }
|
|
24
|
+
rx={ size / 2 }
|
|
25
|
+
stroke={ color }
|
|
26
|
+
/>
|
|
27
|
+
</SVG>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const square = ( size, color ) => (
|
|
31
|
+
<SVG fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
32
|
+
<Rect width={ size } height={ size } fill={ color } />
|
|
33
|
+
</SVG>
|
|
34
|
+
);
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { View, Text } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Icon } from '@wordpress/components';
|
|
10
|
+
import { Platform } from '@wordpress/element';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import styles from './style.scss';
|
|
16
|
+
import { circle, circleOutline, square } from './icons';
|
|
17
|
+
|
|
18
|
+
const DEFAULT_ICON_SIZE = 6;
|
|
19
|
+
|
|
20
|
+
function getListNumberIndex( start, blockIndex, reversed, numberOfListItems ) {
|
|
21
|
+
if ( start ) {
|
|
22
|
+
return reversed
|
|
23
|
+
? numberOfListItems - 1 + start - blockIndex
|
|
24
|
+
: start + blockIndex;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if ( reversed ) {
|
|
28
|
+
return numberOfListItems - blockIndex;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return blockIndex + 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function OrderedList( {
|
|
35
|
+
blockIndex,
|
|
36
|
+
color,
|
|
37
|
+
fontSize,
|
|
38
|
+
numberOfListItems,
|
|
39
|
+
reversed,
|
|
40
|
+
start,
|
|
41
|
+
style,
|
|
42
|
+
} ) {
|
|
43
|
+
const orderedStyles = [
|
|
44
|
+
styles[ 'wp-block-list-item__list-item-container--ordered' ],
|
|
45
|
+
Platform.isIOS &&
|
|
46
|
+
styles[ 'wp-block-list-item__list-item-ordered--default' ],
|
|
47
|
+
Platform.isIOS &&
|
|
48
|
+
style?.fontSize &&
|
|
49
|
+
styles[ 'wp-block-list-item__list-item-ordered--custom' ],
|
|
50
|
+
];
|
|
51
|
+
const numberStyle = [ { fontSize, color } ];
|
|
52
|
+
|
|
53
|
+
const currentIndex = getListNumberIndex(
|
|
54
|
+
start,
|
|
55
|
+
blockIndex,
|
|
56
|
+
reversed,
|
|
57
|
+
numberOfListItems
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View style={ orderedStyles }>
|
|
62
|
+
<Text style={ numberStyle }>{ currentIndex }.</Text>
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function IconList( { fontSize, color, defaultFontSize, indentationLevel } ) {
|
|
68
|
+
const iconSize = parseInt(
|
|
69
|
+
( fontSize * DEFAULT_ICON_SIZE ) / defaultFontSize,
|
|
70
|
+
10
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
let listIcon = circle( iconSize, color );
|
|
74
|
+
if ( indentationLevel === 1 ) {
|
|
75
|
+
listIcon = circleOutline( iconSize, color );
|
|
76
|
+
} else if ( indentationLevel > 1 ) {
|
|
77
|
+
listIcon = square( iconSize, color );
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const listStyles = [
|
|
81
|
+
styles[ 'wp-block-list-item__list-item-container' ],
|
|
82
|
+
{ marginTop: fontSize / 2 },
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<View style={ listStyles }>
|
|
87
|
+
<Icon icon={ listIcon } size={ iconSize } />
|
|
88
|
+
</View>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default function ListStyleType( {
|
|
93
|
+
blockIndex,
|
|
94
|
+
indentationLevel,
|
|
95
|
+
numberOfListItems,
|
|
96
|
+
ordered,
|
|
97
|
+
reversed,
|
|
98
|
+
start,
|
|
99
|
+
style,
|
|
100
|
+
} ) {
|
|
101
|
+
let defaultFontSize =
|
|
102
|
+
styles[ 'wp-block-list-item__list-item--default' ].fontSize;
|
|
103
|
+
|
|
104
|
+
if ( style?.baseColors?.typography?.fontSize ) {
|
|
105
|
+
defaultFontSize = parseInt( style.baseColors.typography.fontSize, 10 );
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const fontSize = parseInt(
|
|
109
|
+
style?.fontSize ? style.fontSize : defaultFontSize,
|
|
110
|
+
10
|
|
111
|
+
);
|
|
112
|
+
const defaultColor = style?.baseColors?.color?.text
|
|
113
|
+
? style.baseColors.color.text
|
|
114
|
+
: styles[ 'wp-block-list-item__list-item--default' ].color;
|
|
115
|
+
const color = style?.color ? style.color : defaultColor;
|
|
116
|
+
|
|
117
|
+
if ( ordered ) {
|
|
118
|
+
return (
|
|
119
|
+
<OrderedList
|
|
120
|
+
blockIndex={ blockIndex }
|
|
121
|
+
color={ color }
|
|
122
|
+
fontSize={ fontSize }
|
|
123
|
+
numberOfListItems={ numberOfListItems }
|
|
124
|
+
reversed={ reversed }
|
|
125
|
+
start={ start }
|
|
126
|
+
style={ style }
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<IconList
|
|
133
|
+
color={ color }
|
|
134
|
+
defaultFontSize={ defaultFontSize }
|
|
135
|
+
fontSize={ fontSize }
|
|
136
|
+
indentationLevel={ indentationLevel }
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.wp-block-list-item__list-item-parent {
|
|
2
|
+
margin-left: $solid-border-space;
|
|
3
|
+
margin-right: $solid-border-space;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.wp-block-list-item__nested-blocks {
|
|
7
|
+
margin-top: 14;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.wp-block-list-item__list-item {
|
|
11
|
+
flex: 1;
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.wp-block-list-item__list-item-icon {
|
|
16
|
+
align-items: center;
|
|
17
|
+
flex-grow: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.wp-block-list-item__list-item-content {
|
|
21
|
+
flex-grow: 1;
|
|
22
|
+
flex-shrink: 1;
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.wp-block-list-item__list-item--default {
|
|
27
|
+
color: $black;
|
|
28
|
+
font-size: $editor-font-size;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.wp-block-list-item__list-item-ordered--default {
|
|
32
|
+
margin-top: 2;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.wp-block-list-item__list-item-ordered--custom {
|
|
36
|
+
margin-top: 3;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.wp-block-list-item__list-item-container--ordered {
|
|
40
|
+
margin-right: 3;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.wp-block-list-item__list-item-container {
|
|
44
|
+
margin-right: 8;
|
|
45
|
+
}
|