@wordpress/editor 13.34.0 → 13.35.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 +10 -4
- package/build/bindings/pattern-overrides.js +70 -1
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +126 -0
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -0
- package/build/components/block-settings-menu/content-only-settings-menu.native.js +11 -0
- package/build/components/block-settings-menu/content-only-settings-menu.native.js.map +1 -0
- package/build/components/collapsible-block-toolbar/index.js +2 -2
- package/build/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build/components/document-bar/index.js +2 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/item.js +2 -2
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/document-tools/index.js +15 -18
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/index.js +19 -8
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/global-styles-provider/index.js +130 -0
- package/build/components/global-styles-provider/index.js.map +1 -0
- package/build/components/header/index.js +147 -0
- package/build/components/header/index.js.map +1 -0
- package/build/components/inserter-sidebar/index.js +56 -31
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/post-actions/actions.js +122 -64
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +7 -14
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-card-panel/index.js +5 -29
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-comments/index.js +28 -8
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-discussion/panel.js +103 -21
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/panel.js +2 -2
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-format/panel.js +27 -0
- package/build/components/post-format/panel.js.map +1 -0
- package/build/components/post-panel-row/index.js +2 -2
- package/build/components/post-panel-row/index.js.map +1 -1
- package/build/components/post-panel-section/index.js +28 -0
- package/build/components/post-panel-section/index.js.map +1 -0
- package/build/components/post-pingbacks/index.js +5 -2
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +2 -2
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-slug/panel.js +27 -0
- package/build/components/post-slug/panel.js.map +1 -0
- package/build/components/post-status/index.js +4 -4
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-sticky/panel.js +21 -0
- package/build/components/post-sticky/panel.js.map +1 -0
- package/build/components/post-title/index.js +2 -2
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/post-title-raw.js +2 -2
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-transform-panel/hooks.js +90 -0
- package/build/components/post-transform-panel/hooks.js.map +1 -0
- package/build/components/post-transform-panel/index.js +101 -0
- package/build/components/post-transform-panel/index.js.map +1 -0
- package/build/components/post-trash/panel.js +18 -0
- package/build/components/post-trash/panel.js.map +1 -0
- package/build/components/post-type-support-check/index.js +1 -1
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +3 -3
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +21 -3
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/sidebar/constants.js +11 -0
- package/build/components/sidebar/constants.js.map +1 -0
- package/build/components/sidebar/header.js +53 -0
- package/build/components/sidebar/header.js.map +1 -0
- package/build/components/sidebar/index.js +157 -0
- package/build/components/sidebar/index.js.map +1 -0
- package/build/components/sidebar/post-summary.js +84 -0
- package/build/components/sidebar/post-summary.js.map +1 -0
- package/build/components/start-page-options/index.js +5 -7
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/start-template-options/index.js +192 -0
- package/build/components/start-template-options/index.js.map +1 -0
- package/build/components/template-content-panel/index.js +38 -0
- package/build/components/template-content-panel/index.js.map +1 -0
- package/build/hooks/pattern-overrides.js +10 -5
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/private-apis.js +7 -12
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +72 -0
- package/build/private-apis.native.js.map +1 -0
- package/build/store/private-selectors.js +6 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +15 -0
- package/build/store/reducer.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +69 -1
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +119 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.native.js +5 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.native.js.map +1 -0
- package/build-module/components/collapsible-block-toolbar/index.js +2 -2
- package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +2 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +2 -2
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/document-tools/index.js +16 -19
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +19 -8
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +120 -0
- package/build-module/components/global-styles-provider/index.js.map +1 -0
- package/build-module/components/header/index.js +139 -0
- package/build-module/components/header/index.js.map +1 -0
- package/build-module/components/inserter-sidebar/index.js +59 -34
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +125 -66
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +7 -14
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +7 -30
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-comments/index.js +30 -10
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-discussion/panel.js +105 -23
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +2 -2
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-format/panel.js +18 -0
- package/build-module/components/post-format/panel.js.map +1 -0
- package/build-module/components/post-panel-row/index.js +2 -2
- package/build-module/components/post-panel-row/index.js.map +1 -1
- package/build-module/components/post-panel-section/index.js +20 -0
- package/build-module/components/post-panel-section/index.js.map +1 -0
- package/build-module/components/post-pingbacks/index.js +6 -3
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +2 -2
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-slug/panel.js +18 -0
- package/build-module/components/post-slug/panel.js.map +1 -0
- package/build-module/components/post-status/index.js +4 -4
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-sticky/panel.js +12 -0
- package/build-module/components/post-sticky/panel.js.map +1 -0
- package/build-module/components/post-title/index.js +2 -2
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js +2 -2
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-transform-panel/hooks.js +83 -0
- package/build-module/components/post-transform-panel/hooks.js.map +1 -0
- package/build-module/components/post-transform-panel/index.js +94 -0
- package/build-module/components/post-transform-panel/index.js.map +1 -0
- package/build-module/components/post-trash/panel.js +10 -0
- package/build-module/components/post-trash/panel.js.map +1 -0
- package/build-module/components/post-type-support-check/index.js +1 -1
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +3 -3
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +21 -3
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/sidebar/constants.js +5 -0
- package/build-module/components/sidebar/constants.js.map +1 -0
- package/build-module/components/sidebar/header.js +46 -0
- package/build-module/components/sidebar/header.js.map +1 -0
- package/build-module/components/sidebar/index.js +149 -0
- package/build-module/components/sidebar/index.js.map +1 -0
- package/build-module/components/sidebar/post-summary.js +77 -0
- package/build-module/components/sidebar/post-summary.js.map +1 -0
- package/build-module/components/start-page-options/index.js +5 -7
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +185 -0
- package/build-module/components/start-template-options/index.js.map +1 -0
- package/build-module/components/template-content-panel/index.js +31 -0
- package/build-module/components/template-content-panel/index.js.map +1 -0
- package/build-module/hooks/pattern-overrides.js +10 -5
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/private-apis.js +7 -12
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +62 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/store/private-selectors.js +3 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +14 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +328 -18
- package/build-style/style.css +328 -18
- package/package.json +38 -36
- package/src/bindings/pattern-overrides.js +83 -1
- package/src/components/autocompleters/style.scss +1 -2
- package/src/components/block-settings-menu/content-only-settings-menu.js +175 -0
- package/src/components/block-settings-menu/content-only-settings-menu.native.js +4 -0
- package/src/components/block-settings-menu/style.scss +4 -0
- package/src/components/collapsible-block-toolbar/index.js +2 -2
- package/src/components/document-bar/index.js +2 -2
- package/src/components/document-outline/item.js +2 -2
- package/src/components/document-tools/index.js +19 -21
- package/src/components/editor-canvas/index.js +18 -6
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/src/components/global-styles-provider/index.js +162 -0
- package/src/components/header/index.js +154 -0
- package/src/components/header/style.scss +231 -0
- package/src/components/inserter-sidebar/index.js +52 -29
- package/src/components/inserter-sidebar/style.scss +10 -3
- package/src/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/src/components/list-view-sidebar/style.scss +1 -0
- package/src/components/page-attributes/test/order.js +5 -1
- package/src/components/post-actions/actions.js +256 -150
- package/src/components/post-actions/index.js +5 -38
- package/src/components/post-card-panel/index.js +39 -85
- package/src/components/post-comments/index.js +47 -9
- package/src/components/post-discussion/panel.js +108 -31
- package/src/components/post-discussion/style.scss +26 -0
- package/src/components/post-excerpt/panel.js +2 -2
- package/src/components/post-format/panel.js +22 -0
- package/src/components/post-format/style.scss +6 -0
- package/src/components/post-last-revision/test/check.js +5 -1
- package/src/components/post-panel-row/index.js +2 -2
- package/src/components/post-panel-section/index.js +19 -0
- package/src/components/post-panel-section/style.scss +3 -0
- package/src/components/post-pingbacks/index.js +11 -2
- package/src/components/post-publish-panel/style.scss +5 -0
- package/src/components/post-saved-state/index.js +2 -2
- package/src/components/post-slug/panel.js +22 -0
- package/src/components/post-slug/style.scss +5 -0
- package/src/components/post-slug/test/index.js +5 -1
- package/src/components/post-status/index.js +4 -4
- package/src/components/post-sticky/panel.js +18 -0
- package/src/components/post-title/index.js +2 -2
- package/src/components/post-title/post-title-raw.js +2 -2
- package/src/components/post-transform-panel/hooks.js +114 -0
- package/src/components/post-transform-panel/index.js +99 -0
- package/src/components/post-trash/panel.js +13 -0
- package/src/components/post-type-support-check/index.js +1 -1
- package/src/components/post-type-support-check/test/index.js +2 -2
- package/src/components/preferences-modal/index.js +3 -3
- package/src/components/provider/index.js +4 -0
- package/src/components/provider/use-block-editor-settings.js +19 -4
- package/src/components/sidebar/constants.js +4 -0
- package/src/components/sidebar/header.js +49 -0
- package/src/components/sidebar/index.js +200 -0
- package/src/components/sidebar/post-summary.js +104 -0
- package/src/components/sidebar/style.scss +18 -0
- package/src/components/start-page-options/index.js +6 -4
- package/src/components/start-template-options/index.js +219 -0
- package/src/components/start-template-options/style.scss +55 -0
- package/src/components/template-areas/style.scss +0 -1
- package/src/components/template-content-panel/index.js +36 -0
- package/src/hooks/pattern-overrides.js +12 -6
- package/src/private-apis.js +10 -12
- package/src/private-apis.native.js +61 -0
- package/src/store/private-selectors.js +3 -0
- package/src/store/reducer.js +12 -0
- package/src/style.scss +7 -0
- package/src/components/post-slug/test/check.js +0 -17
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
BlockSettingsMenuControls,
|
|
6
|
+
__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,
|
|
7
|
+
store as blockEditorStore,
|
|
8
|
+
useBlockDisplayInformation,
|
|
9
|
+
} from '@wordpress/block-editor';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
import { __experimentalText as Text, MenuItem } from '@wordpress/components';
|
|
12
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
+
import { __ } from '@wordpress/i18n';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { store as editorStore } from '../../store';
|
|
19
|
+
import { unlock } from '../../lock-unlock';
|
|
20
|
+
|
|
21
|
+
function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
|
|
22
|
+
const { entity, onNavigateToEntityRecord } = useSelect(
|
|
23
|
+
( select ) => {
|
|
24
|
+
const {
|
|
25
|
+
getBlockEditingMode,
|
|
26
|
+
getBlockParentsByBlockName,
|
|
27
|
+
getSettings,
|
|
28
|
+
getBlockAttributes,
|
|
29
|
+
} = select( blockEditorStore );
|
|
30
|
+
const contentOnly =
|
|
31
|
+
getBlockEditingMode( clientId ) === 'contentOnly';
|
|
32
|
+
if ( ! contentOnly ) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
const patternParent = getBlockParentsByBlockName(
|
|
36
|
+
clientId,
|
|
37
|
+
'core/block',
|
|
38
|
+
true
|
|
39
|
+
)[ 0 ];
|
|
40
|
+
|
|
41
|
+
let record;
|
|
42
|
+
if ( patternParent ) {
|
|
43
|
+
record = select( coreStore ).getEntityRecord(
|
|
44
|
+
'postType',
|
|
45
|
+
'wp_block',
|
|
46
|
+
getBlockAttributes( patternParent ).ref
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
const { getCurrentPostType, getCurrentTemplateId } =
|
|
50
|
+
select( editorStore );
|
|
51
|
+
const currentPostType = getCurrentPostType();
|
|
52
|
+
const templateId = getCurrentTemplateId();
|
|
53
|
+
if ( currentPostType === 'page' && templateId ) {
|
|
54
|
+
record = select( coreStore ).getEntityRecord(
|
|
55
|
+
'postType',
|
|
56
|
+
'wp_template',
|
|
57
|
+
templateId
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
entity: record,
|
|
63
|
+
onNavigateToEntityRecord:
|
|
64
|
+
getSettings().onNavigateToEntityRecord,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
[ clientId ]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if ( ! entity ) {
|
|
71
|
+
return (
|
|
72
|
+
<TemplateLockContentOnlyMenuItems
|
|
73
|
+
clientId={ clientId }
|
|
74
|
+
onClose={ onClose }
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const isPattern = entity.type === 'wp_block';
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
<BlockSettingsMenuFirstItem>
|
|
84
|
+
<MenuItem
|
|
85
|
+
onClick={ () => {
|
|
86
|
+
onNavigateToEntityRecord( {
|
|
87
|
+
postId: entity.id,
|
|
88
|
+
postType: entity.type,
|
|
89
|
+
} );
|
|
90
|
+
} }
|
|
91
|
+
>
|
|
92
|
+
{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }
|
|
93
|
+
</MenuItem>
|
|
94
|
+
</BlockSettingsMenuFirstItem>
|
|
95
|
+
<Text
|
|
96
|
+
variant="muted"
|
|
97
|
+
as="p"
|
|
98
|
+
className="editor-content-only-settings-menu__description"
|
|
99
|
+
>
|
|
100
|
+
{ isPattern
|
|
101
|
+
? __(
|
|
102
|
+
'Edit the pattern to move, delete, or make further changes to this block.'
|
|
103
|
+
)
|
|
104
|
+
: __(
|
|
105
|
+
'Edit the template to move, delete, or make further changes to this block.'
|
|
106
|
+
) }
|
|
107
|
+
</Text>
|
|
108
|
+
</>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {
|
|
113
|
+
const { contentLockingParent } = useSelect(
|
|
114
|
+
( select ) => {
|
|
115
|
+
const { getContentLockingParent } = unlock(
|
|
116
|
+
select( blockEditorStore )
|
|
117
|
+
);
|
|
118
|
+
return {
|
|
119
|
+
contentLockingParent: getContentLockingParent( clientId ),
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
[ clientId ]
|
|
123
|
+
);
|
|
124
|
+
const blockDisplayInformation =
|
|
125
|
+
useBlockDisplayInformation( contentLockingParent );
|
|
126
|
+
// Disable reason: We're using a hook here so it has to be on top-level.
|
|
127
|
+
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
|
|
128
|
+
const { modifyContentLockBlock, selectBlock } = unlock(
|
|
129
|
+
useDispatch( blockEditorStore )
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
if ( ! blockDisplayInformation?.title ) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<>
|
|
138
|
+
<BlockSettingsMenuFirstItem>
|
|
139
|
+
<MenuItem
|
|
140
|
+
onClick={ () => {
|
|
141
|
+
selectBlock( contentLockingParent );
|
|
142
|
+
modifyContentLockBlock( contentLockingParent );
|
|
143
|
+
onClose();
|
|
144
|
+
} }
|
|
145
|
+
>
|
|
146
|
+
{ __( 'Unlock' ) }
|
|
147
|
+
</MenuItem>
|
|
148
|
+
</BlockSettingsMenuFirstItem>
|
|
149
|
+
<Text
|
|
150
|
+
variant="muted"
|
|
151
|
+
as="p"
|
|
152
|
+
className="editor-content-only-settings-menu__description"
|
|
153
|
+
>
|
|
154
|
+
{ __(
|
|
155
|
+
'Temporarily unlock the parent block to edit, delete or make further changes to this block.'
|
|
156
|
+
) }
|
|
157
|
+
</Text>
|
|
158
|
+
</>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default function ContentOnlySettingsMenu() {
|
|
163
|
+
return (
|
|
164
|
+
<BlockSettingsMenuControls>
|
|
165
|
+
{ ( { selectedClientIds, onClose } ) =>
|
|
166
|
+
selectedClientIds.length === 1 && (
|
|
167
|
+
<ContentOnlySettingsMenuItems
|
|
168
|
+
clientId={ selectedClientIds[ 0 ] }
|
|
169
|
+
onClose={ onClose }
|
|
170
|
+
/>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
</BlockSettingsMenuControls>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -49,7 +49,7 @@ function CollapsableBlockToolbar( { isCollapsed, onToggle } ) {
|
|
|
49
49
|
return (
|
|
50
50
|
<>
|
|
51
51
|
<div
|
|
52
|
-
className={
|
|
52
|
+
className={ clsx( 'editor-collapsible-block-toolbar', {
|
|
53
53
|
'is-collapsed': isCollapsed || ! hasBlockSelection,
|
|
54
54
|
} ) }
|
|
55
55
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -111,7 +111,7 @@ export default function DocumentBar() {
|
|
|
111
111
|
|
|
112
112
|
return (
|
|
113
113
|
<div
|
|
114
|
-
className={
|
|
114
|
+
className={ clsx( 'editor-document-bar', {
|
|
115
115
|
'has-back-button': hasBackButton,
|
|
116
116
|
'is-global': isGlobalEntity,
|
|
117
117
|
} ) }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
const TableOfContentsItem = ( {
|
|
7
7
|
children,
|
|
@@ -11,7 +11,7 @@ const TableOfContentsItem = ( {
|
|
|
11
11
|
onSelect,
|
|
12
12
|
} ) => (
|
|
13
13
|
<li
|
|
14
|
-
className={
|
|
14
|
+
className={ clsx(
|
|
15
15
|
'document-outline__item',
|
|
16
16
|
`is-${ level.toLowerCase() }`,
|
|
17
17
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '@wordpress/block-editor';
|
|
17
17
|
import { Button, ToolbarItem } from '@wordpress/components';
|
|
18
18
|
import { listView, plus } from '@wordpress/icons';
|
|
19
|
-
import {
|
|
19
|
+
import { useCallback } from '@wordpress/element';
|
|
20
20
|
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
21
21
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
22
22
|
|
|
@@ -35,11 +35,9 @@ const preventDefault = ( event ) => {
|
|
|
35
35
|
function DocumentTools( {
|
|
36
36
|
className,
|
|
37
37
|
disableBlockTools = false,
|
|
38
|
-
children,
|
|
39
38
|
// This is a temporary prop until the list view is fully unified between post and site editors.
|
|
40
39
|
listViewLabel = __( 'Document Overview' ),
|
|
41
40
|
} ) {
|
|
42
|
-
const inserterButton = useRef();
|
|
43
41
|
const { setIsInserterOpened, setIsListViewOpened } =
|
|
44
42
|
useDispatch( editorStore );
|
|
45
43
|
const {
|
|
@@ -47,16 +45,21 @@ function DocumentTools( {
|
|
|
47
45
|
isInserterOpened,
|
|
48
46
|
isListViewOpen,
|
|
49
47
|
listViewShortcut,
|
|
48
|
+
inserterSidebarToggleRef,
|
|
50
49
|
listViewToggleRef,
|
|
51
50
|
hasFixedToolbar,
|
|
52
51
|
showIconLabels,
|
|
53
52
|
} = useSelect( ( select ) => {
|
|
54
53
|
const { getSettings } = select( blockEditorStore );
|
|
55
54
|
const { get } = select( preferencesStore );
|
|
56
|
-
const {
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const {
|
|
56
|
+
isListViewOpened,
|
|
57
|
+
getEditorMode,
|
|
58
|
+
getInserterSidebarToggleRef,
|
|
59
|
+
getListViewToggleRef,
|
|
60
|
+
} = unlock( select( editorStore ) );
|
|
59
61
|
const { getShortcutRepresentation } = select( keyboardShortcutsStore );
|
|
62
|
+
const { __unstableGetEditorMode } = select( blockEditorStore );
|
|
60
63
|
|
|
61
64
|
return {
|
|
62
65
|
isInserterOpened: select( editorStore ).isInserterOpened(),
|
|
@@ -64,10 +67,13 @@ function DocumentTools( {
|
|
|
64
67
|
listViewShortcut: getShortcutRepresentation(
|
|
65
68
|
'core/editor/toggle-list-view'
|
|
66
69
|
),
|
|
70
|
+
inserterSidebarToggleRef: getInserterSidebarToggleRef(),
|
|
67
71
|
listViewToggleRef: getListViewToggleRef(),
|
|
68
72
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
69
73
|
showIconLabels: get( 'core', 'showIconLabels' ),
|
|
70
74
|
isDistractionFree: get( 'core', 'distractionFree' ),
|
|
75
|
+
isVisualMode: getEditorMode() === 'visual',
|
|
76
|
+
isZoomedOutView: __unstableGetEditorMode() === 'zoom-out',
|
|
71
77
|
};
|
|
72
78
|
}, [] );
|
|
73
79
|
|
|
@@ -82,17 +88,10 @@ function DocumentTools( {
|
|
|
82
88
|
[ setIsListViewOpened, isListViewOpen ]
|
|
83
89
|
);
|
|
84
90
|
|
|
85
|
-
const toggleInserter = useCallback(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// See https://github.com/WordPress/gutenberg/issues/43090 for more details.
|
|
90
|
-
inserterButton.current.focus();
|
|
91
|
-
setIsInserterOpened( false );
|
|
92
|
-
} else {
|
|
93
|
-
setIsInserterOpened( true );
|
|
94
|
-
}
|
|
95
|
-
}, [ isInserterOpened, setIsInserterOpened ] );
|
|
91
|
+
const toggleInserter = useCallback(
|
|
92
|
+
() => setIsInserterOpened( ! isInserterOpened ),
|
|
93
|
+
[ isInserterOpened, setIsInserterOpened ]
|
|
94
|
+
);
|
|
96
95
|
|
|
97
96
|
/* translators: button label text should, if possible, be under 16 characters. */
|
|
98
97
|
const longLabel = _x(
|
|
@@ -107,7 +106,7 @@ function DocumentTools( {
|
|
|
107
106
|
// supported, but we're keeping it in the list of class names for backwards
|
|
108
107
|
// compatibility.
|
|
109
108
|
<NavigableToolbar
|
|
110
|
-
className={
|
|
109
|
+
className={ clsx(
|
|
111
110
|
'editor-document-tools',
|
|
112
111
|
'edit-post-header-toolbar',
|
|
113
112
|
className
|
|
@@ -118,7 +117,7 @@ function DocumentTools( {
|
|
|
118
117
|
<div className="editor-document-tools__left">
|
|
119
118
|
{ ! isDistractionFree && (
|
|
120
119
|
<ToolbarItem
|
|
121
|
-
ref={
|
|
120
|
+
ref={ inserterSidebarToggleRef }
|
|
122
121
|
as={ Button }
|
|
123
122
|
className="editor-document-tools__inserter-toggle"
|
|
124
123
|
variant="primary"
|
|
@@ -179,7 +178,6 @@ function DocumentTools( {
|
|
|
179
178
|
) }
|
|
180
179
|
</>
|
|
181
180
|
) }
|
|
182
|
-
{ children }
|
|
183
181
|
</div>
|
|
184
182
|
</NavigableToolbar>
|
|
185
183
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import clsx from 'clsx';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -161,13 +161,17 @@ function EditorCanvas( {
|
|
|
161
161
|
hasRootPaddingAwareAlignments,
|
|
162
162
|
themeHasDisabledLayoutStyles,
|
|
163
163
|
themeSupportsLayout,
|
|
164
|
+
isZoomOutMode,
|
|
164
165
|
} = useSelect( ( select ) => {
|
|
165
|
-
const
|
|
166
|
+
const { getSettings, __unstableGetEditorMode } =
|
|
167
|
+
select( blockEditorStore );
|
|
168
|
+
const _settings = getSettings();
|
|
166
169
|
return {
|
|
167
170
|
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
168
171
|
themeSupportsLayout: _settings.supportsLayout,
|
|
169
172
|
hasRootPaddingAwareAlignments:
|
|
170
173
|
_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
|
|
174
|
+
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
|
|
171
175
|
};
|
|
172
176
|
}, [] );
|
|
173
177
|
|
|
@@ -248,7 +252,7 @@ function EditorCanvas( {
|
|
|
248
252
|
'core/post-content'
|
|
249
253
|
);
|
|
250
254
|
|
|
251
|
-
const blockListLayoutClass =
|
|
255
|
+
const blockListLayoutClass = clsx(
|
|
252
256
|
{
|
|
253
257
|
'is-layout-flow': ! themeSupportsLayout,
|
|
254
258
|
},
|
|
@@ -319,6 +323,13 @@ function EditorCanvas( {
|
|
|
319
323
|
} ),
|
|
320
324
|
] );
|
|
321
325
|
|
|
326
|
+
const zoomOutProps = isZoomOutMode
|
|
327
|
+
? {
|
|
328
|
+
scale: 'default',
|
|
329
|
+
frameSize: '20px',
|
|
330
|
+
}
|
|
331
|
+
: {};
|
|
332
|
+
|
|
322
333
|
return (
|
|
323
334
|
<BlockCanvas
|
|
324
335
|
shouldIframe={
|
|
@@ -328,10 +339,11 @@ function EditorCanvas( {
|
|
|
328
339
|
styles={ styles }
|
|
329
340
|
height="100%"
|
|
330
341
|
iframeProps={ {
|
|
331
|
-
className:
|
|
342
|
+
className: clsx( 'editor-canvas__iframe', {
|
|
332
343
|
'has-editor-padding': showEditorPadding,
|
|
333
344
|
} ),
|
|
334
345
|
...iframeProps,
|
|
346
|
+
...zoomOutProps,
|
|
335
347
|
style: {
|
|
336
348
|
...iframeProps?.style,
|
|
337
349
|
...deviceStyles,
|
|
@@ -362,7 +374,7 @@ function EditorCanvas( {
|
|
|
362
374
|
) }
|
|
363
375
|
{ renderingMode === 'post-only' && ! isDesignPostType && (
|
|
364
376
|
<div
|
|
365
|
-
className={
|
|
377
|
+
className={ clsx(
|
|
366
378
|
'editor-editor-canvas__post-title-wrapper',
|
|
367
379
|
// The following class is only here for backward comapatibility
|
|
368
380
|
// some themes might be using it to style the post title.
|
|
@@ -387,7 +399,7 @@ function EditorCanvas( {
|
|
|
387
399
|
uniqueId={ wrapperUniqueId }
|
|
388
400
|
>
|
|
389
401
|
<BlockList
|
|
390
|
-
className={
|
|
402
|
+
className={ clsx(
|
|
391
403
|
className,
|
|
392
404
|
'is-' + deviceType.toLowerCase() + '-preview',
|
|
393
405
|
renderingMode !== 'post-only' || isDesignPostType
|
|
@@ -72,7 +72,7 @@ function EditorKeyboardShortcutsRegister() {
|
|
|
72
72
|
registerShortcut( {
|
|
73
73
|
name: 'core/editor/toggle-list-view',
|
|
74
74
|
category: 'global',
|
|
75
|
-
description: __( 'Open the
|
|
75
|
+
description: __( 'Open the List View.' ),
|
|
76
76
|
keyCombination: {
|
|
77
77
|
modifier: 'access',
|
|
78
78
|
character: 'o',
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import deepmerge from 'deepmerge';
|
|
5
|
+
import { isPlainObject } from 'is-plain-object';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
11
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
12
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
+
import { useMemo, useCallback } from '@wordpress/element';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
19
|
+
|
|
20
|
+
const { GlobalStylesContext, cleanEmptyObject } = unlock(
|
|
21
|
+
blockEditorPrivateApis
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export function mergeBaseAndUserConfigs( base, user ) {
|
|
25
|
+
return deepmerge( base, user, {
|
|
26
|
+
// We only pass as arrays the presets,
|
|
27
|
+
// in which case we want the new array of values
|
|
28
|
+
// to override the old array (no merging).
|
|
29
|
+
isMergeableObject: isPlainObject,
|
|
30
|
+
} );
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function useGlobalStylesUserConfig() {
|
|
34
|
+
const { globalStylesId, isReady, settings, styles } = useSelect(
|
|
35
|
+
( select ) => {
|
|
36
|
+
const { getEditedEntityRecord, hasFinishedResolution } =
|
|
37
|
+
select( coreStore );
|
|
38
|
+
const _globalStylesId =
|
|
39
|
+
select( coreStore ).__experimentalGetCurrentGlobalStylesId();
|
|
40
|
+
const record = _globalStylesId
|
|
41
|
+
? getEditedEntityRecord(
|
|
42
|
+
'root',
|
|
43
|
+
'globalStyles',
|
|
44
|
+
_globalStylesId
|
|
45
|
+
)
|
|
46
|
+
: undefined;
|
|
47
|
+
|
|
48
|
+
let hasResolved = false;
|
|
49
|
+
if (
|
|
50
|
+
hasFinishedResolution(
|
|
51
|
+
'__experimentalGetCurrentGlobalStylesId'
|
|
52
|
+
)
|
|
53
|
+
) {
|
|
54
|
+
hasResolved = _globalStylesId
|
|
55
|
+
? hasFinishedResolution( 'getEditedEntityRecord', [
|
|
56
|
+
'root',
|
|
57
|
+
'globalStyles',
|
|
58
|
+
_globalStylesId,
|
|
59
|
+
] )
|
|
60
|
+
: true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
globalStylesId: _globalStylesId,
|
|
65
|
+
isReady: hasResolved,
|
|
66
|
+
settings: record?.settings,
|
|
67
|
+
styles: record?.styles,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
[]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const { getEditedEntityRecord } = useSelect( coreStore );
|
|
74
|
+
const { editEntityRecord } = useDispatch( coreStore );
|
|
75
|
+
const config = useMemo( () => {
|
|
76
|
+
return {
|
|
77
|
+
settings: settings ?? {},
|
|
78
|
+
styles: styles ?? {},
|
|
79
|
+
};
|
|
80
|
+
}, [ settings, styles ] );
|
|
81
|
+
|
|
82
|
+
const setConfig = useCallback(
|
|
83
|
+
( callback, options = {} ) => {
|
|
84
|
+
const record = getEditedEntityRecord(
|
|
85
|
+
'root',
|
|
86
|
+
'globalStyles',
|
|
87
|
+
globalStylesId
|
|
88
|
+
);
|
|
89
|
+
const currentConfig = {
|
|
90
|
+
styles: record?.styles ?? {},
|
|
91
|
+
settings: record?.settings ?? {},
|
|
92
|
+
};
|
|
93
|
+
const updatedConfig = callback( currentConfig );
|
|
94
|
+
editEntityRecord(
|
|
95
|
+
'root',
|
|
96
|
+
'globalStyles',
|
|
97
|
+
globalStylesId,
|
|
98
|
+
{
|
|
99
|
+
styles: cleanEmptyObject( updatedConfig.styles ) || {},
|
|
100
|
+
settings: cleanEmptyObject( updatedConfig.settings ) || {},
|
|
101
|
+
},
|
|
102
|
+
options
|
|
103
|
+
);
|
|
104
|
+
},
|
|
105
|
+
[ globalStylesId ]
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
return [ isReady, config, setConfig ];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function useGlobalStylesBaseConfig() {
|
|
112
|
+
const baseConfig = useSelect( ( select ) => {
|
|
113
|
+
return select(
|
|
114
|
+
coreStore
|
|
115
|
+
).__experimentalGetCurrentThemeBaseGlobalStyles();
|
|
116
|
+
}, [] );
|
|
117
|
+
|
|
118
|
+
return [ !! baseConfig, baseConfig ];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function useGlobalStylesContext() {
|
|
122
|
+
const [ isUserConfigReady, userConfig, setUserConfig ] =
|
|
123
|
+
useGlobalStylesUserConfig();
|
|
124
|
+
const [ isBaseConfigReady, baseConfig ] = useGlobalStylesBaseConfig();
|
|
125
|
+
const mergedConfig = useMemo( () => {
|
|
126
|
+
if ( ! baseConfig || ! userConfig ) {
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
return mergeBaseAndUserConfigs( baseConfig, userConfig );
|
|
130
|
+
}, [ userConfig, baseConfig ] );
|
|
131
|
+
const context = useMemo( () => {
|
|
132
|
+
return {
|
|
133
|
+
isReady: isUserConfigReady && isBaseConfigReady,
|
|
134
|
+
user: userConfig,
|
|
135
|
+
base: baseConfig,
|
|
136
|
+
merged: mergedConfig,
|
|
137
|
+
setUserConfig,
|
|
138
|
+
};
|
|
139
|
+
}, [
|
|
140
|
+
mergedConfig,
|
|
141
|
+
userConfig,
|
|
142
|
+
baseConfig,
|
|
143
|
+
setUserConfig,
|
|
144
|
+
isUserConfigReady,
|
|
145
|
+
isBaseConfigReady,
|
|
146
|
+
] );
|
|
147
|
+
|
|
148
|
+
return context;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function GlobalStylesProvider( { children } ) {
|
|
152
|
+
const context = useGlobalStylesContext();
|
|
153
|
+
if ( ! context.isReady ) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<GlobalStylesContext.Provider value={ context }>
|
|
159
|
+
{ children }
|
|
160
|
+
</GlobalStylesContext.Provider>
|
|
161
|
+
);
|
|
162
|
+
}
|