@wordpress/edit-post 6.1.0 → 6.3.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 (68) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/header/plugin-more-menu-item/index.js +5 -0
  3. package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
  4. package/build/components/header/template-title/delete-template.js +3 -1
  5. package/build/components/header/template-title/delete-template.js.map +1 -1
  6. package/build/components/sidebar/post-link/index.js +1 -1
  7. package/build/components/sidebar/post-link/index.js.map +1 -1
  8. package/build/components/visual-editor/index.js +3 -3
  9. package/build/components/visual-editor/index.js.map +1 -1
  10. package/build/editor.js +4 -6
  11. package/build/editor.js.map +1 -1
  12. package/build/index.js +5 -0
  13. package/build/index.js.map +1 -1
  14. package/build/index.native.js +15 -0
  15. package/build/index.native.js.map +1 -1
  16. package/build/store/actions.js +99 -74
  17. package/build/store/actions.js.map +1 -1
  18. package/build/store/index.js +7 -10
  19. package/build/store/index.js.map +1 -1
  20. package/build/store/reducer.js +0 -118
  21. package/build/store/reducer.js.map +1 -1
  22. package/build/store/selectors.js +95 -34
  23. package/build/store/selectors.js.map +1 -1
  24. package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
  25. package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
  26. package/build-module/components/header/template-title/delete-template.js +3 -1
  27. package/build-module/components/header/template-title/delete-template.js.map +1 -1
  28. package/build-module/components/sidebar/post-link/index.js +1 -1
  29. package/build-module/components/sidebar/post-link/index.js.map +1 -1
  30. package/build-module/components/visual-editor/index.js +3 -3
  31. package/build-module/components/visual-editor/index.js.map +1 -1
  32. package/build-module/editor.js +3 -6
  33. package/build-module/editor.js.map +1 -1
  34. package/build-module/index.js +5 -0
  35. package/build-module/index.js.map +1 -1
  36. package/build-module/index.native.js +13 -0
  37. package/build-module/index.native.js.map +1 -1
  38. package/build-module/store/actions.js +92 -68
  39. package/build-module/store/actions.js.map +1 -1
  40. package/build-module/store/index.js +7 -10
  41. package/build-module/store/index.js.map +1 -1
  42. package/build-module/store/reducer.js +1 -115
  43. package/build-module/store/reducer.js.map +1 -1
  44. package/build-module/store/selectors.js +89 -28
  45. package/build-module/store/selectors.js.map +1 -1
  46. package/build-style/style-rtl.css +1 -4
  47. package/build-style/style.css +1 -4
  48. package/package.json +27 -26
  49. package/src/components/header/plugin-more-menu-item/index.js +2 -0
  50. package/src/components/header/template-title/delete-template.js +3 -1
  51. package/src/components/sidebar/post-link/index.js +1 -1
  52. package/src/components/visual-editor/index.js +5 -3
  53. package/src/editor.js +3 -8
  54. package/src/index.js +5 -0
  55. package/src/index.native.js +14 -0
  56. package/src/store/actions.js +87 -42
  57. package/src/store/index.js +7 -11
  58. package/src/store/reducer.js +1 -106
  59. package/src/store/selectors.js +124 -50
  60. package/src/store/test/actions.js +89 -46
  61. package/src/store/test/reducer.js +0 -135
  62. package/src/store/test/selectors.js +0 -174
  63. package/src/style.scss +0 -4
  64. package/build/store/defaults.js +0 -19
  65. package/build/store/defaults.js.map +0 -1
  66. package/build-module/store/defaults.js +0 -12
  67. package/build-module/store/defaults.js.map +0 -1
  68. package/src/store/defaults.js +0 -11
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/store/reducer.js"],"names":["createWithInitialState","initialState","reducer","state","action","preferences","combineReducers","PREFERENCES_DEFAULTS","panels","type","panelName","enabled","isOpen","opened","editorMode","mode","preferredStyleVariations","blockName","blockStyle","localAutosaveInterval","interval","removedPanels","activeModal","name","publishSidebarActive","isSavingMetaBoxes","metaBoxLocations","metaBoxesPerLocation","deviceType","blockInserterPanel","value","listViewPanel","isEditingTemplate","metaBoxesInitialized","metaBoxes","isSaving","locations","initialized"],"mappings":";;;;;;;;;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,sBAA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F+B;AAG/B7B,EAAAA,WAH+B;AAI/BmB,EAAAA,oBAJ+B;AAK/BH,EAAAA,aAL+B;AAM/BO,EAAAA,UAN+B;AAO/BC,EAAAA,kBAP+B;AAQ/BE,EAAAA,aAR+B;AAS/BC,EAAAA;AAT+B,CAAjB,C","sourcesContent":["/**\n * External dependencies\n */\nimport { flow, get, includes, omit } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { PREFERENCES_DEFAULTS } from './defaults';\n\n/**\n * Higher-order reducer creator which provides the given initial state for the\n * original reducer.\n *\n * @param {*} initialState Initial state to provide to reducer.\n *\n * @return {Function} Higher-order reducer.\n */\nconst createWithInitialState = ( initialState ) => ( reducer ) => {\n\treturn ( state = initialState, action ) => reducer( state, action );\n};\n\n/**\n * Reducer returning the user preferences.\n *\n * @param {Object} state Current state.\n * @param {string} state.mode Current editor mode, either\n * \"visual\" or \"text\".\n * @param {boolean} state.isGeneralSidebarDismissed Whether general sidebar is\n * dismissed. False by default\n * or when closing general\n * sidebar, true when opening\n * sidebar.\n * @param {boolean} state.isSidebarOpened Whether the sidebar is\n * opened or closed.\n * @param {Object} state.panels The state of the different\n * sidebar panels.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const preferences = flow( [\n\tcombineReducers,\n\tcreateWithInitialState( PREFERENCES_DEFAULTS ),\n] )( {\n\tpanels( state, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'TOGGLE_PANEL_ENABLED': {\n\t\t\t\tconst { panelName } = action;\n\t\t\t\treturn {\n\t\t\t\t\t...state,\n\t\t\t\t\t[ panelName ]: {\n\t\t\t\t\t\t...state[ panelName ],\n\t\t\t\t\t\tenabled: ! get( state, [ panelName, 'enabled' ], true ),\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tcase 'TOGGLE_PANEL_OPENED': {\n\t\t\t\tconst { panelName } = action;\n\t\t\t\tconst isOpen =\n\t\t\t\t\tstate[ panelName ] === true ||\n\t\t\t\t\tget( state, [ panelName, 'opened' ], false );\n\t\t\t\treturn {\n\t\t\t\t\t...state,\n\t\t\t\t\t[ panelName ]: {\n\t\t\t\t\t\t...state[ panelName ],\n\t\t\t\t\t\topened: ! isOpen,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn state;\n\t},\n\teditorMode( state, action ) {\n\t\tif ( action.type === 'SWITCH_MODE' ) {\n\t\t\treturn action.mode;\n\t\t}\n\n\t\treturn state;\n\t},\n\tpreferredStyleVariations( state, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'UPDATE_PREFERRED_STYLE_VARIATIONS': {\n\t\t\t\tif ( ! action.blockName ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\tif ( ! action.blockStyle ) {\n\t\t\t\t\treturn omit( state, [ action.blockName ] );\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...state,\n\t\t\t\t\t[ action.blockName ]: action.blockStyle,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn state;\n\t},\n\tlocalAutosaveInterval( state, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'UPDATE_LOCAL_AUTOSAVE_INTERVAL':\n\t\t\t\treturn action.interval;\n\t\t}\n\n\t\treturn state;\n\t},\n} );\n\n/**\n * Reducer storing the list of all programmatically removed panels.\n *\n * @param {Array} state Current state.\n * @param {Object} action Action object.\n *\n * @return {Array} Updated state.\n */\nexport function removedPanels( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REMOVE_PANEL':\n\t\t\tif ( ! includes( state, action.panelName ) ) {\n\t\t\t\treturn [ ...state, action.panelName ];\n\t\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for storing the name of the open modal, or null if no modal is open.\n *\n * @param {Object} state Previous state.\n * @param {Object} action Action object containing the `name` of the modal\n *\n * @return {Object} Updated state\n */\nexport function activeModal( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_MODAL':\n\t\t\treturn action.name;\n\t\tcase 'CLOSE_MODAL':\n\t\t\treturn null;\n\t}\n\n\treturn state;\n}\n\nexport function publishSidebarActive( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_PUBLISH_SIDEBAR':\n\t\t\treturn true;\n\t\tcase 'CLOSE_PUBLISH_SIDEBAR':\n\t\t\treturn false;\n\t\tcase 'TOGGLE_PUBLISH_SIDEBAR':\n\t\t\treturn ! state;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS':\n\t\t\treturn action.metaBoxesPerLocation;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer tracking whether the inserter is open.\n *\n * @param {boolean} state\n * @param {Object} action\n */\nfunction isEditingTemplate( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_EDITING_TEMPLATE':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tactiveModal,\n\tmetaBoxes,\n\tpreferences,\n\tpublishSidebarActive,\n\tremovedPanels,\n\tdeviceType,\n\tblockInserterPanel,\n\tlistViewPanel,\n\tisEditingTemplate,\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/store/reducer.js"],"names":["removedPanels","state","action","type","panelName","activeModal","name","publishSidebarActive","isSavingMetaBoxes","metaBoxLocations","metaBoxesPerLocation","deviceType","blockInserterPanel","isOpen","value","listViewPanel","isEditingTemplate","metaBoxesInitialized","metaBoxes","isSaving","locations","initialized"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,GAA6C;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;AACnD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,cAAL;AACC,UAAK,CAAE,sBAAUF,KAAV,EAAiBC,MAAM,CAACE,SAAxB,CAAP,EAA6C;AAC5C,eAAO,CAAE,GAAGH,KAAL,EAAYC,MAAM,CAACE,SAAnB,CAAP;AACA;;AAJH;;AAOA,SAAOH,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,WAAT,GAA6C;AAAA,MAAvBJ,KAAuB,uEAAf,IAAe;AAAA,MAATC,MAAS;;AACnD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,YAAL;AACC,aAAOD,MAAM,CAACI,IAAd;;AACD,SAAK,aAAL;AACC,aAAO,IAAP;AAJF;;AAOA,SAAOL,KAAP;AACA;;AAEM,SAASM,oBAAT,GAAuD;AAAA,MAAxBN,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AAC7D,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,sBAAL;AACC,aAAO,IAAP;;AACD,SAAK,uBAAL;AACC,aAAO,KAAP;;AACD,SAAK,wBAAL;AACC,aAAO,CAAEF,KAAT;AANF;;AAQA,SAAOA,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,iBAAT,GAAoD;AAAA,MAAxBP,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AAC1D,U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OZ,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASe,iBAAT,GAAoD;AAAA,MAAxBf,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AACnD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,yBAAL;AACC,aAAOD,MAAM,CAACY,KAAd;AAFF;;AAIA,SAAOb,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASgB,oBAAT,GAAuD;AAAA,MAAxBhB,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AACtD,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,wBAAL;AACC,aAAO,IAAP;AAFF;;AAIA,SAAOF,KAAP;AACA;;AAED,MAAMiB,SAAS,GAAG,2BAAiB;AAClCC,EAAAA,QAAQ,EAAEX,iBADwB;AAElCY,EAAAA,SAAS,EAAEX,gBAFuB;AAGlCY,EAAAA,WAAW,EAAEJ;AAHqB,CAAjB,CAAlB;;eAMe,2BAAiB;AAC/BZ,EAAAA,WAD+B;AAE/Ba,EAAAA,SAF+B;AAG/BX,EAAAA,oBAH+B;AAI/BP,EAAAA,aAJ+B;AAK/BW,EAAAA,UAL+B;AAM/BC,EAAAA,kBAN+B;AAO/BG,EAAAA,aAP+B;AAQ/BC,EAAAA;AAR+B,CAAjB,C","sourcesContent":["/**\n * External dependencies\n */\nimport { includes } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Reducer storing the list of all programmatically removed panels.\n *\n * @param {Array} state Current state.\n * @param {Object} action Action object.\n *\n * @return {Array} Updated state.\n */\nexport function removedPanels( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REMOVE_PANEL':\n\t\t\tif ( ! includes( state, action.panelName ) ) {\n\t\t\t\treturn [ ...state, action.panelName ];\n\t\t\t}\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer for storing the name of the open modal, or null if no modal is open.\n *\n * @param {Object} state Previous state.\n * @param {Object} action Action object containing the `name` of the modal\n *\n * @return {Object} Updated state\n */\nexport function activeModal( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_MODAL':\n\t\t\treturn action.name;\n\t\tcase 'CLOSE_MODAL':\n\t\t\treturn null;\n\t}\n\n\treturn state;\n}\n\nexport function publishSidebarActive( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_PUBLISH_SIDEBAR':\n\t\t\treturn true;\n\t\tcase 'CLOSE_PUBLISH_SIDEBAR':\n\t\t\treturn false;\n\t\tcase 'TOGGLE_PUBLISH_SIDEBAR':\n\t\t\treturn ! state;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the meta boxes isSaving state.\n * A \"true\" value means the meta boxes saving request is in-flight.\n *\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function isSavingMetaBoxes( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REQUEST_META_BOX_UPDATES':\n\t\t\treturn true;\n\t\tcase 'META_BOX_UPDATES_SUCCESS':\n\t\tcase 'META_BOX_UPDATES_FAILURE':\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n\n/**\n * Reducer keeping track of the meta boxes per location.\n *\n * @param {boolean} state Previous state.\n * @param {Object} action Action Object.\n *\n * @return {Object} Updated state.\n */\nexport function metaBoxLocations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_META_BOXES_PER_LOCATIONS':\n\t\t\treturn action.metaBoxesPerLocation;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning the editing canvas device type.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function deviceType( state = 'Desktop', action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_PREVIEW_DEVICE_TYPE':\n\t\t\treturn action.deviceType;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer tracking whether the inserter is open.\n *\n * @param {boolean} state\n * @param {Object} action\n */\nfunction isEditingTemplate( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_EDITING_TEMPLATE':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer tracking whether meta boxes are initialized.\n *\n * @param {boolean} state\n * @param {Object} action\n *\n * @return {boolean} Updated state.\n */\nfunction metaBoxesInitialized( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'META_BOXES_INITIALIZED':\n\t\t\treturn true;\n\t}\n\treturn state;\n}\n\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\n\tinitialized: metaBoxesInitialized,\n} );\n\nexport default combineReducers( {\n\tactiveModal,\n\tmetaBoxes,\n\tpublishSidebarActive,\n\tremovedPanels,\n\tdeviceType,\n\tblockInserterPanel,\n\tlistViewPanel,\n\tisEditingTemplate,\n} );\n"]}
@@ -8,16 +8,13 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.__experimentalGetInsertionPoint = __experimentalGetInsertionPoint;
9
9
  exports.__experimentalGetPreviewDeviceType = __experimentalGetPreviewDeviceType;
10
10
  exports.areMetaBoxesInitialized = areMetaBoxesInitialized;
11
- exports.getEditedPostTemplate = exports.getAllMetaBoxes = exports.getActiveMetaBoxLocations = exports.getActiveGeneralSidebarName = void 0;
12
- exports.getEditorMode = getEditorMode;
13
- exports.getHiddenBlockTypes = void 0;
11
+ exports.getHiddenBlockTypes = exports.getEditorMode = exports.getEditedPostTemplate = exports.getAllMetaBoxes = exports.getActiveMetaBoxLocations = exports.getActiveGeneralSidebarName = void 0;
14
12
  exports.getMetaBoxesPerLocation = getMetaBoxesPerLocation;
15
13
  exports.getPreference = getPreference;
16
14
  exports.getPreferences = void 0;
17
15
  exports.hasMetaBoxes = hasMetaBoxes;
18
16
  exports.isEditingTemplate = isEditingTemplate;
19
- exports.isEditorPanelEnabled = isEditorPanelEnabled;
20
- exports.isEditorPanelOpened = isEditorPanelOpened;
17
+ exports.isEditorPanelOpened = exports.isEditorPanelEnabled = void 0;
21
18
  exports.isEditorPanelRemoved = isEditorPanelRemoved;
22
19
  exports.isFeatureActive = exports.isEditorSidebarOpened = void 0;
23
20
  exports.isInserterOpened = isInserterOpened;
@@ -43,6 +40,8 @@ var _coreData = require("@wordpress/core-data");
43
40
 
44
41
  var _editor = require("@wordpress/editor");
45
42
 
43
+ var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
44
+
46
45
  /**
47
46
  * External dependencies
48
47
  */
@@ -51,6 +50,7 @@ var _editor = require("@wordpress/editor");
51
50
  * WordPress dependencies
52
51
  */
53
52
  const EMPTY_ARRAY = [];
53
+ const EMPTY_OBJECT = {};
54
54
  /**
55
55
  * Returns the current editing mode.
56
56
  *
@@ -59,9 +59,11 @@ const EMPTY_ARRAY = [];
59
59
  * @return {string} Editing mode.
60
60
  */
61
61
 
62
- function getEditorMode(state) {
63
- return getPreference(state, 'editorMode', 'visual');
64
- }
62
+ const getEditorMode = (0, _data.createRegistrySelector)(select => () => {
63
+ var _select$get;
64
+
65
+ return (_select$get = select(_preferences.store).get('core/edit-post', 'editorMode')) !== null && _select$get !== void 0 ? _select$get : 'visual';
66
+ });
65
67
  /**
66
68
  * Returns true if the editor sidebar is opened.
67
69
  *
@@ -70,7 +72,7 @@ function getEditorMode(state) {
70
72
  * @return {boolean} Whether the editor sidebar is opened.
71
73
  */
72
74
 
73
-
75
+ exports.getEditorMode = getEditorMode;
74
76
  const isEditorSidebarOpened = (0, _data.createRegistrySelector)(select => () => {
75
77
  const activeGeneralSidebar = select(_interface.store).getActiveComplementaryArea('core/edit-post');
76
78
  return (0, _lodash.includes)(['edit-post/document', 'edit-post/block'], activeGeneralSidebar);
@@ -106,11 +108,55 @@ const isPluginSidebarOpened = (0, _data.createRegistrySelector)(select => () =>
106
108
  exports.isPluginSidebarOpened = isPluginSidebarOpened;
107
109
  const getActiveGeneralSidebarName = (0, _data.createRegistrySelector)(select => () => {
108
110
  return select(_interface.store).getActiveComplementaryArea('core/edit-post');
109
- }); // The current list of preference keys that have been migrated to the
110
- // preferences package.
111
+ });
112
+ /**
113
+ * Converts panels from the new preferences store format to the old format
114
+ * that the post editor previously used.
115
+ *
116
+ * The resultant converted data should look like this:
117
+ * {
118
+ * panelName: {
119
+ * enabled: false,
120
+ * opened: true,
121
+ * },
122
+ * anotherPanelName: {
123
+ * opened: true
124
+ * },
125
+ * }
126
+ *
127
+ * @param {string[] | undefined} inactivePanels An array of inactive panel names.
128
+ * @param {string[] | undefined} openPanels An array of open panel names.
129
+ *
130
+ * @return {Object} The converted panel data.
131
+ */
111
132
 
112
133
  exports.getActiveGeneralSidebarName = getActiveGeneralSidebarName;
113
- const MIGRATED_KEYS = ['hiddenBlockTypes'];
134
+
135
+ function convertPanelsToOldFormat(inactivePanels, openPanels) {
136
+ var _ref;
137
+
138
+ // First reduce the inactive panels.
139
+ const panelsWithEnabledState = inactivePanels === null || inactivePanels === void 0 ? void 0 : inactivePanels.reduce((accumulatedPanels, panelName) => ({ ...accumulatedPanels,
140
+ [panelName]: {
141
+ enabled: false
142
+ }
143
+ }), {}); // Then reduce the open panels, passing in the result of the previous
144
+ // reduction as the initial value so that both open and inactive
145
+ // panel state is combined.
146
+
147
+ const panels = openPanels === null || openPanels === void 0 ? void 0 : openPanels.reduce((accumulatedPanels, panelName) => {
148
+ const currentPanelState = accumulatedPanels === null || accumulatedPanels === void 0 ? void 0 : accumulatedPanels[panelName];
149
+ return { ...accumulatedPanels,
150
+ [panelName]: { ...currentPanelState,
151
+ opened: true
152
+ }
153
+ };
154
+ }, panelsWithEnabledState !== null && panelsWithEnabledState !== void 0 ? panelsWithEnabledState : {}); // The panels variable will only be set if openPanels wasn't `undefined`.
155
+ // If it isn't set just return `panelsWithEnabledState`, and if that isn't
156
+ // set return an empty object.
157
+
158
+ return (_ref = panels !== null && panels !== void 0 ? panels : panelsWithEnabledState) !== null && _ref !== void 0 ? _ref : EMPTY_OBJECT;
159
+ }
114
160
  /**
115
161
  * Returns the preferences (these preferences are persisted locally).
116
162
  *
@@ -119,19 +165,30 @@ const MIGRATED_KEYS = ['hiddenBlockTypes'];
119
165
  * @return {Object} Preferences Object.
120
166
  */
121
167
 
122
- const getPreferences = (0, _data.createRegistrySelector)(select => state => {
123
- const editPostPreferences = state.preferences; // Some preferences now exist in the preferences store.
168
+
169
+ const getPreferences = (0, _data.createRegistrySelector)(select => () => {
170
+ (0, _deprecated.default)(`wp.data.select( 'core/edit-post' ).getPreferences`, {
171
+ since: '6.0',
172
+ alternative: `wp.data.select( 'core/preferences' ).get`
173
+ }); // These preferences now exist in the preferences store.
124
174
  // Fetch them so that they can be merged into the post
125
175
  // editor preferences.
126
176
 
127
- const preferenceStorePreferences = MIGRATED_KEYS.reduce((accumulatedPrefs, preferenceKey) => {
177
+ const preferences = ['hiddenBlockTypes', 'editorMode', 'preferredStyleVariations'].reduce((accumulatedPrefs, preferenceKey) => {
128
178
  const value = select(_preferences.store).get('core/edit-post', preferenceKey);
129
179
  return { ...accumulatedPrefs,
130
180
  [preferenceKey]: value
131
181
  };
132
- }, {});
133
- return { ...editPostPreferences,
134
- ...preferenceStorePreferences
182
+ }, {}); // Panels were a preference, but the data structure changed when the state
183
+ // was migrated to the preferences store. They need to be converted from
184
+ // the new preferences store format to old format to ensure no breaking
185
+ // changes for plugins.
186
+
187
+ const inactivePanels = select(_preferences.store).get('core/edit-post', 'inactivePanels');
188
+ const openPanels = select(_preferences.store).get('core/edit-post', 'openPanels');
189
+ const panels = convertPanelsToOldFormat(inactivePanels, openPanels);
190
+ return { ...preferences,
191
+ panels
135
192
  };
136
193
  });
137
194
  /**
@@ -146,9 +203,12 @@ const getPreferences = (0, _data.createRegistrySelector)(select => state => {
146
203
  exports.getPreferences = getPreferences;
147
204
 
148
205
  function getPreference(state, preferenceKey, defaultValue) {
149
- // Avoid using the `getPreferences` registry selector where possible.
150
- const isMigratedKey = MIGRATED_KEYS.includes(preferenceKey);
151
- const preferences = isMigratedKey ? getPreferences(state) : state.preferences;
206
+ (0, _deprecated.default)(`wp.data.select( 'core/edit-post' ).getPreference`, {
207
+ since: '6.0',
208
+ alternative: `wp.data.select( 'core/preferences' ).get`
209
+ }); // Avoid using the `getPreferences` registry selector where possible.
210
+
211
+ const preferences = getPreferences(state);
152
212
  const value = preferences[preferenceKey];
153
213
  return value === undefined ? defaultValue : value;
154
214
  }
@@ -160,9 +220,9 @@ function getPreference(state, preferenceKey, defaultValue) {
160
220
 
161
221
 
162
222
  const getHiddenBlockTypes = (0, _data.createRegistrySelector)(select => () => {
163
- var _select$get;
223
+ var _select$get2;
164
224
 
165
- return (_select$get = select(_preferences.store).get('core/edit-post', 'hiddenBlockTypes')) !== null && _select$get !== void 0 ? _select$get : EMPTY_ARRAY;
225
+ return (_select$get2 = select(_preferences.store).get('core/edit-post', 'hiddenBlockTypes')) !== null && _select$get2 !== void 0 ? _select$get2 : EMPTY_ARRAY;
166
226
  });
167
227
  /**
168
228
  * Returns true if the publish sidebar is opened.
@@ -202,10 +262,10 @@ function isEditorPanelRemoved(state, panelName) {
202
262
  */
203
263
 
204
264
 
205
- function isEditorPanelEnabled(state, panelName) {
206
- const panels = getPreference(state, 'panels');
207
- return !isEditorPanelRemoved(state, panelName) && (0, _lodash.get)(panels, [panelName, 'enabled'], true);
208
- }
265
+ const isEditorPanelEnabled = (0, _data.createRegistrySelector)(select => (state, panelName) => {
266
+ const inactivePanels = select(_preferences.store).get('core/edit-post', 'inactivePanels');
267
+ return !isEditorPanelRemoved(state, panelName) && !(inactivePanels !== null && inactivePanels !== void 0 && inactivePanels.includes(panelName));
268
+ });
209
269
  /**
210
270
  * Returns true if the given panel is open, or false otherwise. Panels are
211
271
  * closed by default.
@@ -216,11 +276,11 @@ function isEditorPanelEnabled(state, panelName) {
216
276
  * @return {boolean} Whether or not the panel is open.
217
277
  */
218
278
 
219
-
220
- function isEditorPanelOpened(state, panelName) {
221
- const panels = getPreference(state, 'panels');
222
- return (0, _lodash.get)(panels, [panelName]) === true || (0, _lodash.get)(panels, [panelName, 'opened']) === true;
223
- }
279
+ exports.isEditorPanelEnabled = isEditorPanelEnabled;
280
+ const isEditorPanelOpened = (0, _data.createRegistrySelector)(select => (state, panelName) => {
281
+ const openPanels = select(_preferences.store).get('core/edit-post', 'openPanels');
282
+ return !!(openPanels !== null && openPanels !== void 0 && openPanels.includes(panelName));
283
+ });
224
284
  /**
225
285
  * Returns true if a modal is active, or false otherwise.
226
286
  *
@@ -230,6 +290,7 @@ function isEditorPanelOpened(state, panelName) {
230
290
  * @return {boolean} Whether the modal is active.
231
291
  */
232
292
 
293
+ exports.isEditorPanelOpened = isEditorPanelOpened;
233
294
 
234
295
  function isModalActive(state, modalName) {
235
296
  return state.activeModal === modalName;
@@ -285,10 +346,10 @@ const getActiveMetaBoxLocations = (0, _rememo.default)(state => {
285
346
  exports.getActiveMetaBoxLocations = getActiveMetaBoxLocations;
286
347
 
287
348
  function isMetaBoxLocationVisible(state, location) {
288
- return isMetaBoxLocationActive(state, location) && (0, _lodash.some)(getMetaBoxesPerLocation(state, location), _ref => {
349
+ return isMetaBoxLocationActive(state, location) && (0, _lodash.some)(getMetaBoxesPerLocation(state, location), _ref2 => {
289
350
  let {
290
351
  id
291
- } = _ref;
352
+ } = _ref2;
292
353
  return isEditorPanelEnabled(state, `meta-box-${id}`);
293
354
  });
294
355
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/store/selectors.js"],"names":["EMPTY_ARRAY","getEditorMode","state","getPreference","isEditorSidebarOpened","select","activeGeneralSidebar","interfaceStore","getActiveComplementaryArea","isPluginSidebarOpened","getActiveGeneralSidebarName","MIGRATED_KEYS","getPreferences","editPostPreferences","preferences","preferenceStorePreferences","reduce","accumulatedPrefs","preferenceKey","value","preferencesStore","get","defaultValue","isMigratedKey","includes","undefined","getHiddenBlockTypes","isPublishSidebarOpened","publishSidebarActive","isEditorPanelRemoved","panelName","removedPanels","isEditorPanelEnabled","panels","isEditorPanelOpened","isModalActive","modalName","activeModal","isFeatureActive","feature","isPluginItemPinned","pluginName","isItemPinned","getActiveMetaBoxLocations","Object","keys","metaBoxes","locations","filter","location","isMetaBoxLocationActive","isMetaBoxLocationVisible","getMetaBoxesPerLocation","id","length","getAllMetaBoxes","hasMetaBoxes","isSavingMetaBoxes","isSaving","__experimentalGetPreviewDeviceType","deviceType","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isEditingTemplate","areMetaBoxesInitialized","initialized","getEditedPostTemplate","currentTemplate","editorStore","getEditedPostAttribute","templateWithSameSlug","coreStore","getEntityRecords","per_page","find","template","slug","getEditedEntityRecord","post","getCurrentPost","link","__experimentalGetTemplateForLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;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AK,CAACmE,iBAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,uBAAT,CAAkCpE,KAAlC,EAA0C;AAChD,SAAOA,KAAK,CAAC4C,SAAN,CAAgByB,WAAvB;AACA;AAED;AACA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,kCAClCnE,MAAF,IAAc,MAAM;AACnB,QAAMoE,eAAe,GAAGpE,MAAM,CAAEqE,aAAF,CAAN,CAAsBC,sBAAtB,CACvB,UADuB,CAAxB;;AAGA,MAAKF,eAAL,EAAuB;AAAA;;AACtB,UAAMG,oBAAoB,4BAAGvE,MAAM,CAAEwE,eAAF,CAAN,CAC3BC,gBAD2B,CACT,UADS,EACG,aADH,EACkB;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KADlB,CAAH,0DAAG,sBAE1BC,IAF0B,CAElBC,QAAF,IAAgBA,QAAQ,CAACC,IAAT,KAAkBT,eAFd,CAA7B;;AAGA,QAAK,CAAEG,oBAAP,EAA8B;AAC7B,aAAOA,oBAAP;AACA;;AACD,WAAOvE,MAAM,CAAEwE,eAAF,CAAN,CAAoBM,qBAApB,CACN,UADM,EAEN,aAFM,EAGNP,oBAAoB,CAACvB,EAHf,CAAP;AAKA;;AAED,QAAM+B,IAAI,GAAG/E,MAAM,CAAEqE,aAAF,CAAN,CAAsBW,cAAtB,EAAb;;AACA,MAAKD,IAAI,CAACE,IAAV,EAAiB;AAChB,WAAOjF,MAAM,CAAEwE,eAAF,CAAN,CAAoBU,gCAApB,CACNH,IAAI,CAACE,IADC,CAAP;AAGA;;AAED,SAAO,IAAP;AACA,CA3BmC,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\nimport { get, includes, some, flatten, values } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn getPreference( state, 'editorMode', 'visual' );\n}\n\n/**\n * Returns true if the editor sidebar is opened.\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the editor sidebar is opened.\n */\nexport const isEditorSidebarOpened = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst activeGeneralSidebar = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn includes(\n\t\t\t[ 'edit-post/document', 'edit-post/block' ],\n\t\t\tactiveGeneralSidebar\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the plugin sidebar is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the plugin sidebar is opened.\n */\nexport const isPluginSidebarOpened = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst activeGeneralSidebar = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn (\n\t\t\t!! activeGeneralSidebar &&\n\t\t\t! includes(\n\t\t\t\t[ 'edit-post/document', 'edit-post/block' ],\n\t\t\t\tactiveGeneralSidebar\n\t\t\t)\n\t\t);\n\t}\n);\n\n/**\n * Returns the current active general sidebar name, or null if there is no\n * general sidebar active. The active general sidebar is a unique name to\n * identify either an editor or plugin sidebar.\n *\n * Examples:\n *\n * - `edit-post/document`\n * - `my-plugin/insert-image-sidebar`\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} Active general sidebar name.\n */\nexport const getActiveGeneralSidebarName = createRegistrySelector(\n\t( select ) => () => {\n\t\treturn select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t'core/edit-post'\n\t\t);\n\t}\n);\n\n// The current list of preference keys that have been migrated to the\n// preferences package.\nconst MIGRATED_KEYS = [ 'hiddenBlockTypes' ];\n\n/**\n * Returns the preferences (these preferences are persisted locally).\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Preferences Object.\n */\nexport const getPreferences = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst editPostPreferences = state.preferences;\n\n\t\t// Some preferences now exist in the preferences store.\n\t\t// Fetch them so that they can be merged into the post\n\t\t// editor preferences.\n\t\tconst preferenceStorePreferences = MIGRATED_KEYS.reduce(\n\t\t\t( accumulatedPrefs, preferenceKey ) => {\n\t\t\t\tconst value = select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\tpreferenceKey\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulatedPrefs,\n\t\t\t\t\t[ preferenceKey ]: value,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\treturn {\n\t\t\t...editPostPreferences,\n\t\t\t...preferenceStorePreferences,\n\t\t};\n\t}\n);\n\n/**\n *\n * @param {Object} state Global application state.\n * @param {string} preferenceKey Preference Key.\n * @param {*} defaultValue Default Value.\n *\n * @return {*} Preference Value.\n */\nexport function getPreference( state, preferenceKey, defaultValue ) {\n\t// Avoid using the `getPreferences` registry selector where possible.\n\tconst isMigratedKey = MIGRATED_KEYS.includes( preferenceKey );\n\tconst preferences = isMigratedKey\n\t\t? getPreferences( state )\n\t\t: state.preferences;\n\tconst value = preferences[ preferenceKey ];\n\treturn value === undefined ? defaultValue : value;\n}\n\n/**\n * Returns an array of blocks that are hidden.\n *\n * @return {Array} A list of the hidden block types\n */\nexport const getHiddenBlockTypes = createRegistrySelector( ( select ) => () => {\n\treturn (\n\t\tselect( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\t'hiddenBlockTypes'\n\t\t) ?? EMPTY_ARRAY\n\t);\n} );\n\n/**\n * Returns true if the publish sidebar is opened.\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the publish sidebar is open.\n */\nexport function isPublishSidebarOpened( state ) {\n\treturn state.publishSidebarActive;\n}\n\n/**\n * Returns true if the given panel was programmatically removed, or false otherwise.\n * All panels are not removed by default.\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is removed.\n */\nexport function isEditorPanelRemoved( state, panelName ) {\n\treturn includes( state.removedPanels, panelName );\n}\n\n/**\n * Returns true if the given panel is enabled, or false otherwise. Panels are\n * enabled by default.\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is enabled.\n */\nexport function isEditorPanelEnabled( state, panelName ) {\n\tconst panels = getPreference( state, 'panels' );\n\n\treturn (\n\t\t! isEditorPanelRemoved( state, panelName ) &&\n\t\tget( panels, [ panelName, 'enabled' ], true )\n\t);\n}\n\n/**\n * Returns true if the given panel is open, or false otherwise. Panels are\n * closed by default.\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is open.\n */\nexport function isEditorPanelOpened( state, panelName ) {\n\tconst panels = getPreference( state, 'panels' );\n\treturn (\n\t\tget( panels, [ panelName ] ) === true ||\n\t\tget( panels, [ panelName, 'opened' ] ) === true\n\t);\n}\n\n/**\n * Returns true if a modal is active, or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} modalName A string that uniquely identifies the modal.\n *\n * @return {boolean} Whether the modal is active.\n */\nexport function isModalActive( state, modalName ) {\n\treturn state.activeModal === modalName;\n}\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state, feature ) => {\n\t\treturn !! select( preferencesStore ).get( 'core/edit-post', feature );\n\t}\n);\n\n/**\n * Returns true if the plugin item is pinned to the header.\n * When the value is not set it defaults to true.\n *\n * @param {Object} state Global application state.\n * @param {string} pluginName Plugin item name.\n *\n * @return {boolean} Whether the plugin item is pinned.\n */\nexport const isPluginItemPinned = createRegistrySelector(\n\t( select ) => ( state, pluginName ) => {\n\t\treturn select( interfaceStore ).isItemPinned(\n\t\t\t'core/edit-post',\n\t\t\tpluginName\n\t\t);\n\t}\n);\n\n/**\n * Returns an array of active meta box locations.\n *\n * @param {Object} state Post editor state.\n *\n * @return {string[]} Active meta box locations.\n */\nexport const getActiveMetaBoxLocations = createSelector(\n\t( state ) => {\n\t\treturn Object.keys( state.metaBoxes.locations ).filter( ( location ) =>\n\t\t\tisMetaBoxLocationActive( state, location )\n\t\t);\n\t},\n\t( state ) => [ state.metaBoxes.locations ]\n);\n\n/**\n * Returns true if a metabox location is active and visible\n *\n * @param {Object} state Post editor state.\n * @param {string} location Meta box location to test.\n *\n * @return {boolean} Whether the meta box location is active and visible.\n */\nexport function isMetaBoxLocationVisible( state, location ) {\n\treturn (\n\t\tisMetaBoxLocationActive( state, location ) &&\n\t\tsome( getMetaBoxesPerLocation( state, location ), ( { id } ) => {\n\t\t\treturn isEditorPanelEnabled( state, `meta-box-${ id }` );\n\t\t} )\n\t);\n}\n\n/**\n * Returns true if there is an active meta box in the given location, or false\n * otherwise.\n *\n * @param {Object} state Post editor state.\n * @param {string} location Meta box location to test.\n *\n * @return {boolean} Whether the meta box location is active.\n */\nexport function isMetaBoxLocationActive( state, location ) {\n\tconst metaBoxes = getMetaBoxesPerLocation( state, location );\n\treturn !! metaBoxes && metaBoxes.length !== 0;\n}\n\n/**\n * Returns the list of all the available meta boxes for a given location.\n *\n * @param {Object} state Global application state.\n * @param {string} location Meta box location to test.\n *\n * @return {?Array} List of meta boxes.\n */\nexport function getMetaBoxesPerLocation( state, location ) {\n\treturn state.metaBoxes.locations[ location ];\n}\n\n/**\n * Returns the list of all the available meta boxes.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} List of meta boxes.\n */\nexport const getAllMetaBoxes = createSelector(\n\t( state ) => {\n\t\treturn flatten( values( state.metaBoxes.locations ) );\n\t},\n\t( state ) => [ state.metaBoxes.locations ]\n);\n\n/**\n * Returns true if the post is using Meta Boxes\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether there are metaboxes or not.\n */\nexport function hasMetaBoxes( state ) {\n\treturn getActiveMetaBoxLocations( state ).length > 0;\n}\n\n/**\n * Returns true if the Meta Boxes are being saved.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the metaboxes are being saved.\n */\nexport function isSavingMetaBoxes( state ) {\n\treturn state.metaBoxes.isSaving;\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns true if the template editing mode is enabled.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether we're editing the template.\n */\nexport function isEditingTemplate( state ) {\n\treturn state.isEditingTemplate;\n}\n\n/**\n * Returns true if meta boxes are initialized.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether meta boxes are initialized.\n */\nexport function areMetaBoxesInitialized( state ) {\n\treturn state.metaBoxes.initialized;\n}\n\n/**\n * Retrieves the template of the currently edited post.\n *\n * @return {Object?} Post Template.\n */\nexport const getEditedPostTemplate = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst currentTemplate = select( editorStore ).getEditedPostAttribute(\n\t\t\t'template'\n\t\t);\n\t\tif ( currentTemplate ) {\n\t\t\tconst templateWithSameSlug = select( coreStore )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )\n\t\t\t\t?.find( ( template ) => template.slug === currentTemplate );\n\t\t\tif ( ! templateWithSameSlug ) {\n\t\t\t\treturn templateWithSameSlug;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateWithSameSlug.id\n\t\t\t);\n\t\t}\n\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tif ( post.link ) {\n\t\t\treturn select( coreStore ).__experimentalGetTemplateForLink(\n\t\t\t\tpost.link\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/store/selectors.js"],"names":["EMPTY_ARRAY","EMPTY_OBJECT","getEditorMode","select","preferencesStore","get","isEditorSidebarOpened","activeGeneralSidebar","interfaceStore","getActiveComplementaryArea","isPluginSidebarOpened","getActiveGeneralSidebarName","convertPanelsToOldFormat","inactivePanels","openPanels","panelsWithEnabledState","reduce","accumulatedPanels","panelName","enabled","panels","currentPanelState","opened","getPreferences","since","alternative","preferences","accumulatedPrefs","preferenceKey","value","getPreference","state","defaultValue","undefined","getHiddenBlockTypes","isPublishSidebarOpened","publishSidebarActive","isEditorPanelRemoved","removedPanels","isEditorPanelEnabled","includes","isEditorPanelOpened","isModalActive","modalName","activeModal","isFeatureActive","feature","isPluginItemPinned","pluginName","isItemPinned","getActiveMetaBoxLocations","Object","keys","metaBoxes","locations","filter","location","isMetaBoxLocationActive","isMetaBoxLocationVisible","getMetaBoxesPerLocation","id","length","getAllMetaBoxes","hasMetaBoxes","isSavingMetaBoxes","isSaving","__experimentalGetPreviewDeviceType","deviceType","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isEditingTemplate","areMetaBoxesInitialized","initialized","getEditedPostTemplate","currentTemplate","editorStore","getEditedPostAttribute","templateWithSameSlug","coreStore","getEntityRecords","per_page","find","template","slug","getEditedEntityRecord","post","getCurrentPost","link","__experimentalGetTemplateForLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,EAApB;AACA,MAAMC,YAAY,GAAG,EAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,aAAa,GAAG,kCAA0BC,MAAF,IAAc;AAAA;;AAAA,wBAClEA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,GAA3B,CAAgC,gBAAhC,EAAkD,YAAlD,CADkE,qDACE,QADF;AAAA,CAAtC,CAAtB;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,kCAClCH,MAAF,IAAc,MAAM;AACnB,QAAMI,oBAAoB,GAAGJ,MAAM,CAClCK,gBADkC,CAAN,CAE3BC,0BAF2B,CAEC,gBAFD,CAA7B;AAGA,SAAO,sBACN,CAAE,oBAAF,EAAwB,iBAAxB,CADM,EAENF,oBAFM,CAAP;AAIA,CATmC,CAA9B;AAYP;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,qBAAqB,GAAG,kCAClCP,MAAF,IAAc,MAAM;AACnB,QAAMI,oBAAoB,GAAGJ,MAAM,CAClCK,gBADkC,CAAN,CAE3BC,0BAF2B,CAEC,gBAFD,CAA7B;AAGA,SACC,CAAC,CAAEF,oBAAH,IACA,CAAE,sBACD,CAAE,oBAAF,EAAwB,iBAAxB,CADC,EAEDA,oBAFC,CAFH;AAOA,CAZmC,CAA9B;AAeP;AACA;AACA;AACA;AACA;AACA;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A;;AACD,WAAOhF,MAAM,CAAEiF,eAAF,CAAN,CAAoBM,qBAApB,CACN,UADM,EAEN,aAFM,EAGNP,oBAAoB,CAACvB,EAHf,CAAP;AAKA;;AAED,QAAM+B,IAAI,GAAGxF,MAAM,CAAE8E,aAAF,CAAN,CAAsBW,cAAtB,EAAb;;AACA,MAAKD,IAAI,CAACE,IAAV,EAAiB;AAChB,WAAO1F,MAAM,CAAEiF,eAAF,CAAN,CAAoBU,gCAApB,CACNH,IAAI,CAACE,IADC,CAAP;AAGA;;AAED,SAAO,IAAP;AACA,CA3BmC,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\nimport { includes, some, flatten, values } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport deprecated from '@wordpress/deprecated';\n\nconst EMPTY_ARRAY = [];\nconst EMPTY_OBJECT = {};\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport const getEditorMode = createRegistrySelector( ( select ) => () =>\n\tselect( preferencesStore ).get( 'core/edit-post', 'editorMode' ) ?? 'visual'\n);\n\n/**\n * Returns true if the editor sidebar is opened.\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the editor sidebar is opened.\n */\nexport const isEditorSidebarOpened = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst activeGeneralSidebar = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn includes(\n\t\t\t[ 'edit-post/document', 'edit-post/block' ],\n\t\t\tactiveGeneralSidebar\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the plugin sidebar is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the plugin sidebar is opened.\n */\nexport const isPluginSidebarOpened = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst activeGeneralSidebar = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn (\n\t\t\t!! activeGeneralSidebar &&\n\t\t\t! includes(\n\t\t\t\t[ 'edit-post/document', 'edit-post/block' ],\n\t\t\t\tactiveGeneralSidebar\n\t\t\t)\n\t\t);\n\t}\n);\n\n/**\n * Returns the current active general sidebar name, or null if there is no\n * general sidebar active. The active general sidebar is a unique name to\n * identify either an editor or plugin sidebar.\n *\n * Examples:\n *\n * - `edit-post/document`\n * - `my-plugin/insert-image-sidebar`\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} Active general sidebar name.\n */\nexport const getActiveGeneralSidebarName = createRegistrySelector(\n\t( select ) => () => {\n\t\treturn select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t'core/edit-post'\n\t\t);\n\t}\n);\n\n/**\n * Converts panels from the new preferences store format to the old format\n * that the post editor previously used.\n *\n * The resultant converted data should look like this:\n * {\n * panelName: {\n * enabled: false,\n * opened: true,\n * },\n * anotherPanelName: {\n * opened: true\n * },\n * }\n *\n * @param {string[] | undefined} inactivePanels An array of inactive panel names.\n * @param {string[] | undefined} openPanels An array of open panel names.\n *\n * @return {Object} The converted panel data.\n */\nfunction convertPanelsToOldFormat( inactivePanels, openPanels ) {\n\t// First reduce the inactive panels.\n\tconst panelsWithEnabledState = inactivePanels?.reduce(\n\t\t( accumulatedPanels, panelName ) => ( {\n\t\t\t...accumulatedPanels,\n\t\t\t[ panelName ]: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t} ),\n\t\t{}\n\t);\n\n\t// Then reduce the open panels, passing in the result of the previous\n\t// reduction as the initial value so that both open and inactive\n\t// panel state is combined.\n\tconst panels = openPanels?.reduce( ( accumulatedPanels, panelName ) => {\n\t\tconst currentPanelState = accumulatedPanels?.[ panelName ];\n\t\treturn {\n\t\t\t...accumulatedPanels,\n\t\t\t[ panelName ]: {\n\t\t\t\t...currentPanelState,\n\t\t\t\topened: true,\n\t\t\t},\n\t\t};\n\t}, panelsWithEnabledState ?? {} );\n\n\t// The panels variable will only be set if openPanels wasn't `undefined`.\n\t// If it isn't set just return `panelsWithEnabledState`, and if that isn't\n\t// set return an empty object.\n\treturn panels ?? panelsWithEnabledState ?? EMPTY_OBJECT;\n}\n\n/**\n * Returns the preferences (these preferences are persisted locally).\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Preferences Object.\n */\nexport const getPreferences = createRegistrySelector( ( select ) => () => {\n\tdeprecated( `wp.data.select( 'core/edit-post' ).getPreferences`, {\n\t\tsince: '6.0',\n\t\talternative: `wp.data.select( 'core/preferences' ).get`,\n\t} );\n\n\t// These preferences now exist in the preferences store.\n\t// Fetch them so that they can be merged into the post\n\t// editor preferences.\n\tconst preferences = [\n\t\t'hiddenBlockTypes',\n\t\t'editorMode',\n\t\t'preferredStyleVariations',\n\t].reduce( ( accumulatedPrefs, preferenceKey ) => {\n\t\tconst value = select( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\tpreferenceKey\n\t\t);\n\n\t\treturn {\n\t\t\t...accumulatedPrefs,\n\t\t\t[ preferenceKey ]: value,\n\t\t};\n\t}, {} );\n\n\t// Panels were a preference, but the data structure changed when the state\n\t// was migrated to the preferences store. They need to be converted from\n\t// the new preferences store format to old format to ensure no breaking\n\t// changes for plugins.\n\tconst inactivePanels = select( preferencesStore ).get(\n\t\t'core/edit-post',\n\t\t'inactivePanels'\n\t);\n\tconst openPanels = select( preferencesStore ).get(\n\t\t'core/edit-post',\n\t\t'openPanels'\n\t);\n\tconst panels = convertPanelsToOldFormat( inactivePanels, openPanels );\n\n\treturn {\n\t\t...preferences,\n\t\tpanels,\n\t};\n} );\n\n/**\n *\n * @param {Object} state Global application state.\n * @param {string} preferenceKey Preference Key.\n * @param {*} defaultValue Default Value.\n *\n * @return {*} Preference Value.\n */\nexport function getPreference( state, preferenceKey, defaultValue ) {\n\tdeprecated( `wp.data.select( 'core/edit-post' ).getPreference`, {\n\t\tsince: '6.0',\n\t\talternative: `wp.data.select( 'core/preferences' ).get`,\n\t} );\n\n\t// Avoid using the `getPreferences` registry selector where possible.\n\tconst preferences = getPreferences( state );\n\tconst value = preferences[ preferenceKey ];\n\treturn value === undefined ? defaultValue : value;\n}\n\n/**\n * Returns an array of blocks that are hidden.\n *\n * @return {Array} A list of the hidden block types\n */\nexport const getHiddenBlockTypes = createRegistrySelector( ( select ) => () => {\n\treturn (\n\t\tselect( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\t'hiddenBlockTypes'\n\t\t) ?? EMPTY_ARRAY\n\t);\n} );\n\n/**\n * Returns true if the publish sidebar is opened.\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the publish sidebar is open.\n */\nexport function isPublishSidebarOpened( state ) {\n\treturn state.publishSidebarActive;\n}\n\n/**\n * Returns true if the given panel was programmatically removed, or false otherwise.\n * All panels are not removed by default.\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is removed.\n */\nexport function isEditorPanelRemoved( state, panelName ) {\n\treturn includes( state.removedPanels, panelName );\n}\n\n/**\n * Returns true if the given panel is enabled, or false otherwise. Panels are\n * enabled by default.\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is enabled.\n */\nexport const isEditorPanelEnabled = createRegistrySelector(\n\t( select ) => ( state, panelName ) => {\n\t\tconst inactivePanels = select( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\t'inactivePanels'\n\t\t);\n\t\treturn (\n\t\t\t! isEditorPanelRemoved( state, panelName ) &&\n\t\t\t! inactivePanels?.includes( panelName )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the given panel is open, or false otherwise. Panels are\n * closed by default.\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is open.\n */\nexport const isEditorPanelOpened = createRegistrySelector(\n\t( select ) => ( state, panelName ) => {\n\t\tconst openPanels = select( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\t'openPanels'\n\t\t);\n\t\treturn !! openPanels?.includes( panelName );\n\t}\n);\n\n/**\n * Returns true if a modal is active, or false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} modalName A string that uniquely identifies the modal.\n *\n * @return {boolean} Whether the modal is active.\n */\nexport function isModalActive( state, modalName ) {\n\treturn state.activeModal === modalName;\n}\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state, feature ) => {\n\t\treturn !! select( preferencesStore ).get( 'core/edit-post', feature );\n\t}\n);\n\n/**\n * Returns true if the plugin item is pinned to the header.\n * When the value is not set it defaults to true.\n *\n * @param {Object} state Global application state.\n * @param {string} pluginName Plugin item name.\n *\n * @return {boolean} Whether the plugin item is pinned.\n */\nexport const isPluginItemPinned = createRegistrySelector(\n\t( select ) => ( state, pluginName ) => {\n\t\treturn select( interfaceStore ).isItemPinned(\n\t\t\t'core/edit-post',\n\t\t\tpluginName\n\t\t);\n\t}\n);\n\n/**\n * Returns an array of active meta box locations.\n *\n * @param {Object} state Post editor state.\n *\n * @return {string[]} Active meta box locations.\n */\nexport const getActiveMetaBoxLocations = createSelector(\n\t( state ) => {\n\t\treturn Object.keys( state.metaBoxes.locations ).filter( ( location ) =>\n\t\t\tisMetaBoxLocationActive( state, location )\n\t\t);\n\t},\n\t( state ) => [ state.metaBoxes.locations ]\n);\n\n/**\n * Returns true if a metabox location is active and visible\n *\n * @param {Object} state Post editor state.\n * @param {string} location Meta box location to test.\n *\n * @return {boolean} Whether the meta box location is active and visible.\n */\nexport function isMetaBoxLocationVisible( state, location ) {\n\treturn (\n\t\tisMetaBoxLocationActive( state, location ) &&\n\t\tsome( getMetaBoxesPerLocation( state, location ), ( { id } ) => {\n\t\t\treturn isEditorPanelEnabled( state, `meta-box-${ id }` );\n\t\t} )\n\t);\n}\n\n/**\n * Returns true if there is an active meta box in the given location, or false\n * otherwise.\n *\n * @param {Object} state Post editor state.\n * @param {string} location Meta box location to test.\n *\n * @return {boolean} Whether the meta box location is active.\n */\nexport function isMetaBoxLocationActive( state, location ) {\n\tconst metaBoxes = getMetaBoxesPerLocation( state, location );\n\treturn !! metaBoxes && metaBoxes.length !== 0;\n}\n\n/**\n * Returns the list of all the available meta boxes for a given location.\n *\n * @param {Object} state Global application state.\n * @param {string} location Meta box location to test.\n *\n * @return {?Array} List of meta boxes.\n */\nexport function getMetaBoxesPerLocation( state, location ) {\n\treturn state.metaBoxes.locations[ location ];\n}\n\n/**\n * Returns the list of all the available meta boxes.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} List of meta boxes.\n */\nexport const getAllMetaBoxes = createSelector(\n\t( state ) => {\n\t\treturn flatten( values( state.metaBoxes.locations ) );\n\t},\n\t( state ) => [ state.metaBoxes.locations ]\n);\n\n/**\n * Returns true if the post is using Meta Boxes\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether there are metaboxes or not.\n */\nexport function hasMetaBoxes( state ) {\n\treturn getActiveMetaBoxLocations( state ).length > 0;\n}\n\n/**\n * Returns true if the Meta Boxes are being saved.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the metaboxes are being saved.\n */\nexport function isSavingMetaBoxes( state ) {\n\treturn state.metaBoxes.isSaving;\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns true if the template editing mode is enabled.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether we're editing the template.\n */\nexport function isEditingTemplate( state ) {\n\treturn state.isEditingTemplate;\n}\n\n/**\n * Returns true if meta boxes are initialized.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether meta boxes are initialized.\n */\nexport function areMetaBoxesInitialized( state ) {\n\treturn state.metaBoxes.initialized;\n}\n\n/**\n * Retrieves the template of the currently edited post.\n *\n * @return {Object?} Post Template.\n */\nexport const getEditedPostTemplate = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst currentTemplate = select( editorStore ).getEditedPostAttribute(\n\t\t\t'template'\n\t\t);\n\t\tif ( currentTemplate ) {\n\t\t\tconst templateWithSameSlug = select( coreStore )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )\n\t\t\t\t?.find( ( template ) => template.slug === currentTemplate );\n\t\t\tif ( ! templateWithSameSlug ) {\n\t\t\t\treturn templateWithSameSlug;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateWithSameSlug.id\n\t\t\t);\n\t\t}\n\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tif ( post.link ) {\n\t\t\treturn select( coreStore ).__experimentalGetTemplateForLink(\n\t\t\t\tpost.link\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { ActionItem } from '@wordpress/interface';
5
5
  import { compose } from '@wordpress/compose';
6
+ import { MenuItem } from '@wordpress/components';
6
7
  import { withPluginContext } from '@wordpress/plugins';
7
8
  /**
8
9
  * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
@@ -62,7 +63,10 @@ import { withPluginContext } from '@wordpress/plugins';
62
63
  */
63
64
 
64
65
  export default compose(withPluginContext((context, ownProps) => {
66
+ var _ownProps$as;
67
+
65
68
  return {
69
+ as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : MenuItem,
66
70
  icon: ownProps.icon || context.icon,
67
71
  name: 'core/edit-post/plugin-more-menu'
68
72
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/plugin-more-menu-item/index.js"],"names":["ActionItem","compose","withPluginContext","context","ownProps","icon","name"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,sBAA3B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeD,OAAO,CACrBC,iBAAiB,CAAE,CAAEC,OAAF,EAAWC,QAAX,KAAyB;AAC3C,SAAO;AACNC,IAAAA,IAAI,EAAED,QAAQ,CAACC,IAAT,IAAiBF,OAAO,CAACE,IADzB;AAENC,IAAAA,IAAI,EAAE;AAFA,GAAP;AAIA,CALgB,CADI,CAAP,CAOZN,UAPY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ActionItem } from '@wordpress/interface';\nimport { compose } from '@wordpress/compose';\nimport { withPluginContext } from '@wordpress/plugins';\n\n/**\n * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.\n * The text within the component appears as the menu item label.\n *\n * @param {Object} props Component properties.\n * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.\n * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.\n * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.\n * @param {...*} [props.other] Any additional props are passed through to the underlying [MenuItem](https://github.com/WordPress/gutenberg/tree/HEAD/packages/components/src/menu-item/README.md) component.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;\n * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * function MyButtonMoreMenuItem() {\n * \treturn wp.element.createElement(\n * \t\tPluginMoreMenuItem,\n * \t\t{\n * \t\t\ticon: moreIcon,\n * \t\t\tonClick: onButtonClick,\n * \t\t},\n * \t\t__( 'My button title' )\n * \t);\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PluginMoreMenuItem } from '@wordpress/edit-post';\n * import { more } from '@wordpress/icons';\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * const MyButtonMoreMenuItem = () => (\n * \t<PluginMoreMenuItem\n * \t\ticon={ more }\n * \t\tonClick={ onButtonClick }\n * \t>\n * \t\t{ __( 'My button title' ) }\n * \t</PluginMoreMenuItem>\n * );\n * ```\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default compose(\n\twithPluginContext( ( context, ownProps ) => {\n\t\treturn {\n\t\t\ticon: ownProps.icon || context.icon,\n\t\t\tname: 'core/edit-post/plugin-more-menu',\n\t\t};\n\t} )\n)( ActionItem );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/header/plugin-more-menu-item/index.js"],"names":["ActionItem","compose","MenuItem","withPluginContext","context","ownProps","as","icon","name"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,sBAA3B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,iBAAT,QAAkC,oBAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAeF,OAAO,CACrBE,iBAAiB,CAAE,CAAEC,OAAF,EAAWC,QAAX,KAAyB;AAAA;;AAC3C,SAAO;AACNC,IAAAA,EAAE,kBAAED,QAAQ,CAACC,EAAX,uDAAiBJ,QADb;AAENK,IAAAA,IAAI,EAAEF,QAAQ,CAACE,IAAT,IAAiBH,OAAO,CAACG,IAFzB;AAGNC,IAAAA,IAAI,EAAE;AAHA,GAAP;AAKA,CANgB,CADI,CAAP,CAQZR,UARY,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ActionItem } from '@wordpress/interface';\nimport { compose } from '@wordpress/compose';\nimport { MenuItem } from '@wordpress/components';\nimport { withPluginContext } from '@wordpress/plugins';\n\n/**\n * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.\n * The text within the component appears as the menu item label.\n *\n * @param {Object} props Component properties.\n * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.\n * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.\n * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.\n * @param {...*} [props.other] Any additional props are passed through to the underlying [MenuItem](https://github.com/WordPress/gutenberg/tree/HEAD/packages/components/src/menu-item/README.md) component.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;\n * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * function MyButtonMoreMenuItem() {\n * \treturn wp.element.createElement(\n * \t\tPluginMoreMenuItem,\n * \t\t{\n * \t\t\ticon: moreIcon,\n * \t\t\tonClick: onButtonClick,\n * \t\t},\n * \t\t__( 'My button title' )\n * \t);\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PluginMoreMenuItem } from '@wordpress/edit-post';\n * import { more } from '@wordpress/icons';\n *\n * function onButtonClick() {\n * \talert( 'Button clicked.' );\n * }\n *\n * const MyButtonMoreMenuItem = () => (\n * \t<PluginMoreMenuItem\n * \t\ticon={ more }\n * \t\tonClick={ onButtonClick }\n * \t>\n * \t\t{ __( 'My button title' ) }\n * \t</PluginMoreMenuItem>\n * );\n * ```\n *\n * @return {WPComponent} The component to be rendered.\n */\nexport default compose(\n\twithPluginContext( ( context, ownProps ) => {\n\t\treturn {\n\t\t\tas: ownProps.as ?? MenuItem,\n\t\t\ticon: ownProps.icon || context.icon,\n\t\t\tname: 'core/edit-post/plugin-more-menu',\n\t\t};\n\t} )\n)( ActionItem );\n"]}
@@ -77,7 +77,9 @@ export default function DeleteTemplate() {
77
77
  updateEditorSettings({ ...settings,
78
78
  availableTemplates: newAvailableTemplates
79
79
  });
80
- deleteEntityRecord('postType', 'wp_template', template.id);
80
+ deleteEntityRecord('postType', 'wp_template', template.id, {
81
+ throwOnError: true
82
+ });
81
83
  };
82
84
 
83
85
  return createElement(MenuGroup, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/header/template-title/delete-template.js"],"names":["pickBy","__","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","onDelete","settings","newAvailableTemplates","availableTemplates","_title","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,QAAvB;AAEA;AACA;AACA;;AACA,SAASC,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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,IAAAA,oBAAoB,CAAE,EACrB,GAAGe,QADkB;AAErBE,MAAAA,kBAAkB,EAAED;AAFC,KAAF,CAApB;AAIAd,IAAAA,kBAAkB,CAAE,UAAF,EAAc,aAAd,EAA6BC,QAAQ,CAACgB,EAAtC,CAAlB;AACA,GApBD;;AAsBA,SACC,cAAC,SAAD;AAAW,IAAA,SAAS,EAAC;AAArB,KACC,8BACC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,aAAa,MAFd;AAGC,IAAA,OAAO,EAAC,WAHT;AAIC,kBAAarC,EAAE,CAAE,iBAAF,CAJhB;AAKC,IAAA,OAAO,EAAG,MAAM;AACf2B,MAAAA,oBAAoB,CAAE,IAAF,CAApB;AACA;AAPF,KASG3B,EAAE,CAAE,iBAAF,CATL,CADD,EAYC,cAAC,aAAD;AACC,IAAA,MAAM,EAAG0B,iBADV;AAEC,IAAA,SAAS,EAAGM,QAFb;AAGC,IAAA,QAAQ,EAAG,MAAM;AAChBL,MAAAA,oBAAoB,CAAE,KAAF,CAApB;AACA;AALF,KAOG1B,OAAO;AACR;AACAD,EAAAA,EAAE,CACD,0FADC,CAFM,EAKR6B,aALQ,CAPV,CAZD,CADD,CADD;AAgCA","sourcesContent":["/**\n * External dependencies\n */\nimport { pickBy } from 'lodash';\n\n/**\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 } = select(\n\t\t\teditPostStore\n\t\t);\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 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 = pickBy(\n\t\t\tsettings.availableTemplates,\n\t\t\t( _title, id ) => {\n\t\t\t\treturn 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};\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\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\taria-label={ __( 'Delete template' ) }\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>\n\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":["pickBy","__","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","onDelete","settings","newAvailableTemplates","availableTemplates","_title","id","throwOnError"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,QAAvB;AAEA;AACA;AACA;;AACA,SAASC,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,S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AAF,CAAR;AAGA,UAAMY,QAAQ,GAAGhB,iBAAiB,EAAlC;AACA,UAAMiB,qBAAqB,GAAGnC,MAAM,CACnCkC,QAAQ,CAACE,kBAD0B,EAEnC,CAAEC,MAAF,EAAUC,EAAV,KAAkB;AACjB,aAAOA,EAAE,KAAKhB,QAAQ,CAACS,IAAvB;AACA,KAJkC,CAApC;AAMAZ,IAAAA,oBAAoB,CAAE,EACrB,GAAGe,QADkB;AAErBE,MAAAA,kBAAkB,EAAED;AAFC,KAAF,CAApB;AAIAd,IAAAA,kBAAkB,CAAE,UAAF,EAAc,aAAd,EAA6BC,QAAQ,CAACgB,EAAtC,EAA0C;AAC3DC,MAAAA,YAAY,EAAE;AAD6C,KAA1C,CAAlB;AAGA,GAtBD;;AAwBA,SACC,cAAC,SAAD;AAAW,IAAA,SAAS,EAAC;AAArB,KACC,8BACC,cAAC,QAAD;AACC,IAAA,SAAS,EAAC,qDADX;AAEC,IAAA,aAAa,MAFd;AAGC,IAAA,OAAO,EAAC,WAHT;AAIC,kBAAatC,EAAE,CAAE,iBAAF,CAJhB;AAKC,IAAA,OAAO,EAAG,MAAM;AACf2B,MAAAA,oBAAoB,CAAE,IAAF,CAApB;AACA;AAPF,KASG3B,EAAE,CAAE,iBAAF,CATL,CADD,EAYC,cAAC,aAAD;AACC,IAAA,MAAM,EAAG0B,iBADV;AAEC,IAAA,SAAS,EAAGM,QAFb;AAGC,IAAA,QAAQ,EAAG,MAAM;AAChBL,MAAAA,oBAAoB,CAAE,KAAF,CAApB;AACA;AALF,KAOG1B,OAAO;AACR;AACAD,EAAAA,EAAE,CACD,0FADC,CAFM,EAKR6B,aALQ,CAPV,CAZD,CADD,CADD;AAgCA","sourcesContent":["/**\n * External dependencies\n */\nimport { pickBy } from 'lodash';\n\n/**\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 } = select(\n\t\t\teditPostStore\n\t\t);\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 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 = pickBy(\n\t\t\tsettings.availableTemplates,\n\t\t\t( _title, id ) => {\n\t\t\t\treturn 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\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\taria-label={ __( 'Delete template' ) }\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>\n\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"]}
@@ -91,7 +91,7 @@ function PostLink(_ref) {
91
91
  }
92
92
  }
93
93
  }), createElement("p", null, __('The last part of the URL.'), ' ', createElement(ExternalLink, {
94
- href: __('https://wordpress.org/support/article/writing-posts/#post-field-descriptions')
94
+ href: __('https://wordpress.org/support/article/settings-sidebar/#permalink')
95
95
  }, __('Read about permalinks')))), createElement("h3", {
96
96
  className: "edit-post-post-link__preview-label"
97
97
  }, postTypeLabel || __('View post')), createElement("div", {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-link/index.js"],"names":["get","__","PanelBody","TextControl","ExternalLink","withSelect","withDispatch","compose","ifCondition","store","editorStore","safeDecodeURIComponent","cleanForSlug","coreStore","useState","editPostStore","PANEL_NAME","PostLink","isOpened","onTogglePanel","isEditable","postLink","permalinkPrefix","permalinkSuffix","editPermalink","postSlug","postTypeLabel","forceEmptyField","setForceEmptyField","prefixElement","postNameElement","suffixElement","newValue","event","target","value","select","isPermalinkEditable","getCurrentPost","isCurrentPostPublished","getPermalinkParts","getEditedPostAttribute","getEditedPostSlug","isEditorPanelEnabled","isEditorPanelOpened","getPostType","link","postTypeName","postType","permalinkParts","isPublished","isEnabled","isViewable","hasPermalinkParts","prefix","suffix","dispatch","toggleEditorPanelOpened","editPost","newSlug","slug"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,sBAAT,EAAiCC,YAAjC,QAAqD,gBAArD;AACA,SAASH,KAAK,IAAII,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASL,KAAK,IAAIM,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG,WAAnB;;AAEA,SAASC,QAAT,OAUI;AAAA,MAVe;AAClBC,IAAAA,QADkB;AAElBC,IAAAA,aAFkB;AAGlBC,IAAAA,UAHkB;AAIlBC,IAAAA,QAJkB;AAKlBC,IAAAA,eALkB;AAMlBC,IAAAA,eANkB;AAOlBC,IAAAA,aAPkB;AAQlBC,IAAAA,QARkB;AASlBC,IAAAA;AATkB,GAUf;AACH,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0Cd,QAAQ,CAAE,KAAF,CAAxD;AAEA,MAAIe,aAAJ,EAAmBC,eAAnB,EAAoCC,aAApC;;AACA,MAAKX,UAAL,EAAkB;AACjBS,IAAAA,aAAa,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**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\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\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-link';\n\nfunction PostLink( {\n\tisOpened,\n\tonTogglePanel,\n\tisEditable,\n\tpostLink,\n\tpermalinkPrefix,\n\tpermalinkSuffix,\n\teditPermalink,\n\tpostSlug,\n\tpostTypeLabel,\n} ) {\n\tconst [ forceEmptyField, setForceEmptyField ] = useState( false );\n\n\tlet prefixElement, postNameElement, suffixElement;\n\tif ( isEditable ) {\n\t\tprefixElement = permalinkPrefix && (\n\t\t\t<span className=\"edit-post-post-link__link-prefix\">\n\t\t\t\t{ permalinkPrefix }\n\t\t\t</span>\n\t\t);\n\t\tpostNameElement = postSlug && (\n\t\t\t<span className=\"edit-post-post-link__link-post-name\">\n\t\t\t\t{ postSlug }\n\t\t\t</span>\n\t\t);\n\t\tsuffixElement = permalinkSuffix && (\n\t\t\t<span className=\"edit-post-post-link__link-suffix\">\n\t\t\t\t{ permalinkSuffix }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ __( 'Permalink' ) }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ onTogglePanel }\n\t\t>\n\t\t\t{ isEditable && (\n\t\t\t\t<div className=\"editor-post-link\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'URL Slug' ) }\n\t\t\t\t\t\tvalue={ forceEmptyField ? '' : postSlug }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\teditPermalink( newValue );\n\t\t\t\t\t\t\t// When we delete the field the permalink gets\n\t\t\t\t\t\t\t// reverted to the original value.\n\t\t\t\t\t\t\t// The forceEmptyField logic allows the user to have\n\t\t\t\t\t\t\t// the field temporarily empty while typing.\n\t\t\t\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t\t\t\tif ( ! forceEmptyField ) {\n\t\t\t\t\t\t\t\t\tsetForceEmptyField( true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\tsetForceEmptyField( false );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonBlur={ ( event ) => {\n\t\t\t\t\t\t\teditPermalink( cleanForSlug( event.target.value ) );\n\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\tsetForceEmptyField( false );\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\t<p>\n\t\t\t\t\t\t{ __( 'The last part of the URL.' ) }{ ' ' }\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/writing-posts/#post-field-descriptions'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Read about permalinks' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<h3 className=\"edit-post-post-link__preview-label\">\n\t\t\t\t{ postTypeLabel || __( 'View post' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"edit-post-post-link__preview-link-container\">\n\t\t\t\t<ExternalLink\n\t\t\t\t\tclassName=\"edit-post-post-link__link\"\n\t\t\t\t\thref={ postLink }\n\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t>\n\t\t\t\t\t{ isEditable ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ prefixElement }\n\t\t\t\t\t\t\t{ postNameElement }\n\t\t\t\t\t\t\t{ suffixElement }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tpostLink\n\t\t\t\t\t) }\n\t\t\t\t</ExternalLink>\n\t\t\t</div>\n\t\t</PanelBody>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPermalinkEditable,\n\t\t\tgetCurrentPost,\n\t\t\tisCurrentPostPublished,\n\t\t\tgetPermalinkParts,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostSlug,\n\t\t} = select( editorStore );\n\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } = select(\n\t\t\teditPostStore\n\t\t);\n\t\tconst { getPostType } = select( coreStore );\n\n\t\tconst { link } = getCurrentPost();\n\n\t\tconst postTypeName = getEditedPostAttribute( 'type' );\n\t\tconst postType = getPostType( postTypeName );\n\t\tconst permalinkParts = getPermalinkParts();\n\n\t\treturn {\n\t\t\tpostLink: link,\n\t\t\tisEditable: isPermalinkEditable(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisViewable: get( postType, [ 'viewable' ], false ),\n\t\t\tpostSlug: safeDecodeURIComponent( getEditedPostSlug() ),\n\t\t\tpostTypeLabel: get( postType, [ 'labels', 'view_item' ] ),\n\t\t\thasPermalinkParts: !! permalinkParts,\n\t\t\tpermalinkPrefix: permalinkParts?.prefix,\n\t\t\tpermalinkSuffix: permalinkParts?.suffix,\n\t\t};\n\t} ),\n\tifCondition( ( { isEnabled, postLink, isViewable, hasPermalinkParts } ) => {\n\t\treturn isEnabled && postLink && isViewable && hasPermalinkParts;\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { toggleEditorPanelOpened } = dispatch( editPostStore );\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonTogglePanel: () => toggleEditorPanelOpened( PANEL_NAME ),\n\t\t\teditPermalink: ( newSlug ) => {\n\t\t\t\teditPost( { slug: newSlug } );\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostLink );\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-link/index.js"],"names":["get","__","PanelBody","TextControl","ExternalLink","withSelect","withDispatch","compose","ifCondition","store","editorStore","safeDecodeURIComponent","cleanForSlug","coreStore","useState","editPostStore","PANEL_NAME","PostLink","isOpened","onTogglePanel","isEditable","postLink","permalinkPrefix","permalinkSuffix","editPermalink","postSlug","postTypeLabel","forceEmptyField","setForceEmptyField","prefixElement","postNameElement","suffixElement","newValue","event","target","value","select","isPermalinkEditable","getCurrentPost","isCurrentPostPublished","getPermalinkParts","getEditedPostAttribute","getEditedPostSlug","isEditorPanelEnabled","isEditorPanelOpened","getPostType","link","postTypeName","postType","permalinkParts","isPublished","isEnabled","isViewable","hasPermalinkParts","prefix","suffix","dispatch","toggleEditorPanelOpened","editPost","newSlug","slug"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,YAAjC,QAAqD,uBAArD;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,sBAAT,EAAiCC,YAAjC,QAAqD,gBAArD;AACA,SAASH,KAAK,IAAII,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SAASL,KAAK,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U,CAnCY,EAsCvB/C,YAAY,CAAIkD,QAAF,IAAgB;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAA8BD,QAAQ,CAAEzC,aAAF,CAA5C;AACA,QAAM;AAAE2C,IAAAA;AAAF,MAAeF,QAAQ,CAAE9C,WAAF,CAA7B;AACA,SAAO;AACNS,IAAAA,aAAa,EAAE,MAAMsC,uBAAuB,CAAEzC,UAAF,CADtC;AAENQ,IAAAA,aAAa,EAAImC,OAAF,IAAe;AAC7BD,MAAAA,QAAQ,CAAE;AAAEE,QAAAA,IAAI,EAAED;AAAR,OAAF,CAAR;AACA;AAJK,GAAP;AAMA,CATW,CAtCW,CAAF,CAAP,CAgDV1C,QAhDU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\nimport { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';\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\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-link';\n\nfunction PostLink( {\n\tisOpened,\n\tonTogglePanel,\n\tisEditable,\n\tpostLink,\n\tpermalinkPrefix,\n\tpermalinkSuffix,\n\teditPermalink,\n\tpostSlug,\n\tpostTypeLabel,\n} ) {\n\tconst [ forceEmptyField, setForceEmptyField ] = useState( false );\n\n\tlet prefixElement, postNameElement, suffixElement;\n\tif ( isEditable ) {\n\t\tprefixElement = permalinkPrefix && (\n\t\t\t<span className=\"edit-post-post-link__link-prefix\">\n\t\t\t\t{ permalinkPrefix }\n\t\t\t</span>\n\t\t);\n\t\tpostNameElement = postSlug && (\n\t\t\t<span className=\"edit-post-post-link__link-post-name\">\n\t\t\t\t{ postSlug }\n\t\t\t</span>\n\t\t);\n\t\tsuffixElement = permalinkSuffix && (\n\t\t\t<span className=\"edit-post-post-link__link-suffix\">\n\t\t\t\t{ permalinkSuffix }\n\t\t\t</span>\n\t\t);\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ __( 'Permalink' ) }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ onTogglePanel }\n\t\t>\n\t\t\t{ isEditable && (\n\t\t\t\t<div className=\"editor-post-link\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'URL Slug' ) }\n\t\t\t\t\t\tvalue={ forceEmptyField ? '' : postSlug }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\teditPermalink( newValue );\n\t\t\t\t\t\t\t// When we delete the field the permalink gets\n\t\t\t\t\t\t\t// reverted to the original value.\n\t\t\t\t\t\t\t// The forceEmptyField logic allows the user to have\n\t\t\t\t\t\t\t// the field temporarily empty while typing.\n\t\t\t\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t\t\t\tif ( ! forceEmptyField ) {\n\t\t\t\t\t\t\t\t\tsetForceEmptyField( true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\tsetForceEmptyField( false );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonBlur={ ( event ) => {\n\t\t\t\t\t\t\teditPermalink( cleanForSlug( event.target.value ) );\n\t\t\t\t\t\t\tif ( forceEmptyField ) {\n\t\t\t\t\t\t\t\tsetForceEmptyField( false );\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\t<p>\n\t\t\t\t\t\t{ __( 'The last part of the URL.' ) }{ ' ' }\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/settings-sidebar/#permalink'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Read about permalinks' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<h3 className=\"edit-post-post-link__preview-label\">\n\t\t\t\t{ postTypeLabel || __( 'View post' ) }\n\t\t\t</h3>\n\t\t\t<div className=\"edit-post-post-link__preview-link-container\">\n\t\t\t\t<ExternalLink\n\t\t\t\t\tclassName=\"edit-post-post-link__link\"\n\t\t\t\t\thref={ postLink }\n\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t>\n\t\t\t\t\t{ isEditable ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ prefixElement }\n\t\t\t\t\t\t\t{ postNameElement }\n\t\t\t\t\t\t\t{ suffixElement }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\tpostLink\n\t\t\t\t\t) }\n\t\t\t\t</ExternalLink>\n\t\t\t</div>\n\t\t</PanelBody>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPermalinkEditable,\n\t\t\tgetCurrentPost,\n\t\t\tisCurrentPostPublished,\n\t\t\tgetPermalinkParts,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostSlug,\n\t\t} = select( editorStore );\n\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } = select(\n\t\t\teditPostStore\n\t\t);\n\t\tconst { getPostType } = select( coreStore );\n\n\t\tconst { link } = getCurrentPost();\n\n\t\tconst postTypeName = getEditedPostAttribute( 'type' );\n\t\tconst postType = getPostType( postTypeName );\n\t\tconst permalinkParts = getPermalinkParts();\n\n\t\treturn {\n\t\t\tpostLink: link,\n\t\t\tisEditable: isPermalinkEditable(),\n\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisViewable: get( postType, [ 'viewable' ], false ),\n\t\t\tpostSlug: safeDecodeURIComponent( getEditedPostSlug() ),\n\t\t\tpostTypeLabel: get( postType, [ 'labels', 'view_item' ] ),\n\t\t\thasPermalinkParts: !! permalinkParts,\n\t\t\tpermalinkPrefix: permalinkParts?.prefix,\n\t\t\tpermalinkSuffix: permalinkParts?.suffix,\n\t\t};\n\t} ),\n\tifCondition( ( { isEnabled, postLink, isViewable, hasPermalinkParts } ) => {\n\t\treturn isEnabled && postLink && isViewable && hasPermalinkParts;\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { toggleEditorPanelOpened } = dispatch( editPostStore );\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonTogglePanel: () => toggleEditorPanelOpened( PANEL_NAME ),\n\t\t\teditPermalink: ( newSlug ) => {\n\t\t\t\teditPost( { slug: newSlug } );\n\t\t\t},\n\t\t};\n\t} ),\n] )( PostLink );\n"]}
@@ -119,8 +119,7 @@ export default function VisualEditor(_ref2) {
119
119
  setIsEditingTemplate
120
120
  } = useDispatch(editPostStore);
121
121
  const desktopCanvasStyles = {
122
- // We intentionally omit a 100% height here. The container is a flex item, so the 100% height is granted by default.
123
- // If a percentage height is present, older browsers such as Safari 13 apply that, but do so incorrectly as the inheritance is buggy.
122
+ height: '100%',
124
123
  width: '100%',
125
124
  margin: 0,
126
125
  display: 'flex',
@@ -201,7 +200,8 @@ export default function VisualEditor(_ref2) {
201
200
  selector: ".edit-post-visual-editor__post-title-wrapper, .block-editor-block-list__layout.is-root-container",
202
201
  layout: defaultLayout
203
202
  }), !isTemplateMode && createElement("div", {
204
- className: "edit-post-visual-editor__post-title-wrapper"
203
+ className: "edit-post-visual-editor__post-title-wrapper",
204
+ contentEditable: false
205
205
  }, createElement(PostTitle, null)), createElement(RecursionProvider, null, createElement(BlockList, {
206
206
  className: isTemplateMode ? 'wp-site-blocks' : undefined,
207
207
  __experimentalLayout: layout