-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.js
219 lines (210 loc) · 5.67 KB
/
index.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/**
* WordPress dependencies
*/
import '@wordpress/core-data';
import '@wordpress/block-editor';
import {
registerBlockType,
setDefaultBlockName,
setFreeformContentHandlerName,
setUnregisteredTypeHandlerName,
setGroupingBlockName,
unstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase
} 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 buttons from './buttons';
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 navigation from './navigation';
import * as navigationLink from './navigation-link';
import * as latestComments from './latest-comments';
import * as latestPosts from './latest-posts';
import * as legacyWidget from './legacy-widget';
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 group from './group';
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 classic from './classic';
import * as socialLinks from './social-links';
import * as socialLink from './social-link';
import * as widgetArea from './widget-area';
// Full Site Editing Blocks
import * as siteTitle from './site-title';
import * as templatePart from './template-part';
import * as query from './query';
import * as queryLoop from './query-loop';
import * as queryPagination from './query-pagination';
import * as postTitle from './post-title';
import * as postContent from './post-content';
import * as postAuthor from './post-author';
import * as postComments from './post-comments';
import * as postCommentsCount from './post-comments-count';
import * as postCommentsForm from './post-comments-form';
import * as postDate from './post-date';
import * as postExcerpt from './post-excerpt';
import * as postFeaturedImage from './post-featured-image';
import * as postTags from './post-tags';
/**
* 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;
if ( metadata ) {
unstable__bootstrapServerSideBlockDefinitions( { [ name ]: metadata } );
}
registerBlockType( name, settings );
};
/**
* Function to register core blocks provided by the block editor.
*
* @example
* ```js
* import { registerCoreBlocks } from '@wordpress/block-library';
*
* registerCoreBlocks();
* ```
*/
export const registerCoreBlocks = () => {
[
// 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,
buttons,
calendar,
categories,
code,
columns,
column,
cover,
embed,
...embed.common,
...embed.others,
file,
group,
window.wp && window.wp.oldEditor ? classic : null, // Only add the classic block in WP Context
html,
mediaText,
latestComments,
latestPosts,
missing,
more,
nextpage,
preformatted,
pullquote,
rss,
search,
separator,
reusableBlock,
socialLinks,
socialLink,
spacer,
subhead,
table,
tagCloud,
textColumns,
verse,
video,
].forEach( registerBlock );
setDefaultBlockName( paragraph.name );
if ( window.wp && window.wp.oldEditor ) {
setFreeformContentHandlerName( classic.name );
}
setUnregisteredTypeHandlerName( missing.name );
setGroupingBlockName( group.name );
};
/**
* Function to register experimental core blocks depending on editor settings.
*
* @param {Object} settings Editor settings.
*
* @example
* ```js
* import { __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
*
* __experimentalRegisterExperimentalCoreBlocks( settings );
* ```
*/
export const __experimentalRegisterExperimentalCoreBlocks =
process.env.GUTENBERG_PHASE === 2
? ( settings ) => {
const {
__experimentalEnableLegacyWidgetBlock,
__experimentalEnableFullSiteEditing,
} = settings;
[
widgetArea,
__experimentalEnableLegacyWidgetBlock ? legacyWidget : null,
navigation,
navigationLink,
// Register Full Site Editing Blocks.
...( __experimentalEnableFullSiteEditing
? [
siteTitle,
templatePart,
query,
queryLoop,
queryPagination,
postTitle,
postContent,
postAuthor,
postComments,
postCommentsCount,
postCommentsForm,
postDate,
postExcerpt,
postFeaturedImage,
postTags,
]
: [] ),
].forEach( registerBlock );
}
: undefined;