@wordpress/edit-post 7.13.0 → 7.15.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/header-toolbar/index.js +10 -3
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +91 -49
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +26 -30
- package/build/components/header/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/header/preferences-menu-item/index.js +5 -3
- package/build/components/header/preferences-menu-item/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +8 -6
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -2
- package/build/components/keyboard-shortcuts/index.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 +2 -2
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +5 -3
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +2 -1
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-trash/index.js +1 -5
- package/build/components/sidebar/post-trash/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 +3 -0
- package/build/editor.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +176 -0
- package/build/hooks/commands/use-common-commands.js.map +1 -0
- package/build/plugins/index.js +35 -6
- package/build/plugins/index.js.map +1 -1
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +5 -3
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build/store/actions.js +43 -29
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -23
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +11 -7
- package/build/store/selectors.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/header-toolbar/index.js +9 -3
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +92 -53
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +25 -30
- package/build-module/components/header/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/header/preferences-menu-item/index.js +4 -3
- package/build-module/components/header/preferences-menu-item/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -5
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +0 -2
- package/build-module/components/keyboard-shortcuts/index.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 +3 -3
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -4
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +2 -1
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-trash/index.js +1 -4
- package/build-module/components/sidebar/post-trash/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 -0
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +160 -0
- package/build-module/hooks/commands/use-common-commands.js.map +1 -0
- package/build-module/plugins/index.js +33 -6
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +35 -25
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -21
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -15
- package/build-style/style.css +10 -15
- package/package.json +32 -32
- package/src/components/block-manager/style.scss +1 -1
- package/src/components/device-preview/index.js +35 -39
- package/src/components/header/header-toolbar/index.js +5 -1
- package/src/components/header/header-toolbar/index.native.js +124 -68
- package/src/components/header/header-toolbar/style.native.scss +23 -4
- package/src/components/header/index.js +22 -32
- package/src/components/header/post-publish-button-or-toggle.js +0 -2
- package/src/components/header/preferences-menu-item/index.js +4 -3
- package/src/components/keyboard-shortcut-help-modal/index.js +10 -5
- package/src/components/keyboard-shortcuts/index.js +0 -2
- package/src/components/layout/actions-panel.js +5 -7
- package/src/components/layout/index.js +4 -0
- package/src/components/layout/style.native.scss +1 -1
- package/src/components/preferences-modal/index.js +6 -4
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +11 -3
- package/src/components/sidebar/post-status/index.js +1 -0
- package/src/components/sidebar/post-trash/index.js +1 -4
- package/src/components/start-page-options/style.scss +0 -3
- 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 -0
- package/src/hooks/commands/use-common-commands.js +155 -0
- package/src/plugins/index.js +32 -8
- package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
- package/src/store/actions.js +40 -36
- package/src/store/reducer.js +0 -20
- package/src/store/selectors.js +11 -3
- package/src/store/test/reducer.js +0 -25
- package/src/store/test/selectors.js +0 -27
- package/src/style.scss +1 -7
- package/src/components/visual-editor/style.native.scss +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -34,7 +34,6 @@ function DevicePreview() {
|
|
|
34
34
|
const {
|
|
35
35
|
hasActiveMetaboxes,
|
|
36
36
|
isPostSaveable,
|
|
37
|
-
isSaving,
|
|
38
37
|
isViewable,
|
|
39
38
|
deviceType
|
|
40
39
|
} = (0, _data.useSelect)(select => {
|
|
@@ -49,7 +48,6 @@ function DevicePreview() {
|
|
|
49
48
|
const postType = getPostType(getEditedPostAttribute('type'));
|
|
50
49
|
return {
|
|
51
50
|
hasActiveMetaboxes: select(_store.store).hasMetaBoxes(),
|
|
52
|
-
isSaving: select(_store.store).isSavingMetaBoxes(),
|
|
53
51
|
isPostSaveable: select(_editor.store).isEditedPostSaveable(),
|
|
54
52
|
isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false,
|
|
55
53
|
deviceType: select(_store.store).__experimentalGetPreviewDeviceType()
|
|
@@ -64,16 +62,18 @@ function DevicePreview() {
|
|
|
64
62
|
deviceType: deviceType,
|
|
65
63
|
setDeviceType: setPreviewDeviceType,
|
|
66
64
|
label: (0, _i18n.__)('Preview')
|
|
67
|
-
},
|
|
65
|
+
}, ({
|
|
66
|
+
onClose
|
|
67
|
+
}) => isViewable && (0, _element.createElement)(_components.MenuGroup, null, (0, _element.createElement)("div", {
|
|
68
68
|
className: "edit-post-header-preview__grouping-external"
|
|
69
69
|
}, (0, _element.createElement)(_editor.PostPreviewButton, {
|
|
70
|
-
className:
|
|
70
|
+
className: "edit-post-header-preview__button-external",
|
|
71
71
|
role: "menuitem",
|
|
72
72
|
forceIsAutosaveable: hasActiveMetaboxes,
|
|
73
|
-
forcePreviewLink: isSaving ? null : undefined,
|
|
74
73
|
textContent: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Preview in new tab'), (0, _element.createElement)(_components.Icon, {
|
|
75
74
|
icon: _icons.external
|
|
76
|
-
}))
|
|
75
|
+
})),
|
|
76
|
+
onPreview: onClose
|
|
77
77
|
}))));
|
|
78
78
|
}
|
|
79
79
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/device-preview/index.js"],"names":["DevicePreview","hasActiveMetaboxes","isPostSaveable","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/device-preview/index.js"],"names":["DevicePreview","hasActiveMetaboxes","isPostSaveable","isViewable","deviceType","select","getEditedPostAttribute","editorStore","getPostType","coreStore","postType","editPostStore","hasMetaBoxes","isEditedPostSaveable","viewable","__experimentalGetPreviewDeviceType","__experimentalSetPreviewDeviceType","setPreviewDeviceType","onClose","external"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AAGe,SAASA,aAAT,GAAyB;AACvC,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,cAAtB;AAAsCC,IAAAA,UAAtC;AAAkDC,IAAAA;AAAlD,MACL,qBAAaC,MAAF,IAAc;AAAA;;AACxB,UAAM;AAAEC,MAAAA;AAAF,QAA6BD,MAAM,CAAEE,aAAF,CAAzC;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAkBH,MAAM,CAAEI,eAAF,CAA9B;AACA,UAAMC,QAAQ,GAAGF,WAAW,CAAEF,sBAAsB,CAAE,MAAF,CAAxB,CAA5B;AAEA,WAAO;AACNL,MAAAA,kBAAkB,EAAEI,MAAM,CAAEM,YAAF,CAAN,CAAwBC,YAAxB,EADd;AAENV,MAAAA,cAAc,EAAEG,MAAM,CAAEE,aAAF,CAAN,CAAsBM,oBAAtB,EAFV;AAGNV,MAAAA,UAAU,wBAAEO,QAAQ,EAAEI,QAAZ,mEAAwB,KAH5B;AAINV,MAAAA,UAAU,EACTC,MAAM,CACLM,YADK,CAAN,CAEEI,kCAFF;AALK,KAAP;AASA,GAdD,EAcG,EAdH,CADD;AAgBA,QAAM;AAAEC,IAAAA,kCAAkC,EAAEC;AAAtC,MACL,uBAAaN,YAAb,CADD;AAGA,SACC,4BAAC,yCAAD;AACC,IAAA,SAAS,EAAGT,cADb;AAEC,IAAA,SAAS,EAAC,iCAFX;AAGC,IAAA,UAAU,EAAGE,UAHd;AAIC,IAAA,aAAa,EAAGa,oBAJjB;AAKC,IAAA,KAAK,EAAG,cAAI,SAAJ;AALT,KAOG,CAAE;AAAEC,IAAAA;AAAF,GAAF,KACDf,UAAU,IACT,4BAAC,qBAAD,QACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,2CADX;AAEC,IAAA,IAAI,EAAC,UAFN;AAGC,IAAA,mBAAmB,EAAGF,kBAHvB;AAIC,IAAA,WAAW,EACV,qDACG,cAAI,oBAAJ,CADH,EAEC,4BAAC,gBAAD;AAAM,MAAA,IAAI,EAAGkB;AAAb,MAFD,CALF;AAUC,IAAA,SAAS,EAAGD;AAVb,IADD,CADD,CATH,CADD;AA8BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, MenuGroup } from '@wordpress/components';\nimport { PostPreviewButton, store as editorStore } from '@wordpress/editor';\nimport { external } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalPreviewOptions as PreviewOptions } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function DevicePreview() {\n\tconst { hasActiveMetaboxes, isPostSaveable, isViewable, deviceType } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\t\tconst { getPostType } = select( coreStore );\n\t\t\tconst postType = getPostType( getEditedPostAttribute( 'type' ) );\n\n\t\t\treturn {\n\t\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\t\tisPostSaveable: select( editorStore ).isEditedPostSaveable(),\n\t\t\t\tisViewable: postType?.viewable ?? false,\n\t\t\t\tdeviceType:\n\t\t\t\t\tselect(\n\t\t\t\t\t\teditPostStore\n\t\t\t\t\t).__experimentalGetPreviewDeviceType(),\n\t\t\t};\n\t\t}, [] );\n\tconst { __experimentalSetPreviewDeviceType: setPreviewDeviceType } =\n\t\tuseDispatch( editPostStore );\n\n\treturn (\n\t\t<PreviewOptions\n\t\t\tisEnabled={ isPostSaveable }\n\t\t\tclassName=\"edit-post-post-preview-dropdown\"\n\t\t\tdeviceType={ deviceType }\n\t\t\tsetDeviceType={ setPreviewDeviceType }\n\t\t\tlabel={ __( 'Preview' ) }\n\t\t>\n\t\t\t{ ( { onClose } ) =>\n\t\t\t\tisViewable && (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<div className=\"edit-post-header-preview__grouping-external\">\n\t\t\t\t\t\t\t<PostPreviewButton\n\t\t\t\t\t\t\t\tclassName=\"edit-post-header-preview__button-external\"\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t\t\t\t\ttextContent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Preview in new tab' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ external } />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonPreview={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t)\n\t\t\t}\n\t\t</PreviewOptions>\n\t);\n}\n"]}
|
|
@@ -23,6 +23,8 @@ var _icons = require("@wordpress/icons");
|
|
|
23
23
|
|
|
24
24
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
25
25
|
|
|
26
|
+
var _preferences = require("@wordpress/preferences");
|
|
27
|
+
|
|
26
28
|
var _store = require("../../../store");
|
|
27
29
|
|
|
28
30
|
var _lockUnlock = require("../../../lock-unlock");
|
|
@@ -54,7 +56,8 @@ function HeaderToolbar() {
|
|
|
54
56
|
isTextModeEnabled,
|
|
55
57
|
showIconLabels,
|
|
56
58
|
isListViewOpen,
|
|
57
|
-
listViewShortcut
|
|
59
|
+
listViewShortcut,
|
|
60
|
+
hasFixedToolbar
|
|
58
61
|
} = (0, _data.useSelect)(select => {
|
|
59
62
|
const {
|
|
60
63
|
hasInserterItems,
|
|
@@ -72,6 +75,9 @@ function HeaderToolbar() {
|
|
|
72
75
|
const {
|
|
73
76
|
getShortcutRepresentation
|
|
74
77
|
} = select(_keyboardShortcuts.store);
|
|
78
|
+
const {
|
|
79
|
+
get: getPreference
|
|
80
|
+
} = select(_preferences.store);
|
|
75
81
|
return {
|
|
76
82
|
// This setting (richEditingEnabled) should not live in the block editor's setting.
|
|
77
83
|
isInserterEnabled: getEditorMode() === 'visual' && getEditorSettings().richEditingEnabled && hasInserterItems(getBlockRootClientId(getBlockSelectionEnd())),
|
|
@@ -79,7 +85,8 @@ function HeaderToolbar() {
|
|
|
79
85
|
isTextModeEnabled: getEditorMode() === 'text',
|
|
80
86
|
showIconLabels: isFeatureActive('showIconLabels'),
|
|
81
87
|
isListViewOpen: isListViewOpened(),
|
|
82
|
-
listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view')
|
|
88
|
+
listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view'),
|
|
89
|
+
hasFixedToolbar: getPreference('core/edit-post', 'fixedToolbar')
|
|
83
90
|
};
|
|
84
91
|
}, []);
|
|
85
92
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
@@ -143,7 +150,7 @@ function HeaderToolbar() {
|
|
|
143
150
|
icon: _icons.plus,
|
|
144
151
|
label: showIconLabels ? shortLabel : longLabel,
|
|
145
152
|
showTooltip: !showIconLabels
|
|
146
|
-
}), (isWideViewport || !showIconLabels) && (0, _element.createElement)(_element.Fragment, null, isLargeViewport && (0, _element.createElement)(_components.ToolbarItem, {
|
|
153
|
+
}), (isWideViewport || !showIconLabels) && (0, _element.createElement)(_element.Fragment, null, isLargeViewport && !hasFixedToolbar && (0, _element.createElement)(_components.ToolbarItem, {
|
|
147
154
|
as: _blockEditor.ToolSelector,
|
|
148
155
|
showTooltip: !showIconLabels,
|
|
149
156
|
variant: showIconLabels ? 'tertiary' : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.js"],"names":["useShouldContextualToolbarShow","blockEditorPrivateApis","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","editPostStore","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","blockEditorStore","getEditorSettings","editorStore","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","keyboardShortcutsStore","richEditingEnabled","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","Button","listView","undefined","toggleInserter","current","focus","longLabel","shortLabel","plus","ToolSelector","EditorHistoryUndo","EditorHistoryRedo"],"mappings":";;;;;;;AAmBA;;AAhBA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AAEA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAoBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IA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,GAAG,UAAH,GAAgB2B;AAHzC,IAhBD,EAqBGH,aArBH,CAfF,CALD,CADD;AAgDA;;eAEchC,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tEditorHistoryRedo,\n\tEditorHistoryUndo,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction HeaderToolbar() {\n\tconst inserterButton = useRef();\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editPostStore );\n\tconst {\n\t\tisInserterEnabled,\n\t\tisInserterOpened,\n\t\tisTextModeEnabled,\n\t\tshowIconLabels,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t} = useSelect( ( select ) => {\n\t\tconst { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { getEditorMode, isFeatureActive, isListViewOpened } =\n\t\t\tselect( editPostStore );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\treturn {\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tisInserterEnabled:\n\t\t\t\tgetEditorMode() === '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\tisInserterOpened: select( editPostStore ).isInserterOpened(),\n\t\t\tisTextModeEnabled: getEditorMode() === 'text',\n\t\t\tshowIconLabels: isFeatureActive( 'showIconLabels' ),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-post/toggle-list-view'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\tconst overflowItems = (\n\t\t<>\n\t\t\t<ToolbarItem\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-post-header-toolbar__document-overview-toggle\"\n\t\t\t\ticon={ listView }\n\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\tonClick={ toggleListView }\n\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t/>\n\t\t</>\n\t);\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpened, setIsInserterOpened ] );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-post-header-toolbar\"\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t>\n\t\t\t<div className=\"edit-post-header-toolbar__left\">\n\t\t\t\t<ToolbarItem\n\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tclassName=\"edit-post-header-toolbar__inserter-toggle\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\tdisabled={ ! isInserterEnabled }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ overflowItems }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default HeaderToolbar;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.js"],"names":["useShouldContextualToolbarShow","blockEditorPrivateApis","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","editPostStore","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","hasFixedToolbar","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","blockEditorStore","getEditorSettings","editorStore","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","keyboardShortcutsStore","get","getPreference","preferencesStore","richEditingEnabled","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","Button","listView","undefined","toggleInserter","current","focus","longLabel","shortLabel","plus","ToolSelector","EditorHistoryUndo","EditorHistoryRedo"],"mappings":";;;;;;;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H,GAAgB+B,SAJhC;AAMC,IAAA,QAAQ,EAAGhC;AANZ,IAFF,EAWC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGwC,yBADN;AAEC,IAAA,WAAW,EAAG,CAAEvC,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgB+B;AAHzC,IAXD,EAgBC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGS,yBADN;AAEC,IAAA,WAAW,EAAG,CAAExC,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgB+B;AAHzC,IAhBD,EAqBGH,aArBH,CAfF,CALD,CADD;AAgDA;;eAEcpC,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tEditorHistoryRedo,\n\tEditorHistoryUndo,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction HeaderToolbar() {\n\tconst inserterButton = useRef();\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editPostStore );\n\tconst {\n\t\tisInserterEnabled,\n\t\tisInserterOpened,\n\t\tisTextModeEnabled,\n\t\tshowIconLabels,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\thasFixedToolbar,\n\t} = useSelect( ( select ) => {\n\t\tconst { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst { getEditorMode, isFeatureActive, isListViewOpened } =\n\t\t\tselect( editPostStore );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { get: getPreference } = select( preferencesStore );\n\n\t\treturn {\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tisInserterEnabled:\n\t\t\t\tgetEditorMode() === '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\tisInserterOpened: select( editPostStore ).isInserterOpened(),\n\t\t\tisTextModeEnabled: getEditorMode() === 'text',\n\t\t\tshowIconLabels: isFeatureActive( 'showIconLabels' ),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/edit-post/toggle-list-view'\n\t\t\t),\n\t\t\thasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ),\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst {\n\t\tshouldShowContextualToolbar,\n\t\tcanFocusHiddenToolbar,\n\t\tfixedToolbarCanBeFocused,\n\t} = useShouldContextualToolbarShow();\n\t// If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.\n\t// There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.\n\tconst blockToolbarCanBeFocused =\n\t\tshouldShowContextualToolbar ||\n\t\tcanFocusHiddenToolbar ||\n\t\tfixedToolbarCanBeFocused;\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\tconst overflowItems = (\n\t\t<>\n\t\t\t<ToolbarItem\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-post-header-toolbar__document-overview-toggle\"\n\t\t\t\ticon={ listView }\n\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\tonClick={ toggleListView }\n\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t/>\n\t\t</>\n\t);\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpened, setIsInserterOpened ] );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-post-header-toolbar\"\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t>\n\t\t\t<div className=\"edit-post-header-toolbar__left\">\n\t\t\t\t<ToolbarItem\n\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tclassName=\"edit-post-header-toolbar__inserter-toggle\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\tdisabled={ ! isInserterEnabled }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ isTextModeEnabled }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ overflowItems }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default HeaderToolbar;\n"]}
|
|
@@ -27,6 +27,10 @@ var _icons = require("@wordpress/icons");
|
|
|
27
27
|
|
|
28
28
|
var _editor = require("@wordpress/editor");
|
|
29
29
|
|
|
30
|
+
var _blocks = require("@wordpress/blocks");
|
|
31
|
+
|
|
32
|
+
var _reactNativeBridge = require("@wordpress/react-native-bridge");
|
|
33
|
+
|
|
30
34
|
var _style = _interopRequireDefault(require("./style.scss"));
|
|
31
35
|
|
|
32
36
|
var _store = require("../../../store");
|
|
@@ -42,6 +46,16 @@ var _store = require("../../../store");
|
|
|
42
46
|
/**
|
|
43
47
|
* Internal dependencies
|
|
44
48
|
*/
|
|
49
|
+
const shadowStyle = {
|
|
50
|
+
shadowOffset: {
|
|
51
|
+
width: 2,
|
|
52
|
+
height: 2
|
|
53
|
+
},
|
|
54
|
+
shadowOpacity: 1,
|
|
55
|
+
shadowRadius: 6,
|
|
56
|
+
elevation: 18
|
|
57
|
+
};
|
|
58
|
+
|
|
45
59
|
function HeaderToolbar({
|
|
46
60
|
hasRedo,
|
|
47
61
|
hasUndo,
|
|
@@ -49,20 +63,34 @@ function HeaderToolbar({
|
|
|
49
63
|
undo,
|
|
50
64
|
showInserter,
|
|
51
65
|
showKeyboardHideButton,
|
|
52
|
-
|
|
66
|
+
insertBlock,
|
|
53
67
|
onHideKeyboard,
|
|
54
68
|
isRTL,
|
|
55
69
|
noContentSelected
|
|
56
70
|
}) {
|
|
57
|
-
const
|
|
58
|
-
const
|
|
71
|
+
const anchorNodeRef = (0, _element.useRef)();
|
|
72
|
+
const containerStyle = [(0, _compose.usePreferredColorSchemeStyle)(_style.default['header-toolbar__container'], _style.default['header-toolbar__container--dark']), {
|
|
73
|
+
borderTopWidth: _reactNative.StyleSheet.hairlineWidth
|
|
74
|
+
}];
|
|
75
|
+
(0, _element.useEffect)(() => {
|
|
76
|
+
const onUndoSubscription = (0, _reactNativeBridge.subscribeOnUndoPressed)(undo);
|
|
77
|
+
const onRedoSubscription = (0, _reactNativeBridge.subscribeOnRedoPressed)(redo);
|
|
78
|
+
return () => {
|
|
79
|
+
onUndoSubscription?.remove();
|
|
80
|
+
onRedoSubscription?.remove();
|
|
81
|
+
};
|
|
82
|
+
}, [undo, redo]);
|
|
83
|
+
(0, _element.useEffect)(() => {
|
|
84
|
+
(0, _reactNativeBridge.toggleUndoButton)(!hasUndo);
|
|
85
|
+
}, [hasUndo]);
|
|
86
|
+
(0, _element.useEffect)(() => {
|
|
87
|
+
(0, _reactNativeBridge.toggleRedoButton)(!hasRedo);
|
|
88
|
+
}, [hasRedo]);
|
|
59
89
|
const scrollViewRef = (0, _element.useRef)(null);
|
|
60
90
|
|
|
61
91
|
const scrollToStart = () => {
|
|
62
92
|
// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (isAndroid && isRTL) {
|
|
93
|
+
if (_element.Platform.isAndroid && isRTL) {
|
|
66
94
|
scrollViewRef.current.scrollToEnd();
|
|
67
95
|
} else {
|
|
68
96
|
scrollViewRef.current.scrollTo({
|
|
@@ -71,48 +99,60 @@ function HeaderToolbar({
|
|
|
71
99
|
}
|
|
72
100
|
};
|
|
73
101
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
key: "redoButton",
|
|
88
|
-
title: (0, _i18n.__)('Redo'),
|
|
89
|
-
icon: !isRTL ? _icons.redo : _icons.undo,
|
|
90
|
-
isDisabled: !hasRedo,
|
|
91
|
-
onClick: redo,
|
|
92
|
-
extraProps: {
|
|
93
|
-
hint: (0, _i18n.__)('Double tap to redo last change')
|
|
94
|
-
}
|
|
95
|
-
})];
|
|
96
|
-
return isRTL ? buttons.reverse() : buttons;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const onToggleInserter = (0, _element.useCallback)(isOpen => {
|
|
100
|
-
if (isOpen) {
|
|
101
|
-
wasNoContentSelected.current = noContentSelected;
|
|
102
|
+
const onInsertBlock = (0, _element.useCallback)(blockType => () => {
|
|
103
|
+
insertBlock((0, _blocks.createBlock)(blockType), undefined, undefined, true, {
|
|
104
|
+
source: 'inserter_menu'
|
|
105
|
+
});
|
|
106
|
+
}, [insertBlock]);
|
|
107
|
+
const renderMediaButtons = (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, {
|
|
108
|
+
key: "imageButton",
|
|
109
|
+
title: (0, _i18n.__)('Image'),
|
|
110
|
+
icon: _icons.media,
|
|
111
|
+
onClick: onInsertBlock('core/image'),
|
|
112
|
+
testID: "insert-image-button",
|
|
113
|
+
extraProps: {
|
|
114
|
+
hint: (0, _i18n.__)('Insert Image Block')
|
|
102
115
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
}), (0, _element.createElement)(_components.ToolbarButton, {
|
|
117
|
+
key: "videoButton",
|
|
118
|
+
title: (0, _i18n.__)('Video'),
|
|
119
|
+
icon: _icons.video,
|
|
120
|
+
onClick: onInsertBlock('core/video'),
|
|
121
|
+
testID: "insert-video-button",
|
|
122
|
+
extraProps: {
|
|
123
|
+
hint: (0, _i18n.__)('Insert Video Block')
|
|
124
|
+
}
|
|
125
|
+
}), (0, _element.createElement)(_components.ToolbarButton, {
|
|
126
|
+
key: "galleryButton",
|
|
127
|
+
title: (0, _i18n.__)('Gallery'),
|
|
128
|
+
icon: _icons.gallery,
|
|
129
|
+
onClick: onInsertBlock('core/gallery'),
|
|
130
|
+
testID: "insert-gallery-button",
|
|
131
|
+
extraProps: {
|
|
132
|
+
hint: (0, _i18n.__)('Insert Gallery Block')
|
|
133
|
+
}
|
|
134
|
+
}), (0, _element.createElement)(_components.ToolbarButton, {
|
|
135
|
+
key: "audioButton",
|
|
136
|
+
title: (0, _i18n.__)('Audio'),
|
|
137
|
+
icon: _icons.audio,
|
|
138
|
+
onClick: onInsertBlock('core/audio'),
|
|
139
|
+
testID: "insert-audio-button",
|
|
140
|
+
extraProps: {
|
|
141
|
+
hint: (0, _i18n.__)('Insert Audio Block')
|
|
142
|
+
}
|
|
143
|
+
}));
|
|
109
144
|
/* translators: accessibility text for the editor toolbar */
|
|
110
145
|
|
|
111
146
|
const toolbarAriaLabel = (0, _i18n.__)('Document tools');
|
|
147
|
+
const shadowColor = (0, _compose.usePreferredColorSchemeStyle)(_style.default['header-toolbar__keyboard-hide-shadow--light'], _style.default['header-toolbar__keyboard-hide-shadow--dark']);
|
|
148
|
+
const showKeyboardButtonStyles = [(0, _compose.usePreferredColorSchemeStyle)(_style.default['header-toolbar__keyboard-hide-container'], _style.default['header-toolbar__keyboard-hide-container--dark']), shadowStyle, {
|
|
149
|
+
shadowColor: _element.Platform.isAndroid ? _style.default['header-toolbar__keyboard-hide-shadow--solid'].color : shadowColor.color
|
|
150
|
+
}];
|
|
112
151
|
return (0, _element.createElement)(_reactNative.View, {
|
|
152
|
+
ref: anchorNodeRef,
|
|
113
153
|
testID: toolbarAriaLabel,
|
|
114
154
|
accessibilityLabel: toolbarAriaLabel,
|
|
115
|
-
style:
|
|
155
|
+
style: containerStyle
|
|
116
156
|
}, (0, _element.createElement)(_reactNative.ScrollView, {
|
|
117
157
|
ref: scrollViewRef,
|
|
118
158
|
onContentSizeChange: scrollToStart,
|
|
@@ -122,11 +162,11 @@ function HeaderToolbar({
|
|
|
122
162
|
alwaysBounceHorizontal: false,
|
|
123
163
|
contentContainerStyle: _style.default['header-toolbar__scrollable-content']
|
|
124
164
|
}, (0, _element.createElement)(_blockEditor.Inserter, {
|
|
125
|
-
disabled: !showInserter
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
passedStyle:
|
|
165
|
+
disabled: !showInserter
|
|
166
|
+
}), noContentSelected && renderMediaButtons, (0, _element.createElement)(_blockEditor.BlockToolbar, {
|
|
167
|
+
anchorNodeRef: anchorNodeRef.current
|
|
168
|
+
})), showKeyboardHideButton && (0, _element.createElement)(_components.ToolbarGroup, {
|
|
169
|
+
passedStyle: showKeyboardButtonStyles
|
|
130
170
|
}, (0, _element.createElement)(_components.ToolbarButton, {
|
|
131
171
|
title: (0, _i18n.__)('Hide keyboard'),
|
|
132
172
|
icon: _icons.keyboardClose,
|
|
@@ -159,7 +199,8 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
159
199
|
};
|
|
160
200
|
}), (0, _data.withDispatch)(dispatch => {
|
|
161
201
|
const {
|
|
162
|
-
clearSelectedBlock
|
|
202
|
+
clearSelectedBlock,
|
|
203
|
+
insertBlock
|
|
163
204
|
} = dispatch(_blockEditor.store);
|
|
164
205
|
const {
|
|
165
206
|
togglePostTitleSelection
|
|
@@ -171,12 +212,13 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
171
212
|
onHideKeyboard() {
|
|
172
213
|
clearSelectedBlock();
|
|
173
214
|
togglePostTitleSelection(false);
|
|
174
|
-
}
|
|
215
|
+
},
|
|
175
216
|
|
|
217
|
+
insertBlock
|
|
176
218
|
};
|
|
177
219
|
}), (0, _viewport.withViewportMatch)({
|
|
178
220
|
isLargeViewport: 'medium'
|
|
179
|
-
})
|
|
221
|
+
})])(HeaderToolbar);
|
|
180
222
|
|
|
181
223
|
exports.default = _default;
|
|
182
224
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.native.js"],"names":["HeaderToolbar","hasRedo","hasUndo","redo","undo","showInserter","showKeyboardHideButton","getStylesFromColorScheme","onHideKeyboard","isRTL","noContentSelected","wasNoContentSelected","isInserterOpen","setIsInserterOpen","scrollViewRef","scrollToStart","isAndroid","Platform","OS","current","scrollToEnd","scrollTo","x","renderHistoryButtons","buttons","undoIcon","redoIcon","hint","reverse","onToggleInserter","isOpen","useExpandedMode","toolbarAriaLabel","styles","keyboardClose","select","getBlockRootClientId","getBlockSelectionEnd","hasInserterItems","hasSelectedBlock","blockEditorStore","getEditorSettings","editorStore","isAnyBlockSelected","hasEditorRedo","hasEditorUndo","editPostStore","getEditorMode","richEditingEnabled","isTextModeEnabled","getSettings","dispatch","clearSelectedBlock","togglePostTitleSelection","isLargeViewport","withPreferredColorScheme"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AAKA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;AAIA,SAASA,aAAT,CAAwB;AACvBC,EAAAA,OADuB;AAEvBC,EAAAA,OAFuB;AAGvBC,EAAAA,IAHuB;AAIvBC,EAAAA,IAJuB;AAKvBC,EAAAA,YALuB;AAMvBC,EAAAA,sBANuB;AAOvBC,EAAAA,wBAPuB;AAQvBC,EAAAA,cARuB;AASvBC,EAAAA,KATuB;AAUvBC,EAAAA;AAVuB,CAAxB,EAWI;AACH,QAAMC,oBAAoB,GAAG,qBAAQD,iBAAR,CAA7B;AACA,QAAM,CAAEE,cAAF,EAAkBC,iBAAlB,IAAwC,uBAAU,KAAV,CAA9C;AAEA,QAAMC,aAAa,GAAG,qBAAQ,IAAR,CAAtB;;AACA,QAAMC,aAAa,GAAG,MAAM;AAC3B;AACA,UAAMC,SAAS,GAAGC,sBAASC,EAAT,KAAgB,SAAlC;;AACA,QAAKF,SAAS,IAAIP,KAAlB,EAA0B;AACzBK,MAAAA,aAAa,CAACK,OAAd,CAAsBC,WAAtB;AACA,KAFD,MAEO;AACNN,MAAAA,aAAa,CAACK,OAAd,CAAsBE,QAAtB,CAAgC;AAAEC,QAAAA,CAAC,EAAE;AAAL,OAAhC;AACA;AACD,GARD;;AASA,QAAMC,oBAAoB,GAAG,MAAM;AAClC,UAAMC,OAAO,GAAG;AACf;AACA,gCAAC,yBAAD;AACC,MAAA,GAAG,EAAC,YADL;AAEC,MAAA,KAAK,EAAG,cAAI,MAAJ,CAFT;AAGC,MAAA,IAAI,EAAG,CAAEf,KAAF,GAAUgB,WAAV,G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A4C,QAA5C,IACAN,iBAAiB,GAAGO,kBADpB,IAEAV,gBAAgB,CACfF,oBAAoB,CAAEC,oBAAoB,EAAtB,CADL,CAPX;AAUNY,IAAAA,iBAAiB,EAChBd,MAAM,CAAEW,YAAF,CAAN,CAAwBC,aAAxB,OAA4C,MAXvC;AAYNtC,IAAAA,KAAK,EAAE0B,MAAM,CAAEK,kBAAF,CAAN,CAA2BU,WAA3B,GAAyCzC,KAZ1C;AAaNC,IAAAA,iBAAiB,EAAE,CAAEiC;AAbf,GAAP;AAeA,CAxBD,CADuB,EA0BvB,wBAAgBQ,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAAyBD,QAAQ,CAAEX,kBAAF,CAAvC;AACA,QAAM;AAAEa,IAAAA;AAAF,MAA+BF,QAAQ,CAAET,aAAF,CAA7C;AAEA,SAAO;AACNvC,IAAAA,IAAI,EAAEgD,QAAQ,CAAET,aAAF,CAAR,CAAwBvC,IADxB;AAENC,IAAAA,IAAI,EAAE+C,QAAQ,CAAET,aAAF,CAAR,CAAwBtC,IAFxB;;AAGNI,IAAAA,cAAc,GAAG;AAChB4C,MAAAA,kBAAkB;AAClBC,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AANK,GAAP;AAQA,CAZD,CA1BuB,EAuCvB,iCAAmB;AAAEC,EAAAA,eAAe,EAAE;AAAnB,CAAnB,CAvCuB,EAwCvBC,iCAxCuB,CAAT,EAyCVvD,aAzCU,C","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":["shadowStyle","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","HeaderToolbar","hasRedo","hasUndo","redo","undo","showInserter","showKeyboardHideButton","insertBlock","onHideKeyboard","isRTL","noContentSelected","anchorNodeRef","containerStyle","styles","borderTopWidth","StyleSheet","hairlineWidth","onUndoSubscription","onRedoSubscription","remove","scrollViewRef","scrollToStart","Platform","isAndroid","current","scrollToEnd","scrollTo","x","onInsertBlock","blockType","undefined","source","renderMediaButtons","imageIcon","hint","videoIcon","galleryIcon","audioIcon","toolbarAriaLabel","shadowColor","showKeyboardButtonStyles","color","keyboardClose","select","getBlockRootClientId","getBlockSelectionEnd","hasInserterItems","hasSelectedBlock","blockEditorStore","getEditorSettings","editorStore","isAnyBlockSelected","hasEditorRedo","hasEditorUndo","editPostStore","getEditorMode","richEditingEnabled","isTextModeEnabled","getSettings","dispatch","clearSelectedBlock","togglePostTitleSelection","isLargeViewport"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAOA;;AACA;;AACA;;AAUA;;AACA;;AAvCA;AACA;AACA;;AAGA;AACA;AACA;;AA4BA;AACA;AACA;AAIA,MAAMA,WAAW,GAAG;AACnBC,EAAAA,YAAY,EAAE;AAAEC,IAAAA,KAAK,EAAE,CAAT;AAAYC,IAAAA,MAAM,EAAE;AAApB,GADK;AAEnBC,EAAAA,aAAa,EAAE,CAFI;AAGnBC,EAAAA,YAAY,EAAE,CAHK;AAInBC,EAAAA,SAAS,EAAE;AAJQ,CAApB;;AAOA,SAASC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AF,CAA7C;AAEA,SAAO;AACN/C,IAAAA,IAAI,EAAEwD,QAAQ,CAAET,aAAF,CAAR,CAAwB/C,IADxB;AAENC,IAAAA,IAAI,EAAEuD,QAAQ,CAAET,aAAF,CAAR,CAAwB9C,IAFxB;;AAGNI,IAAAA,cAAc,GAAG;AAChBoD,MAAAA,kBAAkB;AAClBC,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA,KANK;;AAONtD,IAAAA;AAPM,GAAP;AASA,CAdD,CA1BuB,EAyCvB,iCAAmB;AAAEuD,EAAAA,eAAe,EAAE;AAAnB,CAAnB,CAzCuB,CAAT,EA0CV9D,aA1CU,C","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} );\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"]}
|
|
@@ -44,6 +44,31 @@ var _documentTitle = _interopRequireDefault(require("./document-title"));
|
|
|
44
44
|
/**
|
|
45
45
|
* Internal dependencies
|
|
46
46
|
*/
|
|
47
|
+
const slideY = {
|
|
48
|
+
hidden: {
|
|
49
|
+
y: '-50px'
|
|
50
|
+
},
|
|
51
|
+
hover: {
|
|
52
|
+
y: 0,
|
|
53
|
+
transition: {
|
|
54
|
+
type: 'tween',
|
|
55
|
+
delay: 0.2
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const slideX = {
|
|
60
|
+
hidden: {
|
|
61
|
+
x: '-100%'
|
|
62
|
+
},
|
|
63
|
+
hover: {
|
|
64
|
+
x: 0,
|
|
65
|
+
transition: {
|
|
66
|
+
type: 'tween',
|
|
67
|
+
delay: 0.2
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
47
72
|
function Header({
|
|
48
73
|
setEntitiesSavedStatesCallback
|
|
49
74
|
}) {
|
|
@@ -51,38 +76,12 @@ function Header({
|
|
|
51
76
|
const {
|
|
52
77
|
hasActiveMetaboxes,
|
|
53
78
|
isPublishSidebarOpened,
|
|
54
|
-
isSaving,
|
|
55
79
|
showIconLabels
|
|
56
80
|
} = (0, _data.useSelect)(select => ({
|
|
57
81
|
hasActiveMetaboxes: select(_store.store).hasMetaBoxes(),
|
|
58
82
|
isPublishSidebarOpened: select(_store.store).isPublishSidebarOpened(),
|
|
59
|
-
isSaving: select(_store.store).isSavingMetaBoxes(),
|
|
60
83
|
showIconLabels: select(_store.store).isFeatureActive('showIconLabels')
|
|
61
84
|
}), []);
|
|
62
|
-
const slideY = {
|
|
63
|
-
hidden: {
|
|
64
|
-
y: '-50px'
|
|
65
|
-
},
|
|
66
|
-
hover: {
|
|
67
|
-
y: 0,
|
|
68
|
-
transition: {
|
|
69
|
-
type: 'tween',
|
|
70
|
-
delay: 0.2
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const slideX = {
|
|
75
|
-
hidden: {
|
|
76
|
-
x: '-100%'
|
|
77
|
-
},
|
|
78
|
-
hover: {
|
|
79
|
-
x: 0,
|
|
80
|
-
transition: {
|
|
81
|
-
type: 'tween',
|
|
82
|
-
delay: 0.2
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
85
|
return (0, _element.createElement)("div", {
|
|
87
86
|
className: "edit-post-header"
|
|
88
87
|
}, (0, _element.createElement)(_mainDashboardButton.default.Slot, null, (0, _element.createElement)(_components.__unstableMotion.div, {
|
|
@@ -116,14 +115,11 @@ function Header({
|
|
|
116
115
|
// when the publish sidebar has been closed.
|
|
117
116
|
(0, _element.createElement)(_editor.PostSavedState, {
|
|
118
117
|
forceIsDirty: hasActiveMetaboxes,
|
|
119
|
-
forceIsSaving: isSaving,
|
|
120
118
|
showIconLabels: showIconLabels
|
|
121
119
|
}), (0, _element.createElement)(_devicePreview.default, null), (0, _element.createElement)(_editor.PostPreviewButton, {
|
|
122
|
-
forceIsAutosaveable: hasActiveMetaboxes
|
|
123
|
-
forcePreviewLink: isSaving ? null : undefined
|
|
120
|
+
forceIsAutosaveable: hasActiveMetaboxes
|
|
124
121
|
}), (0, _element.createElement)(_viewLink.default, null), (0, _element.createElement)(_postPublishButtonOrToggle.default, {
|
|
125
122
|
forceIsDirty: hasActiveMetaboxes,
|
|
126
|
-
forceIsSaving: isSaving,
|
|
127
123
|
setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
|
|
128
124
|
}), (isLargeViewport || !showIconLabels) && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_interface.PinnedItems.Slot, {
|
|
129
125
|
scope: "core/edit-post"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["slideY","hidden","y","hover","transition","type","delay","slideX","x","Header","setEntitiesSavedStatesCallback","isLargeViewport","hasActiveMetaboxes","isPublishSidebarOpened","showIconLabels","select","editPostStore","hasMetaBoxes","isFeatureActive"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAOA;AACA;AACA;AAWA,MAAMA,MAAM,GAAG;AACdC,EAAAA,MAAM,EAAE;AAAEC,IAAAA,CAAC,EAAE;AAAL,GADM;AAEdC,EAAAA,KAAK,EAAE;AAAED,IAAAA,CAAC,EAAE,CAAL;AAAQE,IAAAA,UAAU,EAAE;AAAEC,MAAAA,IAAI,EAAE,OAAR;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AK,EAAE;AAAxB,KAFd;AAGC,IAAA,SAAS,EAAC;AAHX,KAKC,4BAAC,sBAAD,OALD,EAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,sBAAD,OADD,CAND,CATD,EAmBC,4BAAC,4BAAD,CAAQ,GAAR;AACC,IAAA,QAAQ,EAAGN,MADZ;AAEC,IAAA,UAAU,EAAG;AAAEK,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,KAAK,EAAE;AAAxB,KAFd;AAGC,IAAA,SAAS,EAAC;AAHX,KAKG,CAAEO,sBAAF,IACD;AACA;AACA;AACA;AACA;AACA,8BAAC,sBAAD;AACC,IAAA,YAAY,EAAGD,kBADhB;AAEC,IAAA,cAAc,EAAGE;AAFlB,IAXF,EAgBC,4BAAC,sBAAD,OAhBD,EAiBC,4BAAC,yBAAD;AAAmB,IAAA,mBAAmB,EAAGF;AAAzC,IAjBD,EAkBC,4BAAC,iBAAD,OAlBD,EAmBC,4BAAC,kCAAD;AACC,IAAA,YAAY,EAAGA,kBADhB;AAEC,IAAA,8BAA8B,EAC7BF;AAHF,IAnBD,EAyBG,CAAEC,eAAe,IAAI,CAAEG,cAAvB,KACD,qDACC,4BAAC,sBAAD,CAAa,IAAb;AAAkB,IAAA,KAAK,EAAC;AAAxB,IADD,EAEC,4BAAC,iBAAD;AAAU,IAAA,cAAc,EAAGA;AAA3B,IAFD,CA1BF,EA+BGA,cAAc,IAAI,CAAEH,eAApB,IACD,4BAAC,iBAAD;AAAU,IAAA,cAAc,EAAGG;AAA3B,IAhCF,CAnBD,CADD;AAyDA;;eAEcL,M","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 DocumentTitle from './document-title';\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__document-title\">\n\t\t\t\t\t<DocumentTitle />\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"]}
|
|
@@ -25,7 +25,6 @@ var _store = require("../../store");
|
|
|
25
25
|
*/
|
|
26
26
|
function PostPublishButtonOrToggle({
|
|
27
27
|
forceIsDirty,
|
|
28
|
-
forceIsSaving,
|
|
29
28
|
hasPublishAction,
|
|
30
29
|
isBeingScheduled,
|
|
31
30
|
isPending,
|
|
@@ -75,7 +74,6 @@ function PostPublishButtonOrToggle({
|
|
|
75
74
|
|
|
76
75
|
return (0, _element.createElement)(_editor.PostPublishButton, {
|
|
77
76
|
forceIsDirty: forceIsDirty,
|
|
78
|
-
forceIsSaving: forceIsSaving,
|
|
79
77
|
isOpen: isPublishSidebarOpened,
|
|
80
78
|
isToggle: component === IS_TOGGLE,
|
|
81
79
|
onToggle: togglePublishSidebar,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/header/post-publish-button-or-toggle.js"],"names":["PostPublishButtonOrToggle","forceIsDirty","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/post-publish-button-or-toggle.js"],"names":["PostPublishButtonOrToggle","forceIsDirty","hasPublishAction","isBeingScheduled","isPending","isPublished","isPublishSidebarEnabled","isPublishSidebarOpened","isScheduled","togglePublishSidebar","setEntitiesSavedStatesCallback","IS_TOGGLE","IS_BUTTON","isSmallerThanMediumViewport","component","select","editorStore","getCurrentPost","_links","isEditedPostBeingScheduled","isCurrentPostPending","isCurrentPostPublished","editPostStore","isCurrentPostScheduled","dispatch"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGO,SAASA,yBAAT,CAAoC;AAC1CC,EAAAA,YAD0C;AAE1CC,EAAAA,gBAF0C;AAG1CC,EAAAA,gBAH0C;AAI1CC,EAAAA,SAJ0C;AAK1CC,EAAAA,WAL0C;AAM1CC,EAAAA,uBAN0C;AAO1CC,EAAAA,sBAP0C;AAQ1CC,EAAAA,WAR0C;AAS1CC,EAAAA,oBAT0C;AAU1CC,EAAAA;AAV0C,CAApC,EAWH;AACH,QAAMC,SAAS,GAAG,QAAlB;AACA,QAAMC,SAAS,GAAG,QAAlB;AACA,QAAMC,2BAA2B,GAAG,+BAAkB,QAAlB,EAA4B,GAA5B,CAApC;AACA,MAA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B,EAX0B;AAY3BC,IAAAA,WAAW,EAAEO,MAAM,CAAEC,aAAF,CAAN,CAAsBO,sBAAtB;AAZc,GAAhB;AAAA,CAAZ,CADc,EAed,wBAAgBC,QAAF,IAAgB;AAC7B,QAAM;AAAEf,IAAAA;AAAF,MAA2Be,QAAQ,CAAEF,YAAF,CAAzC;AACA,SAAO;AACNb,IAAAA;AADM,GAAP;AAGA,CALD,CAfc,EAqBZT,yBArBY,C","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"]}
|