@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
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"]}
|
|
@@ -30,7 +30,7 @@ var _store = require("../../../store");
|
|
|
30
30
|
/**
|
|
31
31
|
* Internal dependencies
|
|
32
32
|
*/
|
|
33
|
-
function
|
|
33
|
+
function DocumentActions() {
|
|
34
34
|
const {
|
|
35
35
|
template,
|
|
36
36
|
isEditing
|
|
@@ -70,19 +70,19 @@ function DocumentTitle() {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
return (0, _element.createElement)("div", {
|
|
73
|
-
className: "edit-post-document-
|
|
74
|
-
}, (0, _element.createElement)("span", {
|
|
75
|
-
className: "edit-post-document-title__left"
|
|
73
|
+
className: "edit-post-document-actions"
|
|
76
74
|
}, (0, _element.createElement)(_components.Button, {
|
|
75
|
+
className: "edit-post-document-actions__back",
|
|
77
76
|
onClick: () => {
|
|
78
77
|
clearSelectedBlock();
|
|
79
78
|
setIsEditingTemplate(false);
|
|
80
79
|
},
|
|
81
80
|
icon: (0, _i18n.isRTL)() ? _icons.chevronRightSmall : _icons.chevronLeftSmall
|
|
82
|
-
}, (0, _i18n.__)('Back'))
|
|
83
|
-
className: "edit-post-document-
|
|
81
|
+
}, (0, _i18n.__)('Back')), (0, _element.createElement)(_components.Button, {
|
|
82
|
+
className: "edit-post-document-actions__command",
|
|
84
83
|
onClick: () => openCommandCenter()
|
|
85
84
|
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
85
|
+
className: "edit-post-document-actions__title",
|
|
86
86
|
spacing: 1,
|
|
87
87
|
justify: "center"
|
|
88
88
|
}, (0, _element.createElement)(_blockEditor.BlockIcon, {
|
|
@@ -92,12 +92,11 @@ function DocumentTitle() {
|
|
|
92
92
|
as: "h1"
|
|
93
93
|
}, (0, _element.createElement)(_components.VisuallyHidden, {
|
|
94
94
|
as: "span"
|
|
95
|
-
}, (0, _i18n.__)('Editing template: ')), templateTitle))
|
|
96
|
-
className: "edit-post-document-
|
|
97
|
-
|
|
98
|
-
}, _keycodes.displayShortcut.primary('k')));
|
|
95
|
+
}, (0, _i18n.__)('Editing template: ')), templateTitle)), (0, _element.createElement)("span", {
|
|
96
|
+
className: "edit-post-document-actions__shortcut"
|
|
97
|
+
}, _keycodes.displayShortcut.primary('k'))));
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
var _default =
|
|
100
|
+
var _default = DocumentActions;
|
|
102
101
|
exports.default = _default;
|
|
103
102
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/header/document-actions/index.js"],"names":["DocumentActions","template","isEditing","select","isEditingTemplate","getEditedPostTemplate","editPostStore","_isEditing","clearSelectedBlock","blockEditorStore","setIsEditingTemplate","open","openCommandCenter","commandsStore","templateTitle","title","slug","chevronRightSmall","chevronLeftSmall","layout","displayShortcut","primary"],"mappings":";;;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;AANtC,KAQG,cAAI,MAAJ,CARH,CADD,EAWC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,OAAO,EAAG,MAAMN,iBAAiB;AAFlC,KAIC,4BAAC,gCAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAG,CAFX;AAGC,IAAA,OAAO,EAAC;AAHT,KAKC,4BAAC,sBAAD;AAAW,IAAA,IAAI,EAAGO;AAAlB,IALD,EAMC,4BAAC,8BAAD;AAAM,IAAA,IAAI,EAAC,MAAX;AAAkB,IAAA,EAAE,EAAC;AAArB,KACC,4BAAC,0BAAD;AAAgB,IAAA,EAAE,EAAC;AAAnB,KACG,cAAI,oBAAJ,CADH,CADD,EAIGL,aAJH,CAND,CAJD,EAiBC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGM,0BAAgBC,OAAhB,CAAyB,GAAzB,CADH,CAjBD,CAXD,CADD;AAmCA;;eAEcrB,e","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tVisuallyHidden,\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n} from '@wordpress/components';\nimport { layout, chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nfunction DocumentActions() {\n\tconst { template, isEditing } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } =\n\t\t\tselect( editPostStore );\n\t\tconst _isEditing = isEditingTemplate();\n\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t\tisEditing: _isEditing,\n\t\t};\n\t}, [] );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\n\tif ( ! isEditing || ! template ) {\n\t\treturn null;\n\t}\n\n\tlet templateTitle = __( 'Default' );\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t} else if ( !! template ) {\n\t\ttemplateTitle = template.slug;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-post-document-actions\">\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-actions__back\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t\tsetIsEditingTemplate( false );\n\t\t\t\t} }\n\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t>\n\t\t\t\t{ __( 'Back' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-post-document-actions__command\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-post-document-actions__title\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t>\n\t\t\t\t\t<BlockIcon icon={ layout } />\n\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t{ __( 'Editing template: ' ) }\n\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t{ templateTitle }\n\t\t\t\t\t</Text>\n\t\t\t\t</HStack>\n\t\t\t\t<span className=\"edit-post-document-actions__shortcut\">\n\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t</span>\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nexport default DocumentActions;\n"]}
|
|
@@ -50,17 +50,14 @@ function HeaderToolbar() {
|
|
|
50
50
|
setIsInserterOpened,
|
|
51
51
|
setIsListViewOpened
|
|
52
52
|
} = (0, _data.useDispatch)(_store.store);
|
|
53
|
-
const {
|
|
54
|
-
get: getPreference
|
|
55
|
-
} = (0, _data.useSelect)(_preferences.store);
|
|
56
|
-
const hasFixedToolbar = getPreference('core/edit-post', 'fixedToolbar');
|
|
57
53
|
const {
|
|
58
54
|
isInserterEnabled,
|
|
59
55
|
isInserterOpened,
|
|
60
56
|
isTextModeEnabled,
|
|
61
57
|
showIconLabels,
|
|
62
58
|
isListViewOpen,
|
|
63
|
-
listViewShortcut
|
|
59
|
+
listViewShortcut,
|
|
60
|
+
hasFixedToolbar
|
|
64
61
|
} = (0, _data.useSelect)(select => {
|
|
65
62
|
const {
|
|
66
63
|
hasInserterItems,
|
|
@@ -78,6 +75,9 @@ function HeaderToolbar() {
|
|
|
78
75
|
const {
|
|
79
76
|
getShortcutRepresentation
|
|
80
77
|
} = select(_keyboardShortcuts.store);
|
|
78
|
+
const {
|
|
79
|
+
get: getPreference
|
|
80
|
+
} = select(_preferences.store);
|
|
81
81
|
return {
|
|
82
82
|
// This setting (richEditingEnabled) should not live in the block editor's setting.
|
|
83
83
|
isInserterEnabled: getEditorMode() === 'visual' && getEditorSettings().richEditingEnabled && hasInserterItems(getBlockRootClientId(getBlockSelectionEnd())),
|
|
@@ -85,7 +85,8 @@ function HeaderToolbar() {
|
|
|
85
85
|
isTextModeEnabled: getEditorMode() === 'text',
|
|
86
86
|
showIconLabels: isFeatureActive('showIconLabels'),
|
|
87
87
|
isListViewOpen: isListViewOpened(),
|
|
88
|
-
listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view')
|
|
88
|
+
listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view'),
|
|
89
|
+
hasFixedToolbar: getPreference('core/edit-post', 'fixedToolbar')
|
|
89
90
|
};
|
|
90
91
|
}, []);
|
|
91
92
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
@@ -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","get","getPreference","preferencesStore","hasFixedToolbar","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;;AACA;;AAKA;;AACA;;AA3BA;AACA;AACA;;AAqBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAqC,wBAAQC,wBAAR,CAA3C;;AAEA,MAAMC,cAAc,GAAKC,KAAF,IAAa;AACnCA,EAAAA,KAAK,CAACD,cAAN;AACA,CAFD;;AAIA,SAASE,aAAT,GAAyB;AACxB,QAAMC,cAAc,GAAG,sBAAvB;AACA,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACL,uBAAaC,YAAb,CADD;AAEA,QAAM;AAAEC,IAAAA,GAAG,EAAEC;AAAP,MAAyB,qBAAWC,kBAAX,CAA/B;AACA,QAAMC,eAAe,GAAGF,aAAa,CAAE,gBAAF,EAAoB,cAApB,CAArC;AACA,QAAM;AACLG,IAAAA,iBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,cAJK;AAKLC,IAAAA,cALK;AAMLC,IAAAA;AANK,MAOF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAA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AAKC,IAAA,SAAS,EAAG3B,gBALb;AAMC,IAAA,WAAW,EAAGZ,cANf;AAOC,IAAA,OAAO,EAAG0C,cAPX;AAQC,IAAA,QAAQ,EAAG,CAAE/B,iBARd;AASC,IAAA,IAAI,EAAGoC,WATR;AAUC,IAAA,KAAK,EAAGjC,cAAc,GAAGgC,UAAH,GAAgBD,SAVvC;AAWC,IAAA,WAAW,EAAG,CAAE/B;AAXjB,IADD,EAcG,CAAEiB,cAAc,IAAI,CAAEjB,cAAtB,KACD,qDACGgB,eAAe,IAAI,CAAEpB,eAArB,IACD,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGsC,yBADN;AAEC,IAAA,WAAW,EAAG,CAAElC,cAFjB;AAGC,IAAA,OAAO,EACNA,cAAc,GAAG,UAAH,GAAgB2B,SAJhC;AAMC,IAAA,QAAQ,EAAG5B;AANZ,IAFF,EAWC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGoC,yBADN;AAEC,IAAA,WAAW,EAAG,CAAEnC,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgB2B;AAHzC,IAXD,EAgBC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGS,yBADN;AAEC,IAAA,WAAW,EAAG,CAAEpC,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgB2B;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 { get: getPreference } = useSelect( preferencesStore );\n\tconst hasFixedToolbar = getPreference( 'core/edit-post', 'fixedToolbar' );\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 && ! 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"]}
|
|
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":";;;;;;;AAmBA;;AAhBA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AA3BA;AACA;AACA;;AAqBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAqC,wBAAQC,wBAAR,CAA3C;;AAEA,MAAMC,cAAc,GAAKC,KAAF,IAAa;AACnCA,EAAAA,KAAK,CAACD,cAAN;AACA,CAFD;;AAIA,SAASE,aAAT,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AAW,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,61 @@ function HeaderToolbar({
|
|
|
71
99
|
}
|
|
72
100
|
};
|
|
73
101
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
inserterMethod: 'quick-inserter'
|
|
106
|
+
});
|
|
107
|
+
}, [insertBlock]);
|
|
108
|
+
const renderMediaButtons = (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, {
|
|
109
|
+
key: "imageButton",
|
|
110
|
+
title: (0, _i18n.__)('Image'),
|
|
111
|
+
icon: _icons.media,
|
|
112
|
+
onClick: onInsertBlock('core/image'),
|
|
113
|
+
testID: "insert-image-button",
|
|
114
|
+
extraProps: {
|
|
115
|
+
hint: (0, _i18n.__)('Insert Image Block')
|
|
102
116
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
}), (0, _element.createElement)(_components.ToolbarButton, {
|
|
118
|
+
key: "videoButton",
|
|
119
|
+
title: (0, _i18n.__)('Video'),
|
|
120
|
+
icon: _icons.video,
|
|
121
|
+
onClick: onInsertBlock('core/video'),
|
|
122
|
+
testID: "insert-video-button",
|
|
123
|
+
extraProps: {
|
|
124
|
+
hint: (0, _i18n.__)('Insert Video Block')
|
|
125
|
+
}
|
|
126
|
+
}), (0, _element.createElement)(_components.ToolbarButton, {
|
|
127
|
+
key: "galleryButton",
|
|
128
|
+
title: (0, _i18n.__)('Gallery'),
|
|
129
|
+
icon: _icons.gallery,
|
|
130
|
+
onClick: onInsertBlock('core/gallery'),
|
|
131
|
+
testID: "insert-gallery-button",
|
|
132
|
+
extraProps: {
|
|
133
|
+
hint: (0, _i18n.__)('Insert Gallery Block')
|
|
134
|
+
}
|
|
135
|
+
}), (0, _element.createElement)(_components.ToolbarButton, {
|
|
136
|
+
key: "audioButton",
|
|
137
|
+
title: (0, _i18n.__)('Audio'),
|
|
138
|
+
icon: _icons.audio,
|
|
139
|
+
onClick: onInsertBlock('core/audio'),
|
|
140
|
+
testID: "insert-audio-button",
|
|
141
|
+
extraProps: {
|
|
142
|
+
hint: (0, _i18n.__)('Insert Audio Block')
|
|
143
|
+
}
|
|
144
|
+
}));
|
|
109
145
|
/* translators: accessibility text for the editor toolbar */
|
|
110
146
|
|
|
111
147
|
const toolbarAriaLabel = (0, _i18n.__)('Document tools');
|
|
148
|
+
const shadowColor = (0, _compose.usePreferredColorSchemeStyle)(_style.default['header-toolbar__keyboard-hide-shadow--light'], _style.default['header-toolbar__keyboard-hide-shadow--dark']);
|
|
149
|
+
const showKeyboardButtonStyles = [(0, _compose.usePreferredColorSchemeStyle)(_style.default['header-toolbar__keyboard-hide-container'], _style.default['header-toolbar__keyboard-hide-container--dark']), shadowStyle, {
|
|
150
|
+
shadowColor: _element.Platform.isAndroid ? _style.default['header-toolbar__keyboard-hide-shadow--solid'].color : shadowColor.color
|
|
151
|
+
}];
|
|
112
152
|
return (0, _element.createElement)(_reactNative.View, {
|
|
153
|
+
ref: anchorNodeRef,
|
|
113
154
|
testID: toolbarAriaLabel,
|
|
114
155
|
accessibilityLabel: toolbarAriaLabel,
|
|
115
|
-
style:
|
|
156
|
+
style: containerStyle
|
|
116
157
|
}, (0, _element.createElement)(_reactNative.ScrollView, {
|
|
117
158
|
ref: scrollViewRef,
|
|
118
159
|
onContentSizeChange: scrollToStart,
|
|
@@ -122,11 +163,11 @@ function HeaderToolbar({
|
|
|
122
163
|
alwaysBounceHorizontal: false,
|
|
123
164
|
contentContainerStyle: _style.default['header-toolbar__scrollable-content']
|
|
124
165
|
}, (0, _element.createElement)(_blockEditor.Inserter, {
|
|
125
|
-
disabled: !showInserter
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
passedStyle:
|
|
166
|
+
disabled: !showInserter
|
|
167
|
+
}), noContentSelected && renderMediaButtons, (0, _element.createElement)(_blockEditor.BlockToolbar, {
|
|
168
|
+
anchorNodeRef: anchorNodeRef.current
|
|
169
|
+
})), showKeyboardHideButton && (0, _element.createElement)(_components.ToolbarGroup, {
|
|
170
|
+
passedStyle: showKeyboardButtonStyles
|
|
130
171
|
}, (0, _element.createElement)(_components.ToolbarButton, {
|
|
131
172
|
title: (0, _i18n.__)('Hide keyboard'),
|
|
132
173
|
icon: _icons.keyboardClose,
|
|
@@ -159,7 +200,8 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
159
200
|
};
|
|
160
201
|
}), (0, _data.withDispatch)(dispatch => {
|
|
161
202
|
const {
|
|
162
|
-
clearSelectedBlock
|
|
203
|
+
clearSelectedBlock,
|
|
204
|
+
insertBlock
|
|
163
205
|
} = dispatch(_blockEditor.store);
|
|
164
206
|
const {
|
|
165
207
|
togglePostTitleSelection
|
|
@@ -171,12 +213,13 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
171
213
|
onHideKeyboard() {
|
|
172
214
|
clearSelectedBlock();
|
|
173
215
|
togglePostTitleSelection(false);
|
|
174
|
-
}
|
|
216
|
+
},
|
|
175
217
|
|
|
218
|
+
insertBlock
|
|
176
219
|
};
|
|
177
220
|
}), (0, _viewport.withViewportMatch)({
|
|
178
221
|
isLargeViewport: 'medium'
|
|
179
|
-
})
|
|
222
|
+
})])(HeaderToolbar);
|
|
180
223
|
|
|
181
224
|
exports.default = _default;
|
|
182
225
|
//# 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;;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B,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","inserterMethod","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,aAAT,CAAwB;AACvBC,EAAAA,OADuB;AAEvBC,EAAAA,OAFuB;AAGvBC,EAAAA,IAHuB;AAIvBC,EAAAA,IAJuB;AAKvBC,EAAAA,YALuB;AAMvBC,EAAAA,sBANuB;AAOvBC,EAAAA,WAPuB;AAQvBC,EAAAA,cARuB;AASvBC,EAAAA,KATuB;AAUvBC,EAAAA;AAVuB,CAAxB,EAWI;AAC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ClBC,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA,KANK;;AAONvD,IAAAA;AAPM,GAAP;AASA,CAdD,CA1BuB,EAyCvB,iCAAmB;AAAEwD,EAAAA,eAAe,EAAE;AAAnB,CAAnB,CAzCuB,CAAT,EA0CV/D,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\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"]}
|
|
@@ -35,7 +35,7 @@ var _mainDashboardButton = _interopRequireDefault(require("./main-dashboard-butt
|
|
|
35
35
|
|
|
36
36
|
var _store = require("../../store");
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _documentActions = _interopRequireDefault(require("./document-actions"));
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* WordPress dependencies
|
|
@@ -76,12 +76,10 @@ function Header({
|
|
|
76
76
|
const {
|
|
77
77
|
hasActiveMetaboxes,
|
|
78
78
|
isPublishSidebarOpened,
|
|
79
|
-
isSaving,
|
|
80
79
|
showIconLabels
|
|
81
80
|
} = (0, _data.useSelect)(select => ({
|
|
82
81
|
hasActiveMetaboxes: select(_store.store).hasMetaBoxes(),
|
|
83
82
|
isPublishSidebarOpened: select(_store.store).isPublishSidebarOpened(),
|
|
84
|
-
isSaving: select(_store.store).isSavingMetaBoxes(),
|
|
85
83
|
showIconLabels: select(_store.store).isFeatureActive('showIconLabels')
|
|
86
84
|
}), []);
|
|
87
85
|
return (0, _element.createElement)("div", {
|
|
@@ -102,8 +100,8 @@ function Header({
|
|
|
102
100
|
},
|
|
103
101
|
className: "edit-post-header__toolbar"
|
|
104
102
|
}, (0, _element.createElement)(_headerToolbar.default, null), (0, _element.createElement)("div", {
|
|
105
|
-
className: "edit-post-
|
|
106
|
-
}, (0, _element.createElement)(
|
|
103
|
+
className: "edit-post-header__center"
|
|
104
|
+
}, (0, _element.createElement)(_documentActions.default, null))), (0, _element.createElement)(_components.__unstableMotion.div, {
|
|
107
105
|
variants: slideY,
|
|
108
106
|
transition: {
|
|
109
107
|
type: 'tween',
|
|
@@ -117,14 +115,11 @@ function Header({
|
|
|
117
115
|
// when the publish sidebar has been closed.
|
|
118
116
|
(0, _element.createElement)(_editor.PostSavedState, {
|
|
119
117
|
forceIsDirty: hasActiveMetaboxes,
|
|
120
|
-
forceIsSaving: isSaving,
|
|
121
118
|
showIconLabels: showIconLabels
|
|
122
119
|
}), (0, _element.createElement)(_devicePreview.default, null), (0, _element.createElement)(_editor.PostPreviewButton, {
|
|
123
|
-
forceIsAutosaveable: hasActiveMetaboxes
|
|
124
|
-
forcePreviewLink: isSaving ? null : undefined
|
|
120
|
+
forceIsAutosaveable: hasActiveMetaboxes
|
|
125
121
|
}), (0, _element.createElement)(_viewLink.default, null), (0, _element.createElement)(_postPublishButtonOrToggle.default, {
|
|
126
122
|
forceIsDirty: hasActiveMetaboxes,
|
|
127
|
-
forceIsSaving: isSaving,
|
|
128
123
|
setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
|
|
129
124
|
}), (isLargeViewport || !showIconLabels) && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_interface.PinnedItems.Slot, {
|
|
130
125
|
scope: "core/edit-post"
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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;AAAiBC,MAAAA,KAAK,EAAE;AAAxB;AAApB;AAFO,CAAf;AAKA,MAAMC,MAAM,GAAG;AACdN,EAAAA,MAAM,EAAE;AAAEO,IAAAA,CAAC,EAAE;AAAL,GADM;AAEdL,EAAAA,KAAK,EAAE;AAAEK,IAAAA,CAAC,EAAE,CAAL;AAAQJ,IAAAA,UAAU,EAAE;AAAEC,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,KAAK,EAAE;AAAxB;AAApB;AAFO,CAAf;;AAKA,SAASG,MAAT,CAAiB;AAAEC,EAAAA;AAAF,CAAjB,EAAsD;AACrD,QAAMC,eAAe,GAAG,+BAAkB,OAAlB,CAAxB;AACA,QAAM;AAAEC,IAAAA,kBAAF;AAAsBC,IAAAA,sBAAtB;AAA8CC,IAAAA;AAA9C,MACL,qBACGC,MAAF,KAAgB;AACfH,IAAAA,kBAAkB,EAAEG,MAAM,CAAEC,YAAF,CAAN,CAAwBC,YAAxB,EADL;AAEfJ,IAAAA,sBAAsB,EACrBE,MAAM,CAAEC,YAAF,CAAN,CAAwBH,sBAAxB,EAHc;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AHF,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 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"]}
|