@wordpress/edit-post 5.0.18-next.33ec3857e2.0 → 5.0.21

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.
Files changed (55) hide show
  1. package/build/components/block-manager/category.js +47 -42
  2. package/build/components/block-manager/category.js.map +1 -1
  3. package/build/components/edit-post-settings/index.js +16 -0
  4. package/build/components/edit-post-settings/index.js.map +1 -0
  5. package/build/components/header/template-title/edit-template-title.js +5 -0
  6. package/build/components/header/template-title/edit-template-title.js.map +1 -1
  7. package/build/components/header/template-title/index.js +10 -3
  8. package/build/components/header/template-title/index.js.map +1 -1
  9. package/build/components/header/template-title/template-description.js +14 -4
  10. package/build/components/header/template-title/template-description.js.map +1 -1
  11. package/build/components/layout/index.js +1 -3
  12. package/build/components/layout/index.js.map +1 -1
  13. package/build/components/visual-editor/index.js +6 -14
  14. package/build/components/visual-editor/index.js.map +1 -1
  15. package/build/editor.js +11 -6
  16. package/build/editor.js.map +1 -1
  17. package/build/prevent-event-discovery.js +24 -0
  18. package/build/prevent-event-discovery.js.map +1 -0
  19. package/build-module/components/block-manager/category.js +48 -44
  20. package/build-module/components/block-manager/category.js.map +1 -1
  21. package/build-module/components/edit-post-settings/index.js +7 -0
  22. package/build-module/components/edit-post-settings/index.js.map +1 -0
  23. package/build-module/components/header/template-title/edit-template-title.js +4 -0
  24. package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
  25. package/build-module/components/header/template-title/index.js +11 -4
  26. package/build-module/components/header/template-title/index.js.map +1 -1
  27. package/build-module/components/header/template-title/template-description.js +16 -6
  28. package/build-module/components/header/template-title/template-description.js.map +1 -1
  29. package/build-module/components/layout/index.js +2 -4
  30. package/build-module/components/layout/index.js.map +1 -1
  31. package/build-module/components/visual-editor/index.js +7 -15
  32. package/build-module/components/visual-editor/index.js.map +1 -1
  33. package/build-module/editor.js +10 -7
  34. package/build-module/editor.js.map +1 -1
  35. package/build-module/prevent-event-discovery.js +17 -0
  36. package/build-module/prevent-event-discovery.js.map +1 -0
  37. package/build-style/classic-rtl.css +8 -0
  38. package/build-style/classic.css +8 -0
  39. package/build-style/style-rtl.css +13 -5
  40. package/build-style/style.css +13 -5
  41. package/package.json +27 -27
  42. package/src/classic.scss +12 -0
  43. package/src/components/block-manager/category.js +48 -41
  44. package/src/components/edit-post-settings/index.js +7 -0
  45. package/src/components/header/fullscreen-mode-close/style.scss +8 -4
  46. package/src/components/header/template-title/edit-template-title.js +4 -0
  47. package/src/components/header/template-title/index.js +43 -26
  48. package/src/components/header/template-title/style.scss +13 -5
  49. package/src/components/header/template-title/template-description.js +21 -3
  50. package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +2 -2
  51. package/src/components/layout/index.js +1 -2
  52. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +4 -4
  53. package/src/components/visual-editor/index.js +6 -16
  54. package/src/editor.js +26 -22
  55. package/src/prevent-event-discovery.js +21 -0
@@ -29,6 +29,10 @@ export default function EditTemplateTitle() {
29
29
  const { getEditorSettings } = useSelect( editorStore );
30
30
  const { updateEditorSettings } = useDispatch( editorStore );
31
31
 
32
+ if ( template.has_theme_file ) {
33
+ return null;
34
+ }
35
+
32
36
  let templateTitle = __( 'Default' );
33
37
  if ( template?.title ) {
34
38
  templateTitle = template.title;
@@ -3,7 +3,11 @@
3
3
  */
4
4
  import { __, sprintf } from '@wordpress/i18n';
5
5
  import { useSelect, useDispatch } from '@wordpress/data';
6
- import { Dropdown, Button } from '@wordpress/components';
6
+ import {
7
+ Dropdown,
8
+ Button,
9
+ __experimentalText as Text,
10
+ } from '@wordpress/components';
7
11
  import { chevronDown } from '@wordpress/icons';
8
12
 
9
13
  /**
@@ -48,6 +52,12 @@ function TemplateTitle() {
48
52
  templateTitle = template.slug;
49
53
  }
50
54
 
55
+ const hasOptions = !! (
56
+ template.custom ||
57
+ template.wp_id ||
58
+ template.description
59
+ );
60
+
51
61
  return (
52
62
  <div className="edit-post-template-top-area">
53
63
  <Button
@@ -66,32 +76,39 @@ function TemplateTitle() {
66
76
  >
67
77
  { title }
68
78
  </Button>
69
- <Dropdown
70
- position="bottom center"
71
- contentClassName="edit-post-template-top-area__popover"
72
- renderToggle={ ( { onToggle } ) => (
73
- <Button
74
- className="edit-post-template-title"
75
- isLink
76
- icon={ chevronDown }
77
- showTooltip
78
- onClick={ onToggle }
79
- label={ __( 'Template Options' ) }
80
- >
81
- { templateTitle }
82
- </Button>
83
- ) }
84
- renderContent={ () => (
85
- <>
86
- { template.has_theme_file ? (
87
- <TemplateDescription />
88
- ) : (
79
+ { hasOptions ? (
80
+ <Dropdown
81
+ position="bottom center"
82
+ contentClassName="edit-post-template-top-area__popover"
83
+ renderToggle={ ( { onToggle } ) => (
84
+ <Button
85
+ className="edit-post-template-title"
86
+ isLink
87
+ icon={ chevronDown }
88
+ showTooltip
89
+ onClick={ onToggle }
90
+ label={ __( 'Template Options' ) }
91
+ >
92
+ { templateTitle }
93
+ </Button>
94
+ ) }
95
+ renderContent={ () => (
96
+ <>
89
97
  <EditTemplateTitle />
90
- ) }
91
- <DeleteTemplate />
92
- </>
93
- ) }
94
- />
98
+ <TemplateDescription />
99
+ <DeleteTemplate />
100
+ </>
101
+ ) }
102
+ />
103
+ ) : (
104
+ <Text
105
+ className="edit-post-template-title"
106
+ size="body"
107
+ style={ { lineHeight: '24px' } }
108
+ >
109
+ { templateTitle }
110
+ </Text>
111
+ ) }
95
112
  </div>
96
113
  );
97
114
  }
@@ -46,14 +46,21 @@
46
46
  }
47
47
  }
48
48
 
49
- .edit-post-template-top-area__popover .components-popover__content {
50
- min-width: 280px;
49
+ .edit-post-template-top-area__popover {
50
+ .components-popover__content {
51
+ min-width: 280px;
52
+ padding: $grid-unit-10;
53
+ }
54
+
55
+ .edit-post-template-details__description {
56
+ color: $gray-700;
57
+ }
51
58
  }
52
59
 
53
60
  .edit-post-template-top-area__second-menu-group {
54
- margin-left: -$grid-unit-15;
55
- margin-right: -$grid-unit-15;
56
- padding: $grid-unit-15;
61
+ margin-left: -$grid-unit-20;
62
+ margin-right: -$grid-unit-20;
63
+ padding: $grid-unit-20;
57
64
  padding-bottom: 0;
58
65
  border-top: $border-width solid $gray-300;
59
66
 
@@ -63,6 +70,7 @@
63
70
 
64
71
  .components-menu-item__item {
65
72
  margin-right: 0;
73
+ min-width: 0;
66
74
  }
67
75
  }
68
76
  }
@@ -2,7 +2,10 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
- import { __experimentalText as Text } from '@wordpress/components';
5
+ import {
6
+ __experimentalHeading as Heading,
7
+ __experimentalText as Text,
8
+ } from '@wordpress/components';
6
9
 
7
10
  /**
8
11
  * Internal dependencies
@@ -10,14 +13,29 @@ import { __experimentalText as Text } from '@wordpress/components';
10
13
  import { store as editPostStore } from '../../../store';
11
14
 
12
15
  export default function TemplateDescription() {
13
- const { description } = useSelect( ( select ) => {
16
+ const { description, title } = useSelect( ( select ) => {
14
17
  const { getEditedPostTemplate } = select( editPostStore );
15
18
  return {
19
+ title: getEditedPostTemplate().title,
16
20
  description: getEditedPostTemplate().description,
17
21
  };
18
22
  }, [] );
19
23
  if ( ! description ) {
20
24
  return null;
21
25
  }
22
- return <Text size="body">{ description }</Text>;
26
+ return (
27
+ <>
28
+ <Heading level={ 4 } weight={ 600 }>
29
+ { title }
30
+ </Heading>
31
+ <Text
32
+ className="edit-post-template-details__description"
33
+ size="body"
34
+ as="p"
35
+ style={ { marginTop: '12px' } }
36
+ >
37
+ { description }
38
+ </Text>
39
+ </>
40
+ );
23
41
  }
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`KeyboardShortcutHelpModal should match snapshot when the modal is active 1`] = `
4
- <ForwardRef(Modal)
4
+ <Modal
5
5
  className="edit-post-keyboard-shortcut-help-modal"
6
6
  closeLabel="Close"
7
7
  onRequestClose={[Function]}
@@ -80,7 +80,7 @@ exports[`KeyboardShortcutHelpModal should match snapshot when the modal is activ
80
80
  }
81
81
  title="Text formatting"
82
82
  />
83
- </ForwardRef(Modal)>
83
+ </Modal>
84
84
  `;
85
85
 
86
86
  exports[`KeyboardShortcutHelpModal should match snapshot when the modal is not active 1`] = `""`;
@@ -16,7 +16,7 @@ import {
16
16
  store as editorStore,
17
17
  } from '@wordpress/editor';
18
18
  import { useSelect, useDispatch } from '@wordpress/data';
19
- import { BlockBreadcrumb, BlockStyles } from '@wordpress/block-editor';
19
+ import { BlockBreadcrumb } from '@wordpress/block-editor';
20
20
  import { Button, ScrollLock, Popover } from '@wordpress/components';
21
21
  import { useViewportMatch } from '@wordpress/compose';
22
22
  import { PluginArea } from '@wordpress/plugins';
@@ -239,7 +239,6 @@ function Layout( { styles } ) {
239
239
  { isMobileViewport && sidebarIsOpened && (
240
240
  <ScrollLock />
241
241
  ) }
242
- <BlockStyles.Slot scope="core/block-inspector" />
243
242
  </>
244
243
  }
245
244
  footer={
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`PreferencesModal should match snapshot when the modal is active large viewports 1`] = `
4
- <ForwardRef(Modal)
4
+ <Modal
5
5
  className="edit-post-preferences-modal"
6
6
  closeLabel="Close"
7
7
  onRequestClose={[Function]}
@@ -30,11 +30,11 @@ exports[`PreferencesModal should match snapshot when the modal is active large v
30
30
  >
31
31
  <Component />
32
32
  </TabPanel>
33
- </ForwardRef(Modal)>
33
+ </Modal>
34
34
  `;
35
35
 
36
36
  exports[`PreferencesModal should match snapshot when the modal is active small viewports 1`] = `
37
- <ForwardRef(Modal)
37
+ <Modal
38
38
  className="edit-post-preferences-modal"
39
39
  closeLabel="Close"
40
40
  onRequestClose={[Function]}
@@ -386,5 +386,5 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
386
386
  </Card>
387
387
  </NavigatorScreen>
388
388
  </NavigatorProvider>
389
- </ForwardRef(Modal)>
389
+ </Modal>
390
390
  `;
@@ -22,6 +22,7 @@ import {
22
22
  __unstableUseTypingObserver as useTypingObserver,
23
23
  __unstableBlockSettingsMenuFirstItem,
24
24
  __experimentalUseResizeCanvas as useResizeCanvas,
25
+ __unstableUseCanvasClickRedirect as useCanvasClickRedirect,
25
26
  __unstableEditorStyles as EditorStyles,
26
27
  useSetting,
27
28
  __experimentalLayoutStyle as LayoutStyle,
@@ -42,14 +43,7 @@ import { __ } from '@wordpress/i18n';
42
43
  import BlockInspectorButton from './block-inspector-button';
43
44
  import { store as editPostStore } from '../../store';
44
45
 
45
- function MaybeIframe( {
46
- children,
47
- contentRef,
48
- shouldIframe,
49
- styles,
50
- assets,
51
- style,
52
- } ) {
46
+ function MaybeIframe( { children, contentRef, shouldIframe, styles, style } ) {
53
47
  const ref = useMouseMoveTypingReset();
54
48
 
55
49
  if ( ! shouldIframe ) {
@@ -71,7 +65,6 @@ function MaybeIframe( {
71
65
  return (
72
66
  <Iframe
73
67
  head={ <EditorStyles styles={ styles } /> }
74
- assets={ assets }
75
68
  ref={ ref }
76
69
  contentRef={ contentRef }
77
70
  style={ { width: '100%', height: '100%', display: 'block' } }
@@ -114,12 +107,9 @@ export default function VisualEditor( { styles } ) {
114
107
  ( select ) => select( editPostStore ).hasMetaBoxes(),
115
108
  []
116
109
  );
117
- const { themeSupportsLayout, assets } = useSelect( ( select ) => {
118
- const _settings = select( blockEditorStore ).getSettings();
119
- return {
120
- themeSupportsLayout: _settings.supportsLayout,
121
- assets: _settings.__unstableResolvedAssets,
122
- };
110
+ const themeSupportsLayout = useSelect( ( select ) => {
111
+ const { getSettings } = select( blockEditorStore );
112
+ return getSettings().supportsLayout;
123
113
  }, [] );
124
114
  const { clearSelectedBlock } = useDispatch( blockEditorStore );
125
115
  const { setIsEditingTemplate } = useDispatch( editPostStore );
@@ -163,6 +153,7 @@ export default function VisualEditor( { styles } ) {
163
153
  const contentRef = useMergeRefs( [
164
154
  ref,
165
155
  useClipboardHandler(),
156
+ useCanvasClickRedirect(),
166
157
  useTypewriter(),
167
158
  useTypingObserver(),
168
159
  useBlockSelectionClearer(),
@@ -227,7 +218,6 @@ export default function VisualEditor( { styles } ) {
227
218
  }
228
219
  contentRef={ contentRef }
229
220
  styles={ styles }
230
- assets={ assets }
231
221
  style={ { paddingBottom } }
232
222
  >
233
223
  { themeSupportsLayout && ! isTemplateMode && (
package/src/editor.js CHANGED
@@ -15,15 +15,17 @@ import {
15
15
  store as editorStore,
16
16
  } from '@wordpress/editor';
17
17
  import { StrictMode, useMemo } from '@wordpress/element';
18
- import { SlotFillProvider } from '@wordpress/components';
18
+ import { KeyboardShortcuts, SlotFillProvider } from '@wordpress/components';
19
19
  import { store as coreStore } from '@wordpress/core-data';
20
20
  import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
21
21
 
22
22
  /**
23
23
  * Internal dependencies
24
24
  */
25
+ import preventEventDiscovery from './prevent-event-discovery';
25
26
  import Layout from './components/layout';
26
27
  import EditorInitialization from './components/editor-initialization';
28
+ import EditPostSettings from './components/edit-post-settings';
27
29
  import { store as editPostStore } from './store';
28
30
 
29
31
  function Editor( {
@@ -125,9 +127,6 @@ function Editor( {
125
127
  // This is marked as experimental to give time for the quick inserter to mature.
126
128
  __experimentalSetIsInserterOpened: setIsInserterOpened,
127
129
  keepCaretInsideBlock,
128
- // Keep a reference of the `allowedBlockTypes` from the server to handle use cases
129
- // where we need to differentiate if a block is disabled by the user or some plugin.
130
- defaultAllowedBlockTypes: settings.allowedBlockTypes,
131
130
  };
132
131
 
133
132
  // Omit hidden block types if exists and non-empty.
@@ -187,24 +186,29 @@ function Editor( {
187
186
  return (
188
187
  <StrictMode>
189
188
  <ShortcutProvider>
190
- <SlotFillProvider>
191
- <EditorProvider
192
- settings={ editorSettings }
193
- post={ post }
194
- initialEdits={ initialEdits }
195
- useSubRegistry={ false }
196
- __unstableTemplate={
197
- isTemplateMode ? template : undefined
198
- }
199
- { ...props }
200
- >
201
- <ErrorBoundary onError={ onError }>
202
- <EditorInitialization postId={ postId } />
203
- <Layout styles={ styles } />
204
- </ErrorBoundary>
205
- <PostLockedModal />
206
- </EditorProvider>
207
- </SlotFillProvider>
189
+ <EditPostSettings.Provider value={ settings }>
190
+ <SlotFillProvider>
191
+ <EditorProvider
192
+ settings={ editorSettings }
193
+ post={ post }
194
+ initialEdits={ initialEdits }
195
+ useSubRegistry={ false }
196
+ __unstableTemplate={
197
+ isTemplateMode ? template : undefined
198
+ }
199
+ { ...props }
200
+ >
201
+ <ErrorBoundary onError={ onError }>
202
+ <EditorInitialization postId={ postId } />
203
+ <Layout styles={ styles } />
204
+ <KeyboardShortcuts
205
+ shortcuts={ preventEventDiscovery }
206
+ />
207
+ </ErrorBoundary>
208
+ <PostLockedModal />
209
+ </EditorProvider>
210
+ </SlotFillProvider>
211
+ </EditPostSettings.Provider>
208
212
  </ShortcutProvider>
209
213
  </StrictMode>
210
214
  );
@@ -0,0 +1,21 @@
1
+ export default {
2
+ 't a l e s o f g u t e n b e r g': ( event ) => {
3
+ const { ownerDocument } = event.target;
4
+ if (
5
+ ! ownerDocument.activeElement.classList.contains(
6
+ 'edit-post-visual-editor'
7
+ ) &&
8
+ ownerDocument.activeElement !== ownerDocument.body
9
+ ) {
10
+ return;
11
+ }
12
+
13
+ event.preventDefault();
14
+ window.wp.data.dispatch( 'core/block-editor' ).insertBlock(
15
+ window.wp.blocks.createBlock( 'core/paragraph', {
16
+ content:
17
+ '🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️',
18
+ } )
19
+ );
20
+ },
21
+ };