@wordpress/block-library 9.33.1-next.b8c8708f3.0 → 9.33.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 +1 -1
- package/README.md +1 -1
- package/build/breadcrumbs/block.json +8 -2
- package/build/breadcrumbs/edit.js +113 -12
- package/build/breadcrumbs/edit.js.map +2 -2
- package/build/buttons/transforms.js +7 -7
- package/build/buttons/transforms.js.map +2 -2
- package/build/code/transforms.js +19 -15
- package/build/code/transforms.js.map +2 -2
- package/build/heading/index.js +1 -3
- package/build/heading/index.js.map +3 -3
- package/build/heading/transforms.js +22 -20
- package/build/heading/transforms.js.map +2 -2
- package/build/index.js +5 -1
- package/build/index.js.map +2 -2
- package/build/math/block.json +21 -0
- package/build/math/edit.js +132 -0
- package/build/math/edit.js.map +7 -0
- package/build/math/index.js +63 -0
- package/build/math/index.js.map +7 -0
- package/build/math/init.js +35 -0
- package/build/math/init.js.map +7 -0
- package/build/math/save.js +40 -0
- package/build/math/save.js.map +7 -0
- package/build/navigation/edit/menu-inspector-controls.js +3 -3
- package/build/navigation/edit/menu-inspector-controls.js.map +2 -2
- package/build/navigation-link/edit.js +6 -3
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/link-ui/index.js +1 -1
- package/build/navigation-link/link-ui/index.js.map +2 -2
- package/build/navigation-link/shared/controls.js +4 -1
- package/build/navigation-link/shared/controls.js.map +3 -3
- package/build/navigation-link/shared/index.js +2 -0
- package/build/navigation-link/shared/index.js.map +2 -2
- package/build/navigation-link/shared/update-attributes.js +3 -1
- package/build/navigation-link/shared/update-attributes.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +46 -13
- package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build/navigation-submenu/edit.js +6 -3
- package/build/navigation-submenu/edit.js.map +2 -2
- package/build/page-list/use-convert-to-navigation-links.js +6 -1
- package/build/page-list/use-convert-to-navigation-links.js.map +2 -2
- package/build/paragraph/index.js +1 -3
- package/build/paragraph/index.js.map +3 -3
- package/build/post-date/deprecated.js +98 -2
- package/build/post-date/deprecated.js.map +2 -2
- package/build/post-date/edit.js +1 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/variations.js +4 -4
- package/build/post-date/variations.js.map +2 -2
- package/build/term-template/edit.js +4 -1
- package/build/term-template/edit.js.map +2 -2
- package/build/utils/get-transformed-attributes.js +82 -0
- package/build/utils/get-transformed-attributes.js.map +7 -0
- package/build-module/breadcrumbs/block.json +8 -2
- package/build-module/breadcrumbs/edit.js +117 -14
- package/build-module/breadcrumbs/edit.js.map +2 -2
- package/build-module/buttons/transforms.js +7 -7
- package/build-module/buttons/transforms.js.map +2 -2
- package/build-module/code/transforms.js +19 -15
- package/build-module/code/transforms.js.map +2 -2
- package/build-module/heading/index.js +1 -3
- package/build-module/heading/index.js.map +2 -2
- package/build-module/heading/transforms.js +22 -20
- package/build-module/heading/transforms.js.map +2 -2
- package/build-module/index.js +5 -1
- package/build-module/index.js.map +2 -2
- package/build-module/math/block.json +21 -0
- package/build-module/math/edit.js +110 -0
- package/build-module/math/edit.js.map +7 -0
- package/build-module/math/index.js +26 -0
- package/build-module/math/index.js.map +7 -0
- package/build-module/math/init.js +8 -0
- package/build-module/math/init.js.map +7 -0
- package/build-module/math/save.js +20 -0
- package/build-module/math/save.js.map +7 -0
- package/build-module/navigation/edit/menu-inspector-controls.js +3 -3
- package/build-module/navigation/edit/menu-inspector-controls.js.map +2 -2
- package/build-module/navigation-link/edit.js +6 -3
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/link-ui/index.js +1 -1
- package/build-module/navigation-link/link-ui/index.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +4 -1
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/index.js +5 -1
- package/build-module/navigation-link/shared/index.js.map +2 -2
- package/build-module/navigation-link/shared/update-attributes.js +3 -1
- package/build-module/navigation-link/shared/update-attributes.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +45 -13
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/navigation-submenu/edit.js +6 -3
- package/build-module/navigation-submenu/edit.js.map +2 -2
- package/build-module/page-list/use-convert-to-navigation-links.js +6 -1
- package/build-module/page-list/use-convert-to-navigation-links.js.map +2 -2
- package/build-module/paragraph/index.js +1 -3
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/post-date/deprecated.js +98 -2
- package/build-module/post-date/deprecated.js.map +2 -2
- package/build-module/post-date/edit.js +1 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/variations.js +4 -4
- package/build-module/post-date/variations.js.map +2 -2
- package/build-module/term-template/edit.js +4 -1
- package/build-module/term-template/edit.js.map +2 -2
- package/build-module/utils/get-transformed-attributes.js +58 -0
- package/build-module/utils/get-transformed-attributes.js.map +7 -0
- package/package.json +61 -36
- package/src/breadcrumbs/block.json +8 -2
- package/src/breadcrumbs/edit.js +163 -18
- package/src/breadcrumbs/index.php +118 -16
- package/src/buttons/transforms.js +6 -6
- package/src/code/transforms.js +16 -14
- package/src/heading/index.js +0 -2
- package/src/heading/transforms.js +25 -24
- package/src/index.js +6 -1
- package/src/math/block.json +21 -0
- package/src/math/edit.js +123 -0
- package/src/math/index.js +31 -0
- package/src/math/init.js +4 -0
- package/src/math/save.js +20 -0
- package/src/navigation/edit/menu-inspector-controls.js +8 -7
- package/src/navigation-link/edit.js +6 -3
- package/src/navigation-link/index.php +4 -18
- package/src/navigation-link/link-ui/index.js +4 -2
- package/src/navigation-link/shared/controls.js +12 -3
- package/src/navigation-link/shared/index.js +4 -1
- package/src/navigation-link/shared/test/update-attributes.test.js +8 -0
- package/src/navigation-link/shared/test/use-entity-binding.js +132 -17
- package/src/navigation-link/shared/update-attributes.js +1 -0
- package/src/navigation-link/shared/use-entity-binding.js +74 -19
- package/src/navigation-submenu/edit.js +6 -3
- package/src/navigation-submenu/index.php +3 -17
- package/src/page-list/test/{convert-to-links-modal.js → convert-to-navigation-links.js} +67 -0
- package/src/page-list/use-convert-to-navigation-links.js +11 -1
- package/src/paragraph/index.js +0 -2
- package/src/post-date/deprecated.js +100 -2
- package/src/post-date/edit.js +1 -1
- package/src/post-date/index.php +3 -3
- package/src/post-date/variations.js +5 -4
- package/src/term-template/edit.js +4 -1
- package/src/term-template/index.php +4 -6
- package/src/utils/get-transformed-attributes.js +98 -0
- package/tsconfig.json +1 -0
- package/build/heading/variations.js +0 -48
- package/build/heading/variations.js.map +0 -7
- package/build/paragraph/variations.js +0 -48
- package/build/paragraph/variations.js.map +0 -7
- package/build/utils/get-transformed-metadata.js +0 -59
- package/build/utils/get-transformed-metadata.js.map +0 -7
- package/build-module/heading/variations.js +0 -28
- package/build-module/heading/variations.js.map +0 -7
- package/build-module/paragraph/variations.js +0 -28
- package/build-module/paragraph/variations.js.map +0 -7
- package/build-module/utils/get-transformed-metadata.js +0 -35
- package/build-module/utils/get-transformed-metadata.js.map +0 -7
- package/src/heading/variations.js +0 -29
- package/src/paragraph/variations.js +0 -29
- package/src/utils/get-transformed-metadata.js +0 -60
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ Unlike in [PHP code in the /lib directory](https://github.com/WordPress/gutenber
|
|
|
149
149
|
|
|
150
150
|
There are times, however, when blocks may need to use Gutenberg functions even when a Core-equivalent exists, for example, where a Gutenberg function relies on code that is only available in the plugin.
|
|
151
151
|
|
|
152
|
-
In such cases, you can use the corresponding Core `wp_` function in the block PHP code, and add its name to
|
|
152
|
+
In such cases, you can use the corresponding Core `wp_` function in the block PHP code, and add its name to a list of prefixed functions in the package.json.
|
|
153
153
|
|
|
154
154
|
At build time, Webpack will search for `wp_` functions in that list and replace them with their `gutenberg_` equivalents. This process ensures that the plugin calls the `gutenberg_` functions, but the block will still call the Core `wp_` function when updates are back ported.
|
|
155
155
|
|
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
"apiVersion": 3,
|
|
4
4
|
"name": "core/breadcrumbs",
|
|
5
5
|
"title": "Breadcrumbs",
|
|
6
|
+
"__experimental": true,
|
|
6
7
|
"category": "theme",
|
|
7
|
-
"description": "Display a breadcrumb trail
|
|
8
|
+
"description": "Display a breadcrumb trail for hierarchical post types or based on taxonomy terms.",
|
|
8
9
|
"textdomain": "default",
|
|
9
10
|
"attributes": {
|
|
11
|
+
"type": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"default": "auto",
|
|
14
|
+
"enum": [ "auto", "postWithTerms", "postWithAncestors" ]
|
|
15
|
+
},
|
|
10
16
|
"separator": {
|
|
11
17
|
"type": "string",
|
|
12
18
|
"default": "/"
|
|
@@ -16,7 +22,7 @@
|
|
|
16
22
|
"default": true
|
|
17
23
|
}
|
|
18
24
|
},
|
|
19
|
-
"usesContext": [ "postId", "postType" ],
|
|
25
|
+
"usesContext": [ "postId", "postType", "templateSlug" ],
|
|
20
26
|
"supports": {
|
|
21
27
|
"html": false,
|
|
22
28
|
"spacing": {
|
|
@@ -31,35 +31,99 @@ var import_element = require("@wordpress/element");
|
|
|
31
31
|
var import_server_side_render = require("@wordpress/server-side-render");
|
|
32
32
|
var import_hooks = require("../utils/hooks");
|
|
33
33
|
const separatorDefaultValue = "/";
|
|
34
|
+
const typeDefaultValue = "auto";
|
|
35
|
+
const BREADCRUMB_TYPES = {
|
|
36
|
+
auto: {
|
|
37
|
+
help: (0, import_i18n.__)(
|
|
38
|
+
"Try to automatically determine the best type of breadcrumb for the template."
|
|
39
|
+
)
|
|
40
|
+
},
|
|
41
|
+
postWithAncestors: {
|
|
42
|
+
help: (0, import_i18n.__)(
|
|
43
|
+
"Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types."
|
|
44
|
+
),
|
|
45
|
+
placeholderItems: [(0, import_i18n.__)("Ancestor"), (0, import_i18n.__)("Parent")]
|
|
46
|
+
},
|
|
47
|
+
postWithTerms: {
|
|
48
|
+
help: (0, import_i18n.__)(
|
|
49
|
+
"Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical."
|
|
50
|
+
),
|
|
51
|
+
placeholderItems: [(0, import_i18n.__)("Category")]
|
|
52
|
+
}
|
|
53
|
+
};
|
|
34
54
|
function BreadcrumbEdit({
|
|
35
55
|
attributes,
|
|
36
56
|
setAttributes,
|
|
37
|
-
context: { postId, postType }
|
|
57
|
+
context: { postId, postType, templateSlug }
|
|
38
58
|
}) {
|
|
39
|
-
const { separator, showHomeLink } = attributes;
|
|
40
|
-
const isPostTypeHierarchical = (0, import_data.useSelect)(
|
|
59
|
+
const { separator, showHomeLink, type } = attributes;
|
|
60
|
+
const { post, isPostTypeHierarchical, hasTermsAssigned, isLoading } = (0, import_data.useSelect)(
|
|
41
61
|
(select) => {
|
|
42
62
|
if (!postType) {
|
|
43
|
-
return
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
const _post = select(import_core_data.store).getEntityRecord(
|
|
66
|
+
"postType",
|
|
67
|
+
postType,
|
|
68
|
+
postId
|
|
69
|
+
);
|
|
70
|
+
const postTypeObject = select(import_core_data.store).getPostType(postType);
|
|
71
|
+
const postTypeHasTaxonomies = postTypeObject && postTypeObject.taxonomies.length;
|
|
72
|
+
let taxonomies;
|
|
73
|
+
if (postTypeHasTaxonomies) {
|
|
74
|
+
taxonomies = select(import_core_data.store).getTaxonomies({
|
|
75
|
+
type: postType,
|
|
76
|
+
per_page: -1
|
|
77
|
+
});
|
|
44
78
|
}
|
|
45
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
post: _post,
|
|
81
|
+
isPostTypeHierarchical: postTypeObject?.hierarchical,
|
|
82
|
+
hasTermsAssigned: _post && (taxonomies || []).filter(
|
|
83
|
+
({ visibility }) => visibility?.publicly_queryable
|
|
84
|
+
).some((taxonomy) => {
|
|
85
|
+
return !!_post[taxonomy.rest_base]?.length;
|
|
86
|
+
}),
|
|
87
|
+
isLoading: !_post || !postTypeObject || postTypeHasTaxonomies && !taxonomies
|
|
88
|
+
};
|
|
46
89
|
},
|
|
47
|
-
[postType]
|
|
90
|
+
[postType, postId]
|
|
48
91
|
);
|
|
92
|
+
const [invalidationKey, setInvalidationKey] = (0, import_element.useState)(0);
|
|
93
|
+
(0, import_element.useEffect)(() => {
|
|
94
|
+
setInvalidationKey((c) => c + 1);
|
|
95
|
+
}, [post]);
|
|
49
96
|
const blockProps = (0, import_block_editor.useBlockProps)();
|
|
50
97
|
const dropdownMenuProps = (0, import_hooks.useToolsPanelDropdownMenuProps)();
|
|
51
98
|
const { content } = (0, import_server_side_render.useServerSideRender)({
|
|
52
99
|
attributes,
|
|
53
100
|
skipBlockSupportAttributes: true,
|
|
54
101
|
block: "core/breadcrumbs",
|
|
55
|
-
urlQueryArgs: { post_id: postId }
|
|
102
|
+
urlQueryArgs: { post_id: postId, invalidationKey }
|
|
56
103
|
});
|
|
104
|
+
if (isLoading) {
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Spinner, {}) });
|
|
106
|
+
}
|
|
107
|
+
let breadcrumbsType;
|
|
108
|
+
const isSpecificSupportedTypeSet = [
|
|
109
|
+
"postWithAncestors",
|
|
110
|
+
"postWithTerms"
|
|
111
|
+
].includes(type);
|
|
112
|
+
if (isSpecificSupportedTypeSet) {
|
|
113
|
+
breadcrumbsType = type;
|
|
114
|
+
} else {
|
|
115
|
+
breadcrumbsType = isPostTypeHierarchical ? "postWithAncestors" : "postWithTerms";
|
|
116
|
+
}
|
|
57
117
|
let placeholder = null;
|
|
58
|
-
|
|
118
|
+
const showPlaceholder = !postId || !postType || // When `templateSlug` is set only show placeholder if the post type is not.
|
|
119
|
+
// This is needed because when we are showing the template in post editor we
|
|
120
|
+
// want to show the real breadcrumbs if we have the post type.
|
|
121
|
+
templateSlug && !postType || breadcrumbsType === "postWithAncestors" && !isPostTypeHierarchical || breadcrumbsType === "postWithTerms" && !hasTermsAssigned;
|
|
122
|
+
if (showPlaceholder) {
|
|
59
123
|
const placeholderItems = [
|
|
60
124
|
showHomeLink && (0, import_i18n.__)("Home"),
|
|
61
|
-
|
|
62
|
-
(0, import_i18n.__)("
|
|
125
|
+
// For now if we are adding this in a template show a generic placeholder.
|
|
126
|
+
...templateSlug && !isSpecificSupportedTypeSet ? [(0, import_i18n.__)("Page")] : BREADCRUMB_TYPES[breadcrumbsType].placeholderItems
|
|
63
127
|
].filter(Boolean);
|
|
64
128
|
placeholder = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
65
129
|
"nav",
|
|
@@ -83,11 +147,48 @@ function BreadcrumbEdit({
|
|
|
83
147
|
resetAll: () => {
|
|
84
148
|
setAttributes({
|
|
85
149
|
separator: separatorDefaultValue,
|
|
86
|
-
showHomeLink: true
|
|
150
|
+
showHomeLink: true,
|
|
151
|
+
type: typeDefaultValue
|
|
87
152
|
});
|
|
88
153
|
},
|
|
89
154
|
dropdownMenuProps,
|
|
90
155
|
children: [
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
157
|
+
import_components.__experimentalToolsPanelItem,
|
|
158
|
+
{
|
|
159
|
+
label: (0, import_i18n.__)("Type"),
|
|
160
|
+
isShownByDefault: true,
|
|
161
|
+
hasValue: () => type !== typeDefaultValue,
|
|
162
|
+
onDeselect: () => setAttributes({
|
|
163
|
+
type: typeDefaultValue
|
|
164
|
+
}),
|
|
165
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
|
+
import_components.SelectControl,
|
|
167
|
+
{
|
|
168
|
+
__nextHasNoMarginBottom: true,
|
|
169
|
+
__next40pxDefaultSize: true,
|
|
170
|
+
label: (0, import_i18n.__)("Type"),
|
|
171
|
+
value: type,
|
|
172
|
+
onChange: (value) => setAttributes({ type: value }),
|
|
173
|
+
options: [
|
|
174
|
+
{
|
|
175
|
+
label: (0, import_i18n.__)("Auto"),
|
|
176
|
+
value: "auto"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
label: (0, import_i18n.__)("Post with ancestors"),
|
|
180
|
+
value: "postWithAncestors"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
label: (0, import_i18n.__)("Post with terms"),
|
|
184
|
+
value: "postWithTerms"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
help: BREADCRUMB_TYPES[type].help
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
),
|
|
91
192
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
193
|
import_components.__experimentalToolsPanelItem,
|
|
93
194
|
{
|
|
@@ -140,7 +241,7 @@ function BreadcrumbEdit({
|
|
|
140
241
|
]
|
|
141
242
|
}
|
|
142
243
|
) }),
|
|
143
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockProps, children: placeholder
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockProps, children: showPlaceholder ? placeholder : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element.RawHTML, { inert: "true", children: content }) })
|
|
144
245
|
] });
|
|
145
246
|
}
|
|
146
247
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/breadcrumbs/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { RawHTML } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\nconst separatorDefaultValue = '/';\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType },\n} ) {\n\tconst { separator, showHomeLink } = attributes;\n\tconst isPostTypeHierarchical
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\tSelectControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useState, RawHTML } from '@wordpress/element';\nimport { useServerSideRender } from '@wordpress/server-side-render';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nconst separatorDefaultValue = '/';\nconst typeDefaultValue = 'auto';\n\nconst BREADCRUMB_TYPES = {\n\tauto: {\n\t\thelp: __(\n\t\t\t'Try to automatically determine the best type of breadcrumb for the template.'\n\t\t),\n\t},\n\tpostWithAncestors: {\n\t\thelp: __(\n\t\t\t'Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types.'\n\t\t),\n\t\tplaceholderItems: [ __( 'Ancestor' ), __( 'Parent' ) ],\n\t},\n\tpostWithTerms: {\n\t\thelp: __(\n\t\t\t'Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical.'\n\t\t),\n\t\tplaceholderItems: [ __( 'Category' ) ],\n\t},\n};\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType, templateSlug },\n} ) {\n\tconst { separator, showHomeLink, type } = attributes;\n\tconst { post, isPostTypeHierarchical, hasTermsAssigned, isLoading } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tif ( ! postType ) {\n\t\t\t\t\treturn {};\n\t\t\t\t}\n\t\t\t\tconst _post = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t);\n\t\t\t\tconst postTypeObject =\n\t\t\t\t\tselect( coreStore ).getPostType( postType );\n\t\t\t\tconst postTypeHasTaxonomies =\n\t\t\t\t\tpostTypeObject && postTypeObject.taxonomies.length;\n\t\t\t\tlet taxonomies;\n\t\t\t\tif ( postTypeHasTaxonomies ) {\n\t\t\t\t\ttaxonomies = select( coreStore ).getTaxonomies( {\n\t\t\t\t\t\ttype: postType,\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tpost: _post,\n\t\t\t\t\tisPostTypeHierarchical: postTypeObject?.hierarchical,\n\t\t\t\t\thasTermsAssigned:\n\t\t\t\t\t\t_post &&\n\t\t\t\t\t\t( taxonomies || [] )\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t( { visibility } ) =>\n\t\t\t\t\t\t\t\t\tvisibility?.publicly_queryable\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.some( ( taxonomy ) => {\n\t\t\t\t\t\t\t\treturn !! _post[ taxonomy.rest_base ]?.length;\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\tisLoading:\n\t\t\t\t\t\t! _post ||\n\t\t\t\t\t\t! postTypeObject ||\n\t\t\t\t\t\t( postTypeHasTaxonomies && ! taxonomies ),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ postType, postId ]\n\t\t);\n\n\t// Counter used to cache-bust `useServerSideRender`\n\t//\n\t// This is a catch-all signal to re-render the block when a post's title,\n\t// parent ID, or terms change.\n\t//\n\t// This is fundamentally imperfect, because there are other entities which\n\t// could change in the meantime (the titles of ancestor posts, or the\n\t// labels of taxonomy terms), hence the choice to re-render systematically\n\t// upon saving.\n\tconst [ invalidationKey, setInvalidationKey ] = useState( 0 );\n\tuseEffect( () => {\n\t\tsetInvalidationKey( ( c ) => c + 1 );\n\t}, [ post ] );\n\n\tconst blockProps = useBlockProps();\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst { content } = useServerSideRender( {\n\t\tattributes,\n\t\tskipBlockSupportAttributes: true,\n\t\tblock: 'core/breadcrumbs',\n\t\turlQueryArgs: { post_id: postId, invalidationKey },\n\t} );\n\n\tif ( isLoading ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\t// TODO: this should be handled better when we add more types.\n\tlet breadcrumbsType;\n\tconst isSpecificSupportedTypeSet = [\n\t\t'postWithAncestors',\n\t\t'postWithTerms',\n\t].includes( type );\n\tif ( isSpecificSupportedTypeSet ) {\n\t\tbreadcrumbsType = type;\n\t} else {\n\t\tbreadcrumbsType = isPostTypeHierarchical\n\t\t\t? 'postWithAncestors'\n\t\t\t: 'postWithTerms';\n\t}\n\tlet placeholder = null;\n\t// This is fragile because this block is server side rendered and we'll have to\n\t// update the placeholder html if the server side rendering output changes.\n\tconst showPlaceholder =\n\t\t! postId ||\n\t\t! postType ||\n\t\t// When `templateSlug` is set only show placeholder if the post type is not.\n\t\t// This is needed because when we are showing the template in post editor we\n\t\t// want to show the real breadcrumbs if we have the post type.\n\t\t( templateSlug && ! postType ) ||\n\t\t( breadcrumbsType === 'postWithAncestors' &&\n\t\t\t! isPostTypeHierarchical ) ||\n\t\t( breadcrumbsType === 'postWithTerms' && ! hasTermsAssigned );\n\tif ( showPlaceholder ) {\n\t\tconst placeholderItems = [\n\t\t\tshowHomeLink && __( 'Home' ),\n\t\t\t// For now if we are adding this in a template show a generic placeholder.\n\t\t\t...( templateSlug && ! isSpecificSupportedTypeSet\n\t\t\t\t? [ __( 'Page' ) ]\n\t\t\t\t: BREADCRUMB_TYPES[ breadcrumbsType ].placeholderItems ),\n\t\t].filter( Boolean );\n\t\tplaceholder = (\n\t\t\t<nav\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--separator': `'${ separator }'`,\n\t\t\t\t} }\n\t\t\t\tinert=\"true\"\n\t\t\t>\n\t\t\t\t<ol>\n\t\t\t\t\t{ placeholderItems.map( ( text, index ) => (\n\t\t\t\t\t\t<li key={ index }>\n\t\t\t\t\t\t\t<a href={ `#breadcrumbs-pseudo-link-${ index }` }>\n\t\t\t\t\t\t\t\t{ text }\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) ) }\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<span aria-current=\"page\">{ __( 'Current' ) }</span>\n\t\t\t\t\t</li>\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t);\n\t}\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t\ttype: typeDefaultValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Type' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => type !== typeDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\ttype: typeDefaultValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Type' ) }\n\t\t\t\t\t\t\tvalue={ type }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { type: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Auto' ),\n\t\t\t\t\t\t\t\t\tvalue: 'auto',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Post with ancestors' ),\n\t\t\t\t\t\t\t\t\tvalue: 'postWithAncestors',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Post with terms' ),\n\t\t\t\t\t\t\t\t\tvalue: 'postWithTerms',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\thelp={ BREADCRUMB_TYPES[ type ].help }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => ! showHomeLink }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowHomeLink: true,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Show home link' ) }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHomeLink: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ showHomeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\thasValue={ () => separator !== separatorDefaultValue }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\tlabel={ __( 'Separator' ) }\n\t\t\t\t\t\t\tvalue={ separator }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { separator: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t\t\tif ( ! separator ) {\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tseparator: separatorDefaultValue,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ showPlaceholder ? (\n\t\t\t\t\tplaceholder\n\t\t\t\t) : (\n\t\t\t\t\t<RawHTML inert=\"true\">{ content }</RawHTML>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0HI;AAvHJ,kBAAmB;AACnB,0BAAiD;AACjD,wBAOO;AACP,kBAA0B;AAC1B,uBAAmC;AACnC,qBAA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A;AAAA,cACA,WAAQ,gBAAI,gBAAiB;AAAA,cAC7B,kBAAgB;AAAA,cAChB,UAAW,MAAM,CAAE;AAAA,cACnB,YAAa,MACZ,cAAe;AAAA,gBACd,cAAc;AAAA,cACf,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,WAAQ,gBAAI,gBAAiB;AAAA,kBAC7B,UAAW,CAAE,UACZ,cAAe,EAAE,cAAc,MAAM,CAAE;AAAA,kBAExC,SAAU;AAAA;AAAA,cACX;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC,kBAAAA;AAAA,YAAA;AAAA,cACA,WAAQ,gBAAI,WAAY;AAAA,cACxB,kBAAgB;AAAA,cAChB,UAAW,MAAM,cAAc;AAAA,cAC/B,YAAa,MACZ,cAAe;AAAA,gBACd,WAAW;AAAA,cACZ,CAAE;AAAA,cAGH;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,uBAAqB;AAAA,kBACrB,cAAa;AAAA,kBACb,WAAQ,gBAAI,WAAY;AAAA,kBACxB,OAAQ;AAAA,kBACR,UAAW,CAAE,UACZ,cAAe,EAAE,WAAW,MAAM,CAAE;AAAA,kBAErC,QAAS,MAAM;AACd,wBAAK,CAAE,WAAY;AAClB,oCAAe;AAAA,wBACd,WAAW;AAAA,sBACZ,CAAE;AAAA,oBACH;AAAA,kBACD;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACA,4CAAC,SAAM,GAAG,YACP,4BACD,cAEA,4CAAC,0BAAQ,OAAM,QAAS,mBAAS,GAEnC;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["coreStore", "ToolsPanel", "ToolsPanelItem"]
|
|
7
7
|
}
|
|
@@ -23,7 +23,7 @@ __export(transforms_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(transforms_exports);
|
|
24
24
|
var import_blocks = require("@wordpress/blocks");
|
|
25
25
|
var import_rich_text = require("@wordpress/rich-text");
|
|
26
|
-
var
|
|
26
|
+
var import_get_transformed_attributes = require("../utils/get-transformed-attributes");
|
|
27
27
|
const transforms = {
|
|
28
28
|
from: [
|
|
29
29
|
{
|
|
@@ -56,21 +56,21 @@ const transforms = {
|
|
|
56
56
|
{},
|
|
57
57
|
// Loop the selected buttons.
|
|
58
58
|
buttons.map((attributes) => {
|
|
59
|
-
const { content
|
|
59
|
+
const { content } = attributes;
|
|
60
60
|
const element = (0, import_rich_text.__unstableCreateElement)(document, content);
|
|
61
61
|
const text = element.innerText || "";
|
|
62
62
|
const link = element.querySelector("a");
|
|
63
63
|
const url = link?.getAttribute("href");
|
|
64
64
|
return (0, import_blocks.createBlock)("core/button", {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
metadata: (0, import_get_transformed_metadata.getTransformedMetadata)(
|
|
68
|
-
metadata,
|
|
65
|
+
...(0, import_get_transformed_attributes.getTransformedAttributes)(
|
|
66
|
+
attributes,
|
|
69
67
|
"core/button",
|
|
70
68
|
({ content: contentBinding }) => ({
|
|
71
69
|
text: contentBinding
|
|
72
70
|
})
|
|
73
|
-
)
|
|
71
|
+
),
|
|
72
|
+
text,
|
|
73
|
+
url
|
|
74
74
|
});
|
|
75
75
|
})
|
|
76
76
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/buttons/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { __unstableCreateElement as createElement } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAC5B,uBAAyD;AAKzD,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { __unstableCreateElement as createElement } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedAttributes } from '../utils/get-transformed-attributes';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/button' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) =>\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\tcreateBlock( 'core/button', attributes )\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( buttons ) =>\n\t\t\t\t// Creates the buttons block.\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/buttons',\n\t\t\t\t\t{},\n\t\t\t\t\t// Loop the selected buttons.\n\t\t\t\t\tbuttons.map( ( attributes ) => {\n\t\t\t\t\t\tconst { content } = attributes;\n\t\t\t\t\t\tconst element = createElement( document, content );\n\t\t\t\t\t\t// Remove any HTML tags.\n\t\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\t\t// Get first url.\n\t\t\t\t\t\tconst link = element.querySelector( 'a' );\n\t\t\t\t\t\tconst url = link?.getAttribute( 'href' );\n\t\t\t\t\t\t// Create singular button in the buttons block.\n\t\t\t\t\t\treturn createBlock( 'core/button', {\n\t\t\t\t\t\t\t...getTransformedAttributes(\n\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\t'core/button',\n\t\t\t\t\t\t\t\t( { content: contentBinding } ) => ( {\n\t\t\t\t\t\t\t\t\ttext: contentBinding,\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )\n\t\t\t\t),\n\t\t\tisMatch: ( paragraphs ) => {\n\t\t\t\treturn paragraphs.every( ( attributes ) => {\n\t\t\t\t\tconst element = createElement(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t\tattributes.content\n\t\t\t\t\t);\n\t\t\t\t\tconst text = element.innerText || '';\n\t\t\t\t\tconst links = element.querySelectorAll( 'a' );\n\t\t\t\t\treturn text.length <= 30 && links.length <= 1;\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAC5B,uBAAyD;AAKzD,wCAAyC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,aAAc;AAAA,MACxB,WAAW,CAAE;AAAA;AAAA,YAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ;AAAA,YAAK,CAAE;AAAA;AAAA,kBAEd,2BAAa,eAAe,UAAW;AAAA;AAAA,UACxC;AAAA,QACD;AAAA;AAAA,IACF;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE;AAAA;AAAA,YAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ,IAAK,CAAE,eAAgB;AAC9B,kBAAM,EAAE,QAAQ,IAAI;AACpB,kBAAM,cAAU,iBAAAA,yBAAe,UAAU,OAAQ;AAEjD,kBAAM,OAAO,QAAQ,aAAa;AAElC,kBAAM,OAAO,QAAQ,cAAe,GAAI;AACxC,kBAAM,MAAM,MAAM,aAAc,MAAO;AAEvC,uBAAO,2BAAa,eAAe;AAAA,cAClC,OAAG;AAAA,gBACF;AAAA,gBACA;AAAA,gBACA,CAAE,EAAE,SAAS,eAAe,OAAS;AAAA,kBACpC,MAAM;AAAA,gBACP;AAAA,cACD;AAAA,cACA;AAAA,cACA;AAAA,YACD,CAAE;AAAA,UACH,CAAE;AAAA,QACH;AAAA;AAAA,MACD,SAAS,CAAE,eAAgB;AAC1B,eAAO,WAAW,MAAO,CAAE,eAAgB;AAC1C,gBAAM,cAAU,iBAAAA;AAAA,YACf;AAAA,YACA,WAAW;AAAA,UACZ;AACA,gBAAM,OAAO,QAAQ,aAAa;AAClC,gBAAM,QAAQ,QAAQ,iBAAkB,GAAI;AAC5C,iBAAO,KAAK,UAAU,MAAM,MAAM,UAAU;AAAA,QAC7C,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": ["createElement"]
|
|
7
7
|
}
|
package/build/code/transforms.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(transforms_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(transforms_exports);
|
|
24
24
|
var import_blocks = require("@wordpress/blocks");
|
|
25
25
|
var import_rich_text = require("@wordpress/rich-text");
|
|
26
|
-
var
|
|
26
|
+
var import_get_transformed_attributes = require("../utils/get-transformed-attributes");
|
|
27
27
|
const transforms = {
|
|
28
28
|
from: [
|
|
29
29
|
{
|
|
@@ -34,20 +34,24 @@ const transforms = {
|
|
|
34
34
|
{
|
|
35
35
|
type: "block",
|
|
36
36
|
blocks: ["core/paragraph"],
|
|
37
|
-
transform: (
|
|
38
|
-
content
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
transform: (attributes) => {
|
|
38
|
+
const { content } = attributes;
|
|
39
|
+
return (0, import_blocks.createBlock)("core/code", {
|
|
40
|
+
...(0, import_get_transformed_attributes.getTransformedAttributes)(attributes, "core/code"),
|
|
41
|
+
content
|
|
42
|
+
});
|
|
43
|
+
}
|
|
41
44
|
},
|
|
42
45
|
{
|
|
43
46
|
type: "block",
|
|
44
47
|
blocks: ["core/html"],
|
|
45
|
-
transform: (
|
|
48
|
+
transform: (attributes) => {
|
|
49
|
+
const { content: text } = attributes;
|
|
46
50
|
return (0, import_blocks.createBlock)("core/code", {
|
|
51
|
+
...(0, import_get_transformed_attributes.getTransformedAttributes)(attributes, "core/code"),
|
|
47
52
|
// The HTML is plain text (with plain line breaks), so
|
|
48
53
|
// convert it to rich text.
|
|
49
|
-
content: (0, import_rich_text.toHTMLString)({ value: (0, import_rich_text.create)({ text }) })
|
|
50
|
-
metadata: (0, import_get_transformed_metadata.getTransformedMetadata)(metadata, "core/code")
|
|
54
|
+
content: (0, import_rich_text.toHTMLString)({ value: (0, import_rich_text.create)({ text }) })
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
57
|
},
|
|
@@ -71,13 +75,13 @@ const transforms = {
|
|
|
71
75
|
{
|
|
72
76
|
type: "block",
|
|
73
77
|
blocks: ["core/paragraph"],
|
|
74
|
-
transform: (
|
|
75
|
-
content
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
}
|
|
78
|
+
transform: (attributes) => {
|
|
79
|
+
const { content } = attributes;
|
|
80
|
+
return (0, import_blocks.createBlock)("core/paragraph", {
|
|
81
|
+
...(0, import_get_transformed_attributes.getTransformedAttributes)(attributes, "core/paragraph"),
|
|
82
|
+
content
|
|
83
|
+
});
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
]
|
|
83
87
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/code/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAC5B,uBAAqC;AAKrC,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { getTransformedAttributes } from '../utils/get-transformed-attributes';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'enter',\n\t\t\tregExp: /^```$/,\n\t\t\ttransform: () => createBlock( 'core/code' ),\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content } = attributes;\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/code' ),\n\t\t\t\t\tcontent,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/html' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content: text } = attributes;\n\t\t\t\treturn createBlock( 'core/code', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/code' ),\n\t\t\t\t\t// The HTML is plain text (with plain line breaks), so\n\t\t\t\t\t// convert it to rich text.\n\t\t\t\t\tcontent: toHTMLString( { value: create( { text } ) } ),\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tisMatch: ( node ) =>\n\t\t\t\tnode.nodeName === 'PRE' &&\n\t\t\t\tnode.children.length === 1 &&\n\t\t\t\tnode.firstChild.nodeName === 'CODE',\n\t\t\tschema: {\n\t\t\t\tpre: {\n\t\t\t\t\tchildren: {\n\t\t\t\t\t\tcode: {\n\t\t\t\t\t\t\tchildren: {\n\t\t\t\t\t\t\t\t'#text': {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\tconst { content } = attributes;\n\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t...getTransformedAttributes( attributes, 'core/paragraph' ),\n\t\t\t\t\tcontent,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAC5B,uBAAqC;AAKrC,wCAAyC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW,UAAM,2BAAa,WAAY;AAAA,IAC3C;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,QAAQ,IAAI;AACpB,mBAAO,2BAAa,aAAa;AAAA,UAChC,OAAG,4DAA0B,YAAY,WAAY;AAAA,UACrD;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,WAAY;AAAA,MACtB,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,SAAS,KAAK,IAAI;AAC1B,mBAAO,2BAAa,aAAa;AAAA,UAChC,OAAG,4DAA0B,YAAY,WAAY;AAAA;AAAA;AAAA,UAGrD,aAAS,+BAAc,EAAE,WAAO,yBAAQ,EAAE,KAAK,CAAE,EAAE,CAAE;AAAA,QACtD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,SAAS,CAAE,SACV,KAAK,aAAa,SAClB,KAAK,SAAS,WAAW,KACzB,KAAK,WAAW,aAAa;AAAA,MAC9B,QAAQ;AAAA,QACP,KAAK;AAAA,UACJ,UAAU;AAAA,YACT,MAAM;AAAA,cACL,UAAU;AAAA,gBACT,SAAS,CAAC;AAAA,cACX;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA,EACA,IAAI;AAAA,IACH;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,QAAQ,IAAI;AACpB,mBAAO,2BAAa,kBAAkB;AAAA,UACrC,OAAG,4DAA0B,YAAY,gBAAiB;AAAA,UAC1D;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/heading/index.js
CHANGED
|
@@ -42,7 +42,6 @@ var import_edit = __toESM(require("./edit"));
|
|
|
42
42
|
var import_block = __toESM(require("./block.json"));
|
|
43
43
|
var import_save = __toESM(require("./save"));
|
|
44
44
|
var import_transforms = __toESM(require("./transforms"));
|
|
45
|
-
var import_variations = __toESM(require("./variations"));
|
|
46
45
|
const { name } = import_block.default;
|
|
47
46
|
const settings = {
|
|
48
47
|
icon: import_icons.heading,
|
|
@@ -81,8 +80,7 @@ const settings = {
|
|
|
81
80
|
};
|
|
82
81
|
},
|
|
83
82
|
edit: import_edit.default,
|
|
84
|
-
save: import_save.default
|
|
85
|
-
variations: import_variations.default
|
|
83
|
+
save: import_save.default
|
|
86
84
|
};
|
|
87
85
|
const init = () => (0, import_init_block.default)({ name, metadata: import_block.default, settings });
|
|
88
86
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/heading/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,mBAAgC;AAChC,kBAA4B;AAK5B,wBAAsB;AACtB,wBAAuB;AACvB,kBAAiB;AACjB,mBAAqB;AACrB,kBAAiB;AACjB,wBAAuB;
|
|
6
|
-
"names": ["metadata", "icon", "transforms", "deprecated", "edit", "save", "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { heading as icon } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcontent: __( 'Code is Poetry' ),\n\t\t\tlevel: 2,\n\t\t\ttextAlign: 'center',\n\t\t},\n\t},\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content, level } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'accessibility' ) {\n\t\t\treturn ! hasContent\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. %s: heading level. */\n\t\t\t\t\t\t__( 'Level %s. Empty.' ),\n\t\t\t\t\t\tlevel\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: accessibility text. 1: heading level. 2: heading content. */\n\t\t\t\t\t\t__( 'Level %1$s. %2$s' ),\n\t\t\t\t\t\tlevel,\n\t\t\t\t\t\tcontent\n\t\t\t\t );\n\t\t}\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent:\n\t\t\t\t( attributes.content || '' ) +\n\t\t\t\t( attributesToMerge.content || '' ),\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAGA,mBAAgC;AAChC,kBAA4B;AAK5B,wBAAsB;AACtB,wBAAuB;AACvB,kBAAiB;AACjB,mBAAqB;AACrB,kBAAiB;AACjB,wBAAuB;AAEvB,MAAM,EAAE,KAAK,IAAI,aAAAA;AAIV,MAAM,WAAW;AAAA,EACvB,mBAAAC;AAAA,EACA,SAAS;AAAA,IACR,YAAY;AAAA,MACX,aAAS,gBAAI,gBAAiB;AAAA,MAC9B,OAAO;AAAA,MACP,WAAW;AAAA,IACZ;AAAA,EACD;AAAA,EACA,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,SAAS,MAAM,IAAI;AAE3B,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,iBAAkB;AAClC,aAAO,CAAE,iBACN;AAAA;AAAA,YAEA,gBAAI,kBAAmB;AAAA,QACvB;AAAA,MACA,QACA;AAAA;AAAA,YAEA,gBAAI,kBAAmB;AAAA,QACvB;AAAA,QACA;AAAA,MACA;AAAA,IACJ;AAAA,EACD;AAAA,EACA,8BAAAC;AAAA,EACA,8BAAAC;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,UACG,WAAW,WAAW,OACtB,kBAAkB,WAAW;AAAA,IACjC;AAAA,EACD;AAAA,EACA,kBAAAC;AAAA,EACA,kBAAAC;AACD;AAEO,MAAM,OAAO,UAAM,kBAAAC,SAAW,EAAE,MAAM,uBAAAN,SAAU,SAAS,CAAE;",
|
|
6
|
+
"names": ["metadata", "icon", "transforms", "deprecated", "edit", "save", "initBlock"]
|
|
7
7
|
}
|
|
@@ -23,27 +23,28 @@ __export(transforms_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(transforms_exports);
|
|
24
24
|
var import_blocks = require("@wordpress/blocks");
|
|
25
25
|
var import_shared = require("./shared");
|
|
26
|
-
var
|
|
26
|
+
var import_get_transformed_attributes = require("../utils/get-transformed-attributes");
|
|
27
27
|
const transforms = {
|
|
28
28
|
from: [
|
|
29
29
|
{
|
|
30
30
|
type: "block",
|
|
31
31
|
isMultiBlock: true,
|
|
32
32
|
blocks: ["core/paragraph"],
|
|
33
|
-
transform: (attributes) => attributes.map(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
metadata: (0, import_get_transformed_metadata.getTransformedMetadata)(
|
|
39
|
-
metadata,
|
|
33
|
+
transform: (attributes) => attributes.map((_attributes) => {
|
|
34
|
+
const { content, anchor, align: textAlign } = _attributes;
|
|
35
|
+
return (0, import_blocks.createBlock)("core/heading", {
|
|
36
|
+
...(0, import_get_transformed_attributes.getTransformedAttributes)(
|
|
37
|
+
_attributes,
|
|
40
38
|
"core/heading",
|
|
41
39
|
({ content: contentBinding }) => ({
|
|
42
40
|
content: contentBinding
|
|
43
41
|
})
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
),
|
|
43
|
+
content,
|
|
44
|
+
anchor,
|
|
45
|
+
textAlign
|
|
46
|
+
});
|
|
47
|
+
})
|
|
47
48
|
},
|
|
48
49
|
{
|
|
49
50
|
type: "raw",
|
|
@@ -96,19 +97,20 @@ const transforms = {
|
|
|
96
97
|
type: "block",
|
|
97
98
|
isMultiBlock: true,
|
|
98
99
|
blocks: ["core/paragraph"],
|
|
99
|
-
transform: (attributes) => attributes.map(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
metadata,
|
|
100
|
+
transform: (attributes) => attributes.map((_attributes) => {
|
|
101
|
+
const { content, textAlign: align } = _attributes;
|
|
102
|
+
return (0, import_blocks.createBlock)("core/paragraph", {
|
|
103
|
+
...(0, import_get_transformed_attributes.getTransformedAttributes)(
|
|
104
|
+
_attributes,
|
|
105
105
|
"core/paragraph",
|
|
106
106
|
({ content: contentBinding }) => ({
|
|
107
107
|
content: contentBinding
|
|
108
108
|
})
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
),
|
|
110
|
+
content,
|
|
111
|
+
align
|
|
112
|
+
});
|
|
113
|
+
})
|
|
112
114
|
}
|
|
113
115
|
]
|
|
114
116
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/heading/transforms.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock, getBlockAttributes } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getLevelFromHeadingNodeName } from './shared';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAgD;AAKhD,oBAA4C;AAC5C,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock, getBlockAttributes } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getLevelFromHeadingNodeName } from './shared';\nimport { getTransformedAttributes } from '../utils/get-transformed-attributes';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) =>\n\t\t\t\tattributes.map( ( _attributes ) => {\n\t\t\t\t\tconst { content, anchor, align: textAlign } = _attributes;\n\t\t\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\t\t\t...getTransformedAttributes(\n\t\t\t\t\t\t\t_attributes,\n\t\t\t\t\t\t\t'core/heading',\n\t\t\t\t\t\t\t( { content: contentBinding } ) => ( {\n\t\t\t\t\t\t\t\tcontent: contentBinding,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\tanchor,\n\t\t\t\t\t\ttextAlign,\n\t\t\t\t\t} );\n\t\t\t\t} ),\n\t\t},\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tselector: 'h1,h2,h3,h4,h5,h6',\n\t\t\tschema: ( { phrasingContentSchema, isPaste } ) => {\n\t\t\t\tconst schema = {\n\t\t\t\t\tchildren: phrasingContentSchema,\n\t\t\t\t\tattributes: isPaste ? [] : [ 'style', 'id' ],\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\th1: schema,\n\t\t\t\t\th2: schema,\n\t\t\t\t\th3: schema,\n\t\t\t\t\th4: schema,\n\t\t\t\t\th5: schema,\n\t\t\t\t\th6: schema,\n\t\t\t\t};\n\t\t\t},\n\t\t\ttransform( node ) {\n\t\t\t\tconst attributes = getBlockAttributes(\n\t\t\t\t\t'core/heading',\n\t\t\t\t\tnode.outerHTML\n\t\t\t\t);\n\t\t\t\tconst { textAlign } = node.style || {};\n\n\t\t\t\tattributes.level = getLevelFromHeadingNodeName( node.nodeName );\n\n\t\t\t\tif (\n\t\t\t\t\ttextAlign === 'left' ||\n\t\t\t\t\ttextAlign === 'center' ||\n\t\t\t\t\ttextAlign === 'right'\n\t\t\t\t) {\n\t\t\t\t\tattributes.align = textAlign;\n\t\t\t\t}\n\n\t\t\t\treturn createBlock( 'core/heading', attributes );\n\t\t\t},\n\t\t},\n\t\t...[ 1, 2, 3, 4, 5, 6 ].map( ( level ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix: Array( level + 1 ).join( '#' ),\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\t\tlevel,\n\t\t\t\t\tcontent,\n\t\t\t\t} );\n\t\t\t},\n\t\t} ) ),\n\t\t...[ 1, 2, 3, 4, 5, 6 ].map( ( level ) => ( {\n\t\t\ttype: 'enter',\n\t\t\tregExp: new RegExp( `^/(h|H)${ level }$` ),\n\t\t\ttransform: () => createBlock( 'core/heading', { level } ),\n\t\t} ) ),\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) =>\n\t\t\t\tattributes.map( ( _attributes ) => {\n\t\t\t\t\tconst { content, textAlign: align } = _attributes;\n\t\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t\t...getTransformedAttributes(\n\t\t\t\t\t\t\t_attributes,\n\t\t\t\t\t\t\t'core/paragraph',\n\t\t\t\t\t\t\t( { content: contentBinding } ) => ( {\n\t\t\t\t\t\t\t\tcontent: contentBinding,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcontent,\n\t\t\t\t\t\talign,\n\t\t\t\t\t} );\n\t\t\t\t} ),\n\t\t},\n\t],\n};\n\nexport default transforms;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAgD;AAKhD,oBAA4C;AAC5C,wCAAyC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eACZ,WAAW,IAAK,CAAE,gBAAiB;AAClC,cAAM,EAAE,SAAS,QAAQ,O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AK,CAAE,WAAa;AAAA,MAC3C,MAAM;AAAA,MACN,QAAQ,IAAI,OAAQ,UAAW,KAAM,GAAI;AAAA,MACzC,WAAW,UAAM,2BAAa,gBAAgB,EAAE,MAAM,CAAE;AAAA,IACzD,EAAI;AAAA,EACL;AAAA,EACA,IAAI;AAAA,IACH;AAAA,MACC,MAAM;AAAA,MACN,cAAc;AAAA,MACd,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eACZ,WAAW,IAAK,CAAE,gBAAiB;AAClC,cAAM,EAAE,SAAS,WAAW,MAAM,IAAI;AACtC,mBAAO,2BAAa,kBAAkB;AAAA,UACrC,OAAG;AAAA,YACF;AAAA,YACA;AAAA,YACA,CAAE,EAAE,SAAS,eAAe,OAAS;AAAA,cACpC,SAAS;AAAA,YACV;AAAA,UACD;AAAA,UACA;AAAA,UACA;AAAA,QACD,CAAE;AAAA,MACH,CAAE;AAAA,IACJ;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/index.js
CHANGED
|
@@ -86,6 +86,7 @@ var image = __toESM(require("./image"));
|
|
|
86
86
|
var latestComments = __toESM(require("./latest-comments"));
|
|
87
87
|
var latestPosts = __toESM(require("./latest-posts"));
|
|
88
88
|
var list = __toESM(require("./list"));
|
|
89
|
+
var math = __toESM(require("./math"));
|
|
89
90
|
var listItem = __toESM(require("./list-item"));
|
|
90
91
|
var logInOut = __toESM(require("./loginout"));
|
|
91
92
|
var mediaText = __toESM(require("./media-text"));
|
|
@@ -172,7 +173,6 @@ const getAllBlocks = () => {
|
|
|
172
173
|
accordionPanel,
|
|
173
174
|
archives,
|
|
174
175
|
audio,
|
|
175
|
-
breadcrumbs,
|
|
176
176
|
button,
|
|
177
177
|
buttons,
|
|
178
178
|
calendar,
|
|
@@ -187,6 +187,7 @@ const getAllBlocks = () => {
|
|
|
187
187
|
file,
|
|
188
188
|
group,
|
|
189
189
|
html,
|
|
190
|
+
math,
|
|
190
191
|
latestComments,
|
|
191
192
|
latestPosts,
|
|
192
193
|
mediaText,
|
|
@@ -267,6 +268,9 @@ const getAllBlocks = () => {
|
|
|
267
268
|
queryTitle,
|
|
268
269
|
postAuthorBiography
|
|
269
270
|
];
|
|
271
|
+
if (window?.__experimentalEnableBlockExperiments) {
|
|
272
|
+
blocks.push(breadcrumbs);
|
|
273
|
+
}
|
|
270
274
|
if (window?.__experimentalEnableFormBlocks) {
|
|
271
275
|
blocks.push(form);
|
|
272
276
|
blocks.push(formInput);
|