@wordpress/edit-post 5.0.1 → 5.0.5
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/README.md +2 -5
- package/build/components/header/fullscreen-mode-close/index.js +19 -3
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +10 -3
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/more-menu/index.js +3 -14
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/template-title/index.js +1 -1
- package/build/components/header/template-title/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +7 -10
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -8
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +3 -5
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +5 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/meta-boxes/index.js +37 -20
- package/build/components/meta-boxes/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +56 -18
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +1 -0
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-link/index.js +1 -1
- package/build/components/sidebar/post-link/index.js.map +1 -1
- package/build/components/sidebar/template/actions.js +6 -1
- package/build/components/sidebar/template/actions.js.map +1 -1
- package/build/components/sidebar/template/index.js +5 -2
- package/build/components/sidebar/template/index.js.map +1 -1
- package/build/components/sidebar/template-summary/index.js +2 -1
- package/build/components/sidebar/template-summary/index.js.map +1 -1
- package/build/components/visual-editor/index.js +6 -4
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +17 -5
- package/build/editor.js.map +1 -1
- package/build/hooks/validate-multiple-use/index.js +1 -1
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +28 -12
- package/build/index.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +6 -7
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +68 -59
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -9
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +20 -11
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +24 -10
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js +19 -4
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +11 -4
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +5 -15
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/template-title/index.js +1 -1
- package/build-module/components/header/template-title/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +7 -8
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -8
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +4 -6
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +5 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/meta-boxes/index.js +38 -20
- package/build-module/components/meta-boxes/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +57 -20
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +2 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -0
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.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/sidebar/template/actions.js +6 -1
- package/build-module/components/sidebar/template/actions.js.map +1 -1
- package/build-module/components/sidebar/template/index.js +5 -2
- package/build-module/components/sidebar/template/index.js.map +1 -1
- package/build-module/components/sidebar/template-summary/index.js +2 -1
- package/build-module/components/sidebar/template-summary/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +6 -4
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +17 -6
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/validate-multiple-use/index.js +1 -1
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +18 -5
- package/build-module/index.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +7 -8
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +66 -59
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -9
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +20 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +20 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +68 -69
- package/build-style/style.css +68 -69
- package/package.json +27 -27
- package/src/components/header/fullscreen-mode-close/index.js +37 -15
- package/src/components/header/fullscreen-mode-close/style.scss +2 -2
- package/src/components/header/header-toolbar/index.native.js +8 -2
- package/src/components/header/more-menu/index.js +8 -13
- package/src/components/header/template-title/index.js +3 -1
- package/src/components/header/writing-menu/index.js +7 -8
- package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +15 -12
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +2 -2
- package/src/components/keyboard-shortcuts/index.js +19 -32
- package/src/components/layout/index.js +4 -10
- package/src/components/layout/index.native.js +7 -1
- package/src/components/meta-boxes/index.js +35 -14
- package/src/components/preferences-modal/index.js +93 -30
- package/src/components/preferences-modal/style.scss +6 -56
- package/src/components/preferences-modal/test/__snapshots__/index.js.snap +334 -136
- package/src/components/secondary-sidebar/inserter-sidebar.js +1 -0
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -0
- package/src/components/sidebar/plugin-sidebar/index.js +1 -1
- package/src/components/sidebar/post-link/index.js +5 -1
- package/src/components/sidebar/template/actions.js +6 -1
- package/src/components/sidebar/template/index.js +5 -3
- package/src/components/sidebar/template-summary/index.js +1 -1
- package/src/components/sidebar/template-summary/style.scss +2 -1
- package/src/components/text-editor/style.scss +12 -22
- package/src/components/visual-editor/index.js +16 -10
- package/src/components/visual-editor/style.scss +4 -7
- package/src/components/welcome-guide/style.scss +5 -0
- package/src/editor.js +101 -79
- package/src/hooks/validate-multiple-use/index.js +1 -1
- package/src/index.js +18 -5
- package/src/plugins/welcome-guide-menu-item/index.js +7 -12
- package/src/store/actions.js +99 -80
- package/src/store/defaults.js +0 -9
- package/src/store/reducer.js +17 -10
- package/src/store/selectors.js +27 -7
- package/src/store/test/actions.js +0 -11
- package/src/store/test/reducer.js +0 -12
- package/src/store/test/selectors.js +0 -46
- package/build/components/header/feature-toggle/index.js +0 -76
- package/build/components/header/feature-toggle/index.js.map +0 -1
- package/build-module/components/header/feature-toggle/index.js +0 -60
- package/build-module/components/header/feature-toggle/index.js.map +0 -1
- package/src/components/header/feature-toggle/index.js +0 -61
- package/src/components/header/more-menu/test/__snapshots__/index.js.snap +0 -129
- package/src/components/header/more-menu/test/index.js +0 -17
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","document","getElementById","process","env","GUTENBERG_PHASE","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/index.js"],"names":["reinitializeEditor","postType","postId","target","settings","initialEdits","reboot","bind","initializeEditor","id","document","getElementById","interfaceStore","setFeatureDefaults","fixedToolbar","welcomeGuide","mobileGalleryWarning","fullscreenMode","showIconLabels","themeStyles","showBlockBreadcrumbs","welcomeGuideTemplate","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","documentMode","compatMode","console","warn","isIphone","window","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;AALA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAgJA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA3KA;AACA;AACA;;AAUA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AAIC,IAAA,QAAQ,EAAGD,QAJZ;AAKC,IAAA,YAAY,EAAGI;AALhB,IADD,EAQCF,MARD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport { dispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Object} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function reinitializeEditor(\n\tpostType,\n\tpostId,\n\ttarget,\n\tsettings,\n\tinitialEdits\n) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t\trecovery\n\t\t/>,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind(\n\t\tnull,\n\t\tpostType,\n\t\tpostId,\n\t\ttarget,\n\t\tsettings,\n\t\tinitialEdits\n\t);\n\n\tdispatch( interfaceStore ).setFeatureDefaults( 'core/edit-post', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tmobileGalleryWarning: true,\n\t\tfullscreenMode: true,\n\t\tshowIconLabels: false,\n\t\tthemeStyles: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\trender(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tonError={ reboot }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>,\n\t\ttarget\n\t);\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { store } from './store';\n"]}
|
|
@@ -9,7 +9,7 @@ var _element = require("@wordpress/element");
|
|
|
9
9
|
|
|
10
10
|
var _data = require("@wordpress/data");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _interface = require("@wordpress/interface");
|
|
13
13
|
|
|
14
14
|
var _i18n = require("@wordpress/i18n");
|
|
15
15
|
|
|
@@ -24,11 +24,10 @@ var _store = require("../../store");
|
|
|
24
24
|
*/
|
|
25
25
|
function WelcomeGuideMenuItem() {
|
|
26
26
|
const isTemplateMode = (0, _data.useSelect)(select => select(_store.store).isEditingTemplate(), []);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, (0, _i18n.__)('Welcome Guide'));
|
|
27
|
+
return (0, _element.createElement)(_interface.MoreMenuFeatureToggle, {
|
|
28
|
+
scope: "core/edit-post",
|
|
29
|
+
feature: isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide',
|
|
30
|
+
label: (0, _i18n.__)('Welcome Guide')
|
|
31
|
+
});
|
|
33
32
|
}
|
|
34
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/plugins/welcome-guide-menu-item/index.js"],"names":["WelcomeGuideMenuItem","isTemplateMode","select","editPostStore","isEditingTemplate"
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/plugins/welcome-guide-menu-item/index.js"],"names":["WelcomeGuideMenuItem","isTemplateMode","select","editPostStore","isEditingTemplate"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,oBAAT,GAAgC;AAC9C,QAAMC,cAAc,GAAG,qBACpBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAwBC,iBAAxB,EADQ,EAEtB,EAFsB,CAAvB;AAKA,SACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAC,gBADP;AAEC,IAAA,OAAO,EAAGH,cAAc,GAAG,sBAAH,GAA4B,cAFrD;AAGC,IAAA,KAAK,EAAG,cAAI,eAAJ;AAHT,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { MoreMenuFeatureToggle } from '@wordpress/interface';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst isTemplateMode = useSelect(\n\t\t( select ) => select( editPostStore ).isEditingTemplate(),\n\t\t[]\n\t);\n\n\treturn (\n\t\t<MoreMenuFeatureToggle\n\t\t\tscope=\"core/edit-post\"\n\t\t\tfeature={ isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide' }\n\t\t\tlabel={ __( 'Welcome Guide' ) }\n\t\t/>\n\t);\n}\n"]}
|
package/build/store/actions.js
CHANGED
|
@@ -30,6 +30,7 @@ exports.setIsListViewOpened = setIsListViewOpened;
|
|
|
30
30
|
exports.setIsEditingTemplate = setIsEditingTemplate;
|
|
31
31
|
exports.__unstableSwitchToTemplateMode = __unstableSwitchToTemplateMode;
|
|
32
32
|
exports.__unstableCreateTemplate = __unstableCreateTemplate;
|
|
33
|
+
exports.initializeMetaBoxes = initializeMetaBoxes;
|
|
33
34
|
|
|
34
35
|
var _lodash = require("lodash");
|
|
35
36
|
|
|
@@ -75,7 +76,7 @@ var _ = require(".");
|
|
|
75
76
|
* @yield {Object} Action object.
|
|
76
77
|
*/
|
|
77
78
|
function* openGeneralSidebar(name) {
|
|
78
|
-
yield _data.controls.dispatch(_interface.store
|
|
79
|
+
yield _data.controls.dispatch(_interface.store, 'enableComplementaryArea', _.store.name, name);
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
81
82
|
* Returns an action object signalling that the user closed the sidebar.
|
|
@@ -85,7 +86,7 @@ function* openGeneralSidebar(name) {
|
|
|
85
86
|
|
|
86
87
|
|
|
87
88
|
function* closeGeneralSidebar() {
|
|
88
|
-
yield _data.controls.dispatch(_interface.store
|
|
89
|
+
yield _data.controls.dispatch(_interface.store, 'disableComplementaryArea', _.store.name);
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
92
|
* Returns an action object used in signalling that the user opened a modal.
|
|
@@ -198,19 +199,14 @@ function removeEditorPanel(panelName) {
|
|
|
198
199
|
};
|
|
199
200
|
}
|
|
200
201
|
/**
|
|
201
|
-
*
|
|
202
|
+
* Triggers an action used to toggle a feature flag.
|
|
202
203
|
*
|
|
203
204
|
* @param {string} feature Feature name.
|
|
204
|
-
*
|
|
205
|
-
* @return {Object} Action object.
|
|
206
205
|
*/
|
|
207
206
|
|
|
208
207
|
|
|
209
|
-
function toggleFeature(feature) {
|
|
210
|
-
|
|
211
|
-
type: 'TOGGLE_FEATURE',
|
|
212
|
-
feature
|
|
213
|
-
};
|
|
208
|
+
function* toggleFeature(feature) {
|
|
209
|
+
yield _data.controls.dispatch(_interface.store.name, 'toggleFeature', 'core/edit-post', feature);
|
|
214
210
|
}
|
|
215
211
|
|
|
216
212
|
function* switchEditorMode(mode) {
|
|
@@ -220,26 +216,22 @@ function* switchEditorMode(mode) {
|
|
|
220
216
|
}; // Unselect blocks when we switch to the code editor.
|
|
221
217
|
|
|
222
218
|
if (mode !== 'visual') {
|
|
223
|
-
yield _data.controls.dispatch(_blockEditor.store
|
|
219
|
+
yield _data.controls.dispatch(_blockEditor.store, 'clearSelectedBlock');
|
|
224
220
|
}
|
|
225
221
|
|
|
226
222
|
const message = mode === 'visual' ? (0, _i18n.__)('Visual editor selected') : (0, _i18n.__)('Code editor selected');
|
|
227
223
|
(0, _a11y.speak)(message, 'assertive');
|
|
228
224
|
}
|
|
229
225
|
/**
|
|
230
|
-
*
|
|
226
|
+
* Triggers an action object used to toggle a plugin name flag.
|
|
231
227
|
*
|
|
232
228
|
* @param {string} pluginName Plugin name.
|
|
233
|
-
*
|
|
234
|
-
* @return {Object} Action object.
|
|
235
229
|
*/
|
|
236
230
|
|
|
237
231
|
|
|
238
|
-
function togglePinnedPluginItem(pluginName) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
pluginName
|
|
242
|
-
};
|
|
232
|
+
function* togglePinnedPluginItem(pluginName) {
|
|
233
|
+
const isPinned = yield _data.controls.select(_interface.store, 'isItemPinned', 'core/edit-post', pluginName);
|
|
234
|
+
yield _data.controls.dispatch(_interface.store, isPinned ? 'unpinItem' : 'pinItem', 'core/edit-post', pluginName);
|
|
243
235
|
}
|
|
244
236
|
/**
|
|
245
237
|
* Returns an action object used in signalling that block types by the given
|
|
@@ -305,8 +297,6 @@ function showBlockTypes(blockNames) {
|
|
|
305
297
|
blockNames: (0, _lodash.castArray)(blockNames)
|
|
306
298
|
};
|
|
307
299
|
}
|
|
308
|
-
|
|
309
|
-
let saveMetaboxUnsubscribe;
|
|
310
300
|
/**
|
|
311
301
|
* Returns an action object used in signaling
|
|
312
302
|
* what Meta boxes are available in which location.
|
|
@@ -316,43 +306,12 @@ let saveMetaboxUnsubscribe;
|
|
|
316
306
|
* @yield {Object} Action object.
|
|
317
307
|
*/
|
|
318
308
|
|
|
309
|
+
|
|
319
310
|
function* setAvailableMetaBoxesPerLocation(metaBoxesPerLocation) {
|
|
320
311
|
yield {
|
|
321
312
|
type: 'SET_META_BOXES_PER_LOCATIONS',
|
|
322
313
|
metaBoxesPerLocation
|
|
323
314
|
};
|
|
324
|
-
const postType = yield _data.controls.select(_editor.store.name, 'getCurrentPostType');
|
|
325
|
-
|
|
326
|
-
if (window.postboxes.page !== postType) {
|
|
327
|
-
window.postboxes.add_postbox_toggles(postType);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
let wasSavingPost = yield _data.controls.select(_editor.store.name, 'isSavingPost');
|
|
331
|
-
let wasAutosavingPost = yield _data.controls.select(_editor.store.name, 'isAutosavingPost'); // Meta boxes are initialized once at page load. It is not necessary to
|
|
332
|
-
// account for updates on each state change.
|
|
333
|
-
//
|
|
334
|
-
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309
|
|
335
|
-
|
|
336
|
-
const hasActiveMetaBoxes = yield _data.controls.select(_.store.name, 'hasMetaBoxes'); // First remove any existing subscription in order to prevent multiple saves
|
|
337
|
-
|
|
338
|
-
if (!!saveMetaboxUnsubscribe) {
|
|
339
|
-
saveMetaboxUnsubscribe();
|
|
340
|
-
} // Save metaboxes when performing a full save on the post.
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
saveMetaboxUnsubscribe = (0, _data.subscribe)(() => {
|
|
344
|
-
const isSavingPost = (0, _data.select)(_editor.store.name).isSavingPost();
|
|
345
|
-
const isAutosavingPost = (0, _data.select)(_editor.store.name).isAutosavingPost(); // Save metaboxes on save completion, except for autosaves that are not a post preview.
|
|
346
|
-
|
|
347
|
-
const shouldTriggerMetaboxesSave = hasActiveMetaBoxes && wasSavingPost && !isSavingPost && !wasAutosavingPost; // Save current state for next inspection.
|
|
348
|
-
|
|
349
|
-
wasSavingPost = isSavingPost;
|
|
350
|
-
wasAutosavingPost = isAutosavingPost;
|
|
351
|
-
|
|
352
|
-
if (shouldTriggerMetaboxesSave) {
|
|
353
|
-
(0, _data.dispatch)(_.store.name).requestMetaBoxUpdates();
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
315
|
}
|
|
357
316
|
/**
|
|
358
317
|
* Returns an action object used to request meta box update.
|
|
@@ -372,11 +331,11 @@ function* requestMetaBoxUpdates() {
|
|
|
372
331
|
// If we do not provide this data, the post will be overridden with the default values.
|
|
373
332
|
|
|
374
333
|
|
|
375
|
-
const post = yield _data.controls.select(_editor.store
|
|
334
|
+
const post = yield _data.controls.select(_editor.store, 'getCurrentPost');
|
|
376
335
|
const additionalData = [post.comment_status ? ['comment_status', post.comment_status] : false, post.ping_status ? ['ping_status', post.ping_status] : false, post.sticky ? ['sticky', post.sticky] : false, post.author ? ['post_author', post.author] : false].filter(Boolean); // We gather all the metaboxes locations data and the base form data
|
|
377
336
|
|
|
378
337
|
const baseFormData = new window.FormData(document.querySelector('.metabox-base-form'));
|
|
379
|
-
const activeMetaBoxLocations = yield _data.controls.select(_.store
|
|
338
|
+
const activeMetaBoxLocations = yield _data.controls.select(_.store, 'getActiveMetaBoxLocations');
|
|
380
339
|
const formDataToMerge = [baseFormData, ...activeMetaBoxLocations.map(location => new window.FormData((0, _metaBoxes.getMetaBoxContainer)(location)))]; // Merge all form data objects into a single one.
|
|
381
340
|
|
|
382
341
|
const formData = (0, _lodash.reduce)(formDataToMerge, (memo, currentFormData) => {
|
|
@@ -396,9 +355,9 @@ function* requestMetaBoxUpdates() {
|
|
|
396
355
|
body: formData,
|
|
397
356
|
parse: false
|
|
398
357
|
});
|
|
399
|
-
yield _data.controls.dispatch(_.store
|
|
358
|
+
yield _data.controls.dispatch(_.store, 'metaBoxUpdatesSuccess');
|
|
400
359
|
} catch {
|
|
401
|
-
yield _data.controls.dispatch(_.store
|
|
360
|
+
yield _data.controls.dispatch(_.store, 'metaBoxUpdatesFailure');
|
|
402
361
|
}
|
|
403
362
|
}
|
|
404
363
|
/**
|
|
@@ -497,7 +456,7 @@ function setIsEditingTemplate(value) {
|
|
|
497
456
|
|
|
498
457
|
function* __unstableSwitchToTemplateMode(newTemplate = false) {
|
|
499
458
|
yield setIsEditingTemplate(true);
|
|
500
|
-
const isWelcomeGuideActive = yield _data.controls.select(_.store
|
|
459
|
+
const isWelcomeGuideActive = yield _data.controls.select(_.store, 'isFeatureActive', 'welcomeGuideTemplate');
|
|
501
460
|
|
|
502
461
|
if (!isWelcomeGuideActive) {
|
|
503
462
|
const message = newTemplate ? (0, _i18n.__)("Custom template created. You're in template mode now.") : (0, _i18n.__)('Editing template. Changes made here affect all posts and pages that use the template.');
|
|
@@ -515,9 +474,59 @@ function* __unstableSwitchToTemplateMode(newTemplate = false) {
|
|
|
515
474
|
|
|
516
475
|
function* __unstableCreateTemplate(template) {
|
|
517
476
|
const savedTemplate = yield _data.controls.dispatch(_coreData.store, 'saveEntityRecord', 'postType', 'wp_template', template);
|
|
518
|
-
const post = yield _data.controls.select(_editor.store
|
|
477
|
+
const post = yield _data.controls.select(_editor.store, 'getCurrentPost');
|
|
519
478
|
yield _data.controls.dispatch(_coreData.store, 'editEntityRecord', 'postType', post.type, post.id, {
|
|
520
479
|
template: savedTemplate.slug
|
|
521
480
|
});
|
|
522
481
|
}
|
|
482
|
+
|
|
483
|
+
let metaBoxesInitialized = false;
|
|
484
|
+
/**
|
|
485
|
+
* Initializes WordPress `postboxes` script and the logic for saving meta boxes.
|
|
486
|
+
*/
|
|
487
|
+
|
|
488
|
+
function* initializeMetaBoxes() {
|
|
489
|
+
const isEditorReady = yield _data.controls.select(_editor.store, '__unstableIsEditorReady');
|
|
490
|
+
|
|
491
|
+
if (!isEditorReady) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const postType = yield _data.controls.select(_editor.store, 'getCurrentPostType'); // Only initialize once.
|
|
496
|
+
|
|
497
|
+
if (metaBoxesInitialized) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (window.postboxes.page !== postType) {
|
|
502
|
+
window.postboxes.add_postbox_toggles(postType);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
metaBoxesInitialized = true;
|
|
506
|
+
let wasSavingPost = yield _data.controls.select(_editor.store, 'isSavingPost');
|
|
507
|
+
let wasAutosavingPost = yield _data.controls.select(_editor.store, 'isAutosavingPost');
|
|
508
|
+
const hasMetaBoxes = yield _data.controls.select(_.store, 'hasMetaBoxes'); // Save metaboxes when performing a full save on the post.
|
|
509
|
+
|
|
510
|
+
(0, _data.subscribe)(() => {
|
|
511
|
+
const isSavingPost = (0, _data.select)(_editor.store).isSavingPost();
|
|
512
|
+
const isAutosavingPost = (0, _data.select)(_editor.store).isAutosavingPost(); // Save metaboxes on save completion, except for autosaves that are not a post preview.
|
|
513
|
+
//
|
|
514
|
+
// Meta boxes are initialized once at page load. It is not necessary to
|
|
515
|
+
// account for updates on each state change.
|
|
516
|
+
//
|
|
517
|
+
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309
|
|
518
|
+
|
|
519
|
+
const shouldTriggerMetaboxesSave = hasMetaBoxes && wasSavingPost && !isSavingPost && !wasAutosavingPost; // Save current state for next inspection.
|
|
520
|
+
|
|
521
|
+
wasSavingPost = isSavingPost;
|
|
522
|
+
wasAutosavingPost = isAutosavingPost;
|
|
523
|
+
|
|
524
|
+
if (shouldTriggerMetaboxesSave) {
|
|
525
|
+
(0, _data.dispatch)(_.store).requestMetaBoxUpdates();
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
return {
|
|
529
|
+
type: 'META_BOXES_INITIALIZED'
|
|
530
|
+
};
|
|
531
|
+
}
|
|
523
532
|
//# sourceMappingURL=actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/actions.js"],"names":["openGeneralSidebar","name","controls","dispatch","interfaceStore","editPostStore","closeGeneralSidebar","openModal","type","closeModal","openPublishSidebar","closePublishSidebar","togglePublishSidebar","toggleEditorPanelEnabled","panelName","toggleEditorPanelOpened","removeEditorPanel","toggleFeature","feature","switchEditorMode","mode","blockEditorStore","message","togglePinnedPluginItem","pluginName","hideBlockTypes","blockNames","updatePreferredStyleVariations","blockName","blockStyle","__experimentalUpdateLocalAutosaveInterval","interval","showBlockTypes","saveMetaboxUnsubscribe","setAvailableMetaBoxesPerLocation","metaBoxesPerLocation","postType","select","editorStore","window","postboxes","page","add_postbox_toggles","wasSavingPost","wasAutosavingPost","hasActiveMetaBoxes","isSavingPost","isAutosavingPost","shouldTriggerMetaboxesSave","requestMetaBoxUpdates","tinyMCE","triggerSave","post","additionalData","comment_status","ping_status","sticky","author","filter","Boolean","baseFormData","FormData","document","querySelector","activeMetaBoxLocations","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","noticesStore","__unstableCreateTemplate","template","savedTemplate","coreStore","id","slug"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,UAAUA,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMC,eAASC,QAAT,CACLC,iBAAeH,IADV,EAEL,yBAFK,EAGLI,QAAcJ,IAHT,EAILA,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUK,mBAAV,GAAgC;AACtC,QAAMJ,eAASC,QAAT,CACLC,iBAAeH,IADV,EAEL,0BAFK,EAGLI,QAAcJ,IAHT,CAAN;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,SAAT,CAAoBN,IAApB,EAA2B;AACjC,SAAO;AACNO,IAAAA,IAAI,EAAE,YADA;AAENP,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASQ,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;AADA,GAAP;AAGA;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C,MAAT,CAClChC,QAAcJ,IADoB,EAElC,iBAFkC,EAGlC,sBAHkC,CAAnC;;AAMA,MAAK,CAAEyF,oBAAP,EAA8B;AAC7B,UAAMpE,OAAO,GAAGmE,WAAW,GACxB,cAAI,uDAAJ,CADwB,GAExB,cACA,uFADA,CAFH;AAKA,UAAMvF,eAASC,QAAT,CAAmBwF,cAAnB,EAAiC,qBAAjC,EAAwDrE,OAAxD,EAAiE;AACtEd,MAAAA,IAAI,EAAE;AADgE,KAAjE,CAAN;AAGA;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUoF,wBAAV,CAAoCC,QAApC,EAA+C;AACrD,QAAMC,aAAa,GAAG,MAAM5F,eAASC,QAAT,CAC3B4F,eAD2B,EAE3B,kBAF2B,EAG3B,UAH2B,EAI3B,aAJ2B,EAK3BF,QAL2B,CAA5B;AAOA,QAAMzC,IAAI,GAAG,MAAMlD,eAASmC,MAAT,CAAiBC,cAAYrC,IAA7B,EAAmC,gBAAnC,CAAnB;AAEA,QAAMC,eAASC,QAAT,CACL4F,eADK,EAEL,kBAFK,EAGL,UAHK,EAIL3C,IAAI,CAAC5C,IAJA,EAKL4C,IAAI,CAAC4C,EALA,EAML;AACCH,IAAAA,QAAQ,EAAEC,aAAa,CAACG;AADzB,GANK,CAAN;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, reduce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { controls, dispatch, select, subscribe } from '@wordpress/data';\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 * 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 *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore.name,\n\t\t'enableComplementaryArea',\n\t\teditPostStore.name,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore.name,\n\t\t'disableComplementaryArea',\n\t\teditPostStore.name\n\t);\n}\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 * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\nexport function* switchEditorMode( mode ) {\n\tyield {\n\t\ttype: 'SWITCH_MODE',\n\t\tmode,\n\t};\n\n\t// Unselect blocks when we switch to the code editor.\n\tif ( mode !== 'visual' ) {\n\t\tyield controls.dispatch( blockEditorStore.name, '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 * Returns an action object used to toggle a plugin name flag.\n *\n * @param {string} pluginName Plugin name.\n *\n * @return {Object} Action object.\n */\nexport function togglePinnedPluginItem( pluginName ) {\n\treturn {\n\t\ttype: 'TOGGLE_PINNED_PLUGIN_ITEM',\n\t\tpluginName,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that block types by the given\n * name(s) should be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n *\n * @return {Object} Action object.\n */\nexport function hideBlockTypes( blockNames ) {\n\treturn {\n\t\ttype: 'HIDE_BLOCK_TYPES',\n\t\tblockNames: castArray( blockNames ),\n\t};\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 *\n * @return {Object} Action object.\n */\nexport function updatePreferredStyleVariations( blockName, blockStyle ) {\n\treturn {\n\t\ttype: 'UPDATE_PREFERRED_STYLE_VARIATIONS',\n\t\tblockName,\n\t\tblockStyle,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the editor should attempt\n * to locally autosave the current post every `interval` seconds.\n *\n * @param {number} interval The new interval, in seconds.\n * @return {Object} Action object.\n */\nexport function __experimentalUpdateLocalAutosaveInterval( interval ) {\n\treturn {\n\t\ttype: 'UPDATE_LOCAL_AUTOSAVE_INTERVAL',\n\t\tinterval,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that block types by the given\n * name(s) should be shown.\n *\n * @param {string[]} blockNames Names of block types to show.\n *\n * @return {Object} Action object.\n */\nexport function showBlockTypes( blockNames ) {\n\treturn {\n\t\ttype: 'SHOW_BLOCK_TYPES',\n\t\tblockNames: castArray( blockNames ),\n\t};\n}\n\nlet saveMetaboxUnsubscribe;\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 *\n * @yield {Object} Action object.\n */\nexport function* setAvailableMetaBoxesPerLocation( metaBoxesPerLocation ) {\n\tyield {\n\t\ttype: 'SET_META_BOXES_PER_LOCATIONS',\n\t\tmetaBoxesPerLocation,\n\t};\n\n\tconst postType = yield controls.select(\n\t\teditorStore.name,\n\t\t'getCurrentPostType'\n\t);\n\tif ( window.postboxes.page !== postType ) {\n\t\twindow.postboxes.add_postbox_toggles( postType );\n\t}\n\n\tlet wasSavingPost = yield controls.select(\n\t\teditorStore.name,\n\t\t'isSavingPost'\n\t);\n\tlet wasAutosavingPost = yield controls.select(\n\t\teditorStore.name,\n\t\t'isAutosavingPost'\n\t);\n\n\t// Meta boxes are initialized once at page load. It is not necessary to\n\t// account for updates on each state change.\n\t//\n\t// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309\n\tconst hasActiveMetaBoxes = yield controls.select(\n\t\teditPostStore.name,\n\t\t'hasMetaBoxes'\n\t);\n\n\t// First remove any existing subscription in order to prevent multiple saves\n\tif ( !! saveMetaboxUnsubscribe ) {\n\t\tsaveMetaboxUnsubscribe();\n\t}\n\n\t// Save metaboxes when performing a full save on the post.\n\tsaveMetaboxUnsubscribe = subscribe( () => {\n\t\tconst isSavingPost = select( editorStore.name ).isSavingPost();\n\t\tconst isAutosavingPost = select( editorStore.name ).isAutosavingPost();\n\n\t\t// Save metaboxes on save completion, except for autosaves that are not a post preview.\n\t\tconst shouldTriggerMetaboxesSave =\n\t\t\thasActiveMetaBoxes &&\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\tdispatch( editPostStore.name ).requestMetaBoxUpdates();\n\t\t}\n\t} );\n}\n\n/**\n * Returns an action object used to request meta box update.\n *\n * @yield {Object} Action object.\n */\nexport function* requestMetaBoxUpdates() {\n\tyield {\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 = yield controls.select( editorStore.name, '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 = yield controls.select(\n\t\teditPostStore.name,\n\t\t'getActiveMetaBoxLocations'\n\t);\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\tyield 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\tyield controls.dispatch( editPostStore.name, 'metaBoxUpdatesSuccess' );\n\t} catch {\n\t\tyield controls.dispatch( editPostStore.name, '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 function* __unstableSwitchToTemplateMode( newTemplate = false ) {\n\tyield setIsEditingTemplate( true );\n\n\tconst isWelcomeGuideActive = yield controls.select(\n\t\teditPostStore.name,\n\t\t'isFeatureActive',\n\t\t'welcomeGuideTemplate'\n\t);\n\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\tyield controls.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 function* __unstableCreateTemplate( template ) {\n\tconst savedTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\tconst post = yield controls.select( editorStore.name, 'getCurrentPost' );\n\n\tyield controls.dispatch(\n\t\tcoreStore,\n\t\t'editEntityRecord',\n\t\t'postType',\n\t\tpost.type,\n\t\tpost.id,\n\t\t{\n\t\t\ttemplate: savedTemplate.slug,\n\t\t}\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/store/actions.js"],"names":["openGeneralSidebar","name","controls","dispatch","interfaceStore","editPostStore","closeGeneralSidebar","openModal","type","closeModal","openPublishSidebar","closePublishSidebar","togglePublishSidebar","toggleEditorPanelEnabled","panelName","toggleEditorPanelOpened","removeEditorPanel","toggleFeature","feature","switchEditorMode","mode","blockEditorStore","message","togglePinnedPluginItem","pluginName","isPinned","select","hideBlockTypes","blockNames","updatePreferredStyleVariations","blockName","blockStyle","__experimentalUpdateLocalAutosaveInterval","interval","showBlockTypes","setAvailableMetaBoxesPerLocation","metaBoxesPerLocation","requestMetaBoxUpdates","window","tinyMCE","triggerSave","post","editorStore","additionalData","comment_status","ping_status","sticky","author","filter","Boolean","baseFormData","FormData","document","querySelector","activeMetaBoxLocations","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","noticesStore","__unstableCreateTemplate","template","savedTemplate","coreStore","id","slug","metaBoxesInitialized","initializeMetaBoxes","isEditorReady","postType","postboxes","page","add_postbox_toggles","wasSavingPost","wasAutosavingPost","hasMetaBoxes","isSavingPost","isAutosavingPost","shouldTriggerMetaboxesSave"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,UAAUA,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMC,eAASC,QAAT,CACLC,gBADK,EAEL,yBAFK,EAGLC,QAAcJ,IAHT,EAILA,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;;AACO,UAAUK,mBAAV,GAAgC;AACtC,QAAMJ,eAASC,QAAT,CACLC,gBADK,EAEL,0BAFK,EAGLC,QAAcJ,IAHT,CAAN;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASM,SAAT,CAAoBN,IAApB,EAA2B;AACjC,SAAO;AACNO,IAAAA,IAAI,EAAE,YADA;AAENP,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASQ,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;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,wBAAT,CAAmCC,SAAnC,EAA+C;AACrD,SAAO;AACNN,IAAAA,IAAI,EAAE,sBADA;AAENM,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,uBAAT,CAAkCD,SAAlC,EAA8C;AACpD,SAAO;AACNN,IAAAA,IAAI,EAAE,qBADA;AAENM,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AAC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M7F,eAASwB,MAAT,CAAiBgB,aAAjB,EAA8B,cAA9B,CAA1B;AACA,MAAIsD,iBAAiB,GAAG,MAAM9F,eAASwB,MAAT,CAC7BgB,aAD6B,EAE7B,kBAF6B,CAA9B;AAIA,QAAMuD,YAAY,GAAG,MAAM/F,eAASwB,MAAT,CAAiBrB,OAAjB,EAAgC,cAAhC,CAA3B,CA5BsC,CA8BtC;;AACA,uBAAW,MAAM;AAChB,UAAM6F,YAAY,GAAG,kBAAQxD,aAAR,EAAsBwD,YAAtB,EAArB;AACA,UAAMC,gBAAgB,GAAG,kBAAQzD,aAAR,EAAsByD,gBAAtB,EAAzB,CAFgB,CAIhB;AACA;AACA;AACA;AACA;AACA;;AACA,UAAMC,0BAA0B,GAC/BH,YAAY,IACZF,aADA,IAEA,CAAEG,YAFF,IAGA,CAAEF,iBAJH,CAVgB,CAgBhB;;AACAD,IAAAA,aAAa,GAAGG,YAAhB;AACAF,IAAAA,iBAAiB,GAAGG,gBAApB;;AAEA,QAAKC,0BAAL,EAAkC;AACjC,0BAAU/F,OAAV,EAA0BgC,qBAA1B;AACA;AACD,GAvBD;AAyBA,SAAO;AACN7B,IAAAA,IAAI,EAAE;AADA,GAAP;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport { castArray, reduce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { controls, select, subscribe, dispatch } from '@wordpress/data';\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 * 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 *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditPostStore.name,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditPostStore.name\n\t);\n}\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 function* toggleFeature( feature ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore.name,\n\t\t'toggleFeature',\n\t\t'core/edit-post',\n\t\tfeature\n\t);\n}\n\nexport function* switchEditorMode( mode ) {\n\tyield {\n\t\ttype: 'SWITCH_MODE',\n\t\tmode,\n\t};\n\n\t// Unselect blocks when we switch to the code editor.\n\tif ( mode !== 'visual' ) {\n\t\tyield controls.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 function* togglePinnedPluginItem( pluginName ) {\n\tconst isPinned = yield controls.select(\n\t\tinterfaceStore,\n\t\t'isItemPinned',\n\t\t'core/edit-post',\n\t\tpluginName\n\t);\n\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\tisPinned ? 'unpinItem' : 'pinItem',\n\t\t'core/edit-post',\n\t\tpluginName\n\t);\n}\n\n/**\n * Returns an action object used in signalling that block types by the given\n * name(s) should be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n *\n * @return {Object} Action object.\n */\nexport function hideBlockTypes( blockNames ) {\n\treturn {\n\t\ttype: 'HIDE_BLOCK_TYPES',\n\t\tblockNames: castArray( blockNames ),\n\t};\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 *\n * @return {Object} Action object.\n */\nexport function updatePreferredStyleVariations( blockName, blockStyle ) {\n\treturn {\n\t\ttype: 'UPDATE_PREFERRED_STYLE_VARIATIONS',\n\t\tblockName,\n\t\tblockStyle,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the editor should attempt\n * to locally autosave the current post every `interval` seconds.\n *\n * @param {number} interval The new interval, in seconds.\n * @return {Object} Action object.\n */\nexport function __experimentalUpdateLocalAutosaveInterval( interval ) {\n\treturn {\n\t\ttype: 'UPDATE_LOCAL_AUTOSAVE_INTERVAL',\n\t\tinterval,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that block types by the given\n * name(s) should be shown.\n *\n * @param {string[]} blockNames Names of block types to show.\n *\n * @return {Object} Action object.\n */\nexport function showBlockTypes( blockNames ) {\n\treturn {\n\t\ttype: 'SHOW_BLOCK_TYPES',\n\t\tblockNames: castArray( blockNames ),\n\t};\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 *\n * @yield {Object} Action object.\n */\nexport function* setAvailableMetaBoxesPerLocation( metaBoxesPerLocation ) {\n\tyield {\n\t\ttype: 'SET_META_BOXES_PER_LOCATIONS',\n\t\tmetaBoxesPerLocation,\n\t};\n}\n\n/**\n * Returns an action object used to request meta box update.\n *\n * @yield {Object} Action object.\n */\nexport function* requestMetaBoxUpdates() {\n\tyield {\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 = yield controls.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 = yield controls.select(\n\t\teditPostStore,\n\t\t'getActiveMetaBoxLocations'\n\t);\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\tyield 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\tyield controls.dispatch( editPostStore, 'metaBoxUpdatesSuccess' );\n\t} catch {\n\t\tyield controls.dispatch( editPostStore, '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 function* __unstableSwitchToTemplateMode( newTemplate = false ) {\n\tyield setIsEditingTemplate( true );\n\n\tconst isWelcomeGuideActive = yield controls.select(\n\t\teditPostStore,\n\t\t'isFeatureActive',\n\t\t'welcomeGuideTemplate'\n\t);\n\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\tyield controls.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 function* __unstableCreateTemplate( template ) {\n\tconst savedTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\tconst post = yield controls.select( editorStore, 'getCurrentPost' );\n\n\tyield controls.dispatch(\n\t\tcoreStore,\n\t\t'editEntityRecord',\n\t\t'postType',\n\t\tpost.type,\n\t\tpost.id,\n\t\t{\n\t\t\ttemplate: savedTemplate.slug,\n\t\t}\n\t);\n}\n\nlet metaBoxesInitialized = false;\n\n/**\n * Initializes WordPress `postboxes` script and the logic for saving meta boxes.\n */\nexport function* initializeMetaBoxes() {\n\tconst isEditorReady = yield controls.select(\n\t\teditorStore,\n\t\t'__unstableIsEditorReady'\n\t);\n\n\tif ( ! isEditorReady ) {\n\t\treturn;\n\t}\n\n\tconst postType = yield controls.select( editorStore, 'getCurrentPostType' );\n\n\t// Only initialize once.\n\tif ( metaBoxesInitialized ) {\n\t\treturn;\n\t}\n\n\tif ( window.postboxes.page !== postType ) {\n\t\twindow.postboxes.add_postbox_toggles( postType );\n\t}\n\n\tmetaBoxesInitialized = true;\n\n\tlet wasSavingPost = yield controls.select( editorStore, 'isSavingPost' );\n\tlet wasAutosavingPost = yield controls.select(\n\t\teditorStore,\n\t\t'isAutosavingPost'\n\t);\n\tconst hasMetaBoxes = yield controls.select( editPostStore, 'hasMetaBoxes' );\n\n\t// Save metaboxes when performing a full save on the post.\n\tsubscribe( () => {\n\t\tconst isSavingPost = select( editorStore ).isSavingPost();\n\t\tconst isAutosavingPost = select( editorStore ).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\tdispatch( editPostStore ).requestMetaBoxUpdates();\n\t\t}\n\t} );\n\n\treturn {\n\t\ttype: 'META_BOXES_INITIALIZED',\n\t};\n}\n"]}
|
package/build/store/defaults.js
CHANGED
|
@@ -11,15 +11,6 @@ const PREFERENCES_DEFAULTS = {
|
|
|
11
11
|
opened: true
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
features: {
|
|
15
|
-
fixedToolbar: false,
|
|
16
|
-
welcomeGuide: true,
|
|
17
|
-
fullscreenMode: true,
|
|
18
|
-
showIconLabels: false,
|
|
19
|
-
themeStyles: true,
|
|
20
|
-
showBlockBreadcrumbs: true,
|
|
21
|
-
welcomeGuideTemplate: true
|
|
22
|
-
},
|
|
23
14
|
hiddenBlockTypes: [],
|
|
24
15
|
preferredStyleVariations: {},
|
|
25
16
|
localAutosaveInterval: 15
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","editorMode","panels","opened","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","editorMode","panels","opened","hiddenBlockTypes","preferredStyleVariations","localAutosaveInterval"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,UAAU,EAAE,QADuB;AAEnCC,EAAAA,MAAM,EAAE;AACP,mBAAe;AACdC,MAAAA,MAAM,EAAE;AADM;AADR,GAF2B;AAOnCC,EAAAA,gBAAgB,EAAE,EAPiB;AAQnCC,EAAAA,wBAAwB,EAAE,EARS;AASnCC,EAAAA,qBAAqB,EAAE;AATY,CAA7B","sourcesContent":["export const PREFERENCES_DEFAULTS = {\n\teditorMode: 'visual',\n\tpanels: {\n\t\t'post-status': {\n\t\t\topened: true,\n\t\t},\n\t},\n\thiddenBlockTypes: [],\n\tpreferredStyleVariations: {},\n\tlocalAutosaveInterval: 15,\n};\n"]}
|
package/build/store/reducer.js
CHANGED
|
@@ -95,16 +95,6 @@ const preferences = (0, _lodash.flow)([_data.combineReducers, createWithInitialS
|
|
|
95
95
|
return state;
|
|
96
96
|
},
|
|
97
97
|
|
|
98
|
-
features(state, action) {
|
|
99
|
-
if (action.type === 'TOGGLE_FEATURE') {
|
|
100
|
-
return { ...state,
|
|
101
|
-
[action.feature]: !state[action.feature]
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return state;
|
|
106
|
-
},
|
|
107
|
-
|
|
108
98
|
editorMode(state, action) {
|
|
109
99
|
if (action.type === 'SWITCH_MODE') {
|
|
110
100
|
return action.mode;
|
|
@@ -335,10 +325,29 @@ function isEditingTemplate(state = false, action) {
|
|
|
335
325
|
|
|
336
326
|
return state;
|
|
337
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Reducer tracking whether meta boxes are initialized.
|
|
330
|
+
*
|
|
331
|
+
* @param {boolean} state
|
|
332
|
+
* @param {Object} action
|
|
333
|
+
*
|
|
334
|
+
* @return {boolean} Updated state.
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
function metaBoxesInitialized(state = false, action) {
|
|
339
|
+
switch (action.type) {
|
|
340
|
+
case 'META_BOXES_INITIALIZED':
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return state;
|
|
345
|
+
}
|
|
338
346
|
|
|
339
347
|
const metaBoxes = (0, _data.combineReducers)({
|
|
340
348
|
isSaving: isSavingMetaBoxes,
|
|
341
|
-
locations: metaBoxLocations
|
|
349
|
+
locations: metaBoxLocations,
|
|
350
|
+
initialized: metaBoxesInitialized
|
|
342
351
|
});
|
|
343
352
|
|
|
344
353
|
var _default = (0, _data.combineReducers)({
|
|
@@ -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","features","feature","editorMode","mode","hiddenBlockTypes","blockNames","preferredStyleVariations","blockName","blockStyle","localAutosaveInterval","interval","removedPanels","activeModal","name","publishSidebarActive","isSavingMetaBoxes","metaBoxLocations","metaBoxesPerLocation","deviceType","blockInserterPanel","value","listViewPanel","isEditingTemplate","metaBoxes","isSaving","locations"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,sBAAsB,GAAKC,YAAF,IAAsBC,OAAF,IAAe;AACjE,SAAO,CAAEC,KAAK,GAAGF,YAAV,EAAwBG,MAAxB,KAAoCF,OAAO,CAAEC,KAAF,EAASC,MAAT,CAAlD;AACA,CAFD;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,WAAW,GAAG,kBAAM,CAChCC,qBADgC,EAEhCN,sBAAsB,CAAEO,8BAAF,CAFU,CAAN,EAGtB;AACJC,EAAAA,MAAM,CAAEL,KAAF,EAASC,MAAT,EAAkB;AACvB,YAASA,MAAM,CAACK,IAAhB;AACC,WAAK,sBAAL;AAA6B;AAC5B,gBAAM;AAAEC,YAAAA;AAAF,cAAgBN,MAAtB;AACA,iBAAO,EACN,GAAGD,KADG;AAEN,aAAEO,SAAF,GAAe,EACd,GAAGP,KAAK,CAAEO,SAAF,CADM;AAEdC,cAAAA,OAAO,EAAE,CAAE,iBAA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BAAL;AACC,aAAOC,MAAM,CAAC8B,KAAd;AAJF;;AAMA,SAAO/B,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASgC,aAAT,CAAwBhC,KAAK,GAAG,KAAhC,EAAuCC,MAAvC,EAAgD;AACtD,UAASA,MAAM,CAACK,IAAhB;AACC,SAAK,wBAAL;AACC,aAAOL,MAAM,CAAC8B,KAAP,GAAe,KAAf,GAAuB/B,KAA9B;;AACD,SAAK,yBAAL;AACC,aAAOC,MAAM,CAACQ,MAAd;AAJF;;AAMA,SAAOT,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASiC,iBAAT,CAA4BjC,KAAK,GAAG,KAApC,EAA2CC,MAA3C,EAAoD;AACnD,UAASA,MAAM,CAACK,IAAhB;AACC,SAAK,yBAAL;AACC,aAAOL,MAAM,CAAC8B,KAAd;AAFF;;AAIA,SAAO/B,KAAP;AACA;;AAED,MAAMkC,SAAS,GAAG,2BAAiB;AAClCC,EAAAA,QAAQ,EAAET,iBADwB;AAElCU,EAAAA,SAAS,EAAET;AAFuB,CAAjB,CAAlB;;eAKe,2BAAiB;AAC/BJ,EAAAA,WAD+B;AAE/BW,EAAAA,SAF+B;AAG/BhC,EAAAA,WAH+B;AAI/BuB,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, union, without } 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\tfeatures( state, action ) {\n\t\tif ( action.type === 'TOGGLE_FEATURE' ) {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.feature ]: ! state[ action.feature ],\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\thiddenBlockTypes( state, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'SHOW_BLOCK_TYPES':\n\t\t\t\treturn without( state, ...action.blockNames );\n\n\t\t\tcase 'HIDE_BLOCK_TYPES':\n\t\t\t\treturn union( state, action.blockNames );\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\nconst metaBoxes = combineReducers( {\n\tisSaving: isSavingMetaBoxes,\n\tlocations: metaBoxLocations,\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":["createWithInitialState","initialState","reducer","state","action","preferences","combineReducers","PREFERENCES_DEFAULTS","panels","type","panelName","enabled","isOpen","opened","editorMode","mode","hiddenBlockTypes","blockNames","preferredStyleVariations","blockName","blockStyle","localAutosaveInterval","interval","removedPanels","activeModal","name","publishSidebarActive","isSavingMetaBoxes","metaBoxLocations","metaBoxesPerLocation","deviceType","blockInserterPanel","value","listViewPanel","isEditingTemplate","metaBoxesInitialized","metaBoxes","isSaving","locations","initialized"],"mappings":";;;;;;;;;;;;;;;A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C,aAAO,IAAP;AAFF;;AAIA,SAAON,KAAP;AACA;;AAED,MAAMiC,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/B/B,EAAAA,WAH+B;AAI/BqB,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, union, without } 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\thiddenBlockTypes( state, action ) {\n\t\tswitch ( action.type ) {\n\t\t\tcase 'SHOW_BLOCK_TYPES':\n\t\t\t\treturn without( state, ...action.blockNames );\n\n\t\t\tcase 'HIDE_BLOCK_TYPES':\n\t\t\t\treturn union( state, action.blockNames );\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"]}
|