@wordpress/edit-post 7.14.0 → 7.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.
- package/CHANGELOG.md +4 -0
- package/build/components/device-preview/index.js +6 -6
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/header/{document-title → document-actions}/index.js +10 -11
- package/build/components/header/document-actions/index.js.map +1 -0
- package/build/components/header/header-toolbar/index.js +7 -6
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +92 -49
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +4 -9
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +23 -4
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js +0 -2
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/layout/actions-panel.js +5 -10
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js +36 -13
- package/build/components/layout/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +2 -2
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/discussion-panel/index.js +20 -20
- package/build/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build/components/text-editor/index.js +1 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/header.native.js +1 -13
- package/build/components/visual-editor/header.native.js.map +1 -1
- package/build/components/visual-editor/index.js +1 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +2 -39
- package/build/editor.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +61 -4
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/plugins/index.js +35 -6
- package/build/plugins/index.js.map +1 -1
- package/build/store/actions.js +12 -14
- package/build/store/actions.js.map +1 -1
- package/build-module/components/device-preview/index.js +6 -6
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/header/{document-title → document-actions}/index.js +10 -11
- package/build-module/components/header/document-actions/index.js.map +1 -0
- package/build-module/components/header/header-toolbar/index.js +7 -6
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +93 -53
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +4 -9
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +23 -4
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js +0 -2
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/layout/actions-panel.js +5 -10
- package/build-module/components/layout/actions-panel.js.map +1 -1
- package/build-module/components/layout/index.js +37 -14
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/discussion-panel/index.js +21 -19
- package/build-module/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build-module/components/text-editor/index.js +2 -2
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/header.native.js +1 -10
- package/build-module/components/visual-editor/header.native.js.map +1 -1
- package/build-module/components/visual-editor/index.js +2 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +2 -38
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +60 -5
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/index.js +33 -6
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/store/actions.js +11 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +30 -31
- package/build-style/style.css +30 -31
- package/package.json +32 -32
- package/src/components/device-preview/index.js +35 -39
- package/src/components/header/{document-title → document-actions}/index.js +22 -23
- package/src/components/header/{document-title → document-actions}/style.scss +25 -22
- package/src/components/header/header-toolbar/index.js +3 -2
- package/src/components/header/header-toolbar/index.native.js +125 -68
- package/src/components/header/header-toolbar/style.native.scss +23 -4
- package/src/components/header/header-toolbar/style.scss +4 -0
- package/src/components/header/index.js +15 -25
- package/src/components/header/mode-switcher/index.js +23 -4
- package/src/components/header/post-publish-button-or-toggle.js +0 -2
- package/src/components/header/style.scss +1 -1
- package/src/components/layout/actions-panel.js +5 -7
- package/src/components/layout/index.js +45 -9
- package/src/components/layout/style.native.scss +1 -1
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +16 -5
- package/src/components/preferences-modal/test/index.js +4 -4
- package/src/components/secondary-sidebar/list-view-sidebar.js +3 -3
- package/src/components/sidebar/discussion-panel/index.js +15 -20
- package/src/components/text-editor/index.js +0 -2
- package/src/components/visual-editor/header.native.js +1 -17
- package/src/components/visual-editor/index.js +1 -6
- package/src/components/visual-editor/test/__snapshots__/index.native.js.snap +15 -0
- package/src/components/visual-editor/test/index.native.js +118 -1
- package/src/editor.js +2 -47
- package/src/hooks/commands/use-common-commands.js +81 -15
- package/src/index.js +5 -1
- package/src/plugins/index.js +32 -8
- package/src/store/actions.js +18 -27
- package/src/style.scss +2 -8
- package/src/test/editor.native.js +4 -3
- package/build/components/header/document-title/index.js.map +0 -1
- package/build-module/components/header/document-title/index.js.map +0 -1
- package/src/components/visual-editor/style.native.scss +0 -18
|
@@ -3,26 +3,37 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { ScrollView, StyleSheet, View } from 'react-native';
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useCallback, useRef,
|
|
12
|
-
import { compose,
|
|
11
|
+
import { useCallback, useRef, useEffect, Platform } from '@wordpress/element';
|
|
12
|
+
import { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
13
13
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
14
14
|
import { withViewportMatch } from '@wordpress/viewport';
|
|
15
15
|
import { __ } from '@wordpress/i18n';
|
|
16
16
|
import { Inserter, BlockToolbar, store as blockEditorStore } from '@wordpress/block-editor';
|
|
17
17
|
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
|
|
18
|
-
import { keyboardClose,
|
|
18
|
+
import { keyboardClose, audio as audioIcon, media as imageIcon, video as videoIcon, gallery as galleryIcon } from '@wordpress/icons';
|
|
19
19
|
import { store as editorStore } from '@wordpress/editor';
|
|
20
|
+
import { createBlock } from '@wordpress/blocks';
|
|
21
|
+
import { toggleUndoButton, toggleRedoButton, subscribeOnUndoPressed, subscribeOnRedoPressed } from '@wordpress/react-native-bridge';
|
|
20
22
|
/**
|
|
21
23
|
* Internal dependencies
|
|
22
24
|
*/
|
|
23
25
|
|
|
24
26
|
import styles from './style.scss';
|
|
25
27
|
import { store as editPostStore } from '../../../store';
|
|
28
|
+
const shadowStyle = {
|
|
29
|
+
shadowOffset: {
|
|
30
|
+
width: 2,
|
|
31
|
+
height: 2
|
|
32
|
+
},
|
|
33
|
+
shadowOpacity: 1,
|
|
34
|
+
shadowRadius: 6,
|
|
35
|
+
elevation: 18
|
|
36
|
+
};
|
|
26
37
|
|
|
27
38
|
function HeaderToolbar({
|
|
28
39
|
hasRedo,
|
|
@@ -31,20 +42,34 @@ function HeaderToolbar({
|
|
|
31
42
|
undo,
|
|
32
43
|
showInserter,
|
|
33
44
|
showKeyboardHideButton,
|
|
34
|
-
|
|
45
|
+
insertBlock,
|
|
35
46
|
onHideKeyboard,
|
|
36
47
|
isRTL,
|
|
37
48
|
noContentSelected
|
|
38
49
|
}) {
|
|
39
|
-
const
|
|
40
|
-
const [
|
|
50
|
+
const anchorNodeRef = useRef();
|
|
51
|
+
const containerStyle = [usePreferredColorSchemeStyle(styles['header-toolbar__container'], styles['header-toolbar__container--dark']), {
|
|
52
|
+
borderTopWidth: StyleSheet.hairlineWidth
|
|
53
|
+
}];
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const onUndoSubscription = subscribeOnUndoPressed(undo);
|
|
56
|
+
const onRedoSubscription = subscribeOnRedoPressed(redo);
|
|
57
|
+
return () => {
|
|
58
|
+
onUndoSubscription?.remove();
|
|
59
|
+
onRedoSubscription?.remove();
|
|
60
|
+
};
|
|
61
|
+
}, [undo, redo]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
toggleUndoButton(!hasUndo);
|
|
64
|
+
}, [hasUndo]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
toggleRedoButton(!hasRedo);
|
|
67
|
+
}, [hasRedo]);
|
|
41
68
|
const scrollViewRef = useRef(null);
|
|
42
69
|
|
|
43
70
|
const scrollToStart = () => {
|
|
44
71
|
// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (isAndroid && isRTL) {
|
|
72
|
+
if (Platform.isAndroid && isRTL) {
|
|
48
73
|
scrollViewRef.current.scrollToEnd();
|
|
49
74
|
} else {
|
|
50
75
|
scrollViewRef.current.scrollTo({
|
|
@@ -53,49 +78,62 @@ function HeaderToolbar({
|
|
|
53
78
|
}
|
|
54
79
|
};
|
|
55
80
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
title: __('Redo'),
|
|
71
|
-
icon: !isRTL ? redoIcon : undoIcon,
|
|
72
|
-
isDisabled: !hasRedo,
|
|
73
|
-
onClick: redo,
|
|
74
|
-
extraProps: {
|
|
75
|
-
hint: __('Double tap to redo last change')
|
|
76
|
-
}
|
|
77
|
-
})];
|
|
78
|
-
return isRTL ? buttons.reverse() : buttons;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const onToggleInserter = useCallback(isOpen => {
|
|
82
|
-
if (isOpen) {
|
|
83
|
-
wasNoContentSelected.current = noContentSelected;
|
|
81
|
+
const onInsertBlock = useCallback(blockType => () => {
|
|
82
|
+
insertBlock(createBlock(blockType), undefined, undefined, true, {
|
|
83
|
+
source: 'inserter_menu',
|
|
84
|
+
inserterMethod: 'quick-inserter'
|
|
85
|
+
});
|
|
86
|
+
}, [insertBlock]);
|
|
87
|
+
const renderMediaButtons = createElement(ToolbarGroup, null, createElement(ToolbarButton, {
|
|
88
|
+
key: "imageButton",
|
|
89
|
+
title: __('Image'),
|
|
90
|
+
icon: imageIcon,
|
|
91
|
+
onClick: onInsertBlock('core/image'),
|
|
92
|
+
testID: "insert-image-button",
|
|
93
|
+
extraProps: {
|
|
94
|
+
hint: __('Insert Image Block')
|
|
84
95
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
}), createElement(ToolbarButton, {
|
|
97
|
+
key: "videoButton",
|
|
98
|
+
title: __('Video'),
|
|
99
|
+
icon: videoIcon,
|
|
100
|
+
onClick: onInsertBlock('core/video'),
|
|
101
|
+
testID: "insert-video-button",
|
|
102
|
+
extraProps: {
|
|
103
|
+
hint: __('Insert Video Block')
|
|
104
|
+
}
|
|
105
|
+
}), createElement(ToolbarButton, {
|
|
106
|
+
key: "galleryButton",
|
|
107
|
+
title: __('Gallery'),
|
|
108
|
+
icon: galleryIcon,
|
|
109
|
+
onClick: onInsertBlock('core/gallery'),
|
|
110
|
+
testID: "insert-gallery-button",
|
|
111
|
+
extraProps: {
|
|
112
|
+
hint: __('Insert Gallery Block')
|
|
113
|
+
}
|
|
114
|
+
}), createElement(ToolbarButton, {
|
|
115
|
+
key: "audioButton",
|
|
116
|
+
title: __('Audio'),
|
|
117
|
+
icon: audioIcon,
|
|
118
|
+
onClick: onInsertBlock('core/audio'),
|
|
119
|
+
testID: "insert-audio-button",
|
|
120
|
+
extraProps: {
|
|
121
|
+
hint: __('Insert Audio Block')
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
91
124
|
/* translators: accessibility text for the editor toolbar */
|
|
92
125
|
|
|
93
126
|
const toolbarAriaLabel = __('Document tools');
|
|
94
127
|
|
|
128
|
+
const shadowColor = usePreferredColorSchemeStyle(styles['header-toolbar__keyboard-hide-shadow--light'], styles['header-toolbar__keyboard-hide-shadow--dark']);
|
|
129
|
+
const showKeyboardButtonStyles = [usePreferredColorSchemeStyle(styles['header-toolbar__keyboard-hide-container'], styles['header-toolbar__keyboard-hide-container--dark']), shadowStyle, {
|
|
130
|
+
shadowColor: Platform.isAndroid ? styles['header-toolbar__keyboard-hide-shadow--solid'].color : shadowColor.color
|
|
131
|
+
}];
|
|
95
132
|
return createElement(View, {
|
|
133
|
+
ref: anchorNodeRef,
|
|
96
134
|
testID: toolbarAriaLabel,
|
|
97
135
|
accessibilityLabel: toolbarAriaLabel,
|
|
98
|
-
style:
|
|
136
|
+
style: containerStyle
|
|
99
137
|
}, createElement(ScrollView, {
|
|
100
138
|
ref: scrollViewRef,
|
|
101
139
|
onContentSizeChange: scrollToStart,
|
|
@@ -105,11 +143,11 @@ function HeaderToolbar({
|
|
|
105
143
|
alwaysBounceHorizontal: false,
|
|
106
144
|
contentContainerStyle: styles['header-toolbar__scrollable-content']
|
|
107
145
|
}, createElement(Inserter, {
|
|
108
|
-
disabled: !showInserter
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
passedStyle:
|
|
146
|
+
disabled: !showInserter
|
|
147
|
+
}), noContentSelected && renderMediaButtons, createElement(BlockToolbar, {
|
|
148
|
+
anchorNodeRef: anchorNodeRef.current
|
|
149
|
+
})), showKeyboardHideButton && createElement(ToolbarGroup, {
|
|
150
|
+
passedStyle: showKeyboardButtonStyles
|
|
113
151
|
}, createElement(ToolbarButton, {
|
|
114
152
|
title: __('Hide keyboard'),
|
|
115
153
|
icon: keyboardClose,
|
|
@@ -142,7 +180,8 @@ export default compose([withSelect(select => {
|
|
|
142
180
|
};
|
|
143
181
|
}), withDispatch(dispatch => {
|
|
144
182
|
const {
|
|
145
|
-
clearSelectedBlock
|
|
183
|
+
clearSelectedBlock,
|
|
184
|
+
insertBlock
|
|
146
185
|
} = dispatch(blockEditorStore);
|
|
147
186
|
const {
|
|
148
187
|
togglePostTitleSelection
|
|
@@ -154,10 +193,11 @@ export default compose([withSelect(select => {
|
|
|
154
193
|
onHideKeyboard() {
|
|
155
194
|
clearSelectedBlock();
|
|
156
195
|
togglePostTitleSelection(false);
|
|
157
|
-
}
|
|
196
|
+
},
|
|
158
197
|
|
|
198
|
+
insertBlock
|
|
159
199
|
};
|
|
160
200
|
}), withViewportMatch({
|
|
161
201
|
isLargeViewport: 'medium'
|
|
162
|
-
})
|
|
202
|
+
})])(HeaderToolbar);
|
|
163
203
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.native.js"],"names":["Platform","ScrollView","View","useCallback","useRef","useState","compose","withPreferredColorScheme","withSelect","withDispatch","withViewportMatch","__","Inserter","BlockToolbar","store","blockEditorStore","ToolbarGroup","ToolbarButton","keyboardClose","undo","undoIcon","redo","redoIcon","editorStore","styles","editPostStore","HeaderToolbar","hasRedo","hasUndo","showInserter","showKeyboardHideButton","getStylesFromColorScheme","onHideKeyboard","isRTL","noContentSelected","wasNoContentSelected","isInserterOpen","setIsInserterOpen","scrollViewRef","scrollToStart","isAndroid","OS","current","scrollToEnd","scrollTo","x","renderHistoryButtons","buttons","hint","reverse","onToggleInserter","isOpen","useExpandedMode","toolbarAriaLabel","select","getBlockRootClientId","getBlockSelectionEnd","hasInserterItems","hasSelectedBlock","getEditorSettings","isAnyBlockSelected","hasEditorRedo","hasEditorUndo","getEditorMode","richEditingEnabled","isTextModeEnabled","getSettings","dispatch","clearSelectedBlock","togglePostTitleSelection","isLargeViewport"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,IAA/B,QAA2C,cAA3C;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,QAA9B,QAA8C,oBAA9C;AACA,SAASC,OAAT,EAAkBC,wBAAlB,QAAkD,oBAAlD;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASC,YAAT,EAAuBC,aAAvB,QAA4C,uBAA5C;AACA,SACCC,aADD,EAECC,IAAI,IAAIC,QAFT,EAGCC,IAAI,IAAIC,QAHT,QAIO,kBAJP;AAKA,SAASR,KAAK,IAAIS,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,SAASV,KAAK,IAAIW,aAAlB,QAAuC,gBAAvC;;AAEA,SAASC,aAAT,CAAwB;AACvBC,EAAAA,OADuB;AAEvBC,EAAAA,OAFuB;AAGvBP,EAAAA,IAHuB;AAIvBF,EAAAA,IAJuB;AAKvBU,EAAAA,YALuB;AAMvBC,EAAAA,sBANuB;AAOvBC,EAAAA,wBAPuB;AAQvBC,EAAAA,cARuB;AASvBC,EAAAA,KATuB;AAUvBC,EAAAA;AAVuB,CAAxB,EAWI;AACH,QAAMC,oBAAoB,GAAG/B,MAAM,CAAE8B,iBAAF,CAAnC;AACA,QAAM,CAAEE,cAAF,EAAkBC,iBAAlB,IAAwChC,QAAQ,CAAE,KAAF,CAAtD;AAEA,QAAMiC,aAAa,GAAGlC,MAAM,CAAE,IAAF,CAA5B;;AACA,QAAMmC,aAAa,GAAG,MAAM;AAC3B;AACA,UAAMC,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AFxB;;AAGNa,IAAAA,cAAc,GAAG;AAChBoC,MAAAA,kBAAkB;AAClBC,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AANK,GAAP;AAQA,CAZW,CA1BW,EAuCvB3D,iBAAiB,CAAE;AAAE4D,EAAAA,eAAe,EAAE;AAAnB,CAAF,CAvCM,EAwCvB/D,wBAxCuB,CAAF,CAAP,CAyCVmB,aAzCU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { Platform, ScrollView, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { withViewportMatch } from '@wordpress/viewport';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInserter,\n\tBlockToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport {\n\tkeyboardClose,\n\tundo as undoIcon,\n\tredo as redoIcon,\n} from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport { store as editPostStore } from '../../../store';\n\nfunction HeaderToolbar( {\n\thasRedo,\n\thasUndo,\n\tredo,\n\tundo,\n\tshowInserter,\n\tshowKeyboardHideButton,\n\tgetStylesFromColorScheme,\n\tonHideKeyboard,\n\tisRTL,\n\tnoContentSelected,\n} ) {\n\tconst wasNoContentSelected = useRef( noContentSelected );\n\tconst [ isInserterOpen, setIsInserterOpen ] = useState( false );\n\n\tconst scrollViewRef = useRef( null );\n\tconst scrollToStart = () => {\n\t\t// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android\n\t\tconst isAndroid = Platform.OS === 'android';\n\t\tif ( isAndroid && isRTL ) {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t} else {\n\t\t\tscrollViewRef.current.scrollTo( { x: 0 } );\n\t\t}\n\t};\n\tconst renderHistoryButtons = () => {\n\t\tconst buttons = [\n\t\t\t/* TODO: replace with EditorHistoryRedo and EditorHistoryUndo. */\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"undoButton\"\n\t\t\t\ttitle={ __( 'Undo' ) }\n\t\t\t\ticon={ ! isRTL ? undoIcon : redoIcon }\n\t\t\t\tisDisabled={ ! hasUndo }\n\t\t\t\tonClick={ undo }\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Double tap to undo last change' ),\n\t\t\t\t} }\n\t\t\t/>,\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"redoButton\"\n\t\t\t\ttitle={ __( 'Redo' ) }\n\t\t\t\ticon={ ! isRTL ? redoIcon : undoIcon }\n\t\t\t\tisDisabled={ ! hasRedo }\n\t\t\t\tonClick={ redo }\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Double tap to redo last change' ),\n\t\t\t\t} }\n\t\t\t/>,\n\t\t];\n\n\t\treturn isRTL ? buttons.reverse() : buttons;\n\t};\n\n\tconst onToggleInserter = useCallback(\n\t\t( isOpen ) => {\n\t\t\tif ( isOpen ) {\n\t\t\t\twasNoContentSelected.current = noContentSelected;\n\t\t\t}\n\t\t\tsetIsInserterOpen( isOpen );\n\t\t},\n\t\t[ noContentSelected ]\n\t);\n\n\t// Expanded mode should be preserved while the inserter is open.\n\t// This way we prevent style updates during the opening transition.\n\tconst useExpandedMode = isInserterOpen\n\t\t? wasNoContentSelected.current\n\t\t: noContentSelected;\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\treturn (\n\t\t<View\n\t\t\ttestID={ toolbarAriaLabel }\n\t\t\taccessibilityLabel={ toolbarAriaLabel }\n\t\t\tstyle={ [\n\t\t\t\tgetStylesFromColorScheme(\n\t\t\t\t\tstyles[ 'header-toolbar__container' ],\n\t\t\t\t\tstyles[ 'header-toolbar__container--dark' ]\n\t\t\t\t),\n\t\t\t\tuseExpandedMode &&\n\t\t\t\t\tstyles[ 'header-toolbar__container--expanded' ],\n\t\t\t] }\n\t\t>\n\t\t\t<ScrollView\n\t\t\t\tref={ scrollViewRef }\n\t\t\t\tonContentSizeChange={ scrollToStart }\n\t\t\t\thorizontal={ true }\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\talwaysBounceHorizontal={ false }\n\t\t\t\tcontentContainerStyle={\n\t\t\t\t\tstyles[ 'header-toolbar__scrollable-content' ]\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<Inserter\n\t\t\t\t\tdisabled={ ! showInserter }\n\t\t\t\t\tuseExpandedMode={ useExpandedMode }\n\t\t\t\t\tonToggle={ onToggleInserter }\n\t\t\t\t/>\n\t\t\t\t{ renderHistoryButtons() }\n\t\t\t\t<BlockToolbar />\n\t\t\t</ScrollView>\n\t\t\t{ showKeyboardHideButton && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tpassedStyle={\n\t\t\t\t\t\tstyles[ 'header-toolbar__keyboard-hide-container' ]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Hide keyboard' ) }\n\t\t\t\t\t\ticon={ keyboardClose }\n\t\t\t\t\t\tonClick={ onHideKeyboard }\n\t\t\t\t\t\textraProps={ {\n\t\t\t\t\t\t\thint: __( 'Tap to hide the keyboard' ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\thasInserterItems,\n\t\t\thasSelectedBlock,\n\t\t} = select( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst isAnyBlockSelected = hasSelectedBlock();\n\t\treturn {\n\t\t\thasRedo: select( editorStore ).hasEditorRedo(),\n\t\t\thasUndo: select( editorStore ).hasEditorUndo(),\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tshowInserter:\n\t\t\t\tselect( editPostStore ).getEditorMode() === 'visual' &&\n\t\t\t\tgetEditorSettings().richEditingEnabled &&\n\t\t\t\thasInserterItems(\n\t\t\t\t\tgetBlockRootClientId( getBlockSelectionEnd() )\n\t\t\t\t),\n\t\t\tisTextModeEnabled:\n\t\t\t\tselect( editPostStore ).getEditorMode() === 'text',\n\t\t\tisRTL: select( blockEditorStore ).getSettings().isRTL,\n\t\t\tnoContentSelected: ! isAnyBlockSelected,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { clearSelectedBlock } = dispatch( blockEditorStore );\n\t\tconst { togglePostTitleSelection } = dispatch( editorStore );\n\n\t\treturn {\n\t\t\tredo: dispatch( editorStore ).redo,\n\t\t\tundo: dispatch( editorStore ).undo,\n\t\t\tonHideKeyboard() {\n\t\t\t\tclearSelectedBlock();\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithViewportMatch( { isLargeViewport: 'medium' } ),\n\twithPreferredColorScheme,\n] )( HeaderToolbar );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.native.js"],"names":["ScrollView","StyleSheet","View","useCallback","useRef","useEffect","Platform","compose","usePreferredColorSchemeStyle","withSelect","withDispatch","withViewportMatch","__","Inserter","BlockToolbar","store","blockEditorStore","ToolbarGroup","ToolbarButton","keyboardClose","audio","audioIcon","media","imageIcon","video","videoIcon","gallery","galleryIcon","editorStore","createBlock","toggleUndoButton","toggleRedoButton","subscribeOnUndoPressed","subscribeOnRedoPressed","styles","editPostStore","shadowStyle","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","HeaderToolbar","hasRedo","hasUndo","redo","undo","showInserter","showKeyboardHideButton","insertBlock","onHideKeyboard","isRTL","noContentSelected","anchorNodeRef","containerStyle","borderTopWidth","hairlineWidth","onUndoSubscription","onRedoSubscription","remove","scrollViewRef","scrollToStart","isAndroid","current","scrollToEnd","scrollTo","x","onInsertBlock","blockType","undefined","source","inserterMethod","renderMediaButtons","hint","toolbarAriaLabel","shadowColor","showKeyboardButtonStyles","color","select","getBlockRootClientId","getBlockSelectionEnd","hasInserterItems","hasSelectedBlock","getEditorSettings","isAnyBlockSelected","hasEditorRedo","hasEditorUndo","getEditorMode","richEditingEnabled","isTextModeEnabled","getSettings","dispatch","clearSelectedBlock","togglePostTitleSelection","isLargeViewport"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,UAArB,EAAiCC,IAAjC,QAA6C,cAA7C;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,SAA9B,EAAyCC,QAAzC,QAAyD,oBAAzD;AACA,SAASC,OAAT,EAAkBC,4BAAlB,QAAsD,oBAAtD;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASC,YAAT,EAAuBC,aAAvB,QAA4C,uBAA5C;AACA,SACCC,aADD,EAECC,KAAK,IAAIC,SAFV,EAGCC,KAAK,IAAIC,SAHV,EAICC,KAAK,IAAIC,SAJV,EAKCC,OAAO,IAAIC,WALZ,QAMO,kBANP;AAOA,SAASZ,KAAK,IAAIa,WAAlB,QAAqC,mBAArC;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SACCC,gBADD,EAECC,gBAFD,EAGCC,sBAHD,EAICC,sBAJD,QAKO,gCALP;AAOA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,SAASnB,KAAK,IAAIoB,aAAlB,QAAuC,gBAAvC;AAEA,MAAMC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D,aAAtB,EAFH;AAGN;AACAvC,IAAAA,YAAY,EACX+B,MAAM,CAAE5C,aAAF,CAAN,CAAwBqD,aAAxB,OAA4C,QAA5C,IACAJ,iBAAiB,GAAGK,kBADpB,IAEAP,gBAAgB,CACfF,oBAAoB,CAAEC,oBAAoB,EAAtB,CADL,CAPX;AAUNS,IAAAA,iBAAiB,EAChBX,MAAM,CAAE5C,aAAF,CAAN,CAAwBqD,aAAxB,OAA4C,MAXvC;AAYNpC,IAAAA,KAAK,EAAE2B,MAAM,CAAE/D,gBAAF,CAAN,CAA2B2E,WAA3B,GAAyCvC,KAZ1C;AAaNC,IAAAA,iBAAiB,EAAE,CAAEgC;AAbf,GAAP;AAeA,CAxBS,CADa,EA0BvB3E,YAAY,CAAIkF,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,kBAAF;AAAsB3C,IAAAA;AAAtB,MACL0C,QAAQ,CAAE5E,gBAAF,CADT;AAEA,QAAM;AAAE8E,IAAAA;AAAF,MAA+BF,QAAQ,CAAEhE,WAAF,CAA7C;AAEA,SAAO;AACNkB,IAAAA,IAAI,EAAE8C,QAAQ,CAAEhE,WAAF,CAAR,CAAwBkB,IADxB;AAENC,IAAAA,IAAI,EAAE6C,QAAQ,CAAEhE,WAAF,CAAR,CAAwBmB,IAFxB;;AAGNI,IAAAA,cAAc,GAAG;AAChB0C,MAAAA,kBAAkB;AAClBC,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA,KANK;;AAON5C,IAAAA;AAPM,GAAP;AASA,CAdW,CA1BW,EAyCvBvC,iBAAiB,CAAE;AAAEoF,EAAAA,eAAe,EAAE;AAAnB,CAAF,CAzCM,CAAF,CAAP,CA0CVpD,aA1CU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { ScrollView, StyleSheet, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef, useEffect, Platform } from '@wordpress/element';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { withViewportMatch } from '@wordpress/viewport';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInserter,\n\tBlockToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport {\n\tkeyboardClose,\n\taudio as audioIcon,\n\tmedia as imageIcon,\n\tvideo as videoIcon,\n\tgallery as galleryIcon,\n} from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\ttoggleUndoButton,\n\ttoggleRedoButton,\n\tsubscribeOnUndoPressed,\n\tsubscribeOnRedoPressed,\n} from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport { store as editPostStore } from '../../../store';\n\nconst shadowStyle = {\n\tshadowOffset: { width: 2, height: 2 },\n\tshadowOpacity: 1,\n\tshadowRadius: 6,\n\televation: 18,\n};\n\nfunction HeaderToolbar( {\n\thasRedo,\n\thasUndo,\n\tredo,\n\tundo,\n\tshowInserter,\n\tshowKeyboardHideButton,\n\tinsertBlock,\n\tonHideKeyboard,\n\tisRTL,\n\tnoContentSelected,\n} ) {\n\tconst anchorNodeRef = useRef();\n\n\tconst containerStyle = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles[ 'header-toolbar__container' ],\n\t\t\tstyles[ 'header-toolbar__container--dark' ]\n\t\t),\n\t\t{ borderTopWidth: StyleSheet.hairlineWidth },\n\t];\n\n\tuseEffect( () => {\n\t\tconst onUndoSubscription = subscribeOnUndoPressed( undo );\n\t\tconst onRedoSubscription = subscribeOnRedoPressed( redo );\n\n\t\treturn () => {\n\t\t\tonUndoSubscription?.remove();\n\t\t\tonRedoSubscription?.remove();\n\t\t};\n\t}, [ undo, redo ] );\n\n\tuseEffect( () => {\n\t\ttoggleUndoButton( ! hasUndo );\n\t}, [ hasUndo ] );\n\n\tuseEffect( () => {\n\t\ttoggleRedoButton( ! hasRedo );\n\t}, [ hasRedo ] );\n\n\tconst scrollViewRef = useRef( null );\n\tconst scrollToStart = () => {\n\t\t// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android\n\t\tif ( Platform.isAndroid && isRTL ) {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t} else {\n\t\t\tscrollViewRef.current.scrollTo( { x: 0 } );\n\t\t}\n\t};\n\n\tconst onInsertBlock = useCallback(\n\t\t( blockType ) => () => {\n\t\t\tinsertBlock( createBlock( blockType ), undefined, undefined, true, {\n\t\t\t\tsource: 'inserter_menu',\n\t\t\t\tinserterMethod: 'quick-inserter',\n\t\t\t} );\n\t\t},\n\t\t[ insertBlock ]\n\t);\n\n\tconst renderMediaButtons = (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"imageButton\"\n\t\t\t\ttitle={ __( 'Image' ) }\n\t\t\t\ticon={ imageIcon }\n\t\t\t\tonClick={ onInsertBlock( 'core/image' ) }\n\t\t\t\ttestID=\"insert-image-button\"\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Insert Image Block' ),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"videoButton\"\n\t\t\t\ttitle={ __( 'Video' ) }\n\t\t\t\ticon={ videoIcon }\n\t\t\t\tonClick={ onInsertBlock( 'core/video' ) }\n\t\t\t\ttestID=\"insert-video-button\"\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Insert Video Block' ),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"galleryButton\"\n\t\t\t\ttitle={ __( 'Gallery' ) }\n\t\t\t\ticon={ galleryIcon }\n\t\t\t\tonClick={ onInsertBlock( 'core/gallery' ) }\n\t\t\t\ttestID=\"insert-gallery-button\"\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Insert Gallery Block' ),\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"audioButton\"\n\t\t\t\ttitle={ __( 'Audio' ) }\n\t\t\t\ticon={ audioIcon }\n\t\t\t\tonClick={ onInsertBlock( 'core/audio' ) }\n\t\t\t\ttestID=\"insert-audio-button\"\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Insert Audio Block' ),\n\t\t\t\t} }\n\t\t\t/>\n\t\t</ToolbarGroup>\n\t);\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst shadowColor = usePreferredColorSchemeStyle(\n\t\tstyles[ 'header-toolbar__keyboard-hide-shadow--light' ],\n\t\tstyles[ 'header-toolbar__keyboard-hide-shadow--dark' ]\n\t);\n\tconst showKeyboardButtonStyles = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles[ 'header-toolbar__keyboard-hide-container' ],\n\t\t\tstyles[ 'header-toolbar__keyboard-hide-container--dark' ]\n\t\t),\n\t\tshadowStyle,\n\t\t{\n\t\t\tshadowColor: Platform.isAndroid\n\t\t\t\t? styles[ 'header-toolbar__keyboard-hide-shadow--solid' ].color\n\t\t\t\t: shadowColor.color,\n\t\t},\n\t];\n\n\treturn (\n\t\t<View\n\t\t\tref={ anchorNodeRef }\n\t\t\ttestID={ toolbarAriaLabel }\n\t\t\taccessibilityLabel={ toolbarAriaLabel }\n\t\t\tstyle={ containerStyle }\n\t\t>\n\t\t\t<ScrollView\n\t\t\t\tref={ scrollViewRef }\n\t\t\t\tonContentSizeChange={ scrollToStart }\n\t\t\t\thorizontal={ true }\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\talwaysBounceHorizontal={ false }\n\t\t\t\tcontentContainerStyle={\n\t\t\t\t\tstyles[ 'header-toolbar__scrollable-content' ]\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<Inserter disabled={ ! showInserter } />\n\n\t\t\t\t{ noContentSelected && renderMediaButtons }\n\t\t\t\t<BlockToolbar anchorNodeRef={ anchorNodeRef.current } />\n\t\t\t</ScrollView>\n\t\t\t{ showKeyboardHideButton && (\n\t\t\t\t<ToolbarGroup passedStyle={ showKeyboardButtonStyles }>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Hide keyboard' ) }\n\t\t\t\t\t\ticon={ keyboardClose }\n\t\t\t\t\t\tonClick={ onHideKeyboard }\n\t\t\t\t\t\textraProps={ {\n\t\t\t\t\t\t\thint: __( 'Tap to hide the keyboard' ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\thasInserterItems,\n\t\t\thasSelectedBlock,\n\t\t} = select( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst isAnyBlockSelected = hasSelectedBlock();\n\t\treturn {\n\t\t\thasRedo: select( editorStore ).hasEditorRedo(),\n\t\t\thasUndo: select( editorStore ).hasEditorUndo(),\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tshowInserter:\n\t\t\t\tselect( editPostStore ).getEditorMode() === 'visual' &&\n\t\t\t\tgetEditorSettings().richEditingEnabled &&\n\t\t\t\thasInserterItems(\n\t\t\t\t\tgetBlockRootClientId( getBlockSelectionEnd() )\n\t\t\t\t),\n\t\t\tisTextModeEnabled:\n\t\t\t\tselect( editPostStore ).getEditorMode() === 'text',\n\t\t\tisRTL: select( blockEditorStore ).getSettings().isRTL,\n\t\t\tnoContentSelected: ! isAnyBlockSelected,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { clearSelectedBlock, insertBlock } =\n\t\t\tdispatch( blockEditorStore );\n\t\tconst { togglePostTitleSelection } = dispatch( editorStore );\n\n\t\treturn {\n\t\t\tredo: dispatch( editorStore ).redo,\n\t\t\tundo: dispatch( editorStore ).undo,\n\t\t\tonHideKeyboard() {\n\t\t\t\tclearSelectedBlock();\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t\tinsertBlock,\n\t\t};\n\t} ),\n\twithViewportMatch( { isLargeViewport: 'medium' } ),\n] )( HeaderToolbar );\n"]}
|
|
@@ -20,7 +20,7 @@ import { default as DevicePreview } from '../device-preview';
|
|
|
20
20
|
import ViewLink from '../view-link';
|
|
21
21
|
import MainDashboardButton from './main-dashboard-button';
|
|
22
22
|
import { store as editPostStore } from '../../store';
|
|
23
|
-
import
|
|
23
|
+
import DocumentActions from './document-actions';
|
|
24
24
|
const slideY = {
|
|
25
25
|
hidden: {
|
|
26
26
|
y: '-50px'
|
|
@@ -53,12 +53,10 @@ function Header({
|
|
|
53
53
|
const {
|
|
54
54
|
hasActiveMetaboxes,
|
|
55
55
|
isPublishSidebarOpened,
|
|
56
|
-
isSaving,
|
|
57
56
|
showIconLabels
|
|
58
57
|
} = useSelect(select => ({
|
|
59
58
|
hasActiveMetaboxes: select(editPostStore).hasMetaBoxes(),
|
|
60
59
|
isPublishSidebarOpened: select(editPostStore).isPublishSidebarOpened(),
|
|
61
|
-
isSaving: select(editPostStore).isSavingMetaBoxes(),
|
|
62
60
|
showIconLabels: select(editPostStore).isFeatureActive('showIconLabels')
|
|
63
61
|
}), []);
|
|
64
62
|
return createElement("div", {
|
|
@@ -79,8 +77,8 @@ function Header({
|
|
|
79
77
|
},
|
|
80
78
|
className: "edit-post-header__toolbar"
|
|
81
79
|
}, createElement(HeaderToolbar, null), createElement("div", {
|
|
82
|
-
className: "edit-post-
|
|
83
|
-
}, createElement(
|
|
80
|
+
className: "edit-post-header__center"
|
|
81
|
+
}, createElement(DocumentActions, null))), createElement(motion.div, {
|
|
84
82
|
variants: slideY,
|
|
85
83
|
transition: {
|
|
86
84
|
type: 'tween',
|
|
@@ -94,14 +92,11 @@ function Header({
|
|
|
94
92
|
// when the publish sidebar has been closed.
|
|
95
93
|
createElement(PostSavedState, {
|
|
96
94
|
forceIsDirty: hasActiveMetaboxes,
|
|
97
|
-
forceIsSaving: isSaving,
|
|
98
95
|
showIconLabels: showIconLabels
|
|
99
96
|
}), createElement(DevicePreview, null), createElement(PostPreviewButton, {
|
|
100
|
-
forceIsAutosaveable: hasActiveMetaboxes
|
|
101
|
-
forcePreviewLink: isSaving ? null : undefined
|
|
97
|
+
forceIsAutosaveable: hasActiveMetaboxes
|
|
102
98
|
}), createElement(ViewLink, null), createElement(PostPublishButtonOrToggle, {
|
|
103
99
|
forceIsDirty: hasActiveMetaboxes,
|
|
104
|
-
forceIsSaving: isSaving,
|
|
105
100
|
setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
|
|
106
101
|
}), (isLargeViewport || !showIconLabels) && createElement(Fragment, null, createElement(PinnedItems.Slot, {
|
|
107
102
|
scope: "core/edit-post"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["PostSavedState","PostPreviewButton","useSelect","PinnedItems","useViewportMatch","__unstableMotion","motion","FullscreenModeClose","HeaderToolbar","MoreMenu","PostPublishButtonOrToggle","default","DevicePreview","ViewLink","MainDashboardButton","store","editPostStore","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["PostSavedState","PostPreviewButton","useSelect","PinnedItems","useViewportMatch","__unstableMotion","motion","FullscreenModeClose","HeaderToolbar","MoreMenu","PostPublishButtonOrToggle","default","DevicePreview","ViewLink","MainDashboardButton","store","editPostStore","DocumentActions","slideY","hidden","y","hover","transition","type","delay","slideX","x","Header","setEntitiesSavedStatesCallback","isLargeViewport","hasActiveMetaboxes","isPublishSidebarOpened","showIconLabels","select","hasMetaBoxes","isFeatureActive"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,iBAAzB,QAAkD,mBAAlD;AAC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AAA,mBAAmB,EAAGF;AAAzC,IAjBD,EAkBC,cAAC,QAAD,OAlBD,EAmBC,cAAC,yBAAD;AACC,IAAA,YAAY,EAAGA,kBADhB;AAEC,IAAA,8BAA8B,EAC7BF;AAHF,IAnBD,EAyBG,CAAEC,eAAe,IAAI,CAAEG,cAAvB,KACD,8BACC,cAAC,WAAD,CAAa,IAAb;AAAkB,IAAA,KAAK,EAAC;AAAxB,IADD,EAEC,cAAC,QAAD;AAAU,IAAA,cAAc,EAAGA;AAA3B,IAFD,CA1BF,EA+BGA,cAAc,IAAI,CAAEH,eAApB,IACD,cAAC,QAAD;AAAU,IAAA,cAAc,EAAGG;AAA3B,IAhCF,CAnBD,CADD;AAyDA;;AAED,eAAeL,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PostSavedState, PostPreviewButton } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport FullscreenModeClose from './fullscreen-mode-close';\nimport HeaderToolbar from './header-toolbar';\nimport MoreMenu from './more-menu';\nimport PostPublishButtonOrToggle from './post-publish-button-or-toggle';\nimport { default as DevicePreview } from '../device-preview';\nimport ViewLink from '../view-link';\nimport MainDashboardButton from './main-dashboard-button';\nimport { store as editPostStore } from '../../store';\nimport DocumentActions from './document-actions';\n\nconst slideY = {\n\thidden: { y: '-50px' },\n\thover: { y: 0, transition: { type: 'tween', delay: 0.2 } },\n};\n\nconst slideX = {\n\thidden: { x: '-100%' },\n\thover: { x: 0, transition: { type: 'tween', delay: 0.2 } },\n};\n\nfunction Header( { setEntitiesSavedStatesCallback } ) {\n\tconst isLargeViewport = useViewportMatch( 'large' );\n\tconst { hasActiveMetaboxes, isPublishSidebarOpened, showIconLabels } =\n\t\tuseSelect(\n\t\t\t( select ) => ( {\n\t\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\t\tisPublishSidebarOpened:\n\t\t\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\t\t\tshowIconLabels:\n\t\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t\t} ),\n\t\t\t[]\n\t\t);\n\n\treturn (\n\t\t<div className=\"edit-post-header\">\n\t\t\t<MainDashboardButton.Slot>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ slideX }\n\t\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\t>\n\t\t\t\t\t<FullscreenModeClose showTooltip />\n\t\t\t\t</motion.div>\n\t\t\t</MainDashboardButton.Slot>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__toolbar\"\n\t\t\t>\n\t\t\t\t<HeaderToolbar />\n\t\t\t\t<div className=\"edit-post-header__center\">\n\t\t\t\t\t<DocumentActions />\n\t\t\t\t</div>\n\t\t\t</motion.div>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tshowIconLabels={ showIconLabels }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<DevicePreview />\n\t\t\t\t<PostPreviewButton forceIsAutosaveable={ hasActiveMetaboxes } />\n\t\t\t\t<ViewLink />\n\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t{ ( isLargeViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-post\" />\n\t\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ showIconLabels && ! isLargeViewport && (\n\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"]}
|
|
@@ -49,12 +49,31 @@ function ModeSwitcher() {
|
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
let selectedMode = mode;
|
|
53
|
+
|
|
54
|
+
if (!isRichEditingEnabled && mode === 'visual') {
|
|
55
|
+
selectedMode = 'text';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!isCodeEditingEnabled && mode === 'text') {
|
|
59
|
+
selectedMode = 'visual';
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
const choices = MODES.map(choice => {
|
|
57
|
-
if (choice.value
|
|
63
|
+
if (!isCodeEditingEnabled && choice.value === 'text') {
|
|
64
|
+
choice = { ...choice,
|
|
65
|
+
disabled: true
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!isRichEditingEnabled && choice.value === 'visual') {
|
|
70
|
+
choice = { ...choice,
|
|
71
|
+
disabled: true,
|
|
72
|
+
info: __('You can enable the visual editor in your profile settings.')
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (choice.value !== selectedMode && !choice.disabled) {
|
|
58
77
|
return { ...choice,
|
|
59
78
|
shortcut
|
|
60
79
|
};
|
|
@@ -66,7 +85,7 @@ function ModeSwitcher() {
|
|
|
66
85
|
label: __('Editor')
|
|
67
86
|
}, createElement(MenuItemsChoice, {
|
|
68
87
|
choices: choices,
|
|
69
|
-
value:
|
|
88
|
+
value: selectedMode,
|
|
70
89
|
onSelect: switchEditorMode
|
|
71
90
|
}));
|
|
72
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/mode-switcher/index.js"],"names":["__","MenuItemsChoice","MenuGroup","useSelect","useDispatch","store","keyboardShortcutsStore","editorStore","editPostStore","MODES","value","label","ModeSwitcher","shortcut","isRichEditingEnabled","isCodeEditingEnabled","isEditingTemplate","mode","select","getShortcutRepresentation","getEditorSettings","richEditingEnabled","codeEditingEnabled","getEditorMode","switchEditorMode","choices","map","choice"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,EAA0BC,SAA1B,QAA2C,uBAA3C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,KAAK,GAAG,CACb;AACCC,EAAAA,KAAK,EAAE,QADR;AAECC,EAAAA,KAAK,EAAEX,EAAE,CAAE,eAAF;AAFV,CADa,EAKb;AACCU,EAAAA,KAAK,EAAE,MADR;AAECC,EAAAA,KAAK,EAAEX,EAAE,CAAE,aAAF;AAFV,CALa,CAAd;;AAWA,SAASY,YAAT,GAAwB;AACvB,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,oBAFK;AAGLC,IAAAA,oBAHK;AAILC,IAAAA,iBAJK;AAKLC,IAAAA;AALK,MAMFd,SAAS,CACVe,MAAF,KAAgB;AACfL,IAAAA,QAAQ,EAAEK,MAAM,CACfZ,sBADe,CAAN,CAERa,yBAFQ,CAEmB,4BAFnB,CADK;AAIfL,IAAAA,oBAAoB,EACnBI,MAAM,CAAEX,WAAF,CAAN,CAAsBa,iBAAtB,GAA0CC,kBAL5B;AAMfN,IAAAA,oBAAoB,EACnBG,MAAM,CAAEX,WAAF,CAAN,CAAsBa,iBAAtB,GAA0CE,kBAP5B;AAQfN,IAAAA,iBAAiB,EAAEE,MAAM,CAAEV,aAAF,CAAN,CAAwBQ,iBAAxB,EARJ;AASfC,IAAAA,IAAI,EAAEC,MAAM,CAAEV,aAAF,CAAN,CAAwBe,aAAxB;AATS,GAAhB,CADY,EAYZ,EAZY,CANb;AAoBA,QAAM;AAAEC,IAAAA;AAAF,MAAuBpB,WAAW,CAAEI,aAAF,CAAxC;;AAEA,MAAKQ,iBAAL,EAAyB;AACxB,WAAO,IAAP;AACA;;AAED,MAAK,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/mode-switcher/index.js"],"names":["__","MenuItemsChoice","MenuGroup","useSelect","useDispatch","store","keyboardShortcutsStore","editorStore","editPostStore","MODES","value","label","ModeSwitcher","shortcut","isRichEditingEnabled","isCodeEditingEnabled","isEditingTemplate","mode","select","getShortcutRepresentation","getEditorSettings","richEditingEnabled","codeEditingEnabled","getEditorMode","switchEditorMode","selectedMode","choices","map","choice","disabled","info"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,EAA0BC,SAA1B,QAA2C,uBAA3C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,+BAAhD;AACA,SAASD,KAAK,IAAIE,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB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AED,QAAMC,OAAO,GAAGjB,KAAK,CAACkB,GAAN,CAAaC,MAAF,IAAc;AACxC,QAAK,CAAEb,oBAAF,IAA0Ba,MAAM,CAAClB,KAAP,KAAiB,MAAhD,EAAyD;AACxDkB,MAAAA,MAAM,GAAG,EACR,GAAGA,MADK;AAERC,QAAAA,QAAQ,EAAE;AAFF,OAAT;AAIA;;AACD,QAAK,CAAEf,oBAAF,IAA0Bc,MAAM,CAAClB,KAAP,KAAiB,QAAhD,EAA2D;AAC1DkB,MAAAA,MAAM,GAAG,EACR,GAAGA,MADK;AAERC,QAAAA,QAAQ,EAAE,IAFF;AAGRC,QAAAA,IAAI,EAAE9B,EAAE,CACP,4DADO;AAHA,OAAT;AAOA;;AACD,QAAK4B,MAAM,CAAClB,KAAP,KAAiBe,YAAjB,IAAiC,CAAEG,MAAM,CAACC,QAA/C,EAA0D;AACzD,aAAO,EAAE,GAAGD,MAAL;AAAaf,QAAAA;AAAb,OAAP;AACA;;AACD,WAAOe,MAAP;AACA,GApBe,CAAhB;AAsBA,SACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG5B,EAAE,CAAE,QAAF;AAArB,KACC,cAAC,eAAD;AACC,IAAA,OAAO,EAAG0B,OADX;AAEC,IAAA,KAAK,EAAGD,YAFT;AAGC,IAAA,QAAQ,EAAGD;AAHZ,IADD,CADD;AASA;;AAED,eAAeZ,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItemsChoice, MenuGroup } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\n/**\n * Set of available mode options.\n *\n * @type {Array}\n */\nconst MODES = [\n\t{\n\t\tvalue: 'visual',\n\t\tlabel: __( 'Visual editor' ),\n\t},\n\t{\n\t\tvalue: 'text',\n\t\tlabel: __( 'Code editor' ),\n\t},\n];\n\nfunction ModeSwitcher() {\n\tconst {\n\t\tshortcut,\n\t\tisRichEditingEnabled,\n\t\tisCodeEditingEnabled,\n\t\tisEditingTemplate,\n\t\tmode,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-mode' ),\n\t\t\tisRichEditingEnabled:\n\t\t\t\tselect( editorStore ).getEditorSettings().richEditingEnabled,\n\t\t\tisCodeEditingEnabled:\n\t\t\t\tselect( editorStore ).getEditorSettings().codeEditingEnabled,\n\t\t\tisEditingTemplate: select( editPostStore ).isEditingTemplate(),\n\t\t\tmode: select( editPostStore ).getEditorMode(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { switchEditorMode } = useDispatch( editPostStore );\n\n\tif ( isEditingTemplate ) {\n\t\treturn null;\n\t}\n\n\tlet selectedMode = mode;\n\tif ( ! isRichEditingEnabled && mode === 'visual' ) {\n\t\tselectedMode = 'text';\n\t}\n\tif ( ! isCodeEditingEnabled && mode === 'text' ) {\n\t\tselectedMode = 'visual';\n\t}\n\n\tconst choices = MODES.map( ( choice ) => {\n\t\tif ( ! isCodeEditingEnabled && choice.value === 'text' ) {\n\t\t\tchoice = {\n\t\t\t\t...choice,\n\t\t\t\tdisabled: true,\n\t\t\t};\n\t\t}\n\t\tif ( ! isRichEditingEnabled && choice.value === 'visual' ) {\n\t\t\tchoice = {\n\t\t\t\t...choice,\n\t\t\t\tdisabled: true,\n\t\t\t\tinfo: __(\n\t\t\t\t\t'You can enable the visual editor in your profile settings.'\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t\tif ( choice.value !== selectedMode && ! choice.disabled ) {\n\t\t\treturn { ...choice, shortcut };\n\t\t}\n\t\treturn choice;\n\t} );\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Editor' ) }>\n\t\t\t<MenuItemsChoice\n\t\t\t\tchoices={ choices }\n\t\t\t\tvalue={ selectedMode }\n\t\t\t\tonSelect={ switchEditorMode }\n\t\t\t/>\n\t\t</MenuGroup>\n\t);\n}\n\nexport default ModeSwitcher;\n"]}
|
|
@@ -13,7 +13,6 @@ import { PostPublishButton, store as editorStore } from '@wordpress/editor';
|
|
|
13
13
|
import { store as editPostStore } from '../../store';
|
|
14
14
|
export function PostPublishButtonOrToggle({
|
|
15
15
|
forceIsDirty,
|
|
16
|
-
forceIsSaving,
|
|
17
16
|
hasPublishAction,
|
|
18
17
|
isBeingScheduled,
|
|
19
18
|
isPending,
|
|
@@ -63,7 +62,6 @@ export function PostPublishButtonOrToggle({
|
|
|
63
62
|
|
|
64
63
|
return createElement(PostPublishButton, {
|
|
65
64
|
forceIsDirty: forceIsDirty,
|
|
66
|
-
forceIsSaving: forceIsSaving,
|
|
67
65
|
isOpen: isPublishSidebarOpened,
|
|
68
66
|
isToggle: component === IS_TOGGLE,
|
|
69
67
|
onToggle: togglePublishSidebar,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/post-publish-button-or-toggle.js"],"names":["useViewportMatch","compose","withDispatch","withSelect","PostPublishButton","store","editorStore","editPostStore","PostPublishButtonOrToggle","forceIsDirty","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/post-publish-button-or-toggle.js"],"names":["useViewportMatch","compose","withDispatch","withSelect","PostPublishButton","store","editorStore","editPostStore","PostPublishButtonOrToggle","forceIsDirty","hasPublishAction","isBeingScheduled","isPending","isPublished","isPublishSidebarEnabled","isPublishSidebarOpened","isScheduled","togglePublishSidebar","setEntitiesSavedStatesCallback","IS_TOGGLE","IS_BUTTON","isSmallerThanMediumViewport","component","select","getCurrentPost","_links","isEditedPostBeingScheduled","isCurrentPostPending","isCurrentPostPublished","isCurrentPostScheduled","dispatch"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,OAA3B,QAA0C,oBAA1C;AACA,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BAA8B,EAAGC;AALlC,IADD;AASA;AAED,eAAejB,OAAO,CACrBE,UAAU,CAAIoB,MAAF;AAAA;;AAAA,SAAgB;AAC3Bb,IAAAA,gBAAgB,2BACfa,MAAM,CAAEjB,WAAF,CAAN,CAAsBkB,cAAtB,IAAwCC,MAAxC,GACC,mBADD,CADe,yEAGV,KAJqB;AAK3Bd,IAAAA,gBAAgB,EAAEY,MAAM,CAAEjB,WAAF,CAAN,CAAsBoB,0BAAtB,EALS;AAM3Bd,IAAAA,SAAS,EAAEW,MAAM,CAAEjB,WAAF,CAAN,CAAsBqB,oBAAtB,EANgB;AAO3Bd,IAAAA,WAAW,EAAEU,MAAM,CAAEjB,WAAF,CAAN,CAAsBsB,sBAAtB,EAPc;AAQ3Bd,IAAAA,uBAAuB,EACtBS,MAAM,CAAEjB,WAAF,CAAN,CAAsBQ,uBAAtB,EAT0B;AAU3BC,IAAAA,sBAAsB,EACrBQ,MAAM,CAAEhB,aAAF,CAAN,CAAwBQ,sBAAxB,EAX0B;AAY3BC,IAAAA,WAAW,EAAEO,MAAM,CAAEjB,WAAF,CAAN,CAAsBuB,sBAAtB;AAZc,GAAhB;AAAA,CAAF,CADW,EAerB3B,YAAY,CAAI4B,QAAF,IAAgB;AAC7B,QAAM;AAAEb,IAAAA;AAAF,MAA2Ba,QAAQ,CAAEvB,aAAF,CAAzC;AACA,SAAO;AACNU,IAAAA;AADM,GAAP;AAGA,CALW,CAfS,CAAP,CAqBZT,yBArBY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch, compose } from '@wordpress/compose';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { PostPublishButton, store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport function PostPublishButtonOrToggle( {\n\tforceIsDirty,\n\thasPublishAction,\n\tisBeingScheduled,\n\tisPending,\n\tisPublished,\n\tisPublishSidebarEnabled,\n\tisPublishSidebarOpened,\n\tisScheduled,\n\ttogglePublishSidebar,\n\tsetEntitiesSavedStatesCallback,\n} ) {\n\tconst IS_TOGGLE = 'toggle';\n\tconst IS_BUTTON = 'button';\n\tconst isSmallerThanMediumViewport = useViewportMatch( 'medium', '<' );\n\tlet component;\n\n\t/**\n\t * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):\n\t *\n\t * 1) We want to show a BUTTON when the post status is at the _final stage_\n\t * for a particular role (see https://wordpress.org/documentation/article/post-status/):\n\t *\n\t * - is published\n\t * - is scheduled to be published\n\t * - is pending and can't be published (but only for viewports >= medium).\n\t * \t Originally, we considered showing a button for pending posts that couldn't be published\n\t * \t (for example, for an author with the contributor role). Some languages can have\n\t * \t long translations for \"Submit for review\", so given the lack of UI real estate available\n\t * \t we decided to take into account the viewport in that case.\n\t * \t See: https://github.com/WordPress/gutenberg/issues/10475\n\t *\n\t * 2) Then, in small viewports, we'll show a TOGGLE.\n\t *\n\t * 3) Finally, we'll use the publish sidebar status to decide:\n\t *\n\t * - if it is enabled, we show a TOGGLE\n\t * - if it is disabled, we show a BUTTON\n\t */\n\tif (\n\t\tisPublished ||\n\t\t( isScheduled && isBeingScheduled ) ||\n\t\t( isPending && ! hasPublishAction && ! isSmallerThanMediumViewport )\n\t) {\n\t\tcomponent = IS_BUTTON;\n\t} else if ( isSmallerThanMediumViewport ) {\n\t\tcomponent = IS_TOGGLE;\n\t} else if ( isPublishSidebarEnabled ) {\n\t\tcomponent = IS_TOGGLE;\n\t} else {\n\t\tcomponent = IS_BUTTON;\n\t}\n\n\treturn (\n\t\t<PostPublishButton\n\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\tisOpen={ isPublishSidebarOpened }\n\t\t\tisToggle={ component === IS_TOGGLE }\n\t\t\tonToggle={ togglePublishSidebar }\n\t\t\tsetEntitiesSavedStatesCallback={ setEntitiesSavedStatesCallback }\n\t\t/>\n\t);\n}\n\nexport default compose(\n\twithSelect( ( select ) => ( {\n\t\thasPublishAction:\n\t\t\tselect( editorStore ).getCurrentPost()?._links?.[\n\t\t\t\t'wp:action-publish'\n\t\t\t] ?? false,\n\t\tisBeingScheduled: select( editorStore ).isEditedPostBeingScheduled(),\n\t\tisPending: select( editorStore ).isCurrentPostPending(),\n\t\tisPublished: select( editorStore ).isCurrentPostPublished(),\n\t\tisPublishSidebarEnabled:\n\t\t\tselect( editorStore ).isPublishSidebarEnabled(),\n\t\tisPublishSidebarOpened:\n\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\tisScheduled: select( editorStore ).isCurrentPostScheduled(),\n\t} ) ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { togglePublishSidebar } = dispatch( editPostStore );\n\t\treturn {\n\t\t\ttogglePublishSidebar,\n\t\t};\n\t} )\n)( PostPublishButtonOrToggle );\n"]}
|
|
@@ -32,16 +32,12 @@ export default function ActionsPanel({
|
|
|
32
32
|
const {
|
|
33
33
|
publishSidebarOpened,
|
|
34
34
|
hasActiveMetaboxes,
|
|
35
|
-
isSavingMetaBoxes,
|
|
36
35
|
hasNonPostEntityChanges
|
|
37
|
-
} = useSelect(select => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
hasNonPostEntityChanges: select(editorStore).hasNonPostEntityChanges()
|
|
43
|
-
};
|
|
44
|
-
}, []);
|
|
36
|
+
} = useSelect(select => ({
|
|
37
|
+
publishSidebarOpened: select(editPostStore).isPublishSidebarOpened(),
|
|
38
|
+
hasActiveMetaboxes: select(editPostStore).hasMetaBoxes(),
|
|
39
|
+
hasNonPostEntityChanges: select(editorStore).hasNonPostEntityChanges()
|
|
40
|
+
}), []);
|
|
45
41
|
const openEntitiesSavedStates = useCallback(() => setEntitiesSavedStatesCallback(true), []); // It is ok for these components to be unmounted when not in visual use.
|
|
46
42
|
// We don't want more than one present at a time, decide which to render.
|
|
47
43
|
|
|
@@ -51,7 +47,6 @@ export default function ActionsPanel({
|
|
|
51
47
|
unmountableContent = createElement(PostPublishPanel, {
|
|
52
48
|
onClose: closePublishSidebar,
|
|
53
49
|
forceIsDirty: hasActiveMetaboxes,
|
|
54
|
-
forceIsSaving: isSavingMetaBoxes,
|
|
55
50
|
PrePublishExtension: PluginPrePublishPanel.Slot,
|
|
56
51
|
PostPublishExtension: PluginPostPublishPanel.Slot
|
|
57
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/layout/actions-panel.js"],"names":["EntitiesSavedStates","PostPublishPanel","store","editorStore","useSelect","useDispatch","Button","createSlotFill","__","useCallback","PluginPostPublishPanel","PluginPrePublishPanel","editPostStore","Fill","Slot","ActionsPanelFill","ActionsPanel","setEntitiesSavedStatesCallback","closeEntitiesSavedStates","isEntitiesSavedStatesOpen","closePublishSidebar","togglePublishSidebar","publishSidebarOpened","hasActiveMetaboxes","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/layout/actions-panel.js"],"names":["EntitiesSavedStates","PostPublishPanel","store","editorStore","useSelect","useDispatch","Button","createSlotFill","__","useCallback","PluginPostPublishPanel","PluginPrePublishPanel","editPostStore","Fill","Slot","ActionsPanelFill","ActionsPanel","setEntitiesSavedStatesCallback","closeEntitiesSavedStates","isEntitiesSavedStatesOpen","closePublishSidebar","togglePublishSidebar","publishSidebarOpened","hasActiveMetaboxes","hasNonPostEntityChanges","select","isPublishSidebarOpened","hasMetaBoxes","openEntitiesSavedStates","unmountableContent"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,mBADD,EAECC,gBAFD,EAGCC,KAAK,IAAIC,WAHV,QAIO,mBAJP;AAKA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,uBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,oBAA5B;AACA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,sCAAnC;AACA,OAAOC,qBAAP,MAAkC,qCAAlC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C,MAAD;AACC,MAAA,OAAO,EAAC,WADT;AAEC,MAAA,SAAS,EAAC,6DAFX;AAGC,MAAA,OAAO,EAAGD,uBAHX;AAIC,uBAAgB;AAJjB,OAMGpB,EAAE,CAAE,iBAAF,CANL,CADD,CADD;AAYA,GAbM,MAaA;AACNqB,IAAAA,kBAAkB,GACjB;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cAAC,MAAD;AACC,MAAA,OAAO,EAAC,WADT;AAEC,MAAA,SAAS,EAAC,+CAFX;AAGC,MAAA,OAAO,EAAGR,oBAHX;AAIC,uBAAgB;AAJjB,OAMGb,EAAE,CAAE,oBAAF,CANL,CADD,CADD;AAYA,GA7DE,CA+DH;AACA;;;AACA,SACC,8BACGW,yBAAyB,IAC1B,cAAC,mBAAD;AAAqB,IAAA,KAAK,EAAGD;AAA7B,IAFF,EAIC,cAAC,IAAD;AAAM,IAAA,gBAAgB;AAAtB,IAJD,EAKG,CAAEC,yBAAF,IAA+BU,kBALlC,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tEntitiesSavedStates,\n\tPostPublishPanel,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, createSlotFill } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport PluginPostPublishPanel from '../sidebar/plugin-post-publish-panel';\nimport PluginPrePublishPanel from '../sidebar/plugin-pre-publish-panel';\nimport { store as editPostStore } from '../../store';\n\nconst { Fill, Slot } = createSlotFill( 'ActionsPanel' );\n\nexport const ActionsPanelFill = Fill;\n\nexport default function ActionsPanel( {\n\tsetEntitiesSavedStatesCallback,\n\tcloseEntitiesSavedStates,\n\tisEntitiesSavedStatesOpen,\n} ) {\n\tconst { closePublishSidebar, togglePublishSidebar } =\n\t\tuseDispatch( editPostStore );\n\tconst {\n\t\tpublishSidebarOpened,\n\t\thasActiveMetaboxes,\n\t\thasNonPostEntityChanges,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\tpublishSidebarOpened:\n\t\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\thasNonPostEntityChanges:\n\t\t\t\tselect( editorStore ).hasNonPostEntityChanges(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setEntitiesSavedStatesCallback( true ),\n\t\t[]\n\t);\n\n\t// It is ok for these components to be unmounted when not in visual use.\n\t// We don't want more than one present at a time, decide which to render.\n\tlet unmountableContent;\n\tif ( publishSidebarOpened ) {\n\t\tunmountableContent = (\n\t\t\t<PostPublishPanel\n\t\t\t\tonClose={ closePublishSidebar }\n\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\tPrePublishExtension={ PluginPrePublishPanel.Slot }\n\t\t\t\tPostPublishExtension={ PluginPostPublishPanel.Slot }\n\t\t\t/>\n\t\t);\n\t} else if ( hasNonPostEntityChanges ) {\n\t\tunmountableContent = (\n\t\t\t<div className=\"edit-post-layout__toggle-entities-saved-states-panel\">\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tclassName=\"edit-post-layout__toggle-entities-saved-states-panel-button\"\n\t\t\t\t\tonClick={ openEntitiesSavedStates }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open save panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\tunmountableContent = (\n\t\t\t<div className=\"edit-post-layout__toggle-publish-panel\">\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tclassName=\"edit-post-layout__toggle-publish-panel-button\"\n\t\t\t\t\tonClick={ togglePublishSidebar }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open publish panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Since EntitiesSavedStates controls its own panel, we can keep it\n\t// always mounted to retain its own component state (such as checkboxes).\n\treturn (\n\t\t<>\n\t\t\t{ isEntitiesSavedStatesOpen && (\n\t\t\t\t<EntitiesSavedStates close={ closeEntitiesSavedStates } />\n\t\t\t) }\n\t\t\t<Slot bubblesVirtually />\n\t\t\t{ ! isEntitiesSavedStatesOpen && unmountableContent }\n\t\t</>\n\t);\n}\n"]}
|