@wordpress/edit-post 7.8.0 → 7.9.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 (28) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/header/header-toolbar/index.js +23 -3
  3. package/build/components/header/header-toolbar/index.js.map +1 -1
  4. package/build/components/header/template-title/delete-template.js +1 -1
  5. package/build/components/header/template-title/delete-template.js.map +1 -1
  6. package/build/components/header/template-title/edit-template-title.js +2 -7
  7. package/build/components/header/template-title/edit-template-title.js.map +1 -1
  8. package/build/components/start-page-options/index.js +1 -0
  9. package/build/components/start-page-options/index.js.map +1 -1
  10. package/build-module/components/header/header-toolbar/index.js +23 -4
  11. package/build-module/components/header/header-toolbar/index.js.map +1 -1
  12. package/build-module/components/header/template-title/delete-template.js +1 -1
  13. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  14. package/build-module/components/header/template-title/edit-template-title.js +2 -7
  15. package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
  16. package/build-module/components/start-page-options/index.js +1 -0
  17. package/build-module/components/start-page-options/index.js.map +1 -1
  18. package/build-style/style-rtl.css +74 -18
  19. package/build-style/style.css +74 -18
  20. package/package.json +31 -31
  21. package/src/components/header/header-toolbar/index.js +28 -3
  22. package/src/components/header/template-title/delete-template.js +0 -1
  23. package/src/components/header/template-title/edit-template-title.js +4 -7
  24. package/src/components/layout/style.scss +12 -0
  25. package/src/components/secondary-sidebar/style.scss +20 -5
  26. package/src/components/start-page-options/index.js +1 -0
  27. package/src/components/start-page-options/style.scss +11 -15
  28. package/src/components/visual-editor/style.scss +1 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 7.9.0 (2023-04-26)
6
+
5
7
  ## 7.8.0 (2023-04-12)
6
8
 
7
9
  ## 7.7.0 (2023-03-29)
@@ -25,6 +25,8 @@ var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
25
25
 
26
26
  var _store = require("../../../store");
27
27
 
28
+ var _privateApis = require("../../../private-apis");
29
+
28
30
  /**
29
31
  * WordPress dependencies
30
32
  */
@@ -48,12 +50,17 @@ function HeaderToolbar() {
48
50
  isTextModeEnabled,
49
51
  showIconLabels,
50
52
  isListViewOpen,
51
- listViewShortcut
53
+ listViewShortcut,
54
+ selectedBlockId,
55
+ hasFixedToolbar
52
56
  } = (0, _data.useSelect)(select => {
53
57
  const {
54
58
  hasInserterItems,
55
59
  getBlockRootClientId,
56
- getBlockSelectionEnd
60
+ getBlockSelectionEnd,
61
+ getSelectedBlockClientId,
62
+ getFirstMultiSelectedBlockClientId,
63
+ getSettings
57
64
  } = select(_blockEditor.store);
58
65
  const {
59
66
  getEditorSettings
@@ -67,6 +74,8 @@ function HeaderToolbar() {
67
74
  getShortcutRepresentation
68
75
  } = select(_keyboardShortcuts.store);
69
76
  return {
77
+ hasFixedToolbar: getSettings().hasFixedToolbar,
78
+ selectedBlockId: getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId(),
70
79
  // This setting (richEditingEnabled) should not live in the block editor's setting.
71
80
  isInserterEnabled: getEditorMode() === 'visual' && getEditorSettings().richEditingEnabled && hasInserterItems(getBlockRootClientId(getBlockSelectionEnd())),
72
81
  isInserterOpened: select(_store.store).isInserterOpened(),
@@ -76,8 +85,18 @@ function HeaderToolbar() {
76
85
  listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view')
77
86
  };
78
87
  }, []);
88
+ const {
89
+ useShouldContextualToolbarShow
90
+ } = (0, _privateApis.unlock)(_blockEditor.privateApis);
79
91
  const isLargeViewport = (0, _compose.useViewportMatch)('medium');
80
92
  const isWideViewport = (0, _compose.useViewportMatch)('wide');
93
+ const {
94
+ shouldShowContextualToolbar,
95
+ canFocusHiddenToolbar
96
+ } = useShouldContextualToolbarShow(selectedBlockId); // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
97
+ // There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
98
+
99
+ const blockToolbarCanBeFocused = shouldShowContextualToolbar || canFocusHiddenToolbar || (hasFixedToolbar || !isLargeViewport) && selectedBlockId;
81
100
  /* translators: accessibility text for the editor toolbar */
82
101
 
83
102
  const toolbarAriaLabel = (0, _i18n.__)('Document tools');
@@ -113,7 +132,8 @@ function HeaderToolbar() {
113
132
  const shortLabel = !isInserterOpened ? (0, _i18n.__)('Add') : (0, _i18n.__)('Close');
114
133
  return (0, _element.createElement)(_blockEditor.NavigableToolbar, {
115
134
  className: "edit-post-header-toolbar",
116
- "aria-label": toolbarAriaLabel
135
+ "aria-label": toolbarAriaLabel,
136
+ shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused
117
137
  }, (0, _element.createElement)("div", {
118
138
  className: "edit-post-header-toolbar__left"
119
139
  }, (0, _element.createElement)(_components.ToolbarItem, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/header-toolbar/index.js"],"names":["preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","editPostStore","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","blockEditorStore","getEditorSettings","editorStore","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","keyboardShortcutsStore","richEditingEnabled","isLargeViewport","isWideViewport","toolbarAriaLabel","toggleListView","overflowItems","Button","listView","undefined","toggleInserter","current","focus","longLabel","shortLabel","plus","ToolSelector","EditorHistoryUndo","EditorHistoryRedo"],"mappings":";;;;;;;AAkBA;;AAfA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AAEA;;AAKA;;AAxBA;AACA;AACA;;AAmBA;AACA;AACA;AAGA,MAAMA,cAAc,GAAKC,KAAF,IAAa;AACnCA,EAAAA,KAAK,CAACD,cAAN;AACA,CAFD;;AAIA,SAASE,aAAT,GAAyB;AACxB,QAAMC,c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C,IAAA,SAAS,EAAC,2CAHX;AAIC,IAAA,OAAO,EAAC,SAJT;AAKC,IAAA,SAAS,EAAGvB,gBALb;AAMC,IAAA,WAAW,EAAGR,cANf;AAOC,IAAA,OAAO,EAAGkC,cAPX;AAQC,IAAA,QAAQ,EAAG,CAAE3B,iBARd;AASC,IAAA,IAAI,EAAGgC,WATR;AAUC,IAAA,KAAK,EAAG7B,cAAc,GAAG4B,UAAH,GAAgBD,SAVvC;AAWC,IAAA,WAAW,EAAG,CAAE3B;AAXjB,IADD,EAcG,CAAEiB,cAAc,IAAI,CAAEjB,cAAtB,KACD,qDACGgB,eAAe,IAChB,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGc,yBADN;AAEC,IAAA,WAAW,EAAG,CAAE9B,cAFjB;AAGC,IAAA,OAAO,EACNA,cAAc,GAAG,UAAH,GAAgBuB,SAJhC;AAMC,IAAA,QAAQ,EAAGxB;AANZ,IAFF,EAWC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGgC,yBADN;AAEC,IAAA,WAAW,EAAG,CAAE/B,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBuB;AAHzC,IAXD,EAgBC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGS,yBADN;AAEC,IAAA,WAAW,EAAG,CAAEhC,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBuB;AAHzC,IAhBD,EAqBGH,aArBH,CAfF,CAJD,CADD;AA+CA;;eAEc5B,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} 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';\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\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\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>\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":["preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","editPostStore","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","selectedBlockId","hasFixedToolbar","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getSettings","blockEditorStore","getEditorSettings","editorStore","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","keyboardShortcutsStore","richEditingEnabled","useShouldContextualToolbarShow","blockEditorPrivateApis","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","overflowItems","Button","listView","undefined","toggleInserter","current","focus","longLabel","shortLabel","plus","ToolSelector","EditorHistoryUndo","EditorHistoryRedo"],"mappings":";;;;;;;AAmBA;;AAhBA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AACA;;AAEA;;AAKA;;AACA;;AA1BA;AACA;AACA;;AAoBA;AACA;AACA;AAIA,MAAMA,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;AACLC,IAAAA,iBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,cAJK;AAKLC,IAAAA,cALK;AAMLC,IAAAA,gBANK;AAOLC,IAAAA,eAPK;AAQLC,IAAAA;AARK,MASF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AACLC,MAAAA,gBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,oBAHK;AAILC,MAAAA,wBAJK;AAKLC,MAAAA,kCALK;AAMLC,MAAAA;AANK,QAOFN,MAAM,CAAEO,kBAAF,CAPV;AAQA,UAAM;AAAEC,MAAAA;AAAF,QAAwBR,MAAM,CAAES,aAAF,CAApC;AACA,UAAM;AAAEC,MAAAA,aAAF;AAAiBC,MAAAA,e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AAO,EAAC,SAJT;AAKC,IAAA,SAAS,EAAGjC,gBALb;AAMC,IAAA,WAAW,EAAGR,cANf;AAOC,IAAA,OAAO,EAAG4C,cAPX;AAQC,IAAA,QAAQ,EAAG,CAAErC,iBARd;AASC,IAAA,IAAI,EAAG0C,WATR;AAUC,IAAA,KAAK,EAAGvC,cAAc,GAAGsC,UAAH,GAAgBD,SAVvC;AAWC,IAAA,WAAW,EAAG,CAAErC;AAXjB,IADD,EAcG,CAAEwB,cAAc,IAAI,CAAExB,cAAtB,KACD,qDACGuB,eAAe,IAChB,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGiB,yBADN;AAEC,IAAA,WAAW,EAAG,CAAExC,cAFjB;AAGC,IAAA,OAAO,EACNA,cAAc,GAAG,UAAH,GAAgBiC,SAJhC;AAMC,IAAA,QAAQ,EAAGlC;AANZ,IAFF,EAWC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAG0C,yBADN;AAEC,IAAA,WAAW,EAAG,CAAEzC,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBiC;AAHzC,IAXD,EAgBC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGS,yBADN;AAEC,IAAA,WAAW,EAAG,CAAE1C,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgBiC;AAHzC,IAhBD,EAqBGH,aArBH,CAfF,CALD,CADD;AAgDA;;eAEctC,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport {\n\tEditorHistoryRedo,\n\tEditorHistoryUndo,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport { unlock } from '../../../private-apis';\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\tselectedBlockId,\n\t\thasFixedToolbar,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\thasInserterItems,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetFirstMultiSelectedBlockClientId,\n\t\t\tgetSettings,\n\t\t} = select( 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\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tselectedBlockId:\n\t\t\t\tgetSelectedBlockClientId() ||\n\t\t\t\tgetFirstMultiSelectedBlockClientId(),\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 { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst { shouldShowContextualToolbar, canFocusHiddenToolbar } =\n\t\tuseShouldContextualToolbarShow( selectedBlockId );\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\t( ( hasFixedToolbar || ! isLargeViewport ) && selectedBlockId );\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"]}
@@ -87,7 +87,7 @@ function DeleteTemplate() {
87
87
  let [id] = _ref;
88
88
  return id !== template.slug;
89
89
  }));
90
- updateEditorSettings({ ...settings,
90
+ updateEditorSettings({
91
91
  availableTemplates: newAvailableTemplates
92
92
  });
93
93
  deleteEntityRecord('postType', 'wp_template', template.id, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/delete-template.js"],"names":["DeleteTemplate","clearSelectedBlock","blockEditorStore","setIsEditingTemplate","editPostStore","getEditorSettings","editorStore","updateEditorSettings","editPost","deleteEntityRecord","coreStore","template","select","isEditingTemplate","getEditedPostTemplate","_isEditing","showConfirmDialog","setShowConfirmDialog","wp_id","templateTitle","slug","title","isRevertable","has_theme_file","onDelete","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","filter","id","throwOnError","undefined"],"mappings":";;;;;;;AAaA;;AAVA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGe,SAASA,cAAT,GAA0B;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAAyB,uBAAaC,kBAAb,CAA/B;AACA,QAAM;AAAEC,IAAAA;AAAF,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,MAAM,CAACC,WAAP,CAC7BD,MAAM,CAACE,OAAP,0BAAgBJ,QAAQ,CAACK,kBAAzB,yEAA+C,EAA/C,EAAoDC,MAApD,CACC;AAAA,UAAE,CAAEC,EAAF,CAAF;AAAA,aAAcA,EAAE,KAAKrB,QAAQ,CAACS,IAA9B;AAAA,KADD,CAD6B,CAA9B;AAKAb,IAAAA,oBAAoB,CAAE,EACrB,GAAGkB,QADkB;AAErBK,MAAAA,kBAAkB,EAAEJ;AAFC,KAAF,CAApB;AAIAjB,IAAAA,kBAAkB,CAAE,UAAF,EAAc,aAAd,EAA6BE,QAAQ,CAACqB,EAAtC,EAA0C;AAC3DC,MAAAA,YAAY,EAAE;AAD6C,KAA1C,CAAlB;AAGA,GArBD;;AAuBA,SACC,4BAAC,qBAAD;AAAW,IAAA,SAAS,EAAC;AAArB,KACC,qDACC,4BAAC,oBAAD;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,aAAa,EAAG,CAAEX,YAFnB;AAGC,IAAA,OAAO,EAAG,MAAM;AACfL,MAAAA,oBAAoB,CAAE,IAAF,CAApB;AACA,KALF;AAMC,IAAA,IAAI,EACHK,YAAY,GACT,cAAI,4CAAJ,CADS,GAETY;AATL,KAYGZ,YAAY,GACX,cAAI,sBAAJ,CADW,GAEX,cAAI,iBAAJ,CAdJ,CADD,EAiBC,4BAAC,uCAAD;AACC,IAAA,MAAM,EAAGN,iBADV;AAEC,IAAA,SAAS,EAAGQ,QAFb;AAGC,IAAA,QAAQ,EAAG,MAAM;AAChBP,MAAAA,oBAAoB,CAAE,KAAF,CAApB;AACA;AALF,KAOG;AACD;AACA,gBACC,0FADD,CAFC,EAKDE,aALC,CAPH,CAjBD,CADD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function DeleteTemplate() {\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings, editPost } = useDispatch( editorStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } =\n\t\t\tselect( editPostStore );\n\t\tconst _isEditing = isEditingTemplate();\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t};\n\t}, [] );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( ! template || ! template.wp_id ) {\n\t\treturn null;\n\t}\n\tlet templateTitle = template.slug;\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t}\n\n\tconst isRevertable = template?.has_theme_file;\n\n\tconst onDelete = () => {\n\t\tclearSelectedBlock();\n\t\tsetIsEditingTemplate( false );\n\t\tsetShowConfirmDialog( false );\n\n\t\teditPost( {\n\t\t\ttemplate: '',\n\t\t} );\n\t\tconst settings = getEditorSettings();\n\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\tObject.entries( settings.availableTemplates ?? {} ).filter(\n\t\t\t\t( [ id ] ) => id !== template.slug\n\t\t\t)\n\t\t);\n\t\tupdateEditorSettings( {\n\t\t\t...settings,\n\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t} );\n\t\tdeleteEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<MenuGroup className=\"edit-post-template-top-area__second-menu-group\">\n\t\t\t<>\n\t\t\t\t<MenuItem\n\t\t\t\t\tclassName=\"edit-post-template-top-area__delete-template-button\"\n\t\t\t\t\tisDestructive={ ! isRevertable }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t} }\n\t\t\t\t\tinfo={\n\t\t\t\t\t\tisRevertable\n\t\t\t\t\t\t\t? __( 'Use the template as supplied by the theme.' )\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isRevertable\n\t\t\t\t\t\t? __( 'Clear customizations' )\n\t\t\t\t\t\t: __( 'Delete template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ onDelete }\n\t\t\t\t\tonCancel={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( false );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: template name */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Are you sure you want to delete the %s template? It may be used by other pages or posts.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttemplateTitle\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t</>\n\t\t</MenuGroup>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/delete-template.js"],"names":["DeleteTemplate","clearSelectedBlock","blockEditorStore","setIsEditingTemplate","editPostStore","getEditorSettings","editorStore","updateEditorSettings","editPost","deleteEntityRecord","coreStore","template","select","isEditingTemplate","getEditedPostTemplate","_isEditing","showConfirmDialog","setShowConfirmDialog","wp_id","templateTitle","slug","title","isRevertable","has_theme_file","onDelete","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","filter","id","throwOnError","undefined"],"mappings":";;;;;;;AAaA;;AAVA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AAlB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{ __, sprintf } from '@wordpress/i18n';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function DeleteTemplate() {\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings, editPost } = useDispatch( editorStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } =\n\t\t\tselect( editPostStore );\n\t\tconst _isEditing = isEditingTemplate();\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t};\n\t}, [] );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( ! template || ! template.wp_id ) {\n\t\treturn null;\n\t}\n\tlet templateTitle = template.slug;\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t}\n\n\tconst isRevertable = template?.has_theme_file;\n\n\tconst onDelete = () => {\n\t\tclearSelectedBlock();\n\t\tsetIsEditingTemplate( false );\n\t\tsetShowConfirmDialog( false );\n\n\t\teditPost( {\n\t\t\ttemplate: '',\n\t\t} );\n\t\tconst settings = getEditorSettings();\n\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\tObject.entries( settings.availableTemplates ?? {} ).filter(\n\t\t\t\t( [ id ] ) => id !== template.slug\n\t\t\t)\n\t\t);\n\t\tupdateEditorSettings( {\n\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t} );\n\t\tdeleteEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<MenuGroup className=\"edit-post-template-top-area__second-menu-group\">\n\t\t\t<>\n\t\t\t\t<MenuItem\n\t\t\t\t\tclassName=\"edit-post-template-top-area__delete-template-button\"\n\t\t\t\t\tisDestructive={ ! isRevertable }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t} }\n\t\t\t\t\tinfo={\n\t\t\t\t\t\tisRevertable\n\t\t\t\t\t\t\t? __( 'Use the template as supplied by the theme.' )\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isRevertable\n\t\t\t\t\t\t? __( 'Clear customizations' )\n\t\t\t\t\t\t: __( 'Delete template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ onDelete }\n\t\t\t\t\tonCancel={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( false );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: template name */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Are you sure you want to delete the %s template? It may be used by other pages or posts.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttemplateTitle\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t</>\n\t\t</MenuGroup>\n\t);\n}\n"]}
@@ -80,14 +80,9 @@ function EditTemplateTitle() {
80
80
  const settings = getEditorSettings();
81
81
  const newAvailableTemplates = Object.fromEntries(Object.entries((_settings$availableTe = settings.availableTemplates) !== null && _settings$availableTe !== void 0 ? _settings$availableTe : {}).map(_ref => {
82
82
  let [id, existingTitle] = _ref;
83
-
84
- if (id !== template.slug) {
85
- return existingTitle;
86
- }
87
-
88
- return newTitle;
83
+ return [id, id !== template.slug ? existingTitle : newTitle];
89
84
  }));
90
- updateEditorSettings({ ...settings,
85
+ updateEditorSettings({
91
86
  availableTemplates: newAvailableTemplates
92
87
  });
93
88
  editEntityRecord('postType', 'wp_template', template.id, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/edit-template-title.js"],"names":["EditTemplateTitle","forceEmpty","setForceEmpty","template","select","getEditedPostTemplate","editPostStore","editEntityRecord","coreStore","getEditorSettings","editorStore","updateEditorSettings","is_custom","has_theme_file","templateTitle","title","slug","newTitle","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","map","id","existingTitle"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,iBAAT,GAA6B;AAC3C,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU,KAAV,CAAtC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAe,qBAAaC,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA;AAAF,QAA4BD,MAAM,CAAEE,YAAF,CAAxC;AACA,WAAO;AACNH,MAAAA,QAAQ,EAAEE,qBAAqB;AADzB,KAAP;AAGA,GALoB,EAKlB,EALkB,CAArB;AAOA,QAAM;AAAEE,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAwB,qBAAWC,aAAX,CAA9B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA2B,uBAAaD,aAAb,CAAjC,CAX2C,CAa3C;;AACA,MAAK,CAAEP,QAAQ,CAACS,SAAX,IAAwBT,QAAQ,CAACU,cAAtC,EAAuD;AACtD,WAAO,IAAP;AACA;;AAED,MAAIC,aAAa,GAAG,cAAI,SAAJ,CAApB;;AACA,MAAKX,QAAL,aAAKA,QAAL,eAAKA,QAAQ,CAAEY,KAAf,EAAuB;AACtBD,IAAAA,aAAa,GAAGX,QAAQ,CAACY,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WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function EditTemplateTitle() {\n\tconst [ forceEmpty, setForceEmpty ] = useState( false );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\n\t// Only user-created and non-default templates can change the name.\n\tif ( ! template.is_custom || template.has_theme_file ) {\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-site-template-details__group\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\tvalue={ forceEmpty ? '' : templateTitle }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Give the template a title that indicates its purpose, e.g. \"Full Width\".'\n\t\t\t\t) }\n\t\t\t\tonChange={ ( newTitle ) => {\n\t\t\t\t\t// Allow having the field temporarily empty while typing.\n\t\t\t\t\tif ( ! newTitle && ! forceEmpty ) {\n\t\t\t\t\t\tsetForceEmpty( true );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetForceEmpty( false );\n\n\t\t\t\t\tconst settings = getEditorSettings();\n\t\t\t\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( settings.availableTemplates ?? {} ).map(\n\t\t\t\t\t\t\t( [ id, existingTitle ] ) => {\n\t\t\t\t\t\t\t\tif ( id !== template.slug ) {\n\t\t\t\t\t\t\t\t\treturn existingTitle;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn newTitle;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tupdateEditorSettings( {\n\t\t\t\t\t\t...settings,\n\t\t\t\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t\t\t\t} );\n\t\t\t\t\teditEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\t\t\t\ttitle: newTitle,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tonBlur={ () => setForceEmpty( false ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/edit-template-title.js"],"names":["EditTemplateTitle","forceEmpty","setForceEmpty","template","select","getEditedPostTemplate","editPostStore","editEntityRecord","coreStore","getEditorSettings","editorStore","updateEditorSettings","is_custom","has_theme_file","templateTitle","title","slug","newTitle","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","map","id","existingTitle"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AAKA;;AAbA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,iBAAT,GAA6B;AAC3C,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU,KAAV,CAAtC;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAe,qBAAaC,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA;AAAF,QAA4BD,MAAM,CAAEE,YAAF,CAAxC;AACA,WAAO;AACNH,MAAAA,QAAQ,EAAEE,qBAAqB;AADzB,KAAP;AAGA,GALoB,EAKlB,EALkB,CAArB;AAOA,QAAM;AAAEE,IAAAA;AAAF,MAAuB,uBAAaC,eAAb,CAA7B;AACA,QAAM;AAAE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AA7B;AAAA,OADD,CAD6B,CAA9B;AAQAN,MAAAA,oBAAoB,CAAE;AACrBY,QAAAA,kBAAkB,EAAEJ;AADC,OAAF,CAApB;AAGAZ,MAAAA,gBAAgB,CAAE,UAAF,EAAc,aAAd,EAA6BJ,QAAQ,CAACsB,EAAtC,EAA0C;AACzDV,QAAAA,KAAK,EAAEE;AADkD,OAA1C,CAAhB;AAGA,KA9BF;AA+BC,IAAA,MAAM,EAAG,MAAMf,aAAa,CAAE,KAAF;AA/B7B,IADD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function EditTemplateTitle() {\n\tconst [ forceEmpty, setForceEmpty ] = useState( false );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\n\t// Only user-created and non-default templates can change the name.\n\tif ( ! template.is_custom || template.has_theme_file ) {\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-site-template-details__group\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\tvalue={ forceEmpty ? '' : templateTitle }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Give the template a title that indicates its purpose, e.g. \"Full Width\".'\n\t\t\t\t) }\n\t\t\t\tonChange={ ( newTitle ) => {\n\t\t\t\t\t// Allow having the field temporarily empty while typing.\n\t\t\t\t\tif ( ! newTitle && ! forceEmpty ) {\n\t\t\t\t\t\tsetForceEmpty( true );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetForceEmpty( false );\n\n\t\t\t\t\tconst settings = getEditorSettings();\n\t\t\t\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( settings.availableTemplates ?? {} ).map(\n\t\t\t\t\t\t\t( [ id, existingTitle ] ) => [\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\tid !== template.slug ? existingTitle : newTitle,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tupdateEditorSettings( {\n\t\t\t\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t\t\t\t} );\n\t\t\t\t\teditEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\t\t\t\ttitle: newTitle,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tonBlur={ () => setForceEmpty( false ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -113,6 +113,7 @@ function StartPageOptions() {
113
113
  return (0, _element.createElement)(_components.Modal, {
114
114
  className: "edit-post-start-page-options__modal",
115
115
  title: (0, _i18n.__)('Choose a pattern'),
116
+ isFullScreen: true,
116
117
  onRequestClose: () => {
117
118
  setModalState(START_PAGE_MODAL_STATES.CLOSED);
118
119
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"names":["useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","blockEditorStore","getCurrentPostType","editorStore","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","onChoosePattern","blockPatterns","shownBlockPatterns","resetEditorBlocks","_pattern","blocks","START_PAGE_MODAL_STATES","INITIAL","PATTERN","CLOSED","StartPageOptions","modalState","setModalState","hasStartPattern","length","shouldOpenModel","getEditedPostContent","isEditedPostSaveable","isEditingTemplate","isFeatureActive","editPostStore"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAYA;AACA;AACA;AAGA,SAASA,gBAAT,GAA4B;AAC3B;AACA;AACA;AACA,QAAM;AAAEC,IAAAA,qCAAF;AAAyCC,IAAAA;AAAzC,MAAsD,qBACzDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAA8BD,MAAM,CAAEE,kBAAF,CAA1C;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAyBH,MAAM,CAAEI,aAAF,CAArC;AACA,WAAO;AACNN,MAAAA,qCAAqC,EACpCG,uBAAuB,CAAE,mBAAF,CAFlB;AAGNF,MAAAA,QAAQ,EAAEI,kBAAkB;AAHtB,KAAP;AAKA,GAT0D,EAU3D,EAV2D,CAA5D;AAaA,SAAO,sBAAS,MAAM;AACrB;AACA;AACA,WAAOL,qCAAqC,CAACO,MAAtC,CAAgDC,OAAF,IAAe;AACnE,aACGP,QAAQ,KAAK,MAAb,IAAuB,CAAEO,OAAO,CAACC,SAAnC,IACEC,KAAK,CAACC,OAAN,CAAeH,OAAO,CAACC,SAAvB,KACDD,OAAO,CAACC,SAAR,CAAkBG,QAAlB,CAA4BX,QAA5B,CAHF;AAKA,KANM,CAAP;AAOA,GAVM,EAUJ,CAAEA,QAAF,EAAYD,qCAAZ,CAVI,CAAP;AAWA;;AAED,SAASa,gBAAT,OAAiD;AAAA,MAAtB;AAAEC,IAAAA;AAAF,GAAsB;AAChD,QAAMC,aAAa,GAAGhB,gBAAgB,EAAtC;AACA,QAAMiB,kBAAkB,GAAG,2BAAcD,aAAd,CAA3B;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAwB,uBAAaX,aAAb,CAA9B;AACA,SACC,4BAAC,4C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KAAKL,uBAAuB,CAACC,OAAvC,IACAI,UAAU,KAAKL,uBAAuB,CAACG,MAFxC,EAGE;AACD,WAAO,IAAP;AACA;;AACD,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CAFT;AAGC,IAAA,cAAc,EAAG,MAAM;AACtBG,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AALF,KAOC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGE,UAAU,KAAKL,uBAAuB,CAACE,OAAvC,IACD,4BAAC,gBAAD;AACC,IAAA,eAAe,EAAG,MAAM;AACvBI,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AAHF,IAFF,CAPD,CADD;AAmBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declares and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { onChoosePattern } ) {\n\tconst blockPatterns = useStartPatterns();\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nconst START_PAGE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tPATTERN: 'PATTERN',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartPageOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_PAGE_MODAL_STATES.INITIAL\n\t);\n\tconst blockPatterns = useStartPatterns();\n\tconst hasStartPattern = blockPatterns.length > 0;\n\tconst shouldOpenModel = useSelect(\n\t\t( select ) => {\n\t\t\tif (\n\t\t\t\t! hasStartPattern ||\n\t\t\t\tmodalState !== START_PAGE_MODAL_STATES.INITIAL\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getEditedPostContent, isEditedPostSaveable } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { isEditingTemplate, isFeatureActive } =\n\t\t\t\tselect( editPostStore );\n\t\t\treturn (\n\t\t\t\t! isEditedPostSaveable() &&\n\t\t\t\t'' === getEditedPostContent() &&\n\t\t\t\t! isEditingTemplate() &&\n\t\t\t\t! isFeatureActive( 'welcomeGuide' )\n\t\t\t);\n\t\t},\n\t\t[ modalState, hasStartPattern ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldOpenModel ) {\n\t\t\tsetModalState( START_PAGE_MODAL_STATES.PATTERN );\n\t\t}\n\t}, [ shouldOpenModel ] );\n\n\tif (\n\t\tmodalState === START_PAGE_MODAL_STATES.INITIAL ||\n\t\tmodalState === START_PAGE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tonRequestClose={ () => {\n\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t{ modalState === START_PAGE_MODAL_STATES.PATTERN && (\n\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"names":["useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","blockEditorStore","getCurrentPostType","editorStore","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","onChoosePattern","blockPatterns","shownBlockPatterns","resetEditorBlocks","_pattern","blocks","START_PAGE_MODAL_STATES","INITIAL","PATTERN","CLOSED","StartPageOptions","modalState","setModalState","hasStartPattern","length","shouldOpenModel","getEditedPostContent","isEditedPostSaveable","isEditingTemplate","isFeatureActive","editPostStore"],"mappings":";;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AAKA;;AAjBA;AACA;AAC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AY,EAAG,IAHhB;AAIC,IAAA,cAAc,EAAG,MAAM;AACtBG,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AANF,KAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGE,UAAU,KAAKL,uBAAuB,CAACE,OAAvC,IACD,4BAAC,gBAAD;AACC,IAAA,eAAe,EAAG,MAAM;AACvBI,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AAHF,IAFF,CARD,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declares and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { onChoosePattern } ) {\n\tconst blockPatterns = useStartPatterns();\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nconst START_PAGE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tPATTERN: 'PATTERN',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartPageOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_PAGE_MODAL_STATES.INITIAL\n\t);\n\tconst blockPatterns = useStartPatterns();\n\tconst hasStartPattern = blockPatterns.length > 0;\n\tconst shouldOpenModel = useSelect(\n\t\t( select ) => {\n\t\t\tif (\n\t\t\t\t! hasStartPattern ||\n\t\t\t\tmodalState !== START_PAGE_MODAL_STATES.INITIAL\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getEditedPostContent, isEditedPostSaveable } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { isEditingTemplate, isFeatureActive } =\n\t\t\t\tselect( editPostStore );\n\t\t\treturn (\n\t\t\t\t! isEditedPostSaveable() &&\n\t\t\t\t'' === getEditedPostContent() &&\n\t\t\t\t! isEditingTemplate() &&\n\t\t\t\t! isFeatureActive( 'welcomeGuide' )\n\t\t\t);\n\t\t},\n\t\t[ modalState, hasStartPattern ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldOpenModel ) {\n\t\t\tsetModalState( START_PAGE_MODAL_STATES.PATTERN );\n\t\t}\n\t}, [ shouldOpenModel ] );\n\n\tif (\n\t\tmodalState === START_PAGE_MODAL_STATES.INITIAL ||\n\t\tmodalState === START_PAGE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen={ true }\n\t\t\tonRequestClose={ () => {\n\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t{ modalState === START_PAGE_MODAL_STATES.PATTERN && (\n\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -6,7 +6,7 @@ import { createElement, Fragment } from "@wordpress/element";
6
6
  import { useViewportMatch } from '@wordpress/compose';
7
7
  import { useSelect, useDispatch } from '@wordpress/data';
8
8
  import { __, _x } from '@wordpress/i18n';
9
- import { NavigableToolbar, ToolSelector, store as blockEditorStore } from '@wordpress/block-editor';
9
+ import { NavigableToolbar, ToolSelector, store as blockEditorStore, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
10
10
  import { EditorHistoryRedo, EditorHistoryUndo, store as editorStore } from '@wordpress/editor';
11
11
  import { Button, ToolbarItem } from '@wordpress/components';
12
12
  import { listView, plus } from '@wordpress/icons';
@@ -17,6 +17,7 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
17
17
  */
18
18
 
19
19
  import { store as editPostStore } from '../../../store';
20
+ import { unlock } from '../../../private-apis';
20
21
 
21
22
  const preventDefault = event => {
22
23
  event.preventDefault();
@@ -34,12 +35,17 @@ function HeaderToolbar() {
34
35
  isTextModeEnabled,
35
36
  showIconLabels,
36
37
  isListViewOpen,
37
- listViewShortcut
38
+ listViewShortcut,
39
+ selectedBlockId,
40
+ hasFixedToolbar
38
41
  } = useSelect(select => {
39
42
  const {
40
43
  hasInserterItems,
41
44
  getBlockRootClientId,
42
- getBlockSelectionEnd
45
+ getBlockSelectionEnd,
46
+ getSelectedBlockClientId,
47
+ getFirstMultiSelectedBlockClientId,
48
+ getSettings
43
49
  } = select(blockEditorStore);
44
50
  const {
45
51
  getEditorSettings
@@ -53,6 +59,8 @@ function HeaderToolbar() {
53
59
  getShortcutRepresentation
54
60
  } = select(keyboardShortcutsStore);
55
61
  return {
62
+ hasFixedToolbar: getSettings().hasFixedToolbar,
63
+ selectedBlockId: getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId(),
56
64
  // This setting (richEditingEnabled) should not live in the block editor's setting.
57
65
  isInserterEnabled: getEditorMode() === 'visual' && getEditorSettings().richEditingEnabled && hasInserterItems(getBlockRootClientId(getBlockSelectionEnd())),
58
66
  isInserterOpened: select(editPostStore).isInserterOpened(),
@@ -62,8 +70,18 @@ function HeaderToolbar() {
62
70
  listViewShortcut: getShortcutRepresentation('core/edit-post/toggle-list-view')
63
71
  };
64
72
  }, []);
73
+ const {
74
+ useShouldContextualToolbarShow
75
+ } = unlock(blockEditorPrivateApis);
65
76
  const isLargeViewport = useViewportMatch('medium');
66
77
  const isWideViewport = useViewportMatch('wide');
78
+ const {
79
+ shouldShowContextualToolbar,
80
+ canFocusHiddenToolbar
81
+ } = useShouldContextualToolbarShow(selectedBlockId); // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
82
+ // There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
83
+
84
+ const blockToolbarCanBeFocused = shouldShowContextualToolbar || canFocusHiddenToolbar || (hasFixedToolbar || !isLargeViewport) && selectedBlockId;
67
85
  /* translators: accessibility text for the editor toolbar */
68
86
 
69
87
  const toolbarAriaLabel = __('Document tools');
@@ -101,7 +119,8 @@ function HeaderToolbar() {
101
119
  const shortLabel = !isInserterOpened ? __('Add') : __('Close');
102
120
  return createElement(NavigableToolbar, {
103
121
  className: "edit-post-header-toolbar",
104
- "aria-label": toolbarAriaLabel
122
+ "aria-label": toolbarAriaLabel,
123
+ shouldUseKeyboardFocusShortcut: !blockToolbarCanBeFocused
105
124
  }, createElement("div", {
106
125
  className: "edit-post-header-toolbar__left"
107
126
  }, createElement(ToolbarItem, {
@@ -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","EditorHistoryRedo","EditorHistoryUndo","editorStore","Button","ToolbarItem","listView","plus","useRef","useCallback","keyboardShortcutsStore","editPostStore","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getEditorSettings","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","richEditingEnabled","isLargeViewport","isWideViewport","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,QAIO,yBAJP;AAKA,SACCC,iBADD,EAECC,iBAFD,EAGCH,KAAK,IAAII,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,o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D,CADD;AA+CA;;AAED,eAAexB,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} 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';\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\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\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>\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","editPostStore","unlock","preventDefault","event","HeaderToolbar","inserterButton","setIsInserterOpened","setIsListViewOpened","isInserterEnabled","isInserterOpened","isTextModeEnabled","showIconLabels","isListViewOpen","listViewShortcut","selectedBlockId","hasFixedToolbar","select","hasInserterItems","getBlockRootClientId","getBlockSelectionEnd","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getSettings","getEditorSettings","getEditorMode","isFeatureActive","isListViewOpened","getShortcutRepresentation","richEditingEnabled","useShouldContextualToolbarShow","isLargeViewport","isWideViewport","shouldShowContextualToolbar","canFocusHiddenToolbar","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,EA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,EAAG,CAAE/B;AAXjB,IADD,EAcG,CAAEoB,cAAc,IAAI,CAAEpB,cAAtB,KACD,8BACGmB,eAAe,IAChB,cAAC,WAAD;AACC,IAAA,EAAE,EAAG7C,YADN;AAEC,IAAA,WAAW,EAAG,CAAE0B,cAFjB;AAGC,IAAA,OAAO,EACNA,cAAc,GAAG,UAAH,GAAgB2B,SAJhC;AAMC,IAAA,QAAQ,EAAG5B;AANZ,IAFF,EAWC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGnB,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEoB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgB2B;AAHzC,IAXD,EAgBC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGhD,iBADN;AAEC,IAAA,WAAW,EAAG,CAAEqB,cAFjB;AAGC,IAAA,OAAO,EAAGA,cAAc,GAAG,UAAH,GAAgB2B;AAHzC,IAhBD,EAqBGD,aArBH,CAfF,CALD,CADD;AAgDA;;AAED,eAAejC,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 '../../../private-apis';\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\tselectedBlockId,\n\t\thasFixedToolbar,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\thasInserterItems,\n\t\t\tgetBlockRootClientId,\n\t\t\tgetBlockSelectionEnd,\n\t\t\tgetSelectedBlockClientId,\n\t\t\tgetFirstMultiSelectedBlockClientId,\n\t\t\tgetSettings,\n\t\t} = select( 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\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tselectedBlockId:\n\t\t\t\tgetSelectedBlockClientId() ||\n\t\t\t\tgetFirstMultiSelectedBlockClientId(),\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 { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst { shouldShowContextualToolbar, canFocusHiddenToolbar } =\n\t\tuseShouldContextualToolbarShow( selectedBlockId );\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\t( ( hasFixedToolbar || ! isLargeViewport ) && selectedBlockId );\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"]}
@@ -74,7 +74,7 @@ export default function DeleteTemplate() {
74
74
  let [id] = _ref;
75
75
  return id !== template.slug;
76
76
  }));
77
- updateEditorSettings({ ...settings,
77
+ updateEditorSettings({
78
78
  availableTemplates: newAvailableTemplates
79
79
  });
80
80
  deleteEntityRecord('postType', 'wp_template', template.id, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/delete-template.js"],"names":["__","sprintf","MenuGroup","MenuItem","__experimentalConfirmDialog","ConfirmDialog","store","blockEditorStore","useDispatch","useSelect","editorStore","coreStore","useState","editPostStore","DeleteTemplate","clearSelectedBlock","setIsEditingTemplate","getEditorSettings","updateEditorSettings","editPost","deleteEntityRecord","template","select","isEditingTemplate","getEditedPostTemplate","_isEditing","showConfirmDialog","setShowConfirmDialog","wp_id","templateTitle","slug","title","isRevertable","has_theme_file","onDelete","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","filter","id","throwOnError","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,SADD,EAECC,QAFD,EAGCC,2BAA2B,IAAIC,aAHhC,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,mBAArC;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASN,KAAK,IAAIO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AAAA,EAAE,CACD,0FADC,CAFM,EAKR6B,aALQ,CAPV,CAjBD,CADD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function DeleteTemplate() {\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings, editPost } = useDispatch( editorStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } =\n\t\t\tselect( editPostStore );\n\t\tconst _isEditing = isEditingTemplate();\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t};\n\t}, [] );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( ! template || ! template.wp_id ) {\n\t\treturn null;\n\t}\n\tlet templateTitle = template.slug;\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t}\n\n\tconst isRevertable = template?.has_theme_file;\n\n\tconst onDelete = () => {\n\t\tclearSelectedBlock();\n\t\tsetIsEditingTemplate( false );\n\t\tsetShowConfirmDialog( false );\n\n\t\teditPost( {\n\t\t\ttemplate: '',\n\t\t} );\n\t\tconst settings = getEditorSettings();\n\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\tObject.entries( settings.availableTemplates ?? {} ).filter(\n\t\t\t\t( [ id ] ) => id !== template.slug\n\t\t\t)\n\t\t);\n\t\tupdateEditorSettings( {\n\t\t\t...settings,\n\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t} );\n\t\tdeleteEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<MenuGroup className=\"edit-post-template-top-area__second-menu-group\">\n\t\t\t<>\n\t\t\t\t<MenuItem\n\t\t\t\t\tclassName=\"edit-post-template-top-area__delete-template-button\"\n\t\t\t\t\tisDestructive={ ! isRevertable }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t} }\n\t\t\t\t\tinfo={\n\t\t\t\t\t\tisRevertable\n\t\t\t\t\t\t\t? __( 'Use the template as supplied by the theme.' )\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isRevertable\n\t\t\t\t\t\t? __( 'Clear customizations' )\n\t\t\t\t\t\t: __( 'Delete template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ onDelete }\n\t\t\t\t\tonCancel={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( false );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: template name */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Are you sure you want to delete the %s template? It may be used by other pages or posts.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttemplateTitle\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t</>\n\t\t</MenuGroup>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/delete-template.js"],"names":["__","sprintf","MenuGroup","MenuItem","__experimentalConfirmDialog","ConfirmDialog","store","blockEditorStore","useDispatch","useSelect","editorStore","coreStore","useState","editPostStore","DeleteTemplate","clearSelectedBlock","setIsEditingTemplate","getEditorSettings","updateEditorSettings","editPost","deleteEntityRecord","template","select","isEditingTemplate","getEditedPostTemplate","_isEditing","showConfirmDialog","setShowConfirmDialog","wp_id","templateTitle","slug","title","isRevertable","has_theme_file","onDelete","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","filter","id","throwOnError","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,SADD,EAECC,QAFD,EAGCC,2BAA2B,IAAIC,aAHhC,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,mBAArC;AACA,SAASJ,KAAK,IAAIK,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASN,KAAK,IAAIO,aAAlB,QAAuC,gBAAvC;AAEA,eAAe,SAASC,cAAT,GAA0B;AACxC,QAAM;AAAEC,IAAAA;AAAF,MAAyBP,WAAW,CAAED,gBAAF,CAA1C;AACA,QAAM;AAAES,IAAAA;AAAF,MAA2BR,WAAW,CAAEK,aAAF,CAA5C;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAwBR,SAAS,CAAEC,WAAF,CAAvC;AACA,QAAM;AAAEQ,IAAAA,oBAAF;AAAwBC,IAAAA;AAAxB,MAAqCX,WAAW,CAAEE,WAAF,CAAtD;AACA,QAAM;AAAEU,IAAAA;AAAF,MAAyBZ,WAAW,CAAEG,SAAF,CAA1C;AACA,QAAM;AAAEU,IAAAA;AAAF,MAAeZ,SAAS,CAAIa,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QACLF,MAAM,CAAET,aAAF,CADP;;AAEA,UAAMY,UAAU,GAAGF,iBAAi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AY,EAAE;AAD6C,KAA1C,CAAlB;AAGA,GApBD;;AAsBA,SACC,cAAC,SAAD;AAAW,IAAA,SAAS,EAAC;AAArB,KACC,8BACC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,aAAa,EAAG,CAAEX,YAFnB;AAGC,IAAA,OAAO,EAAG,MAAM;AACfL,MAAAA,oBAAoB,CAAE,IAAF,CAApB;AACA,KALF;AAMC,IAAA,IAAI,EACHK,YAAY,GACThC,EAAE,CAAE,4CAAF,CADO,GAET4C;AATL,KAYGZ,YAAY,GACXhC,EAAE,CAAE,sBAAF,CADS,GAEXA,EAAE,CAAE,iBAAF,CAdN,CADD,EAiBC,cAAC,aAAD;AACC,IAAA,MAAM,EAAG0B,iBADV;AAEC,IAAA,SAAS,EAAGQ,QAFb;AAGC,IAAA,QAAQ,EAAG,MAAM;AAChBP,MAAAA,oBAAoB,CAAE,KAAF,CAApB;AACA;AALF,KAOG1B,OAAO;AACR;AACAD,EAAAA,EAAE,CACD,0FADC,CAFM,EAKR6B,aALQ,CAPV,CAjBD,CADD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalConfirmDialog as ConfirmDialog,\n} from '@wordpress/components';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function DeleteTemplate() {\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst { setIsEditingTemplate } = useDispatch( editPostStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings, editPost } = useDispatch( editorStore );\n\tconst { deleteEntityRecord } = useDispatch( coreStore );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { isEditingTemplate, getEditedPostTemplate } =\n\t\t\tselect( editPostStore );\n\t\tconst _isEditing = isEditingTemplate();\n\t\treturn {\n\t\t\ttemplate: _isEditing ? getEditedPostTemplate() : null,\n\t\t};\n\t}, [] );\n\tconst [ showConfirmDialog, setShowConfirmDialog ] = useState( false );\n\n\tif ( ! template || ! template.wp_id ) {\n\t\treturn null;\n\t}\n\tlet templateTitle = template.slug;\n\tif ( template?.title ) {\n\t\ttemplateTitle = template.title;\n\t}\n\n\tconst isRevertable = template?.has_theme_file;\n\n\tconst onDelete = () => {\n\t\tclearSelectedBlock();\n\t\tsetIsEditingTemplate( false );\n\t\tsetShowConfirmDialog( false );\n\n\t\teditPost( {\n\t\t\ttemplate: '',\n\t\t} );\n\t\tconst settings = getEditorSettings();\n\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\tObject.entries( settings.availableTemplates ?? {} ).filter(\n\t\t\t\t( [ id ] ) => id !== template.slug\n\t\t\t)\n\t\t);\n\t\tupdateEditorSettings( {\n\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t} );\n\t\tdeleteEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\tthrowOnError: true,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<MenuGroup className=\"edit-post-template-top-area__second-menu-group\">\n\t\t\t<>\n\t\t\t\t<MenuItem\n\t\t\t\t\tclassName=\"edit-post-template-top-area__delete-template-button\"\n\t\t\t\t\tisDestructive={ ! isRevertable }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( true );\n\t\t\t\t\t} }\n\t\t\t\t\tinfo={\n\t\t\t\t\t\tisRevertable\n\t\t\t\t\t\t\t? __( 'Use the template as supplied by the theme.' )\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isRevertable\n\t\t\t\t\t\t? __( 'Clear customizations' )\n\t\t\t\t\t\t: __( 'Delete template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tisOpen={ showConfirmDialog }\n\t\t\t\t\tonConfirm={ onDelete }\n\t\t\t\t\tonCancel={ () => {\n\t\t\t\t\t\tsetShowConfirmDialog( false );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: template name */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Are you sure you want to delete the %s template? It may be used by other pages or posts.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttemplateTitle\n\t\t\t\t\t) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t</>\n\t\t</MenuGroup>\n\t);\n}\n"]}
@@ -68,14 +68,9 @@ export default function EditTemplateTitle() {
68
68
  const settings = getEditorSettings();
69
69
  const newAvailableTemplates = Object.fromEntries(Object.entries((_settings$availableTe = settings.availableTemplates) !== null && _settings$availableTe !== void 0 ? _settings$availableTe : {}).map(_ref => {
70
70
  let [id, existingTitle] = _ref;
71
-
72
- if (id !== template.slug) {
73
- return existingTitle;
74
- }
75
-
76
- return newTitle;
71
+ return [id, id !== template.slug ? existingTitle : newTitle];
77
72
  }));
78
- updateEditorSettings({ ...settings,
73
+ updateEditorSettings({
79
74
  availableTemplates: newAvailableTemplates
80
75
  });
81
76
  editEntityRecord('postType', 'wp_template', template.id, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/edit-template-title.js"],"names":["__","TextControl","useDispatch","useSelect","useState","store","editorStore","coreStore","editPostStore","EditTemplateTitle","forceEmpty","setForceEmpty","template","select","getEditedPostTemplate","editEntityRecord","getEditorSettings","updateEditorSettings","is_custom","has_theme_file","templateTitle","title","slug","newTitle","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","map","id","existingTitle"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC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IAAA,KAAK,EAAGtB,EAAE,CAAE,OAAF,CAFX;AAGC,IAAA,KAAK,EAAGU,UAAU,GAAG,EAAH,GAAQU,aAH3B;AAIC,IAAA,IAAI,EAAGpB,EAAE,CACR,0EADQ,CAJV;AAOC,IAAA,QAAQ,EAAKuB,QAAF,IAAgB;AAAA;;AAC1B;AACA,UAAK,CAAEA,QAAF,IAAc,CAAEb,UAArB,EAAkC;AACjCC,QAAAA,aAAa,CAAE,IAAF,CAAb;AACA;AACA;;AACDA,MAAAA,aAAa,CAAE,KAAF,CAAb;AAEA,YAAMa,QAAQ,GAAGR,iBAAiB,EAAlC;AACA,YAAMS,qBAAqB,GAAGC,MAAM,CAACC,WAAP,CAC7BD,MAAM,CAACE,OAAP,0BAAgBJ,QAAQ,CAACK,kBAAzB,yEAA+C,EAA/C,EAAoDC,GAApD,CACC,QAA6B;AAAA,YAA3B,CAAEC,EAAF,EAAMC,aAAN,CAA2B;;AAC5B,YAAKD,EAAE,KAAKnB,QAAQ,CAACU,IAArB,EAA4B;AAC3B,iBAAOU,aAAP;AACA;;AACD,eAAOT,QAAP;AACA,OANF,CAD6B,CAA9B;AAUAN,MAAAA,oBAAoB,CAAE,EACrB,GAAGO,QADkB;AAErBK,QAAAA,kBAAkB,EAAEJ;AAFC,OAAF,CAApB;AAIAV,MAAAA,gBAAgB,CAAE,UAAF,EAAc,aAAd,EAA6BH,QAAQ,CAACmB,EAAtC,EAA0C;AACzDV,QAAAA,KAAK,EAAEE;AADkD,OAA1C,CAAhB;AAGA,KAjCF;AAkCC,IAAA,MAAM,EAAG,MAAMZ,aAAa,CAAE,KAAF;AAlC7B,IADD,CADD;AAwCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function EditTemplateTitle() {\n\tconst [ forceEmpty, setForceEmpty ] = useState( false );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\n\t// Only user-created and non-default templates can change the name.\n\tif ( ! template.is_custom || template.has_theme_file ) {\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-site-template-details__group\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\tvalue={ forceEmpty ? '' : templateTitle }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Give the template a title that indicates its purpose, e.g. \"Full Width\".'\n\t\t\t\t) }\n\t\t\t\tonChange={ ( newTitle ) => {\n\t\t\t\t\t// Allow having the field temporarily empty while typing.\n\t\t\t\t\tif ( ! newTitle && ! forceEmpty ) {\n\t\t\t\t\t\tsetForceEmpty( true );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetForceEmpty( false );\n\n\t\t\t\t\tconst settings = getEditorSettings();\n\t\t\t\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( settings.availableTemplates ?? {} ).map(\n\t\t\t\t\t\t\t( [ id, existingTitle ] ) => {\n\t\t\t\t\t\t\t\tif ( id !== template.slug ) {\n\t\t\t\t\t\t\t\t\treturn existingTitle;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn newTitle;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tupdateEditorSettings( {\n\t\t\t\t\t\t...settings,\n\t\t\t\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t\t\t\t} );\n\t\t\t\t\teditEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\t\t\t\ttitle: newTitle,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tonBlur={ () => setForceEmpty( false ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/edit-template-title.js"],"names":["__","TextControl","useDispatch","useSelect","useState","store","editorStore","coreStore","editPostStore","EditTemplateTitle","forceEmpty","setForceEmpty","template","select","getEditedPostTemplate","editEntityRecord","getEditorSettings","updateEditorSettings","is_custom","has_theme_file","templateTitle","title","slug","newTitle","settings","newAvailableTemplates","Object","fromEntries","entries","availableTemplates","map","id","existingTitle"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,uBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,gBAAvC;AAEA,eAAe,SAASC,iBAAT,GAA6B;AAC3C,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgCP,QAAQ,CAAE,KAAF,CAA9C;AACA,QAAM;AAAEQ,IAAAA;AAAF,MAAeT,SAAS,CAAIU,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA;AAAF,QAA4BD,MAAM,CAAEL,aAAF,CAAxC;AACA,WAAO;AACNI,MAAAA,QAAQ,EAAEE,qBAAqB;AADzB,KAAP;AAGA,GAL6B,EA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AEC,EAAF,EAAMC,aAAN,CAAF;AAAA,eAA6B,CAC5BD,EAD4B,EAE5BA,EAAE,KAAKnB,QAAQ,CAACU,IAAhB,GAAuBU,aAAvB,GAAuCT,QAFX,CAA7B;AAAA,OADD,CAD6B,CAA9B;AAQAN,MAAAA,oBAAoB,CAAE;AACrBY,QAAAA,kBAAkB,EAAEJ;AADC,OAAF,CAApB;AAGAV,MAAAA,gBAAgB,CAAE,UAAF,EAAc,aAAd,EAA6BH,QAAQ,CAACmB,EAAtC,EAA0C;AACzDV,QAAAA,KAAK,EAAEE;AADkD,OAA1C,CAAhB;AAGA,KA9BF;AA+BC,IAAA,MAAM,EAAG,MAAMZ,aAAa,CAAE,KAAF;AA/B7B,IADD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { TextControl } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nexport default function EditTemplateTitle() {\n\tconst [ forceEmpty, setForceEmpty ] = useState( false );\n\tconst { template } = useSelect( ( select ) => {\n\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\t\treturn {\n\t\t\ttemplate: getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { updateEditorSettings } = useDispatch( editorStore );\n\n\t// Only user-created and non-default templates can change the name.\n\tif ( ! template.is_custom || template.has_theme_file ) {\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-site-template-details__group\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\tvalue={ forceEmpty ? '' : templateTitle }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Give the template a title that indicates its purpose, e.g. \"Full Width\".'\n\t\t\t\t) }\n\t\t\t\tonChange={ ( newTitle ) => {\n\t\t\t\t\t// Allow having the field temporarily empty while typing.\n\t\t\t\t\tif ( ! newTitle && ! forceEmpty ) {\n\t\t\t\t\t\tsetForceEmpty( true );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetForceEmpty( false );\n\n\t\t\t\t\tconst settings = getEditorSettings();\n\t\t\t\t\tconst newAvailableTemplates = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( settings.availableTemplates ?? {} ).map(\n\t\t\t\t\t\t\t( [ id, existingTitle ] ) => [\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\tid !== template.slug ? existingTitle : newTitle,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tupdateEditorSettings( {\n\t\t\t\t\t\tavailableTemplates: newAvailableTemplates,\n\t\t\t\t\t} );\n\t\t\t\t\teditEntityRecord( 'postType', 'wp_template', template.id, {\n\t\t\t\t\t\ttitle: newTitle,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tonBlur={ () => setForceEmpty( false ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -100,6 +100,7 @@ export default function StartPageOptions() {
100
100
  return createElement(Modal, {
101
101
  className: "edit-post-start-page-options__modal",
102
102
  title: __('Choose a pattern'),
103
+ isFullScreen: true,
103
104
  onRequestClose: () => {
104
105
  setModalState(START_PAGE_MODAL_STATES.CLOSED);
105
106
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"names":["Modal","__","useState","useEffect","useMemo","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getCurrentPostType","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","onChoosePattern","blockPatterns","shownBlockPatterns","resetEditorBlocks","_pattern","blocks","START_PAGE_MODAL_STATES","INITIAL","PATTERN","CLOSED","StartPageOptions","modalState","setModalState","hasStartPattern","length","shouldOpenModel","getEditedPostContent","isEditedPostSaveable","isEditingTemplate","isFeatureActive"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,OAA9B,QAA6C,oBAA7C;AACA,SACCC,KAAK,IAAIC,gBADV,EAECC,+BAA+B,IAAIC,iBAFpC,QAGO,yBAHP;AAIA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASN,KAAK,IAAIO,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASP,KAAK,IAAIQ,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,gBAAT,GAA4B;AAC3B;AACA;AACA;AACA,QAAM;AAAEC,IAAAA,qCAAF;AAAyCC,IAAAA;AAAzC,MAAsDP,SAAS,CAClEQ,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAA8BD,MAAM,CAAEX,gBAAF,CAA1C;AACA,UAAM;AAAEa,MAAAA;AAAF,QAAyBF,MAAM,CAAEL,WAAF,CAArC;AACA,WAAO;AACNG,MAAAA,qCAAqC,EACpCG,uBAAuB,CAAE,mBAAF,CAFlB;AAGNF,MAAAA,QAAQ,EAAEG,kBAAkB;AAHtB,KAAP;AAKA,GATmE,EAUpE,EAVoE,CAArE;AAaA,SAAOf,OAAO,CAAE,MAAM;AACrB;AACA;AACA,WAAOW,qCAAqC,CAACK,MAAtC,CAAgDC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aAAO,KAAP;AACA;;AACD,UAAM;AAAES,MAAAA,oBAAF;AAAwBC,MAAAA;AAAxB,QACL3B,MAAM,CAAEL,WAAF,CADP;AAEA,UAAM;AAAEiC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QACL7B,MAAM,CAAEJ,aAAF,CADP;AAEA,WACC,CAAE+B,oBAAoB,EAAtB,IACA,OAAOD,oBAAoB,EAD3B,IAEA,CAAEE,iBAAiB,EAFnB,IAGA,CAAEC,eAAe,CAAE,cAAF,CAJlB;AAMA,GAlB+B,EAmBhC,CAAER,UAAF,EAAcE,eAAd,CAnBgC,CAAjC;AAsBArC,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKuC,eAAL,EAAuB;AACtBH,MAAAA,aAAa,CAAEN,uBAAuB,CAACE,OAA1B,CAAb;AACA;AACD,GAJQ,EAIN,CAAEO,eAAF,CAJM,CAAT;;AAMA,MACCJ,UAAU,KAAKL,uBAAuB,CAACC,OAAvC,IACAI,UAAU,KAAKL,uBAAuB,CAACG,MAFxC,EAGE;AACD,WAAO,IAAP;AACA;;AACD,SACC,cAAC,KAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,KAAK,EAAGnC,EAAE,CAAE,kBAAF,CAFX;AAGC,IAAA,cAAc,EAAG,MAAM;AACtBsC,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AALF,KAOC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGE,UAAU,KAAKL,uBAAuB,CAACE,OAAvC,IACD,cAAC,gBAAD;AACC,IAAA,eAAe,EAAG,MAAM;AACvBI,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AAHF,IAFF,CAPD,CADD;AAmBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declares and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { onChoosePattern } ) {\n\tconst blockPatterns = useStartPatterns();\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nconst START_PAGE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tPATTERN: 'PATTERN',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartPageOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_PAGE_MODAL_STATES.INITIAL\n\t);\n\tconst blockPatterns = useStartPatterns();\n\tconst hasStartPattern = blockPatterns.length > 0;\n\tconst shouldOpenModel = useSelect(\n\t\t( select ) => {\n\t\t\tif (\n\t\t\t\t! hasStartPattern ||\n\t\t\t\tmodalState !== START_PAGE_MODAL_STATES.INITIAL\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getEditedPostContent, isEditedPostSaveable } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { isEditingTemplate, isFeatureActive } =\n\t\t\t\tselect( editPostStore );\n\t\t\treturn (\n\t\t\t\t! isEditedPostSaveable() &&\n\t\t\t\t'' === getEditedPostContent() &&\n\t\t\t\t! isEditingTemplate() &&\n\t\t\t\t! isFeatureActive( 'welcomeGuide' )\n\t\t\t);\n\t\t},\n\t\t[ modalState, hasStartPattern ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldOpenModel ) {\n\t\t\tsetModalState( START_PAGE_MODAL_STATES.PATTERN );\n\t\t}\n\t}, [ shouldOpenModel ] );\n\n\tif (\n\t\tmodalState === START_PAGE_MODAL_STATES.INITIAL ||\n\t\tmodalState === START_PAGE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tonRequestClose={ () => {\n\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t{ modalState === START_PAGE_MODAL_STATES.PATTERN && (\n\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"names":["Modal","__","useState","useEffect","useMemo","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getCurrentPostType","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","onChoosePattern","blockPatterns","shownBlockPatterns","resetEditorBlocks","_pattern","blocks","START_PAGE_MODAL_STATES","INITIAL","PATTERN","CLOSED","StartPageOptions","modalState","setModalState","hasStartPattern","length","shouldOpenModel","getEditedPostContent","isEditedPostSaveable","isEditingTemplate","isFeatureActive"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,OAA9B,QAA6C,oBAA7C;AACA,SACCC,KAAK,IAAIC,gBADV,EAECC,+BAA+B,IAAIC,iBAFpC,QAGO,yBAHP;AAIA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASN,KAAK,IAAIO,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASP,KAAK,IAAIQ,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,gBAAT,GAA4B;AAC3B;AACA;AACA;AACA,QAAM;AAAEC,IAAAA,qCAAF;AAAyCC,IAAAA;AAAzC,MAAsDP,SAAS,CAClEQ,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAA8BD,MAAM,CAAEX,gBAAF,CAA1C;AACA,UAAM;AAAEa,MAAAA;AAAF,QAAyBF,MAAM,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ACD,cAAC,gBAAD;AACC,IAAA,eAAe,EAAG,MAAM;AACvBI,MAAAA,aAAa,CAAEN,uBAAuB,CAACG,MAA1B,CAAb;AACA;AAHF,IAFF,CARD,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declares and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { onChoosePattern } ) {\n\tconst blockPatterns = useStartPatterns();\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nconst START_PAGE_MODAL_STATES = {\n\tINITIAL: 'INITIAL',\n\tPATTERN: 'PATTERN',\n\tCLOSED: 'CLOSED',\n};\n\nexport default function StartPageOptions() {\n\tconst [ modalState, setModalState ] = useState(\n\t\tSTART_PAGE_MODAL_STATES.INITIAL\n\t);\n\tconst blockPatterns = useStartPatterns();\n\tconst hasStartPattern = blockPatterns.length > 0;\n\tconst shouldOpenModel = useSelect(\n\t\t( select ) => {\n\t\t\tif (\n\t\t\t\t! hasStartPattern ||\n\t\t\t\tmodalState !== START_PAGE_MODAL_STATES.INITIAL\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getEditedPostContent, isEditedPostSaveable } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst { isEditingTemplate, isFeatureActive } =\n\t\t\t\tselect( editPostStore );\n\t\t\treturn (\n\t\t\t\t! isEditedPostSaveable() &&\n\t\t\t\t'' === getEditedPostContent() &&\n\t\t\t\t! isEditingTemplate() &&\n\t\t\t\t! isFeatureActive( 'welcomeGuide' )\n\t\t\t);\n\t\t},\n\t\t[ modalState, hasStartPattern ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldOpenModel ) {\n\t\t\tsetModalState( START_PAGE_MODAL_STATES.PATTERN );\n\t\t}\n\t}, [ shouldOpenModel ] );\n\n\tif (\n\t\tmodalState === START_PAGE_MODAL_STATES.INITIAL ||\n\t\tmodalState === START_PAGE_MODAL_STATES.CLOSED\n\t) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen={ true }\n\t\t\tonRequestClose={ () => {\n\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t} }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t{ modalState === START_PAGE_MODAL_STATES.PATTERN && (\n\t\t\t\t\t<PatternSelection\n\t\t\t\t\t\tonChoosePattern={ () => {\n\t\t\t\t\t\t\tsetModalState( START_PAGE_MODAL_STATES.CLOSED );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -1238,6 +1238,12 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1238
1238
  height: 61px;
1239
1239
  }
1240
1240
 
1241
+ @media (min-width: 782px) {
1242
+ .edit-post-layout.has-fixed-toolbar .interface-interface-skeleton__header:not(:focus-within) {
1243
+ z-index: 19;
1244
+ }
1245
+ }
1246
+
1241
1247
  .edit-post-block-manager__no-results {
1242
1248
  font-style: italic;
1243
1249
  padding: 24px 0;
@@ -1400,6 +1406,10 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1400
1406
  clear: both;
1401
1407
  }
1402
1408
 
1409
+ /**
1410
+ * Note that this CSS file should be in sync with its counterpart in the other editor:
1411
+ * packages/edit-site/src/components/secondary-sidebar/style.scss
1412
+ */
1403
1413
  .edit-post-editor__inserter-panel,
1404
1414
  .edit-post-editor__document-overview-panel {
1405
1415
  height: 100%;
@@ -1407,8 +1417,10 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1407
1417
  flex-direction: column;
1408
1418
  }
1409
1419
 
1410
- .edit-post-editor__document-overview-panel {
1411
- width: 350px;
1420
+ @media (min-width: 782px) {
1421
+ .edit-post-editor__document-overview-panel {
1422
+ width: 350px;
1423
+ }
1412
1424
  }
1413
1425
  .edit-post-editor__document-overview-panel .edit-post-sidebar__panel-tabs {
1414
1426
  flex-direction: row-reverse;
@@ -1458,10 +1470,59 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1458
1470
  .edit-post-editor__list-view-panel-content,
1459
1471
  .edit-post-editor__list-view-container > .document-outline,
1460
1472
  .edit-post-editor__list-view-empty-headings {
1461
- overflow: auto;
1462
1473
  height: 100%;
1474
+ scrollbar-width: thin;
1475
+ scrollbar-gutter: stable both-edges;
1476
+ scrollbar-color: transparent transparent;
1477
+ will-change: transform;
1478
+ overflow: auto;
1479
+ scrollbar-gutter: auto;
1463
1480
  padding: 8px 6px;
1464
1481
  }
1482
+ .edit-post-editor__list-view-panel-content::-webkit-scrollbar,
1483
+ .edit-post-editor__list-view-container > .document-outline::-webkit-scrollbar,
1484
+ .edit-post-editor__list-view-empty-headings::-webkit-scrollbar {
1485
+ width: 12px;
1486
+ height: 12px;
1487
+ }
1488
+ .edit-post-editor__list-view-panel-content::-webkit-scrollbar-track,
1489
+ .edit-post-editor__list-view-container > .document-outline::-webkit-scrollbar-track,
1490
+ .edit-post-editor__list-view-empty-headings::-webkit-scrollbar-track {
1491
+ background-color: transparent;
1492
+ }
1493
+ .edit-post-editor__list-view-panel-content::-webkit-scrollbar-thumb,
1494
+ .edit-post-editor__list-view-container > .document-outline::-webkit-scrollbar-thumb,
1495
+ .edit-post-editor__list-view-empty-headings::-webkit-scrollbar-thumb {
1496
+ background-color: transparent;
1497
+ border-radius: 8px;
1498
+ border: 3px solid transparent;
1499
+ background-clip: padding-box;
1500
+ }
1501
+ .edit-post-editor__list-view-panel-content:hover::-webkit-scrollbar-thumb, .edit-post-editor__list-view-panel-content:focus::-webkit-scrollbar-thumb, .edit-post-editor__list-view-panel-content:focus-within::-webkit-scrollbar-thumb,
1502
+ .edit-post-editor__list-view-container > .document-outline:hover::-webkit-scrollbar-thumb,
1503
+ .edit-post-editor__list-view-container > .document-outline:focus::-webkit-scrollbar-thumb,
1504
+ .edit-post-editor__list-view-container > .document-outline:focus-within::-webkit-scrollbar-thumb,
1505
+ .edit-post-editor__list-view-empty-headings:hover::-webkit-scrollbar-thumb,
1506
+ .edit-post-editor__list-view-empty-headings:focus::-webkit-scrollbar-thumb,
1507
+ .edit-post-editor__list-view-empty-headings:focus-within::-webkit-scrollbar-thumb {
1508
+ background-color: #949494;
1509
+ }
1510
+ .edit-post-editor__list-view-panel-content:hover, .edit-post-editor__list-view-panel-content:focus, .edit-post-editor__list-view-panel-content:focus-within,
1511
+ .edit-post-editor__list-view-container > .document-outline:hover,
1512
+ .edit-post-editor__list-view-container > .document-outline:focus,
1513
+ .edit-post-editor__list-view-container > .document-outline:focus-within,
1514
+ .edit-post-editor__list-view-empty-headings:hover,
1515
+ .edit-post-editor__list-view-empty-headings:focus,
1516
+ .edit-post-editor__list-view-empty-headings:focus-within {
1517
+ scrollbar-color: #949494 transparent;
1518
+ }
1519
+ @media (hover: none) {
1520
+ .edit-post-editor__list-view-panel-content,
1521
+ .edit-post-editor__list-view-container > .document-outline,
1522
+ .edit-post-editor__list-view-empty-headings {
1523
+ scrollbar-color: #949494 transparent;
1524
+ }
1525
+ }
1465
1526
 
1466
1527
  .edit-post-editor__list-view-empty-headings {
1467
1528
  text-align: center;
@@ -1798,6 +1859,7 @@ h2.edit-post-template-summary__title {
1798
1859
  position: relative;
1799
1860
  display: flex;
1800
1861
  flex-flow: column;
1862
+ overflow: hidden;
1801
1863
  background-color: #2f2f2f;
1802
1864
  flex: 1 0 auto;
1803
1865
  }
@@ -1879,27 +1941,21 @@ h2.edit-post-template-summary__title {
1879
1941
  fill: #fff;
1880
1942
  }
1881
1943
 
1882
- @media (min-width: 600px) {
1883
- .edit-post-start-page-options__modal {
1884
- width: calc(100% - 32px);
1885
- height: calc(100% - 120px);
1886
- }
1944
+ .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1945
+ column-count: 2;
1946
+ column-gap: 24px;
1947
+ padding-top: 2px;
1887
1948
  }
1888
1949
  @media (min-width: 782px) {
1889
- .edit-post-start-page-options__modal {
1890
- width: 750px;
1950
+ .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1951
+ column-count: 3;
1891
1952
  }
1892
1953
  }
1893
- @media (min-width: 960px) {
1894
- .edit-post-start-page-options__modal {
1895
- height: 70%;
1954
+ @media (min-width: 1280px) {
1955
+ .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1956
+ column-count: 4;
1896
1957
  }
1897
1958
  }
1898
-
1899
- .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1900
- column-count: 2;
1901
- column-gap: 24px;
1902
- }
1903
1959
  .edit-post-start-page-options__modal-content .block-editor-block-patterns-list .block-editor-block-patterns-list__list-item {
1904
1960
  break-inside: avoid-column;
1905
1961
  margin-bottom: 24px;
@@ -1238,6 +1238,12 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1238
1238
  height: 61px;
1239
1239
  }
1240
1240
 
1241
+ @media (min-width: 782px) {
1242
+ .edit-post-layout.has-fixed-toolbar .interface-interface-skeleton__header:not(:focus-within) {
1243
+ z-index: 19;
1244
+ }
1245
+ }
1246
+
1241
1247
  .edit-post-block-manager__no-results {
1242
1248
  font-style: italic;
1243
1249
  padding: 24px 0;
@@ -1400,6 +1406,10 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1400
1406
  clear: both;
1401
1407
  }
1402
1408
 
1409
+ /**
1410
+ * Note that this CSS file should be in sync with its counterpart in the other editor:
1411
+ * packages/edit-site/src/components/secondary-sidebar/style.scss
1412
+ */
1403
1413
  .edit-post-editor__inserter-panel,
1404
1414
  .edit-post-editor__document-overview-panel {
1405
1415
  height: 100%;
@@ -1407,8 +1417,10 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1407
1417
  flex-direction: column;
1408
1418
  }
1409
1419
 
1410
- .edit-post-editor__document-overview-panel {
1411
- width: 350px;
1420
+ @media (min-width: 782px) {
1421
+ .edit-post-editor__document-overview-panel {
1422
+ width: 350px;
1423
+ }
1412
1424
  }
1413
1425
  .edit-post-editor__document-overview-panel .edit-post-sidebar__panel-tabs {
1414
1426
  flex-direction: row-reverse;
@@ -1458,10 +1470,59 @@ body.is-fullscreen-mode .edit-post-layout .components-editor-notices__snackbar {
1458
1470
  .edit-post-editor__list-view-panel-content,
1459
1471
  .edit-post-editor__list-view-container > .document-outline,
1460
1472
  .edit-post-editor__list-view-empty-headings {
1461
- overflow: auto;
1462
1473
  height: 100%;
1474
+ scrollbar-width: thin;
1475
+ scrollbar-gutter: stable both-edges;
1476
+ scrollbar-color: transparent transparent;
1477
+ will-change: transform;
1478
+ overflow: auto;
1479
+ scrollbar-gutter: auto;
1463
1480
  padding: 8px 6px;
1464
1481
  }
1482
+ .edit-post-editor__list-view-panel-content::-webkit-scrollbar,
1483
+ .edit-post-editor__list-view-container > .document-outline::-webkit-scrollbar,
1484
+ .edit-post-editor__list-view-empty-headings::-webkit-scrollbar {
1485
+ width: 12px;
1486
+ height: 12px;
1487
+ }
1488
+ .edit-post-editor__list-view-panel-content::-webkit-scrollbar-track,
1489
+ .edit-post-editor__list-view-container > .document-outline::-webkit-scrollbar-track,
1490
+ .edit-post-editor__list-view-empty-headings::-webkit-scrollbar-track {
1491
+ background-color: transparent;
1492
+ }
1493
+ .edit-post-editor__list-view-panel-content::-webkit-scrollbar-thumb,
1494
+ .edit-post-editor__list-view-container > .document-outline::-webkit-scrollbar-thumb,
1495
+ .edit-post-editor__list-view-empty-headings::-webkit-scrollbar-thumb {
1496
+ background-color: transparent;
1497
+ border-radius: 8px;
1498
+ border: 3px solid transparent;
1499
+ background-clip: padding-box;
1500
+ }
1501
+ .edit-post-editor__list-view-panel-content:hover::-webkit-scrollbar-thumb, .edit-post-editor__list-view-panel-content:focus::-webkit-scrollbar-thumb, .edit-post-editor__list-view-panel-content:focus-within::-webkit-scrollbar-thumb,
1502
+ .edit-post-editor__list-view-container > .document-outline:hover::-webkit-scrollbar-thumb,
1503
+ .edit-post-editor__list-view-container > .document-outline:focus::-webkit-scrollbar-thumb,
1504
+ .edit-post-editor__list-view-container > .document-outline:focus-within::-webkit-scrollbar-thumb,
1505
+ .edit-post-editor__list-view-empty-headings:hover::-webkit-scrollbar-thumb,
1506
+ .edit-post-editor__list-view-empty-headings:focus::-webkit-scrollbar-thumb,
1507
+ .edit-post-editor__list-view-empty-headings:focus-within::-webkit-scrollbar-thumb {
1508
+ background-color: #949494;
1509
+ }
1510
+ .edit-post-editor__list-view-panel-content:hover, .edit-post-editor__list-view-panel-content:focus, .edit-post-editor__list-view-panel-content:focus-within,
1511
+ .edit-post-editor__list-view-container > .document-outline:hover,
1512
+ .edit-post-editor__list-view-container > .document-outline:focus,
1513
+ .edit-post-editor__list-view-container > .document-outline:focus-within,
1514
+ .edit-post-editor__list-view-empty-headings:hover,
1515
+ .edit-post-editor__list-view-empty-headings:focus,
1516
+ .edit-post-editor__list-view-empty-headings:focus-within {
1517
+ scrollbar-color: #949494 transparent;
1518
+ }
1519
+ @media (hover: none) {
1520
+ .edit-post-editor__list-view-panel-content,
1521
+ .edit-post-editor__list-view-container > .document-outline,
1522
+ .edit-post-editor__list-view-empty-headings {
1523
+ scrollbar-color: #949494 transparent;
1524
+ }
1525
+ }
1465
1526
 
1466
1527
  .edit-post-editor__list-view-empty-headings {
1467
1528
  text-align: center;
@@ -1798,6 +1859,7 @@ h2.edit-post-template-summary__title {
1798
1859
  position: relative;
1799
1860
  display: flex;
1800
1861
  flex-flow: column;
1862
+ overflow: hidden;
1801
1863
  background-color: #2f2f2f;
1802
1864
  flex: 1 0 auto;
1803
1865
  }
@@ -1879,27 +1941,21 @@ h2.edit-post-template-summary__title {
1879
1941
  fill: #fff;
1880
1942
  }
1881
1943
 
1882
- @media (min-width: 600px) {
1883
- .edit-post-start-page-options__modal {
1884
- width: calc(100% - 32px);
1885
- height: calc(100% - 120px);
1886
- }
1944
+ .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1945
+ column-count: 2;
1946
+ column-gap: 24px;
1947
+ padding-top: 2px;
1887
1948
  }
1888
1949
  @media (min-width: 782px) {
1889
- .edit-post-start-page-options__modal {
1890
- width: 750px;
1950
+ .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1951
+ column-count: 3;
1891
1952
  }
1892
1953
  }
1893
- @media (min-width: 960px) {
1894
- .edit-post-start-page-options__modal {
1895
- height: 70%;
1954
+ @media (min-width: 1280px) {
1955
+ .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1956
+ column-count: 4;
1896
1957
  }
1897
1958
  }
1898
-
1899
- .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
1900
- column-count: 2;
1901
- column-gap: 24px;
1902
- }
1903
1959
  .edit-post-start-page-options__modal-content .block-editor-block-patterns-list .block-editor-block-patterns-list__list-item {
1904
1960
  break-inside: avoid-column;
1905
1961
  margin-bottom: 24px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-post",
3
- "version": "7.8.0",
3
+ "version": "7.9.0",
4
4
  "description": "Edit Post module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,37 +27,37 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.31.0",
31
- "@wordpress/api-fetch": "^6.28.0",
32
- "@wordpress/block-editor": "^11.8.0",
33
- "@wordpress/block-library": "^8.8.0",
34
- "@wordpress/blocks": "^12.8.0",
35
- "@wordpress/components": "^23.8.0",
36
- "@wordpress/compose": "^6.8.0",
37
- "@wordpress/core-data": "^6.8.0",
38
- "@wordpress/data": "^9.1.0",
39
- "@wordpress/deprecated": "^3.31.0",
40
- "@wordpress/dom": "^3.31.0",
41
- "@wordpress/editor": "^13.8.0",
42
- "@wordpress/element": "^5.8.0",
43
- "@wordpress/hooks": "^3.31.0",
44
- "@wordpress/i18n": "^4.31.0",
45
- "@wordpress/icons": "^9.22.0",
46
- "@wordpress/interface": "^5.8.0",
47
- "@wordpress/keyboard-shortcuts": "^4.8.0",
48
- "@wordpress/keycodes": "^3.31.0",
49
- "@wordpress/media-utils": "^4.22.0",
50
- "@wordpress/notices": "^3.31.0",
51
- "@wordpress/plugins": "^5.8.0",
52
- "@wordpress/preferences": "^3.8.0",
53
- "@wordpress/private-apis": "^0.13.0",
54
- "@wordpress/url": "^3.32.0",
55
- "@wordpress/viewport": "^5.8.0",
56
- "@wordpress/warning": "^2.31.0",
57
- "@wordpress/widgets": "^3.8.0",
30
+ "@wordpress/a11y": "^3.32.0",
31
+ "@wordpress/api-fetch": "^6.29.0",
32
+ "@wordpress/block-editor": "^12.0.0",
33
+ "@wordpress/block-library": "^8.9.0",
34
+ "@wordpress/blocks": "^12.9.0",
35
+ "@wordpress/components": "^23.9.0",
36
+ "@wordpress/compose": "^6.9.0",
37
+ "@wordpress/core-data": "^6.9.0",
38
+ "@wordpress/data": "^9.2.0",
39
+ "@wordpress/deprecated": "^3.32.0",
40
+ "@wordpress/dom": "^3.32.0",
41
+ "@wordpress/editor": "^13.9.0",
42
+ "@wordpress/element": "^5.9.0",
43
+ "@wordpress/hooks": "^3.32.0",
44
+ "@wordpress/i18n": "^4.32.0",
45
+ "@wordpress/icons": "^9.23.0",
46
+ "@wordpress/interface": "^5.9.0",
47
+ "@wordpress/keyboard-shortcuts": "^4.9.0",
48
+ "@wordpress/keycodes": "^3.32.0",
49
+ "@wordpress/media-utils": "^4.23.0",
50
+ "@wordpress/notices": "^4.0.0",
51
+ "@wordpress/plugins": "^6.0.0",
52
+ "@wordpress/preferences": "^3.9.0",
53
+ "@wordpress/private-apis": "^0.14.0",
54
+ "@wordpress/url": "^3.33.0",
55
+ "@wordpress/viewport": "^5.9.0",
56
+ "@wordpress/warning": "^2.32.0",
57
+ "@wordpress/widgets": "^3.9.0",
58
58
  "classnames": "^2.3.1",
59
59
  "memize": "^1.1.0",
60
- "rememo": "^4.0.0"
60
+ "rememo": "^4.0.2"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": "^18.0.0",
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "d61700b9f1c72ba0b030fc815ef1685b4f4031ec"
69
+ "gitHead": "6df0c62d43b8901414ccd22ffbe56eaa99d012a6"
70
70
  }
@@ -8,6 +8,7 @@ import {
8
8
  NavigableToolbar,
9
9
  ToolSelector,
10
10
  store as blockEditorStore,
11
+ privateApis as blockEditorPrivateApis,
11
12
  } from '@wordpress/block-editor';
12
13
  import {
13
14
  EditorHistoryRedo,
@@ -23,6 +24,7 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
23
24
  * Internal dependencies
24
25
  */
25
26
  import { store as editPostStore } from '../../../store';
27
+ import { unlock } from '../../../private-apis';
26
28
 
27
29
  const preventDefault = ( event ) => {
28
30
  event.preventDefault();
@@ -39,15 +41,27 @@ function HeaderToolbar() {
39
41
  showIconLabels,
40
42
  isListViewOpen,
41
43
  listViewShortcut,
44
+ selectedBlockId,
45
+ hasFixedToolbar,
42
46
  } = useSelect( ( select ) => {
43
- const { hasInserterItems, getBlockRootClientId, getBlockSelectionEnd } =
44
- select( blockEditorStore );
47
+ const {
48
+ hasInserterItems,
49
+ getBlockRootClientId,
50
+ getBlockSelectionEnd,
51
+ getSelectedBlockClientId,
52
+ getFirstMultiSelectedBlockClientId,
53
+ getSettings,
54
+ } = select( blockEditorStore );
45
55
  const { getEditorSettings } = select( editorStore );
46
56
  const { getEditorMode, isFeatureActive, isListViewOpened } =
47
57
  select( editPostStore );
48
58
  const { getShortcutRepresentation } = select( keyboardShortcutsStore );
49
59
 
50
60
  return {
61
+ hasFixedToolbar: getSettings().hasFixedToolbar,
62
+ selectedBlockId:
63
+ getSelectedBlockClientId() ||
64
+ getFirstMultiSelectedBlockClientId(),
51
65
  // This setting (richEditingEnabled) should not live in the block editor's setting.
52
66
  isInserterEnabled:
53
67
  getEditorMode() === 'visual' &&
@@ -64,9 +78,19 @@ function HeaderToolbar() {
64
78
  ),
65
79
  };
66
80
  }, [] );
81
+
82
+ const { useShouldContextualToolbarShow } = unlock( blockEditorPrivateApis );
83
+
67
84
  const isLargeViewport = useViewportMatch( 'medium' );
68
85
  const isWideViewport = useViewportMatch( 'wide' );
69
-
86
+ const { shouldShowContextualToolbar, canFocusHiddenToolbar } =
87
+ useShouldContextualToolbarShow( selectedBlockId );
88
+ // If there's a block toolbar to be focused, disable the focus shortcut for the document toolbar.
89
+ // There's a fixed block toolbar when the fixed toolbar option is enabled or when the browser width is less than the large viewport.
90
+ const blockToolbarCanBeFocused =
91
+ shouldShowContextualToolbar ||
92
+ canFocusHiddenToolbar ||
93
+ ( ( hasFixedToolbar || ! isLargeViewport ) && selectedBlockId );
70
94
  /* translators: accessibility text for the editor toolbar */
71
95
  const toolbarAriaLabel = __( 'Document tools' );
72
96
 
@@ -114,6 +138,7 @@ function HeaderToolbar() {
114
138
  <NavigableToolbar
115
139
  className="edit-post-header-toolbar"
116
140
  aria-label={ toolbarAriaLabel }
141
+ shouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }
117
142
  >
118
143
  <div className="edit-post-header-toolbar__left">
119
144
  <ToolbarItem
@@ -59,7 +59,6 @@ export default function DeleteTemplate() {
59
59
  )
60
60
  );
61
61
  updateEditorSettings( {
62
- ...settings,
63
62
  availableTemplates: newAvailableTemplates,
64
63
  } );
65
64
  deleteEntityRecord( 'postType', 'wp_template', template.id, {
@@ -58,16 +58,13 @@ export default function EditTemplateTitle() {
58
58
  const settings = getEditorSettings();
59
59
  const newAvailableTemplates = Object.fromEntries(
60
60
  Object.entries( settings.availableTemplates ?? {} ).map(
61
- ( [ id, existingTitle ] ) => {
62
- if ( id !== template.slug ) {
63
- return existingTitle;
64
- }
65
- return newTitle;
66
- }
61
+ ( [ id, existingTitle ] ) => [
62
+ id,
63
+ id !== template.slug ? existingTitle : newTitle,
64
+ ]
67
65
  )
68
66
  );
69
67
  updateEditorSettings( {
70
- ...settings,
71
68
  availableTemplates: newAvailableTemplates,
72
69
  } );
73
70
  editEntityRecord( 'postType', 'wp_template', template.id, {
@@ -99,3 +99,15 @@
99
99
  .edit-post-layout .entities-saved-states__panel-header {
100
100
  height: $header-height + $border-width;
101
101
  }
102
+
103
+ .edit-post-layout.has-fixed-toolbar {
104
+ // making the header be lower than the content
105
+ // so the fixed toolbar can be positioned on top of it
106
+ // but only on desktop
107
+ @include break-medium() {
108
+ .interface-interface-skeleton__header:not(:focus-within) {
109
+ z-index: 19;
110
+ }
111
+ }
112
+
113
+ }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Note that this CSS file should be in sync with its counterpart in the other editor:
3
+ * packages/edit-site/src/components/secondary-sidebar/style.scss
4
+ */
5
+
1
6
  .edit-post-editor__inserter-panel,
2
7
  .edit-post-editor__document-overview-panel {
3
8
  height: 100%;
@@ -6,10 +11,11 @@
6
11
  }
7
12
 
8
13
  .edit-post-editor__document-overview-panel {
9
- // Same width as the Inserter.
10
- // @see packages/block-editor/src/components/inserter/style.scss
11
- // Width of the list view panel.
12
- width: 350px;
14
+ @include break-medium() {
15
+ // Same width as the Inserter.
16
+ // @see packages/block-editor/src/components/inserter/style.scss
17
+ width: 350px;
18
+ }
13
19
 
14
20
  .edit-post-sidebar__panel-tabs {
15
21
  flex-direction: row-reverse;
@@ -62,8 +68,17 @@
62
68
  .edit-post-editor__list-view-panel-content,
63
69
  .edit-post-editor__list-view-container > .document-outline,
64
70
  .edit-post-editor__list-view-empty-headings {
65
- overflow: auto;
66
71
  height: 100%;
72
+
73
+ // Include custom scrollbars, invisible until hovered.
74
+ @include custom-scrollbars-on-hover(transparent, $gray-600);
75
+ overflow: auto;
76
+
77
+ // Only reserve space for scrollbars when there is content to scroll.
78
+ // This allows items in the list view to have equidistant padding left and right
79
+ // right up until a scrollbar is present.
80
+ scrollbar-gutter: auto;
81
+
67
82
  // The table cells use an extra pixels of space left and right. We compensate for that here.
68
83
  padding: $grid-unit-10 ($grid-unit-10 - $border-width - $border-width);
69
84
  }
@@ -113,6 +113,7 @@ export default function StartPageOptions() {
113
113
  <Modal
114
114
  className="edit-post-start-page-options__modal"
115
115
  title={ __( 'Choose a pattern' ) }
116
+ isFullScreen={ true }
116
117
  onRequestClose={ () => {
117
118
  setModalState( START_PAGE_MODAL_STATES.CLOSED );
118
119
  } }
@@ -1,23 +1,19 @@
1
- .edit-post-start-page-options__modal {
2
- // To keep modal dimensions consistent as subsections are navigated, width
3
- // and height are used instead of max-(width/height).
4
- @include break-small() {
5
- width: calc(100% - #{ $grid-unit-20 * 2 });
6
- height: calc(100% - #{ $header-height * 2 });
7
- }
8
- @include break-medium() {
9
- width: $break-medium - $grid-unit-20 * 2;
10
- }
11
- @include break-large() {
12
- height: 70%;
13
- }
14
- }
15
-
16
1
  // 2 column masonry layout.
17
2
  .edit-post-start-page-options__modal-content .block-editor-block-patterns-list {
18
3
  column-count: 2;
19
4
  column-gap: $grid-unit-30;
20
5
 
6
+ // Small top padding required to avoid cutting off the visible outline when hovering items
7
+ padding-top: $border-width-focus;
8
+
9
+ @include break-medium() {
10
+ column-count: 3;
11
+ }
12
+
13
+ @include break-wide() {
14
+ column-count: 4;
15
+ }
16
+
21
17
  .block-editor-block-patterns-list__list-item {
22
18
  break-inside: avoid-column;
23
19
  margin-bottom: $grid-unit-30;
@@ -2,6 +2,7 @@
2
2
  position: relative;
3
3
  display: flex;
4
4
  flex-flow: column;
5
+ overflow: hidden;
5
6
 
6
7
  // Gray preview overlay (desktop/tablet/mobile) is intentionally not set on an element with scrolling content like
7
8
  // interface-interface-skeleton__content. This causes graphical glitches (flashes of the background color)