@wordpress/edit-widgets 6.54.2-next.v.202608281122.0 → 6.55.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 +8 -1
- package/build/blocks/widget-area/index.cjs +2 -0
- package/build/blocks/widget-area/index.cjs.map +3 -3
- package/build/components/error-boundary/index.cjs +112 -19
- package/build/components/error-boundary/index.cjs.map +2 -2
- package/build/components/sidebar/widget-areas.cjs +1 -1
- package/build/components/sidebar/widget-areas.cjs.map +2 -2
- package/build/components/widget-areas-block-editor-provider/index.cjs +1 -2
- package/build/components/widget-areas-block-editor-provider/index.cjs.map +2 -2
- package/build-module/blocks/widget-area/index.mjs +2 -0
- package/build-module/blocks/widget-area/index.mjs.map +2 -2
- package/build-module/components/error-boundary/index.mjs +113 -20
- package/build-module/components/error-boundary/index.mjs.map +2 -2
- package/build-module/components/sidebar/widget-areas.mjs +2 -2
- package/build-module/components/sidebar/widget-areas.mjs.map +2 -2
- package/build-module/components/widget-areas-block-editor-provider/index.mjs +1 -2
- package/build-module/components/widget-areas-block-editor-provider/index.mjs.map +2 -2
- package/build-style/style-rtl.css +18 -6
- package/build-style/style.css +18 -6
- package/package.json +34 -33
- package/src/blocks/widget-area/index.js +2 -0
- package/src/components/error-boundary/index.jsx +138 -23
- package/src/components/error-boundary/style.scss +16 -3
- package/src/components/error-boundary/test/{error-boundary.jsx → error-boundary.jsdom.test.jsx} +7 -3
- package/src/components/sidebar/widget-areas.jsx +2 -2
- package/src/components/welcome-guide/style.scss +1 -1
- package/src/components/widget-areas-block-editor-provider/index.jsx +0 -1
- package/src/store/test/reducer.js +1 -0
- package/src/store/test/{selectors.js → selectors.jsdom.test.js} +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
## 6.
|
|
5
|
+
## 6.55.0 (2026-09-10)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- Error boundary: Surface debugging details ([#82099](https://github.com/WordPress/gutenberg/pull/82099)).
|
|
10
|
+
- Widget areas: Use the `layout` icon instead of the default block icon ([#61028](https://github.com/WordPress/gutenberg/issues/61028)).
|
|
6
11
|
|
|
7
12
|
### Bug Fixes
|
|
8
13
|
|
|
14
|
+
- `WelcomeGuide`: Keep the modal close icon white on hover now that it is stroke-based. ([#78812](https://github.com/WordPress/gutenberg/pull/78812))
|
|
9
15
|
- Prevent an error in `canInsertBlockInWidgetArea` when no widget area blocks are present.
|
|
10
16
|
|
|
11
17
|
### Internal
|
|
12
18
|
|
|
19
|
+
- Stop passing the unused `editorTool` block editor setting; the selector that read it was removed with the Write/Design tool in [#72193](https://github.com/WordPress/gutenberg/pull/72193) ([#82677](https://github.com/WordPress/gutenberg/pull/82677)).
|
|
13
20
|
- Remove unused dependency `@wordpress/reusable-blocks` ([#82103](https://github.com/WordPress/gutenberg/pull/82103)).
|
|
14
21
|
- Use the `.jsx` extension for JavaScript source files that contain JSX ([#80990](https://github.com/WordPress/gutenberg/pull/80990)).
|
|
15
22
|
|
|
@@ -35,6 +35,7 @@ __export(widget_area_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(widget_area_exports);
|
|
37
37
|
var import_i18n = require("@wordpress/i18n");
|
|
38
|
+
var import_icons = require("@wordpress/icons");
|
|
38
39
|
var import_block = __toESM(require("./block.json"));
|
|
39
40
|
var import_edit = __toESM(require("./edit/index.cjs"));
|
|
40
41
|
var { name } = import_block.default;
|
|
@@ -42,6 +43,7 @@ var settings = {
|
|
|
42
43
|
title: (0, import_i18n.__)("Widget Area"),
|
|
43
44
|
description: (0, import_i18n.__)("A widget area container."),
|
|
44
45
|
__experimentalLabel: ({ name: label }) => label,
|
|
46
|
+
icon: import_icons.layout,
|
|
45
47
|
edit: import_edit.default
|
|
46
48
|
};
|
|
47
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/blocks/widget-area/index.js"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,mBAAqB;AACrB,kBAAiB;AAEjB,IAAM,EAAE,KAAK,IAAI,aAAAA;AAGV,IAAM,WAAW;AAAA,EACvB,WAAO,gBAAI,aAAc;AAAA,EACzB,iBAAa,gBAAI,0BAA2B;AAAA,EAC5C,qBAAqB,CAAE,EAAE,MAAM,MAAM,MAAO;AAAA,EAC5C,kBAAAC;AACD;",
|
|
6
|
-
"names": ["metadata", "edit"]
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { layout as icon } from '@wordpress/icons';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\ticon,\n\tedit,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,mBAA+B;AAC/B,mBAAqB;AACrB,kBAAiB;AAEjB,IAAM,EAAE,KAAK,IAAI,aAAAA;AAGV,IAAM,WAAW;AAAA,EACvB,WAAO,gBAAI,aAAc;AAAA,EACzB,iBAAa,gBAAI,0BAA2B;AAAA,EAC5C,qBAAqB,CAAE,EAAE,MAAM,MAAM,MAAO;AAAA,EAC5C,mBAAAC;AAAA,EACA,kBAAAC;AACD;",
|
|
6
|
+
"names": ["metadata", "icon", "edit"]
|
|
7
7
|
}
|
|
@@ -24,45 +24,138 @@ __export(error_boundary_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(error_boundary_exports);
|
|
25
25
|
var import_element = require("@wordpress/element");
|
|
26
26
|
var import_i18n = require("@wordpress/i18n");
|
|
27
|
-
var
|
|
28
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
27
|
+
var import_ui = require("@wordpress/ui");
|
|
29
28
|
var import_compose = require("@wordpress/compose");
|
|
30
29
|
var import_hooks = require("@wordpress/hooks");
|
|
31
30
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
function getErrorName(error) {
|
|
32
|
+
return error instanceof Error && error.name || "Error";
|
|
33
|
+
}
|
|
34
|
+
function getErrorMessage(error) {
|
|
35
|
+
if (typeof error === "string" && error) {
|
|
36
|
+
return error;
|
|
37
|
+
}
|
|
38
|
+
if (typeof error?.message === "string" && error.message) {
|
|
39
|
+
return error.message;
|
|
40
|
+
}
|
|
41
|
+
return "An unknown error occurred.";
|
|
35
42
|
}
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
|
|
43
|
+
function getErrorSections(error, componentStack) {
|
|
44
|
+
const sections = [
|
|
45
|
+
{ label: getErrorName(error), content: getErrorMessage(error) }
|
|
39
46
|
];
|
|
40
|
-
|
|
47
|
+
if (error?.stack) {
|
|
48
|
+
sections.push({
|
|
49
|
+
label: "Stack",
|
|
50
|
+
content: error.stack.trim(),
|
|
51
|
+
preformatted: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (componentStack) {
|
|
55
|
+
sections.push({
|
|
56
|
+
label: "Component stack",
|
|
57
|
+
content: componentStack.trim(),
|
|
58
|
+
preformatted: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
sections.push({
|
|
62
|
+
label: "Environment",
|
|
63
|
+
content: `User agent: ${window.navigator.userAgent}`,
|
|
64
|
+
preformatted: true
|
|
65
|
+
});
|
|
66
|
+
return sections;
|
|
67
|
+
}
|
|
68
|
+
function getErrorReport(error, componentStack) {
|
|
69
|
+
const sections = getErrorSections(error, componentStack).map(
|
|
70
|
+
({ label, content, preformatted }) => `**${label}**
|
|
71
|
+
|
|
72
|
+
${preformatted ? `\`\`\`
|
|
73
|
+
${content}
|
|
74
|
+
\`\`\`` : content}`
|
|
75
|
+
);
|
|
76
|
+
return ["### Error report", ...sections].join("\n\n");
|
|
77
|
+
}
|
|
78
|
+
function CopyButton({ text, children, variant = "outline" }) {
|
|
79
|
+
const ref = (0, import_compose.useCopyToClipboard)(text);
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.ActionButton, { variant, ref, children });
|
|
81
|
+
}
|
|
82
|
+
function ErrorReport({ error, componentStack }) {
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
|
+
import_ui.Stack,
|
|
85
|
+
{
|
|
86
|
+
className: "edit-widgets-error-boundary__report",
|
|
87
|
+
direction: "column",
|
|
88
|
+
gap: "md",
|
|
89
|
+
children: getErrorSections(error, componentStack).map(
|
|
90
|
+
({ label, content }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "xs", children: [
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Text, { variant: "heading-md", children: label }),
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "edit-widgets-error-boundary__report-section", children: content })
|
|
93
|
+
] }, label)
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function ErrorDetails({ error, componentStack }) {
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.CollapsibleCard.Root, { className: "edit-widgets-error-boundary__details", children: [
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.CollapsibleCard.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Card.Title, { children: (0, import_i18n.__)("Error details") }) }),
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.CollapsibleCard.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
102
|
+
ErrorReport,
|
|
103
|
+
{
|
|
104
|
+
error,
|
|
105
|
+
componentStack
|
|
106
|
+
}
|
|
107
|
+
) })
|
|
108
|
+
] });
|
|
41
109
|
}
|
|
42
110
|
var ErrorBoundary = class extends import_element.Component {
|
|
43
111
|
constructor() {
|
|
44
112
|
super(...arguments);
|
|
45
113
|
this.state = {
|
|
46
|
-
error: null
|
|
114
|
+
error: null,
|
|
115
|
+
componentStack: null
|
|
47
116
|
};
|
|
48
117
|
}
|
|
49
|
-
componentDidCatch(error) {
|
|
50
|
-
|
|
118
|
+
componentDidCatch(error, errorInfo) {
|
|
119
|
+
this.setState({ componentStack: errorInfo?.componentStack });
|
|
120
|
+
(0, import_hooks.doAction)("editor.ErrorBoundary.errorLogged", error, errorInfo);
|
|
51
121
|
}
|
|
52
122
|
static getDerivedStateFromError(error) {
|
|
53
123
|
return { error };
|
|
54
124
|
}
|
|
55
125
|
render() {
|
|
56
|
-
|
|
126
|
+
const { error, componentStack } = this.state;
|
|
127
|
+
if (!error) {
|
|
57
128
|
return this.props.children;
|
|
58
129
|
}
|
|
59
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
60
|
-
|
|
130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
131
|
+
import_ui.Stack,
|
|
61
132
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
133
|
+
className: "edit-widgets-error-boundary",
|
|
134
|
+
direction: "column",
|
|
135
|
+
gap: "lg",
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Notice.Root, { intent: "error", children: [
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Title, { children: (0, import_i18n.__)("The editor has crashed") }),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Description, { children: (0, import_i18n.__)(
|
|
140
|
+
"An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search."
|
|
141
|
+
) }),
|
|
142
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Actions, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
143
|
+
CopyButton,
|
|
144
|
+
{
|
|
145
|
+
variant: "solid",
|
|
146
|
+
text: () => getErrorReport(error, componentStack),
|
|
147
|
+
children: (0, import_i18n.__)("Copy error")
|
|
148
|
+
}
|
|
149
|
+
) })
|
|
150
|
+
] }),
|
|
151
|
+
globalThis.SCRIPT_DEBUG ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
+
ErrorDetails,
|
|
153
|
+
{
|
|
154
|
+
error,
|
|
155
|
+
componentStack
|
|
156
|
+
}
|
|
157
|
+
) : null
|
|
158
|
+
]
|
|
66
159
|
}
|
|
67
160
|
);
|
|
68
161
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/error-boundary/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAAmB;
|
|
4
|
+
"sourcesContent": ["import { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n// eslint-disable-next-line @wordpress/use-recommended-components -- The fallback UI renders outside the editor's notice system.\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"edit-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"edit-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"edit-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"edit-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>\n\t\t\t\t\t\t{ __( 'The editor has crashed' ) }\n\t\t\t\t\t</Notice.Title>\n\t\t\t\t\t<Notice.Description>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAAmB;AAEnB,gBAA2D;AAC3D,qBAAmC;AACnC,mBAAyB;AAoEvB;AAjEF,SAAS,aAAc,OAAQ;AAC9B,SAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,OAAQ;AACjC,MAAK,OAAO,UAAU,YAAY,OAAQ;AACzC,WAAO;AAAA,EACR;AA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AAA,YACA,4CAAC,iBAAO,SAAP,EACA;AAAA,cAAC;AAAA;AAAA,gBACA,SAAQ;AAAA,gBACR,MAAO,MACN,eAAgB,OAAO,cAAe;AAAA,gBAGrC,8BAAI,YAAa;AAAA;AAAA,YACpB,GACD;AAAA,aACD;AAAA,UACE,WAAW,eACZ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD,IACG;AAAA;AAAA;AAAA,IACL;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -57,7 +57,7 @@ function WidgetAreas({ selectedWidgetAreaId }) {
|
|
|
57
57
|
description = selectedWidgetArea.description;
|
|
58
58
|
}
|
|
59
59
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "edit-widgets-widget-areas", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "edit-widgets-widget-areas__top-container", children: [
|
|
60
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockIcon, { icon: import_icons.
|
|
60
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockIcon, { icon: import_icons.layout }),
|
|
61
61
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
62
62
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
63
63
|
"p",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar/widget-areas.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,qBAAwB;AACxB,
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { layout } from '@wordpress/icons';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { safeHTML } from '@wordpress/dom';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WidgetAreas( { selectedWidgetAreaId } ) {\n\tconst widgetAreas = useSelect(\n\t\t( select ) => select( editWidgetsStore ).getWidgetAreas(),\n\t\t[]\n\t);\n\n\tconst selectedWidgetArea = useMemo(\n\t\t() =>\n\t\t\tselectedWidgetAreaId &&\n\t\t\twidgetAreas?.find(\n\t\t\t\t( widgetArea ) => widgetArea.id === selectedWidgetAreaId\n\t\t\t),\n\t\t[ selectedWidgetAreaId, widgetAreas ]\n\t);\n\n\tlet description;\n\tif ( ! selectedWidgetArea ) {\n\t\tdescription = __(\n\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t'Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'\n\t\t);\n\t} else if ( selectedWidgetAreaId === 'wp_inactive_widgets' ) {\n\t\tdescription = __(\n\t\t\t'Blocks in this Widget Area will not be displayed in your site.'\n\t\t);\n\t} else {\n\t\tdescription = selectedWidgetArea.description;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-widgets-widget-areas\">\n\t\t\t<div className=\"edit-widgets-widget-areas__top-container\">\n\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t<div>\n\t\t\t\t\t<p\n\t\t\t\t\t\t// Use `dangerouslySetInnerHTML` to keep backwards\n\t\t\t\t\t\t// compatibility. Basic markup in the description is an\n\t\t\t\t\t\t// established feature of WordPress.\n\t\t\t\t\t\t// @see https://github.com/WordPress/gutenberg/issues/33106\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: safeHTML( description ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ widgetAreas?.length === 0 && (\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Your theme does not contain any Widget Areas.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! selectedWidgetArea && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ addQueryArgs( 'customize.php', {\n\t\t\t\t\t\t\t\t'autofocus[panel]': 'widgets',\n\t\t\t\t\t\t\t\treturn: window.location.pathname,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Manage with live preview' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,qBAAwB;AACxB,mBAAuB;AACvB,0BAA0B;AAC1B,wBAAuB;AACvB,kBAAmB;AACnB,iBAA6B;AAC7B,iBAAyB;AACzB,mBAA0C;AAkCtC;AAhCW,SAAR,YAA8B,EAAE,qBAAqB,GAAI;AAC/D,QAAM,kBAAc;AAAA,IACnB,CAAE,WAAY,OAAQ,aAAAA,KAAiB,EAAE,eAAe;AAAA,IACxD,CAAC;AAAA,EACF;AAEA,QAAM,yBAAqB;AAAA,IAC1B,MACC,wBACA,aAAa;AAAA,MACZ,CAAE,eAAgB,WAAW,OAAO;AAAA,IACrC;AAAA,IACD,CAAE,sBAAsB,WAAY;AAAA,EACrC;AAEA,MAAI;AACJ,MAAK,CAAE,oBAAqB;AAC3B,sBAAc;AAAA;AAAA,MAEb;AAAA,IACD;AAAA,EACD,WAAY,yBAAyB,uBAAwB;AAC5D,sBAAc;AAAA,MACb;AAAA,IACD;AAAA,EACD,OAAO;AACN,kBAAc,mBAAmB;AAAA,EAClC;AAEA,SACC,4CAAC,SAAI,WAAU,6BACd,uDAAC,SAAI,WAAU,4CACd;AAAA,gDAAC,iCAAU,MAAO,qBAAS;AAAA,IAC3B,6CAAC,SACA;AAAA;AAAA,QAAC;AAAA;AAAA,UAKA,yBAA0B;AAAA,YACzB,YAAQ,qBAAU,WAAY;AAAA,UAC/B;AAAA;AAAA,MACD;AAAA,MACE,aAAa,WAAW,KACzB,4CAAC,OACE;AAAA,QACD;AAAA,MACD,GACD;AAAA,MAEC,CAAE,sBACH;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,UAAO,yBAAc,iBAAiB;AAAA,YACrC,oBAAoB;AAAA,YACpB,QAAQ,OAAO,SAAS;AAAA,UACzB,CAAE;AAAA,UACF,SAAQ;AAAA,UAEN,8BAAI,0BAA2B;AAAA;AAAA,MAClC;AAAA,OAEF;AAAA,KACD,GACD;AAEF;",
|
|
6
6
|
"names": ["editWidgetsStore"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/widget-areas-block-editor-provider/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAiC;AACjC,qBAAiC;AACjC,yBAA4B;AAC5B,kBAAuC;AACvC,uBAAyD;AACzD,qBAAwB;AACxB,0BAAsD;AACtD,sBAAuD;AACvD,yBAA0C;AAC1C,gCAA8B;AAC9B,mBAAwD;AACxD,2CAAsC;AACtC,mBAA0C;AAC1C,uBAAsC;AACtC,yBAAuB;
|
|
4
|
+
"sourcesContent": ["import { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;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AAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,oBAAoB,QAAI,yBAAa,aAAAC,KAAiB;AAE9D,QAAM,eAAW,wBAAS,MAAM;AAC/B,QAAI;AACJ,QAAK,sBAAuB;AAC3B,+BAAyB,CAAE,EAAE,SAAS,GAAG,gBAAgB,MAAO;AAC/D,4CAAa;AAAA,UACZ,oBAAoB,oBAAoB;AAAA,UACxC,SAAS,CAAE,EAAE,QAAQ,MAAO,QAAS,OAAQ;AAAA,UAC7C,GAAG;AAAA,QACJ,CAAE;AAAA,MACH;AAAA,IACD;AACA,WAAO;AAAA,MACN,GAAG;AAAA,MACH,8BAA8B;AAAA,MAC9B,iBAAiB,wBAAwB,CAAE;AAAA,MAC3C;AAAA,MACA,aAAa;AAAA,MACb,cAAc;AAAA,MACd,mCAAmC;AAAA,MACnC;AAAA,MACA;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,mBAAe,qCAAAC,SAA0B;AAE/C,QAAM,CAAE,QAAQ,SAAS,QAAS,QAAI;AAAA,IACrC;AAAA,IACA;AAAA,IACA,EAAE,QAAI,qCAAuB,EAAE;AAAA,EAChC;AAEA,SACC,6CAAC,sCACA;AAAA,gDAAC,0BAAAC,QAAkB,UAAlB,EAA2B;AAAA,IAC5B;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAiB;AAAA,QACf,GAAG;AAAA,QAEH;AAAA;AAAA,UACF,4CAAC,qBAAkB,cAAe,cAAe;AAAA;AAAA;AAAA,IAClD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": ["blockEditorPrivateApis", "editPatternsPrivateApis", "coreStore", "preferencesStore", "editWidgetsStore", "useLastSelectedWidgetArea", "KeyboardShortcuts"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// packages/edit-widgets/src/blocks/widget-area/index.js
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { layout as icon } from "@wordpress/icons";
|
|
3
4
|
import metadata from "./block.json";
|
|
4
5
|
import edit from "./edit/index.mjs";
|
|
5
6
|
var { name } = metadata;
|
|
@@ -7,6 +8,7 @@ var settings = {
|
|
|
7
8
|
title: __("Widget Area"),
|
|
8
9
|
description: __("A widget area container."),
|
|
9
10
|
__experimentalLabel: ({ name: label }) => label,
|
|
11
|
+
icon,
|
|
10
12
|
edit
|
|
11
13
|
};
|
|
12
14
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/blocks/widget-area/index.js"],
|
|
4
|
-
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\tedit,\n};\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,UAAU;AACnB,OAAO,cAAc;AACrB,OAAO,UAAU;AAEjB,IAAM,EAAE,KAAK,IAAI;AAGV,IAAM,WAAW;AAAA,EACvB,OAAO,GAAI,aAAc;AAAA,EACzB,aAAa,GAAI,0BAA2B;AAAA,EAC5C,qBAAqB,CAAE,EAAE,MAAM,MAAM,MAAO;AAAA,EAC5C;AACD;",
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { layout as icon } from '@wordpress/icons';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\ticon,\n\tedit,\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,UAAU,YAAY;AAC/B,OAAO,cAAc;AACrB,OAAO,UAAU;AAEjB,IAAM,EAAE,KAAK,IAAI;AAGV,IAAM,WAAW;AAAA,EACvB,OAAO,GAAI,aAAc;AAAA,EACzB,aAAa,GAAI,0BAA2B;AAAA,EAC5C,qBAAqB,CAAE,EAAE,MAAM,MAAM,MAAO;AAAA,EAC5C;AAAA,EACA;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,45 +1,138 @@
|
|
|
1
1
|
// packages/edit-widgets/src/components/error-boundary/index.jsx
|
|
2
2
|
import { Component } from "@wordpress/element";
|
|
3
3
|
import { __ } from "@wordpress/i18n";
|
|
4
|
-
import {
|
|
5
|
-
import { Warning } from "@wordpress/block-editor";
|
|
4
|
+
import { Card, CollapsibleCard, Notice, Stack, Text } from "@wordpress/ui";
|
|
6
5
|
import { useCopyToClipboard } from "@wordpress/compose";
|
|
7
6
|
import { doAction } from "@wordpress/hooks";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
function getErrorName(error) {
|
|
9
|
+
return error instanceof Error && error.name || "Error";
|
|
10
|
+
}
|
|
11
|
+
function getErrorMessage(error) {
|
|
12
|
+
if (typeof error === "string" && error) {
|
|
13
|
+
return error;
|
|
14
|
+
}
|
|
15
|
+
if (typeof error?.message === "string" && error.message) {
|
|
16
|
+
return error.message;
|
|
17
|
+
}
|
|
18
|
+
return "An unknown error occurred.";
|
|
12
19
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
|
|
20
|
+
function getErrorSections(error, componentStack) {
|
|
21
|
+
const sections = [
|
|
22
|
+
{ label: getErrorName(error), content: getErrorMessage(error) }
|
|
16
23
|
];
|
|
17
|
-
|
|
24
|
+
if (error?.stack) {
|
|
25
|
+
sections.push({
|
|
26
|
+
label: "Stack",
|
|
27
|
+
content: error.stack.trim(),
|
|
28
|
+
preformatted: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (componentStack) {
|
|
32
|
+
sections.push({
|
|
33
|
+
label: "Component stack",
|
|
34
|
+
content: componentStack.trim(),
|
|
35
|
+
preformatted: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
sections.push({
|
|
39
|
+
label: "Environment",
|
|
40
|
+
content: `User agent: ${window.navigator.userAgent}`,
|
|
41
|
+
preformatted: true
|
|
42
|
+
});
|
|
43
|
+
return sections;
|
|
44
|
+
}
|
|
45
|
+
function getErrorReport(error, componentStack) {
|
|
46
|
+
const sections = getErrorSections(error, componentStack).map(
|
|
47
|
+
({ label, content, preformatted }) => `**${label}**
|
|
48
|
+
|
|
49
|
+
${preformatted ? `\`\`\`
|
|
50
|
+
${content}
|
|
51
|
+
\`\`\`` : content}`
|
|
52
|
+
);
|
|
53
|
+
return ["### Error report", ...sections].join("\n\n");
|
|
54
|
+
}
|
|
55
|
+
function CopyButton({ text, children, variant = "outline" }) {
|
|
56
|
+
const ref = useCopyToClipboard(text);
|
|
57
|
+
return /* @__PURE__ */ jsx(Notice.ActionButton, { variant, ref, children });
|
|
58
|
+
}
|
|
59
|
+
function ErrorReport({ error, componentStack }) {
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
Stack,
|
|
62
|
+
{
|
|
63
|
+
className: "edit-widgets-error-boundary__report",
|
|
64
|
+
direction: "column",
|
|
65
|
+
gap: "md",
|
|
66
|
+
children: getErrorSections(error, componentStack).map(
|
|
67
|
+
({ label, content }) => /* @__PURE__ */ jsxs(Stack, { direction: "column", gap: "xs", children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Text, { variant: "heading-md", children: label }),
|
|
69
|
+
/* @__PURE__ */ jsx("pre", { className: "edit-widgets-error-boundary__report-section", children: content })
|
|
70
|
+
] }, label)
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
function ErrorDetails({ error, componentStack }) {
|
|
76
|
+
return /* @__PURE__ */ jsxs(CollapsibleCard.Root, { className: "edit-widgets-error-boundary__details", children: [
|
|
77
|
+
/* @__PURE__ */ jsx(CollapsibleCard.Header, { children: /* @__PURE__ */ jsx(Card.Title, { children: __("Error details") }) }),
|
|
78
|
+
/* @__PURE__ */ jsx(CollapsibleCard.Content, { children: /* @__PURE__ */ jsx(
|
|
79
|
+
ErrorReport,
|
|
80
|
+
{
|
|
81
|
+
error,
|
|
82
|
+
componentStack
|
|
83
|
+
}
|
|
84
|
+
) })
|
|
85
|
+
] });
|
|
18
86
|
}
|
|
19
87
|
var ErrorBoundary = class extends Component {
|
|
20
88
|
constructor() {
|
|
21
89
|
super(...arguments);
|
|
22
90
|
this.state = {
|
|
23
|
-
error: null
|
|
91
|
+
error: null,
|
|
92
|
+
componentStack: null
|
|
24
93
|
};
|
|
25
94
|
}
|
|
26
|
-
componentDidCatch(error) {
|
|
27
|
-
|
|
95
|
+
componentDidCatch(error, errorInfo) {
|
|
96
|
+
this.setState({ componentStack: errorInfo?.componentStack });
|
|
97
|
+
doAction("editor.ErrorBoundary.errorLogged", error, errorInfo);
|
|
28
98
|
}
|
|
29
99
|
static getDerivedStateFromError(error) {
|
|
30
100
|
return { error };
|
|
31
101
|
}
|
|
32
102
|
render() {
|
|
33
|
-
|
|
103
|
+
const { error, componentStack } = this.state;
|
|
104
|
+
if (!error) {
|
|
34
105
|
return this.props.children;
|
|
35
106
|
}
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
|
|
107
|
+
return /* @__PURE__ */ jsxs(
|
|
108
|
+
Stack,
|
|
38
109
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
110
|
+
className: "edit-widgets-error-boundary",
|
|
111
|
+
direction: "column",
|
|
112
|
+
gap: "lg",
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ jsxs(Notice.Root, { intent: "error", children: [
|
|
115
|
+
/* @__PURE__ */ jsx(Notice.Title, { children: __("The editor has crashed") }),
|
|
116
|
+
/* @__PURE__ */ jsx(Notice.Description, { children: __(
|
|
117
|
+
"An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search."
|
|
118
|
+
) }),
|
|
119
|
+
/* @__PURE__ */ jsx(Notice.Actions, { children: /* @__PURE__ */ jsx(
|
|
120
|
+
CopyButton,
|
|
121
|
+
{
|
|
122
|
+
variant: "solid",
|
|
123
|
+
text: () => getErrorReport(error, componentStack),
|
|
124
|
+
children: __("Copy error")
|
|
125
|
+
}
|
|
126
|
+
) })
|
|
127
|
+
] }),
|
|
128
|
+
globalThis.SCRIPT_DEBUG ? /* @__PURE__ */ jsx(
|
|
129
|
+
ErrorDetails,
|
|
130
|
+
{
|
|
131
|
+
error,
|
|
132
|
+
componentStack
|
|
133
|
+
}
|
|
134
|
+
) : null
|
|
135
|
+
]
|
|
43
136
|
}
|
|
44
137
|
);
|
|
45
138
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/error-boundary/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["import { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n// eslint-disable-next-line @wordpress/use-recommended-components -- The fallback UI renders outside the editor's notice system.\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"edit-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"edit-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"edit-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"edit-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>\n\t\t\t\t\t\t{ __( 'The editor has crashed' ) }\n\t\t\t\t\t</Notice.Title>\n\t\t\t\t\t<Notice.Description>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAEnB,SAAS,MAAM,iBAAiB,QAAQ,OAAO,YAAY;AAC3D,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AAoEvB,cAeG,YAfH;AAjEF,SAAS,aAAc,OAAQ;AAC9B,SAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,OAAQ;AACjC,MAAK,OAAO,UAAU,YAAY,OAAQ;AACzC,WAAO;AAAA,EACR;AAEA,MAAK,OAAO,OAAO,YAAY,YAAY,MAAM,SAAU;AAC1D,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAKA,SAAS,iBAAkB,OAAO,gBAAiB;AAClD,QAAM,WAAW;AAAA,IAChB,EAAE,OAAO,aAAc,KAAM,GAAG,SAAS,gBAAiB,KAAM,EAAE;AAAA,EACnE;AAEA,MAAK,OAAO,OAA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AA;AAAA;AAAA,IACL;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/edit-widgets/src/components/sidebar/widget-areas.jsx
|
|
2
2
|
import { useSelect } from "@wordpress/data";
|
|
3
3
|
import { useMemo } from "@wordpress/element";
|
|
4
|
-
import {
|
|
4
|
+
import { layout } from "@wordpress/icons";
|
|
5
5
|
import { BlockIcon } from "@wordpress/block-editor";
|
|
6
6
|
import { Button } from "@wordpress/components";
|
|
7
7
|
import { __ } from "@wordpress/i18n";
|
|
@@ -34,7 +34,7 @@ function WidgetAreas({ selectedWidgetAreaId }) {
|
|
|
34
34
|
description = selectedWidgetArea.description;
|
|
35
35
|
}
|
|
36
36
|
return /* @__PURE__ */ jsx("div", { className: "edit-widgets-widget-areas", children: /* @__PURE__ */ jsxs("div", { className: "edit-widgets-widget-areas__top-container", children: [
|
|
37
|
-
/* @__PURE__ */ jsx(BlockIcon, { icon:
|
|
37
|
+
/* @__PURE__ */ jsx(BlockIcon, { icon: layout }),
|
|
38
38
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
39
39
|
/* @__PURE__ */ jsx(
|
|
40
40
|
"p",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sidebar/widget-areas.jsx"],
|
|
4
|
-
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport {
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,
|
|
4
|
+
"sourcesContent": ["import { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { layout } from '@wordpress/icons';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { safeHTML } from '@wordpress/dom';\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WidgetAreas( { selectedWidgetAreaId } ) {\n\tconst widgetAreas = useSelect(\n\t\t( select ) => select( editWidgetsStore ).getWidgetAreas(),\n\t\t[]\n\t);\n\n\tconst selectedWidgetArea = useMemo(\n\t\t() =>\n\t\t\tselectedWidgetAreaId &&\n\t\t\twidgetAreas?.find(\n\t\t\t\t( widgetArea ) => widgetArea.id === selectedWidgetAreaId\n\t\t\t),\n\t\t[ selectedWidgetAreaId, widgetAreas ]\n\t);\n\n\tlet description;\n\tif ( ! selectedWidgetArea ) {\n\t\tdescription = __(\n\t\t\t// eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts\n\t\t\t'Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'\n\t\t);\n\t} else if ( selectedWidgetAreaId === 'wp_inactive_widgets' ) {\n\t\tdescription = __(\n\t\t\t'Blocks in this Widget Area will not be displayed in your site.'\n\t\t);\n\t} else {\n\t\tdescription = selectedWidgetArea.description;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-widgets-widget-areas\">\n\t\t\t<div className=\"edit-widgets-widget-areas__top-container\">\n\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t<div>\n\t\t\t\t\t<p\n\t\t\t\t\t\t// Use `dangerouslySetInnerHTML` to keep backwards\n\t\t\t\t\t\t// compatibility. Basic markup in the description is an\n\t\t\t\t\t\t// established feature of WordPress.\n\t\t\t\t\t\t// @see https://github.com/WordPress/gutenberg/issues/33106\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: safeHTML( description ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ widgetAreas?.length === 0 && (\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Your theme does not contain any Widget Areas.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! selectedWidgetArea && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ addQueryArgs( 'customize.php', {\n\t\t\t\t\t\t\t\t'autofocus[panel]': 'widgets',\n\t\t\t\t\t\t\t\treturn: window.location.pathname,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Manage with live preview' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,SAAS,wBAAwB;AAkCtC,cACA,YADA;AAhCW,SAAR,YAA8B,EAAE,qBAAqB,GAAI;AAC/D,QAAM,cAAc;AAAA,IACnB,CAAE,WAAY,OAAQ,gBAAiB,EAAE,eAAe;AAAA,IACxD,CAAC;AAAA,EACF;AAEA,QAAM,qBAAqB;AAAA,IAC1B,MACC,wBACA,aAAa;AAAA,MACZ,CAAE,eAAgB,WAAW,OAAO;AAAA,IACrC;AAAA,IACD,CAAE,sBAAsB,WAAY;AAAA,EACrC;AAEA,MAAI;AACJ,MAAK,CAAE,oBAAqB;AAC3B,kBAAc;AAAA;AAAA,MAEb;AAAA,IACD;AAAA,EACD,WAAY,yBAAyB,uBAAwB;AAC5D,kBAAc;AAAA,MACb;AAAA,IACD;AAAA,EACD,OAAO;AACN,kBAAc,mBAAmB;AAAA,EAClC;AAEA,SACC,oBAAC,SAAI,WAAU,6BACd,+BAAC,SAAI,WAAU,4CACd;AAAA,wBAAC,aAAU,MAAO,QAAS;AAAA,IAC3B,qBAAC,SACA;AAAA;AAAA,QAAC;AAAA;AAAA,UAKA,yBAA0B;AAAA,YACzB,QAAQ,SAAU,WAAY;AAAA,UAC/B;AAAA;AAAA,MACD;AAAA,MACE,aAAa,WAAW,KACzB,oBAAC,OACE;AAAA,QACD;AAAA,MACD,GACD;AAAA,MAEC,CAAE,sBACH;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UACrB,MAAO,aAAc,iBAAiB;AAAA,YACrC,oBAAoB;AAAA,YACpB,QAAQ,OAAO,SAAS;AAAA,UACzB,CAAE;AAAA,UACF,SAAQ;AAAA,UAEN,aAAI,0BAA2B;AAAA;AAAA,MAClC;AAAA,OAEF;AAAA,KACD,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/widget-areas-block-editor-provider/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t
|
|
5
|
-
"mappings": ";AAAA,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,aAAa,iBAAiB;AACvC,SAAS,sBAAsB,SAAS,iBAAiB;AACzD,SAAS,eAAe;AACxB,SAAS,eAAe,8BAA8B;AACtD,SAAS,eAAe,+BAA+B;AACvD,SAAS,SAAS,wBAAwB;AAC1C,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB,MAAM,iBAAiB;AACxD,OAAO,+BAA+B;AACtC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,6BAA6B;AACtC,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["import { SlotFillProvider } from '@wordpress/components';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { useMemo } from '@wordpress/element';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst EMPTY_ARRAY = [];\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUser, getEntityRecord, getEntityRecords } =\n\t\t\tselect( coreStore );\n\t\tconst siteSettings = canUser( 'read', {\n\t\t\tkind: 'root',\n\t\t\tname: 'site',\n\t\t} )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\t\treturn {\n\t\t\thasUploadPermissions:\n\t\t\t\tcanUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'attachment',\n\t\t\t\t} ) ?? true,\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: EMPTY_ARRAY,\n\t\t\tisFixedToolbarActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive || ! isLargeViewport,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t};\n\t}, [\n\t\thasUploadPermissions,\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tisLargeViewport,\n\t\tkeepCaretInsideBlock,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\tvalue={ blocks }\n\t\t\t\tonInput={ onInput }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsettings={ settings }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<PatternsMenuItems rootClientId={ widgetAreaId } />\n\t\t\t</ExperimentalBlockEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,aA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CAAE;AACN,QAAM,EAAE,oBAAoB,IAAI,YAAa,gBAAiB;AAE9D,QAAM,WAAW,QAAS,MAAM;AAC/B,QAAI;AACJ,QAAK,sBAAuB;AAC3B,+BAAyB,CAAE,EAAE,SAAS,GAAG,gBAAgB,MAAO;AAC/D,oBAAa;AAAA,UACZ,oBAAoB,oBAAoB;AAAA,UACxC,SAAS,CAAE,EAAE,QAAQ,MAAO,QAAS,OAAQ;AAAA,UAC7C,GAAG;AAAA,QACJ,CAAE;AAAA,MACH;AAAA,IACD;AACA,WAAO;AAAA,MACN,GAAG;AAAA,MACH,8BAA8B;AAAA,MAC9B,iBAAiB,wBAAwB,CAAE;AAAA,MAC3C;AAAA,MACA,aAAa;AAAA,MACb,cAAc;AAAA,MACd,mCAAmC;AAAA,MACnC;AAAA,MACA;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,eAAe,0BAA0B;AAE/C,QAAM,CAAE,QAAQ,SAAS,QAAS,IAAI;AAAA,IACrC;AAAA,IACA;AAAA,IACA,EAAE,IAAI,uBAAuB,EAAE;AAAA,EAChC;AAEA,SACC,qBAAC,oBACA;AAAA,wBAAC,kBAAkB,UAAlB,EAA2B;AAAA,IAC5B;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAiB;AAAA,QACf,GAAG;AAAA,QAEH;AAAA;AAAA,UACF,oBAAC,qBAAkB,cAAe,cAAe;AAAA;AAAA;AAAA,IAClD;AAAA,KACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -590,11 +590,24 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
.edit-widgets-error-boundary {
|
|
593
|
+
font-family: var(--wpds-typography-font-family-body, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
|
|
593
594
|
margin: auto;
|
|
594
|
-
|
|
595
|
-
|
|
595
|
+
width: 100%;
|
|
596
|
+
max-width: var(--wpds-dimension-surface-width-lg, 560px);
|
|
597
|
+
padding: var(--wpds-dimension-padding-xl, 20px);
|
|
596
598
|
margin-top: 64px;
|
|
597
|
-
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.edit-widgets-error-boundary__report {
|
|
602
|
+
max-height: 420px;
|
|
603
|
+
overflow: auto;
|
|
604
|
+
overflow-anchor: none;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.edit-widgets-error-boundary__report-section {
|
|
608
|
+
margin: 0;
|
|
609
|
+
white-space: pre-wrap;
|
|
610
|
+
overflow-wrap: break-word;
|
|
598
611
|
}
|
|
599
612
|
|
|
600
613
|
.edit-widgets-header {
|
|
@@ -851,8 +864,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
851
864
|
.edit-widgets-welcome-guide__image > img {
|
|
852
865
|
display: block;
|
|
853
866
|
max-width: 100%;
|
|
854
|
-
|
|
855
|
-
object-fit: cover;
|
|
867
|
+
object-fit: cover;
|
|
856
868
|
}
|
|
857
869
|
.edit-widgets-welcome-guide__heading {
|
|
858
870
|
font-family: -apple-system, system-ui, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
@@ -872,7 +884,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
872
884
|
vertical-align: text-top;
|
|
873
885
|
}
|
|
874
886
|
.edit-widgets-welcome-guide .components-button:hover svg {
|
|
875
|
-
|
|
887
|
+
color: #fff;
|
|
876
888
|
}
|
|
877
889
|
|
|
878
890
|
.edit-widgets-block-editor {
|
package/build-style/style.css
CHANGED
|
@@ -590,11 +590,24 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
.edit-widgets-error-boundary {
|
|
593
|
+
font-family: var(--wpds-typography-font-family-body, -apple-system, system-ui, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif);
|
|
593
594
|
margin: auto;
|
|
594
|
-
|
|
595
|
-
|
|
595
|
+
width: 100%;
|
|
596
|
+
max-width: var(--wpds-dimension-surface-width-lg, 560px);
|
|
597
|
+
padding: var(--wpds-dimension-padding-xl, 20px);
|
|
596
598
|
margin-top: 64px;
|
|
597
|
-
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.edit-widgets-error-boundary__report {
|
|
602
|
+
max-height: 420px;
|
|
603
|
+
overflow: auto;
|
|
604
|
+
overflow-anchor: none;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.edit-widgets-error-boundary__report-section {
|
|
608
|
+
margin: 0;
|
|
609
|
+
white-space: pre-wrap;
|
|
610
|
+
overflow-wrap: break-word;
|
|
598
611
|
}
|
|
599
612
|
|
|
600
613
|
.edit-widgets-header {
|
|
@@ -851,8 +864,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
851
864
|
.edit-widgets-welcome-guide__image > img {
|
|
852
865
|
display: block;
|
|
853
866
|
max-width: 100%;
|
|
854
|
-
|
|
855
|
-
object-fit: cover;
|
|
867
|
+
object-fit: cover;
|
|
856
868
|
}
|
|
857
869
|
.edit-widgets-welcome-guide__heading {
|
|
858
870
|
font-family: -apple-system, system-ui, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
@@ -872,7 +884,7 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
|
|
|
872
884
|
vertical-align: text-top;
|
|
873
885
|
}
|
|
874
886
|
.edit-widgets-welcome-guide .components-button:hover svg {
|
|
875
|
-
|
|
887
|
+
color: #fff;
|
|
876
888
|
}
|
|
877
889
|
|
|
878
890
|
.edit-widgets-block-editor {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-widgets",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.55.0",
|
|
4
4
|
"description": "Widgets Page module for WordPress..",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -47,41 +47,42 @@
|
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@wordpress/admin-ui": "^2.
|
|
51
|
-
"@wordpress/api-fetch": "^7.
|
|
52
|
-
"@wordpress/base-styles": "^13.
|
|
53
|
-
"@wordpress/block-editor": "^17.
|
|
54
|
-
"@wordpress/block-library": "^
|
|
55
|
-
"@wordpress/blocks": "^16.0.
|
|
56
|
-
"@wordpress/components": "^40.1.
|
|
57
|
-
"@wordpress/compose": "^8.
|
|
58
|
-
"@wordpress/core-data": "^
|
|
59
|
-
"@wordpress/data": "^10.
|
|
60
|
-
"@wordpress/deprecated": "^4.
|
|
61
|
-
"@wordpress/dom": "^4.
|
|
62
|
-
"@wordpress/element": "^8.
|
|
63
|
-
"@wordpress/hooks": "^4.
|
|
64
|
-
"@wordpress/i18n": "^6.
|
|
65
|
-
"@wordpress/icons": "^
|
|
66
|
-
"@wordpress/interface": "^10.
|
|
67
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
68
|
-
"@wordpress/keycodes": "^4.
|
|
69
|
-
"@wordpress/media-utils": "^5.
|
|
70
|
-
"@wordpress/notices": "^5.
|
|
71
|
-
"@wordpress/patterns": "^2.
|
|
72
|
-
"@wordpress/plugins": "^7.
|
|
73
|
-
"@wordpress/preferences": "^4.
|
|
74
|
-
"@wordpress/private-apis": "^1.
|
|
75
|
-
"@wordpress/theme": "^2.1.
|
|
76
|
-
"@wordpress/ui": "^0.22.
|
|
77
|
-
"@wordpress/url": "^4.
|
|
78
|
-
"@wordpress/widgets": "^4.
|
|
50
|
+
"@wordpress/admin-ui": "^2.10.0",
|
|
51
|
+
"@wordpress/api-fetch": "^7.55.0",
|
|
52
|
+
"@wordpress/base-styles": "^13.1.0",
|
|
53
|
+
"@wordpress/block-editor": "^17.1.0",
|
|
54
|
+
"@wordpress/block-library": "^11.0.0",
|
|
55
|
+
"@wordpress/blocks": "^16.0.0",
|
|
56
|
+
"@wordpress/components": "^40.1.0",
|
|
57
|
+
"@wordpress/compose": "^8.8.0",
|
|
58
|
+
"@wordpress/core-data": "^8.0.0",
|
|
59
|
+
"@wordpress/data": "^10.55.0",
|
|
60
|
+
"@wordpress/deprecated": "^4.55.0",
|
|
61
|
+
"@wordpress/dom": "^4.55.0",
|
|
62
|
+
"@wordpress/element": "^8.7.0",
|
|
63
|
+
"@wordpress/hooks": "^4.55.0",
|
|
64
|
+
"@wordpress/i18n": "^6.28.0",
|
|
65
|
+
"@wordpress/icons": "^16.0.0",
|
|
66
|
+
"@wordpress/interface": "^10.1.0",
|
|
67
|
+
"@wordpress/keyboard-shortcuts": "^5.55.0",
|
|
68
|
+
"@wordpress/keycodes": "^4.55.0",
|
|
69
|
+
"@wordpress/media-utils": "^5.55.0",
|
|
70
|
+
"@wordpress/notices": "^5.55.0",
|
|
71
|
+
"@wordpress/patterns": "^2.55.0",
|
|
72
|
+
"@wordpress/plugins": "^7.55.0",
|
|
73
|
+
"@wordpress/preferences": "^4.55.0",
|
|
74
|
+
"@wordpress/private-apis": "^1.55.0",
|
|
75
|
+
"@wordpress/theme": "^2.1.0",
|
|
76
|
+
"@wordpress/ui": "^0.22.0",
|
|
77
|
+
"@wordpress/url": "^4.55.0",
|
|
78
|
+
"@wordpress/widgets": "^4.55.0",
|
|
79
79
|
"clsx": "^2.1.1"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@testing-library/dom": "^10.4.1",
|
|
83
|
-
"@testing-library/react": "^16.3.
|
|
84
|
-
"deep-freeze": "^0.0.1"
|
|
83
|
+
"@testing-library/react": "^16.3.3",
|
|
84
|
+
"deep-freeze": "^0.0.1",
|
|
85
|
+
"vitest": "^5.0.0"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
87
88
|
"react": "^18 || ^19",
|
|
@@ -90,5 +91,5 @@
|
|
|
90
91
|
"publishConfig": {
|
|
91
92
|
"access": "public"
|
|
92
93
|
},
|
|
93
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "485f42ae8a1c58ceea18371a507fd4acfa86fbd8"
|
|
94
95
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
|
+
import { layout as icon } from '@wordpress/icons';
|
|
2
3
|
import metadata from './block.json';
|
|
3
4
|
import edit from './edit';
|
|
4
5
|
|
|
@@ -9,5 +10,6 @@ export const settings = {
|
|
|
9
10
|
title: __( 'Widget Area' ),
|
|
10
11
|
description: __( 'A widget area container.' ),
|
|
11
12
|
__experimentalLabel: ( { name: label } ) => label,
|
|
13
|
+
icon,
|
|
12
14
|
edit,
|
|
13
15
|
};
|
|
@@ -1,30 +1,116 @@
|
|
|
1
1
|
import { Component } from '@wordpress/element';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
|
-
|
|
4
|
-
import {
|
|
3
|
+
// eslint-disable-next-line @wordpress/use-recommended-components -- The fallback UI renders outside the editor's notice system.
|
|
4
|
+
import { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';
|
|
5
5
|
import { useCopyToClipboard } from '@wordpress/compose';
|
|
6
6
|
import { doAction } from '@wordpress/hooks';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// A boundary catches whatever was thrown, which is not always an `Error`.
|
|
9
|
+
function getErrorName( error ) {
|
|
10
|
+
return ( error instanceof Error && error.name ) || 'Error';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getErrorMessage( error ) {
|
|
14
|
+
if ( typeof error === 'string' && error ) {
|
|
15
|
+
return error;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if ( typeof error?.message === 'string' && error.message ) {
|
|
19
|
+
return error.message;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return 'An unknown error occurred.';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The sections of the report, shared by the copied Markdown and the details
|
|
26
|
+
// panel so that the two cannot drift apart. Deliberately untranslated: both
|
|
27
|
+
// are developer-facing, and the report is pasted into a bug report.
|
|
28
|
+
function getErrorSections( error, componentStack ) {
|
|
29
|
+
const sections = [
|
|
30
|
+
{ label: getErrorName( error ), content: getErrorMessage( error ) },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
if ( error?.stack ) {
|
|
34
|
+
sections.push( {
|
|
35
|
+
label: 'Stack',
|
|
36
|
+
content: error.stack.trim(),
|
|
37
|
+
preformatted: true,
|
|
38
|
+
} );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if ( componentStack ) {
|
|
42
|
+
sections.push( {
|
|
43
|
+
label: 'Component stack',
|
|
44
|
+
content: componentStack.trim(),
|
|
45
|
+
preformatted: true,
|
|
46
|
+
} );
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
sections.push( {
|
|
50
|
+
label: 'Environment',
|
|
51
|
+
content: `User agent: ${ window.navigator.userAgent }`,
|
|
52
|
+
preformatted: true,
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
return sections;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Markdown, so the report stays readable as plain text and renders when pasted
|
|
59
|
+
// into a bug report.
|
|
60
|
+
function getErrorReport( error, componentStack ) {
|
|
61
|
+
const sections = getErrorSections( error, componentStack ).map(
|
|
62
|
+
( { label, content, preformatted } ) =>
|
|
63
|
+
`**${ label }**\n\n${
|
|
64
|
+
preformatted ? `\`\`\`\n${ content }\n\`\`\`` : content
|
|
65
|
+
}`
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return [ '### Error report', ...sections ].join( '\n\n' );
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function CopyButton( { text, children, variant = 'outline' } ) {
|
|
9
72
|
const ref = useCopyToClipboard( text );
|
|
10
73
|
return (
|
|
11
|
-
<
|
|
74
|
+
<Notice.ActionButton variant={ variant } ref={ ref }>
|
|
12
75
|
{ children }
|
|
13
|
-
</
|
|
76
|
+
</Notice.ActionButton>
|
|
14
77
|
);
|
|
15
78
|
}
|
|
16
79
|
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
80
|
+
function ErrorReport( { error, componentStack } ) {
|
|
81
|
+
return (
|
|
82
|
+
<Stack
|
|
83
|
+
className="edit-widgets-error-boundary__report"
|
|
84
|
+
direction="column"
|
|
85
|
+
gap="md"
|
|
86
|
+
>
|
|
87
|
+
{ getErrorSections( error, componentStack ).map(
|
|
88
|
+
( { label, content } ) => (
|
|
89
|
+
<Stack key={ label } direction="column" gap="xs">
|
|
90
|
+
<Text variant="heading-md">{ label }</Text>
|
|
91
|
+
<pre className="edit-widgets-error-boundary__report-section">
|
|
92
|
+
{ content }
|
|
93
|
+
</pre>
|
|
94
|
+
</Stack>
|
|
95
|
+
)
|
|
96
|
+
) }
|
|
97
|
+
</Stack>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
23
100
|
|
|
101
|
+
function ErrorDetails( { error, componentStack } ) {
|
|
24
102
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
103
|
+
<CollapsibleCard.Root className="edit-widgets-error-boundary__details">
|
|
104
|
+
<CollapsibleCard.Header>
|
|
105
|
+
<Card.Title>{ __( 'Error details' ) }</Card.Title>
|
|
106
|
+
</CollapsibleCard.Header>
|
|
107
|
+
<CollapsibleCard.Content>
|
|
108
|
+
<ErrorReport
|
|
109
|
+
error={ error }
|
|
110
|
+
componentStack={ componentStack }
|
|
111
|
+
/>
|
|
112
|
+
</CollapsibleCard.Content>
|
|
113
|
+
</CollapsibleCard.Root>
|
|
28
114
|
);
|
|
29
115
|
}
|
|
30
116
|
|
|
@@ -34,11 +120,13 @@ export default class ErrorBoundary extends Component {
|
|
|
34
120
|
|
|
35
121
|
this.state = {
|
|
36
122
|
error: null,
|
|
123
|
+
componentStack: null,
|
|
37
124
|
};
|
|
38
125
|
}
|
|
39
126
|
|
|
40
|
-
componentDidCatch( error ) {
|
|
41
|
-
|
|
127
|
+
componentDidCatch( error, errorInfo ) {
|
|
128
|
+
this.setState( { componentStack: errorInfo?.componentStack } );
|
|
129
|
+
doAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );
|
|
42
130
|
}
|
|
43
131
|
|
|
44
132
|
static getDerivedStateFromError( error ) {
|
|
@@ -46,17 +134,44 @@ export default class ErrorBoundary extends Component {
|
|
|
46
134
|
}
|
|
47
135
|
|
|
48
136
|
render() {
|
|
49
|
-
|
|
137
|
+
const { error, componentStack } = this.state;
|
|
138
|
+
if ( ! error ) {
|
|
50
139
|
return this.props.children;
|
|
51
140
|
}
|
|
52
141
|
|
|
53
142
|
return (
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
143
|
+
<Stack
|
|
144
|
+
className="edit-widgets-error-boundary"
|
|
145
|
+
direction="column"
|
|
146
|
+
gap="lg"
|
|
147
|
+
>
|
|
148
|
+
<Notice.Root intent="error">
|
|
149
|
+
<Notice.Title>
|
|
150
|
+
{ __( 'The editor has crashed' ) }
|
|
151
|
+
</Notice.Title>
|
|
152
|
+
<Notice.Description>
|
|
153
|
+
{ __(
|
|
154
|
+
'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'
|
|
155
|
+
) }
|
|
156
|
+
</Notice.Description>
|
|
157
|
+
<Notice.Actions>
|
|
158
|
+
<CopyButton
|
|
159
|
+
variant="solid"
|
|
160
|
+
text={ () =>
|
|
161
|
+
getErrorReport( error, componentStack )
|
|
162
|
+
}
|
|
163
|
+
>
|
|
164
|
+
{ __( 'Copy error' ) }
|
|
165
|
+
</CopyButton>
|
|
166
|
+
</Notice.Actions>
|
|
167
|
+
</Notice.Root>
|
|
168
|
+
{ globalThis.SCRIPT_DEBUG ? (
|
|
169
|
+
<ErrorDetails
|
|
170
|
+
error={ error }
|
|
171
|
+
componentStack={ componentStack }
|
|
172
|
+
/>
|
|
173
|
+
) : null }
|
|
174
|
+
</Stack>
|
|
60
175
|
);
|
|
61
176
|
}
|
|
62
177
|
}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/variables" as *;
|
|
2
2
|
|
|
3
3
|
.edit-widgets-error-boundary {
|
|
4
|
+
font-family: var(--wpds-typography-font-family-body);
|
|
4
5
|
margin: auto;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
width: 100%;
|
|
7
|
+
max-width: var(--wpds-dimension-surface-width-lg);
|
|
8
|
+
padding: var(--wpds-dimension-padding-xl);
|
|
7
9
|
margin-top: $header-height;
|
|
8
|
-
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.edit-widgets-error-boundary__report {
|
|
13
|
+
max-height: 420px;
|
|
14
|
+
overflow: auto;
|
|
15
|
+
overflow-anchor: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.edit-widgets-error-boundary__report-section {
|
|
19
|
+
margin: 0;
|
|
20
|
+
white-space: pre-wrap;
|
|
21
|
+
overflow-wrap: break-word;
|
|
9
22
|
}
|
package/src/components/error-boundary/test/{error-boundary.jsx → error-boundary.jsdom.test.jsx}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { render } from '@testing-library/react';
|
|
2
3
|
import * as wpHooks from '@wordpress/hooks';
|
|
3
4
|
import ErrorBoundary from '../index';
|
|
@@ -10,8 +11,8 @@ const ChildComponent = () => {
|
|
|
10
11
|
|
|
11
12
|
describe( 'Error Boundary', () => {
|
|
12
13
|
describe( 'when error is thrown from a Child component', () => {
|
|
13
|
-
it( 'calls the `editor.ErrorBoundary.errorLogged` hook action with the error object', () => {
|
|
14
|
-
const doAction =
|
|
14
|
+
it( 'calls the `editor.ErrorBoundary.errorLogged` hook action with the error object and error info', () => {
|
|
15
|
+
const doAction = vi.spyOn( wpHooks, 'doAction' );
|
|
15
16
|
|
|
16
17
|
render(
|
|
17
18
|
<ErrorBoundary>
|
|
@@ -21,7 +22,10 @@ describe( 'Error Boundary', () => {
|
|
|
21
22
|
|
|
22
23
|
expect( doAction ).toHaveBeenCalledWith(
|
|
23
24
|
'editor.ErrorBoundary.errorLogged',
|
|
24
|
-
theError
|
|
25
|
+
theError,
|
|
26
|
+
expect.objectContaining( {
|
|
27
|
+
componentStack: expect.any( String ),
|
|
28
|
+
} )
|
|
25
29
|
);
|
|
26
30
|
expect( console ).toHaveErrored();
|
|
27
31
|
} );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useSelect } from '@wordpress/data';
|
|
2
2
|
import { useMemo } from '@wordpress/element';
|
|
3
|
-
import {
|
|
3
|
+
import { layout } from '@wordpress/icons';
|
|
4
4
|
import { BlockIcon } from '@wordpress/block-editor';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
@@ -40,7 +40,7 @@ export default function WidgetAreas( { selectedWidgetAreaId } ) {
|
|
|
40
40
|
return (
|
|
41
41
|
<div className="edit-widgets-widget-areas">
|
|
42
42
|
<div className="edit-widgets-widget-areas__top-container">
|
|
43
|
-
<BlockIcon icon={
|
|
43
|
+
<BlockIcon icon={ layout } />
|
|
44
44
|
<div>
|
|
45
45
|
<p
|
|
46
46
|
// Use `dangerouslySetInnerHTML` to keep backwards
|