@wordpress/block-library 9.33.2-next.36001005c.0 → 9.34.0
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/accordion/block.json +1 -1
- package/build/accordion/edit.js +11 -9
- package/build/accordion/edit.js.map +2 -2
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-item/block.json +2 -2
- package/build/accordion-panel/block.json +1 -1
- package/build/breadcrumbs/block.json +3 -4
- package/build/breadcrumbs/edit.js +43 -77
- package/build/breadcrumbs/edit.js.map +2 -2
- package/build/buttons/transforms.js +1 -0
- package/build/buttons/transforms.js.map +2 -2
- package/build/categories/edit.js +8 -4
- package/build/categories/edit.js.map +2 -2
- package/build/code/transforms.js +2 -0
- package/build/code/transforms.js.map +2 -2
- package/build/home-link/block.json +2 -1
- package/build/image/view.js +4 -1
- package/build/image/view.js.map +2 -2
- package/build/latest-comments/block.json +4 -3
- package/build/latest-comments/deprecated.js +56 -0
- package/build/latest-comments/deprecated.js.map +7 -0
- package/build/latest-comments/edit.js +16 -10
- package/build/latest-comments/edit.js.map +2 -2
- package/build/latest-comments/index.js +3 -1
- package/build/latest-comments/index.js.map +3 -3
- package/build/math/deprecated.js +54 -0
- package/build/math/deprecated.js.map +7 -0
- package/build/math/edit.js +1 -0
- package/build/math/edit.js.map +2 -2
- package/build/math/index.js +3 -1
- package/build/math/index.js.map +3 -3
- package/build/math/save.js +2 -3
- package/build/math/save.js.map +2 -2
- package/build/navigation/menu-items-to-blocks.js +8 -3
- package/build/navigation/menu-items-to-blocks.js.map +2 -2
- package/build/navigation/view.js +2 -2
- package/build/navigation/view.js.map +2 -2
- package/build/navigation-link/link-ui/page-creator.js +20 -0
- package/build/navigation-link/link-ui/page-creator.js.map +3 -3
- package/build/post-date/block.json +1 -1
- package/build/post-date/edit.js +11 -5
- package/build/post-date/edit.js.map +3 -3
- package/build/post-date/variations.js +4 -7
- package/build/post-date/variations.js.map +2 -2
- package/build/post-template/edit.js +13 -1
- package/build/post-template/edit.js.map +2 -2
- package/build/query/index.js +11 -1
- package/build/query/index.js.map +2 -2
- package/build/query/variations.js +16 -11
- package/build/query/variations.js.map +2 -2
- package/build/search/view.js +4 -4
- package/build/search/view.js.map +2 -2
- package/build/terms-query/edit/inspector-controls/index.js +1 -1
- package/build/terms-query/edit/inspector-controls/index.js.map +2 -2
- package/build/terms-query/edit/inspector-controls/inherit-control.js +2 -4
- package/build/terms-query/edit/inspector-controls/inherit-control.js.map +2 -2
- package/build/utils/get-transformed-attributes.js +1 -10
- package/build/utils/get-transformed-attributes.js.map +2 -2
- package/build-module/accordion/block.json +1 -1
- package/build-module/accordion/edit.js +11 -9
- package/build-module/accordion/edit.js.map +2 -2
- package/build-module/accordion-heading/block.json +1 -1
- package/build-module/accordion-item/block.json +2 -2
- package/build-module/accordion-panel/block.json +1 -1
- package/build-module/breadcrumbs/block.json +3 -4
- package/build-module/breadcrumbs/edit.js +44 -78
- package/build-module/breadcrumbs/edit.js.map +2 -2
- package/build-module/buttons/transforms.js +1 -0
- package/build-module/buttons/transforms.js.map +2 -2
- package/build-module/categories/edit.js +8 -4
- package/build-module/categories/edit.js.map +2 -2
- package/build-module/code/transforms.js +2 -0
- package/build-module/code/transforms.js.map +2 -2
- package/build-module/home-link/block.json +2 -1
- package/build-module/image/view.js +4 -1
- package/build-module/image/view.js.map +2 -2
- package/build-module/latest-comments/block.json +4 -3
- package/build-module/latest-comments/deprecated.js +36 -0
- package/build-module/latest-comments/deprecated.js.map +7 -0
- package/build-module/latest-comments/edit.js +17 -10
- package/build-module/latest-comments/edit.js.map +2 -2
- package/build-module/latest-comments/index.js +3 -1
- package/build-module/latest-comments/index.js.map +2 -2
- package/build-module/math/deprecated.js +34 -0
- package/build-module/math/deprecated.js.map +7 -0
- package/build-module/math/edit.js +1 -0
- package/build-module/math/edit.js.map +2 -2
- package/build-module/math/index.js +3 -1
- package/build-module/math/index.js.map +2 -2
- package/build-module/math/save.js +2 -3
- package/build-module/math/save.js.map +2 -2
- package/build-module/navigation/menu-items-to-blocks.js +8 -3
- package/build-module/navigation/menu-items-to-blocks.js.map +2 -2
- package/build-module/navigation/view.js +2 -2
- package/build-module/navigation/view.js.map +2 -2
- package/build-module/navigation-link/link-ui/page-creator.js +21 -1
- package/build-module/navigation-link/link-ui/page-creator.js.map +2 -2
- package/build-module/post-date/block.json +1 -1
- package/build-module/post-date/edit.js +11 -5
- package/build-module/post-date/edit.js.map +2 -2
- package/build-module/post-date/variations.js +4 -7
- package/build-module/post-date/variations.js.map +2 -2
- package/build-module/post-template/edit.js +13 -1
- package/build-module/post-template/edit.js.map +2 -2
- package/build-module/query/index.js +11 -1
- package/build-module/query/index.js.map +2 -2
- package/build-module/query/variations.js +16 -11
- package/build-module/query/variations.js.map +2 -2
- package/build-module/search/view.js +4 -4
- package/build-module/search/view.js.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/index.js +1 -1
- package/build-module/terms-query/edit/inspector-controls/index.js.map +2 -2
- package/build-module/terms-query/edit/inspector-controls/inherit-control.js +2 -4
- package/build-module/terms-query/edit/inspector-controls/inherit-control.js.map +2 -2
- package/build-module/utils/get-transformed-attributes.js +1 -10
- package/build-module/utils/get-transformed-attributes.js.map +2 -2
- package/build-style/editor-rtl.css +5 -0
- package/build-style/editor.css +6 -0
- package/build-style/math/editor-rtl.css +49 -0
- package/build-style/math/editor.css +50 -0
- package/build-style/math/style-rtl.css +4 -0
- package/build-style/math/style.css +4 -0
- package/build-style/style-rtl.css +5 -0
- package/build-style/style.css +5 -0
- package/package.json +37 -37
- package/src/accordion/block.json +1 -1
- package/src/accordion/edit.js +16 -16
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-item/block.json +2 -2
- package/src/accordion-panel/block.json +1 -1
- package/src/breadcrumbs/block.json +3 -4
- package/src/breadcrumbs/edit.js +96 -132
- package/src/breadcrumbs/index.php +203 -50
- package/src/buttons/transforms.js +1 -0
- package/src/categories/edit.js +10 -6
- package/src/categories/index.php +1 -1
- package/src/code/transforms.js +2 -0
- package/src/editor.scss +1 -0
- package/src/home-link/block.json +2 -1
- package/src/image/index.php +9 -9
- package/src/image/view.js +11 -1
- package/src/latest-comments/block.json +4 -3
- package/src/latest-comments/deprecated.js +37 -0
- package/src/latest-comments/edit.js +17 -10
- package/src/latest-comments/index.js +2 -0
- package/src/latest-comments/index.php +11 -2
- package/src/math/deprecated.js +44 -0
- package/src/math/edit.js +1 -0
- package/src/math/editor.scss +7 -0
- package/src/math/index.js +2 -0
- package/src/math/save.js +6 -5
- package/src/math/style.scss +4 -0
- package/src/navigation/index.php +7 -7
- package/src/navigation/menu-items-to-blocks.js +12 -2
- package/src/navigation/test/menu-items-to-blocks.js +144 -0
- package/src/navigation/view.js +2 -2
- package/src/navigation-link/link-ui/page-creator.js +25 -2
- package/src/post-date/block.json +1 -1
- package/src/post-date/edit.js +15 -10
- package/src/post-date/variations.js +2 -5
- package/src/post-template/edit.js +13 -1
- package/src/query/index.js +10 -0
- package/src/query/variations.js +17 -11
- package/src/query-pagination-next/index.php +1 -1
- package/src/query-pagination-previous/index.php +1 -1
- package/src/search/index.php +2 -2
- package/src/search/view.js +4 -4
- package/src/style.scss +1 -0
- package/src/term-template/index.php +8 -2
- package/src/terms-query/edit/inspector-controls/index.js +2 -2
- package/src/terms-query/edit/inspector-controls/inherit-control.js +1 -3
- package/src/utils/get-transformed-attributes.js +5 -16
|
@@ -4,7 +4,7 @@ import { InspectorControls, useBlockProps } from "@wordpress/block-editor";
|
|
|
4
4
|
import {
|
|
5
5
|
ToggleControl,
|
|
6
6
|
TextControl,
|
|
7
|
-
|
|
7
|
+
CheckboxControl,
|
|
8
8
|
__experimentalToolsPanel as ToolsPanel,
|
|
9
9
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
10
10
|
Spinner
|
|
@@ -15,33 +15,19 @@ import { useEffect, useState, RawHTML } from "@wordpress/element";
|
|
|
15
15
|
import { useServerSideRender } from "@wordpress/server-side-render";
|
|
16
16
|
import { useToolsPanelDropdownMenuProps } from "../utils/hooks";
|
|
17
17
|
const separatorDefaultValue = "/";
|
|
18
|
-
const typeDefaultValue = "auto";
|
|
19
|
-
const BREADCRUMB_TYPES = {
|
|
20
|
-
auto: {
|
|
21
|
-
help: __(
|
|
22
|
-
"Try to automatically determine the best type of breadcrumb for the template."
|
|
23
|
-
)
|
|
24
|
-
},
|
|
25
|
-
postWithAncestors: {
|
|
26
|
-
help: __(
|
|
27
|
-
"Shows breadcrumbs based on post hierarchy. Only works for hierarchical post types."
|
|
28
|
-
),
|
|
29
|
-
placeholderItems: [__("Ancestor"), __("Parent")]
|
|
30
|
-
},
|
|
31
|
-
postWithTerms: {
|
|
32
|
-
help: __(
|
|
33
|
-
"Shows breadcrumbs based on taxonomy terms. Chooses the first taxonomy with assigned terms and includes ancestors if the taxonomy is hierarchical."
|
|
34
|
-
),
|
|
35
|
-
placeholderItems: [__("Category")]
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
18
|
function BreadcrumbEdit({
|
|
39
19
|
attributes,
|
|
40
20
|
setAttributes,
|
|
41
21
|
context: { postId, postType, templateSlug }
|
|
42
22
|
}) {
|
|
43
|
-
const { separator, showHomeLink,
|
|
44
|
-
const {
|
|
23
|
+
const { separator, showHomeLink, prefersTaxonomy } = attributes;
|
|
24
|
+
const {
|
|
25
|
+
post,
|
|
26
|
+
isPostTypeHierarchical,
|
|
27
|
+
postTypeHasTaxonomies,
|
|
28
|
+
hasTermsAssigned,
|
|
29
|
+
isLoading
|
|
30
|
+
} = useSelect(
|
|
45
31
|
(select) => {
|
|
46
32
|
if (!postType) {
|
|
47
33
|
return {};
|
|
@@ -52,9 +38,9 @@ function BreadcrumbEdit({
|
|
|
52
38
|
postId
|
|
53
39
|
);
|
|
54
40
|
const postTypeObject = select(coreStore).getPostType(postType);
|
|
55
|
-
const
|
|
41
|
+
const _postTypeHasTaxonomies = postTypeObject && postTypeObject.taxonomies.length;
|
|
56
42
|
let taxonomies;
|
|
57
|
-
if (
|
|
43
|
+
if (_postTypeHasTaxonomies) {
|
|
58
44
|
taxonomies = select(coreStore).getTaxonomies({
|
|
59
45
|
type: postType,
|
|
60
46
|
per_page: -1
|
|
@@ -63,12 +49,13 @@ function BreadcrumbEdit({
|
|
|
63
49
|
return {
|
|
64
50
|
post: _post,
|
|
65
51
|
isPostTypeHierarchical: postTypeObject?.hierarchical,
|
|
52
|
+
postTypeHasTaxonomies: _postTypeHasTaxonomies,
|
|
66
53
|
hasTermsAssigned: _post && (taxonomies || []).filter(
|
|
67
54
|
({ visibility }) => visibility?.publicly_queryable
|
|
68
55
|
).some((taxonomy) => {
|
|
69
56
|
return !!_post[taxonomy.rest_base]?.length;
|
|
70
57
|
}),
|
|
71
|
-
isLoading: !_post || !postTypeObject ||
|
|
58
|
+
isLoading: postId && !_post || !postTypeObject || _postTypeHasTaxonomies && !taxonomies
|
|
72
59
|
};
|
|
73
60
|
},
|
|
74
61
|
[postType, postId]
|
|
@@ -88,27 +75,31 @@ function BreadcrumbEdit({
|
|
|
88
75
|
if (isLoading) {
|
|
89
76
|
return /* @__PURE__ */ jsx("div", { ...blockProps, children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
90
77
|
}
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (isSpecificSupportedTypeSet) {
|
|
97
|
-
breadcrumbsType = type;
|
|
78
|
+
let _showTerms;
|
|
79
|
+
if (!isPostTypeHierarchical) {
|
|
80
|
+
_showTerms = true;
|
|
81
|
+
} else if (!postTypeHasTaxonomies) {
|
|
82
|
+
_showTerms = false;
|
|
98
83
|
} else {
|
|
99
|
-
|
|
84
|
+
_showTerms = prefersTaxonomy;
|
|
100
85
|
}
|
|
101
86
|
let placeholder = null;
|
|
102
87
|
const showPlaceholder = !postId || !postType || // When `templateSlug` is set only show placeholder if the post type is not.
|
|
103
88
|
// This is needed because when we are showing the template in post editor we
|
|
104
89
|
// want to show the real breadcrumbs if we have the post type.
|
|
105
|
-
templateSlug && !postType ||
|
|
90
|
+
templateSlug && !postType || !_showTerms && !isPostTypeHierarchical || _showTerms && !hasTermsAssigned;
|
|
106
91
|
if (showPlaceholder) {
|
|
107
|
-
const placeholderItems = [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
const placeholderItems = [];
|
|
93
|
+
if (showHomeLink) {
|
|
94
|
+
placeholderItems.push(__("Home"));
|
|
95
|
+
}
|
|
96
|
+
if (templateSlug && !postId) {
|
|
97
|
+
placeholderItems.push(__("Page"));
|
|
98
|
+
} else if (_showTerms) {
|
|
99
|
+
placeholderItems.push(__("Category"));
|
|
100
|
+
} else {
|
|
101
|
+
placeholderItems.push(__("Ancestor"), __("Parent"));
|
|
102
|
+
}
|
|
112
103
|
placeholder = /* @__PURE__ */ jsx(
|
|
113
104
|
"nav",
|
|
114
105
|
{
|
|
@@ -131,48 +122,11 @@ function BreadcrumbEdit({
|
|
|
131
122
|
resetAll: () => {
|
|
132
123
|
setAttributes({
|
|
133
124
|
separator: separatorDefaultValue,
|
|
134
|
-
showHomeLink: true
|
|
135
|
-
type: typeDefaultValue
|
|
125
|
+
showHomeLink: true
|
|
136
126
|
});
|
|
137
127
|
},
|
|
138
128
|
dropdownMenuProps,
|
|
139
129
|
children: [
|
|
140
|
-
/* @__PURE__ */ jsx(
|
|
141
|
-
ToolsPanelItem,
|
|
142
|
-
{
|
|
143
|
-
label: __("Type"),
|
|
144
|
-
isShownByDefault: true,
|
|
145
|
-
hasValue: () => type !== typeDefaultValue,
|
|
146
|
-
onDeselect: () => setAttributes({
|
|
147
|
-
type: typeDefaultValue
|
|
148
|
-
}),
|
|
149
|
-
children: /* @__PURE__ */ jsx(
|
|
150
|
-
SelectControl,
|
|
151
|
-
{
|
|
152
|
-
__nextHasNoMarginBottom: true,
|
|
153
|
-
__next40pxDefaultSize: true,
|
|
154
|
-
label: __("Type"),
|
|
155
|
-
value: type,
|
|
156
|
-
onChange: (value) => setAttributes({ type: value }),
|
|
157
|
-
options: [
|
|
158
|
-
{
|
|
159
|
-
label: __("Auto"),
|
|
160
|
-
value: "auto"
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
label: __("Post with ancestors"),
|
|
164
|
-
value: "postWithAncestors"
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
label: __("Post with terms"),
|
|
168
|
-
value: "postWithTerms"
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
help: BREADCRUMB_TYPES[type].help
|
|
172
|
-
}
|
|
173
|
-
)
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
130
|
/* @__PURE__ */ jsx(
|
|
177
131
|
ToolsPanelItem,
|
|
178
132
|
{
|
|
@@ -225,6 +179,18 @@ function BreadcrumbEdit({
|
|
|
225
179
|
]
|
|
226
180
|
}
|
|
227
181
|
) }),
|
|
182
|
+
/* @__PURE__ */ jsx(InspectorControls, { group: "advanced", children: /* @__PURE__ */ jsx(
|
|
183
|
+
CheckboxControl,
|
|
184
|
+
{
|
|
185
|
+
__nextHasNoMarginBottom: true,
|
|
186
|
+
label: __("Prefer taxonomy terms"),
|
|
187
|
+
checked: prefersTaxonomy,
|
|
188
|
+
onChange: (value) => setAttributes({ prefersTaxonomy: value }),
|
|
189
|
+
help: __(
|
|
190
|
+
"The exact type of breadcrumbs shown will vary automatically depending on the page in which this block is displayed. In the specific case of a hierarchical post type with taxonomies, the breadcrumbs can either reflect its post hierarchy (default) or the hierarchy of its assigned taxonomy terms."
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
) }),
|
|
228
194
|
/* @__PURE__ */ jsx("div", { ...blockProps, children: showPlaceholder ? placeholder : /* @__PURE__ */ jsx(RawHTML, { inert: "true", children: content }) })
|
|
229
195
|
] });
|
|
230
196
|
}
|
|
@@ -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\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useBlockProps } from '@wordpress/block-editor';\nimport {\n\tToggleControl,\n\tTextControl,\n\tCheckboxControl,\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 = '/';\n\nexport default function BreadcrumbEdit( {\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType, templateSlug },\n} ) {\n\tconst { separator, showHomeLink, prefersTaxonomy } = attributes;\n\tconst {\n\t\tpost,\n\t\tisPostTypeHierarchical,\n\t\tpostTypeHasTaxonomies,\n\t\thasTermsAssigned,\n\t\tisLoading,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postType ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _post = select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\tpostId\n\t\t\t);\n\t\t\tconst postTypeObject = select( coreStore ).getPostType( postType );\n\t\t\tconst _postTypeHasTaxonomies =\n\t\t\t\tpostTypeObject && postTypeObject.taxonomies.length;\n\t\t\tlet taxonomies;\n\t\t\tif ( _postTypeHasTaxonomies ) {\n\t\t\t\ttaxonomies = select( coreStore ).getTaxonomies( {\n\t\t\t\t\ttype: postType,\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tpost: _post,\n\t\t\t\tisPostTypeHierarchical: postTypeObject?.hierarchical,\n\t\t\t\tpostTypeHasTaxonomies: _postTypeHasTaxonomies,\n\t\t\t\thasTermsAssigned:\n\t\t\t\t\t_post &&\n\t\t\t\t\t( taxonomies || [] )\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t( { visibility } ) => visibility?.publicly_queryable\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.some( ( taxonomy ) => {\n\t\t\t\t\t\t\treturn !! _post[ taxonomy.rest_base ]?.length;\n\t\t\t\t\t\t} ),\n\t\t\t\tisLoading:\n\t\t\t\t\t( postId && ! _post ) ||\n\t\t\t\t\t! postTypeObject ||\n\t\t\t\t\t( _postTypeHasTaxonomies && ! taxonomies ),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\t/**\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\t */\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\n\t// Determine breadcrumb type for accurate previews (matching PHP logic).\n\tlet _showTerms;\n\tif ( ! isPostTypeHierarchical ) {\n\t\t_showTerms = true;\n\t} else if ( ! postTypeHasTaxonomies ) {\n\t\t// Hierarchical post type without taxonomies can only use ancestors.\n\t\t_showTerms = false;\n\t} else {\n\t\t// For hierarchical post types with taxonomies, use the attribute.\n\t\t_showTerms = prefersTaxonomy;\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( ! _showTerms && ! isPostTypeHierarchical ) ||\n\t\t( _showTerms && ! hasTermsAssigned );\n\tif ( showPlaceholder ) {\n\t\tconst placeholderItems = [];\n\t\tif ( showHomeLink ) {\n\t\t\tplaceholderItems.push( __( 'Home' ) );\n\t\t}\n\t\tif ( templateSlug && ! postId ) {\n\t\t\tplaceholderItems.push( __( 'Page' ) );\n\t\t} else if ( _showTerms ) {\n\t\t\tplaceholderItems.push( __( 'Category' ) );\n\t\t} else {\n\t\t\tplaceholderItems.push( __( 'Ancestor' ), __( 'Parent' ) );\n\t\t}\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} );\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={ __( '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<InspectorControls group=\"advanced\">\n\t\t\t\t<CheckboxControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Prefer taxonomy terms' ) }\n\t\t\t\t\tchecked={ prefersTaxonomy }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { prefersTaxonomy: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'The exact type of breadcrumbs shown will vary automatically depending on the page in which this block is displayed. In the specific case of a hierarchical post type with taxonomies, the breadcrumbs can either reflect its post hierarchy (default) or the hierarchy of its assigned taxonomy terms.'\n\t\t\t\t\t) }\n\t\t\t\t/>\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": "AA2GI,SA+DF,UA/DE,KA+CA,YA/CA;AAxGJ,SAA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AAe;AAAA,wBACd,WAAW;AAAA,sBACZ,CAAE;AAAA,oBACH;AAAA,kBACD;AAAA;AAAA,cACD;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IACD,GACD;AAAA,IACA,oBAAC,qBAAkB,OAAM,YACxB;AAAA,MAAC;AAAA;AAAA,QACA,yBAAuB;AAAA,QACvB,OAAQ,GAAI,uBAAwB;AAAA,QACpC,SAAU;AAAA,QACV,UAAW,CAAE,UACZ,cAAe,EAAE,iBAAiB,MAAM,CAAE;AAAA,QAE3C,MAAO;AAAA,UACN;AAAA,QACD;AAAA;AAAA,IACD,GACD;AAAA,IACA,oBAAC,SAAM,GAAG,YACP,4BACD,cAEA,oBAAC,WAAQ,OAAM,QAAS,mBAAS,GAEnC;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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 { 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": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B,qBAAqB;AAKzD,SAAS,gCAAgC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,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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...attributes,\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": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B,qBAAqB;AAKzD,SAAS,gCAAgC;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,QAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ;AAAA,YAAK,CAAE;AAAA;AAAA,cAEd,YAAa,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,QAEZ;AAAA,UACC;AAAA,UACA,CAAC;AAAA;AAAA,UAED,QAAQ,IAAK,CAAE,eAAgB;AAC9B,kBAAM,EAAE,QAAQ,IAAI;AACpB,kBAAM,UAAU,cAAe,UAAU,OAAQ;AAEjD,kBAAM,OAAO,QAAQ,aAAa;AAElC,kBAAM,OAAO,QAAQ,cAAe,GAAI;AACxC,kBAAM,MAAM,MAAM,aAAc,MAAO;AAEvC,mBAAO,YAAa,eAAe;AAAA,cAClC,GAAG;AAAA,cACH,GAAG;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,UAAU;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": []
|
|
7
7
|
}
|
|
@@ -134,10 +134,14 @@ function CategoriesEdit({
|
|
|
134
134
|
];
|
|
135
135
|
};
|
|
136
136
|
const TagName = !!categories?.length && !displayAsDropdown && !isResolving ? "ul" : "div";
|
|
137
|
-
const classes = clsx(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
const classes = clsx(
|
|
138
|
+
className,
|
|
139
|
+
`wp-block-categories-taxonomy-${taxonomySlug}`,
|
|
140
|
+
{
|
|
141
|
+
"wp-block-categories-list": !!categories?.length && !displayAsDropdown && !isResolving,
|
|
142
|
+
"wp-block-categories-dropdown": !!categories?.length && displayAsDropdown && !isResolving
|
|
143
|
+
}
|
|
144
|
+
);
|
|
141
145
|
const blockProps = useBlockProps({
|
|
142
146
|
className: classes
|
|
143
147
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/categories/edit.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlaceholder,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\tVisuallyHidden,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tRichText,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticeStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t\tshowEmpty,\n\t\tlabel,\n\t\tshowLabel,\n\t\ttaxonomy: taxonomySlug,\n\t},\n\tsetAttributes,\n\tclassName,\n\tclientId,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\n\tconst { records: allTaxonomies, isResolvingTaxonomies } = useEntityRecords(\n\t\t'root',\n\t\t'taxonomy',\n\t\t{ per_page: -1 }\n\t);\n\n\tconst taxonomies = allTaxonomies?.filter( ( t ) => t.visibility.public );\n\n\tconst taxonomy = taxonomies?.find( ( t ) => t.slug === taxonomySlug );\n\n\tconst isHierarchicalTaxonomy =\n\t\t! isResolvingTaxonomies && taxonomy?.hierarchical;\n\n\tconst query = { per_page: -1, hide_empty: ! showEmpty, context: 'view' };\n\tif ( isHierarchicalTaxonomy && showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\ttaxonomySlug,\n\t\tquery\n\t);\n\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/categories/redirection-prevented/${ clientId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : decodeEntities( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn categoriesList.map( ( category ) =>\n\t\t\trenderCategoryListItem( category )\n\t\t);\n\t};\n\n\tconst renderCategoryListItem = ( category ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id } className={ `cat-item cat-item-${ id }` }>\n\t\t\t\t<a href={ link } onClick={ showRedirectionPreventedNotice }>\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t\t{ isHierarchicalTaxonomy &&\n\t\t\t\t\tshowHierarchy &&\n\t\t\t\t\t!! childCategories.length && (\n\t\t\t\t\t\t<ul className=\"children\">\n\t\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\t\trenderCategoryListItem( childCategory )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ showLabel ? (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tclassName=\"wp-block-categories__label\"\n\t\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\t\tplaceholder={ taxonomy?.name }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: html } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<VisuallyHidden as=\"label\" htmlFor={ selectId }>\n\t\t\t\t\t\t{ label ? label : taxonomy?.name }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t<select id={ selectId }>\n\t\t\t\t\t<option>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: taxonomy's singular name */\n\t\t\t\t\t\t\t__( 'Select %s' ),\n\t\t\t\t\t\t\ttaxonomy?.labels?.singular_name\n\t\t\t\t\t\t) }\n\t\t\t\t\t</option>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id } className={ `level-${ level }` }>\n\t\t\t\t{ Array.from( { length: level * 3 } ).map( () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tisHierarchicalTaxonomy &&\n\t\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\tconst TagName =\n\t\t!! categories?.length && ! displayAsDropdown && ! isResolving\n\t\t\t? 'ul'\n\t\t\t: 'div';\n\n\tconst classes = clsx( className, {\n\t\t'wp-block-categories-list':\n\t\t\t!! categories?.length && ! displayAsDropdown && ! isResolving,\n\t\t'wp-block-categories-dropdown':\n\t\t\t!! categories?.length && displayAsDropdown && ! isResolving,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\treturn (\n\t\t<TagName { ...blockProps }>\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\ttaxonomy: 'category',\n\t\t\t\t\t\t\tdisplayAsDropdown: false,\n\t\t\t\t\t\t\tshowHierarchy: false,\n\t\t\t\t\t\t\tshowPostCounts: false,\n\t\t\t\t\t\t\tshowOnlyTopLevel: false,\n\t\t\t\t\t\t\tshowEmpty: false,\n\t\t\t\t\t\t\tshowLabel: true,\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{ Array.isArray( taxonomies ) && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => {\n\t\t\t\t\t\t\t\treturn taxonomySlug !== 'category';\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { taxonomy: 'category' } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\t\toptions={ taxonomies.map( ( t ) => ( {\n\t\t\t\t\t\t\t\t\tlabel: t.name,\n\t\t\t\t\t\t\t\t\tvalue: t.slug,\n\t\t\t\t\t\t\t\t} ) ) }\n\t\t\t\t\t\t\t\tvalue={ taxonomySlug }\n\t\t\t\t\t\t\t\tonChange={ ( selectedTaxonomy ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\ttaxonomy: selectedTaxonomy,\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</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! displayAsDropdown }\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { displayAsDropdown: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\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={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ displayAsDropdown && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showLabel }\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showLabel: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"wp-block-categories__indentation\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showLabel' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showPostCounts }\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showPostCounts: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\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 post counts' ) }\n\t\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showOnlyTopLevel }\n\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showOnlyTopLevel: false } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute(\n\t\t\t\t\t\t\t\t\t'showOnlyTopLevel'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showEmpty }\n\t\t\t\t\t\tlabel={ __( 'Show empty terms' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showEmpty: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\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 empty terms' ) }\n\t\t\t\t\t\t\tchecked={ showEmpty }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showEmpty' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showHierarchy }\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHierarchy: false } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Terms' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>{ taxonomy.labels.no_terms }</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</TagName>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "AAiHG,SAsBA,UArBC,KADD;AA9GH,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sBAAsB;AAC/B,SAAS,IAAI,eAAe;AAC5B,SAAS,WAAW;AACpB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,SAAS,mBAAmB;AAKrC,SAAS,sCAAsC;AAEhC,SAAR,eAAiC;AAAA,EACvC,YAAY;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,WAAW,cAAe,gBAAgB,wBAAyB;AAEzE,QAAM,EAAE,SAAS,eAAe,sBAAsB,IAAI;AAAA,IACzD;AAAA,IACA;AAAA,IACA,EAAE,UAAU,GAAG;AAAA,EAChB;AAEA,QAAM,aAAa,eAAe,OAAQ,CAAE,MAAO,EAAE,WAAW,MAAO;AAE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AAK;AAAA,QACzB,kBAAkB,KAAM,KAAM;AAAA,WAHnB,EAId;AAAA,MACA,0BACC,iBACA,CAAC,CAAE,gBAAgB,UACnB,gBAAgB;AAAA,QAAK,CAAE,kBACtB,2BAA4B,eAAe,QAAQ,CAAE;AAAA,MACtD;AAAA,IACF;AAAA,EACD;AAEA,QAAM,UACL,CAAC,CAAE,YAAY,UAAU,CAAE,qBAAqB,CAAE,cAC/C,OACA;AAEJ,QAAM,UAAU,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPlaceholder,\n\tSelectControl,\n\tSpinner,\n\tToggleControl,\n\tVisuallyHidden,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport {\n\tInspectorControls,\n\tuseBlockProps,\n\tRichText,\n} from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { pin } from '@wordpress/icons';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticeStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function CategoriesEdit( {\n\tattributes: {\n\t\tdisplayAsDropdown,\n\t\tshowHierarchy,\n\t\tshowPostCounts,\n\t\tshowOnlyTopLevel,\n\t\tshowEmpty,\n\t\tlabel,\n\t\tshowLabel,\n\t\ttaxonomy: taxonomySlug,\n\t},\n\tsetAttributes,\n\tclassName,\n\tclientId,\n} ) {\n\tconst selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );\n\n\tconst { records: allTaxonomies, isResolvingTaxonomies } = useEntityRecords(\n\t\t'root',\n\t\t'taxonomy',\n\t\t{ per_page: -1 }\n\t);\n\n\tconst taxonomies = allTaxonomies?.filter( ( t ) => t.visibility.public );\n\n\tconst taxonomy = taxonomies?.find( ( t ) => t.slug === taxonomySlug );\n\n\tconst isHierarchicalTaxonomy =\n\t\t! isResolvingTaxonomies && taxonomy?.hierarchical;\n\n\tconst query = { per_page: -1, hide_empty: ! showEmpty, context: 'view' };\n\tif ( isHierarchicalTaxonomy && showOnlyTopLevel ) {\n\t\tquery.parent = 0;\n\t}\n\n\tconst { records: categories, isResolving } = useEntityRecords(\n\t\t'taxonomy',\n\t\ttaxonomySlug,\n\t\tquery\n\t);\n\n\tconst { createWarningNotice } = useDispatch( noticeStore );\n\tconst showRedirectionPreventedNotice = ( event ) => {\n\t\tevent.preventDefault();\n\t\tcreateWarningNotice( __( 'Links are disabled in the editor.' ), {\n\t\t\tid: `block-library/core/categories/redirection-prevented/${ clientId }`,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t};\n\n\tconst getCategoriesList = ( parentId ) => {\n\t\tif ( ! categories?.length ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( parentId === null ) {\n\t\t\treturn categories;\n\t\t}\n\t\treturn categories.filter( ( { parent } ) => parent === parentId );\n\t};\n\n\tconst toggleAttribute = ( attributeName ) => ( newValue ) =>\n\t\tsetAttributes( { [ attributeName ]: newValue } );\n\n\tconst renderCategoryName = ( name ) =>\n\t\t! name ? __( '(Untitled)' ) : decodeEntities( name ).trim();\n\n\tconst renderCategoryList = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn categoriesList.map( ( category ) =>\n\t\t\trenderCategoryListItem( category )\n\t\t);\n\t};\n\n\tconst renderCategoryListItem = ( category ) => {\n\t\tconst childCategories = getCategoriesList( category.id );\n\t\tconst { id, link, count, name } = category;\n\t\treturn (\n\t\t\t<li key={ id } className={ `cat-item cat-item-${ id }` }>\n\t\t\t\t<a href={ link } onClick={ showRedirectionPreventedNotice }>\n\t\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t</a>\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t\t{ isHierarchicalTaxonomy &&\n\t\t\t\t\tshowHierarchy &&\n\t\t\t\t\t!! childCategories.length && (\n\t\t\t\t\t\t<ul className=\"children\">\n\t\t\t\t\t\t\t{ childCategories.map( ( childCategory ) =>\n\t\t\t\t\t\t\t\trenderCategoryListItem( childCategory )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t) }\n\t\t\t</li>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdown = () => {\n\t\tconst parentId = isHierarchicalTaxonomy && showHierarchy ? 0 : null;\n\t\tconst categoriesList = getCategoriesList( parentId );\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ showLabel ? (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tclassName=\"wp-block-categories__label\"\n\t\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\t\tplaceholder={ taxonomy?.name }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { label: html } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<VisuallyHidden as=\"label\" htmlFor={ selectId }>\n\t\t\t\t\t\t{ label ? label : taxonomy?.name }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t\t<select id={ selectId }>\n\t\t\t\t\t<option>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: %s: taxonomy's singular name */\n\t\t\t\t\t\t\t__( 'Select %s' ),\n\t\t\t\t\t\t\ttaxonomy?.labels?.singular_name\n\t\t\t\t\t\t) }\n\t\t\t\t\t</option>\n\t\t\t\t\t{ categoriesList.map( ( category ) =>\n\t\t\t\t\t\trenderCategoryDropdownItem( category, 0 )\n\t\t\t\t\t) }\n\t\t\t\t</select>\n\t\t\t</>\n\t\t);\n\t};\n\n\tconst renderCategoryDropdownItem = ( category, level ) => {\n\t\tconst { id, count, name } = category;\n\t\tconst childCategories = getCategoriesList( id );\n\t\treturn [\n\t\t\t<option key={ id } className={ `level-${ level }` }>\n\t\t\t\t{ Array.from( { length: level * 3 } ).map( () => '\\xa0' ) }\n\t\t\t\t{ renderCategoryName( name ) }\n\t\t\t\t{ showPostCounts && ` (${ count })` }\n\t\t\t</option>,\n\t\t\tisHierarchicalTaxonomy &&\n\t\t\t\tshowHierarchy &&\n\t\t\t\t!! childCategories.length &&\n\t\t\t\tchildCategories.map( ( childCategory ) =>\n\t\t\t\t\trenderCategoryDropdownItem( childCategory, level + 1 )\n\t\t\t\t),\n\t\t];\n\t};\n\n\tconst TagName =\n\t\t!! categories?.length && ! displayAsDropdown && ! isResolving\n\t\t\t? 'ul'\n\t\t\t: 'div';\n\n\tconst classes = clsx(\n\t\tclassName,\n\t\t`wp-block-categories-taxonomy-${ taxonomySlug }`,\n\t\t{\n\t\t\t'wp-block-categories-list':\n\t\t\t\t!! categories?.length && ! displayAsDropdown && ! isResolving,\n\t\t\t'wp-block-categories-dropdown':\n\t\t\t\t!! categories?.length && displayAsDropdown && ! isResolving,\n\t\t}\n\t);\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\treturn (\n\t\t<TagName { ...blockProps }>\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\ttaxonomy: 'category',\n\t\t\t\t\t\t\tdisplayAsDropdown: false,\n\t\t\t\t\t\t\tshowHierarchy: false,\n\t\t\t\t\t\t\tshowPostCounts: false,\n\t\t\t\t\t\t\tshowOnlyTopLevel: false,\n\t\t\t\t\t\t\tshowEmpty: false,\n\t\t\t\t\t\t\tshowLabel: true,\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{ Array.isArray( taxonomies ) && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => {\n\t\t\t\t\t\t\t\treturn taxonomySlug !== 'category';\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\tonDeselect={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { taxonomy: 'category' } );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomy' ) }\n\t\t\t\t\t\t\t\toptions={ taxonomies.map( ( t ) => ( {\n\t\t\t\t\t\t\t\t\tlabel: t.name,\n\t\t\t\t\t\t\t\t\tvalue: t.slug,\n\t\t\t\t\t\t\t\t} ) ) }\n\t\t\t\t\t\t\t\tvalue={ taxonomySlug }\n\t\t\t\t\t\t\t\tonChange={ ( selectedTaxonomy ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\ttaxonomy: selectedTaxonomy,\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</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! displayAsDropdown }\n\t\t\t\t\t\tlabel={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { displayAsDropdown: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\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={ __( 'Display as dropdown' ) }\n\t\t\t\t\t\t\tchecked={ displayAsDropdown }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'displayAsDropdown' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ displayAsDropdown && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => ! showLabel }\n\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showLabel: true } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"wp-block-categories__indentation\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Show label' ) }\n\t\t\t\t\t\t\t\tchecked={ showLabel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showLabel' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showPostCounts }\n\t\t\t\t\t\tlabel={ __( 'Show post counts' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showPostCounts: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\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 post counts' ) }\n\t\t\t\t\t\t\tchecked={ showPostCounts }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showPostCounts' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showOnlyTopLevel }\n\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showOnlyTopLevel: false } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show only top level terms' ) }\n\t\t\t\t\t\t\t\tchecked={ showOnlyTopLevel }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute(\n\t\t\t\t\t\t\t\t\t'showOnlyTopLevel'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! showEmpty }\n\t\t\t\t\t\tlabel={ __( 'Show empty terms' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { showEmpty: false } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\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 empty terms' ) }\n\t\t\t\t\t\t\tchecked={ showEmpty }\n\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showEmpty' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t{ isHierarchicalTaxonomy && ! showOnlyTopLevel && (\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! showHierarchy }\n\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { showHierarchy: false } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Show hierarchy' ) }\n\t\t\t\t\t\t\t\tchecked={ showHierarchy }\n\t\t\t\t\t\t\t\tonChange={ toggleAttribute( 'showHierarchy' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\t\t\t{ isResolving && (\n\t\t\t\t<Placeholder icon={ pin } label={ __( 'Terms' ) }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ ! isResolving && categories?.length === 0 && (\n\t\t\t\t<p>{ taxonomy.labels.no_terms }</p>\n\t\t\t) }\n\t\t\t{ ! isResolving &&\n\t\t\t\tcategories?.length > 0 &&\n\t\t\t\t( displayAsDropdown\n\t\t\t\t\t? renderCategoryDropdown()\n\t\t\t\t\t: renderCategoryList() ) }\n\t\t</TagName>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAiHG,SAsBA,UArBC,KADD;AA9GH,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,sBAAsB;AAC/B,SAAS,IAAI,eAAe;AAC5B,SAAS,WAAW;AACpB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC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;AAAA,UACE,0BAA0B,CAAE,oBAC7B;AAAA,YAAC;AAAA;AAAA,cACA,UAAW,MAAM,CAAC,CAAE;AAAA,cACpB,OAAQ,GAAI,gBAAiB;AAAA,cAC7B,YAAa,MACZ,cAAe,EAAE,eAAe,MAAM,CAAE;AAAA,cAEzC,kBAAgB;AAAA,cAEhB;AAAA,gBAAC;AAAA;AAAA,kBACA,yBAAuB;AAAA,kBACvB,OAAQ,GAAI,gBAAiB;AAAA,kBAC7B,SAAU;AAAA,kBACV,UAAW,gBAAiB,eAAgB;AAAA;AAAA,cAC7C;AAAA;AAAA,UACD;AAAA;AAAA;AAAA,IAEF,GACD;AAAA,IACE,eACD,oBAAC,eAAY,MAAO,KAAM,OAAQ,GAAI,OAAQ,GAC7C,8BAAC,WAAQ,GACV;AAAA,IAEC,CAAE,eAAe,YAAY,WAAW,KACzC,oBAAC,OAAI,mBAAS,OAAO,UAAU;AAAA,IAE9B,CAAE,eACH,YAAY,SAAS,MACnB,oBACC,uBAAuB,IACvB,mBAAmB;AAAA,KACxB;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14,6 +14,7 @@ const transforms = {
|
|
|
14
14
|
transform: (attributes) => {
|
|
15
15
|
const { content } = attributes;
|
|
16
16
|
return createBlock("core/code", {
|
|
17
|
+
...attributes,
|
|
17
18
|
...getTransformedAttributes(attributes, "core/code"),
|
|
18
19
|
content
|
|
19
20
|
});
|
|
@@ -25,6 +26,7 @@ const transforms = {
|
|
|
25
26
|
transform: (attributes) => {
|
|
26
27
|
const { content: text } = attributes;
|
|
27
28
|
return createBlock("core/code", {
|
|
29
|
+
...attributes,
|
|
28
30
|
...getTransformedAttributes(attributes, "core/code"),
|
|
29
31
|
// The HTML is plain text (with plain line breaks), so
|
|
30
32
|
// convert it to rich text.
|
|
@@ -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 { 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": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,oBAAoB;AAKrC,SAAS,gCAAgC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW,MAAM,YAAa,WAAY;AAAA,IAC3C;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,QAAQ,IAAI;AACpB,eAAO,YAAa,aAAa;AAAA,UAChC,GAAG,yBAA0B,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,eAAO,YAAa,aAAa;AAAA,UAChC,GAAG,yBAA0B,YAAY,WAAY;AAAA;AAAA;AAAA,UAGrD,SAAS,aAAc,EAAE,OAAO,OAAQ,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,eAAO,YAAa,kBAAkB;AAAA,UACrC,GAAG,yBAA0B,YAAY,gBAAiB;AAAA,UAC1D;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
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...attributes,\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...attributes,\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": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,QAAQ,oBAAoB;AAKrC,SAAS,gCAAgC;AAEzC,MAAM,aAAa;AAAA,EAClB,MAAM;AAAA,IACL;AAAA,MACC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,WAAW,MAAM,YAAa,WAAY;AAAA,IAC3C;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,QAAQ,CAAE,gBAAiB;AAAA,MAC3B,WAAW,CAAE,eAAgB;AAC5B,cAAM,EAAE,QAAQ,IAAI;AACpB,eAAO,YAAa,aAAa;AAAA,UAChC,GAAG;AAAA,UACH,GAAG,yBAA0B,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,eAAO,YAAa,aAAa;AAAA,UAChC,GAAG;AAAA,UACH,GAAG,yBAA0B,YAAY,WAAY;AAAA;AAAA;AAAA,UAGrD,SAAS,aAAc,EAAE,OAAO,OAAQ,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,eAAO,YAAa,kBAAkB;AAAA,UACrC,GAAG,yBAA0B,YAAY,gBAAiB;AAAA,UAC1D;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -221,8 +221,11 @@ const { state, actions, callbacks } = store(
|
|
|
221
221
|
`;
|
|
222
222
|
},
|
|
223
223
|
setButtonStyles() {
|
|
224
|
-
const { imageId } = getContext();
|
|
225
224
|
const { ref } = getElement();
|
|
225
|
+
if (!ref) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const { imageId } = getContext();
|
|
226
229
|
state.metadata[imageId].imageRef = ref;
|
|
227
230
|
state.metadata[imageId].currentSrc = ref.currentSrc;
|
|
228
231
|
const {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/image/view.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tstore,\n\tgetContext,\n\tgetElement,\n\twithSyncEvent,\n} from '@wordpress/interactivity';\n\n/**\n * Tracks whether user is touching screen; used to differentiate behavior for\n * touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/**\n * Tracks the last time the screen was touched; used to differentiate behavior\n * for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\nconst { state, actions, callbacks } = store(\n\t'core/image',\n\t{\n\t\tstate: {\n\t\t\tcurrentImageId: null,\n\t\t\tget currentImage() {\n\t\t\t\treturn state.metadata[ state.currentImageId ];\n\t\t\t},\n\t\t\tget overlayOpened() {\n\t\t\t\treturn state.currentImageId !== null;\n\t\t\t},\n\t\t\tget roleAttribute() {\n\t\t\t\treturn state.overlayOpened ? 'dialog' : null;\n\t\t\t},\n\t\t\tget ariaModal() {\n\t\t\t\treturn state.overlayOpened ? 'true' : null;\n\t\t\t},\n\t\t\tget enlargedSrc() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.currentImage.uploadedSrc ||\n\t\t\t\t\t'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='\n\t\t\t\t);\n\t\t\t},\n\t\t\tget figureStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.currentImage.figureStyles?.replace(\n\t\t\t\t\t\t/margin[^;]*;?/g,\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\tget imgStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.currentImage.imgStyles?.replace(\n\t\t\t\t\t\t/;$/,\n\t\t\t\t\t\t''\n\t\t\t\t\t) }; object-fit:cover;`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget imageButtonRight() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\treturn state.metadata[ imageId ].imageButtonRight;\n\t\t\t},\n\t\t\tget imageButtonTop() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\treturn state.metadata[ imageId ].imageButtonTop;\n\t\t\t},\n\t\t\tget isContentHidden() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayEnabled && state.currentImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentVisible() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\t! state.overlayEnabled &&\n\t\t\t\t\tstate.currentImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tshowLightbox() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails out if the image has not loaded yet.\n\t\t\t\tif ( ! state.metadata[ imageId ].imageRef?.complete ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Stores the positions of the scroll to fix it until the overlay is\n\t\t\t\t// closed.\n\t\t\t\tstate.scrollTopReset = document.documentElement.scrollTop;\n\t\t\t\tstate.scrollLeftReset = document.documentElement.scrollLeft;\n\n\t\t\t\t// Sets the current expanded image in the state and enables the overlay.\n\t\t\t\tstate.overlayEnabled = true;\n\t\t\t\tstate.currentImageId = imageId;\n\n\t\t\t\t// Computes the styles of the overlay for the animation.\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t},\n\t\t\thideLightbox() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tstate.overlayEnabled = false;\n\n\t\t\t\t\t// Waits until the close animation has completed before allowing a\n\t\t\t\t\t// user to scroll again. The duration of this animation is defined in\n\t\t\t\t\t// the `styles.scss` file, but in any case we should wait a few\n\t\t\t\t\t// milliseconds longer than the duration, otherwise a user may scroll\n\t\t\t\t\t// too soon and cause the animation to look sloppy.\n\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t// Delays before changing the focus. Otherwise the focus ring will\n\t\t\t\t\t\t// appear on Firefox before the image has finished animating, which\n\t\t\t\t\t\t// looks broken.\n\t\t\t\t\t\tstate.currentImage.buttonRef.focus( {\n\t\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Resets the current image id to mark the overlay as closed.\n\t\t\t\t\t\tstate.currentImageId = null;\n\t\t\t\t\t}, 450 );\n\t\t\t\t}\n\t\t\t},\n\t\t\thandleKeydown: withSyncEvent( ( event ) => {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t// Focuses the close button when the user presses the tab key.\n\t\t\t\t\tif ( event.key === 'Tab' ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tconst { ref } = getElement();\n\t\t\t\t\t\tref.querySelector( 'button' ).focus();\n\t\t\t\t\t}\n\t\t\t\t\t// Closes the lightbox when the user presses the escape key.\n\t\t\t\t\tif ( event.key === 'Escape' ) {\n\t\t\t\t\t\tactions.hideLightbox();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchMove: withSyncEvent( ( event ) => {\n\t\t\t\t// On mobile devices, prevents triggering the scroll event because\n\t\t\t\t// otherwise the page jumps around when it resets the scroll position.\n\t\t\t\t// This also means that closing the lightbox requires that a user\n\t\t\t\t// perform a simple tap. This may be changed in the future if there is a\n\t\t\t\t// better alternative to override or reset the scroll position during\n\t\t\t\t// swipe actions.\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchStart() {\n\t\t\t\tisTouching = true;\n\t\t\t},\n\t\t\thandleTouchEnd() {\n\t\t\t\t// Waits a few milliseconds before resetting to ensure that pinch to\n\t\t\t\t// zoom works consistently on mobile devices when the lightbox is open.\n\t\t\t\tlastTouchTime = Date.now();\n\t\t\t\tisTouching = false;\n\t\t\t},\n\t\t\thandleScroll() {\n\t\t\t\t// Prevents scrolling behaviors that trigger content shift while the\n\t\t\t\t// lightbox is open. It would be better to accomplish through CSS alone,\n\t\t\t\t// but using overflow: hidden is currently the only way to do so and\n\t\t\t\t// that causes a layout to shift and prevents the zoom animation from\n\t\t\t\t// working in some cases because it's not possible to account for the\n\t\t\t\t// layout shift when doing the animation calculations. Instead, it uses\n\t\t\t\t// JavaScript to prevent and reset the scrolling behavior.\n\t\t\t\tif ( state.overlayOpened ) {\n\t\t\t\t\t// Avoids overriding the scroll behavior on mobile devices because\n\t\t\t\t\t// doing so breaks the pinch to zoom functionality, and users should\n\t\t\t\t\t// be able to zoom in further on the high-res image.\n\t\t\t\t\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t\t\t\t\t// It doesn't rely on `event.preventDefault()` to prevent scrolling\n\t\t\t\t\t\t// because the scroll event can't be canceled, so it resets the\n\t\t\t\t\t\t// position instead.\n\t\t\t\t\t\twindow.scrollTo(\n\t\t\t\t\t\t\tstate.scrollLeftReset,\n\t\t\t\t\t\t\tstate.scrollTopReset\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\tcallbacks: {\n\t\t\tsetOverlayStyles() {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth: originalWidth,\n\t\t\t\t\toffsetHeight: originalHeight,\n\t\t\t\t} = state.currentImage.imageRef;\n\t\t\t\tlet { x: screenPosX, y: screenPosY } =\n\t\t\t\t\tstate.currentImage.imageRef.getBoundingClientRect();\n\n\t\t\t\t// Natural ratio of the image clicked to open the lightbox.\n\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t// Original ratio of the image clicked to open the lightbox.\n\t\t\t\tlet originalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// If it has object-fit: contain, recalculates the original sizes\n\t\t\t\t// and the screen position without the blank spaces.\n\t\t\t\tif ( state.currentImage.scaleAttr === 'contain' ) {\n\t\t\t\t\tif ( naturalRatio > originalRatio ) {\n\t\t\t\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the top space.\n\t\t\t\t\t\tscreenPosY +=\n\t\t\t\t\t\t\t( originalHeight - heightWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalHeight = heightWithoutSpace;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the left space.\n\t\t\t\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalWidth = widthWithoutSpace;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\toriginalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// Typically, it uses the image's full-sized dimensions. If those\n\t\t\t\t// dimensions have not been set (i.e. an external image with only one\n\t\t\t\t// size), the image's dimensions in the lightbox are the same\n\t\t\t\t// as those of the image in the content.\n\t\t\t\tlet imgMaxWidth = parseFloat(\n\t\t\t\t\tstate.currentImage.targetWidth !== 'none'\n\t\t\t\t\t\t? state.currentImage.targetWidth\n\t\t\t\t\t\t: naturalWidth\n\t\t\t\t);\n\t\t\t\tlet imgMaxHeight = parseFloat(\n\t\t\t\t\tstate.currentImage.targetHeight !== 'none'\n\t\t\t\t\t\t? state.currentImage.targetHeight\n\t\t\t\t\t\t: naturalHeight\n\t\t\t\t);\n\n\t\t\t\t// Ratio of the biggest image stored in the database.\n\t\t\t\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\t\t\t\tlet containerMaxWidth = imgMaxWidth;\n\t\t\t\tlet containerMaxHeight = imgMaxHeight;\n\t\t\t\tlet containerWidth = imgMaxWidth;\n\t\t\t\tlet containerHeight = imgMaxHeight;\n\n\t\t\t\t// Checks if the target image has a different ratio than the original\n\t\t\t\t// one (thumbnail). Recalculates the width and height.\n\t\t\t\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\t\t\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t\t\t\t// If the width is reached before the height, it keeps the maxWidth\n\t\t\t\t\t\t// and recalculates the height unless the difference between the\n\t\t\t\t\t\t// maxHeight and the reducedHeight is higher than the maxWidth,\n\t\t\t\t\t\t// where it keeps the reducedHeight and recalculate the width.\n\t\t\t\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\t\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the height is reached before the width, it keeps the maxHeight\n\t\t\t\t\t\t// and recalculate the width unlesss the difference between the\n\t\t\t\t\t\t// maxWidth and the reducedWidth is higher than the maxHeight, where\n\t\t\t\t\t\t// it keeps the reducedWidth and recalculate the height.\n\t\t\t\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\t\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcontainerWidth = imgMaxWidth;\n\t\t\t\t\tcontainerHeight = imgMaxHeight;\n\t\t\t\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t\t\t\t// Calculates the max size of the container.\n\t\t\t\t\tif ( originalRatio > imgRatio ) {\n\t\t\t\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\t\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\t\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the image has been pixelated on purpose, it keeps that size.\n\t\t\t\tif (\n\t\t\t\t\toriginalWidth > containerWidth ||\n\t\t\t\t\toriginalHeight > containerHeight\n\t\t\t\t) {\n\t\t\t\t\tcontainerWidth = originalWidth;\n\t\t\t\t\tcontainerHeight = originalHeight;\n\t\t\t\t}\n\n\t\t\t\t// Calculates the final lightbox image size and the scale factor.\n\t\t\t\t// MaxWidth is either the window container (accounting for padding) or\n\t\t\t\t// the image resolution.\n\t\t\t\tlet horizontalPadding = 0;\n\t\t\t\tif ( window.innerWidth > 480 ) {\n\t\t\t\t\thorizontalPadding = 80;\n\t\t\t\t} else if ( window.innerWidth > 1920 ) {\n\t\t\t\t\thorizontalPadding = 160;\n\t\t\t\t}\n\t\t\t\tconst verticalPadding = 80;\n\n\t\t\t\tconst targetMaxWidth = Math.min(\n\t\t\t\t\twindow.innerWidth - horizontalPadding,\n\t\t\t\t\tcontainerWidth\n\t\t\t\t);\n\t\t\t\tconst targetMaxHeight = Math.min(\n\t\t\t\t\twindow.innerHeight - verticalPadding,\n\t\t\t\t\tcontainerHeight\n\t\t\t\t);\n\t\t\t\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\t\t\t\tif ( originalRatio > targetContainerRatio ) {\n\t\t\t\t\t// If targetMaxWidth is reached before targetMaxHeight.\n\t\t\t\t\tcontainerWidth = targetMaxWidth;\n\t\t\t\t\tcontainerHeight = containerWidth / originalRatio;\n\t\t\t\t} else {\n\t\t\t\t\t// If targetMaxHeight is reached before targetMaxWidth.\n\t\t\t\t\tcontainerHeight = targetMaxHeight;\n\t\t\t\t\tcontainerWidth = containerHeight * originalRatio;\n\t\t\t\t}\n\n\t\t\t\tconst containerScale = originalWidth / containerWidth;\n\t\t\t\tconst lightboxImgWidth =\n\t\t\t\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\t\t\t\tconst lightboxImgHeight =\n\t\t\t\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t\t\t\t// As of this writing, using the calculations above will render the\n\t\t\t\t// lightbox with a small, erroneous whitespace on the left side of the\n\t\t\t\t// image in iOS Safari, perhaps due to an inconsistency in how browsers\n\t\t\t\t// handle absolute positioning and CSS transformation. In any case,\n\t\t\t\t// adding 1 pixel to the container width and height solves the problem,\n\t\t\t\t// though this can be removed if the issue is fixed in the future.\n\t\t\t\tstate.overlayStyles = `\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${\n\t\t\t\t\t\twindow.innerWidth - document.documentElement.clientWidth\n\t\t\t\t\t}px;\n\t\t\t\t`;\n\t\t\t},\n\t\t\tsetButtonStyles() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tconst { ref } = getElement();\n\n\t\t\t\tstate.metadata[ imageId ].imageRef = ref;\n\t\t\t\tstate.metadata[ imageId ].currentSrc = ref.currentSrc;\n\n\t\t\t\tconst {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth,\n\t\t\t\t\toffsetHeight,\n\t\t\t\t} = ref;\n\n\t\t\t\t// If the image isn't loaded yet, it can't calculate where the button\n\t\t\t\t// should be.\n\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst figure = ref.parentElement;\n\t\t\t\tconst figureWidth = ref.parentElement.clientWidth;\n\n\t\t\t\t// It needs special handling for the height because a caption will cause\n\t\t\t\t// the figure to be taller than the image, which means it needs to\n\t\t\t\t// account for that when calculating the placement of the button in the\n\t\t\t\t// top right corner of the image.\n\t\t\t\tlet figureHeight = ref.parentElement.clientHeight;\n\t\t\t\tconst caption = figure.querySelector( 'figcaption' );\n\t\t\t\tif ( caption ) {\n\t\t\t\t\tconst captionComputedStyle =\n\t\t\t\t\t\twindow.getComputedStyle( caption );\n\t\t\t\t\tif (\n\t\t\t\t\t\t! [ 'absolute', 'fixed' ].includes(\n\t\t\t\t\t\t\tcaptionComputedStyle.position\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfigureHeight =\n\t\t\t\t\t\t\tfigureHeight -\n\t\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst buttonOffsetTop = figureHeight - offsetHeight;\n\t\t\t\tconst buttonOffsetRight = figureWidth - offsetWidth;\n\n\t\t\t\tlet imageButtonTop = buttonOffsetTop + 16;\n\t\t\t\tlet imageButtonRight = buttonOffsetRight + 16;\n\n\t\t\t\t// In the case of an image with object-fit: contain, the size of the\n\t\t\t\t// <img> element can be larger than the image itself, so it needs to\n\t\t\t\t// calculate where to place the button.\n\t\t\t\tif ( state.metadata[ imageId ].scaleAttr === 'contain' ) {\n\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t\t// If it reaches the width first, it keeps the width and compute the\n\t\t\t\t\t\t// height.\n\t\t\t\t\t\tconst referenceHeight = offsetWidth / naturalRatio;\n\t\t\t\t\t\timageButtonTop =\n\t\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t\timageButtonRight = buttonOffsetRight + 16;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If it reaches the height first, it keeps the height and compute\n\t\t\t\t\t\t// the width.\n\t\t\t\t\t\tconst referenceWidth = offsetHeight * naturalRatio;\n\t\t\t\t\t\timageButtonTop = buttonOffsetTop + 16;\n\t\t\t\t\t\timageButtonRight =\n\t\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstate.metadata[ imageId ].imageButtonTop = imageButtonTop;\n\t\t\t\tstate.metadata[ imageId ].imageButtonRight = imageButtonRight;\n\t\t\t},\n\t\t\tsetOverlayFocus() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t// Moves the focus to the dialog when it opens.\n\t\t\t\t\tconst { ref } = getElement();\n\t\t\t\t\tref.focus();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitTriggerButton() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tstate.metadata[ imageId ].buttonRef = ref;\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n"],
|
|
5
|
-
"mappings": "AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAQP,IAAI,aAAa;AAQjB,IAAI,gBAAgB;AAEpB,MAAM,EAAE,OAAO,SAAS,UAAU,IAAI;AAAA,E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CAAqB,oBAAoB;AAAA,UAC1C,OAAO;AACN,iCAAqB;AACrB,gCAAoB,qBAAqB;AAAA,UAC1C;AAAA,QACD;AAGA,YACC,gBAAgB,kBAChB,iBAAiB,iBAChB;AACD,2BAAiB;AACjB,4BAAkB;AAAA,QACnB;AAKA,YAAI,oBAAoB;AACxB,YAAK,OAAO,aAAa,KAAM;AAC9B,8BAAoB;AAAA,QACrB,WAAY,OAAO,aAAa,MAAO;AACtC,8BAAoB;AAAA,QACrB;AACA,cAAM,kBAAkB;AAExB,cAAM,iBAAiB,KAAK;AAAA,UAC3B,OAAO,aAAa;AAAA,UACpB;AAAA,QACD;AACA,cAAM,kBAAkB,KAAK;AAAA,UAC5B,OAAO,cAAc;AAAA,UACrB;AAAA,QACD;AACA,cAAM,uBAAuB,iBAAiB;AAE9C,YAAK,gBAAgB,sBAAuB;AAE3C,2BAAiB;AACjB,4BAAkB,iBAAiB;AAAA,QACpC,OAAO;AAEN,4BAAkB;AAClB,2BAAiB,kBAAkB;AAAA,QACpC;AAEA,cAAM,iBAAiB,gBAAgB;AACvC,cAAM,mBACL,eAAgB,iBAAiB;AAClC,cAAM,oBACL,gBAAiB,kBAAkB;AAQpC,cAAM,gBAAgB;AAAA,4CACmB,UAAW;AAAA,6CACV,UAAW;AAAA,uCACjB,iBAAiB,CAAE;AAAA,wCAClB,kBAAkB,CAAE;AAAA,mCACzB,gBAAiB;AAAA,oCAChB,iBAAkB;AAAA,6BACzB,cAAe;AAAA,uCAEvC,OAAO,aAAa,SAAS,gBAAgB,WAC9C;AAAA;AAAA,MAEF;AAAA,MACA,kBAAkB;AACjB,cAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tstore,\n\tgetContext,\n\tgetElement,\n\twithSyncEvent,\n} from '@wordpress/interactivity';\n\n/**\n * Tracks whether user is touching screen; used to differentiate behavior for\n * touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/**\n * Tracks the last time the screen was touched; used to differentiate behavior\n * for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\nconst { state, actions, callbacks } = store(\n\t'core/image',\n\t{\n\t\tstate: {\n\t\t\tcurrentImageId: null,\n\t\t\tget currentImage() {\n\t\t\t\treturn state.metadata[ state.currentImageId ];\n\t\t\t},\n\t\t\tget overlayOpened() {\n\t\t\t\treturn state.currentImageId !== null;\n\t\t\t},\n\t\t\tget roleAttribute() {\n\t\t\t\treturn state.overlayOpened ? 'dialog' : null;\n\t\t\t},\n\t\t\tget ariaModal() {\n\t\t\t\treturn state.overlayOpened ? 'true' : null;\n\t\t\t},\n\t\t\tget enlargedSrc() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.currentImage.uploadedSrc ||\n\t\t\t\t\t'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='\n\t\t\t\t);\n\t\t\t},\n\t\t\tget figureStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.currentImage.figureStyles?.replace(\n\t\t\t\t\t\t/margin[^;]*;?/g,\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\tget imgStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.currentImage.imgStyles?.replace(\n\t\t\t\t\t\t/;$/,\n\t\t\t\t\t\t''\n\t\t\t\t\t) }; object-fit:cover;`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget imageButtonRight() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\treturn state.metadata[ imageId ].imageButtonRight;\n\t\t\t},\n\t\t\tget imageButtonTop() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\treturn state.metadata[ imageId ].imageButtonTop;\n\t\t\t},\n\t\t\tget isContentHidden() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayEnabled && state.currentImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentVisible() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\t! state.overlayEnabled &&\n\t\t\t\t\tstate.currentImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tshowLightbox() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails out if the image has not loaded yet.\n\t\t\t\tif ( ! state.metadata[ imageId ].imageRef?.complete ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Stores the positions of the scroll to fix it until the overlay is\n\t\t\t\t// closed.\n\t\t\t\tstate.scrollTopReset = document.documentElement.scrollTop;\n\t\t\t\tstate.scrollLeftReset = document.documentElement.scrollLeft;\n\n\t\t\t\t// Sets the current expanded image in the state and enables the overlay.\n\t\t\t\tstate.overlayEnabled = true;\n\t\t\t\tstate.currentImageId = imageId;\n\n\t\t\t\t// Computes the styles of the overlay for the animation.\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t},\n\t\t\thideLightbox() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tstate.overlayEnabled = false;\n\n\t\t\t\t\t// Waits until the close animation has completed before allowing a\n\t\t\t\t\t// user to scroll again. The duration of this animation is defined in\n\t\t\t\t\t// the `styles.scss` file, but in any case we should wait a few\n\t\t\t\t\t// milliseconds longer than the duration, otherwise a user may scroll\n\t\t\t\t\t// too soon and cause the animation to look sloppy.\n\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t// Delays before changing the focus. Otherwise the focus ring will\n\t\t\t\t\t\t// appear on Firefox before the image has finished animating, which\n\t\t\t\t\t\t// looks broken.\n\t\t\t\t\t\tstate.currentImage.buttonRef.focus( {\n\t\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Resets the current image id to mark the overlay as closed.\n\t\t\t\t\t\tstate.currentImageId = null;\n\t\t\t\t\t}, 450 );\n\t\t\t\t}\n\t\t\t},\n\t\t\thandleKeydown: withSyncEvent( ( event ) => {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t// Focuses the close button when the user presses the tab key.\n\t\t\t\t\tif ( event.key === 'Tab' ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tconst { ref } = getElement();\n\t\t\t\t\t\tref.querySelector( 'button' ).focus();\n\t\t\t\t\t}\n\t\t\t\t\t// Closes the lightbox when the user presses the escape key.\n\t\t\t\t\tif ( event.key === 'Escape' ) {\n\t\t\t\t\t\tactions.hideLightbox();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchMove: withSyncEvent( ( event ) => {\n\t\t\t\t// On mobile devices, prevents triggering the scroll event because\n\t\t\t\t// otherwise the page jumps around when it resets the scroll position.\n\t\t\t\t// This also means that closing the lightbox requires that a user\n\t\t\t\t// perform a simple tap. This may be changed in the future if there is a\n\t\t\t\t// better alternative to override or reset the scroll position during\n\t\t\t\t// swipe actions.\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchStart() {\n\t\t\t\tisTouching = true;\n\t\t\t},\n\t\t\thandleTouchEnd() {\n\t\t\t\t// Waits a few milliseconds before resetting to ensure that pinch to\n\t\t\t\t// zoom works consistently on mobile devices when the lightbox is open.\n\t\t\t\tlastTouchTime = Date.now();\n\t\t\t\tisTouching = false;\n\t\t\t},\n\t\t\thandleScroll() {\n\t\t\t\t// Prevents scrolling behaviors that trigger content shift while the\n\t\t\t\t// lightbox is open. It would be better to accomplish through CSS alone,\n\t\t\t\t// but using overflow: hidden is currently the only way to do so and\n\t\t\t\t// that causes a layout to shift and prevents the zoom animation from\n\t\t\t\t// working in some cases because it's not possible to account for the\n\t\t\t\t// layout shift when doing the animation calculations. Instead, it uses\n\t\t\t\t// JavaScript to prevent and reset the scrolling behavior.\n\t\t\t\tif ( state.overlayOpened ) {\n\t\t\t\t\t// Avoids overriding the scroll behavior on mobile devices because\n\t\t\t\t\t// doing so breaks the pinch to zoom functionality, and users should\n\t\t\t\t\t// be able to zoom in further on the high-res image.\n\t\t\t\t\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t\t\t\t\t// It doesn't rely on `event.preventDefault()` to prevent scrolling\n\t\t\t\t\t\t// because the scroll event can't be canceled, so it resets the\n\t\t\t\t\t\t// position instead.\n\t\t\t\t\t\twindow.scrollTo(\n\t\t\t\t\t\t\tstate.scrollLeftReset,\n\t\t\t\t\t\t\tstate.scrollTopReset\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\tcallbacks: {\n\t\t\tsetOverlayStyles() {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth: originalWidth,\n\t\t\t\t\toffsetHeight: originalHeight,\n\t\t\t\t} = state.currentImage.imageRef;\n\t\t\t\tlet { x: screenPosX, y: screenPosY } =\n\t\t\t\t\tstate.currentImage.imageRef.getBoundingClientRect();\n\n\t\t\t\t// Natural ratio of the image clicked to open the lightbox.\n\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t// Original ratio of the image clicked to open the lightbox.\n\t\t\t\tlet originalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// If it has object-fit: contain, recalculates the original sizes\n\t\t\t\t// and the screen position without the blank spaces.\n\t\t\t\tif ( state.currentImage.scaleAttr === 'contain' ) {\n\t\t\t\t\tif ( naturalRatio > originalRatio ) {\n\t\t\t\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the top space.\n\t\t\t\t\t\tscreenPosY +=\n\t\t\t\t\t\t\t( originalHeight - heightWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalHeight = heightWithoutSpace;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the left space.\n\t\t\t\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalWidth = widthWithoutSpace;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\toriginalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// Typically, it uses the image's full-sized dimensions. If those\n\t\t\t\t// dimensions have not been set (i.e. an external image with only one\n\t\t\t\t// size), the image's dimensions in the lightbox are the same\n\t\t\t\t// as those of the image in the content.\n\t\t\t\tlet imgMaxWidth = parseFloat(\n\t\t\t\t\tstate.currentImage.targetWidth !== 'none'\n\t\t\t\t\t\t? state.currentImage.targetWidth\n\t\t\t\t\t\t: naturalWidth\n\t\t\t\t);\n\t\t\t\tlet imgMaxHeight = parseFloat(\n\t\t\t\t\tstate.currentImage.targetHeight !== 'none'\n\t\t\t\t\t\t? state.currentImage.targetHeight\n\t\t\t\t\t\t: naturalHeight\n\t\t\t\t);\n\n\t\t\t\t// Ratio of the biggest image stored in the database.\n\t\t\t\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\t\t\t\tlet containerMaxWidth = imgMaxWidth;\n\t\t\t\tlet containerMaxHeight = imgMaxHeight;\n\t\t\t\tlet containerWidth = imgMaxWidth;\n\t\t\t\tlet containerHeight = imgMaxHeight;\n\n\t\t\t\t// Checks if the target image has a different ratio than the original\n\t\t\t\t// one (thumbnail). Recalculates the width and height.\n\t\t\t\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\t\t\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t\t\t\t// If the width is reached before the height, it keeps the maxWidth\n\t\t\t\t\t\t// and recalculates the height unless the difference between the\n\t\t\t\t\t\t// maxHeight and the reducedHeight is higher than the maxWidth,\n\t\t\t\t\t\t// where it keeps the reducedHeight and recalculate the width.\n\t\t\t\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\t\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the height is reached before the width, it keeps the maxHeight\n\t\t\t\t\t\t// and recalculate the width unlesss the difference between the\n\t\t\t\t\t\t// maxWidth and the reducedWidth is higher than the maxHeight, where\n\t\t\t\t\t\t// it keeps the reducedWidth and recalculate the height.\n\t\t\t\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\t\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcontainerWidth = imgMaxWidth;\n\t\t\t\t\tcontainerHeight = imgMaxHeight;\n\t\t\t\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t\t\t\t// Calculates the max size of the container.\n\t\t\t\t\tif ( originalRatio > imgRatio ) {\n\t\t\t\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\t\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\t\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the image has been pixelated on purpose, it keeps that size.\n\t\t\t\tif (\n\t\t\t\t\toriginalWidth > containerWidth ||\n\t\t\t\t\toriginalHeight > containerHeight\n\t\t\t\t) {\n\t\t\t\t\tcontainerWidth = originalWidth;\n\t\t\t\t\tcontainerHeight = originalHeight;\n\t\t\t\t}\n\n\t\t\t\t// Calculates the final lightbox image size and the scale factor.\n\t\t\t\t// MaxWidth is either the window container (accounting for padding) or\n\t\t\t\t// the image resolution.\n\t\t\t\tlet horizontalPadding = 0;\n\t\t\t\tif ( window.innerWidth > 480 ) {\n\t\t\t\t\thorizontalPadding = 80;\n\t\t\t\t} else if ( window.innerWidth > 1920 ) {\n\t\t\t\t\thorizontalPadding = 160;\n\t\t\t\t}\n\t\t\t\tconst verticalPadding = 80;\n\n\t\t\t\tconst targetMaxWidth = Math.min(\n\t\t\t\t\twindow.innerWidth - horizontalPadding,\n\t\t\t\t\tcontainerWidth\n\t\t\t\t);\n\t\t\t\tconst targetMaxHeight = Math.min(\n\t\t\t\t\twindow.innerHeight - verticalPadding,\n\t\t\t\t\tcontainerHeight\n\t\t\t\t);\n\t\t\t\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\t\t\t\tif ( originalRatio > targetContainerRatio ) {\n\t\t\t\t\t// If targetMaxWidth is reached before targetMaxHeight.\n\t\t\t\t\tcontainerWidth = targetMaxWidth;\n\t\t\t\t\tcontainerHeight = containerWidth / originalRatio;\n\t\t\t\t} else {\n\t\t\t\t\t// If targetMaxHeight is reached before targetMaxWidth.\n\t\t\t\t\tcontainerHeight = targetMaxHeight;\n\t\t\t\t\tcontainerWidth = containerHeight * originalRatio;\n\t\t\t\t}\n\n\t\t\t\tconst containerScale = originalWidth / containerWidth;\n\t\t\t\tconst lightboxImgWidth =\n\t\t\t\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\t\t\t\tconst lightboxImgHeight =\n\t\t\t\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t\t\t\t// As of this writing, using the calculations above will render the\n\t\t\t\t// lightbox with a small, erroneous whitespace on the left side of the\n\t\t\t\t// image in iOS Safari, perhaps due to an inconsistency in how browsers\n\t\t\t\t// handle absolute positioning and CSS transformation. In any case,\n\t\t\t\t// adding 1 pixel to the container width and height solves the problem,\n\t\t\t\t// though this can be removed if the issue is fixed in the future.\n\t\t\t\tstate.overlayStyles = `\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${\n\t\t\t\t\t\twindow.innerWidth - document.documentElement.clientWidth\n\t\t\t\t\t}px;\n\t\t\t\t`;\n\t\t\t},\n\t\t\tsetButtonStyles() {\n\t\t\t\tconst { ref } = getElement();\n\n\t\t\t\t// This guard prevents errors in images with the `srcset`\n\t\t\t\t// attribute, which can dispatch `load` events even after DOM\n\t\t\t\t// removal. Preact doesn't automatically clean up `load` event\n\t\t\t\t// listeners on unmounted `img` elements (see\n\t\t\t\t// https://github.com/preactjs/preact/issues/3141).\n\t\t\t\tif ( ! ref ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\tstate.metadata[ imageId ].imageRef = ref;\n\t\t\t\tstate.metadata[ imageId ].currentSrc = ref.currentSrc;\n\n\t\t\t\tconst {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth,\n\t\t\t\t\toffsetHeight,\n\t\t\t\t} = ref;\n\n\t\t\t\t// If the image isn't loaded yet, it can't calculate where the button\n\t\t\t\t// should be.\n\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst figure = ref.parentElement;\n\t\t\t\tconst figureWidth = ref.parentElement.clientWidth;\n\n\t\t\t\t// It needs special handling for the height because a caption will cause\n\t\t\t\t// the figure to be taller than the image, which means it needs to\n\t\t\t\t// account for that when calculating the placement of the button in the\n\t\t\t\t// top right corner of the image.\n\t\t\t\tlet figureHeight = ref.parentElement.clientHeight;\n\t\t\t\tconst caption = figure.querySelector( 'figcaption' );\n\t\t\t\tif ( caption ) {\n\t\t\t\t\tconst captionComputedStyle =\n\t\t\t\t\t\twindow.getComputedStyle( caption );\n\t\t\t\t\tif (\n\t\t\t\t\t\t! [ 'absolute', 'fixed' ].includes(\n\t\t\t\t\t\t\tcaptionComputedStyle.position\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfigureHeight =\n\t\t\t\t\t\t\tfigureHeight -\n\t\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst buttonOffsetTop = figureHeight - offsetHeight;\n\t\t\t\tconst buttonOffsetRight = figureWidth - offsetWidth;\n\n\t\t\t\tlet imageButtonTop = buttonOffsetTop + 16;\n\t\t\t\tlet imageButtonRight = buttonOffsetRight + 16;\n\n\t\t\t\t// In the case of an image with object-fit: contain, the size of the\n\t\t\t\t// <img> element can be larger than the image itself, so it needs to\n\t\t\t\t// calculate where to place the button.\n\t\t\t\tif ( state.metadata[ imageId ].scaleAttr === 'contain' ) {\n\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t\t// If it reaches the width first, it keeps the width and compute the\n\t\t\t\t\t\t// height.\n\t\t\t\t\t\tconst referenceHeight = offsetWidth / naturalRatio;\n\t\t\t\t\t\timageButtonTop =\n\t\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t\timageButtonRight = buttonOffsetRight + 16;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If it reaches the height first, it keeps the height and compute\n\t\t\t\t\t\t// the width.\n\t\t\t\t\t\tconst referenceWidth = offsetHeight * naturalRatio;\n\t\t\t\t\t\timageButtonTop = buttonOffsetTop + 16;\n\t\t\t\t\t\timageButtonRight =\n\t\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstate.metadata[ imageId ].imageButtonTop = imageButtonTop;\n\t\t\t\tstate.metadata[ imageId ].imageButtonRight = imageButtonRight;\n\t\t\t},\n\t\t\tsetOverlayFocus() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t// Moves the focus to the dialog when it opens.\n\t\t\t\t\tconst { ref } = getElement();\n\t\t\t\t\tref.focus();\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitTriggerButton() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tstate.metadata[ imageId ].buttonRef = ref;\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n"],
|
|
5
|
+
"mappings": "AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAQP,IAAI,aAAa;AAQjB,IAAI,gBAAgB;AAEpB,MAAM,EAAE,OAAO,SAAS,UAAU,IAAI;AAAA,EACrC;AAAA,EAC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