@wordpress/editor 12.11.0 → 12.14.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 (141) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/document-outline/index.js +7 -9
  3. package/build/components/document-outline/index.js.map +1 -1
  4. package/build/components/editor-history/redo.js +2 -1
  5. package/build/components/editor-history/redo.js.map +1 -1
  6. package/build/components/error-boundary/index.js +3 -0
  7. package/build/components/error-boundary/index.js.map +1 -1
  8. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +11 -1
  9. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  10. package/build/components/index.js +49 -8
  11. package/build/components/index.js.map +1 -1
  12. package/build/components/page-attributes/order.js +3 -7
  13. package/build/components/page-attributes/order.js.map +1 -1
  14. package/build/components/page-attributes/parent.js +7 -3
  15. package/build/components/page-attributes/parent.js.map +1 -1
  16. package/build/components/post-format/index.js +5 -8
  17. package/build/components/post-format/index.js.map +1 -1
  18. package/build/components/post-locked-modal/index.js +1 -1
  19. package/build/components/post-locked-modal/index.js.map +1 -1
  20. package/build/components/post-publish-panel/maybe-category-panel.js +2 -4
  21. package/build/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  22. package/build/components/post-schedule/label.js +3 -3
  23. package/build/components/post-schedule/label.js.map +1 -1
  24. package/build/components/post-slug/index.js +8 -13
  25. package/build/components/post-slug/index.js.map +1 -1
  26. package/build/components/post-taxonomies/flat-term-selector.js +1 -0
  27. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  28. package/build/components/post-taxonomies/hierarchical-term-selector.js +1 -0
  29. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  30. package/build/components/post-taxonomies/index.js +3 -1
  31. package/build/components/post-taxonomies/index.js.map +1 -1
  32. package/build/components/post-template/index.js +1 -2
  33. package/build/components/post-template/index.js.map +1 -1
  34. package/build/components/post-title/index.js +8 -2
  35. package/build/components/post-title/index.js.map +1 -1
  36. package/build/components/post-url/check.js +54 -0
  37. package/build/components/post-url/check.js.map +1 -0
  38. package/build/components/post-url/index.js +115 -0
  39. package/build/components/post-url/index.js.map +1 -0
  40. package/build/components/post-url/label.js +30 -0
  41. package/build/components/post-url/label.js.map +1 -0
  42. package/build/components/post-visibility/label.js +5 -0
  43. package/build/components/post-visibility/label.js.map +1 -1
  44. package/build/components/provider/index.native.js +3 -1
  45. package/build/components/provider/index.native.js.map +1 -1
  46. package/build/components/provider/use-block-editor-settings.js +2 -2
  47. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  48. package/build/components/table-of-contents/panel.js +5 -1
  49. package/build/components/table-of-contents/panel.js.map +1 -1
  50. package/build/components/time-to-read/index.js +60 -0
  51. package/build/components/time-to-read/index.js.map +1 -0
  52. package/build/store/selectors.js +3 -3
  53. package/build/store/selectors.js.map +1 -1
  54. package/build-module/components/document-outline/index.js +7 -8
  55. package/build-module/components/document-outline/index.js.map +1 -1
  56. package/build-module/components/editor-history/redo.js +3 -2
  57. package/build-module/components/editor-history/redo.js.map +1 -1
  58. package/build-module/components/error-boundary/index.js +2 -0
  59. package/build-module/components/error-boundary/index.js.map +1 -1
  60. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +10 -1
  61. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  62. package/build-module/components/index.js +6 -3
  63. package/build-module/components/index.js.map +1 -1
  64. package/build-module/components/page-attributes/order.js +3 -6
  65. package/build-module/components/page-attributes/order.js.map +1 -1
  66. package/build-module/components/page-attributes/parent.js +5 -4
  67. package/build-module/components/page-attributes/parent.js.map +1 -1
  68. package/build-module/components/post-format/index.js +5 -8
  69. package/build-module/components/post-format/index.js.map +1 -1
  70. package/build-module/components/post-locked-modal/index.js +1 -1
  71. package/build-module/components/post-locked-modal/index.js.map +1 -1
  72. package/build-module/components/post-publish-panel/maybe-category-panel.js +2 -4
  73. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  74. package/build-module/components/post-schedule/label.js +3 -3
  75. package/build-module/components/post-schedule/label.js.map +1 -1
  76. package/build-module/components/post-slug/index.js +8 -14
  77. package/build-module/components/post-slug/index.js.map +1 -1
  78. package/build-module/components/post-taxonomies/flat-term-selector.js +1 -2
  79. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  80. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +1 -2
  81. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  82. package/build-module/components/post-taxonomies/index.js +4 -1
  83. package/build-module/components/post-taxonomies/index.js.map +1 -1
  84. package/build-module/components/post-template/index.js +1 -2
  85. package/build-module/components/post-template/index.js.map +1 -1
  86. package/build-module/components/post-title/index.js +8 -2
  87. package/build-module/components/post-title/index.js.map +1 -1
  88. package/build-module/components/post-url/check.js +44 -0
  89. package/build-module/components/post-url/check.js.map +1 -0
  90. package/build-module/components/post-url/index.js +102 -0
  91. package/build-module/components/post-url/index.js.map +1 -0
  92. package/build-module/components/post-url/label.js +18 -0
  93. package/build-module/components/post-url/label.js.map +1 -0
  94. package/build-module/components/post-visibility/label.js +3 -0
  95. package/build-module/components/post-visibility/label.js.map +1 -1
  96. package/build-module/components/provider/index.native.js +3 -1
  97. package/build-module/components/provider/index.native.js.map +1 -1
  98. package/build-module/components/provider/use-block-editor-settings.js +2 -2
  99. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  100. package/build-module/components/table-of-contents/panel.js +4 -1
  101. package/build-module/components/table-of-contents/panel.js.map +1 -1
  102. package/build-module/components/time-to-read/index.js +50 -0
  103. package/build-module/components/time-to-read/index.js.map +1 -0
  104. package/build-module/store/selectors.js +4 -4
  105. package/build-module/store/selectors.js.map +1 -1
  106. package/build-style/style-rtl.css +18 -17
  107. package/build-style/style.css +22 -17
  108. package/package.json +30 -29
  109. package/src/components/README.md +1 -1
  110. package/src/components/document-outline/index.js +9 -8
  111. package/src/components/editor-history/redo.js +6 -2
  112. package/src/components/error-boundary/index.js +3 -0
  113. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +13 -0
  114. package/src/components/index.js +9 -3
  115. package/src/components/page-attributes/order.js +1 -9
  116. package/src/components/page-attributes/parent.js +5 -11
  117. package/src/components/post-format/index.js +13 -19
  118. package/src/components/post-format/style.scss +2 -17
  119. package/src/components/post-locked-modal/index.js +1 -1
  120. package/src/components/post-publish-panel/maybe-category-panel.js +3 -5
  121. package/src/components/post-schedule/label.js +1 -1
  122. package/src/components/post-slug/index.js +7 -13
  123. package/src/components/post-slug/test/index.js +7 -6
  124. package/src/components/post-taxonomies/flat-term-selector.js +1 -1
  125. package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -1
  126. package/src/components/post-taxonomies/index.js +3 -1
  127. package/src/components/post-template/index.js +1 -1
  128. package/src/components/post-title/index.js +8 -2
  129. package/src/components/post-trash/style.scss +3 -0
  130. package/src/components/post-url/check.js +38 -0
  131. package/src/components/post-url/index.js +122 -0
  132. package/src/components/post-url/label.js +22 -0
  133. package/src/components/post-url/style.scss +16 -0
  134. package/src/components/post-visibility/label.js +4 -0
  135. package/src/components/provider/index.native.js +3 -1
  136. package/src/components/provider/use-block-editor-settings.js +5 -1
  137. package/src/components/table-of-contents/panel.js +7 -2
  138. package/src/components/time-to-read/index.js +59 -0
  139. package/src/store/selectors.js +5 -6
  140. package/src/store/test/selectors.js +1 -1
  141. package/src/style.scss +1 -0
@@ -0,0 +1,16 @@
1
+ .editor-post-url__link-label {
2
+ font-size: $default-font-size;
3
+ font-weight: 400;
4
+ margin: 0;
5
+ }
6
+
7
+ /* rtl:begin:ignore */
8
+ .editor-post-url__link {
9
+ direction: ltr;
10
+ word-break: break-word;
11
+ }
12
+ /* rtl:end:ignore */
13
+
14
+ .editor-post-url__link-slug {
15
+ font-weight: 600;
16
+ }
@@ -10,6 +10,10 @@ import { visibilityOptions } from './utils';
10
10
  import { store as editorStore } from '../../store';
11
11
 
12
12
  export default function PostVisibilityLabel() {
13
+ return usePostVisibilityLabel();
14
+ }
15
+
16
+ export function usePostVisibilityLabel() {
13
17
  const visibility = useSelect( ( select ) =>
14
18
  select( editorStore ).getEditedPostVisibility()
15
19
  );
@@ -91,12 +91,14 @@ class NativeEditorProvider extends Component {
91
91
  }
92
92
 
93
93
  componentDidMount() {
94
- const { capabilities, locale, updateSettings } = this.props;
94
+ const { capabilities, locale, hostAppNamespace, updateSettings } =
95
+ this.props;
95
96
 
96
97
  updateSettings( {
97
98
  ...capabilities,
98
99
  ...this.getThemeColors( this.props ),
99
100
  locale,
101
+ hostAppNamespace,
100
102
  } );
101
103
 
102
104
  this.subscriptionParentGetHtml = subscribeParentGetHtml( () => {
@@ -41,7 +41,9 @@ function useBlockEditorSettings( settings, hasTemplate ) {
41
41
  const isWeb = Platform.OS === 'web';
42
42
  const { canUser, getEntityRecord } = select( coreStore );
43
43
 
44
- const siteSettings = getEntityRecord( 'root', 'site' );
44
+ const siteSettings = canUser( 'read', 'settings' )
45
+ ? getEntityRecord( 'root', 'site' )
46
+ : undefined;
45
47
 
46
48
  return {
47
49
  canUseUnfilteredHTML: canUserUseUnfilteredHTML(),
@@ -127,6 +129,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
127
129
  'disableCustomColors',
128
130
  'disableCustomFontSizes',
129
131
  'disableCustomGradients',
132
+ 'disableLayoutStyles',
130
133
  'enableCustomLineHeight',
131
134
  'enableCustomSpacing',
132
135
  'enableCustomUnits',
@@ -136,6 +139,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
136
139
  'generateAnchors',
137
140
  'hasFixedToolbar',
138
141
  'hasReducedUI',
142
+ 'hasInlineToolbar',
139
143
  'imageDefaultSize',
140
144
  'imageDimensions',
141
145
  'imageEditing',
@@ -9,6 +9,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
9
9
  * Internal dependencies
10
10
  */
11
11
  import WordCount from '../word-count';
12
+ import TimeToRead from '../time-to-read';
12
13
  import DocumentOutline from '../document-outline';
13
14
  import CharacterCount from '../character-count';
14
15
 
@@ -38,6 +39,10 @@ function TableOfContentsPanel( { hasOutlineItemsDisabled, onRequestClose } ) {
38
39
  tabIndex="0"
39
40
  >
40
41
  <ul role="list" className="table-of-contents__counts">
42
+ <li className="table-of-contents__count">
43
+ { __( 'Words' ) }
44
+ <WordCount />
45
+ </li>
41
46
  <li className="table-of-contents__count">
42
47
  { __( 'Characters' ) }
43
48
  <span className="table-of-contents__number">
@@ -45,8 +50,8 @@ function TableOfContentsPanel( { hasOutlineItemsDisabled, onRequestClose } ) {
45
50
  </span>
46
51
  </li>
47
52
  <li className="table-of-contents__count">
48
- { __( 'Words' ) }
49
- <WordCount />
53
+ { __( 'Time to read' ) }
54
+ <TimeToRead />
50
55
  </li>
51
56
  <li className="table-of-contents__count">
52
57
  { __( 'Headings' ) }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { _x, _n, __, sprintf } from '@wordpress/i18n';
6
+ import { count as wordCount } from '@wordpress/wordcount';
7
+ import { createInterpolateElement } from '@wordpress/element';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { store as editorStore } from '../../store';
13
+
14
+ /**
15
+ * Average reading rate - based on average taken from
16
+ * https://irisreading.com/average-reading-speed-in-various-languages/
17
+ * (Characters/minute used for Chinese rather than words).
18
+ *
19
+ * @type {number} A rough estimate of the average reading rate across multiple languages.
20
+ */
21
+ const AVERAGE_READING_RATE = 189;
22
+
23
+ export default function TimeToRead() {
24
+ const content = useSelect(
25
+ ( select ) => select( editorStore ).getEditedPostAttribute( 'content' ),
26
+ []
27
+ );
28
+
29
+ /*
30
+ * translators: If your word count is based on single characters (e.g. East Asian characters),
31
+ * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
32
+ * Do not translate into your own language.
33
+ */
34
+ const wordCountType = _x( 'words', 'Word count type. Do not translate!' );
35
+ const minutesToRead = Math.round(
36
+ wordCount( content, wordCountType ) / AVERAGE_READING_RATE
37
+ );
38
+ const minutesToReadString =
39
+ minutesToRead === 0
40
+ ? createInterpolateElement( __( '<span>< 1</span> minute' ), {
41
+ span: <span className="table-of-contents__number" />,
42
+ } )
43
+ : createInterpolateElement(
44
+ sprintf(
45
+ /* translators: %s is the number of minutes the post will take to read. */
46
+ _n(
47
+ '<span>%d</span> minute',
48
+ '<span>%d</span> minutes',
49
+ minutesToRead
50
+ ),
51
+ minutesToRead
52
+ ),
53
+ {
54
+ span: <span className="table-of-contents__number" />,
55
+ }
56
+ );
57
+
58
+ return <span className="time-to-read">{ minutesToReadString }</span>;
59
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { find, get, has, isString, includes, some } from 'lodash';
4
+ import { find, get, has, includes, some } from 'lodash';
5
5
  import createSelector from 'rememo';
6
6
 
7
7
  /**
@@ -534,7 +534,7 @@ export function isEditedPostEmpty( state ) {
534
534
 
535
535
  if ( blocks.length ) {
536
536
  // Pierce the abstraction of the serializer in knowing that blocks are
537
- // joined with with newlines such that even if every individual block
537
+ // joined with newlines such that even if every individual block
538
538
  // produces an empty save result, the serialized content is non-empty.
539
539
  if ( blocks.length > 1 ) {
540
540
  return false;
@@ -1605,10 +1605,9 @@ export function __experimentalGetTemplateInfo( state, template ) {
1605
1605
  const { title: defaultTitle, description: defaultDescription } =
1606
1606
  __experimentalGetDefaultTemplateType( state, slug );
1607
1607
 
1608
- const templateTitle = isString( title ) ? title : title?.rendered;
1609
- const templateDescription = isString( description )
1610
- ? description
1611
- : description?.raw;
1608
+ const templateTitle = typeof title === 'string' ? title : title?.rendered;
1609
+ const templateDescription =
1610
+ typeof description === 'string' ? description : description?.raw;
1612
1611
  const templateIcon =
1613
1612
  __experimentalGetDefaultTemplatePartAreas( state ).find(
1614
1613
  ( item ) => area === item.area
@@ -1599,7 +1599,7 @@ describe( 'selectors', () => {
1599
1599
 
1600
1600
  for ( const variantField of fields ) {
1601
1601
  for ( const constantField of fields.filter(
1602
- ( f ) => ! f === variantField
1602
+ ( f ) => f !== variantField
1603
1603
  ) ) {
1604
1604
  const state = {
1605
1605
  editor: {
package/src/style.scss CHANGED
@@ -14,6 +14,7 @@
14
14
  @import "./components/post-saved-state/style.scss";
15
15
  @import "./components/post-taxonomies/style.scss";
16
16
  @import "./components/post-text-editor/style.scss";
17
+ @import "./components/post-url/style.scss";
17
18
  @import "./components/post-visibility/style.scss";
18
19
  @import "./components/post-title/style.scss";
19
20
  @import "./components/post-trash/style.scss";