@wordpress/edit-post 8.48.0 → 8.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.
- package/CHANGELOG.md +3 -1
- package/build/components/layout/index.cjs +3 -2
- package/build/components/layout/index.cjs.map +2 -2
- package/build-module/components/layout/index.mjs +3 -2
- package/build-module/components/layout/index.mjs.map +2 -2
- package/build-style/style-rtl.css +7 -3
- package/build-style/style.css +7 -3
- package/package.json +39 -35
- package/src/components/layout/index.js +3 -1
- package/src/components/header/header-toolbar/index.native.js +0 -255
- package/src/components/header/header-toolbar/style.native.scss +0 -49
- package/src/components/header/index.native.js +0 -60
- package/src/components/layout/index.native.js +0 -207
- package/src/components/layout/style.native.scss +0 -26
- package/src/components/visual-editor/header.native.js +0 -58
- package/src/components/visual-editor/index.native.js +0 -33
- package/src/components/visual-editor/test/__snapshots__/index.native.js.snap +0 -15
- package/src/components/visual-editor/test/index.native.js +0 -221
- package/src/editor.native.js +0 -171
- package/src/index.native.js +0 -41
- package/src/test/__snapshots__/editor.native.js.snap +0 -105
- package/src/test/editor.native.js +0 -263
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useCallback, useRef, useEffect, Platform } from '@wordpress/element';
|
|
10
|
-
import { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
11
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
12
|
-
import { withViewportMatch } from '@wordpress/viewport';
|
|
13
|
-
import { __ } from '@wordpress/i18n';
|
|
14
|
-
import {
|
|
15
|
-
Inserter,
|
|
16
|
-
BlockToolbar,
|
|
17
|
-
store as blockEditorStore,
|
|
18
|
-
} from '@wordpress/block-editor';
|
|
19
|
-
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
|
|
20
|
-
import {
|
|
21
|
-
keyboardClose,
|
|
22
|
-
audio as audioIcon,
|
|
23
|
-
media as imageIcon,
|
|
24
|
-
video as videoIcon,
|
|
25
|
-
gallery as galleryIcon,
|
|
26
|
-
} from '@wordpress/icons';
|
|
27
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
28
|
-
import { createBlock } from '@wordpress/blocks';
|
|
29
|
-
import {
|
|
30
|
-
toggleUndoButton,
|
|
31
|
-
toggleRedoButton,
|
|
32
|
-
subscribeOnUndoPressed,
|
|
33
|
-
subscribeOnRedoPressed,
|
|
34
|
-
} from '@wordpress/react-native-bridge';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal dependencies
|
|
38
|
-
*/
|
|
39
|
-
import styles from './style.scss';
|
|
40
|
-
import { store as editPostStore } from '../../../store';
|
|
41
|
-
|
|
42
|
-
const shadowStyle = {
|
|
43
|
-
shadowOffset: { width: 2, height: 2 },
|
|
44
|
-
shadowOpacity: 1,
|
|
45
|
-
shadowRadius: 6,
|
|
46
|
-
elevation: 18,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
function HeaderToolbar( {
|
|
50
|
-
hasRedo,
|
|
51
|
-
hasUndo,
|
|
52
|
-
redo,
|
|
53
|
-
undo,
|
|
54
|
-
showInserter,
|
|
55
|
-
showKeyboardHideButton,
|
|
56
|
-
insertBlock,
|
|
57
|
-
onHideKeyboard,
|
|
58
|
-
isRTL,
|
|
59
|
-
noContentSelected,
|
|
60
|
-
} ) {
|
|
61
|
-
const anchorNodeRef = useRef();
|
|
62
|
-
|
|
63
|
-
const containerStyle = [
|
|
64
|
-
usePreferredColorSchemeStyle(
|
|
65
|
-
styles[ 'header-toolbar__container' ],
|
|
66
|
-
styles[ 'header-toolbar__container--dark' ]
|
|
67
|
-
),
|
|
68
|
-
{ borderTopWidth: StyleSheet.hairlineWidth },
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
useEffect( () => {
|
|
72
|
-
const onUndoSubscription = subscribeOnUndoPressed( undo );
|
|
73
|
-
const onRedoSubscription = subscribeOnRedoPressed( redo );
|
|
74
|
-
|
|
75
|
-
return () => {
|
|
76
|
-
onUndoSubscription?.remove();
|
|
77
|
-
onRedoSubscription?.remove();
|
|
78
|
-
};
|
|
79
|
-
}, [ undo, redo ] );
|
|
80
|
-
|
|
81
|
-
useEffect( () => {
|
|
82
|
-
toggleUndoButton( ! hasUndo );
|
|
83
|
-
}, [ hasUndo ] );
|
|
84
|
-
|
|
85
|
-
useEffect( () => {
|
|
86
|
-
toggleRedoButton( ! hasRedo );
|
|
87
|
-
}, [ hasRedo ] );
|
|
88
|
-
|
|
89
|
-
const scrollViewRef = useRef( null );
|
|
90
|
-
const scrollToStart = () => {
|
|
91
|
-
// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android
|
|
92
|
-
if ( Platform.isAndroid && isRTL ) {
|
|
93
|
-
scrollViewRef.current.scrollToEnd();
|
|
94
|
-
} else {
|
|
95
|
-
scrollViewRef.current.scrollTo( { x: 0 } );
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const onInsertBlock = useCallback(
|
|
100
|
-
( blockType ) => () => {
|
|
101
|
-
insertBlock( createBlock( blockType ), undefined, undefined, true, {
|
|
102
|
-
source: 'inserter_menu',
|
|
103
|
-
inserterMethod: 'quick-inserter',
|
|
104
|
-
} );
|
|
105
|
-
},
|
|
106
|
-
[ insertBlock ]
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const renderMediaButtons = (
|
|
110
|
-
<ToolbarGroup>
|
|
111
|
-
<ToolbarButton
|
|
112
|
-
key="imageButton"
|
|
113
|
-
title={ __( 'Image' ) }
|
|
114
|
-
icon={ imageIcon }
|
|
115
|
-
onClick={ onInsertBlock( 'core/image' ) }
|
|
116
|
-
testID="insert-image-button"
|
|
117
|
-
extraProps={ {
|
|
118
|
-
hint: __( 'Insert Image Block' ),
|
|
119
|
-
} }
|
|
120
|
-
/>
|
|
121
|
-
<ToolbarButton
|
|
122
|
-
key="videoButton"
|
|
123
|
-
title={ __( 'Video' ) }
|
|
124
|
-
icon={ videoIcon }
|
|
125
|
-
onClick={ onInsertBlock( 'core/video' ) }
|
|
126
|
-
testID="insert-video-button"
|
|
127
|
-
extraProps={ {
|
|
128
|
-
hint: __( 'Insert Video Block' ),
|
|
129
|
-
} }
|
|
130
|
-
/>
|
|
131
|
-
<ToolbarButton
|
|
132
|
-
key="galleryButton"
|
|
133
|
-
title={ __( 'Gallery' ) }
|
|
134
|
-
icon={ galleryIcon }
|
|
135
|
-
onClick={ onInsertBlock( 'core/gallery' ) }
|
|
136
|
-
testID="insert-gallery-button"
|
|
137
|
-
extraProps={ {
|
|
138
|
-
hint: __( 'Insert Gallery Block' ),
|
|
139
|
-
} }
|
|
140
|
-
/>
|
|
141
|
-
<ToolbarButton
|
|
142
|
-
key="audioButton"
|
|
143
|
-
title={ __( 'Audio' ) }
|
|
144
|
-
icon={ audioIcon }
|
|
145
|
-
onClick={ onInsertBlock( 'core/audio' ) }
|
|
146
|
-
testID="insert-audio-button"
|
|
147
|
-
extraProps={ {
|
|
148
|
-
hint: __( 'Insert Audio Block' ),
|
|
149
|
-
} }
|
|
150
|
-
/>
|
|
151
|
-
</ToolbarGroup>
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
/* translators: accessibility text for the editor toolbar */
|
|
155
|
-
const toolbarAriaLabel = __( 'Document tools' );
|
|
156
|
-
|
|
157
|
-
const shadowColor = usePreferredColorSchemeStyle(
|
|
158
|
-
styles[ 'header-toolbar__keyboard-hide-shadow--light' ],
|
|
159
|
-
styles[ 'header-toolbar__keyboard-hide-shadow--dark' ]
|
|
160
|
-
);
|
|
161
|
-
const showKeyboardButtonStyles = [
|
|
162
|
-
usePreferredColorSchemeStyle(
|
|
163
|
-
styles[ 'header-toolbar__keyboard-hide-container' ],
|
|
164
|
-
styles[ 'header-toolbar__keyboard-hide-container--dark' ]
|
|
165
|
-
),
|
|
166
|
-
shadowStyle,
|
|
167
|
-
{
|
|
168
|
-
shadowColor: Platform.isAndroid
|
|
169
|
-
? styles[ 'header-toolbar__keyboard-hide-shadow--solid' ].color
|
|
170
|
-
: shadowColor.color,
|
|
171
|
-
},
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
return (
|
|
175
|
-
<View
|
|
176
|
-
ref={ anchorNodeRef }
|
|
177
|
-
testID={ toolbarAriaLabel }
|
|
178
|
-
accessibilityLabel={ toolbarAriaLabel }
|
|
179
|
-
style={ containerStyle }
|
|
180
|
-
>
|
|
181
|
-
<ScrollView
|
|
182
|
-
ref={ scrollViewRef }
|
|
183
|
-
onContentSizeChange={ scrollToStart }
|
|
184
|
-
horizontal
|
|
185
|
-
showsHorizontalScrollIndicator={ false }
|
|
186
|
-
keyboardShouldPersistTaps="always"
|
|
187
|
-
alwaysBounceHorizontal={ false }
|
|
188
|
-
contentContainerStyle={
|
|
189
|
-
styles[ 'header-toolbar__scrollable-content' ]
|
|
190
|
-
}
|
|
191
|
-
>
|
|
192
|
-
<Inserter disabled={ ! showInserter } />
|
|
193
|
-
|
|
194
|
-
{ noContentSelected && renderMediaButtons }
|
|
195
|
-
<BlockToolbar anchorNodeRef={ anchorNodeRef.current } />
|
|
196
|
-
</ScrollView>
|
|
197
|
-
{ showKeyboardHideButton && (
|
|
198
|
-
<ToolbarGroup passedStyle={ showKeyboardButtonStyles }>
|
|
199
|
-
<ToolbarButton
|
|
200
|
-
title={ __( 'Hide keyboard' ) }
|
|
201
|
-
icon={ keyboardClose }
|
|
202
|
-
onClick={ onHideKeyboard }
|
|
203
|
-
extraProps={ {
|
|
204
|
-
hint: __( 'Tap to hide the keyboard' ),
|
|
205
|
-
} }
|
|
206
|
-
/>
|
|
207
|
-
</ToolbarGroup>
|
|
208
|
-
) }
|
|
209
|
-
</View>
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export default compose( [
|
|
214
|
-
withSelect( ( select ) => {
|
|
215
|
-
const {
|
|
216
|
-
getBlockRootClientId,
|
|
217
|
-
getBlockSelectionEnd,
|
|
218
|
-
hasInserterItems,
|
|
219
|
-
hasSelectedBlock,
|
|
220
|
-
} = select( blockEditorStore );
|
|
221
|
-
const { getEditorSettings } = select( editorStore );
|
|
222
|
-
const isAnyBlockSelected = hasSelectedBlock();
|
|
223
|
-
return {
|
|
224
|
-
hasRedo: select( editorStore ).hasEditorRedo(),
|
|
225
|
-
hasUndo: select( editorStore ).hasEditorUndo(),
|
|
226
|
-
// This setting (richEditingEnabled) should not live in the block editor's setting.
|
|
227
|
-
showInserter:
|
|
228
|
-
select( editPostStore ).getEditorMode() === 'visual' &&
|
|
229
|
-
getEditorSettings().richEditingEnabled &&
|
|
230
|
-
hasInserterItems(
|
|
231
|
-
getBlockRootClientId( getBlockSelectionEnd() )
|
|
232
|
-
),
|
|
233
|
-
isTextModeEnabled:
|
|
234
|
-
select( editPostStore ).getEditorMode() === 'text',
|
|
235
|
-
isRTL: select( blockEditorStore ).getSettings().isRTL,
|
|
236
|
-
noContentSelected: ! isAnyBlockSelected,
|
|
237
|
-
};
|
|
238
|
-
} ),
|
|
239
|
-
withDispatch( ( dispatch ) => {
|
|
240
|
-
const { clearSelectedBlock, insertBlock } =
|
|
241
|
-
dispatch( blockEditorStore );
|
|
242
|
-
const { togglePostTitleSelection } = dispatch( editorStore );
|
|
243
|
-
|
|
244
|
-
return {
|
|
245
|
-
redo: dispatch( editorStore ).redo,
|
|
246
|
-
undo: dispatch( editorStore ).undo,
|
|
247
|
-
onHideKeyboard() {
|
|
248
|
-
clearSelectedBlock();
|
|
249
|
-
togglePostTitleSelection( false );
|
|
250
|
-
},
|
|
251
|
-
insertBlock,
|
|
252
|
-
};
|
|
253
|
-
} ),
|
|
254
|
-
withViewportMatch( { isLargeViewport: 'medium' } ),
|
|
255
|
-
] )( HeaderToolbar );
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
.header-toolbar__container {
|
|
3
|
-
height: $mobile-header-toolbar-height;
|
|
4
|
-
flex-direction: row;
|
|
5
|
-
background-color: $app-background;
|
|
6
|
-
border-top-color: $light-quaternary;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.header-toolbar__container--dark {
|
|
11
|
-
background-color: $app-safe-area-background-dark;
|
|
12
|
-
border-top-color: $dark-quaternary;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.header-toolbar__container--expanded {
|
|
16
|
-
height: $mobile-header-toolbar-expanded-height;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.header-toolbar__scrollable-content {
|
|
20
|
-
flex-grow: 1; // Fixes RTL issue on Android.
|
|
21
|
-
padding-right: 8px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.header-toolbar__keyboard-hide-container {
|
|
25
|
-
padding-right: 0;
|
|
26
|
-
padding-left: 0;
|
|
27
|
-
padding-top: 4px;
|
|
28
|
-
width: 44px;
|
|
29
|
-
justify-content: center;
|
|
30
|
-
align-items: center;
|
|
31
|
-
border-color: transparent;
|
|
32
|
-
background-color: $app-background;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.header-toolbar__keyboard-hide-container--dark {
|
|
36
|
-
background-color: $app-background-dark-alt;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.header-toolbar__keyboard-hide-shadow--solid {
|
|
40
|
-
color: $black;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.header-toolbar__keyboard-hide-shadow--light {
|
|
44
|
-
color: $light-quaternary;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.header-toolbar__keyboard-hide-shadow--dark {
|
|
48
|
-
color: $light-primary;
|
|
49
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Keyboard } from 'react-native';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Component } from '@wordpress/element';
|
|
10
|
-
import '@wordpress/editor';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import HeaderToolbar from './header-toolbar';
|
|
16
|
-
|
|
17
|
-
export default class Header extends Component {
|
|
18
|
-
constructor() {
|
|
19
|
-
super( ...arguments );
|
|
20
|
-
|
|
21
|
-
this.keyboardDidShow = this.keyboardDidShow.bind( this );
|
|
22
|
-
this.keyboardDidHide = this.keyboardDidHide.bind( this );
|
|
23
|
-
|
|
24
|
-
this.state = {
|
|
25
|
-
isKeyboardVisible: false,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
componentDidMount() {
|
|
30
|
-
this.keyboardShowSubscription = Keyboard.addListener(
|
|
31
|
-
'keyboardDidShow',
|
|
32
|
-
this.keyboardDidShow
|
|
33
|
-
);
|
|
34
|
-
this.keyboardHideSubscription = Keyboard.addListener(
|
|
35
|
-
'keyboardDidHide',
|
|
36
|
-
this.keyboardDidHide
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
componentWillUnmount() {
|
|
41
|
-
this.keyboardShowSubscription.remove();
|
|
42
|
-
this.keyboardHideSubscription.remove();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
keyboardDidShow() {
|
|
46
|
-
this.setState( { isKeyboardVisible: true } );
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
keyboardDidHide() {
|
|
50
|
-
this.setState( { isKeyboardVisible: false } );
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
render() {
|
|
54
|
-
return (
|
|
55
|
-
<HeaderToolbar
|
|
56
|
-
showKeyboardHideButton={ this.state.isKeyboardVisible }
|
|
57
|
-
/>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Platform, SafeAreaView, View } from 'react-native';
|
|
5
|
-
import SafeArea from 'react-native-safe-area';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { Component } from '@wordpress/element';
|
|
11
|
-
import { withSelect } from '@wordpress/data';
|
|
12
|
-
import {
|
|
13
|
-
BottomSheetSettings,
|
|
14
|
-
FloatingToolbar,
|
|
15
|
-
store as blockEditorStore,
|
|
16
|
-
} from '@wordpress/block-editor';
|
|
17
|
-
import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
18
|
-
import {
|
|
19
|
-
HTMLTextInput,
|
|
20
|
-
KeyboardAvoidingView,
|
|
21
|
-
NoticeList,
|
|
22
|
-
Tooltip as WCTooltip,
|
|
23
|
-
__unstableAutocompletionItemsSlot as AutocompletionItemsSlot,
|
|
24
|
-
} from '@wordpress/components';
|
|
25
|
-
import {
|
|
26
|
-
AutosaveMonitor,
|
|
27
|
-
OfflineStatus,
|
|
28
|
-
store as editorStore,
|
|
29
|
-
} from '@wordpress/editor';
|
|
30
|
-
import { sendNativeEditorDidLayout } from '@wordpress/react-native-bridge';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Internal dependencies
|
|
34
|
-
*/
|
|
35
|
-
import styles from './style.scss';
|
|
36
|
-
import headerToolbarStyles from '../header/header-toolbar/style.scss';
|
|
37
|
-
import Header from '../header';
|
|
38
|
-
import VisualEditor from '../visual-editor';
|
|
39
|
-
|
|
40
|
-
class Layout extends Component {
|
|
41
|
-
constructor() {
|
|
42
|
-
super( ...arguments );
|
|
43
|
-
|
|
44
|
-
this.onSafeAreaInsetsUpdate = this.onSafeAreaInsetsUpdate.bind( this );
|
|
45
|
-
this.onRootViewLayout = this.onRootViewLayout.bind( this );
|
|
46
|
-
|
|
47
|
-
this.state = {
|
|
48
|
-
rootViewHeight: 0,
|
|
49
|
-
safeAreaInsets: { top: 0, bottom: 0, right: 0, left: 0 },
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
SafeArea.getSafeAreaInsetsForRootView().then(
|
|
53
|
-
this.onSafeAreaInsetsUpdate
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
componentDidMount() {
|
|
58
|
-
this._isMounted = true;
|
|
59
|
-
this.safeAreaSubscription = SafeArea.addEventListener(
|
|
60
|
-
'safeAreaInsetsForRootViewDidChange',
|
|
61
|
-
this.onSafeAreaInsetsUpdate
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
componentWillUnmount() {
|
|
66
|
-
this.safeAreaSubscription?.remove();
|
|
67
|
-
this._isMounted = false;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
onSafeAreaInsetsUpdate( result ) {
|
|
71
|
-
const { safeAreaInsets } = result;
|
|
72
|
-
if ( this._isMounted ) {
|
|
73
|
-
this.setState( { safeAreaInsets } );
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
onRootViewLayout( event ) {
|
|
78
|
-
if ( this._isMounted ) {
|
|
79
|
-
this.setHeightState( event );
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setHeightState( event ) {
|
|
84
|
-
const { height } = event.nativeEvent.layout;
|
|
85
|
-
if ( height !== this.state.rootViewHeight ) {
|
|
86
|
-
this.setState(
|
|
87
|
-
{ rootViewHeight: height },
|
|
88
|
-
sendNativeEditorDidLayout
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
renderHTML() {
|
|
94
|
-
const { globalStyles } = this.props;
|
|
95
|
-
return (
|
|
96
|
-
<HTMLTextInput
|
|
97
|
-
parentHeight={ this.state.rootViewHeight }
|
|
98
|
-
style={ globalStyles }
|
|
99
|
-
/>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
renderVisual() {
|
|
104
|
-
const { isReady } = this.props;
|
|
105
|
-
|
|
106
|
-
if ( ! isReady ) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return <VisualEditor setTitleRef={ this.props.setTitleRef } />;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
render() {
|
|
114
|
-
const { getStylesFromColorScheme, mode, globalStyles } = this.props;
|
|
115
|
-
|
|
116
|
-
const isHtmlView = mode === 'text';
|
|
117
|
-
|
|
118
|
-
// Add a margin view at the bottom for the header.
|
|
119
|
-
const marginBottom =
|
|
120
|
-
Platform.OS === 'android' && ! isHtmlView
|
|
121
|
-
? headerToolbarStyles[ 'header-toolbar__container' ].height
|
|
122
|
-
: 0;
|
|
123
|
-
|
|
124
|
-
const containerStyles = getStylesFromColorScheme(
|
|
125
|
-
styles.container,
|
|
126
|
-
styles.containerDark
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const toolbarKeyboardAvoidingViewStyle = {
|
|
130
|
-
...styles.toolbarKeyboardAvoidingView,
|
|
131
|
-
left: this.state.safeAreaInsets.left,
|
|
132
|
-
right: this.state.safeAreaInsets.right,
|
|
133
|
-
bottom: this.state.safeAreaInsets.bottom,
|
|
134
|
-
backgroundColor: containerStyles.backgroundColor,
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const editorStyles = [
|
|
138
|
-
getStylesFromColorScheme(
|
|
139
|
-
styles.background,
|
|
140
|
-
styles.backgroundDark
|
|
141
|
-
),
|
|
142
|
-
globalStyles?.background && {
|
|
143
|
-
backgroundColor: globalStyles.background,
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<WCTooltip.Slot>
|
|
149
|
-
<SafeAreaView
|
|
150
|
-
style={ containerStyles }
|
|
151
|
-
onLayout={ this.onRootViewLayout }
|
|
152
|
-
>
|
|
153
|
-
<AutosaveMonitor disableIntervalChecks />
|
|
154
|
-
<OfflineStatus />
|
|
155
|
-
<View style={ editorStyles }>
|
|
156
|
-
{ isHtmlView ? this.renderHTML() : this.renderVisual() }
|
|
157
|
-
{ ! isHtmlView && Platform.OS === 'android' && (
|
|
158
|
-
<FloatingToolbar />
|
|
159
|
-
) }
|
|
160
|
-
<NoticeList />
|
|
161
|
-
</View>
|
|
162
|
-
<View
|
|
163
|
-
style={ {
|
|
164
|
-
flex: 0,
|
|
165
|
-
flexBasis: marginBottom,
|
|
166
|
-
height: marginBottom,
|
|
167
|
-
} }
|
|
168
|
-
/>
|
|
169
|
-
{ ! isHtmlView && (
|
|
170
|
-
<KeyboardAvoidingView
|
|
171
|
-
parentHeight={ this.state.rootViewHeight }
|
|
172
|
-
style={ toolbarKeyboardAvoidingViewStyle }
|
|
173
|
-
withAnimatedHeight
|
|
174
|
-
>
|
|
175
|
-
{ Platform.OS === 'ios' && (
|
|
176
|
-
<>
|
|
177
|
-
<AutocompletionItemsSlot />
|
|
178
|
-
<FloatingToolbar />
|
|
179
|
-
</>
|
|
180
|
-
) }
|
|
181
|
-
<Header />
|
|
182
|
-
<BottomSheetSettings />
|
|
183
|
-
</KeyboardAvoidingView>
|
|
184
|
-
) }
|
|
185
|
-
{ Platform.OS === 'android' && <AutocompletionItemsSlot /> }
|
|
186
|
-
</SafeAreaView>
|
|
187
|
-
</WCTooltip.Slot>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export default compose( [
|
|
193
|
-
withSelect( ( select ) => {
|
|
194
|
-
const { __unstableIsEditorReady: isEditorReady, getEditorMode } =
|
|
195
|
-
select( editorStore );
|
|
196
|
-
const { getSettings } = select( blockEditorStore );
|
|
197
|
-
const globalStyles =
|
|
198
|
-
getSettings()?.__experimentalGlobalStylesBaseStyles?.color;
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
isReady: isEditorReady(),
|
|
202
|
-
mode: getEditorMode(),
|
|
203
|
-
globalStyles,
|
|
204
|
-
};
|
|
205
|
-
} ),
|
|
206
|
-
withPreferredColorScheme,
|
|
207
|
-
] )( Layout );
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
.container {
|
|
3
|
-
flex: 1;
|
|
4
|
-
justify-content: flex-start;
|
|
5
|
-
background-color: $app-background;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.containerDark {
|
|
9
|
-
background-color: $app-safe-area-background-dark;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.background {
|
|
13
|
-
flex: 1;
|
|
14
|
-
background-color: $app-background;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.backgroundDark {
|
|
18
|
-
background-color: $app-background-dark;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.toolbarKeyboardAvoidingView {
|
|
22
|
-
position: absolute;
|
|
23
|
-
bottom: 0;
|
|
24
|
-
right: 0;
|
|
25
|
-
left: 0;
|
|
26
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { memo } from '@wordpress/element';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { withDispatch, withSelect } from '@wordpress/data';
|
|
12
|
-
import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
13
|
-
import { PostTitle } from '@wordpress/editor';
|
|
14
|
-
import {
|
|
15
|
-
store as blockEditorStore,
|
|
16
|
-
useEditorWrapperStyles,
|
|
17
|
-
} from '@wordpress/block-editor';
|
|
18
|
-
|
|
19
|
-
const Header = memo(
|
|
20
|
-
function EditorHeader( { editTitle, setTitleRef, title } ) {
|
|
21
|
-
const [ wrapperStyles ] = useEditorWrapperStyles();
|
|
22
|
-
return (
|
|
23
|
-
<View style={ wrapperStyles }>
|
|
24
|
-
<PostTitle
|
|
25
|
-
innerRef={ setTitleRef }
|
|
26
|
-
title={ title }
|
|
27
|
-
onUpdate={ editTitle }
|
|
28
|
-
placeholder={ __( 'Add title' ) }
|
|
29
|
-
accessibilityLabel="post-title"
|
|
30
|
-
/>
|
|
31
|
-
</View>
|
|
32
|
-
);
|
|
33
|
-
},
|
|
34
|
-
( prevProps, nextProps ) => prevProps.title === nextProps.title
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export default compose( [
|
|
38
|
-
withSelect( ( select ) => {
|
|
39
|
-
const { getEditedPostAttribute } = select( 'core/editor' );
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
title: getEditedPostAttribute( 'title' ),
|
|
43
|
-
};
|
|
44
|
-
} ),
|
|
45
|
-
withDispatch( ( dispatch ) => {
|
|
46
|
-
const { editPost } = dispatch( 'core/editor' );
|
|
47
|
-
|
|
48
|
-
const { clearSelectedBlock } = dispatch( blockEditorStore );
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
clearSelectedBlock,
|
|
52
|
-
editTitle( title ) {
|
|
53
|
-
editPost( { title } );
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
} ),
|
|
57
|
-
withPreferredColorScheme,
|
|
58
|
-
] )( Header );
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Component } from '@wordpress/element';
|
|
5
|
-
import { BlockList } from '@wordpress/block-editor';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import Header from './header';
|
|
11
|
-
|
|
12
|
-
export default class VisualEditor extends Component {
|
|
13
|
-
constructor( props ) {
|
|
14
|
-
super( props );
|
|
15
|
-
this.renderHeader = this.renderHeader.bind( this );
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
renderHeader() {
|
|
19
|
-
const { setTitleRef } = this.props;
|
|
20
|
-
return <Header setTitleRef={ setTitleRef } />;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
render() {
|
|
24
|
-
const { safeAreaBottomInset } = this.props;
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<BlockList
|
|
28
|
-
header={ this.renderHeader }
|
|
29
|
-
safeAreaBottomInset={ safeAreaBottomInset }
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`when nothing is selected media buttons and picker display correctly 1`] = `
|
|
4
|
-
"<!-- wp:paragraph -->
|
|
5
|
-
<p>First example paragraph.</p>
|
|
6
|
-
<!-- /wp:paragraph -->
|
|
7
|
-
|
|
8
|
-
<!-- wp:paragraph -->
|
|
9
|
-
<p>Second example paragraph.</p>
|
|
10
|
-
<!-- /wp:paragraph -->
|
|
11
|
-
|
|
12
|
-
<!-- wp:gallery {"linkTo":"none"} -->
|
|
13
|
-
<figure class="wp-block-gallery has-nested-images columns-default is-cropped"></figure>
|
|
14
|
-
<!-- /wp:gallery -->"
|
|
15
|
-
`;
|