@@ -15,7 +15,7 @@ import { Autocomplete, PanelBody, PanelColor, withFallbackStyles } from '@wordpr
15
15
*/
16
16
import './editor.scss' ;
17
17
import './style.scss' ;
18
- import { registerBlockType , createBlock , setDefaultBlockName } from '../../api' ;
18
+ import { createBlock } from '../../api' ;
19
19
import { blockAutocompleter , userAutocompleter } from '../../autocompleters' ;
20
20
import AlignmentToolbar from '../../alignment-toolbar' ;
21
21
import BlockAlignmentToolbar from '../../block-alignment-toolbar' ;
@@ -192,97 +192,95 @@ class ParagraphBlock extends Component {
192
192
}
193
193
}
194
194
195
- export const registerParagraphBlock = ( ) => {
196
- registerBlockType ( 'core/paragraph' , {
197
- title : __ ( 'Paragraph' ) ,
195
+ export const name = 'core/paragraph' ;
198
196
199
- description : __ ( 'This is a simple text only block for adding a single paragraph of content.' ) ,
197
+ export const settings = {
198
+ title : __ ( 'Paragraph' ) ,
200
199
201
- icon : 'editor- paragraph' ,
200
+ description : __ ( 'This is a simple text only block for adding a single paragraph of content.' ) ,
202
201
203
- category : 'common ' ,
202
+ icon : 'editor-paragraph ' ,
204
203
205
- keywords : [ __ ( 'text' ) ] ,
204
+ category : 'common' ,
206
205
207
- supports : {
208
- className : false ,
209
- } ,
206
+ keywords : [ __ ( 'text' ) ] ,
210
207
211
- attributes : {
212
- content : {
213
- type : 'array' ,
214
- source : 'children' ,
215
- selector : 'p' ,
216
- } ,
217
- align : {
218
- type : 'string' ,
219
- } ,
220
- dropCap : {
221
- type : 'boolean' ,
222
- default : false ,
223
- } ,
224
- placeholder : {
225
- type : 'string' ,
226
- } ,
227
- width : {
228
- type : 'string' ,
229
- } ,
230
- textColor : {
231
- type : 'string' ,
232
- } ,
233
- backgroundColor : {
234
- type : 'string' ,
235
- } ,
236
- fontSize : {
237
- type : 'number' ,
238
- } ,
239
- } ,
208
+ supports : {
209
+ className : false ,
210
+ } ,
240
211
241
- transforms : {
242
- from : [
243
- {
244
- type : 'raw' ,
245
- isMatch : ( node ) => (
246
- node . nodeName === 'P' &&
247
- // Do not allow embedded content.
248
- ! node . querySelector ( 'audio, canvas, embed, iframe, img, math, object, svg, video' )
249
- ) ,
250
- } ,
251
- ] ,
212
+ attributes : {
213
+ content : {
214
+ type : 'array' ,
215
+ source : 'children' ,
216
+ selector : 'p' ,
252
217
} ,
253
-
254
- merge ( attributes , attributesToMerge ) {
255
- return {
256
- content : concatChildren ( attributes . content , attributesToMerge . content ) ,
257
- } ;
218
+ align : {
219
+ type : 'string' ,
258
220
} ,
259
-
260
- getEditWrapperProps ( attributes ) {
261
- const { width } = attributes ;
262
- if ( [ 'wide' , 'full' , 'left' , 'right' ] . indexOf ( width ) !== - 1 ) {
263
- return { 'data-align' : width } ;
264
- }
221
+ dropCap : {
222
+ type : 'boolean' ,
223
+ default : false ,
224
+ } ,
225
+ placeholder : {
226
+ type : 'string' ,
227
+ } ,
228
+ width : {
229
+ type : 'string' ,
230
+ } ,
231
+ textColor : {
232
+ type : 'string' ,
233
+ } ,
234
+ backgroundColor : {
235
+ type : 'string' ,
236
+ } ,
237
+ fontSize : {
238
+ type : 'number' ,
265
239
} ,
240
+ } ,
266
241
267
- edit : ParagraphBlock ,
242
+ transforms : {
243
+ from : [
244
+ {
245
+ type : 'raw' ,
246
+ isMatch : ( node ) => (
247
+ node . nodeName === 'P' &&
248
+ // Do not allow embedded content.
249
+ ! node . querySelector ( 'audio, canvas, embed, iframe, img, math, object, svg, video' )
250
+ ) ,
251
+ } ,
252
+ ] ,
253
+ } ,
268
254
269
- save ( { attributes } ) {
270
- const { width, align, content, dropCap, backgroundColor, textColor, fontSize } = attributes ;
271
- const className = classnames ( {
272
- [ `align${ width } ` ] : width ,
273
- 'has-background' : backgroundColor ,
274
- 'has-drop-cap' : dropCap ,
275
- } ) ;
276
- const styles = {
277
- backgroundColor : backgroundColor ,
278
- color : textColor ,
279
- fontSize : fontSize ,
280
- textAlign : align ,
281
- } ;
255
+ merge ( attributes , attributesToMerge ) {
256
+ return {
257
+ content : concatChildren ( attributes . content , attributesToMerge . content ) ,
258
+ } ;
259
+ } ,
282
260
283
- return < p style = { styles } className = { className ? className : undefined } > { content } </ p > ;
284
- } ,
285
- } ) ;
261
+ getEditWrapperProps ( attributes ) {
262
+ const { width } = attributes ;
263
+ if ( [ 'wide' , 'full' , 'left' , 'right' ] . indexOf ( width ) !== - 1 ) {
264
+ return { 'data-align' : width } ;
265
+ }
266
+ } ,
267
+
268
+ edit : ParagraphBlock ,
269
+
270
+ save ( { attributes } ) {
271
+ const { width, align, content, dropCap, backgroundColor, textColor, fontSize } = attributes ;
272
+ const className = classnames ( {
273
+ [ `align${ width } ` ] : width ,
274
+ 'has-background' : backgroundColor ,
275
+ 'has-drop-cap' : dropCap ,
276
+ } ) ;
277
+ const styles = {
278
+ backgroundColor : backgroundColor ,
279
+ color : textColor ,
280
+ fontSize : fontSize ,
281
+ textAlign : align ,
282
+ } ;
286
283
287
- setDefaultBlockName ( 'core/paragraph' ) ;
284
+ return < p style = { styles } className = { className ? className : undefined } > { content } </ p > ;
285
+ } ,
288
286
} ;
0 commit comments