-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
index.native.js
162 lines (156 loc) · 3.5 KB
/
index.native.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/**
* External dependencies
*/
import { Platform } from 'react-native';
/**
* WordPress dependencies
*/
import {
registerBlockType,
setDefaultBlockName,
setUnregisteredTypeHandlerName,
setGroupingBlockName,
} from '@wordpress/blocks';
/**
* Internal dependencies
*/
import * as paragraph from './paragraph';
import * as image from './image';
import * as heading from './heading';
import * as quote from './quote';
import * as gallery from './gallery';
import * as archives from './archives';
import * as audio from './audio';
import * as button from './button';
import * as calendar from './calendar';
import * as categories from './categories';
import * as code from './code';
import * as columns from './columns';
import * as column from './column';
import * as cover from './cover';
import * as embed from './embed';
import * as file from './file';
import * as html from './html';
import * as mediaText from './media-text';
import * as latestComments from './latest-comments';
import * as latestPosts from './latest-posts';
import * as list from './list';
import * as missing from './missing';
import * as more from './more';
import * as nextpage from './nextpage';
import * as preformatted from './preformatted';
import * as pullquote from './pullquote';
import * as reusableBlock from './block';
import * as rss from './rss';
import * as search from './search';
import * as separator from './separator';
import * as shortcode from './shortcode';
import * as spacer from './spacer';
import * as subhead from './subhead';
import * as table from './table';
import * as textColumns from './text-columns';
import * as verse from './verse';
import * as video from './video';
import * as tagCloud from './tag-cloud';
import * as group from './group';
export const coreBlocks = [
// Common blocks are grouped at the top to prioritize their display
// in various contexts — like the inserter and auto-complete components.
paragraph,
image,
heading,
gallery,
list,
quote,
// Register all remaining core blocks.
shortcode,
archives,
audio,
button,
calendar,
categories,
code,
columns,
column,
cover,
embed,
...embed.common,
...embed.others,
file,
html,
mediaText,
latestComments,
latestPosts,
missing,
more,
nextpage,
preformatted,
pullquote,
rss,
search,
separator,
reusableBlock,
spacer,
subhead,
table,
tagCloud,
textColumns,
verse,
video,
].reduce( ( accumulator, block ) => {
accumulator[ block.name ] = block;
return accumulator;
}, {} );
/**
* Function to register an individual block.
*
* @param {Object} block The block to be registered.
*
*/
const registerBlock = ( block ) => {
if ( ! block ) {
return;
}
const { metadata, settings, name } = block;
registerBlockType( name, {
...metadata,
...settings,
} );
};
/**
* Function to register core blocks provided by the block editor.
*
* @example
* ```js
* import { registerCoreBlocks } from '@wordpress/block-library';
*
* registerCoreBlocks();
* ```
*/
export const registerCoreBlocks = () => {
[
paragraph,
heading,
code,
missing,
more,
image,
video,
nextpage,
separator,
list,
quote,
mediaText,
// eslint-disable-next-line no-undef
( ( Platform.OS === 'ios' ) || ( !! __DEV__ ) ) ? preformatted : null,
// eslint-disable-next-line no-undef
!! __DEV__ ? group : null,
// eslint-disable-next-line no-undef
!! __DEV__ ? spacer : null,
].forEach( registerBlock );
setDefaultBlockName( paragraph.name );
setUnregisteredTypeHandlerName( missing.name );
if ( group ) {
setGroupingBlockName( group.name );
}
};