@wordpress/editor 13.26.0 → 13.27.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/bindings/index.js +20 -0
- package/build/bindings/index.js.map +1 -0
- package/build/bindings/post-meta.js +52 -0
- package/build/bindings/post-meta.js.map +1 -0
- package/build/components/block-manager/category.js +106 -0
- package/build/components/block-manager/category.js.map +1 -0
- package/build/components/block-manager/checklist.js +35 -0
- package/build/components/block-manager/checklist.js.map +1 -0
- package/build/components/block-manager/index.js +130 -0
- package/build/components/block-manager/index.js.map +1 -0
- package/build/components/document-tools/index.js +58 -52
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/index.js +4 -4
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/editor-notices/index.js +11 -11
- package/build/components/editor-notices/index.js.map +1 -1
- package/build/components/entities-saved-states/entity-type-list.js +38 -7
- package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build/components/entities-saved-states/index.js +1 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/offline-status/index.native.js +1 -3
- package/build/components/offline-status/index.native.js.map +1 -1
- package/build/components/post-locked-modal/index.js +1 -1
- package/build/components/post-locked-modal/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +10 -24
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/check.js +5 -16
- package/build/components/post-schedule/check.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js +42 -0
- package/build/components/preferences-modal/enable-panel.js.map +1 -0
- package/build/components/preferences-modal/enable-plugin-document-setting-panel.js +33 -0
- package/build/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -0
- package/build/components/preferences-modal/index.js +186 -0
- package/build/components/preferences-modal/index.js.map +1 -0
- package/build/components/provider/disable-non-page-content-blocks.js +1 -4
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +34 -8
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/hooks/pattern-partial-syncing.js +12 -8
- package/build/hooks/pattern-partial-syncing.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +6 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/defaults.js +2 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/private-actions.js +33 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +1 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build-module/bindings/index.js +15 -0
- package/build-module/bindings/index.js.map +1 -0
- package/build-module/bindings/post-meta.js +45 -0
- package/build-module/bindings/post-meta.js.map +1 -0
- package/build-module/components/block-manager/category.js +97 -0
- package/build-module/components/block-manager/category.js.map +1 -0
- package/build-module/components/block-manager/checklist.js +27 -0
- package/build-module/components/block-manager/checklist.js.map +1 -0
- package/build-module/components/block-manager/index.js +121 -0
- package/build-module/components/block-manager/index.js.map +1 -0
- package/build-module/components/document-tools/index.js +58 -52
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +4 -4
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/editor-notices/index.js +12 -12
- package/build-module/components/editor-notices/index.js.map +1 -1
- package/build-module/components/entities-saved-states/entity-type-list.js +39 -8
- package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +1 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/offline-status/index.native.js +1 -3
- package/build-module/components/offline-status/index.native.js.map +1 -1
- package/build-module/components/post-locked-modal/index.js +1 -1
- package/build-module/components/post-locked-modal/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +11 -25
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/check.js +6 -15
- package/build-module/components/post-schedule/check.js.map +1 -1
- package/build-module/components/preferences-modal/enable-panel.js +34 -0
- package/build-module/components/preferences-modal/enable-panel.js.map +1 -0
- package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js +24 -0
- package/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +179 -0
- package/build-module/components/preferences-modal/index.js.map +1 -0
- package/build-module/components/provider/disable-non-page-content-blocks.js +1 -4
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +35 -9
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/hooks/pattern-partial-syncing.js +12 -8
- package/build-module/hooks/pattern-partial-syncing.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +6 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/defaults.js +2 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/private-actions.js +29 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-style/style-rtl.css +80 -12
- package/build-style/style.css +80 -12
- package/package.json +33 -33
- package/src/bindings/index.js +13 -0
- package/src/bindings/post-meta.js +42 -0
- package/src/components/block-manager/category.js +96 -0
- package/src/components/block-manager/checklist.js +30 -0
- package/src/components/block-manager/index.js +160 -0
- package/src/components/block-manager/style.scss +82 -0
- package/src/components/document-tools/index.js +9 -1
- package/src/components/editor-canvas/index.js +3 -2
- package/src/components/editor-notices/index.js +11 -12
- package/src/components/editor-notices/style.scss +0 -1
- package/src/components/entities-saved-states/entity-type-list.js +47 -5
- package/src/components/entities-saved-states/index.js +7 -7
- package/src/components/entities-saved-states/style.scss +4 -0
- package/src/components/offline-status/index.native.js +2 -4
- package/src/components/post-locked-modal/index.js +1 -1
- package/src/components/post-locked-modal/style.scss +0 -6
- package/src/components/post-saved-state/index.js +30 -47
- package/src/components/post-schedule/check.js +10 -14
- package/src/components/post-schedule/test/check.js +24 -9
- package/src/components/preferences-modal/enable-panel.js +30 -0
- package/src/components/preferences-modal/enable-plugin-document-setting-panel.js +23 -0
- package/src/components/preferences-modal/index.js +269 -0
- package/src/components/preferences-modal/test/index.js +28 -0
- package/src/components/provider/disable-non-page-content-blocks.js +3 -3
- package/src/components/provider/use-block-editor-settings.js +45 -17
- package/src/hooks/pattern-partial-syncing.js +26 -29
- package/src/index.js +1 -0
- package/src/private-apis.js +6 -2
- package/src/store/defaults.js +2 -0
- package/src/store/private-actions.js +49 -0
- package/src/store/private-selectors.js +1 -1
- package/src/style.scss +1 -1
- package/src/components/editor-canvas/style.scss +0 -5
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { compose, ifCondition } from '@wordpress/compose';
|
|
5
|
+
import { withSelect, withDispatch } from '@wordpress/data';
|
|
6
|
+
import { privateApis as preferencesPrivateApis } from '@wordpress/preferences';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { unlock } from '../../lock-unlock';
|
|
12
|
+
import { store as editorStore } from '../../store';
|
|
13
|
+
|
|
14
|
+
const { PreferenceBaseOption } = unlock( preferencesPrivateApis );
|
|
15
|
+
|
|
16
|
+
export default compose(
|
|
17
|
+
withSelect( ( select, { panelName } ) => {
|
|
18
|
+
const { isEditorPanelEnabled, isEditorPanelRemoved } =
|
|
19
|
+
select( editorStore );
|
|
20
|
+
return {
|
|
21
|
+
isRemoved: isEditorPanelRemoved( panelName ),
|
|
22
|
+
isChecked: isEditorPanelEnabled( panelName ),
|
|
23
|
+
};
|
|
24
|
+
} ),
|
|
25
|
+
ifCondition( ( { isRemoved } ) => ! isRemoved ),
|
|
26
|
+
withDispatch( ( dispatch, { panelName } ) => ( {
|
|
27
|
+
onChange: () =>
|
|
28
|
+
dispatch( editorStore ).toggleEditorPanelEnabled( panelName ),
|
|
29
|
+
} ) )
|
|
30
|
+
)( PreferenceBaseOption );
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createSlotFill } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import EnablePanelOption from './enable-panel';
|
|
10
|
+
|
|
11
|
+
const { Fill, Slot } = createSlotFill(
|
|
12
|
+
'EnablePluginDocumentSettingPanelOption'
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const EnablePluginDocumentSettingPanelOption = ( { label, panelName } ) => (
|
|
16
|
+
<Fill>
|
|
17
|
+
<EnablePanelOption label={ label } panelName={ panelName } />
|
|
18
|
+
</Fill>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
EnablePluginDocumentSettingPanelOption.Slot = Slot;
|
|
22
|
+
|
|
23
|
+
export default EnablePluginDocumentSettingPanelOption;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
7
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
+
import { useMemo } from '@wordpress/element';
|
|
9
|
+
import {
|
|
10
|
+
store as preferencesStore,
|
|
11
|
+
privateApis as preferencesPrivateApis,
|
|
12
|
+
} from '@wordpress/preferences';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import EnablePanelOption from './enable-panel';
|
|
18
|
+
import EnablePluginDocumentSettingPanelOption from './enable-plugin-document-setting-panel';
|
|
19
|
+
import BlockManager from '../block-manager';
|
|
20
|
+
import PostTaxonomies from '../post-taxonomies';
|
|
21
|
+
import PostFeaturedImageCheck from '../post-featured-image/check';
|
|
22
|
+
import PostExcerptCheck from '../post-excerpt/check';
|
|
23
|
+
import PageAttributesCheck from '../page-attributes/check';
|
|
24
|
+
import PostTypeSupportCheck from '../post-type-support-check';
|
|
25
|
+
import { store as editorStore } from '../../store';
|
|
26
|
+
import { unlock } from '../../lock-unlock';
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
PreferencesModal,
|
|
30
|
+
PreferencesModalTabs,
|
|
31
|
+
PreferencesModalSection,
|
|
32
|
+
PreferenceToggleControl,
|
|
33
|
+
} = unlock( preferencesPrivateApis );
|
|
34
|
+
|
|
35
|
+
export default function EditorPreferencesModal( {
|
|
36
|
+
extraSections = {},
|
|
37
|
+
isActive,
|
|
38
|
+
onClose,
|
|
39
|
+
} ) {
|
|
40
|
+
const isLargeViewport = useViewportMatch( 'medium' );
|
|
41
|
+
const { showBlockBreadcrumbsOption } = useSelect(
|
|
42
|
+
( select ) => {
|
|
43
|
+
const { getEditorSettings } = select( editorStore );
|
|
44
|
+
const { get } = select( preferencesStore );
|
|
45
|
+
const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
|
|
46
|
+
const isDistractionFreeEnabled = get( 'core', 'distractionFree' );
|
|
47
|
+
return {
|
|
48
|
+
showBlockBreadcrumbsOption:
|
|
49
|
+
! isDistractionFreeEnabled &&
|
|
50
|
+
isLargeViewport &&
|
|
51
|
+
isRichEditingEnabled,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
[ isLargeViewport ]
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const { setIsListViewOpened, setIsInserterOpened } =
|
|
58
|
+
useDispatch( editorStore );
|
|
59
|
+
const { set: setPreference } = useDispatch( preferencesStore );
|
|
60
|
+
|
|
61
|
+
const toggleDistractionFree = () => {
|
|
62
|
+
setPreference( 'core', 'fixedToolbar', true );
|
|
63
|
+
setIsInserterOpened( false );
|
|
64
|
+
setIsListViewOpened( false );
|
|
65
|
+
// Todo: Check sidebar when closing/opening distraction free.
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const turnOffDistractionFree = () => {
|
|
69
|
+
setPreference( 'core', 'distractionFree', false );
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const sections = useMemo(
|
|
73
|
+
() => [
|
|
74
|
+
{
|
|
75
|
+
name: 'general',
|
|
76
|
+
tabLabel: __( 'General' ),
|
|
77
|
+
content: (
|
|
78
|
+
<>
|
|
79
|
+
<PreferencesModalSection title={ __( 'Interface' ) }>
|
|
80
|
+
<PreferenceToggleControl
|
|
81
|
+
scope="core"
|
|
82
|
+
featureName="showListViewByDefault"
|
|
83
|
+
help={ __(
|
|
84
|
+
'Opens the block list view sidebar by default.'
|
|
85
|
+
) }
|
|
86
|
+
label={ __( 'Always open list view' ) }
|
|
87
|
+
/>
|
|
88
|
+
{ showBlockBreadcrumbsOption && (
|
|
89
|
+
<PreferenceToggleControl
|
|
90
|
+
scope="core"
|
|
91
|
+
featureName="showBlockBreadcrumbs"
|
|
92
|
+
help={ __(
|
|
93
|
+
'Display the block hierarchy trail at the bottom of the editor.'
|
|
94
|
+
) }
|
|
95
|
+
label={ __( 'Show block breadcrumbs' ) }
|
|
96
|
+
/>
|
|
97
|
+
) }
|
|
98
|
+
<PreferenceToggleControl
|
|
99
|
+
scope="core"
|
|
100
|
+
featureName="allowRightClickOverrides"
|
|
101
|
+
help={ __(
|
|
102
|
+
'Allows contextual list view menus via right-click, overriding browser defaults.'
|
|
103
|
+
) }
|
|
104
|
+
label={ __(
|
|
105
|
+
'Allow right-click contextual menus'
|
|
106
|
+
) }
|
|
107
|
+
/>
|
|
108
|
+
</PreferencesModalSection>
|
|
109
|
+
<PreferencesModalSection
|
|
110
|
+
title={ __( 'Document settings' ) }
|
|
111
|
+
description={ __(
|
|
112
|
+
'Select what settings are shown in the document panel.'
|
|
113
|
+
) }
|
|
114
|
+
>
|
|
115
|
+
<EnablePluginDocumentSettingPanelOption.Slot />
|
|
116
|
+
<PostTaxonomies
|
|
117
|
+
taxonomyWrapper={ ( content, taxonomy ) => (
|
|
118
|
+
<EnablePanelOption
|
|
119
|
+
label={ taxonomy.labels.menu_name }
|
|
120
|
+
panelName={ `taxonomy-panel-${ taxonomy.slug }` }
|
|
121
|
+
/>
|
|
122
|
+
) }
|
|
123
|
+
/>
|
|
124
|
+
<PostFeaturedImageCheck>
|
|
125
|
+
<EnablePanelOption
|
|
126
|
+
label={ __( 'Featured image' ) }
|
|
127
|
+
panelName="featured-image"
|
|
128
|
+
/>
|
|
129
|
+
</PostFeaturedImageCheck>
|
|
130
|
+
<PostExcerptCheck>
|
|
131
|
+
<EnablePanelOption
|
|
132
|
+
label={ __( 'Excerpt' ) }
|
|
133
|
+
panelName="post-excerpt"
|
|
134
|
+
/>
|
|
135
|
+
</PostExcerptCheck>
|
|
136
|
+
<PostTypeSupportCheck
|
|
137
|
+
supportKeys={ [ 'comments', 'trackbacks' ] }
|
|
138
|
+
>
|
|
139
|
+
<EnablePanelOption
|
|
140
|
+
label={ __( 'Discussion' ) }
|
|
141
|
+
panelName="discussion-panel"
|
|
142
|
+
/>
|
|
143
|
+
</PostTypeSupportCheck>
|
|
144
|
+
<PageAttributesCheck>
|
|
145
|
+
<EnablePanelOption
|
|
146
|
+
label={ __( 'Page attributes' ) }
|
|
147
|
+
panelName="page-attributes"
|
|
148
|
+
/>
|
|
149
|
+
</PageAttributesCheck>
|
|
150
|
+
</PreferencesModalSection>
|
|
151
|
+
{ extraSections?.general }
|
|
152
|
+
</>
|
|
153
|
+
),
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'appearance',
|
|
157
|
+
tabLabel: __( 'Appearance' ),
|
|
158
|
+
content: (
|
|
159
|
+
<PreferencesModalSection
|
|
160
|
+
title={ __( 'Appearance' ) }
|
|
161
|
+
description={ __(
|
|
162
|
+
'Customize the editor interface to suit your needs.'
|
|
163
|
+
) }
|
|
164
|
+
>
|
|
165
|
+
<PreferenceToggleControl
|
|
166
|
+
scope="core"
|
|
167
|
+
featureName="fixedToolbar"
|
|
168
|
+
onToggle={ turnOffDistractionFree }
|
|
169
|
+
help={ __(
|
|
170
|
+
'Access all block and document tools in a single place.'
|
|
171
|
+
) }
|
|
172
|
+
label={ __( 'Top toolbar' ) }
|
|
173
|
+
/>
|
|
174
|
+
<PreferenceToggleControl
|
|
175
|
+
scope="core"
|
|
176
|
+
featureName="distractionFree"
|
|
177
|
+
onToggle={ toggleDistractionFree }
|
|
178
|
+
help={ __(
|
|
179
|
+
'Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'
|
|
180
|
+
) }
|
|
181
|
+
label={ __( 'Distraction free' ) }
|
|
182
|
+
/>
|
|
183
|
+
<PreferenceToggleControl
|
|
184
|
+
scope="core"
|
|
185
|
+
featureName="focusMode"
|
|
186
|
+
help={ __(
|
|
187
|
+
'Highlights the current block and fades other content.'
|
|
188
|
+
) }
|
|
189
|
+
label={ __( 'Spotlight mode' ) }
|
|
190
|
+
/>
|
|
191
|
+
{ extraSections?.appearance }
|
|
192
|
+
</PreferencesModalSection>
|
|
193
|
+
),
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'accessibility',
|
|
197
|
+
tabLabel: __( 'Accessibility' ),
|
|
198
|
+
content: (
|
|
199
|
+
<>
|
|
200
|
+
<PreferencesModalSection
|
|
201
|
+
title={ __( 'Navigation' ) }
|
|
202
|
+
description={ __(
|
|
203
|
+
'Optimize the editing experience for enhanced control.'
|
|
204
|
+
) }
|
|
205
|
+
>
|
|
206
|
+
<PreferenceToggleControl
|
|
207
|
+
scope="core"
|
|
208
|
+
featureName="keepCaretInsideBlock"
|
|
209
|
+
help={ __(
|
|
210
|
+
'Keeps the text cursor within the block boundaries, aiding users with screen readers by preventing unintentional cursor movement outside the block.'
|
|
211
|
+
) }
|
|
212
|
+
label={ __(
|
|
213
|
+
'Contain text cursor inside block'
|
|
214
|
+
) }
|
|
215
|
+
/>
|
|
216
|
+
</PreferencesModalSection>
|
|
217
|
+
<PreferencesModalSection title={ __( 'Interface' ) }>
|
|
218
|
+
<PreferenceToggleControl
|
|
219
|
+
scope="core"
|
|
220
|
+
featureName="showIconLabels"
|
|
221
|
+
label={ __( 'Show button text labels' ) }
|
|
222
|
+
help={ __(
|
|
223
|
+
'Show text instead of icons on buttons across the interface.'
|
|
224
|
+
) }
|
|
225
|
+
/>
|
|
226
|
+
</PreferencesModalSection>
|
|
227
|
+
</>
|
|
228
|
+
),
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'blocks',
|
|
232
|
+
tabLabel: __( 'Blocks' ),
|
|
233
|
+
content: (
|
|
234
|
+
<>
|
|
235
|
+
<PreferencesModalSection title={ __( 'Inserter' ) }>
|
|
236
|
+
<PreferenceToggleControl
|
|
237
|
+
scope="core"
|
|
238
|
+
featureName="mostUsedBlocks"
|
|
239
|
+
help={ __(
|
|
240
|
+
'Adds a category with the most frequently used blocks in the inserter.'
|
|
241
|
+
) }
|
|
242
|
+
label={ __( 'Show most used blocks' ) }
|
|
243
|
+
/>
|
|
244
|
+
</PreferencesModalSection>
|
|
245
|
+
<PreferencesModalSection
|
|
246
|
+
title={ __( 'Manage block visibility' ) }
|
|
247
|
+
description={ __(
|
|
248
|
+
"Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."
|
|
249
|
+
) }
|
|
250
|
+
>
|
|
251
|
+
<BlockManager />
|
|
252
|
+
</PreferencesModalSection>
|
|
253
|
+
</>
|
|
254
|
+
),
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
[ isLargeViewport, showBlockBreadcrumbsOption, extraSections ]
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
if ( ! isActive ) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<PreferencesModal closeModal={ onClose }>
|
|
266
|
+
<PreferencesModalTabs sections={ sections } />
|
|
267
|
+
</PreferencesModal>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import EditPostPreferencesModal from '../';
|
|
15
|
+
|
|
16
|
+
// This allows us to tweak the returned value on each test.
|
|
17
|
+
jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
|
|
18
|
+
jest.mock( '@wordpress/compose/src/hooks/use-viewport-match', () => jest.fn() );
|
|
19
|
+
|
|
20
|
+
describe( 'EditPostPreferencesModal', () => {
|
|
21
|
+
it( 'should not render when the modal is not active', () => {
|
|
22
|
+
useSelect.mockImplementation( () => [ false, false, false ] );
|
|
23
|
+
render( <EditPostPreferencesModal /> );
|
|
24
|
+
expect(
|
|
25
|
+
screen.queryByRole( 'dialog', { name: 'Preferences' } )
|
|
26
|
+
).not.toBeInTheDocument();
|
|
27
|
+
} );
|
|
28
|
+
} );
|
|
@@ -44,9 +44,9 @@ function DisableBlock( { clientId } ) {
|
|
|
44
44
|
export default function DisableNonPageContentBlocks() {
|
|
45
45
|
useBlockEditingMode( 'disabled' );
|
|
46
46
|
const clientIds = useSelect( ( select ) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
return select( blockEditorStore ).getBlocksByName(
|
|
48
|
+
PAGE_CONTENT_BLOCK_TYPES
|
|
49
|
+
);
|
|
50
50
|
}, [] );
|
|
51
51
|
|
|
52
52
|
return clientIds.map( ( clientId ) => {
|
|
@@ -7,10 +7,12 @@ import {
|
|
|
7
7
|
store as coreStore,
|
|
8
8
|
__experimentalFetchLinkSuggestions as fetchLinkSuggestions,
|
|
9
9
|
__experimentalFetchUrlData as fetchUrlData,
|
|
10
|
+
fetchBlockPatterns,
|
|
10
11
|
} from '@wordpress/core-data';
|
|
11
12
|
import { __ } from '@wordpress/i18n';
|
|
12
13
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
14
|
import { useViewportMatch } from '@wordpress/compose';
|
|
15
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Internal dependencies
|
|
@@ -29,7 +31,6 @@ const BLOCK_EDITOR_SETTINGS = [
|
|
|
29
31
|
'__experimentalPreferredStyleVariations',
|
|
30
32
|
'__unstableGalleryWithImageBlocks',
|
|
31
33
|
'alignWide',
|
|
32
|
-
'allowedBlockTypes',
|
|
33
34
|
'blockInspectorTabs',
|
|
34
35
|
'allowedMimeTypes',
|
|
35
36
|
'bodyPlaceholder',
|
|
@@ -88,18 +89,19 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
88
89
|
const isLargeViewport = useViewportMatch( 'medium' );
|
|
89
90
|
const {
|
|
90
91
|
allowRightClickOverrides,
|
|
92
|
+
blockTypes,
|
|
91
93
|
focusMode,
|
|
92
94
|
hasFixedToolbar,
|
|
93
95
|
isDistractionFree,
|
|
94
96
|
keepCaretInsideBlock,
|
|
95
97
|
reusableBlocks,
|
|
96
98
|
hasUploadPermissions,
|
|
99
|
+
hiddenBlockTypes,
|
|
97
100
|
canUseUnfilteredHTML,
|
|
98
101
|
userCanCreatePages,
|
|
99
102
|
pageOnFront,
|
|
100
103
|
pageForPosts,
|
|
101
104
|
userPatternCategories,
|
|
102
|
-
restBlockPatterns,
|
|
103
105
|
restBlockPatternCategories,
|
|
104
106
|
} = useSelect(
|
|
105
107
|
( select ) => {
|
|
@@ -110,11 +112,10 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
110
112
|
getEntityRecord,
|
|
111
113
|
getUserPatternCategories,
|
|
112
114
|
getEntityRecords,
|
|
113
|
-
getBlockPatterns,
|
|
114
115
|
getBlockPatternCategories,
|
|
115
116
|
} = select( coreStore );
|
|
116
117
|
const { get } = select( preferencesStore );
|
|
117
|
-
|
|
118
|
+
const { getBlockTypes } = select( blocksStore );
|
|
118
119
|
const siteSettings = canUser( 'read', 'settings' )
|
|
119
120
|
? getEntityRecord( 'root', 'site' )
|
|
120
121
|
: undefined;
|
|
@@ -124,6 +125,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
124
125
|
'core',
|
|
125
126
|
'allowRightClickOverrides'
|
|
126
127
|
),
|
|
128
|
+
blockTypes: getBlockTypes(),
|
|
127
129
|
canUseUnfilteredHTML: getRawEntityRecord(
|
|
128
130
|
'postType',
|
|
129
131
|
postType,
|
|
@@ -132,6 +134,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
132
134
|
focusMode: get( 'core', 'focusMode' ),
|
|
133
135
|
hasFixedToolbar:
|
|
134
136
|
get( 'core', 'fixedToolbar' ) || ! isLargeViewport,
|
|
137
|
+
hiddenBlockTypes: get( 'core', 'hiddenBlockTypes' ),
|
|
135
138
|
isDistractionFree: get( 'core', 'distractionFree' ),
|
|
136
139
|
keepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),
|
|
137
140
|
reusableBlocks: isWeb
|
|
@@ -144,7 +147,6 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
144
147
|
pageOnFront: siteSettings?.page_on_front,
|
|
145
148
|
pageForPosts: siteSettings?.page_for_posts,
|
|
146
149
|
userPatternCategories: getUserPatternCategories(),
|
|
147
|
-
restBlockPatterns: getBlockPatterns(),
|
|
148
150
|
restBlockPatternCategories: getBlockPatternCategories(),
|
|
149
151
|
};
|
|
150
152
|
},
|
|
@@ -160,22 +162,16 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
160
162
|
|
|
161
163
|
const blockPatterns = useMemo(
|
|
162
164
|
() =>
|
|
163
|
-
[
|
|
164
|
-
|
|
165
|
-
...( restBlockPatterns || [] ),
|
|
166
|
-
]
|
|
167
|
-
.filter(
|
|
168
|
-
( x, index, arr ) =>
|
|
169
|
-
index === arr.findIndex( ( y ) => x.name === y.name )
|
|
170
|
-
)
|
|
171
|
-
.filter( ( { postTypes } ) => {
|
|
165
|
+
[ ...( settingsBlockPatterns || [] ) ].filter(
|
|
166
|
+
( { postTypes } ) => {
|
|
172
167
|
return (
|
|
173
168
|
! postTypes ||
|
|
174
169
|
( Array.isArray( postTypes ) &&
|
|
175
170
|
postTypes.includes( postType ) )
|
|
176
171
|
);
|
|
177
|
-
}
|
|
178
|
-
|
|
172
|
+
}
|
|
173
|
+
),
|
|
174
|
+
[ settingsBlockPatterns, postType ]
|
|
179
175
|
);
|
|
180
176
|
|
|
181
177
|
const blockPatternCategories = useMemo(
|
|
@@ -215,6 +211,25 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
215
211
|
[ saveEntityRecord, userCanCreatePages ]
|
|
216
212
|
);
|
|
217
213
|
|
|
214
|
+
const allowedBlockTypes = useMemo( () => {
|
|
215
|
+
// Omit hidden block types if exists and non-empty.
|
|
216
|
+
if ( hiddenBlockTypes && hiddenBlockTypes.length > 0 ) {
|
|
217
|
+
// Defer to passed setting for `allowedBlockTypes` if provided as
|
|
218
|
+
// anything other than `true` (where `true` is equivalent to allow
|
|
219
|
+
// all block types).
|
|
220
|
+
const defaultAllowedBlockTypes =
|
|
221
|
+
true === settings.allowedBlockTypes
|
|
222
|
+
? blockTypes.map( ( { name } ) => name )
|
|
223
|
+
: settings.allowedBlockTypes || [];
|
|
224
|
+
|
|
225
|
+
return defaultAllowedBlockTypes.filter(
|
|
226
|
+
( type ) => ! hiddenBlockTypes.includes( type )
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return settings.allowedBlockTypes;
|
|
231
|
+
}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );
|
|
232
|
+
|
|
218
233
|
const forceDisableFocusMode = settings.focusMode === false;
|
|
219
234
|
|
|
220
235
|
return useMemo(
|
|
@@ -224,14 +239,26 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
224
239
|
BLOCK_EDITOR_SETTINGS.includes( key )
|
|
225
240
|
)
|
|
226
241
|
),
|
|
242
|
+
allowedBlockTypes,
|
|
227
243
|
allowRightClickOverrides,
|
|
228
244
|
focusMode: focusMode && ! forceDisableFocusMode,
|
|
229
245
|
hasFixedToolbar,
|
|
230
246
|
isDistractionFree,
|
|
231
247
|
keepCaretInsideBlock,
|
|
232
248
|
mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
|
|
233
|
-
__experimentalReusableBlocks: reusableBlocks,
|
|
234
249
|
__experimentalBlockPatterns: blockPatterns,
|
|
250
|
+
__experimentalFetchBlockPatterns: async () => {
|
|
251
|
+
return ( await fetchBlockPatterns() ).filter(
|
|
252
|
+
( { postTypes } ) => {
|
|
253
|
+
return (
|
|
254
|
+
! postTypes ||
|
|
255
|
+
( Array.isArray( postTypes ) &&
|
|
256
|
+
postTypes.includes( postType ) )
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
},
|
|
261
|
+
__experimentalReusableBlocks: reusableBlocks,
|
|
235
262
|
__experimentalBlockPatternCategories: blockPatternCategories,
|
|
236
263
|
__experimentalUserPatternCategories: userPatternCategories,
|
|
237
264
|
__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>
|
|
@@ -261,6 +288,7 @@ function useBlockEditorSettings( settings, postType, postId ) {
|
|
|
261
288
|
__experimentalSetIsInserterOpened: setIsInserterOpened,
|
|
262
289
|
} ),
|
|
263
290
|
[
|
|
291
|
+
allowedBlockTypes,
|
|
264
292
|
allowRightClickOverrides,
|
|
265
293
|
focusMode,
|
|
266
294
|
forceDisableFocusMode,
|
|
@@ -5,7 +5,6 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
5
5
|
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
6
6
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
7
7
|
import { useBlockEditingMode } from '@wordpress/block-editor';
|
|
8
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
9
8
|
import { useSelect } from '@wordpress/data';
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -31,43 +30,41 @@ const {
|
|
|
31
30
|
*/
|
|
32
31
|
const withPartialSyncingControls = createHigherOrderComponent(
|
|
33
32
|
( BlockEdit ) => ( props ) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'__experimentalConnections',
|
|
38
|
-
false
|
|
39
|
-
);
|
|
40
|
-
const isEditingPattern = useSelect(
|
|
41
|
-
( select ) =>
|
|
42
|
-
select( editorStore ).getCurrentPostType() ===
|
|
43
|
-
PATTERN_TYPES.user,
|
|
44
|
-
[]
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const shouldShowPartialSyncingControls =
|
|
48
|
-
hasCustomFieldsSupport &&
|
|
49
|
-
props.isSelected &&
|
|
50
|
-
isEditingPattern &&
|
|
51
|
-
blockEditingMode === 'default' &&
|
|
52
|
-
Object.keys( PARTIAL_SYNCING_SUPPORTED_BLOCKS ).includes(
|
|
53
|
-
props.name
|
|
54
|
-
);
|
|
33
|
+
const isSupportedBlock = Object.keys(
|
|
34
|
+
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
35
|
+
).includes( props.name );
|
|
55
36
|
|
|
56
37
|
return (
|
|
57
38
|
<>
|
|
58
39
|
<BlockEdit { ...props } />
|
|
59
|
-
{
|
|
60
|
-
<
|
|
40
|
+
{ props.isSelected && isSupportedBlock && (
|
|
41
|
+
<ControlsWithStoreSubscription { ...props } />
|
|
61
42
|
) }
|
|
62
43
|
</>
|
|
63
44
|
);
|
|
64
45
|
}
|
|
65
46
|
);
|
|
66
47
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
48
|
+
// Split into a separate component to avoid a store subscription
|
|
49
|
+
// on every block.
|
|
50
|
+
function ControlsWithStoreSubscription( props ) {
|
|
51
|
+
const blockEditingMode = useBlockEditingMode();
|
|
52
|
+
const isEditingPattern = useSelect(
|
|
53
|
+
( select ) =>
|
|
54
|
+
select( editorStore ).getCurrentPostType() === PATTERN_TYPES.user,
|
|
55
|
+
[]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
isEditingPattern &&
|
|
60
|
+
blockEditingMode === 'default' && (
|
|
61
|
+
<PartialSyncingControls { ...props } />
|
|
62
|
+
)
|
|
72
63
|
);
|
|
73
64
|
}
|
|
65
|
+
|
|
66
|
+
addFilter(
|
|
67
|
+
'editor.BlockEdit',
|
|
68
|
+
'core/editor/with-partial-syncing-controls',
|
|
69
|
+
withPartialSyncingControls
|
|
70
|
+
);
|
package/src/index.js
CHANGED
package/src/private-apis.js
CHANGED
|
@@ -4,28 +4,32 @@
|
|
|
4
4
|
import EditorCanvas from './components/editor-canvas';
|
|
5
5
|
import { ExperimentalEditorProvider } from './components/provider';
|
|
6
6
|
import { lock } from './lock-unlock';
|
|
7
|
+
import EnablePluginDocumentSettingPanelOption from './components/preferences-modal/enable-plugin-document-setting-panel';
|
|
7
8
|
import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
|
|
8
9
|
import useBlockEditorSettings from './components/provider/use-block-editor-settings';
|
|
9
10
|
import DocumentTools from './components/document-tools';
|
|
10
11
|
import InserterSidebar from './components/inserter-sidebar';
|
|
11
12
|
import ListViewSidebar from './components/list-view-sidebar';
|
|
13
|
+
import PluginPostExcerpt from './components/post-excerpt/plugin';
|
|
12
14
|
import PostPanelRow from './components/post-panel-row';
|
|
13
15
|
import PostViewLink from './components/post-view-link';
|
|
14
16
|
import PreviewDropdown from './components/preview-dropdown';
|
|
15
|
-
import
|
|
17
|
+
import PreferencesModal from './components/preferences-modal';
|
|
16
18
|
|
|
17
19
|
export const privateApis = {};
|
|
18
20
|
lock( privateApis, {
|
|
19
21
|
DocumentTools,
|
|
20
22
|
EditorCanvas,
|
|
21
23
|
ExperimentalEditorProvider,
|
|
24
|
+
EnablePluginDocumentSettingPanelOption,
|
|
22
25
|
EntitiesSavedStatesExtensible,
|
|
23
26
|
InserterSidebar,
|
|
24
27
|
ListViewSidebar,
|
|
28
|
+
PluginPostExcerpt,
|
|
25
29
|
PostPanelRow,
|
|
26
30
|
PostViewLink,
|
|
27
31
|
PreviewDropdown,
|
|
28
|
-
|
|
32
|
+
PreferencesModal,
|
|
29
33
|
|
|
30
34
|
// This is a temporary private API while we're updating the site editor to use EditorProvider.
|
|
31
35
|
useBlockEditorSettings,
|
package/src/store/defaults.js
CHANGED
|
@@ -9,6 +9,7 @@ import { SETTINGS_DEFAULTS } from '@wordpress/block-editor';
|
|
|
9
9
|
* @property {boolean|Array} allowedBlockTypes Allowed block types
|
|
10
10
|
* @property {boolean} richEditingEnabled Whether rich editing is enabled or not
|
|
11
11
|
* @property {boolean} codeEditingEnabled Whether code editing is enabled or not
|
|
12
|
+
* @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
|
|
12
13
|
* @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
|
|
13
14
|
* true = the user has opted to show the Custom Fields panel at the bottom of the editor.
|
|
14
15
|
* false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
|
|
@@ -26,6 +27,7 @@ export const EDITOR_SETTINGS_DEFAULTS = {
|
|
|
26
27
|
|
|
27
28
|
richEditingEnabled: true,
|
|
28
29
|
codeEditingEnabled: true,
|
|
30
|
+
fontLibraryEnabled: true,
|
|
29
31
|
enableCustomFields: undefined,
|
|
30
32
|
defaultRenderingMode: 'post-only',
|
|
31
33
|
};
|