@wordpress/block-library 8.26.0 → 8.27.1
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/avatar/edit.js +2 -2
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +76 -13
- package/build/block/edit.js.map +1 -1
- package/build/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/build/block/edit.native.js.map +1 -0
- package/build/block/index.js +5 -3
- package/build/block/index.js.map +1 -1
- package/build/button/edit.js +24 -6
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +3 -1
- package/build/button/save.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +13 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit.native.js +1 -0
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/index.js +3 -0
- package/build/cover/index.js.map +1 -1
- package/build/embed/edit.js +3 -2
- package/build/embed/edit.js.map +1 -1
- package/build/file/index.js +0 -1
- package/build/file/index.js.map +1 -1
- package/build/footnotes/edit.js +2 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +17 -19
- package/build/footnotes/format.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +2 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/edit.native.js +141 -0
- package/build/heading/edit.native.js.map +1 -0
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.js +8 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +33 -7
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -3
- package/build/image/index.js.map +1 -1
- package/build/more/index.js +4 -0
- package/build/more/index.js.map +1 -1
- package/build/navigation/edit/index.js +2 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/paragraph/edit.js +2 -1
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +1 -2
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -2
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-content/edit.js +2 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +43 -2
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-navigation-link/index.js +8 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/pullquote/index.js +4 -0
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -3
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +2 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -7
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +1 -2
- package/build/query/index.js.map +1 -1
- package/build/query/variations.js +8 -1
- package/build/query/variations.js.map +1 -1
- package/build/query/view.js +31 -12
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +0 -1
- package/build/search/index.js.map +1 -1
- package/build/table-of-contents/hooks.js +2 -2
- package/build/table-of-contents/hooks.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -4
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +39 -17
- package/build/template-part/edit/index.js.map +1 -1
- package/build/video/edit.native.js +7 -2
- package/build/video/edit.native.js.map +1 -1
- package/build/video/transforms.js +17 -0
- package/build/video/transforms.js.map +1 -1
- package/build-module/avatar/edit.js +2 -2
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +76 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/{v1/edit.native.js → edit.native.js} +3 -3
- package/build-module/block/edit.native.js.map +1 -0
- package/build-module/block/index.js +5 -3
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/edit.js +25 -7
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +4 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +14 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit.native.js +1 -0
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/index.js +3 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/embed/edit.js +3 -2
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/file/index.js +0 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/footnotes/edit.js +2 -1
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +17 -19
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +3 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/edit.native.js +132 -0
- package/build-module/heading/edit.native.js.map +1 -0
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.js +9 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +33 -7
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/more/index.js +4 -0
- package/build-module/more/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -2
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +1 -2
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -2
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +44 -3
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-navigation-link/index.js +8 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/pullquote/index.js +4 -0
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +2 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +7 -8
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +1 -2
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/variations.js +8 -1
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query/view.js +30 -9
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +0 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +2 -2
- package/build-module/table-of-contents/hooks.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -4
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +38 -16
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/video/edit.native.js +7 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/transforms.js +17 -0
- package/build-module/video/transforms.js.map +1 -1
- package/build-style/common-rtl.css +4 -2
- package/build-style/common.css +4 -2
- package/build-style/cover/style-rtl.css +2 -4
- package/build-style/cover/style.css +2 -4
- package/build-style/editor-rtl.css +6 -4
- package/build-style/editor.css +6 -4
- package/build-style/gallery/style-rtl.css +2 -4
- package/build-style/gallery/style.css +2 -4
- package/build-style/image/editor-rtl.css +6 -0
- package/build-style/image/editor.css +6 -0
- package/build-style/page-list/editor-rtl.css +0 -4
- package/build-style/page-list/editor.css +0 -4
- package/build-style/pullquote/style-rtl.css +10 -1
- package/build-style/pullquote/style.css +10 -1
- package/build-style/search/style-rtl.css +2 -1
- package/build-style/search/style.css +2 -1
- package/build-style/style-rtl.css +20 -13
- package/build-style/style.css +20 -13
- package/build-style/video/style-rtl.css +1 -2
- package/build-style/video/style.css +1 -2
- package/package.json +34 -32
- package/src/avatar/edit.js +16 -18
- package/src/block/block.json +3 -0
- package/src/block/edit.js +102 -20
- package/src/block/{v1/edit.native.js → edit.native.js} +4 -4
- package/src/block/index.js +2 -3
- package/src/block/index.php +3 -31
- package/src/button/block.json +1 -0
- package/src/button/edit.js +76 -43
- package/src/button/save.js +3 -0
- package/src/buttons/test/__snapshots__/edit.native.js.snap +6 -0
- package/src/buttons/test/edit.native.js +49 -0
- package/src/cover/block.json +3 -0
- package/src/cover/edit/index.js +2 -1
- package/src/cover/edit/inspector-controls.js +14 -1
- package/src/cover/edit.native.js +1 -0
- package/src/cover/style.scss +2 -3
- package/src/embed/edit.js +3 -2
- package/src/file/block.json +0 -1
- package/src/file/index.php +11 -57
- package/src/footnotes/edit.js +2 -1
- package/src/footnotes/format.js +34 -31
- package/src/footnotes/index.php +20 -11
- package/src/gallery/index.php +0 -3
- package/src/group/block.json +1 -0
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +18 -14
- package/src/heading/edit.native.js +144 -0
- package/src/image/block.json +7 -3
- package/src/image/edit.js +19 -6
- package/src/image/editor.scss +6 -1
- package/src/image/image.js +101 -42
- package/src/image/index.js +6 -0
- package/src/image/index.php +14 -51
- package/src/more/index.js +6 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +2 -2
- package/src/navigation/index.php +777 -28
- package/src/navigation-link/index.php +78 -16
- package/src/page-list/editor.scss +0 -4
- package/src/paragraph/block.json +1 -2
- package/src/paragraph/edit.js +23 -19
- package/src/post-content/edit.js +2 -2
- package/src/post-date/edit.js +38 -33
- package/src/post-navigation-link/block.json +8 -0
- package/src/post-navigation-link/edit.js +63 -1
- package/src/post-navigation-link/index.php +17 -3
- package/src/post-terms/index.php +13 -4
- package/src/pullquote/block.json +4 -0
- package/src/pullquote/style.scss +13 -1
- package/src/query/block.json +1 -2
- package/src/query/edit/inspector-controls/index.js +137 -146
- package/src/query/edit/query-content.js +9 -7
- package/src/query/edit/query-placeholder.js +11 -11
- package/src/query/index.php +33 -71
- package/src/query/variations.js +4 -0
- package/src/query/view.js +24 -19
- package/src/search/block.json +0 -1
- package/src/search/index.php +18 -36
- package/src/table-of-contents/hooks.js +2 -2
- package/src/template-part/edit/advanced-controls.js +2 -3
- package/src/template-part/edit/index.js +77 -50
- package/src/template-part/index.php +2 -2
- package/src/video/edit.native.js +5 -2
- package/src/video/test/edit.native.js +38 -0
- package/src/video/transforms.js +32 -0
- package/tsconfig.json +1 -0
- package/build/block/v1/edit.js +0 -116
- package/build/block/v1/edit.js.map +0 -1
- package/build/block/v1/edit.native.js.map +0 -1
- package/build-module/block/v1/edit.js +0 -108
- package/build-module/block/v1/edit.js.map +0 -1
- package/build-module/block/v1/edit.native.js.map +0 -1
- package/src/block/v1/edit.js +0 -163
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import classnames from 'classnames';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { useEntityBlockEditor, useEntityProp, useEntityRecord } from '@wordpress/core-data';
|
|
11
|
-
import { Placeholder, Spinner, TextControl, PanelBody } from '@wordpress/components';
|
|
12
|
-
import { __ } from '@wordpress/i18n';
|
|
13
|
-
import { useInnerBlocksProps, __experimentalRecursionProvider as RecursionProvider, __experimentalUseHasRecursion as useHasRecursion, InnerBlocks, InspectorControls, useBlockProps, Warning, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
14
|
-
import { useRef, useMemo } from '@wordpress/element';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import { unlock } from '../../lock-unlock';
|
|
20
|
-
const {
|
|
21
|
-
useLayoutClasses
|
|
22
|
-
} = unlock(blockEditorPrivateApis);
|
|
23
|
-
const fullAlignments = ['full', 'wide', 'left', 'right'];
|
|
24
|
-
const useInferredLayout = (blocks, parentLayout) => {
|
|
25
|
-
const initialInferredAlignmentRef = useRef();
|
|
26
|
-
return useMemo(() => {
|
|
27
|
-
// Exit early if the pattern's blocks haven't loaded yet.
|
|
28
|
-
if (!blocks?.length) {
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
let alignment = initialInferredAlignmentRef.current;
|
|
32
|
-
|
|
33
|
-
// Only track the initial alignment so that temporarily removed
|
|
34
|
-
// alignments can be reapplied.
|
|
35
|
-
if (alignment === undefined) {
|
|
36
|
-
const isConstrained = parentLayout?.type === 'constrained';
|
|
37
|
-
const hasFullAlignment = blocks.some(block => fullAlignments.includes(block.attributes.align));
|
|
38
|
-
alignment = isConstrained && hasFullAlignment ? 'full' : null;
|
|
39
|
-
initialInferredAlignmentRef.current = alignment;
|
|
40
|
-
}
|
|
41
|
-
const layout = alignment ? parentLayout : undefined;
|
|
42
|
-
return {
|
|
43
|
-
alignment,
|
|
44
|
-
layout
|
|
45
|
-
};
|
|
46
|
-
}, [blocks, parentLayout]);
|
|
47
|
-
};
|
|
48
|
-
export default function ReusableBlockEdit({
|
|
49
|
-
name,
|
|
50
|
-
attributes: {
|
|
51
|
-
ref
|
|
52
|
-
},
|
|
53
|
-
__unstableParentLayout: parentLayout
|
|
54
|
-
}) {
|
|
55
|
-
const hasAlreadyRendered = useHasRecursion(ref);
|
|
56
|
-
const {
|
|
57
|
-
record,
|
|
58
|
-
hasResolved
|
|
59
|
-
} = useEntityRecord('postType', 'wp_block', ref);
|
|
60
|
-
const isMissing = hasResolved && !record;
|
|
61
|
-
const [blocks, onInput, onChange] = useEntityBlockEditor('postType', 'wp_block', {
|
|
62
|
-
id: ref
|
|
63
|
-
});
|
|
64
|
-
const [title, setTitle] = useEntityProp('postType', 'wp_block', 'title', ref);
|
|
65
|
-
const {
|
|
66
|
-
alignment,
|
|
67
|
-
layout
|
|
68
|
-
} = useInferredLayout(blocks, parentLayout);
|
|
69
|
-
const layoutClasses = useLayoutClasses({
|
|
70
|
-
layout
|
|
71
|
-
}, name);
|
|
72
|
-
const blockProps = useBlockProps({
|
|
73
|
-
className: classnames('block-library-block__reusable-block-container', layout && layoutClasses, {
|
|
74
|
-
[`align${alignment}`]: alignment
|
|
75
|
-
})
|
|
76
|
-
});
|
|
77
|
-
const innerBlocksProps = useInnerBlocksProps(blockProps, {
|
|
78
|
-
value: blocks,
|
|
79
|
-
layout,
|
|
80
|
-
onInput,
|
|
81
|
-
onChange,
|
|
82
|
-
renderAppender: blocks?.length ? undefined : InnerBlocks.ButtonBlockAppender
|
|
83
|
-
});
|
|
84
|
-
let children = null;
|
|
85
|
-
if (hasAlreadyRendered) {
|
|
86
|
-
children = createElement(Warning, null, __('Block cannot be rendered inside itself.'));
|
|
87
|
-
}
|
|
88
|
-
if (isMissing) {
|
|
89
|
-
children = createElement(Warning, null, __('Block has been deleted or is unavailable.'));
|
|
90
|
-
}
|
|
91
|
-
if (!hasResolved) {
|
|
92
|
-
children = createElement(Placeholder, null, createElement(Spinner, null));
|
|
93
|
-
}
|
|
94
|
-
return createElement(RecursionProvider, {
|
|
95
|
-
uniqueId: ref
|
|
96
|
-
}, createElement(InspectorControls, null, createElement(PanelBody, null, createElement(TextControl, {
|
|
97
|
-
label: __('Name'),
|
|
98
|
-
value: title,
|
|
99
|
-
onChange: setTitle,
|
|
100
|
-
__nextHasNoMarginBottom: true,
|
|
101
|
-
__next40pxDefaultSize: true
|
|
102
|
-
}))), children === null ? createElement("div", {
|
|
103
|
-
...innerBlocksProps
|
|
104
|
-
}) : createElement("div", {
|
|
105
|
-
...blockProps
|
|
106
|
-
}, children));
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useEntityBlockEditor","useEntityProp","useEntityRecord","Placeholder","Spinner","TextControl","PanelBody","__","useInnerBlocksProps","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","InnerBlocks","InspectorControls","useBlockProps","Warning","privateApis","blockEditorPrivateApis","useRef","useMemo","unlock","useLayoutClasses","fullAlignments","useInferredLayout","blocks","parentLayout","initialInferredAlignmentRef","length","alignment","current","undefined","isConstrained","type","hasFullAlignment","some","block","includes","attributes","align","layout","ReusableBlockEdit","name","ref","__unstableParentLayout","hasAlreadyRendered","record","hasResolved","isMissing","onInput","onChange","id","title","setTitle","layoutClasses","blockProps","className","innerBlocksProps","value","renderAppender","ButtonBlockAppender","children","createElement","uniqueId","label","__nextHasNoMarginBottom","__next40pxDefaultSize"],"sources":["@wordpress/block-library/src/block/v1/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseEntityBlockEditor,\n\tuseEntityProp,\n\tuseEntityRecord,\n} from '@wordpress/core-data';\nimport {\n\tPlaceholder,\n\tSpinner,\n\tTextControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseInnerBlocksProps,\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseBlockProps,\n\tWarning,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useRef, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useLayoutClasses } = unlock( blockEditorPrivateApis );\nconst fullAlignments = [ 'full', 'wide', 'left', 'right' ];\n\nconst useInferredLayout = ( blocks, parentLayout ) => {\n\tconst initialInferredAlignmentRef = useRef();\n\n\treturn useMemo( () => {\n\t\t// Exit early if the pattern's blocks haven't loaded yet.\n\t\tif ( ! blocks?.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet alignment = initialInferredAlignmentRef.current;\n\n\t\t// Only track the initial alignment so that temporarily removed\n\t\t// alignments can be reapplied.\n\t\tif ( alignment === undefined ) {\n\t\t\tconst isConstrained = parentLayout?.type === 'constrained';\n\t\t\tconst hasFullAlignment = blocks.some( ( block ) =>\n\t\t\t\tfullAlignments.includes( block.attributes.align )\n\t\t\t);\n\n\t\t\talignment = isConstrained && hasFullAlignment ? 'full' : null;\n\t\t\tinitialInferredAlignmentRef.current = alignment;\n\t\t}\n\n\t\tconst layout = alignment ? parentLayout : undefined;\n\n\t\treturn { alignment, layout };\n\t}, [ blocks, parentLayout ] );\n};\n\nexport default function ReusableBlockEdit( {\n\tname,\n\tattributes: { ref },\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\tconst { record, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_block',\n\t\tref\n\t);\n\tconst isMissing = hasResolved && ! record;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ id: ref }\n\t);\n\n\tconst [ title, setTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_block',\n\t\t'title',\n\t\tref\n\t);\n\n\tconst { alignment, layout } = useInferredLayout( blocks, parentLayout );\n\tconst layoutClasses = useLayoutClasses( { layout }, name );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames(\n\t\t\t'block-library-block__reusable-block-container',\n\t\t\tlayout && layoutClasses,\n\t\t\t{ [ `align${ alignment }` ]: alignment }\n\t\t),\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tvalue: blocks,\n\t\tlayout,\n\t\tonInput,\n\t\tonChange,\n\t\trenderAppender: blocks?.length\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t} );\n\n\tlet children = null;\n\n\tif ( hasAlreadyRendered ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\tchildren = (\n\t\t\t<Warning>\n\t\t\t\t{ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\tchildren = (\n\t\t\t<Placeholder>\n\t\t\t\t<Spinner />\n\t\t\t</Placeholder>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ children === null ? (\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t) : (\n\t\t\t\t<div { ...blockProps }>{ children }</div>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,oBAAoB,EACpBC,aAAa,EACbC,eAAe,QACT,sBAAsB;AAC7B,SACCC,WAAW,EACXC,OAAO,EACPC,WAAW,EACXC,SAAS,QACH,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,mBAAmB,EACnBC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,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,CACT;EACF;EAEA,IAAKyC,SAAS,EAAG;IAChBa,QAAQ,GACPC,aAAA,CAAC9C,OAAO,QACLT,EAAE,CAAE,2CAA4C,CAC1C,CACT;EACF;EAEA,IAAK,CAAEwC,WAAW,EAAG;IACpBc,QAAQ,GACPC,aAAA,CAAC3D,WAAW,QACX2D,aAAA,CAAC1D,OAAO,MAAE,CACE,CACb;EACF;EAEA,OACC0D,aAAA,CAACpD,iBAAiB;IAACqD,QAAQ,EAAGpB;EAAK,GAClCmB,aAAA,CAAChD,iBAAiB,QACjBgD,aAAA,CAACxD,SAAS,QACTwD,aAAA,CAACzD,WAAW;IACX2D,KAAK,EAAGzD,EAAE,CAAE,MAAO,CAAG;IACtBmD,KAAK,EAAGN,KAAO;IACfF,QAAQ,EAAGG,QAAU;IACrBY,uBAAuB;IACvBC,qBAAqB;EAAA,CACrB,CACS,CACO,CAAC,EAClBL,QAAQ,KAAK,IAAI,GAClBC,aAAA;IAAA,GAAUL;EAAgB,CAAI,CAAC,GAE/BK,aAAA;IAAA,GAAUP;EAAU,GAAKM,QAAe,CAEvB,CAAC;AAEtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ActivityIndicator","Platform","Text","TouchableWithoutFeedback","View","useState","useCallback","useEntityBlockEditor","useEntityProp","store","coreStore","BottomSheet","Icon","Disabled","TextControl","useSelect","useDispatch","__","sprintf","__experimentalRecursionProvider","RecursionProvider","__experimentalUseHasRecursion","useHasRecursion","InnerBlocks","Warning","blockEditorStore","usePreferredColorSchemeStyle","help","reusableBlocksStore","editorStore","noticesStore","styles","EditTitle","ReusableBlockEdit","attributes","ref","clientId","isSelected","hasAlreadyRendered","showHelp","setShowHelp","infoTextStyle","infoText","infoTextDark","infoTitleStyle","infoTitle","infoTitleDark","infoSheetIconStyle","infoSheetIcon","infoSheetIconDark","infoDescriptionStyle","infoDescription","infoDescriptionDark","actionButtonStyle","actionButton","actionButtonDark","spinnerStyle","spinner","spinnerDark","hasResolved","isEditing","isMissing","select","persistedBlock","getEntityRecord","hasResolvedBlock","hasFinishedResolution","getBlockCount","__experimentalIsEditingReusableBlock","innerBlockCount","hostAppNamespace","getEditorSettings","createSuccessNotice","__experimentalConvertBlockToStatic","convertBlockToStatic","clearSelectedBlock","blocks","onInput","onChange","id","title","openSheet","closeSheet","onConvertToRegularBlocks","successNotice","setImmediate","renderSheet","OS","createElement","isVisible","hideHeader","onClose","style","infoContainer","icon","color","size","label","separatorType","onPress","labelStyle","message","animating","element","value","uniqueId","disabled","accessibilityLabel","accessibilityRole","accessibilityHint"],"sources":["@wordpress/block-library/src/block/v1/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tActivityIndicator,\n\tPlatform,\n\tText,\n\tTouchableWithoutFeedback,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useCallback } from '@wordpress/element';\nimport {\n\tuseEntityBlockEditor,\n\tuseEntityProp,\n\tstore as coreStore,\n} from '@wordpress/core-data';\nimport {\n\tBottomSheet,\n\tIcon,\n\tDisabled,\n\tTextControl,\n} from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__experimentalRecursionProvider as RecursionProvider,\n\t__experimentalUseHasRecursion as useHasRecursion,\n\tInnerBlocks,\n\tWarning,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { help } from '@wordpress/icons';\nimport { store as reusableBlocksStore } from '@wordpress/reusable-blocks';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport styles from '../editor.scss';\nimport EditTitle from '../edit-title';\n\nexport default function ReusableBlockEdit( {\n\tattributes: { ref },\n\tclientId,\n\tisSelected,\n} ) {\n\tconst hasAlreadyRendered = useHasRecursion( ref );\n\n\tconst [ showHelp, setShowHelp ] = useState( false );\n\tconst infoTextStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoText,\n\t\tstyles.infoTextDark\n\t);\n\tconst infoTitleStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoTitle,\n\t\tstyles.infoTitleDark\n\t);\n\tconst infoSheetIconStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoSheetIcon,\n\t\tstyles.infoSheetIconDark\n\t);\n\tconst infoDescriptionStyle = usePreferredColorSchemeStyle(\n\t\tstyles.infoDescription,\n\t\tstyles.infoDescriptionDark\n\t);\n\tconst actionButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.actionButton,\n\t\tstyles.actionButtonDark\n\t);\n\tconst spinnerStyle = usePreferredColorSchemeStyle(\n\t\tstyles.spinner,\n\t\tstyles.spinnerDark\n\t);\n\n\tconst { hasResolved, isEditing, isMissing } = useSelect(\n\t\t( select ) => {\n\t\t\tconst persistedBlock = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_block',\n\t\t\t\tref\n\t\t\t);\n\t\t\tconst hasResolvedBlock = select( coreStore ).hasFinishedResolution(\n\t\t\t\t'getEntityRecord',\n\t\t\t\t[ 'postType', 'wp_block', ref ]\n\t\t\t);\n\n\t\t\tconst { getBlockCount } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\thasResolved: hasResolvedBlock,\n\t\t\t\tisEditing:\n\t\t\t\t\tselect(\n\t\t\t\t\t\treusableBlocksStore\n\t\t\t\t\t).__experimentalIsEditingReusableBlock( clientId ),\n\t\t\t\tisMissing: hasResolvedBlock && ! persistedBlock,\n\t\t\t\tinnerBlockCount: getBlockCount( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ ref, clientId ]\n\t);\n\tconst hostAppNamespace = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditorSettings().hostAppNamespace,\n\t\t[]\n\t);\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_block',\n\t\t{ id: ref }\n\t);\n\n\tconst [ title ] = useEntityProp( 'postType', 'wp_block', 'title', ref );\n\n\tfunction openSheet() {\n\t\tsetShowHelp( true );\n\t}\n\n\tfunction closeSheet() {\n\t\tsetShowHelp( false );\n\t}\n\n\tconst onConvertToRegularBlocks = useCallback( () => {\n\t\t/* translators: %s: name of the synced block */\n\t\tconst successNotice = __( '%s detached' );\n\t\tcreateSuccessNotice( sprintf( successNotice, title ) );\n\n\t\tclearSelectedBlock();\n\t\t// Convert action is executed at the end of the current JavaScript execution block\n\t\t// to prevent issues related to undo/redo actions.\n\t\tsetImmediate( () => convertBlockToStatic( clientId ) );\n\t}, [ title, clientId ] );\n\n\tfunction renderSheet() {\n\t\tconst infoTitle =\n\t\t\tPlatform.OS === 'android'\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: name of the host app (e.g. WordPress) */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Editing synced patterns is not yet supported on %s for Android'\n\t\t\t\t\t\t),\n\t\t\t\t\t\thostAppNamespace\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: name of the host app (e.g. WordPress) */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Editing synced patterns is not yet supported on %s for iOS'\n\t\t\t\t\t\t),\n\t\t\t\t\t\thostAppNamespace\n\t\t\t\t );\n\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ showHelp }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ closeSheet }\n\t\t\t>\n\t\t\t\t<View style={ styles.infoContainer }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ help }\n\t\t\t\t\t\tcolor={ infoSheetIconStyle.color }\n\t\t\t\t\t\tsize={ styles.infoSheetIcon.size }\n\t\t\t\t\t/>\n\t\t\t\t\t<Text style={ [ infoTextStyle, infoTitleStyle ] }>\n\t\t\t\t\t\t{ infoTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<Text style={ [ infoTextStyle, infoDescriptionStyle ] }>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Alternatively, you can detach and edit this block separately by tapping “Detach”.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Detach' ) }\n\t\t\t\t\t\tseparatorType=\"topFullWidth\"\n\t\t\t\t\t\tonPress={ onConvertToRegularBlocks }\n\t\t\t\t\t\tlabelStyle={ actionButtonStyle }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t</BottomSheet>\n\t\t);\n\t}\n\n\tif ( hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tmessage={ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( isMissing ) {\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tmessage={ __( 'Block has been deleted or is unavailable.' ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\tif ( ! hasResolved ) {\n\t\treturn (\n\t\t\t<View style={ spinnerStyle }>\n\t\t\t\t<ActivityIndicator animating />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tlet element = (\n\t\t<InnerBlocks\n\t\t\tvalue={ blocks }\n\t\t\tonChange={ onChange }\n\t\t\tonInput={ onInput }\n\t\t/>\n\t);\n\n\tif ( ! isEditing ) {\n\t\telement = <Disabled>{ element }</Disabled>;\n\t}\n\n\treturn (\n\t\t<RecursionProvider uniqueId={ ref }>\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tdisabled={ ! isSelected }\n\t\t\t\taccessibilityLabel={ __( 'Help button' ) }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityHint={ __( 'Tap here to show help' ) }\n\t\t\t\tonPress={ openSheet }\n\t\t\t>\n\t\t\t\t<View>\n\t\t\t\t\t{ isSelected && <EditTitle title={ title } /> }\n\t\t\t\t\t{ element }\n\t\t\t\t\t{ renderSheet() }\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</RecursionProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,iBAAiB,EACjBC,QAAQ,EACRC,IAAI,EACJC,wBAAwB,EACxBC,IAAI,QACE,cAAc;;AAErB;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;AAC1D,SACCC,oBAAoB,EACpBC,aAAa,EACbC,KAAK,IAAIC,SAAS,QACZ,sBAAsB;AAC7B,SACCC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,WAAW,QACL,uBAAuB;AAC9B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,+BAA+B,IAAIC,iBAAiB,EACpDC,6BAA6B,IAAIC,eAAe,EAChDC,WAAW,EACXC,OAAO,EACPf,KAAK,IAAIgB,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,4BAA4B,QAAQ,oBAAoB;AACjE,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASlB,KAAK,IAAImB,mBAAmB,QAAQ,4BAA4B;AACzE,SAASnB,KAAK,IAAIoB,WAAW,QAAQ,mBAAmB;AACxD,SAASpB,KAAK,IAAIqB,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,OAAOC,MAAM,MAAM,gBAAgB;AACnC,OAAOC,SAAS,MAAM,eAAe;AAErC,eAAe,SAASC,iBAAiBA,CAAE;EAC1CC,UAAU,EAAE;IAAEC;EAAI,CAAC;EACnBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAMC,kBAAkB,GAAGhB,eAAe,CAAEa,GAA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AAG;IACpB,OACC6B,aAAA,CAACpF,IAAI;MAACwF,KAAK,EAAGpC;IAAc,GAC3BgC,aAAA,CAACxF,iBAAiB;MAACsG,SAAS;IAAA,CAAE,CACzB,CAAC;EAET;EAEA,IAAIC,OAAO,GACVf,aAAA,CAACjE,WAAW;IACXiF,KAAK,EAAG5B,MAAQ;IAChBE,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA;EAAS,CACnB,CACD;EAED,IAAK,CAAEjB,SAAS,EAAG;IAClB2C,OAAO,GAAGf,aAAA,CAAC3E,QAAQ,QAAG0F,OAAmB,CAAC;EAC3C;EAEA,OACCf,aAAA,CAACpE,iBAAiB;IAACqF,QAAQ,EAAGtE;EAAK,GAClCqD,aAAA,CAACrF,wBAAwB;IACxBuG,QAAQ,EAAG,CAAErE,UAAY;IACzBsE,kBAAkB,EAAG1F,EAAE,CAAE,aAAc,CAAG;IAC1C2F,iBAAiB,EAAG,QAAU;IAC9BC,iBAAiB,EAAG5F,EAAE,CAAE,uBAAwB,CAAG;IACnDkF,OAAO,EAAGlB;EAAW,GAErBO,aAAA,CAACpF,IAAI,QACFiC,UAAU,IAAImD,aAAA,CAACxD,SAAS;IAACgD,KAAK,EAAGA;EAAO,CAAE,CAAC,EAC3CuB,OAAO,EACPjB,WAAW,CAAC,CACT,CACmB,CACR,CAAC;AAEtB"}
|
package/src/block/v1/edit.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import {
|
|
10
|
-
useEntityBlockEditor,
|
|
11
|
-
useEntityProp,
|
|
12
|
-
useEntityRecord,
|
|
13
|
-
} from '@wordpress/core-data';
|
|
14
|
-
import {
|
|
15
|
-
Placeholder,
|
|
16
|
-
Spinner,
|
|
17
|
-
TextControl,
|
|
18
|
-
PanelBody,
|
|
19
|
-
} from '@wordpress/components';
|
|
20
|
-
import { __ } from '@wordpress/i18n';
|
|
21
|
-
import {
|
|
22
|
-
useInnerBlocksProps,
|
|
23
|
-
__experimentalRecursionProvider as RecursionProvider,
|
|
24
|
-
__experimentalUseHasRecursion as useHasRecursion,
|
|
25
|
-
InnerBlocks,
|
|
26
|
-
InspectorControls,
|
|
27
|
-
useBlockProps,
|
|
28
|
-
Warning,
|
|
29
|
-
privateApis as blockEditorPrivateApis,
|
|
30
|
-
} from '@wordpress/block-editor';
|
|
31
|
-
import { useRef, useMemo } from '@wordpress/element';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Internal dependencies
|
|
35
|
-
*/
|
|
36
|
-
import { unlock } from '../../lock-unlock';
|
|
37
|
-
|
|
38
|
-
const { useLayoutClasses } = unlock( blockEditorPrivateApis );
|
|
39
|
-
const fullAlignments = [ 'full', 'wide', 'left', 'right' ];
|
|
40
|
-
|
|
41
|
-
const useInferredLayout = ( blocks, parentLayout ) => {
|
|
42
|
-
const initialInferredAlignmentRef = useRef();
|
|
43
|
-
|
|
44
|
-
return useMemo( () => {
|
|
45
|
-
// Exit early if the pattern's blocks haven't loaded yet.
|
|
46
|
-
if ( ! blocks?.length ) {
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let alignment = initialInferredAlignmentRef.current;
|
|
51
|
-
|
|
52
|
-
// Only track the initial alignment so that temporarily removed
|
|
53
|
-
// alignments can be reapplied.
|
|
54
|
-
if ( alignment === undefined ) {
|
|
55
|
-
const isConstrained = parentLayout?.type === 'constrained';
|
|
56
|
-
const hasFullAlignment = blocks.some( ( block ) =>
|
|
57
|
-
fullAlignments.includes( block.attributes.align )
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
alignment = isConstrained && hasFullAlignment ? 'full' : null;
|
|
61
|
-
initialInferredAlignmentRef.current = alignment;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const layout = alignment ? parentLayout : undefined;
|
|
65
|
-
|
|
66
|
-
return { alignment, layout };
|
|
67
|
-
}, [ blocks, parentLayout ] );
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default function ReusableBlockEdit( {
|
|
71
|
-
name,
|
|
72
|
-
attributes: { ref },
|
|
73
|
-
__unstableParentLayout: parentLayout,
|
|
74
|
-
} ) {
|
|
75
|
-
const hasAlreadyRendered = useHasRecursion( ref );
|
|
76
|
-
const { record, hasResolved } = useEntityRecord(
|
|
77
|
-
'postType',
|
|
78
|
-
'wp_block',
|
|
79
|
-
ref
|
|
80
|
-
);
|
|
81
|
-
const isMissing = hasResolved && ! record;
|
|
82
|
-
|
|
83
|
-
const [ blocks, onInput, onChange ] = useEntityBlockEditor(
|
|
84
|
-
'postType',
|
|
85
|
-
'wp_block',
|
|
86
|
-
{ id: ref }
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const [ title, setTitle ] = useEntityProp(
|
|
90
|
-
'postType',
|
|
91
|
-
'wp_block',
|
|
92
|
-
'title',
|
|
93
|
-
ref
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const { alignment, layout } = useInferredLayout( blocks, parentLayout );
|
|
97
|
-
const layoutClasses = useLayoutClasses( { layout }, name );
|
|
98
|
-
|
|
99
|
-
const blockProps = useBlockProps( {
|
|
100
|
-
className: classnames(
|
|
101
|
-
'block-library-block__reusable-block-container',
|
|
102
|
-
layout && layoutClasses,
|
|
103
|
-
{ [ `align${ alignment }` ]: alignment }
|
|
104
|
-
),
|
|
105
|
-
} );
|
|
106
|
-
|
|
107
|
-
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
108
|
-
value: blocks,
|
|
109
|
-
layout,
|
|
110
|
-
onInput,
|
|
111
|
-
onChange,
|
|
112
|
-
renderAppender: blocks?.length
|
|
113
|
-
? undefined
|
|
114
|
-
: InnerBlocks.ButtonBlockAppender,
|
|
115
|
-
} );
|
|
116
|
-
|
|
117
|
-
let children = null;
|
|
118
|
-
|
|
119
|
-
if ( hasAlreadyRendered ) {
|
|
120
|
-
children = (
|
|
121
|
-
<Warning>
|
|
122
|
-
{ __( 'Block cannot be rendered inside itself.' ) }
|
|
123
|
-
</Warning>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if ( isMissing ) {
|
|
128
|
-
children = (
|
|
129
|
-
<Warning>
|
|
130
|
-
{ __( 'Block has been deleted or is unavailable.' ) }
|
|
131
|
-
</Warning>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if ( ! hasResolved ) {
|
|
136
|
-
children = (
|
|
137
|
-
<Placeholder>
|
|
138
|
-
<Spinner />
|
|
139
|
-
</Placeholder>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return (
|
|
144
|
-
<RecursionProvider uniqueId={ ref }>
|
|
145
|
-
<InspectorControls>
|
|
146
|
-
<PanelBody>
|
|
147
|
-
<TextControl
|
|
148
|
-
label={ __( 'Name' ) }
|
|
149
|
-
value={ title }
|
|
150
|
-
onChange={ setTitle }
|
|
151
|
-
__nextHasNoMarginBottom
|
|
152
|
-
__next40pxDefaultSize
|
|
153
|
-
/>
|
|
154
|
-
</PanelBody>
|
|
155
|
-
</InspectorControls>
|
|
156
|
-
{ children === null ? (
|
|
157
|
-
<div { ...innerBlocksProps } />
|
|
158
|
-
) : (
|
|
159
|
-
<div { ...blockProps }>{ children }</div>
|
|
160
|
-
) }
|
|
161
|
-
</RecursionProvider>
|
|
162
|
-
);
|
|
163
|
-
}
|