@wordpress/edit-site 6.0.0 → 6.1.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/components/add-new-page/index.js +2 -1
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/app/index.js +17 -1
- package/build/components/app/index.js.map +1 -1
- package/build/components/editor/index.js +55 -69
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/use-editor-title.js +39 -0
- package/build/components/editor/use-editor-title.js.map +1 -0
- package/build/components/global-styles/font-library-modal/installed-fonts.js +1 -0
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/screen-css.js +1 -1
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +4 -23
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +1 -0
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/variations/variation.js +11 -16
- package/build/components/global-styles/variations/variation.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +2 -1
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +1 -0
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/global-styles-sidebar/index.js +2 -0
- package/build/components/global-styles-sidebar/index.js.map +1 -1
- package/build/components/layout/index.js +23 -95
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page/header.js +1 -0
- package/build/components/page/header.js.map +1 -1
- package/build/components/page-patterns/header.js +2 -1
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +5 -5
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/pagination/index.js +17 -8
- package/build/components/pagination/index.js.map +1 -1
- package/build/components/posts-app/index.js +50 -0
- package/build/components/posts-app/index.js.map +1 -0
- package/build/components/sidebar-dataviews/dataview-item.js +6 -2
- package/build/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +1 -1
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/site-hub/index.js +38 -128
- package/build/components/site-hub/index.js.map +1 -1
- package/build/hooks/commands/use-set-command-context.js +53 -0
- package/build/hooks/commands/use-set-command-context.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +3 -2
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +20 -88
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/index.js +15 -2
- package/build/index.js.map +1 -1
- package/build/posts.js +34 -0
- package/build/posts.js.map +1 -0
- package/build/store/private-actions.js +33 -18
- package/build/store/private-actions.js.map +1 -1
- package/build-module/components/add-new-page/index.js +2 -1
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/app/index.js +17 -1
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/editor/index.js +55 -69
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/use-editor-title.js +31 -0
- package/build-module/components/editor/use-editor-title.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +1 -0
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +1 -1
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +4 -23
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +1 -0
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/variations/variation.js +11 -16
- package/build-module/components/global-styles/variations/variation.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +3 -2
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +1 -0
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/global-styles-sidebar/index.js +2 -0
- package/build-module/components/global-styles-sidebar/index.js.map +1 -1
- package/build-module/components/layout/index.js +27 -99
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page/header.js +1 -0
- package/build-module/components/page/header.js.map +1 -1
- package/build-module/components/page-patterns/header.js +2 -1
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +5 -5
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/pagination/index.js +17 -8
- package/build-module/components/pagination/index.js.map +1 -1
- package/build-module/components/posts-app/index.js +43 -0
- package/build-module/components/posts-app/index.js.map +1 -0
- package/build-module/components/sidebar-dataviews/dataview-item.js +6 -2
- package/build-module/components/sidebar-dataviews/dataview-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js +2 -2
- package/build-module/components/sidebar-navigation-screen-patterns/category-item.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +40 -130
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/hooks/commands/use-set-command-context.js +46 -0
- package/build-module/hooks/commands/use-set-command-context.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +3 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +19 -86
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/index.js +8 -2
- package/build-module/index.js.map +1 -1
- package/build-module/posts.js +27 -0
- package/build-module/posts.js.map +1 -0
- package/build-module/store/private-actions.js +33 -18
- package/build-module/store/private-actions.js.map +1 -1
- package/build-style/posts-rtl.css +1707 -0
- package/build-style/posts.css +1707 -0
- package/build-style/style-rtl.css +59 -104
- package/build-style/style.css +59 -104
- package/package.json +41 -41
- package/src/components/add-new-page/index.js +2 -1
- package/src/components/app/index.js +17 -1
- package/src/components/block-editor/style.scss +11 -0
- package/src/components/editor/index.js +69 -103
- package/src/components/editor/style.scss +1 -5
- package/src/components/editor/use-editor-title.js +35 -0
- package/src/components/global-styles/font-library-modal/installed-fonts.js +1 -0
- package/src/components/global-styles/screen-css.js +1 -1
- package/src/components/global-styles/screen-revisions/index.js +4 -24
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/src/components/global-styles/screen-revisions/style.scss +4 -8
- package/src/components/global-styles/shadows-edit-panel.js +1 -0
- package/src/components/global-styles/style.scss +1 -7
- package/src/components/global-styles/variations/variation.js +14 -19
- package/src/components/global-styles/variations/variations-color.js +12 -4
- package/src/components/global-styles/variations/variations-typography.js +5 -1
- package/src/components/global-styles-sidebar/index.js +2 -0
- package/src/components/global-styles-sidebar/style.scss +0 -1
- package/src/components/layout/index.js +41 -137
- package/src/components/layout/style.scss +18 -58
- package/src/components/page/header.js +1 -0
- package/src/components/page/style.scss +6 -0
- package/src/components/page-patterns/header.js +8 -2
- package/src/components/page-patterns/index.js +15 -12
- package/src/components/page-patterns/style.scss +6 -0
- package/src/components/pagination/index.js +21 -16
- package/src/components/posts-app/index.js +39 -0
- package/src/components/sidebar/style.scss +4 -4
- package/src/components/sidebar-dataviews/dataview-item.js +6 -2
- package/src/components/sidebar-navigation-screen/index.js +1 -1
- package/src/components/sidebar-navigation-screen/style.scss +2 -2
- package/src/components/sidebar-navigation-screen-navigation-menu/delete-confirm-dialog.js +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +1 -0
- package/src/components/sidebar-navigation-screen-patterns/category-item.js +11 -2
- package/src/components/sidebar-navigation-screen-patterns/index.js +5 -1
- package/src/components/site-hub/index.js +55 -146
- package/src/components/site-hub/style.scss +1 -4
- package/src/components/site-icon/style.scss +0 -4
- package/src/hooks/commands/use-set-command-context.js +37 -0
- package/src/hooks/push-changes-to-global-styles/index.js +3 -2
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +1 -875
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +29 -117
- package/src/index.js +10 -2
- package/src/posts.js +29 -0
- package/src/posts.scss +46 -0
- package/src/store/private-actions.js +58 -30
- package/build/components/block-editor/block-inspector-button.js +0 -57
- package/build/components/block-editor/block-inspector-button.js.map +0 -1
- package/build/components/block-editor/inserter-media-categories.js +0 -183
- package/build/components/block-editor/inserter-media-categories.js.map +0 -1
- package/build/components/template-part-converter/convert-to-regular.js +0 -38
- package/build/components/template-part-converter/convert-to-regular.js.map +0 -1
- package/build/components/template-part-converter/convert-to-template-part.js +0 -84
- package/build/components/template-part-converter/convert-to-template-part.js.map +0 -1
- package/build/components/template-part-converter/index.js +0 -67
- package/build/components/template-part-converter/index.js.map +0 -1
- package/build-module/components/block-editor/block-inspector-button.js +0 -50
- package/build-module/components/block-editor/block-inspector-button.js.map +0 -1
- package/build-module/components/block-editor/inserter-media-categories.js +0 -177
- package/build-module/components/block-editor/inserter-media-categories.js.map +0 -1
- package/build-module/components/template-part-converter/convert-to-regular.js +0 -31
- package/build-module/components/template-part-converter/convert-to-regular.js.map +0 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +0 -79
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +0 -1
- package/build-module/components/template-part-converter/index.js +0 -59
- package/build-module/components/template-part-converter/index.js.map +0 -1
- package/src/components/block-editor/block-inspector-button.js +0 -60
- package/src/components/block-editor/inserter-media-categories.js +0 -227
- package/src/components/template-part-converter/convert-to-regular.js +0 -32
- package/src/components/template-part-converter/convert-to-template-part.js +0 -78
- package/src/components/template-part-converter/index.js +0 -59
|
@@ -8,11 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
11
|
-
var _compose = require("@wordpress/compose");
|
|
12
11
|
var _i18n = require("@wordpress/i18n");
|
|
13
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
14
12
|
var _coreData = require("@wordpress/core-data");
|
|
15
|
-
var _editor = require("@wordpress/editor");
|
|
16
13
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
17
14
|
var _element = require("@wordpress/element");
|
|
18
15
|
var _icons = require("@wordpress/icons");
|
|
@@ -35,19 +32,15 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
35
32
|
* Internal dependencies
|
|
36
33
|
*/
|
|
37
34
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
className
|
|
42
|
-
}) => {
|
|
35
|
+
const SiteHub = (0, _element.memo)((0, _element.forwardRef)(({
|
|
36
|
+
isTransparent
|
|
37
|
+
}, ref) => {
|
|
43
38
|
const {
|
|
44
|
-
canvasMode,
|
|
45
39
|
dashboardLink,
|
|
46
40
|
homeUrl,
|
|
47
41
|
siteTitle
|
|
48
42
|
} = (0, _data.useSelect)(select => {
|
|
49
43
|
const {
|
|
50
|
-
getCanvasMode,
|
|
51
44
|
getSettings
|
|
52
45
|
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
53
46
|
const {
|
|
@@ -56,7 +49,6 @@ const SiteHub = (0, _element.memo)(({
|
|
|
56
49
|
} = select(_coreData.store);
|
|
57
50
|
const _site = getSite();
|
|
58
51
|
return {
|
|
59
|
-
canvasMode: getCanvasMode(),
|
|
60
52
|
dashboardLink: getSettings().__experimentalDashboardLink || 'index.php',
|
|
61
53
|
homeUrl: getUnstableBase()?.home,
|
|
62
54
|
siteTitle: !_site?.title && !!_site?.url ? (0, _url.filterURLForDisplay)(_site?.url) : _site?.title
|
|
@@ -65,135 +57,53 @@ const SiteHub = (0, _element.memo)(({
|
|
|
65
57
|
const {
|
|
66
58
|
open: openCommandCenter
|
|
67
59
|
} = (0, _data.useDispatch)(_commands.store);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
setCanvasMode
|
|
71
|
-
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
72
|
-
const {
|
|
73
|
-
clearSelectedBlock
|
|
74
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
75
|
-
const {
|
|
76
|
-
setDeviceType
|
|
77
|
-
} = (0, _data.useDispatch)(_editor.store);
|
|
78
|
-
const isBackToDashboardButton = canvasMode === 'view';
|
|
79
|
-
const siteIconButtonProps = isBackToDashboardButton ? {
|
|
80
|
-
href: dashboardLink,
|
|
81
|
-
label: (0, _i18n.__)('Go to the Dashboard')
|
|
82
|
-
} : {
|
|
83
|
-
href: dashboardLink,
|
|
84
|
-
// We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.
|
|
85
|
-
role: 'button',
|
|
86
|
-
label: (0, _i18n.__)('Open Navigation'),
|
|
87
|
-
onClick: event => {
|
|
88
|
-
event.preventDefault();
|
|
89
|
-
if (canvasMode === 'edit') {
|
|
90
|
-
clearSelectedBlock();
|
|
91
|
-
setDeviceType('Desktop');
|
|
92
|
-
setCanvasMode('view');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__unstableMotion.div, {
|
|
97
|
-
className: (0, _clsx.default)('edit-site-site-hub', className),
|
|
98
|
-
variants: {
|
|
99
|
-
isDistractionFree: {
|
|
100
|
-
x: '-100%'
|
|
101
|
-
},
|
|
102
|
-
isDistractionFreeHovering: {
|
|
103
|
-
x: 0
|
|
104
|
-
},
|
|
105
|
-
view: {
|
|
106
|
-
x: 0
|
|
107
|
-
},
|
|
108
|
-
edit: {
|
|
109
|
-
x: 0
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
initial: false,
|
|
113
|
-
transition: {
|
|
114
|
-
type: 'tween',
|
|
115
|
-
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
116
|
-
ease: 'easeOut'
|
|
117
|
-
},
|
|
60
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
61
|
+
className: "edit-site-site-hub",
|
|
118
62
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
119
63
|
justify: "flex-start",
|
|
120
64
|
spacing: "0",
|
|
121
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
65
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
122
66
|
className: (0, _clsx.default)('edit-site-site-hub__view-mode-toggle-container', {
|
|
123
67
|
'has-transparent-background': isTransparent
|
|
124
68
|
}),
|
|
125
|
-
layout: true,
|
|
126
|
-
transition: {
|
|
127
|
-
type: 'tween',
|
|
128
|
-
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
129
|
-
ease: 'easeOut'
|
|
130
|
-
},
|
|
131
69
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
132
|
-
|
|
70
|
+
ref: ref,
|
|
71
|
+
href: dashboardLink,
|
|
72
|
+
label: (0, _i18n.__)('Go to the Dashboard'),
|
|
133
73
|
className: "edit-site-layout__view-mode-toggle",
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
scale: canvasMode === 'view' ? 0.5 : 1
|
|
138
|
-
},
|
|
139
|
-
whileHover: {
|
|
140
|
-
scale: canvasMode === 'view' ? 0.5 : 0.96
|
|
141
|
-
},
|
|
142
|
-
transition: {
|
|
143
|
-
type: 'tween',
|
|
144
|
-
duration: disableMotion ? 0 : HUB_ANIMATION_DURATION,
|
|
145
|
-
ease: 'easeOut'
|
|
146
|
-
},
|
|
147
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_siteIcon.default, {
|
|
148
|
-
className: "edit-site-layout__view-mode-toggle-icon"
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__unstableAnimatePresence, {
|
|
153
|
-
initial: false,
|
|
154
|
-
children: canvasMode === 'view' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
155
|
-
as: _components.__unstableMotion.div,
|
|
156
|
-
initial: {
|
|
157
|
-
opacity: 0
|
|
158
|
-
},
|
|
159
|
-
animate: {
|
|
160
|
-
opacity: isTransparent ? 0 : 1
|
|
74
|
+
style: {
|
|
75
|
+
transform: 'scale(0.5)',
|
|
76
|
+
borderRadius: 4
|
|
161
77
|
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
transition: {
|
|
166
|
-
type: 'tween',
|
|
167
|
-
duration: disableMotion ? 0 : 0.2,
|
|
168
|
-
ease: 'easeOut',
|
|
169
|
-
delay: canvasMode === 'view' ? 0.1 : 0
|
|
170
|
-
},
|
|
171
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
172
|
-
className: "edit-site-site-hub__title",
|
|
173
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
174
|
-
variant: "link",
|
|
175
|
-
href: homeUrl,
|
|
176
|
-
target: "_blank",
|
|
177
|
-
label: (0, _i18n.__)('View site (opens in a new tab)'),
|
|
178
|
-
"aria-label": (0, _i18n.__)('View site (opens in a new tab)'),
|
|
179
|
-
children: (0, _htmlEntities.decodeEntities)(siteTitle)
|
|
180
|
-
})
|
|
181
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
|
|
182
|
-
spacing: 0,
|
|
183
|
-
expanded: false,
|
|
184
|
-
className: "edit-site-site-hub__actions",
|
|
185
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
186
|
-
className: "edit-site-site-hub_toggle-command-center",
|
|
187
|
-
icon: _icons.search,
|
|
188
|
-
onClick: () => openCommandCenter(),
|
|
189
|
-
label: (0, _i18n.__)('Open command palette'),
|
|
190
|
-
shortcut: _keycodes.displayShortcut.primary('k')
|
|
191
|
-
})
|
|
192
|
-
})]
|
|
78
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_siteIcon.default, {
|
|
79
|
+
className: "edit-site-layout__view-mode-toggle-icon"
|
|
80
|
+
})
|
|
193
81
|
})
|
|
82
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
|
|
83
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
84
|
+
className: "edit-site-site-hub__title",
|
|
85
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
86
|
+
variant: "link",
|
|
87
|
+
href: homeUrl,
|
|
88
|
+
target: "_blank",
|
|
89
|
+
label: (0, _i18n.__)('View site (opens in a new tab)'),
|
|
90
|
+
children: (0, _htmlEntities.decodeEntities)(siteTitle)
|
|
91
|
+
})
|
|
92
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalHStack, {
|
|
93
|
+
spacing: 0,
|
|
94
|
+
expanded: false,
|
|
95
|
+
className: "edit-site-site-hub__actions",
|
|
96
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
97
|
+
className: "edit-site-site-hub_toggle-command-center",
|
|
98
|
+
icon: _icons.search,
|
|
99
|
+
onClick: () => openCommandCenter(),
|
|
100
|
+
label: (0, _i18n.__)('Open command palette'),
|
|
101
|
+
shortcut: _keycodes.displayShortcut.primary('k')
|
|
102
|
+
})
|
|
103
|
+
})]
|
|
194
104
|
})]
|
|
195
105
|
})
|
|
196
106
|
});
|
|
197
|
-
});
|
|
107
|
+
}));
|
|
198
108
|
var _default = exports.default = SiteHub;
|
|
199
109
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_data","_components","_compose","_i18n","_blockEditor","_coreData","_editor","_htmlEntities","_element","_icons","_commands","_keycodes","_url","_store","_siteIcon","_lockUnlock","_jsxRuntime","HUB_ANIMATION_DURATION","SiteHub","memo","isTransparent","className","canvasMode","dashboardLink","homeUrl","siteTitle","useSelect","select","getCanvasMode","getSettings","unlock","editSiteStore","getSite","getUnstableBase","coreStore","_site","__experimentalDashboardLink","home","title","url","filterURLForDisplay","open","openCommandCenter","useDispatch","commandsStore","disableMotion","useReducedMotion","setCanvasMode","clearSelectedBlock","blockEditorStore","setDeviceType","editorStore","isBackToDashboardButton","siteIconButtonProps","href","label","__","role","onClick","event","preventDefault","jsx","__unstableMotion","div","clsx","variants","isDistractionFree","x","isDistractionFreeHovering","view","edit","initial","transition","type","duration","ease","children","jsxs","__experimentalHStack","justify","spacing","layout","Button","animate","scale","whileHover","default","__unstableAnimatePresence","as","motion","opacity","exit","delay","variant","target","decodeEntities","expanded","icon","search","shortcut","displayShortcut","primary","_default","exports"],"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { memo } from '@wordpress/element';\nimport { search } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../lock-unlock';\n\nconst HUB_ANIMATION_DURATION = 0.3;\n\nconst SiteHub = memo( ( { isTransparent, className } ) => {\n\tconst { canvasMode, dashboardLink, homeUrl, siteTitle } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCanvasMode, getSettings } = unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t);\n\n\t\t\tconst {\n\t\t\t\tgetSite,\n\t\t\t\tgetUnstableBase, // Site index.\n\t\t\t} = select( coreStore );\n\t\t\tconst _site = getSite();\n\t\t\treturn {\n\t\t\t\tcanvasMode: getCanvasMode(),\n\t\t\t\tdashboardLink:\n\t\t\t\t\tgetSettings().__experimentalDashboardLink || 'index.php',\n\t\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\t\tsiteTitle:\n\t\t\t\t\t! _site?.title && !! _site?.url\n\t\t\t\t\t\t? filterURLForDisplay( _site?.url )\n\t\t\t\t\t\t: _site?.title,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tconst disableMotion = useReducedMotion();\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setDeviceType } = useDispatch( editorStore );\n\tconst isBackToDashboardButton = canvasMode === 'view';\n\tconst siteIconButtonProps = isBackToDashboardButton\n\t\t? {\n\t\t\t\thref: dashboardLink,\n\t\t\t\tlabel: __( 'Go to the Dashboard' ),\n\t\t }\n\t\t: {\n\t\t\t\thref: dashboardLink, // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation.\n\t\t\t\trole: 'button',\n\t\t\t\tlabel: __( 'Open Navigation' ),\n\t\t\t\tonClick: ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( canvasMode === 'edit' ) {\n\t\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\t\tsetDeviceType( 'Desktop' );\n\t\t\t\t\t\tsetCanvasMode( 'view' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t };\n\n\treturn (\n\t\t<motion.div\n\t\t\tclassName={ clsx( 'edit-site-site-hub', className ) }\n\t\t\tvariants={ {\n\t\t\t\tisDistractionFree: { x: '-100%' },\n\t\t\t\tisDistractionFreeHovering: { x: 0 },\n\t\t\t\tview: { x: 0 },\n\t\t\t\tedit: { x: 0 },\n\t\t\t} }\n\t\t\tinitial={ false }\n\t\t\ttransition={ {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\tease: 'easeOut',\n\t\t\t} }\n\t\t>\n\t\t\t<HStack justify=\"flex-start\" spacing=\"0\">\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'edit-site-site-hub__view-mode-toggle-container',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-transparent-background': isTransparent,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tlayout\n\t\t\t\t\ttransition={ {\n\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\tduration: disableMotion ? 0 : HUB_ANIMATION_DURATION,\n\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t{ ...siteIconButtonProps }\n\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tinitial={ false }\n\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 1,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\twhileHover={ {\n\t\t\t\t\t\t\t\tscale: canvasMode === 'view' ? 0.5 : 0.96,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\tduration: disableMotion\n\t\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t\t: HUB_ANIMATION_DURATION,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t</Button>\n\t\t\t\t</motion.div>\n\n\t\t\t\t<AnimatePresence initial={ false }>\n\t\t\t\t\t{ canvasMode === 'view' && (\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tas={ motion.div }\n\t\t\t\t\t\t\tinitial={ { opacity: 0 } }\n\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\topacity: isTransparent ? 0 : 1,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\texit={ { opacity: 0 } }\n\t\t\t\t\t\t\ttransition={ {\n\t\t\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\t\t\tduration: disableMotion ? 0 : 0.2,\n\t\t\t\t\t\t\t\tease: 'easeOut',\n\t\t\t\t\t\t\t\tdelay: canvasMode === 'view' ? 0.1 : 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t\t'View site (opens in a new tab)'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\taria-label={ __(\n\t\t\t\t\t\t\t\t\t\t'View site (opens in a new tab)'\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\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__actions\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</H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;YAAAuD,QAAA,eACzC,IAAA5D,WAAA,CAAA6C,GAAA,EAAC5D,WAAA,CAAAiF,MAAM;cACNW,OAAO,EAAC,MAAM;cACdvC,IAAI,EAAG9B,OAAS;cAChBsE,MAAM,EAAC,QAAQ;cACfvC,KAAK,EAAG,IAAAC,QAAE,EACT,gCACD,CAAG;cACH,cAAa,IAAAA,QAAE,EACd,gCACD,CAAG;cAAAoB,QAAA,EAED,IAAAmB,4BAAc,EAAEtE,SAAU;YAAC,CACtB;UAAC,CACL,CAAC,eACN,IAAAT,WAAA,CAAA6C,GAAA,EAAC5D,WAAA,CAAA6E,oBAAM;YACNE,OAAO,EAAG,CAAG;YACbgB,QAAQ,EAAG,KAAO;YAClB3E,SAAS,EAAC,6BAA6B;YAAAuD,QAAA,eAEvC,IAAA5D,WAAA,CAAA6C,GAAA,EAAC5D,WAAA,CAAAiF,MAAM;cACN7D,SAAS,EAAC,0CAA0C;cACpD4E,IAAI,EAAGC,aAAQ;cACfxC,OAAO,EAAGA,CAAA,KAAMhB,iBAAiB,CAAC,CAAG;cACrCa,KAAK,EAAG,IAAAC,QAAE,EAAE,sBAAuB,CAAG;cACtC2C,QAAQ,EAAGC,yBAAe,CAACC,OAAO,CAAE,GAAI;YAAG,CAC3C;UAAC,CACK,CAAC;QAAA,CACF;MACR,CACe,CAAC;IAAA,CACX;EAAC,CACE,CAAC;AAEf,CAAE,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjB,OAAA,GAEWpE,OAAO","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_data","_components","_i18n","_coreData","_htmlEntities","_element","_icons","_commands","_keycodes","_url","_store","_siteIcon","_lockUnlock","_jsxRuntime","SiteHub","memo","forwardRef","isTransparent","ref","dashboardLink","homeUrl","siteTitle","useSelect","select","getSettings","unlock","editSiteStore","getSite","getUnstableBase","coreStore","_site","__experimentalDashboardLink","home","title","url","filterURLForDisplay","open","openCommandCenter","useDispatch","commandsStore","jsx","className","children","jsxs","__experimentalHStack","justify","spacing","clsx","Button","href","label","__","style","transform","borderRadius","default","variant","target","decodeEntities","expanded","icon","search","onClick","shortcut","displayShortcut","primary","_default","exports"],"sources":["@wordpress/edit-site/src/components/site-hub/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, __experimentalHStack as HStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { memo, forwardRef } from '@wordpress/element';\nimport { search } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport SiteIcon from '../site-icon';\nimport { unlock } from '../../lock-unlock';\n\nconst SiteHub = memo(\n\tforwardRef( ( { isTransparent }, ref ) => {\n\t\tconst { dashboardLink, homeUrl, siteTitle } = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\n\t\t\tconst {\n\t\t\t\tgetSite,\n\t\t\t\tgetUnstableBase, // Site index.\n\t\t\t} = select( coreStore );\n\t\t\tconst _site = getSite();\n\t\t\treturn {\n\t\t\t\tdashboardLink:\n\t\t\t\t\tgetSettings().__experimentalDashboardLink || 'index.php',\n\t\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\t\tsiteTitle:\n\t\t\t\t\t! _site?.title && !! _site?.url\n\t\t\t\t\t\t? filterURLForDisplay( _site?.url )\n\t\t\t\t\t\t: _site?.title,\n\t\t\t};\n\t\t}, [] );\n\t\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\t\treturn (\n\t\t\t<div className=\"edit-site-site-hub\">\n\t\t\t\t<HStack justify=\"flex-start\" spacing=\"0\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t'edit-site-site-hub__view-mode-toggle-container',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'has-transparent-background': isTransparent,\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<Button\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\thref={ dashboardLink }\n\t\t\t\t\t\t\tlabel={ __( 'Go to the Dashboard' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-layout__view-mode-toggle\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\ttransform: 'scale(0.5)',\n\t\t\t\t\t\t\t\tborderRadius: 4,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<SiteIcon className=\"edit-site-layout__view-mode-toggle-icon\" />\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\n\t\t\t\t\t<HStack>\n\t\t\t\t\t\t<div className=\"edit-site-site-hub__title\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\tlabel={ __( 'View site (opens in a new tab)' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ decodeEntities( siteTitle ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<HStack\n\t\t\t\t\t\t\tspacing={ 0 }\n\t\t\t\t\t\t\texpanded={ false }\n\t\t\t\t\t\t\tclassName=\"edit-site-site-hub__actions\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-site-site-hub_toggle-command-center\"\n\t\t\t\t\t\t\t\ticon={ search }\n\t\t\t\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\t\t\t\tlabel={ __( 'Open command palette' ) }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</HStack>\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t);\n\t} )\n);\n\nexport default SiteHub;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,SAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AAA2C,IAAAc,WAAA,GAAAd,OAAA;AAxB3C;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;;AAKA,MAAMe,OAAO,GAAG,IAAAC,aAAI,EACnB,IAAAC,mBAAU,EAAE,CAAE;EAAEC;AAAc,CAAC,EAAEC,GAAG,KAAM;EACzC,MAAM;IAAEC,aAAa;IAAEC,OAAO;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACtE,MAAM;MAAEC;IAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEF,MAAM,CAAEG,YAAc,CAAE,CAAC;IAEzD,MAAM;MACLC,OAAO;MACPC,eAAe,CAAE;IAClB,CAAC,GAAGL,MAAM,CAAEM,eAAU,CAAC;IACvB,MAAMC,KAAK,GAAGH,OAAO,CAAC,CA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A2C,oBAAM;QAAAF,QAAA,gBACN,IAAA7B,WAAA,CAAA2B,GAAA;UAAKC,SAAS,EAAC,2BAA2B;UAAAC,QAAA,eACzC,IAAA7B,WAAA,CAAA2B,GAAA,EAACvC,WAAA,CAAA+C,MAAM;YACNQ,OAAO,EAAC,MAAM;YACdP,IAAI,EAAG7B,OAAS;YAChBqC,MAAM,EAAC,QAAQ;YACfP,KAAK,EAAG,IAAAC,QAAE,EAAE,gCAAiC,CAAG;YAAAT,QAAA,EAE9C,IAAAgB,4BAAc,EAAErC,SAAU;UAAC,CACtB;QAAC,CACL,CAAC,eACN,IAAAR,WAAA,CAAA2B,GAAA,EAACvC,WAAA,CAAA2C,oBAAM;UACNE,OAAO,EAAG,CAAG;UACba,QAAQ,EAAG,KAAO;UAClBlB,SAAS,EAAC,6BAA6B;UAAAC,QAAA,eAEvC,IAAA7B,WAAA,CAAA2B,GAAA,EAACvC,WAAA,CAAA+C,MAAM;YACNP,SAAS,EAAC,0CAA0C;YACpDmB,IAAI,EAAGC,aAAQ;YACfC,OAAO,EAAGA,CAAA,KAAMzB,iBAAiB,CAAC,CAAG;YACrCa,KAAK,EAAG,IAAAC,QAAE,EAAE,sBAAuB,CAAG;YACtCY,QAAQ,EAAGC,yBAAe,CAACC,OAAO,CAAE,GAAI;UAAG,CAC3C;QAAC,CACK,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACL,CAAC;AAER,CAAE,CACH,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEazC,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useSetCommandContext;
|
|
7
|
+
var _data = require("@wordpress/data");
|
|
8
|
+
var _commands = require("@wordpress/commands");
|
|
9
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
10
|
+
var _store = require("../../store");
|
|
11
|
+
var _lockUnlock = require("../../lock-unlock");
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
useCommandContext
|
|
22
|
+
} = (0, _lockUnlock.unlock)(_commands.privateApis);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* React hook used to set the correct command context based on the current state.
|
|
26
|
+
*/
|
|
27
|
+
function useSetCommandContext() {
|
|
28
|
+
const {
|
|
29
|
+
hasBlockSelected,
|
|
30
|
+
canvasMode
|
|
31
|
+
} = (0, _data.useSelect)(select => {
|
|
32
|
+
const {
|
|
33
|
+
getCanvasMode
|
|
34
|
+
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
35
|
+
const {
|
|
36
|
+
getBlockSelectionStart
|
|
37
|
+
} = select(_blockEditor.store);
|
|
38
|
+
return {
|
|
39
|
+
canvasMode: getCanvasMode(),
|
|
40
|
+
hasBlockSelected: getBlockSelectionStart()
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
// Sets the right context for the command palette
|
|
44
|
+
let commandContext = 'site-editor';
|
|
45
|
+
if (canvasMode === 'edit') {
|
|
46
|
+
commandContext = 'entity-edit';
|
|
47
|
+
}
|
|
48
|
+
if (hasBlockSelected) {
|
|
49
|
+
commandContext = 'block-selection-edit';
|
|
50
|
+
}
|
|
51
|
+
useCommandContext(commandContext);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=use-set-command-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_data","require","_commands","_blockEditor","_store","_lockUnlock","useCommandContext","unlock","commandsPrivateApis","useSetCommandContext","hasBlockSelected","canvasMode","useSelect","select","getCanvasMode","editSiteStore","getBlockSelectionStart","blockEditorStore","commandContext"],"sources":["@wordpress/edit-site/src/hooks/commands/use-set-command-context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { privateApis as commandsPrivateApis } from '@wordpress/commands';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n\n/**\n * React hook used to set the correct command context based on the current state.\n */\nexport default function useSetCommandContext() {\n\tconst { hasBlockSelected, canvasMode } = useSelect( ( select ) => {\n\t\tconst { getCanvasMode } = unlock( select( editSiteStore ) );\n\t\tconst { getBlockSelectionStart } = select( blockEditorStore );\n\t\treturn {\n\t\t\tcanvasMode: getCanvasMode(),\n\t\t\thasBlockSelected: getBlockSelectionStart(),\n\t\t};\n\t}, [] );\n\t// Sets the right context for the command palette\n\tlet commandContext = 'site-editor';\n\tif ( canvasMode === 'edit' ) {\n\t\tcommandContext = 'entity-edit';\n\t}\n\tif ( hasBlockSelected ) {\n\t\tcommandContext = 'block-selection-edit';\n\t}\n\tuseCommandContext( commandContext );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAKA;AACA;AACA;;AAIA,MAAM;EAAEK;AAAkB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAoB,CAAC;;AAE3D;AACA;AACA;AACe,SAASC,oBAAoBA,CAAA,EAAG;EAC9C,MAAM;IAAEC,gBAAgB;IAAEC;EAAW,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACjE,MAAM;MAAEC;IAAc,CAAC,GAAG,IAAAP,kBAAM,EAAEM,MAAM,CAAEE,YAAc,CAAE,CAAC;IAC3D,MAAM;MAAEC;IAAuB,CAAC,GAAGH,MAAM,CAAEI,kBAAiB,CAAC;IAC7D,OAAO;MACNN,UAAU,EAAEG,aAAa,CAAC,CAAC;MAC3BJ,gBAAgB,EAAEM,sBAAsB,CAAC;IAC1C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP;EACA,IAAIE,cAAc,GAAG,aAAa;EAClC,IAAKP,UAAU,KAAK,MAAM,EAAG;IAC5BO,cAAc,GAAG,aAAa;EAC/B;EACA,IAAKR,gBAAgB,EAAG;IACvBQ,cAAc,GAAG,sBAAsB;EACxC;EACAZ,iBAAiB,CAAEY,cAAe,CAAC;AACpC","ignoreList":[]}
|
|
@@ -271,7 +271,7 @@ function PushChangesToGlobalStylesControl({
|
|
|
271
271
|
// notification.
|
|
272
272
|
__unstableMarkNextChangeAsNotPersistent();
|
|
273
273
|
setAttributes(newBlockAttributes);
|
|
274
|
-
setUserConfig(
|
|
274
|
+
setUserConfig(newUserConfig, {
|
|
275
275
|
undoIgnore: true
|
|
276
276
|
});
|
|
277
277
|
createSuccessNotice((0, _i18n.sprintf)(
|
|
@@ -283,7 +283,7 @@ function PushChangesToGlobalStylesControl({
|
|
|
283
283
|
onClick() {
|
|
284
284
|
__unstableMarkNextChangeAsNotPersistent();
|
|
285
285
|
setAttributes(attributes);
|
|
286
|
-
setUserConfig(
|
|
286
|
+
setUserConfig(userConfig, {
|
|
287
287
|
undoIgnore: true
|
|
288
288
|
});
|
|
289
289
|
}
|
|
@@ -301,6 +301,7 @@ function PushChangesToGlobalStylesControl({
|
|
|
301
301
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
302
302
|
__next40pxDefaultSize: true,
|
|
303
303
|
variant: "secondary",
|
|
304
|
+
__experimentalIsFocusable: true,
|
|
304
305
|
disabled: changes.length === 0,
|
|
305
306
|
onClick: pushChanges,
|
|
306
307
|
children: (0, _i18n.__)('Apply globally')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_hooks","require","_compose","_blockEditor","_components","_i18n","_blocks","_element","_data","_notices","_coreData","_hooks2","_lockUnlock","_cloneDeep","_interopRequireDefault","_setNestedValue","_jsxRuntime","cleanEmptyObject","GlobalStylesContext","unlock","blockEditorPrivateApis","STYLE_PROPERTY","__EXPERIMENTAL_STYLE_PROPERTY","blockGap","value","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","SUPPORTED_STYLES","getValueFromObjectPath","object","path","forEach","fieldName","flatBorderProperties","sides","getBorderStyleChanges","border","presetColor","userStyle","changes","getFallbackBorderStyleChange","color","customColor","style","width","hasColorOrWidth","side","push","globalBorderStyle","useChangesToPush","name","attributes","userConfig","supports","useSupportedStyles","blockUserConfig","styles","blocks","useMemo","flatMap","key","presetAttributeKey","join","presetAttributeValue","linkChanges","hoverPath","hoverValue","includes","borderChanges","currentPath","splice","borderColor","change","PushChangesToGlobalStylesControl","setAttributes","user","setUserConfig","useContext","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","useCallback","length","blockStyles","newBlockStyles","cloneDeep","newUserConfig","setNestedValue","undefined","newBlockAttributes","backgroundColor","textColor","gradient","fontSize","fontFamily","undoIgnore","sprintf","__","getBlockType","title","type","actions","label","onClick","jsxs","BaseControl","className","help","children","jsx","VisualLabel","Button","__next40pxDefaultSize","variant","disabled","PushChangesToGlobalStyles","props","blockEditingMode","useBlockEditingMode","isBlockBasedTheme","useSelect","select","coreStore","getCurrentTheme","is_block_theme","supportsStyles","some","feature","hasBlockSupport","isDisplayed","InspectorAdvancedControls","withPushChangesToGlobalStyles","createHigherOrderComponent","BlockEdit","Fragment","isSelected","addFilter"],"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\nimport cloneDeep from '../../utils/clone-deep';\nimport setNestedValue from '../../utils/set-nested-value';\n\nconst { cleanEmptyObject, GlobalStylesContext } = unlock(\n\tblockEditorPrivateApis\n);\n\n// Block Gap is a special case and isn't defined within the blocks\n// style properties config. We'll add it here to allow it to be pushed\n// to global styles as well.\nconst STYLE_PROPERTY = {\n\t...__EXPERIMENTAL_STYLE_PROPERTY,\n\tblockGap: { value: [ 'spacing', 'blockGap' ] },\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'border.color': 'color',\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.caption.color.text': 'color',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\tblockGap: 'spacing',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'border.color': 'borderColor',\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nconst SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\nconst flatBorderProperties = [ 'borderColor', 'borderWidth', 'borderStyle' ];\nconst sides = [ 'top', 'right', 'bottom', 'left' ];\n\nfunction getBorderStyleChanges( border, presetColor, userStyle ) {\n\tif ( ! border && ! presetColor ) {\n\t\treturn [];\n\t}\n\n\tconst changes = [\n\t\t...getFallbackBorderStyleChange( 'top', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'right', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'bottom', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'left', border, userStyle ),\n\t];\n\n\t// Handle a flat border i.e. all sides the same, CSS shorthand.\n\tconst { color: customColor, style, width } = border || {};\n\tconst hasColorOrWidth = presetColor || customColor || width;\n\n\tif ( hasColorOrWidth && ! style ) {\n\t\t// Global Styles need individual side configurations to overcome\n\t\t// theme.json configurations which are per side as well.\n\t\tsides.forEach( ( side ) => {\n\t\t\t// Only add fallback border-style if global styles don't already\n\t\t\t// have something set.\n\t\t\tif ( ! userStyle?.[ side ]?.style ) {\n\t\t\t\tchanges.push( {\n\t\t\t\t\tpath: [ 'border', side, 'style' ],\n\t\t\t\t\tvalue: 'solid',\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}\n\n\treturn changes;\n}\n\nfunction getFallbackBorderStyleChange( side, border, globalBorderStyle ) {\n\tif ( ! border?.[ side ] || globalBorderStyle?.[ side ]?.style ) {\n\t\treturn [];\n\t}\n\n\tconst { color, style, width } = border[ side ];\n\tconst hasColorOrWidth = color || width;\n\n\tif ( ! hasColorOrWidth || style ) {\n\t\treturn [];\n\t}\n\n\treturn [ { path: [ 'border', side, 'style' ], value: 'solid' } ];\n}\n\nfunction useChangesToPush( name, attributes, userConfig ) {\n\tconst supports = useSupportedStyles( name );\n\tconst blockUserConfig = userConfig?.styles?.blocks?.[ name ];\n\n\treturn useMemo( () => {\n\t\tconst changes = supports.flatMap( ( key ) => {\n\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\tconst presetAttributeValue =\n\t\t\t\tattributes[\n\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t\t];\n\t\t\tconst value = presetAttributeValue\n\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t: getValueFromObjectPath( attributes.style, path );\n\n\t\t\t// Links only have a single support entry but have two element\n\t\t\t// style properties, color and hover color. The following check\n\t\t\t// will add the hover color to the changes if required.\n\t\t\tif ( key === 'linkColor' ) {\n\t\t\t\tconst linkChanges = value ? [ { path, value } ] : [];\n\t\t\t\tconst hoverPath = [\n\t\t\t\t\t'elements',\n\t\t\t\t\t'link',\n\t\t\t\t\t':hover',\n\t\t\t\t\t'color',\n\t\t\t\t\t'text',\n\t\t\t\t];\n\t\t\t\tconst hoverValue = getValueFromObjectPath(\n\t\t\t\t\tattributes.style,\n\t\t\t\t\thoverPath\n\t\t\t\t);\n\n\t\t\t\tif ( hoverValue ) {\n\t\t\t\t\tlinkChanges.push( { path: hoverPath, value: hoverValue } );\n\t\t\t\t}\n\n\t\t\t\treturn linkChanges;\n\t\t\t}\n\n\t\t\t// The shorthand border styles can't be mapped directly as global\n\t\t\t// styles requires longhand config.\n\t\t\tif ( flatBorderProperties.includes( key ) && value ) {\n\t\t\t\t// The shorthand config path is included to clear the block attribute.\n\t\t\t\tconst borderChanges = [ { path, value } ];\n\t\t\t\tsides.forEach( ( side ) => {\n\t\t\t\t\tconst currentPath = [ ...path ];\n\t\t\t\t\tcurrentPath.splice( -1, 0, side );\n\t\t\t\t\tborderChanges.push( { path: currentPath, value } );\n\t\t\t\t} );\n\t\t\t\treturn borderChanges;\n\t\t\t}\n\n\t\t\treturn value ? [ { path, value } ] : [];\n\t\t} );\n\n\t\t// To ensure display of a visible border, global styles require a\n\t\t// default border style if a border color or width is present.\n\t\tgetBorderStyleChanges(\n\t\t\tattributes.style?.border,\n\t\t\tattributes.borderColor,\n\t\t\tblockUserConfig?.border\n\t\t).forEach( ( change ) => changes.push( change ) );\n\n\t\treturn changes;\n\t}, [ supports, attributes, blockUserConfig ] );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst changes = useChangesToPush( name, attributes, userConfig );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( changes.length > 0 ) {\n\t\t\tconst { style: blockStyles } = attributes;\n\n\t\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\t\tfor ( const { path, value } of changes ) {\n\t\t\t\tsetNestedValue( newBlockStyles, path, undefined );\n\t\t\t\tsetNestedValue(\n\t\t\t\t\tnewUserConfig,\n\t\t\t\t\t[ 'styles', 'blocks', name, ...path ],\n\t\t\t\t\tvalue\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst newBlockAttributes = {\n\t\t\t\tborderColor: undefined,\n\t\t\t\tbackgroundColor: undefined,\n\t\t\t\ttextColor: undefined,\n\t\t\t\tgradient: undefined,\n\t\t\t\tfontSize: undefined,\n\t\t\t\tfontFamily: undefined,\n\t\t\t\tstyle: cleanEmptyObject( newBlockStyles ),\n\t\t\t};\n\n\t\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t\t// tracking and implement our own Undo button in the snackbar\n\t\t\t// notification.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( newBlockAttributes );\n\t\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\t\tgetBlockType( name ).title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tsetAttributes( attributes );\n\t\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\t\tundoIgnore: true,\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],\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tattributes,\n\t\tchanges,\n\t\tcreateSuccessNotice,\n\t\tname,\n\t\tsetAttributes,\n\t\tsetUserConfig,\n\t\tuserConfig,\n\t] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nfunction PushChangesToGlobalStyles( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isBlockBasedTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n\tconst supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>\n\t\thasBlockSupport( props.name, feature )\n\t);\n\tconst isDisplayed =\n\t\tblockEditingMode === 'default' && supportsStyles && isBlockBasedTheme;\n\n\tif ( ! isDisplayed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorAdvancedControls>\n\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t</InspectorAdvancedControls>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => (\n\t\t<>\n\t\t\t<BlockEdit { ...props } />\n\t\t\t{ props.isSelected && <PushChangesToGlobalStyles { ...props } /> }\n\t\t</>\n\t)\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"],"mappings":";;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAKA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAKA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,UAAA,GAAAC,sBAAA,CAAAb,OAAA;AACA,IAAAc,eAAA,GAAAD,sBAAA,CAAAb,OAAA;AAA0D,IAAAe,WAAA,GAAAf,OAAA;AA7B1D;AACA;AACA;;AAqBA;AACA;AACA;;AAMA,MAA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AiB,GAAG,IAAAC,eAAS,EAChCC,MAAM,IAAMA,MAAM,CAAEC,eAAU,CAAC,CAACC,eAAe,CAAC,CAAC,EAAEC,cAAc,EACnE,EACD,CAAC;EACD,MAAMC,cAAc,GAAGrG,gBAAgB,CAACsG,IAAI,CAAIC,OAAO,IACtD,IAAAC,uBAAe,EAAEZ,KAAK,CAACrE,IAAI,EAAEgF,OAAQ,CACtC,CAAC;EACD,MAAME,WAAW,GAChBZ,gBAAgB,KAAK,SAAS,IAAIQ,cAAc,IAAIN,iBAAiB;EAEtE,IAAK,CAAEU,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAApH,WAAA,CAAAgG,GAAA,EAAC7G,YAAA,CAAAkI,yBAAyB;IAAAtB,QAAA,eACzB,IAAA/F,WAAA,CAAAgG,GAAA,EAACvC,gCAAgC;MAAA,GAAM8C;IAAK,CAAI;EAAC,CACvB,CAAC;AAE9B;AAEA,MAAMe,6BAA6B,GAAG,IAAAC,mCAA0B,EAC7DC,SAAS,IAAQjB,KAAK,iBACvB,IAAAvG,WAAA,CAAA2F,IAAA,EAAA3F,WAAA,CAAAyH,QAAA;EAAA1B,QAAA,gBACC,IAAA/F,WAAA,CAAAgG,GAAA,EAACwB,SAAS;IAAA,GAAMjB;EAAK,CAAI,CAAC,EACxBA,KAAK,CAACmB,UAAU,iBAAI,IAAA1H,WAAA,CAAAgG,GAAA,EAACM,yBAAyB;IAAA,GAAMC;EAAK,CAAI,CAAC;AAAA,CAC/D,CAEJ,CAAC;AAED,IAAAoB,gBAAS,EACR,kBAAkB,EAClB,8CAA8C,EAC9CL,6BACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_hooks","require","_compose","_blockEditor","_components","_i18n","_blocks","_element","_data","_notices","_coreData","_hooks2","_lockUnlock","_cloneDeep","_interopRequireDefault","_setNestedValue","_jsxRuntime","cleanEmptyObject","GlobalStylesContext","unlock","blockEditorPrivateApis","STYLE_PROPERTY","__EXPERIMENTAL_STYLE_PROPERTY","blockGap","value","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","SUPPORTED_STYLES","getValueFromObjectPath","object","path","forEach","fieldName","flatBorderProperties","sides","getBorderStyleChanges","border","presetColor","userStyle","changes","getFallbackBorderStyleChange","color","customColor","style","width","hasColorOrWidth","side","push","globalBorderStyle","useChangesToPush","name","attributes","userConfig","supports","useSupportedStyles","blockUserConfig","styles","blocks","useMemo","flatMap","key","presetAttributeKey","join","presetAttributeValue","linkChanges","hoverPath","hoverValue","includes","borderChanges","currentPath","splice","borderColor","change","PushChangesToGlobalStylesControl","setAttributes","user","setUserConfig","useContext","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","useCallback","length","blockStyles","newBlockStyles","cloneDeep","newUserConfig","setNestedValue","undefined","newBlockAttributes","backgroundColor","textColor","gradient","fontSize","fontFamily","undoIgnore","sprintf","__","getBlockType","title","type","actions","label","onClick","jsxs","BaseControl","className","help","children","jsx","VisualLabel","Button","__next40pxDefaultSize","variant","__experimentalIsFocusable","disabled","PushChangesToGlobalStyles","props","blockEditingMode","useBlockEditingMode","isBlockBasedTheme","useSelect","select","coreStore","getCurrentTheme","is_block_theme","supportsStyles","some","feature","hasBlockSupport","isDisplayed","InspectorAdvancedControls","withPushChangesToGlobalStyles","createHigherOrderComponent","BlockEdit","Fragment","isSelected","addFilter"],"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\nimport cloneDeep from '../../utils/clone-deep';\nimport setNestedValue from '../../utils/set-nested-value';\n\nconst { cleanEmptyObject, GlobalStylesContext } = unlock(\n\tblockEditorPrivateApis\n);\n\n// Block Gap is a special case and isn't defined within the blocks\n// style properties config. We'll add it here to allow it to be pushed\n// to global styles as well.\nconst STYLE_PROPERTY = {\n\t...__EXPERIMENTAL_STYLE_PROPERTY,\n\tblockGap: { value: [ 'spacing', 'blockGap' ] },\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'border.color': 'color',\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.caption.color.text': 'color',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\tblockGap: 'spacing',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'border.color': 'borderColor',\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nconst SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];\n\nconst getValueFromObjectPath = ( object, path ) => {\n\tlet value = object;\n\tpath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\n};\n\nconst flatBorderProperties = [ 'borderColor', 'borderWidth', 'borderStyle' ];\nconst sides = [ 'top', 'right', 'bottom', 'left' ];\n\nfunction getBorderStyleChanges( border, presetColor, userStyle ) {\n\tif ( ! border && ! presetColor ) {\n\t\treturn [];\n\t}\n\n\tconst changes = [\n\t\t...getFallbackBorderStyleChange( 'top', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'right', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'bottom', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'left', border, userStyle ),\n\t];\n\n\t// Handle a flat border i.e. all sides the same, CSS shorthand.\n\tconst { color: customColor, style, width } = border || {};\n\tconst hasColorOrWidth = presetColor || customColor || width;\n\n\tif ( hasColorOrWidth && ! style ) {\n\t\t// Global Styles need individual side configurations to overcome\n\t\t// theme.json configurations which are per side as well.\n\t\tsides.forEach( ( side ) => {\n\t\t\t// Only add fallback border-style if global styles don't already\n\t\t\t// have something set.\n\t\t\tif ( ! userStyle?.[ side ]?.style ) {\n\t\t\t\tchanges.push( {\n\t\t\t\t\tpath: [ 'border', side, 'style' ],\n\t\t\t\t\tvalue: 'solid',\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}\n\n\treturn changes;\n}\n\nfunction getFallbackBorderStyleChange( side, border, globalBorderStyle ) {\n\tif ( ! border?.[ side ] || globalBorderStyle?.[ side ]?.style ) {\n\t\treturn [];\n\t}\n\n\tconst { color, style, width } = border[ side ];\n\tconst hasColorOrWidth = color || width;\n\n\tif ( ! hasColorOrWidth || style ) {\n\t\treturn [];\n\t}\n\n\treturn [ { path: [ 'border', side, 'style' ], value: 'solid' } ];\n}\n\nfunction useChangesToPush( name, attributes, userConfig ) {\n\tconst supports = useSupportedStyles( name );\n\tconst blockUserConfig = userConfig?.styles?.blocks?.[ name ];\n\n\treturn useMemo( () => {\n\t\tconst changes = supports.flatMap( ( key ) => {\n\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\tconst presetAttributeValue =\n\t\t\t\tattributes[\n\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t\t];\n\t\t\tconst value = presetAttributeValue\n\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t: getValueFromObjectPath( attributes.style, path );\n\n\t\t\t// Links only have a single support entry but have two element\n\t\t\t// style properties, color and hover color. The following check\n\t\t\t// will add the hover color to the changes if required.\n\t\t\tif ( key === 'linkColor' ) {\n\t\t\t\tconst linkChanges = value ? [ { path, value } ] : [];\n\t\t\t\tconst hoverPath = [\n\t\t\t\t\t'elements',\n\t\t\t\t\t'link',\n\t\t\t\t\t':hover',\n\t\t\t\t\t'color',\n\t\t\t\t\t'text',\n\t\t\t\t];\n\t\t\t\tconst hoverValue = getValueFromObjectPath(\n\t\t\t\t\tattributes.style,\n\t\t\t\t\thoverPath\n\t\t\t\t);\n\n\t\t\t\tif ( hoverValue ) {\n\t\t\t\t\tlinkChanges.push( { path: hoverPath, value: hoverValue } );\n\t\t\t\t}\n\n\t\t\t\treturn linkChanges;\n\t\t\t}\n\n\t\t\t// The shorthand border styles can't be mapped directly as global\n\t\t\t// styles requires longhand config.\n\t\t\tif ( flatBorderProperties.includes( key ) && value ) {\n\t\t\t\t// The shorthand config path is included to clear the block attribute.\n\t\t\t\tconst borderChanges = [ { path, value } ];\n\t\t\t\tsides.forEach( ( side ) => {\n\t\t\t\t\tconst currentPath = [ ...path ];\n\t\t\t\t\tcurrentPath.splice( -1, 0, side );\n\t\t\t\t\tborderChanges.push( { path: currentPath, value } );\n\t\t\t\t} );\n\t\t\t\treturn borderChanges;\n\t\t\t}\n\n\t\t\treturn value ? [ { path, value } ] : [];\n\t\t} );\n\n\t\t// To ensure display of a visible border, global styles require a\n\t\t// default border style if a border color or width is present.\n\t\tgetBorderStyleChanges(\n\t\t\tattributes.style?.border,\n\t\t\tattributes.borderColor,\n\t\t\tblockUserConfig?.border\n\t\t).forEach( ( change ) => changes.push( change ) );\n\n\t\treturn changes;\n\t}, [ supports, attributes, blockUserConfig ] );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst changes = useChangesToPush( name, attributes, userConfig );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( changes.length > 0 ) {\n\t\t\tconst { style: blockStyles } = attributes;\n\n\t\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\t\tfor ( const { path, value } of changes ) {\n\t\t\t\tsetNestedValue( newBlockStyles, path, undefined );\n\t\t\t\tsetNestedValue(\n\t\t\t\t\tnewUserConfig,\n\t\t\t\t\t[ 'styles', 'blocks', name, ...path ],\n\t\t\t\t\tvalue\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst newBlockAttributes = {\n\t\t\t\tborderColor: undefined,\n\t\t\t\tbackgroundColor: undefined,\n\t\t\t\ttextColor: undefined,\n\t\t\t\tgradient: undefined,\n\t\t\t\tfontSize: undefined,\n\t\t\t\tfontFamily: undefined,\n\t\t\t\tstyle: cleanEmptyObject( newBlockStyles ),\n\t\t\t};\n\n\t\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t\t// tracking and implement our own Undo button in the snackbar\n\t\t\t// notification.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( newBlockAttributes );\n\t\t\tsetUserConfig( newUserConfig, { undoIgnore: true } );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\t\tgetBlockType( name ).title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\tsetAttributes( attributes );\n\t\t\t\t\t\t\t\tsetUserConfig( userConfig, {\n\t\t\t\t\t\t\t\t\tundoIgnore: true,\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],\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tattributes,\n\t\tchanges,\n\t\tcreateSuccessNotice,\n\t\tname,\n\t\tsetAttributes,\n\t\tsetUserConfig,\n\t\tuserConfig,\n\t] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\t__experimentalIsFocusable\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nfunction PushChangesToGlobalStyles( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst isBlockBasedTheme = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme,\n\t\t[]\n\t);\n\tconst supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>\n\t\thasBlockSupport( props.name, feature )\n\t);\n\tconst isDisplayed =\n\t\tblockEditingMode === 'default' && supportsStyles && isBlockBasedTheme;\n\n\tif ( ! isDisplayed ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorAdvancedControls>\n\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t</InspectorAdvancedControls>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => (\n\t\t<>\n\t\t\t<BlockEdit { ...props } />\n\t\t\t{ props.isSelected && <PushChangesToGlobalStyles { ...props } /> }\n\t\t</>\n\t)\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"],"mappings":";;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAKA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAKA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AACA,IAAAY,UAAA,GAAAC,sBAAA,CAAAb,OAAA;AACA,IAAAc,eAAA,GAAAD,sBAAA,CAAAb,OAAA;AAA0D,IAAAe,WAAA,GAAAf,OAAA;AA7B1D;AACA;AACA;;AAqBA;AACA;AACA;;AAMA,MAAM;EAAEgB,gBAAgB;EAAEC;AAAoB,CAAC,GAAG,IAAAC,kBAAM,EACvDC,wBACD,CAAC;;AAED;AACA;AACA;AACA,MAAMC,cAAc,GAAG;EACtB,GAAGC,qC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MC,cAAc,GAAGtG,gBAAgB,CAACuG,IAAI,CAAIC,OAAO,IACtD,IAAAC,uBAAe,EAAEZ,KAAK,CAACtE,IAAI,EAAEiF,OAAQ,CACtC,CAAC;EACD,MAAME,WAAW,GAChBZ,gBAAgB,KAAK,SAAS,IAAIQ,cAAc,IAAIN,iBAAiB;EAEtE,IAAK,CAAEU,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAArH,WAAA,CAAAgG,GAAA,EAAC7G,YAAA,CAAAmI,yBAAyB;IAAAvB,QAAA,eACzB,IAAA/F,WAAA,CAAAgG,GAAA,EAACvC,gCAAgC;MAAA,GAAM+C;IAAK,CAAI;EAAC,CACvB,CAAC;AAE9B;AAEA,MAAMe,6BAA6B,GAAG,IAAAC,mCAA0B,EAC7DC,SAAS,IAAQjB,KAAK,iBACvB,IAAAxG,WAAA,CAAA2F,IAAA,EAAA3F,WAAA,CAAA0H,QAAA;EAAA3B,QAAA,gBACC,IAAA/F,WAAA,CAAAgG,GAAA,EAACyB,SAAS;IAAA,GAAMjB;EAAK,CAAI,CAAC,EACxBA,KAAK,CAACmB,UAAU,iBAAI,IAAA3H,WAAA,CAAAgG,GAAA,EAACO,yBAAyB;IAAA,GAAMC;EAAK,CAAI,CAAC;AAAA,CAC/D,CAEJ,CAAC;AAED,IAAAoB,gBAAS,EACR,kBAAkB,EAClB,8CAA8C,EAC9CL,6BACD,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default = useThemeStyleVariationsByProperty;
|
|
8
7
|
exports.filterObjectByProperty = void 0;
|
|
9
8
|
exports.isVariationWithSingleProperty = isVariationWithSingleProperty;
|
|
10
9
|
exports.removePropertyFromObject = removePropertyFromObject;
|
|
@@ -57,17 +56,15 @@ function removePropertyFromObject(object, property) {
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
61
|
-
* and
|
|
59
|
+
* Fetches the current theme style variations that contain only the specified property
|
|
60
|
+
* and merges them with the user config.
|
|
62
61
|
*
|
|
63
|
-
* @param {Object}
|
|
64
|
-
* @param {string}
|
|
65
|
-
* @param {Function} props.filter Optional. The filter function to apply to the variations.
|
|
62
|
+
* @param {Object} props Object of hook args.
|
|
63
|
+
* @param {string} props.property The property to filter by.
|
|
66
64
|
* @return {Object[]|*} The merged object.
|
|
67
65
|
*/
|
|
68
66
|
function useCurrentMergeThemeStyleVariationsWithUserConfig({
|
|
69
|
-
property
|
|
70
|
-
filter
|
|
67
|
+
property
|
|
71
68
|
}) {
|
|
72
69
|
const {
|
|
73
70
|
variationsFromTheme
|
|
@@ -78,21 +75,21 @@ function useCurrentMergeThemeStyleVariationsWithUserConfig({
|
|
|
78
75
|
};
|
|
79
76
|
}, []);
|
|
80
77
|
const {
|
|
81
|
-
user:
|
|
78
|
+
user: userVariation
|
|
82
79
|
} = (0, _element.useContext)(GlobalStylesContext);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
80
|
+
return (0, _element.useMemo)(() => {
|
|
81
|
+
const clonedUserVariation = (0, _cloneDeep.default)(userVariation);
|
|
82
|
+
|
|
83
|
+
// Get user variation and remove the settings for the given property.
|
|
84
|
+
const userVariationWithoutProperty = removePropertyFromObject(clonedUserVariation, property);
|
|
85
|
+
userVariationWithoutProperty.title = (0, _i18n.__)('Default');
|
|
86
|
+
const variationsWithSinglePropertyAndBase = variationsFromTheme.filter(variation => {
|
|
87
|
+
return isVariationWithSingleProperty(variation, property);
|
|
88
|
+
}).map(variation => {
|
|
89
|
+
return mergeBaseAndUserConfigs(userVariationWithoutProperty, variation);
|
|
90
|
+
});
|
|
91
|
+
return [userVariationWithoutProperty, ...variationsWithSinglePropertyAndBase];
|
|
92
|
+
}, [property, userVariation, variationsFromTheme]);
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
/**
|
|
@@ -123,72 +120,6 @@ const filterObjectByProperty = (object, property) => {
|
|
|
123
120
|
return newObject;
|
|
124
121
|
};
|
|
125
122
|
|
|
126
|
-
/**
|
|
127
|
-
* Returns a new object with only the properties specified in `property`.
|
|
128
|
-
* Optional merges the baseVariation object with the variation object.
|
|
129
|
-
* Note: this function will only overwrite the specified property in baseVariation if it exists.
|
|
130
|
-
* The baseVariation will not be otherwise modified. To strip a property from the baseVariation object, use `removePropertyFromObject`.
|
|
131
|
-
* See useCurrentMergeThemeStyleVariationsWithUserConfig for an example of how to use this function.
|
|
132
|
-
*
|
|
133
|
-
* @param {Object} props Object of hook args.
|
|
134
|
-
* @param {Object[]} props.variations The theme style variations to filter.
|
|
135
|
-
* @param {string} props.property The property to filter by.
|
|
136
|
-
* @param {Function} props.filter Optional. The filter function to apply to the variations.
|
|
137
|
-
* @param {Object} props.baseVariation Optional. Base or user settings to be updated with variation properties.
|
|
138
|
-
* @return {Object[]|*} The merged object.
|
|
139
|
-
*/
|
|
140
|
-
exports.filterObjectByProperty = filterObjectByProperty;
|
|
141
|
-
function useThemeStyleVariationsByProperty({
|
|
142
|
-
variations,
|
|
143
|
-
property,
|
|
144
|
-
filter,
|
|
145
|
-
baseVariation
|
|
146
|
-
}) {
|
|
147
|
-
return (0, _element.useMemo)(() => {
|
|
148
|
-
if (!property || !variations || variations?.length === 0) {
|
|
149
|
-
return variations;
|
|
150
|
-
}
|
|
151
|
-
const clonedBaseVariation = typeof baseVariation === 'object' && Object.keys(baseVariation).length > 0 ? (0, _cloneDeep.default)(baseVariation) : null;
|
|
152
|
-
let processedStyleVariations = variations.reduce((accumulator, variation) => {
|
|
153
|
-
const variationFilteredByProperty = filterObjectByProperty((0, _cloneDeep.default)(variation), property);
|
|
154
|
-
|
|
155
|
-
// Remove variations that are empty once the property is filtered out.
|
|
156
|
-
if (variation.title !== (0, _i18n.__)('Default') && Object.keys(variationFilteredByProperty).length === 0) {
|
|
157
|
-
return accumulator;
|
|
158
|
-
}
|
|
159
|
-
let result = {
|
|
160
|
-
...variationFilteredByProperty,
|
|
161
|
-
title: variation?.title,
|
|
162
|
-
description: variation?.description
|
|
163
|
-
};
|
|
164
|
-
if (clonedBaseVariation) {
|
|
165
|
-
/*
|
|
166
|
-
* Overwrites all baseVariation object `styleProperty` properties
|
|
167
|
-
* with the theme variation `styleProperty` properties.
|
|
168
|
-
*/
|
|
169
|
-
result = mergeBaseAndUserConfigs(clonedBaseVariation, result);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Detect if this is a duplicate variation.
|
|
173
|
-
const isDuplicate = accumulator.some(item => {
|
|
174
|
-
return JSON.stringify(item.styles) === JSON.stringify(result?.styles) && JSON.stringify(item.settings) === JSON.stringify(result?.settings);
|
|
175
|
-
});
|
|
176
|
-
if (isDuplicate) {
|
|
177
|
-
return accumulator;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// If the variation is not a duplicate, add it to the accumulator.
|
|
181
|
-
accumulator.push(result);
|
|
182
|
-
return accumulator;
|
|
183
|
-
}, [] // Initial accumulator value.
|
|
184
|
-
);
|
|
185
|
-
if ('function' === typeof filter) {
|
|
186
|
-
processedStyleVariations = processedStyleVariations.filter(filter);
|
|
187
|
-
}
|
|
188
|
-
return processedStyleVariations;
|
|
189
|
-
}, [variations, property, baseVariation, filter]);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
123
|
/**
|
|
193
124
|
* Compares a style variation to the same variation filtered by a single property.
|
|
194
125
|
* Returns true if the variation contains only the property specified.
|
|
@@ -197,6 +128,7 @@ function useThemeStyleVariationsByProperty({
|
|
|
197
128
|
* @param {string} property The property to compare.
|
|
198
129
|
* @return {boolean} Whether the variation contains only a single property.
|
|
199
130
|
*/
|
|
131
|
+
exports.filterObjectByProperty = filterObjectByProperty;
|
|
200
132
|
function isVariationWithSingleProperty(variation, property) {
|
|
201
133
|
const variationWithProperty = filterObjectByProperty((0, _cloneDeep.default)(variation), property);
|
|
202
134
|
return JSON.stringify(variationWithProperty?.styles) === JSON.stringify(variation?.styles) && JSON.stringify(variationWithProperty?.settings) === JSON.stringify(variation?.settings);
|