@wordpress/edit-site 4.15.0 → 4.16.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-editor/resizable-editor.js +11 -35
  3. package/build/components/block-editor/resizable-editor.js.map +1 -1
  4. package/build/components/global-styles/palette.js +2 -2
  5. package/build/components/global-styles/palette.js.map +1 -1
  6. package/build/components/global-styles/preview.js +2 -2
  7. package/build/components/global-styles/preview.js.map +1 -1
  8. package/build/components/global-styles/screen-typography-element.js +49 -2
  9. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  10. package/build/components/global-styles/typography-panel.js +128 -81
  11. package/build/components/global-styles/typography-panel.js.map +1 -1
  12. package/build/components/global-styles/typography-preview.js +54 -0
  13. package/build/components/global-styles/typography-preview.js.map +1 -0
  14. package/build/components/global-styles/use-global-styles-output.js +7 -7
  15. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  16. package/build/components/main-dashboard-button/index.js +2 -2
  17. package/build/components/main-dashboard-button/index.js.map +1 -1
  18. package/build/index.js +20 -1
  19. package/build/index.js.map +1 -1
  20. package/build-module/components/block-editor/resizable-editor.js +10 -34
  21. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  22. package/build-module/components/global-styles/palette.js +2 -2
  23. package/build-module/components/global-styles/palette.js.map +1 -1
  24. package/build-module/components/global-styles/preview.js +2 -2
  25. package/build-module/components/global-styles/preview.js.map +1 -1
  26. package/build-module/components/global-styles/screen-typography-element.js +48 -2
  27. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  28. package/build-module/components/global-styles/typography-panel.js +129 -83
  29. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  30. package/build-module/components/global-styles/typography-preview.js +46 -0
  31. package/build-module/components/global-styles/typography-preview.js.map +1 -0
  32. package/build-module/components/global-styles/use-global-styles-output.js +7 -7
  33. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  34. package/build-module/components/main-dashboard-button/index.js +3 -3
  35. package/build-module/components/main-dashboard-button/index.js.map +1 -1
  36. package/build-module/index.js +19 -1
  37. package/build-module/index.js.map +1 -1
  38. package/build-style/style-rtl.css +4 -4
  39. package/build-style/style.css +4 -4
  40. package/package.json +29 -29
  41. package/src/components/block-editor/resizable-editor.js +8 -37
  42. package/src/components/global-styles/palette.js +9 -5
  43. package/src/components/global-styles/preview.js +2 -2
  44. package/src/components/global-styles/screen-typography-element.js +65 -1
  45. package/src/components/global-styles/style.scss +3 -3
  46. package/src/components/global-styles/typography-panel.js +192 -150
  47. package/src/components/global-styles/typography-preview.js +49 -0
  48. package/src/components/global-styles/use-global-styles-output.js +15 -9
  49. package/src/components/main-dashboard-button/index.js +3 -3
  50. package/src/components/sidebar/style.scss +1 -1
  51. package/src/index.js +21 -0
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { useStyle } from './hooks';
5
+
6
+ export default function TypographyPreview( { name, element, headingLevel } ) {
7
+ let prefix = '';
8
+ if ( element === 'heading' ) {
9
+ prefix = `elements.${ headingLevel }.`;
10
+ } else if ( element && element !== 'text' ) {
11
+ prefix = `elements.${ element }.`;
12
+ }
13
+
14
+ const [ fontFamily ] = useStyle( prefix + 'typography.fontFamily', name );
15
+ const [ gradientValue ] = useStyle( prefix + 'color.gradient', name );
16
+ const [ backgroundColor ] = useStyle( prefix + 'color.background', name );
17
+ const [ color ] = useStyle( prefix + 'color.text', name );
18
+ const [ fontSize ] = useStyle( prefix + 'typography.fontSize', name );
19
+ const [ fontStyle ] = useStyle( prefix + 'typography.fontStyle', name );
20
+ const [ fontWeight ] = useStyle( prefix + 'typography.fontWeight', name );
21
+ const [ letterSpacing ] = useStyle(
22
+ prefix + 'typography.letterSpacing',
23
+ name
24
+ );
25
+ const extraStyles =
26
+ element === 'link'
27
+ ? {
28
+ textDecoration: 'underline',
29
+ }
30
+ : {};
31
+
32
+ return (
33
+ <div
34
+ className="edit-site-typography-preview"
35
+ style={ {
36
+ fontFamily: fontFamily ?? 'serif',
37
+ background: gradientValue ?? backgroundColor,
38
+ color,
39
+ fontSize,
40
+ fontStyle,
41
+ fontWeight,
42
+ letterSpacing,
43
+ ...extraStyles,
44
+ } }
45
+ >
46
+ Aa
47
+ </div>
48
+ );
49
+ }
@@ -434,9 +434,15 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => {
434
434
 
435
435
  const pickStyleKeys = ( treeToPickFrom ) =>
436
436
  pickBy( treeToPickFrom, ( value, key ) =>
437
- [ 'border', 'color', 'spacing', 'typography', 'filter' ].includes(
438
- key
439
- )
437
+ [
438
+ 'border',
439
+ 'color',
440
+ 'spacing',
441
+ 'typography',
442
+ 'filter',
443
+ 'outline',
444
+ 'shadow',
445
+ ].includes( key )
440
446
  );
441
447
 
442
448
  // Top-level.
@@ -605,12 +611,12 @@ export const toStyles = (
605
611
  }
606
612
 
607
613
  if ( useRootPaddingAlign ) {
608
- ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
609
- .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
610
- .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
611
- .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
612
- .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
613
- .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
614
+ ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
615
+ .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
616
+ .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
617
+ .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
618
+ .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
619
+ .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
614
620
  .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
615
621
  }
616
622
 
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- __experimentalUseSlot as useSlot,
5
+ __experimentalUseSlotFills as useSlotFills,
6
6
  createSlotFill,
7
7
  } from '@wordpress/components';
8
8
 
@@ -13,8 +13,8 @@ const { Fill, Slot: MainDashboardButtonSlot } = createSlotFill( slotName );
13
13
  const MainDashboardButton = Fill;
14
14
 
15
15
  const Slot = ( { children } ) => {
16
- const slot = useSlot( slotName );
17
- const hasFills = Boolean( slot.fills && slot.fills.length );
16
+ const fills = useSlotFills( slotName );
17
+ const hasFills = Boolean( fills && fills.length );
18
18
 
19
19
  if ( ! hasFills ) {
20
20
  return children;
@@ -56,7 +56,7 @@
56
56
  border: 0;
57
57
  }
58
58
 
59
- .edit-site-global-styles-sidebar .components-tools-panel-item.single-column {
59
+ .edit-site-global-styles-sidebar .single-column {
60
60
  grid-column: span 1;
61
61
  }
62
62
 
package/src/index.js CHANGED
@@ -18,6 +18,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
18
18
  import { __ } from '@wordpress/i18n';
19
19
  import { store as viewportStore } from '@wordpress/viewport';
20
20
  import { getQueryArgs } from '@wordpress/url';
21
+ import { addFilter } from '@wordpress/hooks';
21
22
 
22
23
  /**
23
24
  * Internal dependencies
@@ -51,6 +52,26 @@ export function reinitializeEditor( target, settings ) {
51
52
  return;
52
53
  }
53
54
 
55
+ /*
56
+ * Prevent adding the Clasic block in the site editor.
57
+ * Only add the filter when the site editor is initialized, not imported.
58
+ * Also only add the filter(s) after registerCoreBlocks()
59
+ * so that common filters in the block library are not overwritten.
60
+ *
61
+ * This usage here is inspired by previous usage of the filter in the post editor:
62
+ * https://github.com/WordPress/gutenberg/pull/37157
63
+ */
64
+ addFilter(
65
+ 'blockEditor.__unstableCanInsertBlockType',
66
+ 'removeClassicBlockFromInserter',
67
+ ( canInsert, blockType ) => {
68
+ if ( blockType.name === 'core/freeform' ) {
69
+ return false;
70
+ }
71
+ return canInsert;
72
+ }
73
+ );
74
+
54
75
  // This will be a no-op if the target doesn't have any React nodes.
55
76
  unmountComponentAtNode( target );
56
77
  const reboot = reinitializeEditor.bind( null, target, settings );