@wordpress/editor 14.47.0 → 14.48.1

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 (213) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/build/components/block-removal-warnings/index.cjs +0 -3
  3. package/build/components/block-removal-warnings/index.cjs.map +2 -2
  4. package/build/components/collab-sidebar/note-indicator-toolbar.cjs +49 -43
  5. package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +3 -3
  6. package/build/components/collaborators-overlay/use-block-highlighting.cjs +1 -8
  7. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
  8. package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -7
  9. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  10. package/build/components/more-menu/view-more-menu-group.cjs +1 -2
  11. package/build/components/more-menu/view-more-menu-group.cjs.map +2 -2
  12. package/build/components/page-attributes/parent.cjs +1 -0
  13. package/build/components/page-attributes/parent.cjs.map +2 -2
  14. package/build/components/post-publish-button/index.cjs +114 -157
  15. package/build/components/post-publish-button/index.cjs.map +3 -3
  16. package/build/components/post-revisions-preview/block-diff.cjs +21 -9
  17. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  18. package/build/components/post-revisions-preview/preserve-client-ids.cjs +2 -2
  19. package/build/components/post-revisions-preview/preserve-client-ids.cjs.map +2 -2
  20. package/build/components/provider/index.cjs +2 -0
  21. package/build/components/provider/index.cjs.map +3 -3
  22. package/build/components/provider/use-block-editor-settings.cjs +1 -1
  23. package/build/components/provider/use-block-editor-settings.cjs.map +2 -2
  24. package/build/components/provider/use-network-reconnect.cjs +51 -0
  25. package/build/components/provider/use-network-reconnect.cjs.map +7 -0
  26. package/build/components/revision-fields-diff/index.cjs +2 -2
  27. package/build/components/revision-fields-diff/index.cjs.map +2 -2
  28. package/build/components/sidebar/index.cjs +1 -4
  29. package/build/components/sidebar/index.cjs.map +2 -2
  30. package/build/components/template-actions-panel/block-theme-content.cjs +7 -1
  31. package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
  32. package/build/components/upload-progress-snackbar/index.cjs +161 -0
  33. package/build/components/upload-progress-snackbar/index.cjs.map +7 -0
  34. package/build/components/upload-progress-snackbar/tracker.cjs +90 -0
  35. package/build/components/upload-progress-snackbar/tracker.cjs.map +7 -0
  36. package/build/private-apis.cjs +2 -0
  37. package/build/private-apis.cjs.map +3 -3
  38. package/build/store/selectors.cjs +1 -2
  39. package/build/store/selectors.cjs.map +2 -2
  40. package/build/utils/media-upload/index.cjs +16 -0
  41. package/build/utils/media-upload/index.cjs.map +3 -3
  42. package/build-module/components/block-removal-warnings/index.mjs +0 -3
  43. package/build-module/components/block-removal-warnings/index.mjs.map +2 -2
  44. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs +53 -44
  45. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +2 -2
  46. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +1 -8
  47. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  48. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -7
  49. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  50. package/build-module/components/more-menu/view-more-menu-group.mjs +1 -2
  51. package/build-module/components/more-menu/view-more-menu-group.mjs.map +2 -2
  52. package/build-module/components/page-attributes/parent.mjs +1 -0
  53. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  54. package/build-module/components/post-publish-button/index.mjs +116 -159
  55. package/build-module/components/post-publish-button/index.mjs.map +2 -2
  56. package/build-module/components/post-revisions-preview/block-diff.mjs +20 -8
  57. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  58. package/build-module/components/post-revisions-preview/preserve-client-ids.mjs +1 -1
  59. package/build-module/components/post-revisions-preview/preserve-client-ids.mjs.map +1 -1
  60. package/build-module/components/provider/index.mjs +2 -0
  61. package/build-module/components/provider/index.mjs.map +2 -2
  62. package/build-module/components/provider/use-block-editor-settings.mjs +1 -1
  63. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  64. package/build-module/components/provider/use-network-reconnect.mjs +30 -0
  65. package/build-module/components/provider/use-network-reconnect.mjs.map +7 -0
  66. package/build-module/components/revision-fields-diff/index.mjs +2 -2
  67. package/build-module/components/revision-fields-diff/index.mjs.map +2 -2
  68. package/build-module/components/sidebar/index.mjs +2 -11
  69. package/build-module/components/sidebar/index.mjs.map +2 -2
  70. package/build-module/components/template-actions-panel/block-theme-content.mjs +7 -1
  71. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
  72. package/build-module/components/upload-progress-snackbar/index.mjs +135 -0
  73. package/build-module/components/upload-progress-snackbar/index.mjs.map +7 -0
  74. package/build-module/components/upload-progress-snackbar/tracker.mjs +61 -0
  75. package/build-module/components/upload-progress-snackbar/tracker.mjs.map +7 -0
  76. package/build-module/private-apis.mjs +2 -0
  77. package/build-module/private-apis.mjs.map +2 -2
  78. package/build-module/store/selectors.mjs +1 -2
  79. package/build-module/store/selectors.mjs.map +2 -2
  80. package/build-module/utils/media-upload/index.mjs +19 -0
  81. package/build-module/utils/media-upload/index.mjs.map +2 -2
  82. package/build-style/style-rtl.css +479 -84
  83. package/build-style/style.css +479 -84
  84. package/build-types/components/block-removal-warnings/index.d.ts.map +1 -1
  85. package/build-types/components/collab-sidebar/add-comment.d.ts +6 -0
  86. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
  87. package/build-types/components/collab-sidebar/comment-author-info.d.ts +8 -0
  88. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -0
  89. package/build-types/components/collab-sidebar/comment-form.d.ts +9 -0
  90. package/build-types/components/collab-sidebar/comment-form.d.ts.map +1 -0
  91. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +6 -0
  92. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +1 -0
  93. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +6 -0
  94. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +1 -0
  95. package/build-types/components/collab-sidebar/comments.d.ts +10 -0
  96. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
  97. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -1
  98. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +0 -3
  99. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  100. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  101. package/build-types/components/document-bar/index.d.ts +2 -2
  102. package/build-types/components/document-bar/index.d.ts.map +1 -1
  103. package/build-types/components/global-styles-provider/index.d.ts +16 -0
  104. package/build-types/components/global-styles-provider/index.d.ts.map +1 -0
  105. package/build-types/components/media/index.d.ts +3 -0
  106. package/build-types/components/media/index.d.ts.map +1 -0
  107. package/build-types/components/media/metadata-panel.d.ts +12 -0
  108. package/build-types/components/media/metadata-panel.d.ts.map +1 -0
  109. package/build-types/components/media/preview.d.ts +9 -0
  110. package/build-types/components/media/preview.d.ts.map +1 -0
  111. package/build-types/components/more-menu/view-more-menu-group.d.ts.map +1 -1
  112. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  113. package/build-types/components/post-locked-modal/index.d.ts +6 -1
  114. package/build-types/components/post-publish-button/index.d.ts +9 -9
  115. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  116. package/build-types/components/post-revisions-preview/block-diff.d.ts +3 -0
  117. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  118. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +6 -1
  119. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +6 -1
  120. package/build-types/components/post-text-editor/index.d.ts +1 -1
  121. package/build-types/components/post-text-editor/index.d.ts.map +1 -1
  122. package/build-types/components/post-text-editor/utils.d.ts +29 -0
  123. package/build-types/components/post-text-editor/utils.d.ts.map +1 -0
  124. package/build-types/components/provider/index.d.ts.map +1 -1
  125. package/build-types/components/provider/use-network-reconnect.d.ts +8 -0
  126. package/build-types/components/provider/use-network-reconnect.d.ts.map +1 -0
  127. package/build-types/components/revision-fields-diff/index.d.ts +3 -0
  128. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -1
  129. package/build-types/components/sidebar/index.d.ts.map +1 -1
  130. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
  131. package/build-types/components/upload-progress-snackbar/index.d.ts +19 -0
  132. package/build-types/components/upload-progress-snackbar/index.d.ts.map +1 -0
  133. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts +28 -0
  134. package/build-types/components/upload-progress-snackbar/stories/index.story.d.ts.map +1 -0
  135. package/build-types/components/upload-progress-snackbar/tracker.d.ts +41 -0
  136. package/build-types/components/upload-progress-snackbar/tracker.d.ts.map +1 -0
  137. package/build-types/private-apis.d.ts.map +1 -1
  138. package/build-types/store/selectors.d.ts.map +1 -1
  139. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  140. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  141. package/package.json +55 -52
  142. package/src/components/README.md +1 -1
  143. package/src/components/block-removal-warnings/index.js +0 -7
  144. package/src/components/collab-sidebar/note-indicator-toolbar.js +73 -60
  145. package/src/components/collaborators-overlay/use-block-highlighting.ts +0 -9
  146. package/src/components/collaborators-overlay/use-render-cursors.ts +0 -8
  147. package/src/components/collaborators-presence/avatar/test/index.tsx +8 -3
  148. package/src/components/more-menu/view-more-menu-group.js +1 -2
  149. package/src/components/page-attributes/parent.js +1 -0
  150. package/src/components/post-publish-button/index.js +143 -192
  151. package/src/components/post-publish-button/test/index.js +137 -114
  152. package/src/components/post-revisions-preview/block-diff.js +63 -19
  153. package/src/components/post-revisions-preview/preserve-client-ids.js +1 -1
  154. package/src/components/post-revisions-preview/test/block-diff.js +109 -6
  155. package/src/components/provider/index.js +4 -0
  156. package/src/components/provider/test/use-network-reconnect.js +137 -0
  157. package/src/components/provider/use-block-editor-settings.js +2 -2
  158. package/src/components/provider/use-network-reconnect.js +44 -0
  159. package/src/components/revision-fields-diff/index.js +7 -2
  160. package/src/components/sidebar/index.js +2 -11
  161. package/src/components/template-actions-panel/block-theme-content.js +10 -1
  162. package/src/components/upload-progress-snackbar/README.md +26 -0
  163. package/src/components/upload-progress-snackbar/index.js +216 -0
  164. package/src/components/upload-progress-snackbar/stories/index.story.tsx +85 -0
  165. package/src/components/upload-progress-snackbar/style.scss +30 -0
  166. package/src/components/upload-progress-snackbar/test/index.js +199 -0
  167. package/src/components/upload-progress-snackbar/tracker.js +105 -0
  168. package/src/private-apis.js +2 -0
  169. package/src/store/selectors.js +1 -3
  170. package/src/style.scss +1 -0
  171. package/src/utils/media-upload/index.js +27 -0
  172. package/src/components/commands/index.native.js +0 -2
  173. package/src/components/deprecated.native.js +0 -47
  174. package/src/components/editor-help/add-blocks.native.js +0 -40
  175. package/src/components/editor-help/customize-blocks.native.js +0 -40
  176. package/src/components/editor-help/help-detail-navigation-screen.native.js +0 -67
  177. package/src/components/editor-help/help-get-support-button.native.js +0 -38
  178. package/src/components/editor-help/help-section-title.native.js +0 -29
  179. package/src/components/editor-help/help-topic-row.native.js +0 -33
  180. package/src/components/editor-help/icon-move-blocks.native.js +0 -10
  181. package/src/components/editor-help/index.native.js +0 -208
  182. package/src/components/editor-help/intro-to-blocks.native.js +0 -91
  183. package/src/components/editor-help/move-blocks.native.js +0 -55
  184. package/src/components/editor-help/remove-blocks.native.js +0 -35
  185. package/src/components/editor-help/style.android.scss +0 -6
  186. package/src/components/editor-help/style.ios.scss +0 -6
  187. package/src/components/editor-help/test/index.native.js +0 -81
  188. package/src/components/editor-help/view-sections.native.js +0 -79
  189. package/src/components/error-boundary/index.native.js +0 -192
  190. package/src/components/error-boundary/style.native.scss +0 -116
  191. package/src/components/index.native.js +0 -15
  192. package/src/components/offline-status/index.native.js +0 -99
  193. package/src/components/offline-status/style.native.scss +0 -28
  194. package/src/components/offline-status/test/index.native.js +0 -108
  195. package/src/components/post-title/index.native.js +0 -282
  196. package/src/components/post-title/style.native.scss +0 -13
  197. package/src/components/post-title/test/__snapshots__/index.native.js.snap +0 -25
  198. package/src/components/post-title/test/index.native.js +0 -78
  199. package/src/components/provider/index.native.js +0 -497
  200. package/src/components/provider/use-block-editor-settings.native.js +0 -48
  201. package/src/components/template-part-menu-items/index.native.js +0 -3
  202. package/src/hooks/index.native.js +0 -0
  203. package/src/index.native.js +0 -16
  204. package/src/private-apis.native.js +0 -33
  205. package/src/store/actions.native.js +0 -27
  206. package/src/store/reducer.native.js +0 -94
  207. package/src/store/selectors.native.js +0 -57
  208. package/src/store/test/actions.native.js +0 -16
  209. package/src/store/test/reducer.native.js +0 -36
  210. package/src/store/test/selectors.native.js +0 -28
  211. package/src/utils/index.native.js +0 -6
  212. package/src/utils/media-sideload/index.native.js +0 -1
  213. package/src/utils/media-upload/index.native.js +0 -1
@@ -1,497 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { BackHandler } from 'react-native';
5
- import memize from 'memize';
6
- import { SafeAreaProvider } from 'react-native-safe-area-context';
7
-
8
- /**
9
- * WordPress dependencies
10
- */
11
- import RNReactNativeGutenbergBridge, {
12
- requestBlockTypeImpressions,
13
- setBlockTypeImpressions,
14
- subscribeParentGetHtml,
15
- subscribeParentToggleHTMLMode,
16
- subscribeUpdateHtml,
17
- subscribeSetTitle,
18
- subscribeMediaAppend,
19
- subscribeReplaceBlock,
20
- subscribeUpdateEditorSettings,
21
- subscribeUpdateCapabilities,
22
- subscribeShowNotice,
23
- subscribeShowEditorHelp,
24
- subscribeToContentUpdate,
25
- } from '@wordpress/react-native-bridge';
26
- import { Component } from '@wordpress/element';
27
- import { count as wordCount } from '@wordpress/wordcount';
28
- import {
29
- parse,
30
- serialize,
31
- getUnregisteredTypeHandlerName,
32
- getBlockType,
33
- createBlock,
34
- pasteHandler,
35
- } from '@wordpress/blocks';
36
- import { withDispatch, withSelect } from '@wordpress/data';
37
- import { compose } from '@wordpress/compose';
38
- import { applyFilters } from '@wordpress/hooks';
39
- import {
40
- store as blockEditorStore,
41
- getGlobalStyles,
42
- getColorsAndGradients,
43
- } from '@wordpress/block-editor';
44
- import { NEW_BLOCK_TYPES } from '@wordpress/block-library';
45
- import { __ } from '@wordpress/i18n';
46
-
47
- const postTypeEntities = [
48
- { name: 'post', baseURL: '/wp/v2/posts' },
49
- { name: 'page', baseURL: '/wp/v2/pages' },
50
- {
51
- name: 'attachment',
52
- baseURL: '/wp/v2/media',
53
- baseURLParams: { context: 'edit' },
54
- },
55
- { name: 'wp_block', baseURL: '/wp/v2/blocks' },
56
- ].map( ( postTypeEntity ) => ( {
57
- kind: 'postType',
58
- ...postTypeEntity,
59
- transientEdits: {
60
- blocks: true,
61
- selection: true,
62
- },
63
- mergedEdits: {
64
- meta: true,
65
- },
66
- rawAttributes: [ 'title', 'excerpt', 'content' ],
67
- } ) );
68
- import { EditorHelpTopics, store as editorStore } from '@wordpress/editor';
69
- import { store as noticesStore } from '@wordpress/notices';
70
- import { store as coreStore } from '@wordpress/core-data';
71
-
72
- /**
73
- * Internal dependencies
74
- */
75
- import EditorProvider from './index.js';
76
- import { insertContentWithTitle } from '../post-title';
77
-
78
- class NativeEditorProvider extends Component {
79
- constructor() {
80
- super( ...arguments );
81
-
82
- // Keep a local reference to `post` to detect changes.
83
- this.post = this.props.post;
84
- this.props.addEntities( postTypeEntities );
85
- this.props.receiveEntityRecords(
86
- 'postType',
87
- this.post.type,
88
- this.post
89
- );
90
-
91
- this.onHardwareBackPress = this.onHardwareBackPress.bind( this );
92
- this.onContentUpdate = this.onContentUpdate.bind( this );
93
-
94
- this.getEditorSettings = memize(
95
- ( settings, capabilities ) => ( {
96
- ...settings,
97
- capabilities,
98
- } ),
99
- {
100
- maxSize: 1,
101
- }
102
- );
103
- this.state = {
104
- isHelpVisible: false,
105
- };
106
- }
107
-
108
- componentDidMount() {
109
- const {
110
- capabilities,
111
- createErrorNotice,
112
- locale,
113
- hostAppNamespace,
114
- updateEditorSettings,
115
- updateBlockEditorSettings,
116
- } = this.props;
117
-
118
- updateEditorSettings( {
119
- capabilities,
120
- ...this.getThemeColors( this.props ),
121
- locale,
122
- hostAppNamespace,
123
- } );
124
-
125
- this.subscriptionParentGetHtml = subscribeParentGetHtml( () => {
126
- this.serializeToNativeAction();
127
- } );
128
-
129
- this.subscriptionParentToggleHTMLMode = subscribeParentToggleHTMLMode(
130
- () => {
131
- this.toggleMode();
132
- }
133
- );
134
-
135
- this.subscriptionParentSetTitle = subscribeSetTitle( ( payload ) => {
136
- this.props.editTitle( payload.title );
137
- } );
138
-
139
- this.subscriptionParentUpdateHtml = subscribeUpdateHtml(
140
- ( payload ) => {
141
- this.updateHtmlAction( payload.html );
142
- }
143
- );
144
-
145
- this.subscriptionParentReplaceBlock = subscribeReplaceBlock(
146
- ( payload ) => {
147
- this.replaceBlockAction( payload.html, payload.clientId );
148
- }
149
- );
150
-
151
- this.subscriptionParentMediaAppend = subscribeMediaAppend(
152
- ( payload ) => {
153
- const blockName = 'core/' + payload.mediaType;
154
- const blockType = getBlockType( blockName );
155
-
156
- if ( blockType && blockType?.name ) {
157
- const newBlock = createBlock( blockType.name, {
158
- id: payload.mediaId,
159
- [ payload.mediaType === 'image' ? 'url' : 'src' ]:
160
- payload.mediaUrl,
161
- } );
162
-
163
- const indexAfterSelected =
164
- this.props.selectedBlockIndex + 1;
165
- const insertionIndex =
166
- indexAfterSelected || this.props.blockCount;
167
-
168
- this.props.insertBlock( newBlock, insertionIndex );
169
- } else {
170
- createErrorNotice(
171
- __( 'File type not supported as a media file.' )
172
- );
173
- }
174
- }
175
- );
176
-
177
- this.subscriptionParentUpdateEditorSettings =
178
- subscribeUpdateEditorSettings( ( { ...editorSettings } ) => {
179
- updateEditorSettings( this.getThemeColors( editorSettings ) );
180
- } );
181
-
182
- this.subscriptionParentUpdateCapabilities = subscribeUpdateCapabilities(
183
- ( payload ) => {
184
- this.updateCapabilitiesAction( payload );
185
- }
186
- );
187
-
188
- this.subscriptionParentShowNotice = subscribeShowNotice(
189
- ( payload ) => {
190
- this.props.createSuccessNotice( payload.message );
191
- }
192
- );
193
-
194
- this.subscriptionParentShowEditorHelp = subscribeShowEditorHelp( () => {
195
- this.setState( { isHelpVisible: true } );
196
- } );
197
-
198
- this.hardwareBackPressListener = BackHandler.addEventListener(
199
- 'hardwareBackPress',
200
- this.onHardwareBackPress
201
- );
202
-
203
- this.subscriptionOnContentUpdate = subscribeToContentUpdate(
204
- ( data ) => {
205
- this.onContentUpdate( data );
206
- }
207
- );
208
-
209
- // Request current block impressions from native app.
210
- requestBlockTypeImpressions( ( storedImpressions ) => {
211
- const impressions = { ...NEW_BLOCK_TYPES, ...storedImpressions };
212
-
213
- // Persist impressions to JavaScript store.
214
- updateBlockEditorSettings( { impressions } );
215
-
216
- // Persist impressions to native store if they do not include latest
217
- // `NEW_BLOCK_TYPES` configuration.
218
- const storedImpressionKeys = Object.keys( storedImpressions );
219
- const storedImpressionsCurrent = Object.keys(
220
- NEW_BLOCK_TYPES
221
- ).every( ( newKey ) => storedImpressionKeys.includes( newKey ) );
222
- if ( ! storedImpressionsCurrent ) {
223
- setBlockTypeImpressions( impressions );
224
- }
225
- } );
226
- }
227
-
228
- componentWillUnmount() {
229
- if ( this.subscriptionParentGetHtml ) {
230
- this.subscriptionParentGetHtml.remove();
231
- }
232
-
233
- if ( this.subscriptionParentToggleHTMLMode ) {
234
- this.subscriptionParentToggleHTMLMode.remove();
235
- }
236
-
237
- if ( this.subscriptionParentSetTitle ) {
238
- this.subscriptionParentSetTitle.remove();
239
- }
240
-
241
- if ( this.subscriptionParentUpdateHtml ) {
242
- this.subscriptionParentUpdateHtml.remove();
243
- }
244
-
245
- if ( this.subscriptionParentReplaceBlock ) {
246
- this.subscriptionParentReplaceBlock.remove();
247
- }
248
-
249
- if ( this.subscriptionParentMediaAppend ) {
250
- this.subscriptionParentMediaAppend.remove();
251
- }
252
-
253
- if ( this.subscriptionParentUpdateEditorSettings ) {
254
- this.subscriptionParentUpdateEditorSettings.remove();
255
- }
256
-
257
- if ( this.subscriptionParentUpdateCapabilities ) {
258
- this.subscriptionParentUpdateCapabilities.remove();
259
- }
260
-
261
- if ( this.subscriptionParentShowNotice ) {
262
- this.subscriptionParentShowNotice.remove();
263
- }
264
-
265
- if ( this.subscriptionParentShowEditorHelp ) {
266
- this.subscriptionParentShowEditorHelp.remove();
267
- }
268
-
269
- if ( this.hardwareBackPressListener ) {
270
- this.hardwareBackPressListener.remove();
271
- }
272
-
273
- if ( this.subscriptionOnContentUpdate ) {
274
- this.subscriptionOnContentUpdate.remove();
275
- }
276
- }
277
-
278
- getThemeColors( { rawStyles, rawFeatures } ) {
279
- const { defaultEditorColors, defaultEditorGradients } = this.props;
280
-
281
- if ( rawStyles && rawFeatures ) {
282
- return getGlobalStyles( rawStyles, rawFeatures );
283
- }
284
-
285
- return getColorsAndGradients(
286
- defaultEditorColors,
287
- defaultEditorGradients,
288
- rawFeatures
289
- );
290
- }
291
-
292
- componentDidUpdate( prevProps ) {
293
- if ( ! prevProps.isReady && this.props.isReady ) {
294
- const blocks = this.props.blocks;
295
- const isUnsupportedBlock = ( { name } ) =>
296
- name === getUnregisteredTypeHandlerName();
297
- const unsupportedBlockNames = blocks
298
- .filter( isUnsupportedBlock )
299
- .map( ( block ) => block.attributes.originalName );
300
- RNReactNativeGutenbergBridge.editorDidMount(
301
- unsupportedBlockNames
302
- );
303
- }
304
- }
305
-
306
- onHardwareBackPress() {
307
- const { clearSelectedBlock, selectedBlockIndex } = this.props;
308
-
309
- if ( selectedBlockIndex !== -1 ) {
310
- clearSelectedBlock();
311
- return true;
312
- }
313
- return false;
314
- }
315
-
316
- onContentUpdate( { content: rawContent } ) {
317
- const {
318
- editTitle,
319
- onClearPostTitleSelection,
320
- onInsertBlockAfter: onInsertBlocks,
321
- title,
322
- } = this.props;
323
- const content = pasteHandler( {
324
- plainText: rawContent,
325
- } );
326
-
327
- insertContentWithTitle( title, content, editTitle, onInsertBlocks );
328
- onClearPostTitleSelection();
329
- }
330
-
331
- serializeToNativeAction() {
332
- const title = this.props.title;
333
- let html;
334
-
335
- if ( this.props.mode === 'text' ) {
336
- // The HTMLTextInput component does not update the store when user is doing changes
337
- // Let's request the HTML from the component's state directly.
338
- html = applyFilters( 'native.persist-html' );
339
- } else {
340
- html = serialize( this.props.blocks );
341
- }
342
-
343
- const hasChanges =
344
- title !== this.post.title.raw || html !== this.post.content.raw;
345
-
346
- // Variable to store the content structure metrics.
347
- const contentInfo = {};
348
- contentInfo.characterCount = wordCount(
349
- html,
350
- 'characters_including_spaces'
351
- );
352
- contentInfo.wordCount = wordCount( html, 'words' );
353
- contentInfo.paragraphCount = this.props.paragraphCount;
354
- contentInfo.blockCount = this.props.blockCount;
355
- RNReactNativeGutenbergBridge.provideToNative_Html(
356
- html,
357
- title,
358
- hasChanges,
359
- contentInfo
360
- );
361
-
362
- if ( hasChanges ) {
363
- this.post.title.raw = title;
364
- this.post.content.raw = html;
365
- }
366
- }
367
-
368
- updateHtmlAction( html ) {
369
- const parsed = parse( html );
370
- this.props.resetEditorBlocksWithoutUndoLevel( parsed );
371
- }
372
-
373
- replaceBlockAction( html, blockClientId ) {
374
- const parsed = parse( html );
375
- this.props.replaceBlock( blockClientId, parsed );
376
- }
377
-
378
- toggleMode() {
379
- const { mode, switchMode } = this.props;
380
- // Refresh html content first.
381
- this.serializeToNativeAction();
382
- switchMode( mode === 'visual' ? 'text' : 'visual' );
383
- }
384
-
385
- updateCapabilitiesAction( capabilities ) {
386
- this.props.updateEditorSettings( { capabilities } );
387
- }
388
-
389
- render() {
390
- const { children, post, capabilities, settings, ...props } = this.props;
391
- const editorSettings = this.getEditorSettings( settings, capabilities );
392
-
393
- return (
394
- <>
395
- <EditorProvider
396
- post={ this.post }
397
- settings={ editorSettings }
398
- { ...props }
399
- >
400
- <SafeAreaProvider>{ children }</SafeAreaProvider>
401
- </EditorProvider>
402
- <EditorHelpTopics
403
- isVisible={ this.state.isHelpVisible }
404
- onClose={ () => this.setState( { isHelpVisible: false } ) }
405
- close={ () => this.setState( { isHelpVisible: false } ) }
406
- showSupport={ capabilities?.supportSection === true }
407
- />
408
- </>
409
- );
410
- }
411
- }
412
-
413
- const ComposedNativeProvider = compose( [
414
- withSelect( ( select ) => {
415
- const {
416
- __unstableIsEditorReady: isEditorReady,
417
- getEditorBlocks,
418
- getEditedPostAttribute,
419
- getEditedPostContent,
420
- getEditorSettings,
421
- getEditorMode,
422
- } = select( editorStore );
423
-
424
- const { getBlockIndex, getSelectedBlockClientId, getGlobalBlockCount } =
425
- select( blockEditorStore );
426
-
427
- const settings = getEditorSettings();
428
- const defaultEditorColors = settings?.colors ?? [];
429
- const defaultEditorGradients = settings?.gradients ?? [];
430
-
431
- const selectedBlockClientId = getSelectedBlockClientId();
432
- return {
433
- mode: getEditorMode(),
434
- isReady: isEditorReady(),
435
- blocks: getEditorBlocks(),
436
- title: getEditedPostAttribute( 'title' ),
437
- getEditedPostContent,
438
- defaultEditorColors,
439
- defaultEditorGradients,
440
- selectedBlockIndex: getBlockIndex( selectedBlockClientId ),
441
- blockCount: getGlobalBlockCount(),
442
- paragraphCount: getGlobalBlockCount( 'core/paragraph' ),
443
- };
444
- } ),
445
- withDispatch( ( dispatch ) => {
446
- const {
447
- editPost,
448
- resetEditorBlocks,
449
- updateEditorSettings,
450
- switchEditorMode,
451
- togglePostTitleSelection,
452
- } = dispatch( editorStore );
453
- const {
454
- clearSelectedBlock,
455
- updateSettings,
456
- insertBlock,
457
- insertBlocks,
458
- replaceBlock,
459
- } = dispatch( blockEditorStore );
460
- const { addEntities, receiveEntityRecords } = dispatch( coreStore );
461
- const { createSuccessNotice, createErrorNotice } =
462
- dispatch( noticesStore );
463
-
464
- return {
465
- updateBlockEditorSettings: updateSettings,
466
- updateEditorSettings,
467
- addEntities,
468
- insertBlock,
469
- insertBlocks,
470
- createSuccessNotice,
471
- createErrorNotice,
472
- clearSelectedBlock,
473
- editTitle( title ) {
474
- editPost( { title } );
475
- },
476
- receiveEntityRecords,
477
- resetEditorBlocksWithoutUndoLevel( blocks ) {
478
- resetEditorBlocks( blocks, {
479
- __unstableShouldCreateUndoLevel: false,
480
- } );
481
- },
482
- switchMode( mode ) {
483
- switchEditorMode( mode );
484
- },
485
- onInsertBlockAfter( blocks ) {
486
- insertBlocks( blocks, undefined, undefined, false );
487
- },
488
- onClearPostTitleSelection() {
489
- togglePostTitleSelection( false );
490
- },
491
- replaceBlock,
492
- };
493
- } ),
494
- ] )( NativeEditorProvider );
495
-
496
- export default ComposedNativeProvider;
497
- export { ComposedNativeProvider as ExperimentalEditorProvider };
@@ -1,48 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useMemo } from '@wordpress/element';
5
- import { useSelect } from '@wordpress/data';
6
- import { store as coreStore } from '@wordpress/core-data';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import useBlockEditorSettings from './use-block-editor-settings.js';
12
- import { store as editorStore } from '../../store';
13
-
14
- const EMPTY_BLOCKS_LIST = [];
15
-
16
- function useNativeBlockEditorSettings( settings, postType, postId ) {
17
- const editorSettings = useBlockEditorSettings( settings, postType, postId );
18
- const supportReusableBlock = settings.capabilities?.reusableBlock === true;
19
-
20
- const { reusableBlocks, isTitleSelected } = useSelect(
21
- ( select ) => {
22
- return {
23
- reusableBlocks: supportReusableBlock
24
- ? select( coreStore ).getEntityRecords(
25
- 'postType',
26
- 'wp_block',
27
- // Unbounded queries are not supported on native so as a workaround, we set per_page with the maximum value that native version can handle.
28
- // Related issue: https://github.com/wordpress-mobile/gutenberg-mobile/issues/2661
29
- { per_page: 100 }
30
- )
31
- : EMPTY_BLOCKS_LIST,
32
- isTitleSelected: select( editorStore ).isPostTitleSelected(),
33
- };
34
- },
35
- [ supportReusableBlock ]
36
- );
37
-
38
- return useMemo(
39
- () => ( {
40
- ...editorSettings,
41
- __experimentalReusableBlocks: reusableBlocks,
42
- __experimentalShouldInsertAtTheTop: isTitleSelected,
43
- } ),
44
- [ editorSettings, reusableBlocks, isTitleSelected ]
45
- );
46
- }
47
-
48
- export default useNativeBlockEditorSettings;
@@ -1,3 +0,0 @@
1
- export default function TemplatePartMenuItems() {
2
- return null;
3
- }
File without changes
@@ -1,16 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import '@wordpress/block-editor';
5
- import '@wordpress/core-data';
6
- import '@wordpress/rich-text';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import './hooks';
12
-
13
- export { store } from './store';
14
- export * from './components';
15
- export * from './utils';
16
- export * from './private-apis';
@@ -1,33 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import * as interfaceApis from '@wordpress/interface';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import VisualEditor from './components/visual-editor';
10
- import { lock } from './lock-unlock';
11
- import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
12
- import useBlockEditorSettings from './components/provider/use-block-editor-settings';
13
- import PluginPostExcerpt from './components/post-excerpt/plugin';
14
- import PreferencesModal from './components/preferences-modal';
15
- import ToolsMoreMenuGroup from './components/more-menu/tools-more-menu-group';
16
- import ViewMoreMenuGroup from './components/more-menu/view-more-menu-group';
17
-
18
- const { store: interfaceStore, ...remainingInterfaceApis } = interfaceApis;
19
-
20
- export const privateApis = {};
21
- lock( privateApis, {
22
- VisualEditor,
23
- EntitiesSavedStatesExtensible,
24
- PluginPostExcerpt,
25
- PreferencesModal,
26
- ToolsMoreMenuGroup,
27
- ViewMoreMenuGroup,
28
-
29
- // This is a temporary private API while we're updating the site editor to use EditorProvider.
30
- useBlockEditorSettings,
31
- interfaceStore,
32
- ...remainingInterfaceApis,
33
- } );
@@ -1,27 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import RNReactNativeGutenbergBridge from '@wordpress/react-native-bridge';
5
-
6
- export * from './actions.js';
7
-
8
- /**
9
- * Returns an action object that enables or disables post title selection.
10
- *
11
- * @param {boolean} [isSelected=true] Whether post title is currently selected.
12
- *
13
- * @return {Object} Action object.
14
- */
15
- export function togglePostTitleSelection( isSelected = true ) {
16
- return {
17
- type: 'TOGGLE_POST_TITLE_SELECTION',
18
- isSelected,
19
- };
20
- }
21
-
22
- /**
23
- * Action that autosaves the post.
24
- */
25
- export const autosave = () => () => {
26
- RNReactNativeGutenbergBridge.editorDidAutosave();
27
- };