@wordpress/editor 13.6.0 → 13.8.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 (47) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/post-excerpt/index.js +1 -1
  3. package/build/components/post-excerpt/index.js.map +1 -1
  4. package/build/components/post-locked-modal/index.js +7 -5
  5. package/build/components/post-locked-modal/index.js.map +1 -1
  6. package/build/components/post-publish-panel/postpublish.js +5 -0
  7. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  8. package/build/components/post-taxonomies/hierarchical-term-selector.js +13 -7
  9. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  10. package/build/components/post-type-support-check/index.js.map +1 -1
  11. package/build/components/post-url/index.js +1 -1
  12. package/build/components/post-url/index.js.map +1 -1
  13. package/build/components/theme-support-check/index.js.map +1 -1
  14. package/build/hooks/custom-sources-backwards-compatibility.js +18 -10
  15. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  16. package/build/utils/terms.js +21 -10
  17. package/build/utils/terms.js.map +1 -1
  18. package/build-module/components/post-excerpt/index.js +1 -1
  19. package/build-module/components/post-excerpt/index.js.map +1 -1
  20. package/build-module/components/post-locked-modal/index.js +8 -6
  21. package/build-module/components/post-locked-modal/index.js.map +1 -1
  22. package/build-module/components/post-publish-panel/postpublish.js +5 -0
  23. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  24. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +15 -9
  25. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  26. package/build-module/components/post-type-support-check/index.js.map +1 -1
  27. package/build-module/components/post-url/index.js +1 -1
  28. package/build-module/components/post-url/index.js.map +1 -1
  29. package/build-module/components/theme-support-check/index.js.map +1 -1
  30. package/build-module/hooks/custom-sources-backwards-compatibility.js +19 -11
  31. package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  32. package/build-module/utils/terms.js +20 -8
  33. package/build-module/utils/terms.js.map +1 -1
  34. package/build-style/style-rtl.css +4 -23
  35. package/build-style/style.css +4 -23
  36. package/package.json +30 -30
  37. package/src/components/post-excerpt/index.js +1 -1
  38. package/src/components/post-locked-modal/index.js +56 -60
  39. package/src/components/post-locked-modal/style.scss +1 -5
  40. package/src/components/post-publish-panel/postpublish.js +5 -0
  41. package/src/components/post-taxonomies/hierarchical-term-selector.js +26 -21
  42. package/src/components/post-taxonomies/style.scss +5 -20
  43. package/src/components/post-type-support-check/index.js +1 -1
  44. package/src/components/post-url/index.js +1 -1
  45. package/src/components/theme-support-check/index.js +1 -1
  46. package/src/hooks/custom-sources-backwards-compatibility.js +12 -11
  47. package/src/utils/terms.js +17 -7
@@ -9,7 +9,8 @@ import {
9
9
  TextControl,
10
10
  TreeSelect,
11
11
  withFilters,
12
- __experimentalVStack as VStack,
12
+ Flex,
13
+ FlexItem,
13
14
  } from '@wordpress/components';
14
15
  import { useDispatch, useSelect } from '@wordpress/data';
15
16
  import { useDebounce } from '@wordpress/compose';
@@ -392,11 +393,10 @@ export function HierarchicalTermSelector( { slug } ) {
392
393
  const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
393
394
 
394
395
  return (
395
- <>
396
+ <Flex direction="column" gap="4">
396
397
  { showFilter && (
397
398
  <TextControl
398
399
  __nextHasNoMarginBottom
399
- className="editor-post-taxonomies__hierarchical-terms-filter"
400
400
  label={ filterLabel }
401
401
  value={ filterValue }
402
402
  onChange={ setFilter }
@@ -413,18 +413,20 @@ export function HierarchicalTermSelector( { slug } ) {
413
413
  ) }
414
414
  </div>
415
415
  { ! loading && hasCreateAction && (
416
- <Button
417
- onClick={ onToggleForm }
418
- className="editor-post-taxonomies__hierarchical-terms-add"
419
- aria-expanded={ showForm }
420
- variant="link"
421
- >
422
- { newTermButtonLabel }
423
- </Button>
416
+ <FlexItem>
417
+ <Button
418
+ onClick={ onToggleForm }
419
+ className="editor-post-taxonomies__hierarchical-terms-add"
420
+ aria-expanded={ showForm }
421
+ variant="link"
422
+ >
423
+ { newTermButtonLabel }
424
+ </Button>
425
+ </FlexItem>
424
426
  ) }
425
427
  { showForm && (
426
428
  <form onSubmit={ onAddTerm }>
427
- <VStack>
429
+ <Flex direction="column" gap="4">
428
430
  <TextControl
429
431
  __nextHasNoMarginBottom
430
432
  className="editor-post-taxonomies__hierarchical-terms-input"
@@ -435,6 +437,7 @@ export function HierarchicalTermSelector( { slug } ) {
435
437
  />
436
438
  { !! availableTerms.length && (
437
439
  <TreeSelect
440
+ __nextHasNoMarginBottom
438
441
  label={ parentSelectLabel }
439
442
  noOptionLabel={ noParentOption }
440
443
  onChange={ onChangeFormParent }
@@ -442,17 +445,19 @@ export function HierarchicalTermSelector( { slug } ) {
442
445
  tree={ availableTermsTree }
443
446
  />
444
447
  ) }
445
- </VStack>
446
- <Button
447
- variant="secondary"
448
- type="submit"
449
- className="editor-post-taxonomies__hierarchical-terms-submit"
450
- >
451
- { newTermSubmitLabel }
452
- </Button>
448
+ <FlexItem>
449
+ <Button
450
+ variant="secondary"
451
+ type="submit"
452
+ className="editor-post-taxonomies__hierarchical-terms-submit"
453
+ >
454
+ { newTermSubmitLabel }
455
+ </Button>
456
+ </FlexItem>
457
+ </Flex>
453
458
  </form>
454
459
  ) }
455
- </>
460
+ </Flex>
456
461
  );
457
462
  }
458
463
 
@@ -10,32 +10,17 @@
10
10
  }
11
11
 
12
12
  .editor-post-taxonomies__hierarchical-terms-choice {
13
- margin-bottom: 8px;
13
+ margin-bottom: $grid-unit-10;
14
+ &:last-child {
15
+ margin-bottom: $grid-unit-05;
16
+ }
14
17
  }
15
18
 
16
19
  .editor-post-taxonomies__hierarchical-terms-subchoices {
17
- margin-top: 8px;
20
+ margin-top: $grid-unit-10;
18
21
  margin-left: $grid-unit-20;
19
22
  }
20
23
 
21
- .components-button.editor-post-taxonomies__hierarchical-terms-submit,
22
- .components-button.editor-post-taxonomies__hierarchical-terms-add {
23
- margin-top: 12px;
24
- }
25
-
26
- .editor-post-taxonomies__hierarchical-terms-label {
27
- display: inline-block;
28
- margin-top: 12px;
29
- }
30
-
31
- .editor-post-taxonomies__hierarchical-terms-input {
32
- margin-top: 8px;
33
- }
34
- .editor-post-taxonomies__hierarchical-terms-filter {
35
- margin-bottom: 8px;
36
- width: 100%;
37
- }
38
-
39
24
  .editor-post-taxonomies__flat-term-most-used {
40
25
  .editor-post-taxonomies__flat-term-most-used-label {
41
26
  margin-bottom: $grid-unit-05;
@@ -27,7 +27,7 @@ export function PostTypeSupportCheck( { postType, children, supportKeys } ) {
27
27
  if ( postType ) {
28
28
  isSupported = (
29
29
  Array.isArray( supportKeys ) ? supportKeys : [ supportKeys ]
30
- ).some( ( key ) => !! postType.supports[ key ] );
30
+ ).some( ( key ) => !! postType.supports[ key ] );
31
31
  }
32
32
 
33
33
  if ( ! isSupported ) {
@@ -61,7 +61,7 @@ export default function PostURL( { onClose } ) {
61
61
  { __( 'The last part of the URL.' ) }{ ' ' }
62
62
  <ExternalLink
63
63
  href={ __(
64
- 'https://wordpress.org/support/article/settings-sidebar/#permalink'
64
+ 'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'
65
65
  ) }
66
66
  >
67
67
  { __( 'Learn more.' ) }
@@ -17,7 +17,7 @@ export function ThemeSupportCheck( {
17
17
  } ) {
18
18
  const isSupported = (
19
19
  Array.isArray( supportKeys ) ? supportKeys : [ supportKeys ]
20
- ).some( ( key ) => {
20
+ ).some( ( key ) => {
21
21
  const supported = themeSupports?.[ key ] ?? false;
22
22
  // 'post-thumbnails' can be boolean or an array of post types.
23
23
  // In the latter case, we need to verify `postType` exists
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { mapValues, isEmpty } from 'lodash';
4
+ import { isEmpty } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -57,9 +57,13 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
57
57
  const mergedAttributes = useMemo(
58
58
  () => ( {
59
59
  ...attributes,
60
- ...mapValues(
61
- metaAttributes,
62
- ( metaKey ) => meta[ metaKey ]
60
+ ...Object.fromEntries(
61
+ Object.entries( metaAttributes ).map(
62
+ ( [ attributeKey, metaKey ] ) => [
63
+ attributeKey,
64
+ meta[ metaKey ],
65
+ ]
66
+ )
63
67
  ),
64
68
  } ),
65
69
  [ attributes, meta ]
@@ -106,13 +110,10 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
106
110
  */
107
111
  function shimAttributeSource( settings ) {
108
112
  /** @type {WPMetaAttributeMapping} */
109
- const metaAttributes = mapValues(
110
- Object.fromEntries(
111
- Object.entries( settings.attributes ?? {} ).filter(
112
- ( [ , { source } ] ) => source === 'meta'
113
- )
114
- ),
115
- 'meta'
113
+ const metaAttributes = Object.fromEntries(
114
+ Object.entries( settings.attributes ?? {} )
115
+ .filter( ( [ , { source } ] ) => source === 'meta' )
116
+ .map( ( [ attributeKey, { meta } ] ) => [ attributeKey, meta ] )
116
117
  );
117
118
  if ( ! isEmpty( metaAttributes ) ) {
118
119
  settings.edit = createWithMetaAttributeSource( metaAttributes )(
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { groupBy } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -24,10 +19,25 @@ export function buildTermsTree( flatTerms ) {
24
19
  };
25
20
  } );
26
21
 
27
- const termsByParent = groupBy( flatTermsWithParentAndChildren, 'parent' );
28
- if ( termsByParent.null && termsByParent.null.length ) {
22
+ // All terms should have a `parent` because we're about to index them by it.
23
+ if (
24
+ flatTermsWithParentAndChildren.some( ( { parent } ) => parent === null )
25
+ ) {
29
26
  return flatTermsWithParentAndChildren;
30
27
  }
28
+
29
+ const termsByParent = flatTermsWithParentAndChildren.reduce(
30
+ ( acc, term ) => {
31
+ const { parent } = term;
32
+ if ( ! acc[ parent ] ) {
33
+ acc[ parent ] = [];
34
+ }
35
+ acc[ parent ].push( term );
36
+ return acc;
37
+ },
38
+ {}
39
+ );
40
+
31
41
  const fillWithChildren = ( terms ) => {
32
42
  return terms.map( ( term ) => {
33
43
  const children = termsByParent[ term.id ];