@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.
Files changed (130) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/device-preview/index.js +6 -6
  3. package/build/components/device-preview/index.js.map +1 -1
  4. package/build/components/header/header-toolbar/index.js +10 -3
  5. package/build/components/header/header-toolbar/index.js.map +1 -1
  6. package/build/components/header/header-toolbar/index.native.js +91 -49
  7. package/build/components/header/header-toolbar/index.native.js.map +1 -1
  8. package/build/components/header/index.js +26 -30
  9. package/build/components/header/index.js.map +1 -1
  10. package/build/components/header/post-publish-button-or-toggle.js +0 -2
  11. package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
  12. package/build/components/header/preferences-menu-item/index.js +5 -3
  13. package/build/components/header/preferences-menu-item/index.js.map +1 -1
  14. package/build/components/keyboard-shortcut-help-modal/index.js +8 -6
  15. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  16. package/build/components/keyboard-shortcuts/index.js +0 -2
  17. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  18. package/build/components/layout/actions-panel.js +5 -10
  19. package/build/components/layout/actions-panel.js.map +1 -1
  20. package/build/components/layout/index.js +2 -2
  21. package/build/components/layout/index.js.map +1 -1
  22. package/build/components/preferences-modal/index.js +5 -3
  23. package/build/components/preferences-modal/index.js.map +1 -1
  24. package/build/components/sidebar/post-status/index.js +2 -1
  25. package/build/components/sidebar/post-status/index.js.map +1 -1
  26. package/build/components/sidebar/post-trash/index.js +1 -5
  27. package/build/components/sidebar/post-trash/index.js.map +1 -1
  28. package/build/components/text-editor/index.js +1 -1
  29. package/build/components/text-editor/index.js.map +1 -1
  30. package/build/components/visual-editor/header.native.js +1 -13
  31. package/build/components/visual-editor/header.native.js.map +1 -1
  32. package/build/components/visual-editor/index.js +1 -1
  33. package/build/components/visual-editor/index.js.map +1 -1
  34. package/build/editor.js +3 -0
  35. package/build/editor.js.map +1 -1
  36. package/build/hooks/commands/use-common-commands.js +176 -0
  37. package/build/hooks/commands/use-common-commands.js.map +1 -0
  38. package/build/plugins/index.js +35 -6
  39. package/build/plugins/index.js.map +1 -1
  40. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +5 -3
  41. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
  42. package/build/store/actions.js +43 -29
  43. package/build/store/actions.js.map +1 -1
  44. package/build/store/reducer.js +0 -23
  45. package/build/store/reducer.js.map +1 -1
  46. package/build/store/selectors.js +11 -7
  47. package/build/store/selectors.js.map +1 -1
  48. package/build-module/components/device-preview/index.js +6 -6
  49. package/build-module/components/device-preview/index.js.map +1 -1
  50. package/build-module/components/header/header-toolbar/index.js +9 -3
  51. package/build-module/components/header/header-toolbar/index.js.map +1 -1
  52. package/build-module/components/header/header-toolbar/index.native.js +92 -53
  53. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  54. package/build-module/components/header/index.js +25 -30
  55. package/build-module/components/header/index.js.map +1 -1
  56. package/build-module/components/header/post-publish-button-or-toggle.js +0 -2
  57. package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
  58. package/build-module/components/header/preferences-menu-item/index.js +4 -3
  59. package/build-module/components/header/preferences-menu-item/index.js.map +1 -1
  60. package/build-module/components/keyboard-shortcut-help-modal/index.js +5 -5
  61. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  62. package/build-module/components/keyboard-shortcuts/index.js +0 -2
  63. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  64. package/build-module/components/layout/actions-panel.js +5 -10
  65. package/build-module/components/layout/actions-panel.js.map +1 -1
  66. package/build-module/components/layout/index.js +3 -3
  67. package/build-module/components/layout/index.js.map +1 -1
  68. package/build-module/components/preferences-modal/index.js +4 -4
  69. package/build-module/components/preferences-modal/index.js.map +1 -1
  70. package/build-module/components/sidebar/post-status/index.js +2 -1
  71. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  72. package/build-module/components/sidebar/post-trash/index.js +1 -4
  73. package/build-module/components/sidebar/post-trash/index.js.map +1 -1
  74. package/build-module/components/text-editor/index.js +2 -2
  75. package/build-module/components/text-editor/index.js.map +1 -1
  76. package/build-module/components/visual-editor/header.native.js +1 -10
  77. package/build-module/components/visual-editor/header.native.js.map +1 -1
  78. package/build-module/components/visual-editor/index.js +2 -2
  79. package/build-module/components/visual-editor/index.js.map +1 -1
  80. package/build-module/editor.js +2 -0
  81. package/build-module/editor.js.map +1 -1
  82. package/build-module/hooks/commands/use-common-commands.js +160 -0
  83. package/build-module/hooks/commands/use-common-commands.js.map +1 -0
  84. package/build-module/plugins/index.js +33 -6
  85. package/build-module/plugins/index.js.map +1 -1
  86. package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
  87. package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
  88. package/build-module/store/actions.js +35 -25
  89. package/build-module/store/actions.js.map +1 -1
  90. package/build-module/store/reducer.js +0 -21
  91. package/build-module/store/reducer.js.map +1 -1
  92. package/build-module/store/selectors.js +9 -3
  93. package/build-module/store/selectors.js.map +1 -1
  94. package/build-style/style-rtl.css +10 -15
  95. package/build-style/style.css +10 -15
  96. package/package.json +32 -32
  97. package/src/components/block-manager/style.scss +1 -1
  98. package/src/components/device-preview/index.js +35 -39
  99. package/src/components/header/header-toolbar/index.js +5 -1
  100. package/src/components/header/header-toolbar/index.native.js +124 -68
  101. package/src/components/header/header-toolbar/style.native.scss +23 -4
  102. package/src/components/header/index.js +22 -32
  103. package/src/components/header/post-publish-button-or-toggle.js +0 -2
  104. package/src/components/header/preferences-menu-item/index.js +4 -3
  105. package/src/components/keyboard-shortcut-help-modal/index.js +10 -5
  106. package/src/components/keyboard-shortcuts/index.js +0 -2
  107. package/src/components/layout/actions-panel.js +5 -7
  108. package/src/components/layout/index.js +4 -0
  109. package/src/components/layout/style.native.scss +1 -1
  110. package/src/components/preferences-modal/index.js +6 -4
  111. package/src/components/preferences-modal/test/__snapshots__/index.js.snap +11 -3
  112. package/src/components/sidebar/post-status/index.js +1 -0
  113. package/src/components/sidebar/post-trash/index.js +1 -4
  114. package/src/components/start-page-options/style.scss +0 -3
  115. package/src/components/text-editor/index.js +0 -2
  116. package/src/components/visual-editor/header.native.js +1 -17
  117. package/src/components/visual-editor/index.js +1 -6
  118. package/src/components/visual-editor/test/__snapshots__/index.native.js.snap +15 -0
  119. package/src/components/visual-editor/test/index.native.js +118 -1
  120. package/src/editor.js +2 -0
  121. package/src/hooks/commands/use-common-commands.js +155 -0
  122. package/src/plugins/index.js +32 -8
  123. package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +4 -3
  124. package/src/store/actions.js +40 -36
  125. package/src/store/reducer.js +0 -20
  126. package/src/store/selectors.js +11 -3
  127. package/src/store/test/reducer.js +0 -25
  128. package/src/store/test/selectors.js +0 -27
  129. package/src/style.scss +1 -7
  130. package/src/components/visual-editor/style.native.scss +0 -18
@@ -12,6 +12,7 @@ import { Button, ToolbarItem } from '@wordpress/components';
12
12
  import { listView, plus } from '@wordpress/icons';
13
13
  import { useRef, useCallback } from '@wordpress/element';
14
14
  import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
15
+ import { store as preferencesStore } from '@wordpress/preferences';
15
16
  /**
16
17
  * Internal dependencies
17
18
  */
@@ -38,7 +39,8 @@ function HeaderToolbar() {
38
39
  isTextModeEnabled,
39
40
  showIconLabels,
40
41
  isListViewOpen,
41
- listViewShortcut
42
+ listViewShortcut,
43
+ hasFixedToolbar
42
44
  } = useSelect(select => {
43
45
  const {
44
46
  hasInserterItems,
@@ -56,6 +58,9 @@ function HeaderToolbar() {
56
58
  const {
57
59
  getShortcutRepresentation
58
60
  } = select(keyboardShortcutsStore);
61
+ const {
62
+ get: getPreference
63
+ } = select(preferencesStore);
59
64
  return {
60
65
  // This setting (richEditingEnabled) should not live in the block editor's setting.
61
66
  isInserterEnabled: getEditorMode() === 'visual' && getEditorSettings().richEditingEnabled && hasInserterItems(getBlockRootClientId(getBlockSelectionEnd())),
@@ -63,7 +68,8 @@ function HeaderToolbar() {
63
68
  isTextModeEnabled: getEditorMode() === 'text',
64
69
  showIconLabels: isFeatureActive('showIconLabels'),
65
70
  isListViewOpen: isListViewOpened(),
66
- listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view')
71
+ listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view'),
72
+ hasFixedToolbar: getPreference('core/edit-post', 'fixedToolbar')
67
73
  };
68
74
  }, []);
69
75
  const isLargeViewport = useViewportMatch('medium');
@@ -129,7 +135,7 @@ function HeaderToolbar() {
129
135
  icon: plus,
130
136
  label: showIconLabels ? shortLabel : longLabel,
131
137
  showTooltip: !showIconLabels
132
- }), (isWideViewport || !showIconLabels) && createElement(Fragment, null, isLargeViewport && createElement(ToolbarItem, {
138
+ }), (isWideViewport || !showIconLabels) && createElement(Fragment, null, isLargeViewport && !hasFixedToolbar && createElement(ToolbarItem, {
133
139
  as: ToolSelector,
134
140
  showTooltip: !showIconLabels,
135
141
  variant: showIconLabels ? 'tertiary' : undefined,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.js"],"names":["useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","privateApis","blockEditorPrivateApis","EditorHistoryRedo","EditorHistoryUndo","editorStore","Button","ToolbarItem","listView","plus","useRef","useCallback","keyboardShortcutsStore","editPostStore","unlock","useShouldContextualToolbarShow","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getEditorSettings","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","richEditingEnabled","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","undefined","toggleInserter","current","focus","longLabel","shortLabel"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,oBAAjC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SACCC,gBADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,gBAHV,EAICC,WAAW,IAAIC,sBAJhB,QAKO,yBALP;AAMA,SACCC,iBADD,EAECC,iBAFD,EAGCL,KAAK,IAAIM,WAHV,QAIO,mBAJP;AAKA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,kBAA/B;AACA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,oBAApC;AACA,SAASZ,KAAK,IAAIa,sBAAlB,QAAgD,+BAAhD;AAEA;AACA;AACA;;AACA,SAASb,KAAK,IAAIc,aAAlB,QAAuC,gBAAvC;AACA,SAASC,MAAT,QAAuB,sBAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAqCD,MAAM,CAAEZ,sBAAF,CAAjD;;AAEA,MAAMc,cAAc,GAAKC,KAAF,IAAa;AACnCA,EAAAA,KAAK,CAACD,cAAN;AACA,CAFD;;AAIA,SAASE,aAAT,GAAyB;AACxB,QAAMC,cAAc,GAAGT,MAAM,EAA7B;AACA,QAAM;AAAEU,IAAAA,mBAAF;AAAuBC,IAAAA;AAAvB,MACL3B,WAAW,CAAEmB,aAAF,CADZ;AAEA,QAAM;AACLS,IAAAA,iBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,cAJK;AAKLC,IAAAA,cALK;AAMLC,IAAAA;AANK,MAOFlC,SAAS,CAAImC,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAAAA,gBAAF;AAAoBC,MAAAA,oBAApB;AAA0CC,MAAAA;AAA1C,Q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SAJT;AAKC,IAAA,SAAS,EAAGiB,gBALb;AAMC,IAAA,WAAW,EAAGP,cANf;AAOC,IAAA,OAAO,EAAGgC,cAPX;AAQC,IAAA,QAAQ,EAAG,CAAE1B,iBARd;AASC,IAAA,IAAI,EAAGb,IATR;AAUC,IAAA,KAAK,EAAGgB,cAAc,GAAG2B,UAAH,GAAgBD,SAVvC;AAWC,IAAA,WAAW,EAAG,CAAE1B;AAXjB,IADD,EAcG,CAAEc,cAAc,IAAI,CAAEd,cAAtB,KACD,8BACGa,eAAe,IAChB,cAAC,WAAD;AACC,IAAA,EAAE,EAAGxC,YADN;AAEC,IAAA,WAAW,EAAG,CAAE2B,cAFjB;AAGC,IAAA,OAAO,EACNA,cAAc,GAAG,UAAH,GAAgBsB,SAJhC;AAMC,IAAA,QAAQ,EAAGvB;AANZ,IAFF,EAWC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGpB,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEqB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBsB;AAHzC,IAXD,EAgBC,cAAC,WAAD;AACC,IAAA,EAAE,EAAG5C,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEsB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBsB;AAHzC,IAhBD,EAqBGD,aArBH,CAfF,CALD,CADD;AAgDA;;AAED,eAAe5B,aAAf","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":["useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","privateApis","blockEditorPrivateApis","EditorHistoryRedo","EditorHistoryUndo","editorStore","Button","ToolbarItem","listView","plus","useRef","useCallback","keyboardShortcutsStore","preferencesStore","editPostStore","unlock","useShouldContextualToolbarShow","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","hasFixedToolbar","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getEditorSettings","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","get","getPreference","richEditingEnabled","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","fixedToolbarCanBeFocused","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","undefined","toggleInserter","current","focus","longLabel","shortLabel"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,QAAiC,oBAAjC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SACCC,gBADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,gBAHV,EAICC,WAAW,IAAIC,sBAJhB,QAKO,yBALP;AAMA,SACCC,iBADD,EAECC,iBAFD,EAGCL,KAAK,IAAIM,WAHV,QAIO,mBAJP;AAKA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAAS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,SAVvC;AAWC,IAAA,WAAW,EAAG,CAAE7B;AAXjB,IADD,EAcG,CAAEiB,cAAc,IAAI,CAAEjB,cAAtB,KACD,8BACGgB,eAAe,IAAI,CAAEb,eAArB,IACD,cAAC,WAAD;AACC,IAAA,EAAE,EAAG/B,YADN;AAEC,IAAA,WAAW,EAAG,CAAE4B,cAFjB;AAGC,IAAA,OAAO,EACNA,cAAc,GAAG,UAAH,GAAgByB,SAJhC;AAMC,IAAA,QAAQ,EAAG1B;AANZ,IAFF,EAWC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGrB,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEsB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgByB;AAHzC,IAXD,EAgBC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGhD,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEuB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgByB;AAHzC,IAhBD,EAqBGD,aArBH,CAfF,CALD,CADD;AAgDA;;AAED,eAAe/B,aAAf","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"]}
@@ -3,26 +3,37 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import { Platform, ScrollView, View } from 'react-native';
6
+ import { ScrollView, StyleSheet, View } from 'react-native';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { useCallback, useRef, useState } from '@wordpress/element';
12
- import { compose, withPreferredColorScheme } from '@wordpress/compose';
11
+ import { useCallback, useRef, useEffect, Platform } from '@wordpress/element';
12
+ import { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';
13
13
  import { withSelect, withDispatch } from '@wordpress/data';
14
14
  import { withViewportMatch } from '@wordpress/viewport';
15
15
  import { __ } from '@wordpress/i18n';
16
16
  import { Inserter, BlockToolbar, store as blockEditorStore } from '@wordpress/block-editor';
17
17
  import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
18
- import { keyboardClose, undo as undoIcon, redo as redoIcon } from '@wordpress/icons';
18
+ import { keyboardClose, audio as audioIcon, media as imageIcon, video as videoIcon, gallery as galleryIcon } from '@wordpress/icons';
19
19
  import { store as editorStore } from '@wordpress/editor';
20
+ import { createBlock } from '@wordpress/blocks';
21
+ import { toggleUndoButton, toggleRedoButton, subscribeOnUndoPressed, subscribeOnRedoPressed } from '@wordpress/react-native-bridge';
20
22
  /**
21
23
  * Internal dependencies
22
24
  */
23
25
 
24
26
  import styles from './style.scss';
25
27
  import { store as editPostStore } from '../../../store';
28
+ const shadowStyle = {
29
+ shadowOffset: {
30
+ width: 2,
31
+ height: 2
32
+ },
33
+ shadowOpacity: 1,
34
+ shadowRadius: 6,
35
+ elevation: 18
36
+ };
26
37
 
27
38
  function HeaderToolbar({
28
39
  hasRedo,
@@ -31,20 +42,34 @@ function HeaderToolbar({
31
42
  undo,
32
43
  showInserter,
33
44
  showKeyboardHideButton,
34
- getStylesFromColorScheme,
45
+ insertBlock,
35
46
  onHideKeyboard,
36
47
  isRTL,
37
48
  noContentSelected
38
49
  }) {
39
- const wasNoContentSelected = useRef(noContentSelected);
40
- const [isInserterOpen, setIsInserterOpen] = useState(false);
50
+ const anchorNodeRef = useRef();
51
+ const containerStyle = [usePreferredColorSchemeStyle(styles['header-toolbar__container'], styles['header-toolbar__container--dark']), {
52
+ borderTopWidth: StyleSheet.hairlineWidth
53
+ }];
54
+ useEffect(() => {
55
+ const onUndoSubscription = subscribeOnUndoPressed(undo);
56
+ const onRedoSubscription = subscribeOnRedoPressed(redo);
57
+ return () => {
58
+ onUndoSubscription?.remove();
59
+ onRedoSubscription?.remove();
60
+ };
61
+ }, [undo, redo]);
62
+ useEffect(() => {
63
+ toggleUndoButton(!hasUndo);
64
+ }, [hasUndo]);
65
+ useEffect(() => {
66
+ toggleRedoButton(!hasRedo);
67
+ }, [hasRedo]);
41
68
  const scrollViewRef = useRef(null);
42
69
 
43
70
  const scrollToStart = () => {
44
71
  // scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android
45
- const isAndroid = Platform.OS === 'android';
46
-
47
- if (isAndroid && isRTL) {
72
+ if (Platform.isAndroid && isRTL) {
48
73
  scrollViewRef.current.scrollToEnd();
49
74
  } else {
50
75
  scrollViewRef.current.scrollTo({
@@ -53,49 +78,61 @@ function HeaderToolbar({
53
78
  }
54
79
  };
55
80
 
56
- const renderHistoryButtons = () => {
57
- const buttons = [
58
- /* TODO: replace with EditorHistoryRedo and EditorHistoryUndo. */
59
- createElement(ToolbarButton, {
60
- key: "undoButton",
61
- title: __('Undo'),
62
- icon: !isRTL ? undoIcon : redoIcon,
63
- isDisabled: !hasUndo,
64
- onClick: undo,
65
- extraProps: {
66
- hint: __('Double tap to undo last change')
67
- }
68
- }), createElement(ToolbarButton, {
69
- key: "redoButton",
70
- title: __('Redo'),
71
- icon: !isRTL ? redoIcon : undoIcon,
72
- isDisabled: !hasRedo,
73
- onClick: redo,
74
- extraProps: {
75
- hint: __('Double tap to redo last change')
76
- }
77
- })];
78
- return isRTL ? buttons.reverse() : buttons;
79
- };
80
-
81
- const onToggleInserter = useCallback(isOpen => {
82
- if (isOpen) {
83
- wasNoContentSelected.current = noContentSelected;
81
+ const onInsertBlock = useCallback(blockType => () => {
82
+ insertBlock(createBlock(blockType), undefined, undefined, true, {
83
+ source: 'inserter_menu'
84
+ });
85
+ }, [insertBlock]);
86
+ const renderMediaButtons = createElement(ToolbarGroup, null, createElement(ToolbarButton, {
87
+ key: "imageButton",
88
+ title: __('Image'),
89
+ icon: imageIcon,
90
+ onClick: onInsertBlock('core/image'),
91
+ testID: "insert-image-button",
92
+ extraProps: {
93
+ hint: __('Insert Image Block')
84
94
  }
85
-
86
- setIsInserterOpen(isOpen);
87
- }, [noContentSelected]); // Expanded mode should be preserved while the inserter is open.
88
- // This way we prevent style updates during the opening transition.
89
-
90
- const useExpandedMode = isInserterOpen ? wasNoContentSelected.current : noContentSelected;
95
+ }), createElement(ToolbarButton, {
96
+ key: "videoButton",
97
+ title: __('Video'),
98
+ icon: videoIcon,
99
+ onClick: onInsertBlock('core/video'),
100
+ testID: "insert-video-button",
101
+ extraProps: {
102
+ hint: __('Insert Video Block')
103
+ }
104
+ }), createElement(ToolbarButton, {
105
+ key: "galleryButton",
106
+ title: __('Gallery'),
107
+ icon: galleryIcon,
108
+ onClick: onInsertBlock('core/gallery'),
109
+ testID: "insert-gallery-button",
110
+ extraProps: {
111
+ hint: __('Insert Gallery Block')
112
+ }
113
+ }), createElement(ToolbarButton, {
114
+ key: "audioButton",
115
+ title: __('Audio'),
116
+ icon: audioIcon,
117
+ onClick: onInsertBlock('core/audio'),
118
+ testID: "insert-audio-button",
119
+ extraProps: {
120
+ hint: __('Insert Audio Block')
121
+ }
122
+ }));
91
123
  /* translators: accessibility text for the editor toolbar */
92
124
 
93
125
  const toolbarAriaLabel = __('Document tools');
94
126
 
127
+ const shadowColor = usePreferredColorSchemeStyle(styles['header-toolbar__keyboard-hide-shadow--light'], styles['header-toolbar__keyboard-hide-shadow--dark']);
128
+ const showKeyboardButtonStyles = [usePreferredColorSchemeStyle(styles['header-toolbar__keyboard-hide-container'], styles['header-toolbar__keyboard-hide-container--dark']), shadowStyle, {
129
+ shadowColor: Platform.isAndroid ? styles['header-toolbar__keyboard-hide-shadow--solid'].color : shadowColor.color
130
+ }];
95
131
  return createElement(View, {
132
+ ref: anchorNodeRef,
96
133
  testID: toolbarAriaLabel,
97
134
  accessibilityLabel: toolbarAriaLabel,
98
- style: [getStylesFromColorScheme(styles['header-toolbar__container'], styles['header-toolbar__container--dark']), useExpandedMode && styles['header-toolbar__container--expanded']]
135
+ style: containerStyle
99
136
  }, createElement(ScrollView, {
100
137
  ref: scrollViewRef,
101
138
  onContentSizeChange: scrollToStart,
@@ -105,11 +142,11 @@ function HeaderToolbar({
105
142
  alwaysBounceHorizontal: false,
106
143
  contentContainerStyle: styles['header-toolbar__scrollable-content']
107
144
  }, createElement(Inserter, {
108
- disabled: !showInserter,
109
- useExpandedMode: useExpandedMode,
110
- onToggle: onToggleInserter
111
- }), renderHistoryButtons(), createElement(BlockToolbar, null)), showKeyboardHideButton && createElement(ToolbarGroup, {
112
- passedStyle: styles['header-toolbar__keyboard-hide-container']
145
+ disabled: !showInserter
146
+ }), noContentSelected && renderMediaButtons, createElement(BlockToolbar, {
147
+ anchorNodeRef: anchorNodeRef.current
148
+ })), showKeyboardHideButton && createElement(ToolbarGroup, {
149
+ passedStyle: showKeyboardButtonStyles
113
150
  }, createElement(ToolbarButton, {
114
151
  title: __('Hide keyboard'),
115
152
  icon: keyboardClose,
@@ -142,7 +179,8 @@ export default compose([withSelect(select => {
142
179
  };
143
180
  }), withDispatch(dispatch => {
144
181
  const {
145
- clearSelectedBlock
182
+ clearSelectedBlock,
183
+ insertBlock
146
184
  } = dispatch(blockEditorStore);
147
185
  const {
148
186
  togglePostTitleSelection
@@ -154,10 +192,11 @@ export default compose([withSelect(select => {
154
192
  onHideKeyboard() {
155
193
  clearSelectedBlock();
156
194
  togglePostTitleSelection(false);
157
- }
195
+ },
158
196
 
197
+ insertBlock
159
198
  };
160
199
  }), withViewportMatch({
161
200
  isLargeViewport: 'medium'
162
- }), withPreferredColorScheme])(HeaderToolbar);
201
+ })])(HeaderToolbar);
163
202
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.native.js"],"names":["Platform","ScrollView","View","useCallback","useRef","useState","compose","withPreferredColorScheme","withSelect","withDispatch","withViewportMatch","__","Inserter","BlockToolbar","store","blockEditorStore","ToolbarGroup","ToolbarButton","keyboardClose","undo","undoIcon","redo","redoIcon","editorStore","styles","editPostStore","HeaderToolbar","hasRedo","hasUndo","showInserter","showKeyboardHideButton","getStylesFromColorScheme","onHideKeyboard","isRTL","noContentSelected","wasNoContentSelected","isInserterOpen","setIsInserterOpen","scrollViewRef","scrollToStart","isAndroid","OS","current","scrollToEnd","scrollTo","x","renderHistoryButtons","buttons","hint","reverse","onToggleInserter","isOpen","useExpandedMode","toolbarAriaLabel","select","getBlockRootClientId","getBlockSelectionEnd","hasInserterItems","hasSelectedBlock","getEditorSettings","isAnyBlockSelected","hasEditorRedo","hasEditorUndo","getEditorMode","richEditingEnabled","isTextModeEnabled","getSettings","dispatch","clearSelectedBlock","togglePostTitleSelection","isLargeViewport"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,UAAnB,EAA+BC,IAA/B,QAA2C,cAA3C;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,QAA9B,QAA8C,oBAA9C;AACA,SAASC,OAAT,EAAkBC,wBAAlB,QAAkD,oBAAlD;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,EAAT,Q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sBsC,aAAtB,EADH;AAENjC,IAAAA,OAAO,EAAE0B,MAAM,CAAE/B,WAAF,CAAN,CAAsBuC,aAAtB,EAFH;AAGN;AACAjC,IAAAA,YAAY,EACXyB,MAAM,CAAE7B,aAAF,CAAN,CAAwBsC,aAAxB,OAA4C,QAA5C,IACAJ,iBAAiB,GAAGK,kBADpB,IAEAP,gBAAgB,CACfF,oBAAoB,CAAEC,oBAAoB,EAAtB,CADL,CAPX;AAUNS,IAAAA,iBAAiB,EAChBX,MAAM,CAAE7B,aAAF,CAAN,CAAwBsC,aAAxB,OAA4C,MAXvC;AAYN9B,IAAAA,KAAK,EAAEqB,MAAM,CAAEvC,gBAAF,CAAN,CAA2BmD,WAA3B,GAAyCjC,KAZ1C;AAaNC,IAAAA,iBAAiB,EAAE,CAAE0B;AAbf,GAAP;AAeA,CAxBS,CADa,EA0BvBnD,YAAY,CAAI0D,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAAyBD,QAAQ,CAAEpD,gBAAF,CAAvC;AACA,QAAM;AAAEsD,IAAAA;AAAF,MAA+BF,QAAQ,CAAE5C,WAAF,CAA7C;AAEA,SAAO;AACNF,IAAAA,IAAI,EAAE8C,QAAQ,CAAE5C,WAAF,CAAR,CAAwBF,IADxB;AAENF,IAAAA,IAAI,EAAEgD,QAAQ,CAAE5C,WAAF,CAAR,CAAwBJ,IAFxB;;AAGNa,IAAAA,cAAc,GAAG;AAChBoC,MAAAA,kBAAkB;AAClBC,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AANK,GAAP;AAQA,CAZW,CA1BW,EAuCvB3D,iBAAiB,CAAE;AAAE4D,EAAAA,eAAe,EAAE;AAAnB,CAAF,CAvCM,EAwCvB/D,wBAxCuB,CAAF,CAAP,CAyCVmB,aAzCU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { Platform, ScrollView, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { withViewportMatch } from '@wordpress/viewport';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInserter,\n\tBlockToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport {\n\tkeyboardClose,\n\tundo as undoIcon,\n\tredo as redoIcon,\n} from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport { store as editPostStore } from '../../../store';\n\nfunction HeaderToolbar( {\n\thasRedo,\n\thasUndo,\n\tredo,\n\tundo,\n\tshowInserter,\n\tshowKeyboardHideButton,\n\tgetStylesFromColorScheme,\n\tonHideKeyboard,\n\tisRTL,\n\tnoContentSelected,\n} ) {\n\tconst wasNoContentSelected = useRef( noContentSelected );\n\tconst [ isInserterOpen, setIsInserterOpen ] = useState( false );\n\n\tconst scrollViewRef = useRef( null );\n\tconst scrollToStart = () => {\n\t\t// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android\n\t\tconst isAndroid = Platform.OS === 'android';\n\t\tif ( isAndroid && isRTL ) {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t} else {\n\t\t\tscrollViewRef.current.scrollTo( { x: 0 } );\n\t\t}\n\t};\n\tconst renderHistoryButtons = () => {\n\t\tconst buttons = [\n\t\t\t/* TODO: replace with EditorHistoryRedo and EditorHistoryUndo. */\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"undoButton\"\n\t\t\t\ttitle={ __( 'Undo' ) }\n\t\t\t\ticon={ ! isRTL ? undoIcon : redoIcon }\n\t\t\t\tisDisabled={ ! hasUndo }\n\t\t\t\tonClick={ undo }\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Double tap to undo last change' ),\n\t\t\t\t} }\n\t\t\t/>,\n\t\t\t<ToolbarButton\n\t\t\t\tkey=\"redoButton\"\n\t\t\t\ttitle={ __( 'Redo' ) }\n\t\t\t\ticon={ ! isRTL ? redoIcon : undoIcon }\n\t\t\t\tisDisabled={ ! hasRedo }\n\t\t\t\tonClick={ redo }\n\t\t\t\textraProps={ {\n\t\t\t\t\thint: __( 'Double tap to redo last change' ),\n\t\t\t\t} }\n\t\t\t/>,\n\t\t];\n\n\t\treturn isRTL ? buttons.reverse() : buttons;\n\t};\n\n\tconst onToggleInserter = useCallback(\n\t\t( isOpen ) => {\n\t\t\tif ( isOpen ) {\n\t\t\t\twasNoContentSelected.current = noContentSelected;\n\t\t\t}\n\t\t\tsetIsInserterOpen( isOpen );\n\t\t},\n\t\t[ noContentSelected ]\n\t);\n\n\t// Expanded mode should be preserved while the inserter is open.\n\t// This way we prevent style updates during the opening transition.\n\tconst useExpandedMode = isInserterOpen\n\t\t? wasNoContentSelected.current\n\t\t: noContentSelected;\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\treturn (\n\t\t<View\n\t\t\ttestID={ toolbarAriaLabel }\n\t\t\taccessibilityLabel={ toolbarAriaLabel }\n\t\t\tstyle={ [\n\t\t\t\tgetStylesFromColorScheme(\n\t\t\t\t\tstyles[ 'header-toolbar__container' ],\n\t\t\t\t\tstyles[ 'header-toolbar__container--dark' ]\n\t\t\t\t),\n\t\t\t\tuseExpandedMode &&\n\t\t\t\t\tstyles[ 'header-toolbar__container--expanded' ],\n\t\t\t] }\n\t\t>\n\t\t\t<ScrollView\n\t\t\t\tref={ scrollViewRef }\n\t\t\t\tonContentSizeChange={ scrollToStart }\n\t\t\t\thorizontal={ true }\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\talwaysBounceHorizontal={ false }\n\t\t\t\tcontentContainerStyle={\n\t\t\t\t\tstyles[ 'header-toolbar__scrollable-content' ]\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<Inserter\n\t\t\t\t\tdisabled={ ! showInserter }\n\t\t\t\t\tuseExpandedMode={ useExpandedMode }\n\t\t\t\t\tonToggle={ onToggleInserter }\n\t\t\t\t/>\n\t\t\t\t{ renderHistoryButtons() }\n\t\t\t\t<BlockToolbar />\n\t\t\t</ScrollView>\n\t\t\t{ showKeyboardHideButton && (\n\t\t\t\t<ToolbarGroup\n\t\t\t\t\tpassedStyle={\n\t\t\t\t\t\tstyles[ 'header-toolbar__keyboard-hide-container' ]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Hide keyboard' ) }\n\t\t\t\t\t\ticon={ keyboardClose }\n\t\t\t\t\t\tonClick={ onHideKeyboard }\n\t\t\t\t\t\textraProps={ {\n\t\t\t\t\t\t\thint: __( 'Tap to hide the keyboard' ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t) }\n\t\t</View>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\thasInserterItems,\n\t\t\thasSelectedBlock,\n\t\t} = select( blockEditorStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\t\tconst isAnyBlockSelected = hasSelectedBlock();\n\t\treturn {\n\t\t\thasRedo: select( editorStore ).hasEditorRedo(),\n\t\t\thasUndo: select( editorStore ).hasEditorUndo(),\n\t\t\t// This setting (richEditingEnabled) should not live in the block editor's setting.\n\t\t\tshowInserter:\n\t\t\t\tselect( editPostStore ).getEditorMode() === 'visual' &&\n\t\t\t\tgetEditorSettings().richEditingEnabled &&\n\t\t\t\thasInserterItems(\n\t\t\t\t\tgetBlockRootClientId( getBlockSelectionEnd() )\n\t\t\t\t),\n\t\t\tisTextModeEnabled:\n\t\t\t\tselect( editPostStore ).getEditorMode() === 'text',\n\t\t\tisRTL: select( blockEditorStore ).getSettings().isRTL,\n\t\t\tnoContentSelected: ! isAnyBlockSelected,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { clearSelectedBlock } = dispatch( blockEditorStore );\n\t\tconst { togglePostTitleSelection } = dispatch( editorStore );\n\n\t\treturn {\n\t\t\tredo: dispatch( editorStore ).redo,\n\t\t\tundo: dispatch( editorStore ).undo,\n\t\t\tonHideKeyboard() {\n\t\t\t\tclearSelectedBlock();\n\t\t\t\ttogglePostTitleSelection( false );\n\t\t\t},\n\t\t};\n\t} ),\n\twithViewportMatch( { isLargeViewport: 'medium' } ),\n\twithPreferredColorScheme,\n] )( HeaderToolbar );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.native.js"],"names":["ScrollView","StyleSheet","View","useCallback","useRef","useEffect","Platform","compose","usePreferredColorSchemeStyle","withSelect","withDispatch","withViewportMatch","__","Inserter","BlockToolbar","store","blockEditorStore","ToolbarGroup","ToolbarButton","keyboardClose","audio","audioIcon","media","imageIcon","video","videoIcon","gallery","galleryIcon","editorStore","createBlock","toggleUndoButton","toggleRedoButton","subscribeOnUndoPressed","subscribeOnRedoPressed","styles","editPostStore","shadowStyle","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","HeaderToolbar","hasRedo","hasUndo","redo","undo","showInserter","showKeyboardHideButton","insertBlock","onHideKeyboard","isRTL","noContentSelected","anchorNodeRef","containerStyle","borderTopWidth","hairlineWidth","onUndoSubscription","onRedoSubscription","remove","scrollViewRef","scrollToStart","isAndroid","current","scrollToEnd","scrollTo","x","onInsertBlock","blockType","undefined","source","renderMediaButtons","hint","toolbarAriaLabel","shadowColor","showKeyboardButtonStyles","color","select","getBlockRootClientId","getBlockSelectionEnd","hasInserterItems","hasSelectedBlock","getEditorSettings","isAnyBlockSelected","hasEditorRedo","hasEditorUndo","getEditorMode","richEditingEnabled","isTextModeEnabled","getSettings","dispatch","clearSelectedBlock","togglePostTitleSelection","isLargeViewport"],"mappings":";;AAA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A,CAxBS,CADa,EA0BvB1E,YAAY,CAAIiF,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA,kBAAF;AAAsB1C,IAAAA;AAAtB,MACLyC,QAAQ,CAAE3E,gBAAF,CADT;AAEA,QAAM;AAAE6E,IAAAA;AAAF,MAA+BF,QAAQ,CAAE/D,WAAF,CAA7C;AAEA,SAAO;AACNkB,IAAAA,IAAI,EAAE6C,QAAQ,CAAE/D,WAAF,CAAR,CAAwBkB,IADxB;AAENC,IAAAA,IAAI,EAAE4C,QAAQ,CAAE/D,WAAF,CAAR,CAAwBmB,IAFxB;;AAGNI,IAAAA,cAAc,GAAG;AAChByC,MAAAA,kBAAkB;AAClBC,MAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA,KANK;;AAON3C,IAAAA;AAPM,GAAP;AASA,CAdW,CA1BW,EAyCvBvC,iBAAiB,CAAE;AAAEmF,EAAAA,eAAe,EAAE;AAAnB,CAAF,CAzCM,CAAF,CAAP,CA0CVnD,aA1CU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { ScrollView, StyleSheet, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef, useEffect, Platform } from '@wordpress/element';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { withViewportMatch } from '@wordpress/viewport';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInserter,\n\tBlockToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarGroup, ToolbarButton } from '@wordpress/components';\nimport {\n\tkeyboardClose,\n\taudio as audioIcon,\n\tmedia as imageIcon,\n\tvideo as videoIcon,\n\tgallery as galleryIcon,\n} from '@wordpress/icons';\nimport { store as editorStore } from '@wordpress/editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\ttoggleUndoButton,\n\ttoggleRedoButton,\n\tsubscribeOnUndoPressed,\n\tsubscribeOnRedoPressed,\n} from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport { store as editPostStore } from '../../../store';\n\nconst shadowStyle = {\n\tshadowOffset: { width: 2, height: 2 },\n\tshadowOpacity: 1,\n\tshadowRadius: 6,\n\televation: 18,\n};\n\nfunction HeaderToolbar( {\n\thasRedo,\n\thasUndo,\n\tredo,\n\tundo,\n\tshowInserter,\n\tshowKeyboardHideButton,\n\tinsertBlock,\n\tonHideKeyboard,\n\tisRTL,\n\tnoContentSelected,\n} ) {\n\tconst anchorNodeRef = useRef();\n\n\tconst containerStyle = [\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles[ 'header-toolbar__container' ],\n\t\t\tstyles[ 'header-toolbar__container--dark' ]\n\t\t),\n\t\t{ borderTopWidth: StyleSheet.hairlineWidth },\n\t];\n\n\tuseEffect( () => {\n\t\tconst onUndoSubscription = subscribeOnUndoPressed( undo );\n\t\tconst onRedoSubscription = subscribeOnRedoPressed( redo );\n\n\t\treturn () => {\n\t\t\tonUndoSubscription?.remove();\n\t\t\tonRedoSubscription?.remove();\n\t\t};\n\t}, [ undo, redo ] );\n\n\tuseEffect( () => {\n\t\ttoggleUndoButton( ! hasUndo );\n\t}, [ hasUndo ] );\n\n\tuseEffect( () => {\n\t\ttoggleRedoButton( ! hasRedo );\n\t}, [ hasRedo ] );\n\n\tconst scrollViewRef = useRef( null );\n\tconst scrollToStart = () => {\n\t\t// scrollview doesn't seem to automatically adjust to RTL on Android so, scroll to end when Android\n\t\tif ( Platform.isAndroid && isRTL ) {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t} else {\n\t\t\tscrollViewRef.current.scrollTo( { x: 0 } );\n\t\t}\n\t};\n\n\tconst onInsertBlock = useCallback(\n\t\t( blockType ) => () => {\n\t\t\tinsertBlock( createBlock( blockType ), undefined, undefined, true, {\n\t\t\t\tsource: 'inserter_menu',\n\t\t\t} );\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"]}
@@ -21,6 +21,30 @@ import ViewLink from '../view-link';
21
21
  import MainDashboardButton from './main-dashboard-button';
22
22
  import { store as editPostStore } from '../../store';
23
23
  import DocumentTitle from './document-title';
24
+ const slideY = {
25
+ hidden: {
26
+ y: '-50px'
27
+ },
28
+ hover: {
29
+ y: 0,
30
+ transition: {
31
+ type: 'tween',
32
+ delay: 0.2
33
+ }
34
+ }
35
+ };
36
+ const slideX = {
37
+ hidden: {
38
+ x: '-100%'
39
+ },
40
+ hover: {
41
+ x: 0,
42
+ transition: {
43
+ type: 'tween',
44
+ delay: 0.2
45
+ }
46
+ }
47
+ };
24
48
 
25
49
  function Header({
26
50
  setEntitiesSavedStatesCallback
@@ -29,38 +53,12 @@ function Header({
29
53
  const {
30
54
  hasActiveMetaboxes,
31
55
  isPublishSidebarOpened,
32
- isSaving,
33
56
  showIconLabels
34
57
  } = useSelect(select => ({
35
58
  hasActiveMetaboxes: select(editPostStore).hasMetaBoxes(),
36
59
  isPublishSidebarOpened: select(editPostStore).isPublishSidebarOpened(),
37
- isSaving: select(editPostStore).isSavingMetaBoxes(),
38
60
  showIconLabels: select(editPostStore).isFeatureActive('showIconLabels')
39
61
  }), []);
40
- const slideY = {
41
- hidden: {
42
- y: '-50px'
43
- },
44
- hover: {
45
- y: 0,
46
- transition: {
47
- type: 'tween',
48
- delay: 0.2
49
- }
50
- }
51
- };
52
- const slideX = {
53
- hidden: {
54
- x: '-100%'
55
- },
56
- hover: {
57
- x: 0,
58
- transition: {
59
- type: 'tween',
60
- delay: 0.2
61
- }
62
- }
63
- };
64
62
  return createElement("div", {
65
63
  className: "edit-post-header"
66
64
  }, createElement(MainDashboardButton.Slot, null, createElement(motion.div, {
@@ -94,14 +92,11 @@ function Header({
94
92
  // when the publish sidebar has been closed.
95
93
  createElement(PostSavedState, {
96
94
  forceIsDirty: hasActiveMetaboxes,
97
- forceIsSaving: isSaving,
98
95
  showIconLabels: showIconLabels
99
96
  }), createElement(DevicePreview, null), createElement(PostPreviewButton, {
100
- forceIsAutosaveable: hasActiveMetaboxes,
101
- forcePreviewLink: isSaving ? null : undefined
97
+ forceIsAutosaveable: hasActiveMetaboxes
102
98
  }), createElement(ViewLink, null), createElement(PostPublishButtonOrToggle, {
103
99
  forceIsDirty: hasActiveMetaboxes,
104
- forceIsSaving: isSaving,
105
100
  setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
106
101
  }), (isLargeViewport || !showIconLabels) && createElement(Fragment, null, createElement(PinnedItems.Slot, {
107
102
  scope: "core/edit-post"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["PostSavedState","PostPreviewButton","useSelect","PinnedItems","useViewportMatch","__unstableMotion","motion","FullscreenModeClose","HeaderToolbar","MoreMenu","PostPublishButtonOrToggle","default","DevicePreview","ViewLink","MainDashboardButton","store","editPostStore","DocumentTitle","Header","setEntitiesSavedStatesCallback","isLargeViewport","hasActiveMetaboxes","isPublishSidebarOpened","isSaving","showIconLabels","select","hasMetaBoxes","isSavingMetaBoxes","isFeatureActive","slideY","hidden","y","hover","transition","type","delay","slideX","x","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,iBAAzB,QAAkD,mBAAlD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,SAASC,OAAO,IAAIC,aAApB,QAAyC,mBAAzC;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;;AAEA,SAASC,MAAT,CAAiB;AAAEC,EAAAA;AAAF,CAAjB,EAAsD;AACrD,QAAMC,eAAe,GAAGhB,gBAAgB,CAAE,OAAF,CAAxC;AACA,QAAM;AACLiB,IAAAA,kBADK;AAELC,IAAAA,sBAFK;AAGLC,IAAAA,QAHK;A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\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\nfunction Header( { setEntitiesSavedStatesCallback } ) {\n\tconst isLargeViewport = useViewportMatch( 'large' );\n\tconst {\n\t\thasActiveMetaboxes,\n\t\tisPublishSidebarOpened,\n\t\tisSaving,\n\t\tshowIconLabels,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\tisPublishSidebarOpened:\n\t\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\t\tisSaving: select( editPostStore ).isSavingMetaBoxes(),\n\t\t\tshowIconLabels:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst slideY = {\n\t\thidden: { y: '-50px' },\n\t\thover: { y: 0, transition: { type: 'tween', delay: 0.2 } },\n\t};\n\n\tconst slideX = {\n\t\thidden: { x: '-100%' },\n\t\thover: { x: 0, transition: { type: 'tween', delay: 0.2 } },\n\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\tforceIsSaving={ isSaving }\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\n\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t\tforcePreviewLink={ isSaving ? null : undefined }\n\t\t\t\t/>\n\t\t\t\t<ViewLink />\n\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\tforceIsSaving={ isSaving }\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"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/index.js"],"names":["PostSavedState","PostPreviewButton","useSelect","PinnedItems","useViewportMatch","__unstableMotion","motion","FullscreenModeClose","HeaderToolbar","MoreMenu","PostPublishButtonOrToggle","default","DevicePreview","ViewLink","MainDashboardButton","store","editPostStore","DocumentTitle","slideY","hidden","y","hover","transition","type","delay","slideX","x","Header","setEntitiesSavedStatesCallback","isLargeViewport","hasActiveMetaboxes","isPublishSidebarOpened","showIconLabels","select","hasMetaBoxes","isFeatureActive"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,EAAyBC,iBAAzB,QAAkD,mBAAlD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,QAA4B,sBAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,SAASC,OAAO,IAAIC,aAApB,QAAyC,mBAAzC;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AAEA,MAAMC,MAAM,GAAG;AACdC,EAAAA,MAAM,EAAE;AAAEC,IAAAA,CAAC,EAAE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CADD,CADD,EASC,cAAC,MAAD,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,KAKC,cAAC,aAAD,OALD,EAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,aAAD,OADD,CAND,CATD,EAmBC,cAAC,MAAD,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,gBAAC,cAAD;AACC,IAAA,YAAY,EAAGD,kBADhB;AAEC,IAAA,cAAc,EAAGE;AAFlB,IAXF,EAgBC,cAAC,aAAD,OAhBD,EAiBC,cAAC,iBAAD;AAAmB,IAAA,mBAAmB,EAAGF;AAAzC,IAjBD,EAkBC,cAAC,QAAD,OAlBD,EAmBC,cAAC,yBAAD;AACC,IAAA,YAAY,EAAGA,kBADhB;AAEC,IAAA,8BAA8B,EAC7BF;AAHF,IAnBD,EAyBG,CAAEC,eAAe,IAAI,CAAEG,cAAvB,KACD,8BACC,cAAC,WAAD,CAAa,IAAb;AAAkB,IAAA,KAAK,EAAC;AAAxB,IADD,EAEC,cAAC,QAAD;AAAU,IAAA,cAAc,EAAGA;AAA3B,IAFD,CA1BF,EA+BGA,cAAc,IAAI,CAAEH,eAApB,IACD,cAAC,QAAD;AAAU,IAAA,cAAc,EAAGG;AAA3B,IAhCF,CAnBD,CADD;AAyDA;;AAED,eAAeL,MAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PostSavedState, PostPreviewButton } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport FullscreenModeClose from './fullscreen-mode-close';\nimport HeaderToolbar from './header-toolbar';\nimport MoreMenu from './more-menu';\nimport PostPublishButtonOrToggle from './post-publish-button-or-toggle';\nimport { default as DevicePreview } from '../device-preview';\nimport ViewLink from '../view-link';\nimport MainDashboardButton from './main-dashboard-button';\nimport { store as editPostStore } from '../../store';\nimport 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"]}
@@ -13,7 +13,6 @@ import { PostPublishButton, store as editorStore } from '@wordpress/editor';
13
13
  import { store as editPostStore } from '../../store';
14
14
  export function PostPublishButtonOrToggle({
15
15
  forceIsDirty,
16
- forceIsSaving,
17
16
  hasPublishAction,
18
17
  isBeingScheduled,
19
18
  isPending,
@@ -63,7 +62,6 @@ export function PostPublishButtonOrToggle({
63
62
 
64
63
  return createElement(PostPublishButton, {
65
64
  forceIsDirty: forceIsDirty,
66
- forceIsSaving: forceIsSaving,
67
65
  isOpen: isPublishSidebarOpened,
68
66
  isToggle: component === IS_TOGGLE,
69
67
  onToggle: togglePublishSidebar,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/post-publish-button-or-toggle.js"],"names":["useViewportMatch","compose","withDispatch","withSelect","PostPublishButton","store","editorStore","editPostStore","PostPublishButtonOrToggle","forceIsDirty","forceIsSaving","hasPublishAction","isBeingScheduled","isPending","isPublished","isPublishSidebarEnabled","isPublishSidebarOpened","isScheduled","togglePublishSidebar","setEntitiesSavedStatesCallback","IS_TOGGLE","IS_BUTTON","isSmallerThanMediumViewport","component","select","getCurrentPost","_links","isEditedPostBeingScheduled","isCurrentPostPending","isCurrentPostPublished","isCurrentPostScheduled","dispatch"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,OAA3B,QAA0C,oBAA1C;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,iBAAT,EAA4BC,KAAK,IAAIC,WAArC,QAAwD,mBAAxD;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,aAAlB,QAAuC,aAAvC;AAEA,OAAO,SAASC,yBAAT,CAAoC;AAC1CC,EAAAA,YAD0C;AAE1CC,EAAAA,aAF0C;AAG1CC,EAAAA,gBAH0C;AAI1CC,EAAAA,gBAJ0C;AAK1CC,EAAAA,SAL0C;AAM1CC,EAAAA,WAN0C;AAO1CC,EAAAA,uBAP0C;AAQ1CC,EAAAA,sBAR0C;AAS1CC,EAAAA,WAT0C;AAU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sB,oBAAtB,EANgB;AAO3Bd,IAAAA,WAAW,EAAEU,MAAM,CAAElB,WAAF,CAAN,CAAsBuB,sBAAtB,EAPc;AAQ3Bd,IAAAA,uBAAuB,EACtBS,MAAM,CAAElB,WAAF,CAAN,CAAsBS,uBAAtB,EAT0B;AAU3BC,IAAAA,sBAAsB,EACrBQ,MAAM,CAAEjB,aAAF,CAAN,CAAwBS,sBAAxB,EAX0B;AAY3BC,IAAAA,WAAW,EAAEO,MAAM,CAAElB,WAAF,CAAN,CAAsBwB,sBAAtB;AAZc,GAAhB;AAAA,CAAF,CADW,EAerB5B,YAAY,CAAI6B,QAAF,IAAgB;AAC7B,QAAM;AAAEb,IAAAA;AAAF,MAA2Ba,QAAQ,CAAExB,aAAF,CAAzC;AACA,SAAO;AACNW,IAAAA;AADM,GAAP;AAGA,CALW,CAfS,CAAP,CAqBZV,yBArBY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch, compose } from '@wordpress/compose';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { PostPublishButton, store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport function PostPublishButtonOrToggle( {\n\tforceIsDirty,\n\tforceIsSaving,\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\tforceIsSaving={ forceIsSaving }\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"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/post-publish-button-or-toggle.js"],"names":["useViewportMatch","compose","withDispatch","withSelect","PostPublishButton","store","editorStore","editPostStore","PostPublishButtonOrToggle","forceIsDirty","hasPublishAction","isBeingScheduled","isPending","isPublished","isPublishSidebarEnabled","isPublishSidebarOpened","isScheduled","togglePublishSidebar","setEntitiesSavedStatesCallback","IS_TOGGLE","IS_BUTTON","isSmallerThanMediumViewport","component","select","getCurrentPost","_links","isEditedPostBeingScheduled","isCurrentPostPending","isCurrentPostPublished","isCurrentPostScheduled","dispatch"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,OAA3B,QAA0C,oBAA1C;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,iBAAT,EAA4BC,KAAK,IAAIC,WAArC,QAAwD,mBAAxD;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,aAAlB,QAAuC,aAAvC;AAEA,OAAO,SAASC,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,GAAGrB,gBAAgB,CAAE,QAAF,EAAY,GAAZ,CAApD;AACA,MAAIsB,SAAJ;AAEA;AACD;AACA;AACA;A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,EAX0B;AAY3BC,IAAAA,WAAW,EAAEO,MAAM,CAAEjB,WAAF,CAAN,CAAsBuB,sBAAtB;AAZc,GAAhB;AAAA,CAAF,CADW,EAerB3B,YAAY,CAAI4B,QAAF,IAAgB;AAC7B,QAAM;AAAEb,IAAAA;AAAF,MAA2Ba,QAAQ,CAAEvB,aAAF,CAAzC;AACA,SAAO;AACNU,IAAAA;AADM,GAAP;AAGA,CALW,CAfS,CAAP,CAqBZT,yBArBY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch, compose } from '@wordpress/compose';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { PostPublishButton, store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport function PostPublishButtonOrToggle( {\n\tforceIsDirty,\n\thasPublishAction,\n\tisBeingScheduled,\n\tisPending,\n\tisPublished,\n\tisPublishSidebarEnabled,\n\tisPublishSidebarOpened,\n\tisScheduled,\n\ttogglePublishSidebar,\n\tsetEntitiesSavedStatesCallback,\n} ) {\n\tconst IS_TOGGLE = 'toggle';\n\tconst IS_BUTTON = 'button';\n\tconst isSmallerThanMediumViewport = useViewportMatch( 'medium', '<' );\n\tlet component;\n\n\t/**\n\t * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):\n\t *\n\t * 1) We want to show a BUTTON when the post status is at the _final stage_\n\t * for a particular role (see https://wordpress.org/documentation/article/post-status/):\n\t *\n\t * - is published\n\t * - is scheduled to be published\n\t * - is pending and can't be published (but only for viewports >= medium).\n\t * \t Originally, we considered showing a button for pending posts that couldn't be published\n\t * \t (for example, for an author with the contributor role). Some languages can have\n\t * \t long translations for \"Submit for review\", so given the lack of UI real estate available\n\t * \t we decided to take into account the viewport in that case.\n\t * \t See: https://github.com/WordPress/gutenberg/issues/10475\n\t *\n\t * 2) Then, in small viewports, we'll show a TOGGLE.\n\t *\n\t * 3) Finally, we'll use the publish sidebar status to decide:\n\t *\n\t * - if it is enabled, we show a TOGGLE\n\t * - if it is disabled, we show a BUTTON\n\t */\n\tif (\n\t\tisPublished ||\n\t\t( isScheduled && isBeingScheduled ) ||\n\t\t( isPending && ! hasPublishAction && ! isSmallerThanMediumViewport )\n\t) {\n\t\tcomponent = IS_BUTTON;\n\t} else if ( isSmallerThanMediumViewport ) {\n\t\tcomponent = IS_TOGGLE;\n\t} else if ( isPublishSidebarEnabled ) {\n\t\tcomponent = IS_TOGGLE;\n\t} else {\n\t\tcomponent = IS_BUTTON;\n\t}\n\n\treturn (\n\t\t<PostPublishButton\n\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\tisOpen={ isPublishSidebarOpened }\n\t\t\tisToggle={ component === IS_TOGGLE }\n\t\t\tonToggle={ togglePublishSidebar }\n\t\t\tsetEntitiesSavedStatesCallback={ setEntitiesSavedStatesCallback }\n\t\t/>\n\t);\n}\n\nexport default compose(\n\twithSelect( ( select ) => ( {\n\t\thasPublishAction:\n\t\t\tselect( editorStore ).getCurrentPost()?._links?.[\n\t\t\t\t'wp:action-publish'\n\t\t\t] ?? false,\n\t\tisBeingScheduled: select( editorStore ).isEditedPostBeingScheduled(),\n\t\tisPending: select( editorStore ).isCurrentPostPending(),\n\t\tisPublished: select( editorStore ).isCurrentPostPublished(),\n\t\tisPublishSidebarEnabled:\n\t\t\tselect( editorStore ).isPublishSidebarEnabled(),\n\t\tisPublishSidebarOpened:\n\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\tisScheduled: select( editorStore ).isCurrentPostScheduled(),\n\t} ) ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { togglePublishSidebar } = dispatch( editPostStore );\n\t\treturn {\n\t\t\ttogglePublishSidebar,\n\t\t};\n\t} )\n)( PostPublishButtonOrToggle );\n"]}
@@ -6,18 +6,19 @@ import { createElement } from "@wordpress/element";
6
6
  import { useDispatch } from '@wordpress/data';
7
7
  import { __ } from '@wordpress/i18n';
8
8
  import { MenuItem } from '@wordpress/components';
9
+ import { store as interfaceStore } from '@wordpress/interface';
9
10
  /**
10
11
  * Internal dependencies
11
12
  */
12
13
 
13
- import { store as editPostStore } from '../../../store';
14
+ import { PREFERENCES_MODAL_NAME } from '../../../components/preferences-modal';
14
15
  export default function PreferencesMenuItem() {
15
16
  const {
16
17
  openModal
17
- } = useDispatch(editPostStore);
18
+ } = useDispatch(interfaceStore);
18
19
  return createElement(MenuItem, {
19
20
  onClick: () => {
20
- openModal('edit-post/preferences');
21
+ openModal(PREFERENCES_MODAL_NAME);
21
22
  }
22
23
  }, __('Preferences'));
23
24
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/preferences-menu-item/index.js"],"names":["useDispatch","__","MenuItem","store","editPostStore","PreferencesMenuItem","openModal"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,gBAAvC;AAEA,eAAe,SAASC,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA;AAAF,MAAgBN,WAAW,CAAEI,aAAF,CAAjC;AACA,SACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfE,MAAAA,SAAS,CAAE,uBAAF,CAAT;AACA;AAHF,KAKGL,EAAE,CAAE,aAAF,CALL,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function PreferencesMenuItem() {\n\tconst { openModal } = useDispatch( editPostStore );\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\topenModal( 'edit-post/preferences' );\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Preferences' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/preferences-menu-item/index.js"],"names":["useDispatch","__","MenuItem","store","interfaceStore","PREFERENCES_MODAL_NAME","PreferencesMenuItem","openModal"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;;AACA,SAASC,sBAAT,QAAuC,uCAAvC;AAEA,eAAe,SAASC,mBAAT,GAA+B;AAC7C,QAAM;AAAEC,IAAAA;AAAF,MAAgBP,WAAW,CAAEI,cAAF,CAAjC;AACA,SACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,SAAS,CAAEF,sBAAF,CAAT;AACA;AAHF,KAKGJ,EAAE,CAAE,aAAF,CALL,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { PREFERENCES_MODAL_NAME } from '../../../components/preferences-modal';\n\nexport default function PreferencesMenuItem() {\n\tconst { openModal } = useDispatch( interfaceStore );\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\topenModal( PREFERENCES_MODAL_NAME );\n\t\t\t} }\n\t\t>\n\t\t\t{ __( 'Preferences' ) }\n\t\t</MenuItem>\n\t);\n}\n"]}