@wordpress/edit-post 6.2.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.
- package/CHANGELOG.md +2 -0
- package/build/components/sidebar/post-link/index.js +1 -1
- package/build/components/sidebar/post-link/index.js.map +1 -1
- package/build/components/visual-editor/index.js +3 -3
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +3 -2
- package/build/editor.js.map +1 -1
- package/build/index.js +3 -0
- package/build/index.js.map +1 -1
- package/build/index.native.js +3 -0
- package/build/index.native.js.map +1 -1
- package/build/store/actions.js +76 -49
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +7 -10
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +0 -80
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +86 -25
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/sidebar/post-link/index.js +1 -1
- package/build-module/components/sidebar/post-link/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +3 -3
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +2 -2
- package/build-module/editor.js.map +1 -1
- package/build-module/index.js +3 -0
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +3 -0
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/actions.js +71 -45
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +7 -10
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +1 -77
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +82 -23
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +0 -3
- package/build-style/style.css +0 -3
- package/package.json +27 -26
- package/src/components/sidebar/post-link/index.js +1 -1
- package/src/components/visual-editor/index.js +5 -3
- package/src/editor.js +3 -2
- package/src/index.js +3 -0
- package/src/index.native.js +3 -0
- package/src/store/actions.js +47 -15
- package/src/store/index.js +7 -11
- package/src/store/reducer.js +1 -74
- package/src/store/selectors.js +121 -51
- package/src/store/test/actions.js +30 -33
- package/src/store/test/reducer.js +0 -126
- package/src/store/test/selectors.js +0 -155
- package/src/style.scss +0 -4
- package/build/store/defaults.js +0 -15
- package/build/store/defaults.js.map +0 -1
- package/build-module/store/defaults.js +0 -8
- package/build-module/store/defaults.js.map +0 -1
- package/src/store/defaults.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/actions.js"],"names":["openGeneralSidebar","name","registry","dispatch","interfaceStore","enableComplementaryArea","editPostStore","closeGeneralSidebar","disableComplementaryArea","openModal","type","closeModal","openPublishSidebar","closePublishSidebar","togglePublishSidebar","toggleEditorPanelEnabled","panelName","toggleEditorPanelOpened","removeEditorPanel","toggleFeature","feature","preferencesStore","toggle","switchEditorMode","mode","set","blockEditorStore","clearSelectedBlock","message","togglePinnedPluginItem","pluginName","isPinned","select","isItemPinned","updatePreferredStyleVariations","blockName","blockStyle","existingVariations","get","updatedVariations","showBlockTypes","blockNames","existingBlockNames","newBlockNames","hideBlockTypes","mergedBlockNames","Set","setAvailableMetaBoxesPerLocation","metaBoxesPerLocation","requestMetaBoxUpdates","window","tinyMCE","triggerSave","post","editorStore","getCurrentPost","additionalData","comment_status","ping_status","sticky","author","filter","Boolean","baseFormData","FormData","document","querySelector","activeMetaBoxLocations","getActiveMetaBoxLocations","formDataToMerge","map","location","formData","memo","currentFormData","key","value","append","forEach","url","_wpMetaBoxUrl","method","body","parse","metaBoxUpdatesSuccess","metaBoxUpdatesFailure","__experimentalSetPreviewDeviceType","deviceType","setIsInserterOpened","setIsListViewOpened","isOpen","setIsEditingTemplate","__unstableSwitchToTemplateMode","newTemplate","isWelcomeGuideActive","isFeatureActive","noticesStore","createSuccessNotice","__unstableCreateTemplate","template","savedTemplate","coreStore","saveEntityRecord","editEntityRecord","id","slug","metaBoxesInitialized","initializeMetaBoxes","isEditorReady","__unstableIsEditorReady","postType","getCurrentPostType","postboxes","page","add_postbox_toggles","wasSavingPost","isSavingPost","wasAutosavingPost","isAutosavingPost","hasMetaBoxes","subscribe","shouldTriggerMetaboxesSave"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAKC,IAAF,IAAY;AAAA,MAAE;AAAEC,IAAAA;AAAF,GAAF;AAAA,SAC7CA,QAAQ,CACNC,QADF,CACYC,gBADZ,EAEEC,uBAFF,CAE2BC,QAAcL,IAFzC,EAE+CA,IAF/C,CAD6C;AAAA,CAAvC;AAKP;AACA;AACA;;;;;AACO,MAAMM,mBAAmB,GAAG,MAAM;AAAA,MAAE;AAAEL,IAAAA;AAAF,GAAF;AAAA,SACxCA,QAAQ,CACNC,QADF,CACYC,gBADZ,EAEEI,wBAFF,CAE4BF,QAAcL,IAF1C,CADwC;AAAA,CAAlC;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASQ,SAAT,CAAoBR,IAApB,EAA2B;AACjC,SAAO;AACNS,IAAAA,IAAI,EAAE,YADA;AAENT,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASU,UAAT,GAAsB;AAC5B,SAAO;AACND,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,kBAAT,GAA8B;AACpC,SAAO;AACNF,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,mBAAT,GAA+B;AACrC,SAAO;AACNH,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASI,oBAAT,GAAgC;AACtC,SAAO;AACNJ,IAAAA,IAAI,EAAE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/B8B,MADuB,CACfsB,aADe,EAEvBgE,gBAFuB,EAAzB,CAF+B,CAM/B;AACA;AACA;AACA;AACA;AACA;;AACA,UAAMG,0BAA0B,GAC/BF,YAAY,IACZJ,aADA,IAEA,CAAEC,YAFF,IAGA,CAAEC,iBAJH,CAZ+B,CAkB/B;;AACAF,IAAAA,aAAa,GAAGC,YAAhB;AACAC,IAAAA,iBAAiB,GAAGC,gBAApB;;AAEA,QAAKG,0BAAL,EAAkC;AACjC,YAAMtH,QAAQ,CAAC8C,qBAAT,EAAN;AACA;AACD,GAzBD;AA2BA9C,EAAAA,QAAQ,CAAE;AACTO,IAAAA,IAAI,EAAE;AADG,GAAF,CAAR;AAGA,CAtDM","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, reduce, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { getMetaBoxContainer } from '../utils/meta-boxes';\nimport { store as editPostStore } from '.';\n\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar = ( name ) => ( { registry } ) =>\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.enableComplementaryArea( editPostStore.name, name );\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) =>\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editPostStore.name );\n\n/**\n * Returns an action object used in signalling that the user opened a modal.\n *\n * @param {string} name A string that uniquely identifies the modal.\n *\n * @return {Object} Action object.\n */\nexport function openModal( name ) {\n\treturn {\n\t\ttype: 'OPEN_MODAL',\n\t\tname,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed a modal.\n *\n * @return {Object} Action object.\n */\nexport function closeModal() {\n\treturn {\n\t\ttype: 'CLOSE_MODAL',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user opened the publish\n * sidebar.\n *\n * @return {Object} Action object\n */\nexport function openPublishSidebar() {\n\treturn {\n\t\ttype: 'OPEN_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user closed the\n * publish sidebar.\n *\n * @return {Object} Action object.\n */\nexport function closePublishSidebar() {\n\treturn {\n\t\ttype: 'CLOSE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user toggles the publish sidebar.\n *\n * @return {Object} Action object\n */\nexport function togglePublishSidebar() {\n\treturn {\n\t\ttype: 'TOGGLE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used to enable or disable a panel in the editor.\n *\n * @param {string} panelName A string that identifies the panel to enable or disable.\n *\n * @return {Object} Action object.\n */\nexport function toggleEditorPanelEnabled( panelName ) {\n\treturn {\n\t\ttype: 'TOGGLE_PANEL_ENABLED',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Returns an action object used to open or close a panel in the editor.\n *\n * @param {string} panelName A string that identifies the panel to open or close.\n *\n * @return {Object} Action object.\n */\nexport function toggleEditorPanelOpened( panelName ) {\n\treturn {\n\t\ttype: 'TOGGLE_PANEL_OPENED',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Returns an action object used to remove a panel from the editor.\n *\n * @param {string} panelName A string that identifies the panel to remove.\n *\n * @return {Object} Action object.\n */\nexport function removeEditorPanel( panelName ) {\n\treturn {\n\t\ttype: 'REMOVE_PANEL',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Triggers an action used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n */\nexport const toggleFeature = ( feature ) => ( { registry } ) =>\n\tregistry.dispatch( preferencesStore ).toggle( 'core/edit-post', feature );\n\n/**\n * Triggers an action used to switch editor mode.\n *\n * @param {string} mode The editor mode.\n */\nexport const switchEditorMode = ( mode ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'editorMode', mode );\n\n\t// Unselect blocks when we switch to the code editor.\n\tif ( mode !== 'visual' ) {\n\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t}\n\n\tconst message =\n\t\tmode === 'visual'\n\t\t\t? __( 'Visual editor selected' )\n\t\t\t: __( 'Code editor selected' );\n\tspeak( message, 'assertive' );\n};\n\n/**\n * Triggers an action object used to toggle a plugin name flag.\n *\n * @param {string} pluginName Plugin name.\n */\nexport const togglePinnedPluginItem = ( pluginName ) => ( { registry } ) => {\n\tconst isPinned = registry\n\t\t.select( interfaceStore )\n\t\t.isItemPinned( 'core/edit-post', pluginName );\n\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t[ isPinned ? 'unpinItem' : 'pinItem' ]( 'core/edit-post', pluginName );\n};\n\n/**\n * Returns an action object used in signaling that a style should be auto-applied when a block is created.\n *\n * @param {string} blockName Name of the block.\n * @param {?string} blockStyle Name of the style that should be auto applied. If undefined, the \"auto apply\" setting of the block is removed.\n */\nexport const updatePreferredStyleVariations = ( blockName, blockStyle ) => ( {\n\tregistry,\n} ) => {\n\tif ( ! blockName ) {\n\t\treturn;\n\t}\n\n\tconst existingVariations =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'preferredStyleVariations' ) ?? {};\n\n\t// When the blockStyle is omitted, remove the block's preferred variation.\n\tif ( ! blockStyle ) {\n\t\tconst updatedVariations = {\n\t\t\t...existingVariations,\n\t\t};\n\n\t\tdelete updatedVariations[ blockName ];\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'preferredStyleVariations',\n\t\t\t\tupdatedVariations\n\t\t\t);\n\t} else {\n\t\t// Else add the variation.\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core/edit-post', 'preferredStyleVariations', {\n\t\t\t\t...existingVariations,\n\t\t\t\t[ blockName ]: blockStyle,\n\t\t\t} );\n\t}\n};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes = ( blockNames ) => ( { registry } ) => {\n\tconst existingBlockNames =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];\n\n\tconst newBlockNames = without(\n\t\texistingBlockNames,\n\t\t...castArray( blockNames )\n\t);\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'hiddenBlockTypes', newBlockNames );\n};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes = ( blockNames ) => ( { registry } ) => {\n\tconst existingBlockNames =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];\n\n\tconst mergedBlockNames = new Set( [\n\t\t...existingBlockNames,\n\t\t...castArray( blockNames ),\n\t] );\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n};\n\n/**\n * Returns an action object used in signaling\n * what Meta boxes are available in which location.\n *\n * @param {Object} metaBoxesPerLocation Meta boxes per location.\n */\nexport const setAvailableMetaBoxesPerLocation = ( metaBoxesPerLocation ) => ( {\n\tdispatch,\n} ) =>\n\tdispatch( {\n\t\ttype: 'SET_META_BOXES_PER_LOCATIONS',\n\t\tmetaBoxesPerLocation,\n\t} );\n\n/**\n * Update a metabox.\n */\nexport const requestMetaBoxUpdates = () => async ( {\n\tregistry,\n\tselect,\n\tdispatch,\n} ) => {\n\tdispatch( {\n\t\ttype: 'REQUEST_META_BOX_UPDATES',\n\t} );\n\n\t// Saves the wp_editor fields.\n\tif ( window.tinyMCE ) {\n\t\twindow.tinyMCE.triggerSave();\n\t}\n\n\t// Additional data needed for backward compatibility.\n\t// If we do not provide this data, the post will be overridden with the default values.\n\tconst post = registry.select( editorStore ).getCurrentPost();\n\tconst additionalData = [\n\t\tpost.comment_status ? [ 'comment_status', post.comment_status ] : false,\n\t\tpost.ping_status ? [ 'ping_status', post.ping_status ] : false,\n\t\tpost.sticky ? [ 'sticky', post.sticky ] : false,\n\t\tpost.author ? [ 'post_author', post.author ] : false,\n\t].filter( Boolean );\n\n\t// We gather all the metaboxes locations data and the base form data.\n\tconst baseFormData = new window.FormData(\n\t\tdocument.querySelector( '.metabox-base-form' )\n\t);\n\tconst activeMetaBoxLocations = select.getActiveMetaBoxLocations();\n\tconst formDataToMerge = [\n\t\tbaseFormData,\n\t\t...activeMetaBoxLocations.map(\n\t\t\t( location ) =>\n\t\t\t\tnew window.FormData( getMetaBoxContainer( location ) )\n\t\t),\n\t];\n\n\t// Merge all form data objects into a single one.\n\tconst formData = reduce(\n\t\tformDataToMerge,\n\t\t( memo, currentFormData ) => {\n\t\t\tfor ( const [ key, value ] of currentFormData ) {\n\t\t\t\tmemo.append( key, value );\n\t\t\t}\n\t\t\treturn memo;\n\t\t},\n\t\tnew window.FormData()\n\t);\n\tadditionalData.forEach( ( [ key, value ] ) =>\n\t\tformData.append( key, value )\n\t);\n\n\ttry {\n\t\t// Save the metaboxes.\n\t\tawait apiFetch( {\n\t\t\turl: window._wpMetaBoxUrl,\n\t\t\tmethod: 'POST',\n\t\t\tbody: formData,\n\t\t\tparse: false,\n\t\t} );\n\t\tdispatch.metaBoxUpdatesSuccess();\n\t} catch {\n\t\tdispatch.metaBoxUpdatesFailure();\n\t}\n};\n\n/**\n * Returns an action object used to signal a successful meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesSuccess() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_SUCCESS',\n\t};\n}\n\n/**\n * Returns an action object used to signal a failed meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesFailure() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_FAILURE',\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to switch to template editing.\n *\n * @param {boolean} value Is editing template.\n * @return {Object} Action object.\n */\nexport function setIsEditingTemplate( value ) {\n\treturn {\n\t\ttype: 'SET_IS_EDITING_TEMPLATE',\n\t\tvalue,\n\t};\n}\n\n/**\n * Switches to the template mode.\n *\n * @param {boolean} newTemplate Is new template.\n */\nexport const __unstableSwitchToTemplateMode = ( newTemplate = false ) => ( {\n\tregistry,\n\tselect,\n\tdispatch,\n} ) => {\n\tdispatch( setIsEditingTemplate( true ) );\n\tconst isWelcomeGuideActive = select.isFeatureActive(\n\t\t'welcomeGuideTemplate'\n\t);\n\tif ( ! isWelcomeGuideActive ) {\n\t\tconst message = newTemplate\n\t\t\t? __( \"Custom template created. You're in template mode now.\" )\n\t\t\t: __(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t );\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice( message, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n};\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport const __unstableCreateTemplate = ( template ) => async ( {\n\tregistry,\n} ) => {\n\tconst savedTemplate = await registry\n\t\t.dispatch( coreStore )\n\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\tconst post = registry.select( editorStore ).getCurrentPost();\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.editEntityRecord( 'postType', post.type, post.id, {\n\t\t\ttemplate: savedTemplate.slug,\n\t\t} );\n};\n\nlet metaBoxesInitialized = false;\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n */\nexport const initializeMetaBoxes = () => ( { registry, select, dispatch } ) => {\n\tconst isEditorReady = registry\n\t\t.select( editorStore )\n\t\t.__unstableIsEditorReady();\n\n\tif ( ! isEditorReady ) {\n\t\treturn;\n\t}\n\t// Only initialize once.\n\tif ( metaBoxesInitialized ) {\n\t\treturn;\n\t}\n\tconst postType = registry.select( editorStore ).getCurrentPostType();\n\tif ( window.postboxes.page !== postType ) {\n\t\twindow.postboxes.add_postbox_toggles( postType );\n\t}\n\n\tmetaBoxesInitialized = true;\n\n\tlet wasSavingPost = registry.select( editorStore ).isSavingPost();\n\tlet wasAutosavingPost = registry.select( editorStore ).isAutosavingPost();\n\tconst hasMetaBoxes = select.hasMetaBoxes();\n\n\t// Save metaboxes when performing a full save on the post.\n\tregistry.subscribe( async () => {\n\t\tconst isSavingPost = registry.select( editorStore ).isSavingPost();\n\t\tconst isAutosavingPost = registry\n\t\t\t.select( editorStore )\n\t\t\t.isAutosavingPost();\n\n\t\t// Save metaboxes on save completion, except for autosaves that are not a post preview.\n\t\t//\n\t\t// Meta boxes are initialized once at page load. It is not necessary to\n\t\t// account for updates on each state change.\n\t\t//\n\t\t// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309.\n\t\tconst shouldTriggerMetaboxesSave =\n\t\t\thasMetaBoxes &&\n\t\t\twasSavingPost &&\n\t\t\t! isSavingPost &&\n\t\t\t! wasAutosavingPost;\n\n\t\t// Save current state for next inspection.\n\t\twasSavingPost = isSavingPost;\n\t\twasAutosavingPost = isAutosavingPost;\n\n\t\tif ( shouldTriggerMetaboxesSave ) {\n\t\t\tawait dispatch.requestMetaBoxUpdates();\n\t\t}\n\t} );\n\n\tdispatch( {\n\t\ttype: 'META_BOXES_INITIALIZED',\n\t} );\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/store/actions.js"],"names":["openGeneralSidebar","name","registry","dispatch","interfaceStore","enableComplementaryArea","editPostStore","closeGeneralSidebar","disableComplementaryArea","openModal","type","closeModal","openPublishSidebar","closePublishSidebar","togglePublishSidebar","toggleEditorPanelEnabled","panelName","inactivePanels","select","preferencesStore","get","isPanelInactive","includes","updatedInactivePanels","filter","invactivePanelName","set","toggleEditorPanelOpened","openPanels","isPanelOpen","updatedOpenPanels","openPanelName","removeEditorPanel","toggleFeature","feature","toggle","switchEditorMode","mode","blockEditorStore","clearSelectedBlock","message","togglePinnedPluginItem","pluginName","isPinned","isItemPinned","updatePreferredStyleVariations","blockName","blockStyle","existingVariations","updatedVariations","showBlockTypes","blockNames","existingBlockNames","newBlockNames","hideBlockTypes","mergedBlockNames","Set","setAvailableMetaBoxesPerLocation","metaBoxesPerLocation","requestMetaBoxUpdates","window","tinyMCE","triggerSave","post","editorStore","getCurrentPost","additionalData","comment_status","ping_status","sticky","author","Boolean","baseFormData","FormData","document","querySelector","activeMetaBoxLocations","getActiveMetaBoxLocations","formDataToMerge","map","location","formData","memo","currentFormData","key","value","append","forEach","url","_wpMetaBoxUrl","method","body","parse","metaBoxUpdatesSuccess","metaBoxUpdatesFailure","__experimentalSetPreviewDeviceType","deviceType","setIsInserterOpened","setIsListViewOpened","isOpen","setIsEditingTemplate","__unstableSwitchToTemplateMode","newTemplate","isWelcomeGuideActive","isFeatureActive","noticesStore","createSuccessNotice","__unstableCreateTemplate","template","savedTemplate","coreStore","saveEntityRecord","editEntityRecord","id","slug","metaBoxesInitialized","initializeMetaBoxes","isEditorReady","__unstableIsEditorReady","postType","getCurrentPostType","postboxes","page","add_postbox_toggles","wasSavingPost","isSavingPost","wasAutosavingPost","isAutosavingPost","hasMetaBoxes","subscribe","shouldTriggerMetaboxesSave"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,kBAAkB,GAAKC,IAAF,IAAY;AAAA,MAAE;AAAEC,IAAAA;AAAF,GAAF;AAAA,SAC7CA,QAAQ,CACNC,QADF,CACYC,gBADZ,EAEEC,uBAFF,CAE2BC,QAAcL,IAFzC,EAE+CA,IAF/C,CAD6C;AAAA,CAAvC;AAKP;AACA;AACA;;;;;AACO,MAAMM,mBAAmB,GAAG,MAAM;AAAA,MAAE;AAAEL,IAAAA;AAAF,GAAF;AAAA,SACxCA,QAAQ,CACNC,QADF,CACYC,gBADZ,EAEEI,wBAFF,CAE4BF,QAAcL,IAF1C,CADwC;AAAA,CAAlC;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASQ,SAAT,CAAoBR,IAApB,EAA2B;AACjC,SAAO;AACNS,IAAAA,IAAI,EAAE,YADA;AAENT,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASU,UAAT,GAAsB;AAC5B,SAAO;AACND,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA;AAED;A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gBAA/B,EAAxB;AACA,QAAMC,YAAY,GAAG9G,MAAM,CAAC8G,YAAP,EAArB,CArB8E,CAuB9E;;AACA9H,EAAAA,QAAQ,CAAC+H,SAAT,CAAoB,YAAY;AAC/B,UAAMJ,YAAY,GAAG3H,QAAQ,CAACgB,MAAT,CAAiB8C,aAAjB,EAA+B6D,YAA/B,EAArB;AACA,UAAME,gBAAgB,GAAG7H,QAAQ,CAC/BgB,MADuB,CACf8C,aADe,EAEvB+D,gBAFuB,EAAzB,CAF+B,CAM/B;AACA;AACA;AACA;AACA;AACA;;AACA,UAAMG,0BAA0B,GAC/BF,YAAY,IACZJ,aADA,IAEA,CAAEC,YAFF,IAGA,CAAEC,iBAJH,CAZ+B,CAkB/B;;AACAF,IAAAA,aAAa,GAAGC,YAAhB;AACAC,IAAAA,iBAAiB,GAAGC,gBAApB;;AAEA,QAAKG,0BAAL,EAAkC;AACjC,YAAM/H,QAAQ,CAACwD,qBAAT,EAAN;AACA;AACD,GAzBD;AA2BAxD,EAAAA,QAAQ,CAAE;AACTO,IAAAA,IAAI,EAAE;AADG,GAAF,CAAR;AAGA,CAtDM","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, reduce, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { speak } from '@wordpress/a11y';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { getMetaBoxContainer } from '../utils/meta-boxes';\nimport { store as editPostStore } from '.';\n\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n */\nexport const openGeneralSidebar = ( name ) => ( { registry } ) =>\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.enableComplementaryArea( editPostStore.name, name );\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) =>\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editPostStore.name );\n\n/**\n * Returns an action object used in signalling that the user opened a modal.\n *\n * @param {string} name A string that uniquely identifies the modal.\n *\n * @return {Object} Action object.\n */\nexport function openModal( name ) {\n\treturn {\n\t\ttype: 'OPEN_MODAL',\n\t\tname,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed a modal.\n *\n * @return {Object} Action object.\n */\nexport function closeModal() {\n\treturn {\n\t\ttype: 'CLOSE_MODAL',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user opened the publish\n * sidebar.\n *\n * @return {Object} Action object\n */\nexport function openPublishSidebar() {\n\treturn {\n\t\ttype: 'OPEN_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user closed the\n * publish sidebar.\n *\n * @return {Object} Action object.\n */\nexport function closePublishSidebar() {\n\treturn {\n\t\ttype: 'CLOSE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user toggles the publish sidebar.\n *\n * @return {Object} Action object\n */\nexport function togglePublishSidebar() {\n\treturn {\n\t\ttype: 'TOGGLE_PUBLISH_SIDEBAR',\n\t};\n}\n\n/**\n * Returns an action object used to enable or disable a panel in the editor.\n *\n * @param {string} panelName A string that identifies the panel to enable or disable.\n *\n * @return {Object} Action object.\n */\nexport const toggleEditorPanelEnabled = ( panelName ) => ( { registry } ) => {\n\tconst inactivePanels =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'inactivePanels' ) ?? [];\n\n\tconst isPanelInactive = !! inactivePanels?.includes( panelName );\n\n\t// If the panel is inactive, remove it to enable it, else add it to\n\t// make it inactive.\n\tlet updatedInactivePanels;\n\tif ( isPanelInactive ) {\n\t\tupdatedInactivePanels = inactivePanels.filter(\n\t\t\t( invactivePanelName ) => invactivePanelName !== panelName\n\t\t);\n\t} else {\n\t\tupdatedInactivePanels = [ ...inactivePanels, panelName ];\n\t}\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'inactivePanels', updatedInactivePanels );\n};\n\n/**\n * Opens a closed panel and closes an open panel.\n *\n * @param {string} panelName A string that identifies the panel to open or close.\n */\nexport const toggleEditorPanelOpened = ( panelName ) => ( { registry } ) => {\n\tconst openPanels =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'openPanels' ) ?? [];\n\n\tconst isPanelOpen = !! openPanels?.includes( panelName );\n\n\t// If the panel is open, remove it to close it, else add it to\n\t// make it open.\n\tlet updatedOpenPanels;\n\tif ( isPanelOpen ) {\n\t\tupdatedOpenPanels = openPanels.filter(\n\t\t\t( openPanelName ) => openPanelName !== panelName\n\t\t);\n\t} else {\n\t\tupdatedOpenPanels = [ ...openPanels, panelName ];\n\t}\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'openPanels', updatedOpenPanels );\n};\n\n/**\n * Returns an action object used to remove a panel from the editor.\n *\n * @param {string} panelName A string that identifies the panel to remove.\n *\n * @return {Object} Action object.\n */\nexport function removeEditorPanel( panelName ) {\n\treturn {\n\t\ttype: 'REMOVE_PANEL',\n\t\tpanelName,\n\t};\n}\n\n/**\n * Triggers an action used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n */\nexport const toggleFeature = ( feature ) => ( { registry } ) =>\n\tregistry.dispatch( preferencesStore ).toggle( 'core/edit-post', feature );\n\n/**\n * Triggers an action used to switch editor mode.\n *\n * @param {string} mode The editor mode.\n */\nexport const switchEditorMode = ( mode ) => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'editorMode', mode );\n\n\t// Unselect blocks when we switch to the code editor.\n\tif ( mode !== 'visual' ) {\n\t\tregistry.dispatch( blockEditorStore ).clearSelectedBlock();\n\t}\n\n\tconst message =\n\t\tmode === 'visual'\n\t\t\t? __( 'Visual editor selected' )\n\t\t\t: __( 'Code editor selected' );\n\tspeak( message, 'assertive' );\n};\n\n/**\n * Triggers an action object used to toggle a plugin name flag.\n *\n * @param {string} pluginName Plugin name.\n */\nexport const togglePinnedPluginItem = ( pluginName ) => ( { registry } ) => {\n\tconst isPinned = registry\n\t\t.select( interfaceStore )\n\t\t.isItemPinned( 'core/edit-post', pluginName );\n\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t[ isPinned ? 'unpinItem' : 'pinItem' ]( 'core/edit-post', pluginName );\n};\n\n/**\n * Returns an action object used in signaling that a style should be auto-applied when a block is created.\n *\n * @param {string} blockName Name of the block.\n * @param {?string} blockStyle Name of the style that should be auto applied. If undefined, the \"auto apply\" setting of the block is removed.\n */\nexport const updatePreferredStyleVariations = ( blockName, blockStyle ) => ( {\n\tregistry,\n} ) => {\n\tif ( ! blockName ) {\n\t\treturn;\n\t}\n\n\tconst existingVariations =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'preferredStyleVariations' ) ?? {};\n\n\t// When the blockStyle is omitted, remove the block's preferred variation.\n\tif ( ! blockStyle ) {\n\t\tconst updatedVariations = {\n\t\t\t...existingVariations,\n\t\t};\n\n\t\tdelete updatedVariations[ blockName ];\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set(\n\t\t\t\t'core/edit-post',\n\t\t\t\t'preferredStyleVariations',\n\t\t\t\tupdatedVariations\n\t\t\t);\n\t} else {\n\t\t// Else add the variation.\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core/edit-post', 'preferredStyleVariations', {\n\t\t\t\t...existingVariations,\n\t\t\t\t[ blockName ]: blockStyle,\n\t\t\t} );\n\t}\n};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes = ( blockNames ) => ( { registry } ) => {\n\tconst existingBlockNames =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];\n\n\tconst newBlockNames = without(\n\t\texistingBlockNames,\n\t\t...castArray( blockNames )\n\t);\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'hiddenBlockTypes', newBlockNames );\n};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes = ( blockNames ) => ( { registry } ) => {\n\tconst existingBlockNames =\n\t\tregistry\n\t\t\t.select( preferencesStore )\n\t\t\t.get( 'core/edit-post', 'hiddenBlockTypes' ) ?? [];\n\n\tconst mergedBlockNames = new Set( [\n\t\t...existingBlockNames,\n\t\t...castArray( blockNames ),\n\t] );\n\n\tregistry\n\t\t.dispatch( preferencesStore )\n\t\t.set( 'core/edit-post', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n};\n\n/**\n * Returns an action object used in signaling\n * what Meta boxes are available in which location.\n *\n * @param {Object} metaBoxesPerLocation Meta boxes per location.\n */\nexport const setAvailableMetaBoxesPerLocation = ( metaBoxesPerLocation ) => ( {\n\tdispatch,\n} ) =>\n\tdispatch( {\n\t\ttype: 'SET_META_BOXES_PER_LOCATIONS',\n\t\tmetaBoxesPerLocation,\n\t} );\n\n/**\n * Update a metabox.\n */\nexport const requestMetaBoxUpdates = () => async ( {\n\tregistry,\n\tselect,\n\tdispatch,\n} ) => {\n\tdispatch( {\n\t\ttype: 'REQUEST_META_BOX_UPDATES',\n\t} );\n\n\t// Saves the wp_editor fields.\n\tif ( window.tinyMCE ) {\n\t\twindow.tinyMCE.triggerSave();\n\t}\n\n\t// Additional data needed for backward compatibility.\n\t// If we do not provide this data, the post will be overridden with the default values.\n\tconst post = registry.select( editorStore ).getCurrentPost();\n\tconst additionalData = [\n\t\tpost.comment_status ? [ 'comment_status', post.comment_status ] : false,\n\t\tpost.ping_status ? [ 'ping_status', post.ping_status ] : false,\n\t\tpost.sticky ? [ 'sticky', post.sticky ] : false,\n\t\tpost.author ? [ 'post_author', post.author ] : false,\n\t].filter( Boolean );\n\n\t// We gather all the metaboxes locations data and the base form data.\n\tconst baseFormData = new window.FormData(\n\t\tdocument.querySelector( '.metabox-base-form' )\n\t);\n\tconst activeMetaBoxLocations = select.getActiveMetaBoxLocations();\n\tconst formDataToMerge = [\n\t\tbaseFormData,\n\t\t...activeMetaBoxLocations.map(\n\t\t\t( location ) =>\n\t\t\t\tnew window.FormData( getMetaBoxContainer( location ) )\n\t\t),\n\t];\n\n\t// Merge all form data objects into a single one.\n\tconst formData = reduce(\n\t\tformDataToMerge,\n\t\t( memo, currentFormData ) => {\n\t\t\tfor ( const [ key, value ] of currentFormData ) {\n\t\t\t\tmemo.append( key, value );\n\t\t\t}\n\t\t\treturn memo;\n\t\t},\n\t\tnew window.FormData()\n\t);\n\tadditionalData.forEach( ( [ key, value ] ) =>\n\t\tformData.append( key, value )\n\t);\n\n\ttry {\n\t\t// Save the metaboxes.\n\t\tawait apiFetch( {\n\t\t\turl: window._wpMetaBoxUrl,\n\t\t\tmethod: 'POST',\n\t\t\tbody: formData,\n\t\t\tparse: false,\n\t\t} );\n\t\tdispatch.metaBoxUpdatesSuccess();\n\t} catch {\n\t\tdispatch.metaBoxUpdatesFailure();\n\t}\n};\n\n/**\n * Returns an action object used to signal a successful meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesSuccess() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_SUCCESS',\n\t};\n}\n\n/**\n * Returns an action object used to signal a failed meta box update.\n *\n * @return {Object} Action object.\n */\nexport function metaBoxUpdatesFailure() {\n\treturn {\n\t\ttype: 'META_BOX_UPDATES_FAILURE',\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to switch to template editing.\n *\n * @param {boolean} value Is editing template.\n * @return {Object} Action object.\n */\nexport function setIsEditingTemplate( value ) {\n\treturn {\n\t\ttype: 'SET_IS_EDITING_TEMPLATE',\n\t\tvalue,\n\t};\n}\n\n/**\n * Switches to the template mode.\n *\n * @param {boolean} newTemplate Is new template.\n */\nexport const __unstableSwitchToTemplateMode = ( newTemplate = false ) => ( {\n\tregistry,\n\tselect,\n\tdispatch,\n} ) => {\n\tdispatch( setIsEditingTemplate( true ) );\n\tconst isWelcomeGuideActive = select.isFeatureActive(\n\t\t'welcomeGuideTemplate'\n\t);\n\tif ( ! isWelcomeGuideActive ) {\n\t\tconst message = newTemplate\n\t\t\t? __( \"Custom template created. You're in template mode now.\" )\n\t\t\t: __(\n\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t );\n\t\tregistry.dispatch( noticesStore ).createSuccessNotice( message, {\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n};\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport const __unstableCreateTemplate = ( template ) => async ( {\n\tregistry,\n} ) => {\n\tconst savedTemplate = await registry\n\t\t.dispatch( coreStore )\n\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\tconst post = registry.select( editorStore ).getCurrentPost();\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.editEntityRecord( 'postType', post.type, post.id, {\n\t\t\ttemplate: savedTemplate.slug,\n\t\t} );\n};\n\nlet metaBoxesInitialized = false;\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n */\nexport const initializeMetaBoxes = () => ( { registry, select, dispatch } ) => {\n\tconst isEditorReady = registry\n\t\t.select( editorStore )\n\t\t.__unstableIsEditorReady();\n\n\tif ( ! isEditorReady ) {\n\t\treturn;\n\t}\n\t// Only initialize once.\n\tif ( metaBoxesInitialized ) {\n\t\treturn;\n\t}\n\tconst postType = registry.select( editorStore ).getCurrentPostType();\n\tif ( window.postboxes.page !== postType ) {\n\t\twindow.postboxes.add_postbox_toggles( postType );\n\t}\n\n\tmetaBoxesInitialized = true;\n\n\tlet wasSavingPost = registry.select( editorStore ).isSavingPost();\n\tlet wasAutosavingPost = registry.select( editorStore ).isAutosavingPost();\n\tconst hasMetaBoxes = select.hasMetaBoxes();\n\n\t// Save metaboxes when performing a full save on the post.\n\tregistry.subscribe( async () => {\n\t\tconst isSavingPost = registry.select( editorStore ).isSavingPost();\n\t\tconst isAutosavingPost = registry\n\t\t\t.select( editorStore )\n\t\t\t.isAutosavingPost();\n\n\t\t// Save metaboxes on save completion, except for autosaves that are not a post preview.\n\t\t//\n\t\t// Meta boxes are initialized once at page load. It is not necessary to\n\t\t// account for updates on each state change.\n\t\t//\n\t\t// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309.\n\t\tconst shouldTriggerMetaboxesSave =\n\t\t\thasMetaBoxes &&\n\t\t\twasSavingPost &&\n\t\t\t! isSavingPost &&\n\t\t\t! wasAutosavingPost;\n\n\t\t// Save current state for next inspection.\n\t\twasSavingPost = isSavingPost;\n\t\twasAutosavingPost = isAutosavingPost;\n\n\t\tif ( shouldTriggerMetaboxesSave ) {\n\t\t\tawait dispatch.requestMetaBoxUpdates();\n\t\t}\n\t} );\n\n\tdispatch( {\n\t\ttype: 'META_BOXES_INITIALIZED',\n\t} );\n};\n"]}
|
package/build/store/index.js
CHANGED
|
@@ -28,12 +28,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
28
28
|
/**
|
|
29
29
|
* Internal dependencies
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
reducer: _reducer.default,
|
|
33
|
-
actions,
|
|
34
|
-
selectors,
|
|
35
|
-
persist: ['preferences']
|
|
36
|
-
};
|
|
31
|
+
|
|
37
32
|
/**
|
|
38
33
|
* Store definition for the edit post namespace.
|
|
39
34
|
*
|
|
@@ -41,9 +36,11 @@ const storeConfig = {
|
|
|
41
36
|
*
|
|
42
37
|
* @type {Object}
|
|
43
38
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const store = (0, _data.createReduxStore)(_constants.STORE_NAME, {
|
|
40
|
+
reducer: _reducer.default,
|
|
41
|
+
actions,
|
|
42
|
+
selectors
|
|
43
|
+
});
|
|
47
44
|
exports.store = store;
|
|
48
|
-
(0, _data.
|
|
45
|
+
(0, _data.register)(store);
|
|
49
46
|
//# sourceMappingURL=index.js.map
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/store/index.js"],"names":["store","STORE_NAME","reducer","actions","selectors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8B;AAClDC,EAAAA,OAAO,EAAPA,gBADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAA9B,CAAd;;AAMP,oBAAUJ,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\n/**\n * Store definition for the edit post namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"]}
|
package/build/store/reducer.js
CHANGED
|
@@ -10,7 +10,6 @@ exports.deviceType = deviceType;
|
|
|
10
10
|
exports.isSavingMetaBoxes = isSavingMetaBoxes;
|
|
11
11
|
exports.listViewPanel = listViewPanel;
|
|
12
12
|
exports.metaBoxLocations = metaBoxLocations;
|
|
13
|
-
exports.preferences = void 0;
|
|
14
13
|
exports.publishSidebarActive = publishSidebarActive;
|
|
15
14
|
exports.removedPanels = removedPanels;
|
|
16
15
|
|
|
@@ -18,8 +17,6 @@ var _lodash = require("lodash");
|
|
|
18
17
|
|
|
19
18
|
var _data = require("@wordpress/data");
|
|
20
19
|
|
|
21
|
-
var _defaults = require("./defaults");
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* External dependencies
|
|
25
22
|
*/
|
|
@@ -28,79 +25,6 @@ var _defaults = require("./defaults");
|
|
|
28
25
|
* WordPress dependencies
|
|
29
26
|
*/
|
|
30
27
|
|
|
31
|
-
/**
|
|
32
|
-
* Internal dependencies
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Higher-order reducer creator which provides the given initial state for the
|
|
37
|
-
* original reducer.
|
|
38
|
-
*
|
|
39
|
-
* @param {*} initialState Initial state to provide to reducer.
|
|
40
|
-
*
|
|
41
|
-
* @return {Function} Higher-order reducer.
|
|
42
|
-
*/
|
|
43
|
-
const createWithInitialState = initialState => reducer => {
|
|
44
|
-
return function () {
|
|
45
|
-
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
|
46
|
-
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
47
|
-
return reducer(state, action);
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Reducer returning the user preferences.
|
|
52
|
-
*
|
|
53
|
-
* @param {Object} state Current state.
|
|
54
|
-
* @param {string} state.mode Current editor mode, either
|
|
55
|
-
* "visual" or "text".
|
|
56
|
-
* @param {boolean} state.isGeneralSidebarDismissed Whether general sidebar is
|
|
57
|
-
* dismissed. False by default
|
|
58
|
-
* or when closing general
|
|
59
|
-
* sidebar, true when opening
|
|
60
|
-
* sidebar.
|
|
61
|
-
* @param {boolean} state.isSidebarOpened Whether the sidebar is
|
|
62
|
-
* opened or closed.
|
|
63
|
-
* @param {Object} state.panels The state of the different
|
|
64
|
-
* sidebar panels.
|
|
65
|
-
* @param {Object} action Dispatched action.
|
|
66
|
-
*
|
|
67
|
-
* @return {Object} Updated state.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const preferences = (0, _lodash.flow)([_data.combineReducers, createWithInitialState(_defaults.PREFERENCES_DEFAULTS)])({
|
|
72
|
-
panels(state, action) {
|
|
73
|
-
switch (action.type) {
|
|
74
|
-
case 'TOGGLE_PANEL_ENABLED':
|
|
75
|
-
{
|
|
76
|
-
const {
|
|
77
|
-
panelName
|
|
78
|
-
} = action;
|
|
79
|
-
return { ...state,
|
|
80
|
-
[panelName]: { ...state[panelName],
|
|
81
|
-
enabled: !(0, _lodash.get)(state, [panelName, 'enabled'], true)
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
case 'TOGGLE_PANEL_OPENED':
|
|
87
|
-
{
|
|
88
|
-
const {
|
|
89
|
-
panelName
|
|
90
|
-
} = action;
|
|
91
|
-
const isOpen = state[panelName] === true || (0, _lodash.get)(state, [panelName, 'opened'], false);
|
|
92
|
-
return { ...state,
|
|
93
|
-
[panelName]: { ...state[panelName],
|
|
94
|
-
opened: !isOpen
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return state;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
});
|
|
104
28
|
/**
|
|
105
29
|
* Reducer storing the list of all programmatically removed panels.
|
|
106
30
|
*
|
|
@@ -109,9 +33,6 @@ const preferences = (0, _lodash.flow)([_data.combineReducers, createWithInitialS
|
|
|
109
33
|
*
|
|
110
34
|
* @return {Array} Updated state.
|
|
111
35
|
*/
|
|
112
|
-
|
|
113
|
-
exports.preferences = preferences;
|
|
114
|
-
|
|
115
36
|
function removedPanels() {
|
|
116
37
|
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
117
38
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -338,7 +259,6 @@ const metaBoxes = (0, _data.combineReducers)({
|
|
|
338
259
|
var _default = (0, _data.combineReducers)({
|
|
339
260
|
activeModal,
|
|
340
261
|
metaBoxes,
|
|
341
|
-
preferences,
|
|
342
262
|
publishSidebarActive,
|
|
343
263
|
removedPanels,
|
|
344
264
|
deviceType,
|
|
@@ -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","removedPanels","activeModal","name","publishSidebarActive","isSavingMetaBoxes","metaBoxLocations","metaBoxesPerLocation","deviceType","blockInserterPanel","value","listViewPanel","isEditingTemplate","metaBoxesInitialized","metaBoxes","isSaving","locations","initialized"],"mappings":";;;;;;;;;;;;;;;;AAGA;;AAKA;;AA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AhB;AACC,SAAK,yBAAL;AACC,aAAOL,MAAM,CAACmB,KAAd;AAFF;;AAIA,SAAOpB,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASuB,oBAAT,GAAuD;AAAA,MAAxBvB,KAAwB,uEAAhB,KAAgB;AAAA,MAATC,MAAS;;AACtD,UAASA,MAAM,CAACK,IAAhB;AACC,SAAK,wBAAL;AACC,aAAO,IAAP;AAFF;;AAIA,SAAON,KAAP;AACA;;AAED,MAAMwB,SAAS,GAAG,2BAAiB;AAClCC,EAAAA,QAAQ,EAAEV,iBADwB;AAElCW,EAAAA,SAAS,EAAEV,gBAFuB;AAGlCW,EAAAA,WAAW,EAAEJ;AAHqB,CAAjB,CAAlB;;eAMe,2BAAiB;AAC/BX,EAAAA,WAD+B;AAE/BY,EAAAA,SAF+B;AAG/BtB,EAAAA,WAH+B;AAI/BY,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 } 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} );\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,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,0BAAL;AACC,aAAO,IAAP;;AACD,SAA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oD;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"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -14,8 +14,7 @@ exports.getPreference = getPreference;
|
|
|
14
14
|
exports.getPreferences = void 0;
|
|
15
15
|
exports.hasMetaBoxes = hasMetaBoxes;
|
|
16
16
|
exports.isEditingTemplate = isEditingTemplate;
|
|
17
|
-
exports.isEditorPanelEnabled =
|
|
18
|
-
exports.isEditorPanelOpened = isEditorPanelOpened;
|
|
17
|
+
exports.isEditorPanelOpened = exports.isEditorPanelEnabled = void 0;
|
|
19
18
|
exports.isEditorPanelRemoved = isEditorPanelRemoved;
|
|
20
19
|
exports.isFeatureActive = exports.isEditorSidebarOpened = void 0;
|
|
21
20
|
exports.isInserterOpened = isInserterOpened;
|
|
@@ -41,6 +40,8 @@ var _coreData = require("@wordpress/core-data");
|
|
|
41
40
|
|
|
42
41
|
var _editor = require("@wordpress/editor");
|
|
43
42
|
|
|
43
|
+
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
44
|
+
|
|
44
45
|
/**
|
|
45
46
|
* External dependencies
|
|
46
47
|
*/
|
|
@@ -49,6 +50,7 @@ var _editor = require("@wordpress/editor");
|
|
|
49
50
|
* WordPress dependencies
|
|
50
51
|
*/
|
|
51
52
|
const EMPTY_ARRAY = [];
|
|
53
|
+
const EMPTY_OBJECT = {};
|
|
52
54
|
/**
|
|
53
55
|
* Returns the current editing mode.
|
|
54
56
|
*
|
|
@@ -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
|
-
});
|
|
110
|
-
|
|
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
|
-
|
|
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', 'editorMode', 'preferredStyleVariatio
|
|
|
119
165
|
* @return {Object} Preferences Object.
|
|
120
166
|
*/
|
|
121
167
|
|
|
122
|
-
|
|
123
|
-
|
|
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
|
|
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
|
-
|
|
134
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
}
|
|
@@ -202,10 +262,10 @@ function isEditorPanelRemoved(state, panelName) {
|
|
|
202
262
|
*/
|
|
203
263
|
|
|
204
264
|
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
return !isEditorPanelRemoved(state, panelName) && (0
|
|
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
|
-
|
|
221
|
-
const
|
|
222
|
-
return (
|
|
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),
|
|
349
|
+
return isMetaBoxLocationActive(state, location) && (0, _lodash.some)(getMetaBoxesPerLocation(state, location), _ref2 => {
|
|
289
350
|
let {
|
|
290
351
|
id
|
|
291
|
-
} =
|
|
352
|
+
} = _ref2;
|
|
292
353
|
return isEditorPanelEnabled(state, `meta-box-${id}`);
|
|
293
354
|
});
|
|
294
355
|
}
|