1 | import { createElement } from "@wordpress/element";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import deprecated from '@wordpress/deprecated';
|
7 | import { __ } from '@wordpress/i18n';
|
8 | import { Fragment } from '@wordpress/element';
|
9 | import { createBlock } from '@wordpress/blocks';
|
10 | import { RichText, BlockControls, AlignmentToolbar } from '@wordpress/block-editor';
|
11 | import { SVG, Path } from '@wordpress/components';
|
12 | export var name = 'core/subhead';
|
13 | export var settings = {
|
14 | title: __('Subheading (deprecated)'),
|
15 | description: __('This block is deprecated. Please use the Paragraph block instead.'),
|
16 | icon: createElement(SVG, {
|
17 | xmlns: "http://www.w3.org/2000/svg",
|
18 | viewBox: "0 0 24 24"
|
19 | }, createElement(Path, {
|
20 | d: "M7.1 6l-.5 3h4.5L9.4 19h3l1.8-10h4.5l.5-3H7.1z"
|
21 | })),
|
22 | category: 'common',
|
23 | supports: {
|
24 |
|
25 | inserter: false,
|
26 | multiple: false
|
27 | },
|
28 | attributes: {
|
29 | content: {
|
30 | type: 'string',
|
31 | source: 'html',
|
32 | selector: 'p'
|
33 | },
|
34 | align: {
|
35 | type: 'string'
|
36 | }
|
37 | },
|
38 | transforms: {
|
39 | to: [{
|
40 | type: 'block',
|
41 | blocks: ['core/paragraph'],
|
42 | transform: function transform(attributes) {
|
43 | return createBlock('core/paragraph', attributes);
|
44 | }
|
45 | }]
|
46 | },
|
47 | edit: function edit(_ref) {
|
48 | var attributes = _ref.attributes,
|
49 | setAttributes = _ref.setAttributes,
|
50 | className = _ref.className;
|
51 | var align = attributes.align,
|
52 | content = attributes.content,
|
53 | placeholder = attributes.placeholder;
|
54 | deprecated('The Subheading block', {
|
55 | alternative: 'the Paragraph block',
|
56 | plugin: 'Gutenberg'
|
57 | });
|
58 | return createElement(Fragment, null, createElement(BlockControls, null, createElement(AlignmentToolbar, {
|
59 | value: align,
|
60 | onChange: function onChange(nextAlign) {
|
61 | setAttributes({
|
62 | align: nextAlign
|
63 | });
|
64 | }
|
65 | })), createElement(RichText, {
|
66 | tagName: "p",
|
67 | value: content,
|
68 | onChange: function onChange(nextContent) {
|
69 | setAttributes({
|
70 | content: nextContent
|
71 | });
|
72 | },
|
73 | style: {
|
74 | textAlign: align
|
75 | },
|
76 | className: className,
|
77 | placeholder: placeholder || __('Write subheading…')
|
78 | }));
|
79 | },
|
80 | save: function save(_ref2) {
|
81 | var attributes = _ref2.attributes;
|
82 | var align = attributes.align,
|
83 | content = attributes.content;
|
84 | return createElement(RichText.Content, {
|
85 | tagName: "p",
|
86 | style: {
|
87 | textAlign: align
|
88 | },
|
89 | value: content
|
90 | });
|
91 | }
|
92 | };
|
93 |
|
\ | No newline at end of file |