@wordpress/edit-site 6.1.0 → 6.2.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 -6
- package/build/components/add-new-page/index.js +9 -1
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +31 -16
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/editor/index.js +11 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +18 -7
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/font-families.js +17 -17
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +2 -2
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/variations/variation.js +25 -19
- package/build/components/global-styles/variations/variation.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +1 -0
- 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/page-pages/index.js +38 -6
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/index.js +8 -2
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/rename-category-menu-item.js +3 -1
- package/build/components/page-patterns/rename-category-menu-item.js.map +1 -1
- package/build/components/page-templates/index.js +10 -3
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -4
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +2 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build/deprecated.js +11 -0
- package/build/deprecated.js.map +1 -1
- package/build/hooks/commands/use-set-command-context.js +11 -0
- package/build/hooks/commands/use-set-command-context.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build-module/components/add-new-page/index.js +10 -2
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +31 -16
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/editor/index.js +12 -5
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +19 -8
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +18 -18
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +2 -2
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/variations/variation.js +25 -19
- package/build-module/components/global-styles/variations/variation.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +1 -0
- 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/page-pages/index.js +38 -6
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +8 -2
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/rename-category-menu-item.js +3 -1
- package/build-module/components/page-patterns/rename-category-menu-item.js.map +1 -1
- package/build-module/components/page-templates/index.js +10 -3
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +5 -5
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +2 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build-module/deprecated.js +11 -0
- package/build-module/deprecated.js.map +1 -1
- package/build-module/hooks/commands/use-set-command-context.js +11 -0
- package/build-module/hooks/commands/use-set-command-context.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-style/style-rtl.css +19 -17
- package/build-style/style.css +19 -17
- package/lib/inflate.js +3188 -3937
- package/lib/lib-font.browser.js +32 -2
- package/lib/unbrotli.js +1818 -2458
- package/package.json +41 -41
- package/src/components/add-new-page/index.js +20 -2
- package/src/components/add-new-pattern/index.js +38 -23
- package/src/components/block-editor/style.scss +0 -11
- package/src/components/editor/index.js +13 -15
- package/src/components/editor-canvas-container/index.js +20 -8
- package/src/components/global-styles/font-families.js +28 -19
- package/src/components/global-styles/font-library-modal/context.js +2 -2
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/global-styles/variations/variation.js +37 -22
- package/src/components/global-styles/variations/variations-color.js +1 -0
- package/src/components/global-styles/variations/variations-typography.js +1 -0
- package/src/components/page-pages/index.js +45 -11
- package/src/components/page-patterns/index.js +8 -2
- package/src/components/page-patterns/rename-category-menu-item.js +2 -0
- package/src/components/page-templates/index.js +9 -2
- package/src/components/sidebar-dataviews/default-views.js +13 -5
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +6 -1
- package/src/deprecated.js +14 -0
- package/src/hooks/commands/use-set-command-context.js +12 -0
- package/src/lock-unlock.js +1 -1
- package/src/style.scss +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,45 +29,45 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.16.0",
|
|
31
31
|
"@react-spring/web": "^9.4.5",
|
|
32
|
-
"@wordpress/a11y": "^4.
|
|
33
|
-
"@wordpress/api-fetch": "^7.
|
|
34
|
-
"@wordpress/blob": "^4.
|
|
35
|
-
"@wordpress/block-editor": "^13.
|
|
36
|
-
"@wordpress/block-library": "^9.
|
|
37
|
-
"@wordpress/blocks": "^13.
|
|
38
|
-
"@wordpress/commands": "^1.
|
|
39
|
-
"@wordpress/components": "^28.
|
|
40
|
-
"@wordpress/compose": "^7.
|
|
41
|
-
"@wordpress/core-commands": "^1.
|
|
42
|
-
"@wordpress/core-data": "^7.
|
|
43
|
-
"@wordpress/data": "^10.
|
|
44
|
-
"@wordpress/dataviews": "^2.
|
|
45
|
-
"@wordpress/date": "^5.
|
|
46
|
-
"@wordpress/deprecated": "^4.
|
|
47
|
-
"@wordpress/dom": "^4.
|
|
48
|
-
"@wordpress/editor": "^14.
|
|
49
|
-
"@wordpress/element": "^6.
|
|
50
|
-
"@wordpress/escape-html": "^3.
|
|
51
|
-
"@wordpress/hooks": "^4.
|
|
52
|
-
"@wordpress/html-entities": "^4.
|
|
53
|
-
"@wordpress/i18n": "^5.
|
|
54
|
-
"@wordpress/icons": "^10.
|
|
55
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
56
|
-
"@wordpress/keycodes": "^4.
|
|
57
|
-
"@wordpress/notices": "^5.
|
|
58
|
-
"@wordpress/patterns": "^2.
|
|
59
|
-
"@wordpress/plugins": "^7.
|
|
60
|
-
"@wordpress/preferences": "^4.
|
|
61
|
-
"@wordpress/primitives": "^4.
|
|
62
|
-
"@wordpress/priority-queue": "^3.
|
|
63
|
-
"@wordpress/private-apis": "^1.
|
|
64
|
-
"@wordpress/reusable-blocks": "^5.
|
|
65
|
-
"@wordpress/router": "^1.
|
|
66
|
-
"@wordpress/style-engine": "^2.
|
|
67
|
-
"@wordpress/url": "^4.
|
|
68
|
-
"@wordpress/viewport": "^6.
|
|
69
|
-
"@wordpress/widgets": "^4.
|
|
70
|
-
"@wordpress/wordcount": "^4.
|
|
32
|
+
"@wordpress/a11y": "^4.2.0",
|
|
33
|
+
"@wordpress/api-fetch": "^7.2.0",
|
|
34
|
+
"@wordpress/blob": "^4.2.0",
|
|
35
|
+
"@wordpress/block-editor": "^13.2.0",
|
|
36
|
+
"@wordpress/block-library": "^9.2.0",
|
|
37
|
+
"@wordpress/blocks": "^13.2.0",
|
|
38
|
+
"@wordpress/commands": "^1.2.0",
|
|
39
|
+
"@wordpress/components": "^28.2.0",
|
|
40
|
+
"@wordpress/compose": "^7.2.0",
|
|
41
|
+
"@wordpress/core-commands": "^1.2.0",
|
|
42
|
+
"@wordpress/core-data": "^7.2.0",
|
|
43
|
+
"@wordpress/data": "^10.2.0",
|
|
44
|
+
"@wordpress/dataviews": "^2.2.0",
|
|
45
|
+
"@wordpress/date": "^5.2.0",
|
|
46
|
+
"@wordpress/deprecated": "^4.2.0",
|
|
47
|
+
"@wordpress/dom": "^4.2.0",
|
|
48
|
+
"@wordpress/editor": "^14.2.0",
|
|
49
|
+
"@wordpress/element": "^6.2.0",
|
|
50
|
+
"@wordpress/escape-html": "^3.2.0",
|
|
51
|
+
"@wordpress/hooks": "^4.2.0",
|
|
52
|
+
"@wordpress/html-entities": "^4.2.0",
|
|
53
|
+
"@wordpress/i18n": "^5.2.0",
|
|
54
|
+
"@wordpress/icons": "^10.2.0",
|
|
55
|
+
"@wordpress/keyboard-shortcuts": "^5.2.0",
|
|
56
|
+
"@wordpress/keycodes": "^4.2.0",
|
|
57
|
+
"@wordpress/notices": "^5.2.0",
|
|
58
|
+
"@wordpress/patterns": "^2.2.0",
|
|
59
|
+
"@wordpress/plugins": "^7.2.0",
|
|
60
|
+
"@wordpress/preferences": "^4.2.0",
|
|
61
|
+
"@wordpress/primitives": "^4.2.0",
|
|
62
|
+
"@wordpress/priority-queue": "^3.2.0",
|
|
63
|
+
"@wordpress/private-apis": "^1.2.0",
|
|
64
|
+
"@wordpress/reusable-blocks": "^5.2.0",
|
|
65
|
+
"@wordpress/router": "^1.2.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.2.0",
|
|
67
|
+
"@wordpress/url": "^4.2.0",
|
|
68
|
+
"@wordpress/viewport": "^6.2.0",
|
|
69
|
+
"@wordpress/widgets": "^4.2.0",
|
|
70
|
+
"@wordpress/wordcount": "^4.2.0",
|
|
71
71
|
"change-case": "^4.1.2",
|
|
72
72
|
"clsx": "^2.1.1",
|
|
73
73
|
"colord": "^2.9.2",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "aa5b14bb5bdbb8d8a02914e154c3bc1c2f18ace6"
|
|
86
86
|
}
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
TextControl,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { __, sprintf } from '@wordpress/i18n';
|
|
12
|
-
import { useDispatch } from '@wordpress/data';
|
|
12
|
+
import { useDispatch, useRegistry } from '@wordpress/data';
|
|
13
13
|
import { useState } from '@wordpress/element';
|
|
14
14
|
import { store as coreStore } from '@wordpress/core-data';
|
|
15
15
|
import { store as noticesStore } from '@wordpress/notices';
|
|
16
16
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
17
|
+
import { serialize, synchronizeBlocksWithTemplate } from '@wordpress/blocks';
|
|
17
18
|
|
|
18
19
|
export default function AddNewPageModal( { onSave, onClose } ) {
|
|
19
20
|
const [ isCreatingPage, setIsCreatingPage ] = useState( false );
|
|
@@ -22,6 +23,7 @@ export default function AddNewPageModal( { onSave, onClose } ) {
|
|
|
22
23
|
const { saveEntityRecord } = useDispatch( coreStore );
|
|
23
24
|
const { createErrorNotice, createSuccessNotice } =
|
|
24
25
|
useDispatch( noticesStore );
|
|
26
|
+
const { resolveSelect } = useRegistry();
|
|
25
27
|
|
|
26
28
|
async function createPage( event ) {
|
|
27
29
|
event.preventDefault();
|
|
@@ -31,6 +33,8 @@ export default function AddNewPageModal( { onSave, onClose } ) {
|
|
|
31
33
|
}
|
|
32
34
|
setIsCreatingPage( true );
|
|
33
35
|
try {
|
|
36
|
+
const pagePostType =
|
|
37
|
+
await resolveSelect( coreStore ).getPostType( 'page' );
|
|
34
38
|
const newPage = await saveEntityRecord(
|
|
35
39
|
'postType',
|
|
36
40
|
'page',
|
|
@@ -38,6 +42,15 @@ export default function AddNewPageModal( { onSave, onClose } ) {
|
|
|
38
42
|
status: 'draft',
|
|
39
43
|
title,
|
|
40
44
|
slug: title || __( 'No title' ),
|
|
45
|
+
content:
|
|
46
|
+
!! pagePostType.template && pagePostType.template.length
|
|
47
|
+
? serialize(
|
|
48
|
+
synchronizeBlocksWithTemplate(
|
|
49
|
+
[],
|
|
50
|
+
pagePostType.template
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
: undefined,
|
|
41
54
|
},
|
|
42
55
|
{ throwOnError: true }
|
|
43
56
|
);
|
|
@@ -69,7 +82,12 @@ export default function AddNewPageModal( { onSave, onClose } ) {
|
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
return (
|
|
72
|
-
<Modal
|
|
85
|
+
<Modal
|
|
86
|
+
title={ __( 'Draft a new page' ) }
|
|
87
|
+
onRequestClose={ onClose }
|
|
88
|
+
focusOnMount="firstContentElement"
|
|
89
|
+
size="small"
|
|
90
|
+
>
|
|
73
91
|
<form onSubmit={ createPage }>
|
|
74
92
|
<VStack spacing={ 3 }>
|
|
75
93
|
<TextControl
|
|
@@ -36,21 +36,30 @@ export default function AddNewPattern() {
|
|
|
36
36
|
const [ showPatternModal, setShowPatternModal ] = useState( false );
|
|
37
37
|
const [ showTemplatePartModal, setShowTemplatePartModal ] =
|
|
38
38
|
useState( false );
|
|
39
|
+
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
39
40
|
const { createPatternFromFile } = unlock( useDispatch( patternsStore ) );
|
|
40
41
|
const { createSuccessNotice, createErrorNotice } =
|
|
41
42
|
useDispatch( noticesStore );
|
|
42
43
|
const patternUploadInputRef = useRef();
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
const {
|
|
45
|
+
isBlockBasedTheme,
|
|
46
|
+
addNewPatternLabel,
|
|
47
|
+
addNewTemplatePartLabel,
|
|
48
|
+
canCreatePattern,
|
|
49
|
+
canCreateTemplatePart,
|
|
50
|
+
} = useSelect( ( select ) => {
|
|
51
|
+
const { getCurrentTheme, getPostType, canUser } = select( coreStore );
|
|
52
|
+
return {
|
|
53
|
+
isBlockBasedTheme: getCurrentTheme()?.is_block_theme,
|
|
54
|
+
addNewPatternLabel: getPostType( PATTERN_TYPES.user )?.labels
|
|
55
|
+
?.add_new_item,
|
|
56
|
+
addNewTemplatePartLabel: getPostType( TEMPLATE_PART_POST_TYPE )
|
|
57
|
+
?.labels?.add_new_item,
|
|
58
|
+
// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.
|
|
59
|
+
canCreatePattern: canUser( 'create', 'blocks' ),
|
|
60
|
+
canCreateTemplatePart: canUser( 'create', 'template-parts' ),
|
|
61
|
+
};
|
|
62
|
+
}, [] );
|
|
54
63
|
|
|
55
64
|
function handleCreatePattern( { pattern } ) {
|
|
56
65
|
setShowPatternModal( false );
|
|
@@ -78,15 +87,16 @@ export default function AddNewPattern() {
|
|
|
78
87
|
setShowTemplatePartModal( false );
|
|
79
88
|
}
|
|
80
89
|
|
|
81
|
-
const controls = [
|
|
82
|
-
|
|
90
|
+
const controls = [];
|
|
91
|
+
if ( canCreatePattern ) {
|
|
92
|
+
controls.push( {
|
|
83
93
|
icon: symbol,
|
|
84
94
|
onClick: () => setShowPatternModal( true ),
|
|
85
95
|
title: addNewPatternLabel,
|
|
86
|
-
}
|
|
87
|
-
|
|
96
|
+
} );
|
|
97
|
+
}
|
|
88
98
|
|
|
89
|
-
if ( isBlockBasedTheme ) {
|
|
99
|
+
if ( isBlockBasedTheme && canCreateTemplatePart ) {
|
|
90
100
|
controls.push( {
|
|
91
101
|
icon: symbolFilled,
|
|
92
102
|
onClick: () => setShowTemplatePartModal( true ),
|
|
@@ -94,15 +104,20 @@ export default function AddNewPattern() {
|
|
|
94
104
|
} );
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
if ( canCreatePattern ) {
|
|
108
|
+
controls.push( {
|
|
109
|
+
icon: upload,
|
|
110
|
+
onClick: () => {
|
|
111
|
+
patternUploadInputRef.current.click();
|
|
112
|
+
},
|
|
113
|
+
title: __( 'Import pattern from JSON' ),
|
|
114
|
+
} );
|
|
115
|
+
}
|
|
104
116
|
|
|
105
117
|
const { categoryMap, findOrCreateTerm } = useAddPatternCategory();
|
|
118
|
+
if ( controls.length === 0 ) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
106
121
|
return (
|
|
107
122
|
<>
|
|
108
123
|
{ addNewPatternLabel && (
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
/* stylelint-disable -- Disable reason: View Transitions not supported properly by stylelint. */
|
|
2
|
-
::view-transition-old(frame),
|
|
3
|
-
::view-transition-new(frame) {
|
|
4
|
-
animation-duration: 0;
|
|
5
|
-
}
|
|
6
|
-
/* stylelint-enable */
|
|
7
|
-
|
|
8
1
|
.edit-site-visual-editor__editor-canvas {
|
|
9
|
-
/* stylelint-disable -- Disable reason: View Transitions not supported properly by stylelint. */
|
|
10
|
-
view-transition-name: frame;
|
|
11
|
-
/* stylelint-enable */
|
|
12
|
-
|
|
13
2
|
&.is-focused {
|
|
14
3
|
outline: calc(2 * var(--wp-admin-border-width-focus)) solid var(--wp-admin-theme-color);
|
|
15
4
|
outline-offset: calc(-2 * var(--wp-admin-border-width-focus));
|
|
@@ -36,7 +36,7 @@ import PluginTemplateSettingPanel from '../plugin-template-setting-panel';
|
|
|
36
36
|
import GlobalStylesSidebar from '../global-styles-sidebar';
|
|
37
37
|
import { isPreviewingTheme } from '../../utils/is-previewing-theme';
|
|
38
38
|
import {
|
|
39
|
-
|
|
39
|
+
getEditorCanvasContainerTitleAndIcon,
|
|
40
40
|
useHasEditorCanvasContainer,
|
|
41
41
|
} from '../editor-canvas-container';
|
|
42
42
|
import SaveButton from '../save-button';
|
|
@@ -63,6 +63,7 @@ export default function EditSiteEditor( { isLoading } ) {
|
|
|
63
63
|
currentPostIsTrashed,
|
|
64
64
|
} = useSelect( ( select ) => {
|
|
65
65
|
const {
|
|
66
|
+
getEditorCanvasContainerView,
|
|
66
67
|
getEditedPostContext,
|
|
67
68
|
getCanvasMode,
|
|
68
69
|
isPage,
|
|
@@ -84,9 +85,7 @@ export default function EditSiteEditor( { isLoading } ) {
|
|
|
84
85
|
isEditingPage: isPage(),
|
|
85
86
|
supportsGlobalStyles: getCurrentTheme()?.is_block_theme,
|
|
86
87
|
showIconLabels: get( 'core', 'showIconLabels' ),
|
|
87
|
-
editorCanvasView:
|
|
88
|
-
select( editSiteStore )
|
|
89
|
-
).getEditorCanvasContainerView(),
|
|
88
|
+
editorCanvasView: getEditorCanvasContainerView(),
|
|
90
89
|
currentPostIsTrashed:
|
|
91
90
|
select( editorStore ).getCurrentPostAttribute( 'status' ) ===
|
|
92
91
|
'trash',
|
|
@@ -110,14 +109,12 @@ export default function EditSiteEditor( { isLoading } ) {
|
|
|
110
109
|
{
|
|
111
110
|
// Forming a "block formatting context" to prevent margin collapsing.
|
|
112
111
|
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
113
|
-
|
|
114
|
-
css: `body{${
|
|
112
|
+
css:
|
|
115
113
|
canvasMode === 'view'
|
|
116
|
-
? `min-height: 100vh; ${
|
|
114
|
+
? `body{min-height: 100vh; ${
|
|
117
115
|
currentPostIsTrashed ? '' : 'cursor: pointer;'
|
|
118
|
-
}`
|
|
119
|
-
:
|
|
120
|
-
}}}`,
|
|
116
|
+
}}`
|
|
117
|
+
: undefined,
|
|
121
118
|
},
|
|
122
119
|
],
|
|
123
120
|
[ settings.styles, canvasMode, currentPostIsTrashed ]
|
|
@@ -173,6 +170,10 @@ export default function EditSiteEditor( { isLoading } ) {
|
|
|
173
170
|
[ history, createSuccessNotice ]
|
|
174
171
|
);
|
|
175
172
|
|
|
173
|
+
// Replace the title and icon displayed in the DocumentBar when there's an overlay visible.
|
|
174
|
+
const { title, icon } =
|
|
175
|
+
getEditorCanvasContainerTitleAndIcon( editorCanvasView );
|
|
176
|
+
|
|
176
177
|
const isReady = ! isLoading;
|
|
177
178
|
|
|
178
179
|
return (
|
|
@@ -199,11 +200,8 @@ export default function EditSiteEditor( { isLoading } ) {
|
|
|
199
200
|
_isPreviewingTheme && <SaveButton size="compact" />
|
|
200
201
|
}
|
|
201
202
|
forceDisableBlockTools={ ! hasDefaultEditorCanvasView }
|
|
202
|
-
title={
|
|
203
|
-
|
|
204
|
-
? getEditorCanvasContainerTitle( editorCanvasView )
|
|
205
|
-
: undefined
|
|
206
|
-
}
|
|
203
|
+
title={ title }
|
|
204
|
+
icon={ icon }
|
|
207
205
|
iframeProps={ iframeProps }
|
|
208
206
|
onActionPerformed={ onActionPerformed }
|
|
209
207
|
extraSidebarPanels={
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
|
-
import { closeSmall } from '@wordpress/icons';
|
|
12
|
+
import { backup, closeSmall, seen } from '@wordpress/icons';
|
|
13
13
|
import { useFocusOnMount, useFocusReturn } from '@wordpress/compose';
|
|
14
14
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
15
15
|
import {
|
|
@@ -30,17 +30,26 @@ const { EditorContentSlotFill, ResizableEditor } = unlock( editorPrivateApis );
|
|
|
30
30
|
*
|
|
31
31
|
* @param {string} view Editor canvas container view.
|
|
32
32
|
*
|
|
33
|
-
* @return {
|
|
33
|
+
* @return {Object} Translated string for the view title and associated icon, both defaulting to ''.
|
|
34
34
|
*/
|
|
35
|
-
function
|
|
35
|
+
function getEditorCanvasContainerTitleAndIcon( view ) {
|
|
36
36
|
switch ( view ) {
|
|
37
37
|
case 'style-book':
|
|
38
|
-
return
|
|
38
|
+
return {
|
|
39
|
+
title: __( 'Style Book' ),
|
|
40
|
+
icon: seen,
|
|
41
|
+
};
|
|
39
42
|
case 'global-styles-revisions':
|
|
40
43
|
case 'global-styles-revisions:style-book':
|
|
41
|
-
return
|
|
44
|
+
return {
|
|
45
|
+
title: __( 'Style Revisions' ),
|
|
46
|
+
icon: backup,
|
|
47
|
+
};
|
|
42
48
|
default:
|
|
43
|
-
return
|
|
49
|
+
return {
|
|
50
|
+
title: '',
|
|
51
|
+
icon: '',
|
|
52
|
+
};
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
|
|
@@ -109,7 +118,9 @@ function EditorCanvasContainer( {
|
|
|
109
118
|
return null;
|
|
110
119
|
}
|
|
111
120
|
|
|
112
|
-
const title =
|
|
121
|
+
const { title } = getEditorCanvasContainerTitleAndIcon(
|
|
122
|
+
editorCanvasContainerView
|
|
123
|
+
);
|
|
113
124
|
const shouldShowCloseButton = onClose || closeButtonLabel;
|
|
114
125
|
|
|
115
126
|
return (
|
|
@@ -138,10 +149,11 @@ function EditorCanvasContainer( {
|
|
|
138
149
|
</EditorContentSlotFill.Fill>
|
|
139
150
|
);
|
|
140
151
|
}
|
|
152
|
+
|
|
141
153
|
function useHasEditorCanvasContainer() {
|
|
142
154
|
const fills = useSlotFills( EditorContentSlotFill.privateKey );
|
|
143
155
|
return !! fills?.length;
|
|
144
156
|
}
|
|
145
157
|
|
|
146
158
|
export default EditorCanvasContainer;
|
|
147
|
-
export { useHasEditorCanvasContainer,
|
|
159
|
+
export { useHasEditorCanvasContainer, getEditorCanvasContainerTitleAndIcon };
|
|
@@ -5,11 +5,9 @@ import { __ } from '@wordpress/i18n';
|
|
|
5
5
|
import {
|
|
6
6
|
__experimentalItemGroup as ItemGroup,
|
|
7
7
|
__experimentalVStack as VStack,
|
|
8
|
-
__experimentalHStack as HStack,
|
|
9
8
|
Button,
|
|
10
9
|
} from '@wordpress/components';
|
|
11
10
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
12
|
-
import { settings } from '@wordpress/icons';
|
|
13
11
|
import { useContext } from '@wordpress/element';
|
|
14
12
|
|
|
15
13
|
/**
|
|
@@ -51,30 +49,41 @@ function FontFamilies() {
|
|
|
51
49
|
) }
|
|
52
50
|
|
|
53
51
|
<VStack spacing={ 2 }>
|
|
54
|
-
<
|
|
55
|
-
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
|
|
56
|
-
<Button
|
|
57
|
-
onClick={ () => setModalTabOpen( 'installed-fonts' ) }
|
|
58
|
-
label={ __( 'Manage fonts' ) }
|
|
59
|
-
icon={ settings }
|
|
60
|
-
size="small"
|
|
61
|
-
/>
|
|
62
|
-
</HStack>
|
|
52
|
+
<Subtitle level={ 3 }>{ __( 'Fonts' ) }</Subtitle>
|
|
63
53
|
{ hasFonts ? (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
<>
|
|
55
|
+
<ItemGroup isBordered isSeparated>
|
|
56
|
+
{ customFonts.map( ( font ) => (
|
|
57
|
+
<FontFamilyItem
|
|
58
|
+
key={ font.slug }
|
|
59
|
+
font={ font }
|
|
60
|
+
/>
|
|
61
|
+
) ) }
|
|
62
|
+
{ themeFonts.map( ( font ) => (
|
|
63
|
+
<FontFamilyItem
|
|
64
|
+
key={ font.slug }
|
|
65
|
+
font={ font }
|
|
66
|
+
/>
|
|
67
|
+
) ) }
|
|
68
|
+
</ItemGroup>
|
|
69
|
+
<Button
|
|
70
|
+
className="edit-site-global-styles-font-families__manage-fonts"
|
|
71
|
+
variant="secondary"
|
|
72
|
+
__next40pxDefaultSize
|
|
73
|
+
onClick={ () =>
|
|
74
|
+
setModalTabOpen( 'installed-fonts' )
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
{ __( 'Manage fonts' ) }
|
|
78
|
+
</Button>
|
|
79
|
+
</>
|
|
72
80
|
) : (
|
|
73
81
|
<>
|
|
74
82
|
{ __( 'No fonts installed.' ) }
|
|
75
83
|
<Button
|
|
76
84
|
className="edit-site-global-styles-font-families__add-fonts"
|
|
77
85
|
variant="secondary"
|
|
86
|
+
__next40pxDefaultSize
|
|
78
87
|
onClick={ () => setModalTabOpen( 'upload-fonts' ) }
|
|
79
88
|
>
|
|
80
89
|
{ __( 'Add fonts' ) }
|
|
@@ -451,13 +451,13 @@ function FontLibraryProvider( { children } ) {
|
|
|
451
451
|
);
|
|
452
452
|
|
|
453
453
|
if ( isFaceActivated ) {
|
|
454
|
+
unloadFontFaceInBrowser( face, 'all' );
|
|
455
|
+
} else {
|
|
454
456
|
loadFontFaceInBrowser(
|
|
455
457
|
face,
|
|
456
458
|
getDisplaySrcFromFontFace( face?.src ),
|
|
457
459
|
'all'
|
|
458
460
|
);
|
|
459
|
-
} else {
|
|
460
|
-
unloadFontFaceInBrowser( face, 'all' );
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
|
|
@@ -6,6 +6,7 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
+
import { Tooltip } from '@wordpress/components';
|
|
9
10
|
import { useMemo, useContext, useState } from '@wordpress/element';
|
|
10
11
|
import { ENTER } from '@wordpress/keycodes';
|
|
11
12
|
import { __, sprintf } from '@wordpress/i18n';
|
|
@@ -23,7 +24,13 @@ const { GlobalStylesContext, areGlobalStyleConfigsEqual } = unlock(
|
|
|
23
24
|
blockEditorPrivateApis
|
|
24
25
|
);
|
|
25
26
|
|
|
26
|
-
export default function Variation( {
|
|
27
|
+
export default function Variation( {
|
|
28
|
+
variation,
|
|
29
|
+
children,
|
|
30
|
+
isPill,
|
|
31
|
+
property,
|
|
32
|
+
showTooltip,
|
|
33
|
+
} ) {
|
|
27
34
|
const [ isFocused, setIsFocused ] = useState( false );
|
|
28
35
|
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
|
|
29
36
|
|
|
@@ -64,30 +71,38 @@ export default function Variation( { variation, children, isPill, property } ) {
|
|
|
64
71
|
);
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
<
|
|
74
|
+
const content = (
|
|
75
|
+
<div
|
|
76
|
+
className={ clsx( 'edit-site-global-styles-variations_item', {
|
|
77
|
+
'is-active': isActive,
|
|
78
|
+
} ) }
|
|
79
|
+
role="button"
|
|
80
|
+
onClick={ selectVariation }
|
|
81
|
+
onKeyDown={ selectOnEnter }
|
|
82
|
+
tabIndex="0"
|
|
83
|
+
aria-label={ label }
|
|
84
|
+
aria-current={ isActive }
|
|
85
|
+
onFocus={ () => setIsFocused( true ) }
|
|
86
|
+
onBlur={ () => setIsFocused( false ) }
|
|
87
|
+
>
|
|
69
88
|
<div
|
|
70
|
-
className={ clsx(
|
|
71
|
-
'
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onClick={ selectVariation }
|
|
75
|
-
onKeyDown={ selectOnEnter }
|
|
76
|
-
tabIndex="0"
|
|
77
|
-
aria-label={ label }
|
|
78
|
-
aria-current={ isActive }
|
|
79
|
-
onFocus={ () => setIsFocused( true ) }
|
|
80
|
-
onBlur={ () => setIsFocused( false ) }
|
|
89
|
+
className={ clsx(
|
|
90
|
+
'edit-site-global-styles-variations_item-preview',
|
|
91
|
+
{ 'is-pill': isPill }
|
|
92
|
+
) }
|
|
81
93
|
>
|
|
82
|
-
|
|
83
|
-
className={ clsx(
|
|
84
|
-
'edit-site-global-styles-variations_item-preview',
|
|
85
|
-
{ 'is-pill': isPill }
|
|
86
|
-
) }
|
|
87
|
-
>
|
|
88
|
-
{ children( isFocused ) }
|
|
89
|
-
</div>
|
|
94
|
+
{ children( isFocused ) }
|
|
90
95
|
</div>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<GlobalStylesContext.Provider value={ context }>
|
|
101
|
+
{ showTooltip ? (
|
|
102
|
+
<Tooltip text={ variation?.title }>{ content }</Tooltip>
|
|
103
|
+
) : (
|
|
104
|
+
content
|
|
105
|
+
) }
|
|
91
106
|
</GlobalStylesContext.Provider>
|
|
92
107
|
);
|
|
93
108
|
}
|