@wordpress/editor 14.0.2 → 14.0.4
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/build/bindings/pattern-overrides.js +8 -5
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/components/editor/index.js +5 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-interface/index.js +3 -2
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +6 -65
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/post-actions/actions.js +62 -13
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +4 -1
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-excerpt/index.js +2 -1
- package/build/components/post-excerpt/index.js.map +1 -1
- package/build/components/post-excerpt/panel.js +2 -1
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/save-publish-panels/index.js +30 -16
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build/hooks/pattern-overrides.js +3 -3
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/store/private-actions.js +9 -5
- package/build/store/private-actions.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +8 -5
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/components/editor/index.js +5 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-interface/index.js +3 -2
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +7 -66
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +63 -14
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +4 -1
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-excerpt/index.js +2 -1
- package/build-module/components/post-excerpt/index.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +2 -1
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +30 -16
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +4 -2
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/store/private-actions.js +9 -5
- package/build-module/store/private-actions.js.map +1 -1
- package/build-style/style-rtl.css +19 -2
- package/build-style/style.css +19 -2
- package/package.json +14 -14
- package/src/bindings/pattern-overrides.js +9 -10
- package/src/components/editor/index.js +6 -0
- package/src/components/editor-interface/index.js +17 -8
- package/src/components/global-styles-provider/index.js +7 -90
- package/src/components/post-actions/actions.js +109 -21
- package/src/components/post-actions/index.js +1 -1
- package/src/components/post-card-panel/style.scss +1 -0
- package/src/components/post-excerpt/index.js +4 -1
- package/src/components/post-excerpt/panel.js +2 -1
- package/src/components/post-featured-image/style.scss +15 -0
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-url/style.scss +4 -0
- package/src/components/save-publish-panels/index.js +33 -23
- package/src/components/visual-editor/style.scss +3 -1
- package/src/hooks/pattern-overrides.js +6 -4
- package/src/store/private-actions.js +54 -21
|
@@ -35,13 +35,25 @@ export default function SavePublishPanels({
|
|
|
35
35
|
} = useDispatch(editorStore);
|
|
36
36
|
const {
|
|
37
37
|
publishSidebarOpened,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
isPublishable,
|
|
39
|
+
isDirty,
|
|
40
|
+
hasOtherEntitiesChanges
|
|
41
|
+
} = useSelect(select => {
|
|
42
|
+
const {
|
|
43
|
+
isPublishSidebarOpened,
|
|
44
|
+
isEditedPostPublishable,
|
|
45
|
+
isCurrentPostPublished,
|
|
46
|
+
isEditedPostDirty,
|
|
47
|
+
hasNonPostEntityChanges
|
|
48
|
+
} = select(editorStore);
|
|
49
|
+
const _hasOtherEntitiesChanges = hasNonPostEntityChanges() || unlock(select(editorStore)).hasPostMetaChanges();
|
|
50
|
+
return {
|
|
51
|
+
publishSidebarOpened: isPublishSidebarOpened(),
|
|
52
|
+
isPublishable: !isCurrentPostPublished() && isEditedPostPublishable(),
|
|
53
|
+
isDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),
|
|
54
|
+
hasOtherEntitiesChanges: _hasOtherEntitiesChanges
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
45
57
|
const openEntitiesSavedStates = useCallback(() => setEntitiesSavedStatesCallback(true), []);
|
|
46
58
|
|
|
47
59
|
// It is ok for these components to be unmounted when not in visual use.
|
|
@@ -54,26 +66,28 @@ export default function SavePublishPanels({
|
|
|
54
66
|
PrePublishExtension: PluginPrePublishPanel.Slot,
|
|
55
67
|
PostPublishExtension: PluginPostPublishPanel.Slot
|
|
56
68
|
});
|
|
57
|
-
} else if (
|
|
69
|
+
} else if (isPublishable && !hasOtherEntitiesChanges) {
|
|
58
70
|
unmountableContent = /*#__PURE__*/_jsx("div", {
|
|
59
|
-
className: "editor-layout__toggle-
|
|
71
|
+
className: "editor-layout__toggle-publish-panel",
|
|
60
72
|
children: /*#__PURE__*/_jsx(Button, {
|
|
61
73
|
variant: "secondary",
|
|
62
|
-
className: "editor-layout__toggle-
|
|
63
|
-
onClick:
|
|
74
|
+
className: "editor-layout__toggle-publish-panel-button",
|
|
75
|
+
onClick: togglePublishSidebar,
|
|
64
76
|
"aria-expanded": false,
|
|
65
|
-
children: __('Open
|
|
77
|
+
children: __('Open publish panel')
|
|
66
78
|
})
|
|
67
79
|
});
|
|
68
80
|
} else {
|
|
69
81
|
unmountableContent = /*#__PURE__*/_jsx("div", {
|
|
70
|
-
className: "editor-layout__toggle-
|
|
82
|
+
className: "editor-layout__toggle-entities-saved-states-panel",
|
|
71
83
|
children: /*#__PURE__*/_jsx(Button, {
|
|
72
84
|
variant: "secondary",
|
|
73
|
-
className: "editor-layout__toggle-
|
|
74
|
-
onClick:
|
|
85
|
+
className: "editor-layout__toggle-entities-saved-states-panel-button",
|
|
86
|
+
onClick: openEntitiesSavedStates,
|
|
75
87
|
"aria-expanded": false,
|
|
76
|
-
|
|
88
|
+
disabled: !isDirty,
|
|
89
|
+
__experimentalIsFocusable: true,
|
|
90
|
+
children: __('Open save panel')
|
|
77
91
|
})
|
|
78
92
|
});
|
|
79
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","Button","createSlotFill","__","useCallback","EntitiesSavedStates","PostPublishPanel","PluginPrePublishPanel","PluginPostPublishPanel","store","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","Fill","Slot","ActionsPanelFill","SavePublishPanels","setEntitiesSavedStatesCallback","closeEntitiesSavedStates","isEntitiesSavedStatesOpen","forceIsDirtyPublishPanel","closePublishSidebar","togglePublishSidebar","publishSidebarOpened","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","Button","createSlotFill","__","useCallback","EntitiesSavedStates","PostPublishPanel","PluginPrePublishPanel","PluginPostPublishPanel","store","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","Fill","Slot","ActionsPanelFill","SavePublishPanels","setEntitiesSavedStatesCallback","closeEntitiesSavedStates","isEntitiesSavedStatesOpen","forceIsDirtyPublishPanel","closePublishSidebar","togglePublishSidebar","publishSidebarOpened","isPublishable","isDirty","hasOtherEntitiesChanges","select","isPublishSidebarOpened","isEditedPostPublishable","isCurrentPostPublished","isEditedPostDirty","hasNonPostEntityChanges","_hasOtherEntitiesChanges","hasPostMetaChanges","openEntitiesSavedStates","unmountableContent","onClose","forceIsDirty","PrePublishExtension","PostPublishExtension","className","children","variant","onClick","disabled","__experimentalIsFocusable","close","bubblesVirtually"],"sources":["@wordpress/editor/src/components/save-publish-panels/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, createSlotFill } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport EntitiesSavedStates from '../entities-saved-states';\nimport PostPublishPanel from '../post-publish-panel';\nimport PluginPrePublishPanel from '../plugin-pre-publish-panel';\nimport PluginPostPublishPanel from '../plugin-post-publish-panel';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Fill, Slot } = createSlotFill( 'ActionsPanel' );\n\nexport const ActionsPanelFill = Fill;\n\nexport default function SavePublishPanels( {\n\tsetEntitiesSavedStatesCallback,\n\tcloseEntitiesSavedStates,\n\tisEntitiesSavedStatesOpen,\n\tforceIsDirtyPublishPanel,\n} ) {\n\tconst { closePublishSidebar, togglePublishSidebar } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tpublishSidebarOpened,\n\t\tisPublishable,\n\t\tisDirty,\n\t\thasOtherEntitiesChanges,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisPublishSidebarOpened,\n\t\t\tisEditedPostPublishable,\n\t\t\tisCurrentPostPublished,\n\t\t\tisEditedPostDirty,\n\t\t\thasNonPostEntityChanges,\n\t\t} = select( editorStore );\n\t\tconst _hasOtherEntitiesChanges =\n\t\t\thasNonPostEntityChanges() ||\n\t\t\tunlock( select( editorStore ) ).hasPostMetaChanges();\n\t\treturn {\n\t\t\tpublishSidebarOpened: isPublishSidebarOpened(),\n\t\t\tisPublishable:\n\t\t\t\t! isCurrentPostPublished() && isEditedPostPublishable(),\n\t\t\tisDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),\n\t\t\thasOtherEntitiesChanges: _hasOtherEntitiesChanges,\n\t\t};\n\t}, [] );\n\n\tconst openEntitiesSavedStates = useCallback(\n\t\t() => setEntitiesSavedStatesCallback( true ),\n\t\t[]\n\t);\n\n\t// It is ok for these components to be unmounted when not in visual use.\n\t// We don't want more than one present at a time, decide which to render.\n\tlet unmountableContent;\n\tif ( publishSidebarOpened ) {\n\t\tunmountableContent = (\n\t\t\t<PostPublishPanel\n\t\t\t\tonClose={ closePublishSidebar }\n\t\t\t\tforceIsDirty={ forceIsDirtyPublishPanel }\n\t\t\t\tPrePublishExtension={ PluginPrePublishPanel.Slot }\n\t\t\t\tPostPublishExtension={ PluginPostPublishPanel.Slot }\n\t\t\t/>\n\t\t);\n\t} else if ( isPublishable && ! hasOtherEntitiesChanges ) {\n\t\tunmountableContent = (\n\t\t\t<div className=\"editor-layout__toggle-publish-panel\">\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tclassName=\"editor-layout__toggle-publish-panel-button\"\n\t\t\t\t\tonClick={ togglePublishSidebar }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open publish panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t} else {\n\t\tunmountableContent = (\n\t\t\t<div className=\"editor-layout__toggle-entities-saved-states-panel\">\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tclassName=\"editor-layout__toggle-entities-saved-states-panel-button\"\n\t\t\t\t\tonClick={ openEntitiesSavedStates }\n\t\t\t\t\taria-expanded={ false }\n\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Open save panel' ) }\n\t\t\t\t</Button>\n\t\t\t</div>\n\t\t);\n\t}\n\n\t// Since EntitiesSavedStates controls its own panel, we can keep it\n\t// always mounted to retain its own component state (such as checkboxes).\n\treturn (\n\t\t<>\n\t\t\t{ isEntitiesSavedStatesOpen && (\n\t\t\t\t<EntitiesSavedStates close={ closeEntitiesSavedStates } />\n\t\t\t) }\n\t\t\t<Slot bubblesVirtually />\n\t\t\t{ ! isEntitiesSavedStatesOpen && unmountableContent }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,MAAM,EAAEC,cAAc,QAAQ,uBAAuB;AAC9D,SAASC,EAAE,QAAQ,iBAAiB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+C,KAAK,EAAG7B;IAA0B,CAAE,CACzD,eACDV,IAAA,CAACM,IAAI;MAACkC,gBAAgB;IAAA,CAAE,CAAC,EACvB,CAAE7B,yBAAyB,IAAIiB,kBAAkB;EAAA,CAClD,CAAC;AAEL","ignoreList":[]}
|
|
@@ -13,6 +13,8 @@ import { store as blocksStore } from '@wordpress/blocks';
|
|
|
13
13
|
*/
|
|
14
14
|
import { store as editorStore } from '../store';
|
|
15
15
|
import { unlock } from '../lock-unlock';
|
|
16
|
+
|
|
17
|
+
/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
|
|
16
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
19
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -35,7 +37,7 @@ const {
|
|
|
35
37
|
* @return {Component} Wrapped component.
|
|
36
38
|
*/
|
|
37
39
|
const withPatternOverrideControls = createHigherOrderComponent(BlockEdit => props => {
|
|
38
|
-
const isSupportedBlock =
|
|
40
|
+
const isSupportedBlock = !!PARTIAL_SYNCING_SUPPORTED_BLOCKS[props.name];
|
|
39
41
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
40
42
|
children: [/*#__PURE__*/_jsx(BlockEdit, {
|
|
41
43
|
...props
|
|
@@ -43,7 +45,7 @@ const withPatternOverrideControls = createHigherOrderComponent(BlockEdit => prop
|
|
|
43
45
|
...props
|
|
44
46
|
}), isSupportedBlock && /*#__PURE__*/_jsx(PatternOverridesBlockControls, {})]
|
|
45
47
|
});
|
|
46
|
-
});
|
|
48
|
+
}, 'withPatternOverrideControls');
|
|
47
49
|
|
|
48
50
|
// Split into a separate component to avoid a store subscription
|
|
49
51
|
// on every block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","blocksStore","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","
|
|
1
|
+
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","blocksStore","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","name","children","isSelected","ControlsWithStoreSubscription","blockEditingMode","hasPatternOverridesSource","isEditingSyncedPattern","select","getBlockBindingsSource","getCurrentPostType","getEditedPostAttribute","user","wp_pattern_sync_status","unsynced","bindings","attributes","metadata","hasPatternBindings","Object","values","some","binding","source","shouldShowPatternOverridesControls","shouldShowResetOverridesControl"],"sources":["@wordpress/editor/src/hooks/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useBlockEditingMode } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\nconst {\n\tPatternOverridesControls,\n\tResetOverridesControl,\n\tPatternOverridesBlockControls,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternsPrivateApis );\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning a partial syncing controls to supported blocks in the pattern editor.\n * Currently, only the `core/paragraph` block is supported.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withPatternOverrideControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isSupportedBlock =\n\t\t\t!! PARTIAL_SYNCING_SUPPORTED_BLOCKS[ props.name ];\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ props.isSelected && isSupportedBlock && (\n\t\t\t\t\t<ControlsWithStoreSubscription { ...props } />\n\t\t\t\t) }\n\t\t\t\t{ isSupportedBlock && <PatternOverridesBlockControls /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withPatternOverrideControls'\n);\n\n// Split into a separate component to avoid a store subscription\n// on every block.\nfunction ControlsWithStoreSubscription( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst { hasPatternOverridesSource, isEditingSyncedPattern } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockBindingsSource } = unlock( select( blocksStore ) );\n\t\t\tconst { getCurrentPostType, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\n\t\t\treturn {\n\t\t\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\t\t\thasPatternOverridesSource: !! getBlockBindingsSource(\n\t\t\t\t\t'core/pattern-overrides'\n\t\t\t\t),\n\t\t\t\tisEditingSyncedPattern:\n\t\t\t\t\tgetCurrentPostType() === PATTERN_TYPES.user &&\n\t\t\t\t\tgetEditedPostAttribute( 'meta' )?.wp_pattern_sync_status !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced &&\n\t\t\t\t\tgetEditedPostAttribute( 'wp_pattern_sync_status' ) !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst bindings = props.attributes.metadata?.bindings;\n\tconst hasPatternBindings =\n\t\t!! bindings &&\n\t\tObject.values( bindings ).some(\n\t\t\t( binding ) => binding.source === 'core/pattern-overrides'\n\t\t);\n\n\tconst shouldShowPatternOverridesControls =\n\t\tisEditingSyncedPattern && blockEditingMode === 'default';\n\tconst shouldShowResetOverridesControl =\n\t\t! isEditingSyncedPattern &&\n\t\t!! props.attributes.metadata?.name &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\tif ( ! hasPatternOverridesSource ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldShowPatternOverridesControls && (\n\t\t\t\t<PatternOverridesControls { ...props } />\n\t\t\t) }\n\t\t\t{ shouldShowResetOverridesControl && (\n\t\t\t\t<ResetOverridesControl { ...props } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/with-pattern-override-controls',\n\twithPatternOverrideControls\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,IAAIC,mBAAmB,QAAQ,qBAAqB;AACxE,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEA,MAAM;EACLC,wBAAwB;EACxBC,qBAAqB;EACrBC,6BAA6B;EAC7BC,aAAa;EACbC,gCAAgC;EAChCC;AACD,CAAC,GAAGZ,MAAM,CAAEP,mBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMoB,2BAA2B,GAAGnB,0BAA0B,CA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XI,MAAM,CAACC,MAAM,CAAEL,QAAS,CAAC,CAACM,IAAI,CAC3BC,OAAO,IAAMA,OAAO,CAACC,MAAM,KAAK,wBACnC,CAAC;EAEF,MAAMC,kCAAkC,GACvCjB,sBAAsB,IAAIF,gBAAgB,KAAK,SAAS;EACzD,MAAMoB,+BAA+B,GACpC,CAAElB,sBAAsB,IACxB,CAAC,CAAER,KAAK,CAACiB,UAAU,CAACC,QAAQ,EAAEhB,IAAI,IAClCI,gBAAgB,KAAK,UAAU,IAC/Ba,kBAAkB;EAEnB,IAAK,CAAEZ,yBAAyB,EAAG;IAClC,OAAO,IAAI;EACZ;EAEA,oBACChB,KAAA,CAAAF,SAAA;IAAAc,QAAA,GACGsB,kCAAkC,iBACnCtC,IAAA,CAACK,wBAAwB;MAAA,GAAMQ;IAAK,CAAI,CACxC,EACC0B,+BAA+B,iBAChCvC,IAAA,CAACM,qBAAqB;MAAA,GAAMO;IAAK,CAAI,CACrC;EAAA,CACA,CAAC;AAEL;AAEAxB,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5CsB,2BACD,CAAC","ignoreList":[]}
|
|
@@ -253,6 +253,7 @@ export const revertTemplate = (template, {
|
|
|
253
253
|
export const removeTemplates = items => async ({
|
|
254
254
|
registry
|
|
255
255
|
}) => {
|
|
256
|
+
const isResetting = items.every(item => !!item && (item.has_theme_file || item.templatePart && item.templatePart.has_theme_file));
|
|
256
257
|
const promiseResult = await Promise.allSettled(items.map(item => {
|
|
257
258
|
return registry.dispatch(coreStore).deleteEntityRecord('postType', item.type, item.id, {
|
|
258
259
|
force: true
|
|
@@ -270,10 +271,11 @@ export const removeTemplates = items => async ({
|
|
|
270
271
|
// Depending on how the entity was retrieved its title might be
|
|
271
272
|
// an object or simple string.
|
|
272
273
|
const title = typeof items[0].title === 'string' ? items[0].title : items[0].title?.rendered;
|
|
273
|
-
successMessage = sprintf( /* translators: The template/part's name. */
|
|
274
|
+
successMessage = isResetting ? sprintf( /* translators: The template/part's name. */
|
|
275
|
+
__('"%s" reset.'), decodeEntities(title)) : sprintf( /* translators: The template/part's name. */
|
|
274
276
|
__('"%s" deleted.'), decodeEntities(title));
|
|
275
277
|
} else {
|
|
276
|
-
successMessage = __('Items deleted.');
|
|
278
|
+
successMessage = isResetting ? __('Items reset.') : __('Items deleted.');
|
|
277
279
|
}
|
|
278
280
|
registry.dispatch(noticesStore).createSuccessNotice(successMessage, {
|
|
279
281
|
type: 'snackbar',
|
|
@@ -287,7 +289,7 @@ export const removeTemplates = items => async ({
|
|
|
287
289
|
if (promiseResult[0].reason?.message) {
|
|
288
290
|
errorMessage = promiseResult[0].reason.message;
|
|
289
291
|
} else {
|
|
290
|
-
errorMessage = __('An error occurred while deleting the item.');
|
|
292
|
+
errorMessage = isResetting ? __('An error occurred while reverting the item.') : __('An error occurred while deleting the item.');
|
|
291
293
|
}
|
|
292
294
|
// If we were trying to delete a multiple templates
|
|
293
295
|
} else {
|
|
@@ -303,10 +305,12 @@ export const removeTemplates = items => async ({
|
|
|
303
305
|
if (errorMessages.size === 0) {
|
|
304
306
|
errorMessage = __('An error occurred while deleting the items.');
|
|
305
307
|
} else if (errorMessages.size === 1) {
|
|
306
|
-
errorMessage = sprintf( /* translators: %s: an error message */
|
|
308
|
+
errorMessage = isResetting ? sprintf( /* translators: %s: an error message */
|
|
309
|
+
__('An error occurred while reverting the items: %s'), [...errorMessages][0]) : sprintf( /* translators: %s: an error message */
|
|
307
310
|
__('An error occurred while deleting the items: %s'), [...errorMessages][0]);
|
|
308
311
|
} else {
|
|
309
|
-
sprintf( /* translators: %s: a list of comma separated error messages */
|
|
312
|
+
errorMessage = isResetting ? sprintf( /* translators: %s: a list of comma separated error messages */
|
|
313
|
+
__('Some errors occurred while reverting the items: %s'), [...errorMessages].join(',')) : sprintf( /* translators: %s: a list of comma separated error messages */
|
|
310
314
|
__('Some errors occurred while deleting the items: %s'), [...errorMessages].join(','));
|
|
311
315
|
}
|
|
312
316
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","coreStore","__","sprintf","noticesStore","blockEditorStore","preferencesStore","addQueryArgs","apiFetch","parse","__unstableSerializeAndClean","decodeEntities","isTemplateRevertable","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","createSuccessNotice","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","get","newBlockNames","filter","Array","isArray","includes","set","hideBlockTypes","_registry$select$get2","mergedBlockNames","Set","saveDirtyEntities","onSave","dirtyEntityRecords","entitiesToSkip","close","PUBLISH_ON_SAVE_ENTITIES","kind","name","saveNoticeId","homeUrl","getUnstableBase","home","removeNotice","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","templateEntityConfig","getEntityConfig","fileTemplatePath","baseURL","context","source","fileTemplate","path","serializeBlocks","blocks","blocksForSerialization","edited","getEditedEntityRecord","content","undoIgnore","raw","undoRevert","errorMessage","message","code","removeTemplates","items","promiseResult","allSettled","map","item","deleteEntityRecord","force","throwOnError","every","successMessage","title","rendered","reason","errorMessages","failedPromises","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\treturn savedTemplate;\n\t};\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 =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\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 =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n */\nexport const saveDirtyEntities =\n\t( { onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry.select( coreStore ).getUnstableBase()?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: 'theme' }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with sucess.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tconst title =\n\t\t\t\t\ttypeof items[ 0 ].title === 'string'\n\t\t\t\t\t\t? items[ 0 ].title\n\t\t\t\t\t\t: items[ 0 ].title?.rendered;\n\t\t\t\tsuccessMessage = sprintf(\n\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsuccessMessage = __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the item.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = sprintf(\n\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t__( 'An error occurred while deleting the items: %s' ),\n\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASH,KAAK,IAAII,Y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ACND,YAAY,GAAGzG,EAAE,CAChB,4CACD,CAAC;MACF;MACA;IACD,CAAC,MAAM;MACN,MAAM0H,aAAa,GAAG,IAAI5E,GAAG,CAAC,CAAC;MAC/B,MAAM6E,cAAc,GAAGb,aAAa,CAACxE,MAAM,CAC1C,CAAE;QAAEgC;MAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;MACD,KAAM,MAAMsD,aAAa,IAAID,cAAc,EAAG;QAC7C,IAAKC,aAAa,CAACH,MAAM,EAAEf,OAAO,EAAG;UACpCgB,aAAa,CAACG,GAAG,CAAED,aAAa,CAACH,MAAM,CAACf,OAAQ,CAAC;QAClD;MACD;MACA,IAAKgB,aAAa,CAACI,IAAI,KAAK,CAAC,EAAG;QAC/BrB,YAAY,GAAGzG,EAAE,CAChB,6CACD,CAAC;MACF,CAAC,MAAM,IAAK0H,aAAa,CAACI,IAAI,KAAK,CAAC,EAAG;QACtCrB,YAAY,GAAGxG,OAAO,EACrB;QACAD,EAAE,CAAE,gDAAiD,CAAC,EACtD,CAAE,GAAG0H,aAAa,CAAE,CAAE,CAAC,CACxB,CAAC;MACF,CAAC,MAAM;QACNzH,OAAO,EACN;QACAD,EAAE,CACD,mDACD,CAAC,EACD,CAAE,GAAG0H,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAChC,CAAC;MACF;IACD;IACA7G,QAAQ,CACND,QAAQ,CAAEf,YAAa,CAAC,CACxB+E,iBAAiB,CAAEwB,YAAY,EAAE;MAAE5F,IAAI,EAAE;IAAW,CAAE,CAAC;EAC1D;AACD,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["store","coreStore","__","sprintf","noticesStore","blockEditorStore","preferencesStore","addQueryArgs","apiFetch","parse","__unstableSerializeAndClean","decodeEntities","isTemplateRevertable","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","createSuccessNotice","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","get","newBlockNames","filter","Array","isArray","includes","set","hideBlockTypes","_registry$select$get2","mergedBlockNames","Set","saveDirtyEntities","onSave","dirtyEntityRecords","entitiesToSkip","close","PUBLISH_ON_SAVE_ENTITIES","kind","name","saveNoticeId","homeUrl","getUnstableBase","home","removeNotice","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","templateEntityConfig","getEntityConfig","fileTemplatePath","baseURL","context","source","fileTemplate","path","serializeBlocks","blocks","blocksForSerialization","edited","getEditedEntityRecord","content","undoIgnore","raw","undoRevert","errorMessage","message","code","removeTemplates","items","isResetting","every","item","has_theme_file","templatePart","promiseResult","allSettled","map","deleteEntityRecord","force","throwOnError","successMessage","title","rendered","reason","errorMessages","failedPromises","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {Object?} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\treturn savedTemplate;\n\t};\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 =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\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 =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n */\nexport const saveDirtyEntities =\n\t( { onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry.select( coreStore ).getUnstableBase()?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: 'theme' }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst isResetting = items.every(\n\t\t\t( item ) =>\n\t\t\t\t!! item &&\n\t\t\t\t( item.has_theme_file ||\n\t\t\t\t\t( item.templatePart && item.templatePart.has_theme_file ) )\n\t\t);\n\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with sucess.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tconst title =\n\t\t\t\t\ttypeof items[ 0 ].title === 'string'\n\t\t\t\t\t\t? items[ 0 ].title\n\t\t\t\t\t\t: items[ 0 ].title?.rendered;\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t );\n\t\t\t} else {\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? __( 'An error occurred while reverting the item.' )\n\t\t\t\t\t\t: __( 'An error occurred while deleting the item.' );\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASH,KAAK,IAAII,YAAY,QAAQ,oBAAoB;AAC1D,SAASJ,KAAK,IAAIK,gBAAgB,QAAQ,yBAAyB;AACnE,SAASL,KAAK,IAAIM,gBAAgB,QAAQ,wBAAwB;AAClE,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,KAAK,EAAEC,2BAA2B,QAAQ,mBAAmB;AACtE,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,gCAAgC;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAEC,EAAE,EAAG;EAC1C,OAAO;IACNC,IAAI,EAAE,yBAAyB;IAC/BD;EACD,CAAC;AACF;;AAEA;AACA;AACA;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CAAC,CAAC;MAC/B,MAAMgF,cAAc,GAAGX,aAAa,CAAC7E,MAAM,CAC1C,CAAE;QAAEgC;MAAO,CAAC,KAAMA,MAAM,KAAK,UAC9B,CAAC;MACD,KAAM,MAAMyD,aAAa,IAAID,cAAc,EAAG;QAC7C,IAAKC,aAAa,CAACH,MAAM,EAAElB,OAAO,EAAG;UACpCmB,aAAa,CAACG,GAAG,CAAED,aAAa,CAACH,MAAM,CAAClB,OAAQ,CAAC;QAClD;MACD;MACA,IAAKmB,aAAa,CAACI,IAAI,KAAK,CAAC,EAAG;QAC/BxB,YAAY,GAAGzG,EAAE,CAChB,6CACD,CAAC;MACF,CAAC,MAAM,IAAK6H,aAAa,CAACI,IAAI,KAAK,CAAC,EAAG;QACtCxB,YAAY,GAAGK,WAAW,GACvB7G,OAAO,EACP;QACAD,EAAE,CACD,iDACD,CAAC,EACD,CAAE,GAAG6H,aAAa,CAAE,CAAE,CAAC,CACvB,CAAC,GACD5H,OAAO,EACP;QACAD,EAAE,CACD,gDACD,CAAC,EACD,CAAE,GAAG6H,aAAa,CAAE,CAAE,CAAC,CACvB,CAAC;MACL,CAAC,MAAM;QACNpB,YAAY,GAAGK,WAAW,GACvB7G,OAAO,EACP;QACAD,EAAE,CACD,oDACD,CAAC,EACD,CAAE,GAAG6H,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAC/B,CAAC,GACDjI,OAAO,EACP;QACAD,EAAE,CACD,mDACD,CAAC,EACD,CAAE,GAAG6H,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAC/B,CAAC;MACL;IACD;IACAhH,QAAQ,CACND,QAAQ,CAAEf,YAAa,CAAC,CACxB+E,iBAAiB,CAAEwB,YAAY,EAAE;MAAE5F,IAAI,EAAE;IAAW,CAAE,CAAC;EAC1D;AACD,CAAC","ignoreList":[]}
|
|
@@ -1457,6 +1457,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
1457
1457
|
flex-wrap: wrap;
|
|
1458
1458
|
column-gap: 8px;
|
|
1459
1459
|
row-gap: 4px;
|
|
1460
|
+
word-break: break-word;
|
|
1460
1461
|
}
|
|
1461
1462
|
.editor-post-card-panel__icon {
|
|
1462
1463
|
flex: 0 0 24px;
|
|
@@ -1541,6 +1542,17 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
1541
1542
|
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
1542
1543
|
opacity: 1;
|
|
1543
1544
|
}
|
|
1545
|
+
.editor-post-featured-image__container .components-drop-zone__content {
|
|
1546
|
+
border-radius: 2px;
|
|
1547
|
+
}
|
|
1548
|
+
.editor-post-featured-image__container:has(.editor-post-featured-image__toggle) .components-drop-zone .components-drop-zone__content-inner {
|
|
1549
|
+
display: flex;
|
|
1550
|
+
align-items: center;
|
|
1551
|
+
gap: 8px;
|
|
1552
|
+
}
|
|
1553
|
+
.editor-post-featured-image__container:has(.editor-post-featured-image__toggle) .components-drop-zone .components-drop-zone__content-inner .components-drop-zone__content-icon {
|
|
1554
|
+
margin: 0;
|
|
1555
|
+
}
|
|
1544
1556
|
|
|
1545
1557
|
.editor-post-featured-image__toggle,
|
|
1546
1558
|
.editor-post-featured-image__preview {
|
|
@@ -1882,7 +1894,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
1882
1894
|
position: fixed;
|
|
1883
1895
|
z-index: 100001;
|
|
1884
1896
|
background: #fff;
|
|
1885
|
-
top:
|
|
1897
|
+
top: 46px;
|
|
1886
1898
|
bottom: 0;
|
|
1887
1899
|
left: 0;
|
|
1888
1900
|
right: 0;
|
|
@@ -2165,6 +2177,10 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2165
2177
|
padding-inline-start: 0 !important;
|
|
2166
2178
|
}
|
|
2167
2179
|
|
|
2180
|
+
.editor-post-url__panel-toggle {
|
|
2181
|
+
word-break: break-word;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2168
2184
|
.editor-post-visibility__fieldset .editor-post-visibility__radio[type=radio] {
|
|
2169
2185
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
2170
2186
|
padding: 6px 8px;
|
|
@@ -2642,6 +2658,7 @@ h3.components-heading.editor-template-areas__title {
|
|
|
2642
2658
|
height: 100%;
|
|
2643
2659
|
display: block;
|
|
2644
2660
|
background-color: #ddd;
|
|
2661
|
+
isolation: isolate;
|
|
2645
2662
|
align-items: center;
|
|
2646
2663
|
}
|
|
2647
2664
|
.editor-visual-editor.is-resizable {
|
|
@@ -2650,7 +2667,7 @@ h3.components-heading.editor-template-areas__title {
|
|
|
2650
2667
|
.editor-visual-editor.has-padding {
|
|
2651
2668
|
padding: 24px 24px 0;
|
|
2652
2669
|
}
|
|
2653
|
-
.editor-visual-editor
|
|
2670
|
+
.editor-visual-editor.is-iframed {
|
|
2654
2671
|
overflow: hidden;
|
|
2655
2672
|
}
|
|
2656
2673
|
.editor-visual-editor .components-button {
|
package/build-style/style.css
CHANGED
|
@@ -1457,6 +1457,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
1457
1457
|
flex-wrap: wrap;
|
|
1458
1458
|
column-gap: 8px;
|
|
1459
1459
|
row-gap: 4px;
|
|
1460
|
+
word-break: break-word;
|
|
1460
1461
|
}
|
|
1461
1462
|
.editor-post-card-panel__icon {
|
|
1462
1463
|
flex: 0 0 24px;
|
|
@@ -1541,6 +1542,17 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
1541
1542
|
.editor-post-featured-image__container:hover .editor-post-featured-image__actions, .editor-post-featured-image__container:focus .editor-post-featured-image__actions, .editor-post-featured-image__container:focus-within .editor-post-featured-image__actions {
|
|
1542
1543
|
opacity: 1;
|
|
1543
1544
|
}
|
|
1545
|
+
.editor-post-featured-image__container .components-drop-zone__content {
|
|
1546
|
+
border-radius: 2px;
|
|
1547
|
+
}
|
|
1548
|
+
.editor-post-featured-image__container:has(.editor-post-featured-image__toggle) .components-drop-zone .components-drop-zone__content-inner {
|
|
1549
|
+
display: flex;
|
|
1550
|
+
align-items: center;
|
|
1551
|
+
gap: 8px;
|
|
1552
|
+
}
|
|
1553
|
+
.editor-post-featured-image__container:has(.editor-post-featured-image__toggle) .components-drop-zone .components-drop-zone__content-inner .components-drop-zone__content-icon {
|
|
1554
|
+
margin: 0;
|
|
1555
|
+
}
|
|
1544
1556
|
|
|
1545
1557
|
.editor-post-featured-image__toggle,
|
|
1546
1558
|
.editor-post-featured-image__preview {
|
|
@@ -1882,7 +1894,7 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
1882
1894
|
position: fixed;
|
|
1883
1895
|
z-index: 100001;
|
|
1884
1896
|
background: #fff;
|
|
1885
|
-
top:
|
|
1897
|
+
top: 46px;
|
|
1886
1898
|
bottom: 0;
|
|
1887
1899
|
right: 0;
|
|
1888
1900
|
left: 0;
|
|
@@ -2169,6 +2181,10 @@ textarea.editor-post-text-editor:-ms-input-placeholder {
|
|
|
2169
2181
|
padding-inline-start: 0 !important;
|
|
2170
2182
|
}
|
|
2171
2183
|
|
|
2184
|
+
.editor-post-url__panel-toggle {
|
|
2185
|
+
word-break: break-word;
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2172
2188
|
.editor-post-visibility__fieldset .editor-post-visibility__radio[type=radio] {
|
|
2173
2189
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
2174
2190
|
padding: 6px 8px;
|
|
@@ -2646,6 +2662,7 @@ h3.components-heading.editor-template-areas__title {
|
|
|
2646
2662
|
height: 100%;
|
|
2647
2663
|
display: block;
|
|
2648
2664
|
background-color: #ddd;
|
|
2665
|
+
isolation: isolate;
|
|
2649
2666
|
align-items: center;
|
|
2650
2667
|
}
|
|
2651
2668
|
.editor-visual-editor.is-resizable {
|
|
@@ -2654,7 +2671,7 @@ h3.components-heading.editor-template-areas__title {
|
|
|
2654
2671
|
.editor-visual-editor.has-padding {
|
|
2655
2672
|
padding: 24px 24px 0;
|
|
2656
2673
|
}
|
|
2657
|
-
.editor-visual-editor
|
|
2674
|
+
.editor-visual-editor.is-iframed {
|
|
2658
2675
|
overflow: hidden;
|
|
2659
2676
|
}
|
|
2660
2677
|
.editor-visual-editor .components-button {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.4",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@wordpress/a11y": "^4.0.1",
|
|
36
36
|
"@wordpress/api-fetch": "^7.0.1",
|
|
37
37
|
"@wordpress/blob": "^4.0.1",
|
|
38
|
-
"@wordpress/block-editor": "^13.0.
|
|
39
|
-
"@wordpress/blocks": "^13.0.
|
|
40
|
-
"@wordpress/commands": "^1.0.
|
|
41
|
-
"@wordpress/components": "^28.0.
|
|
38
|
+
"@wordpress/block-editor": "^13.0.4",
|
|
39
|
+
"@wordpress/blocks": "^13.0.3",
|
|
40
|
+
"@wordpress/commands": "^1.0.3",
|
|
41
|
+
"@wordpress/components": "^28.0.3",
|
|
42
42
|
"@wordpress/compose": "^7.0.1",
|
|
43
|
-
"@wordpress/core-data": "^7.0.
|
|
43
|
+
"@wordpress/core-data": "^7.0.4",
|
|
44
44
|
"@wordpress/data": "^10.0.2",
|
|
45
45
|
"@wordpress/date": "^5.0.1",
|
|
46
46
|
"@wordpress/deprecated": "^4.0.1",
|
|
@@ -49,19 +49,19 @@
|
|
|
49
49
|
"@wordpress/hooks": "^4.0.1",
|
|
50
50
|
"@wordpress/html-entities": "^4.0.1",
|
|
51
51
|
"@wordpress/i18n": "^5.0.1",
|
|
52
|
-
"@wordpress/icons": "^10.0.
|
|
53
|
-
"@wordpress/interface": "^6.0.
|
|
52
|
+
"@wordpress/icons": "^10.0.2",
|
|
53
|
+
"@wordpress/interface": "^6.0.3",
|
|
54
54
|
"@wordpress/keyboard-shortcuts": "^5.0.2",
|
|
55
55
|
"@wordpress/keycodes": "^4.0.1",
|
|
56
56
|
"@wordpress/media-utils": "^5.0.1",
|
|
57
57
|
"@wordpress/notices": "^5.0.2",
|
|
58
|
-
"@wordpress/patterns": "^2.0.
|
|
59
|
-
"@wordpress/plugins": "^7.0.
|
|
60
|
-
"@wordpress/preferences": "^4.0.
|
|
58
|
+
"@wordpress/patterns": "^2.0.4",
|
|
59
|
+
"@wordpress/plugins": "^7.0.3",
|
|
60
|
+
"@wordpress/preferences": "^4.0.3",
|
|
61
61
|
"@wordpress/private-apis": "^1.0.2",
|
|
62
|
-
"@wordpress/reusable-blocks": "^5.0.
|
|
62
|
+
"@wordpress/reusable-blocks": "^5.0.4",
|
|
63
63
|
"@wordpress/rich-text": "^7.0.2",
|
|
64
|
-
"@wordpress/server-side-render": "^5.0.
|
|
64
|
+
"@wordpress/server-side-render": "^5.0.3",
|
|
65
65
|
"@wordpress/url": "^4.0.1",
|
|
66
66
|
"@wordpress/warning": "^3.0.1",
|
|
67
67
|
"@wordpress/wordcount": "^4.0.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "85486692a3e48b7d863226cf895a21d787434921"
|
|
87
87
|
}
|
|
@@ -9,23 +9,22 @@ const CONTENT = 'content';
|
|
|
9
9
|
export default {
|
|
10
10
|
name: 'core/pattern-overrides',
|
|
11
11
|
label: _x( 'Pattern Overrides', 'block bindings source' ),
|
|
12
|
-
getValue( { registry, clientId, attributeName } ) {
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
getValue( { registry, clientId, context, attributeName } ) {
|
|
13
|
+
const patternOverridesContent = context[ 'pattern/overrides' ];
|
|
14
|
+
const { getBlockAttributes } = registry.select( blockEditorStore );
|
|
15
15
|
const currentBlockAttributes = getBlockAttributes( clientId );
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
);
|
|
16
|
+
|
|
17
|
+
if ( ! patternOverridesContent ) {
|
|
18
|
+
return currentBlockAttributes[ attributeName ];
|
|
19
|
+
}
|
|
21
20
|
|
|
22
21
|
const overridableValue =
|
|
23
|
-
|
|
22
|
+
patternOverridesContent?.[
|
|
24
23
|
currentBlockAttributes?.metadata?.name
|
|
25
24
|
]?.[ attributeName ];
|
|
26
25
|
|
|
27
26
|
// If there is no pattern client ID, or it is not overwritten, return the default value.
|
|
28
|
-
if (
|
|
27
|
+
if ( overridableValue === undefined ) {
|
|
29
28
|
return currentBlockAttributes[ attributeName ];
|
|
30
29
|
}
|
|
31
30
|
|
|
@@ -29,6 +29,7 @@ function Editor( {
|
|
|
29
29
|
className,
|
|
30
30
|
styles,
|
|
31
31
|
customSaveButton,
|
|
32
|
+
customSavePanel,
|
|
32
33
|
forceDisableBlockTools,
|
|
33
34
|
title,
|
|
34
35
|
iframeProps,
|
|
@@ -58,6 +59,10 @@ function Editor( {
|
|
|
58
59
|
[ postType, postId, templateId ]
|
|
59
60
|
);
|
|
60
61
|
|
|
62
|
+
if ( ! post ) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
61
66
|
return (
|
|
62
67
|
<ExperimentalEditorProvider
|
|
63
68
|
post={ post }
|
|
@@ -77,6 +82,7 @@ function Editor( {
|
|
|
77
82
|
styles={ styles }
|
|
78
83
|
enableRegionNavigation={ enableRegionNavigation }
|
|
79
84
|
customSaveButton={ customSaveButton }
|
|
85
|
+
customSavePanel={ customSavePanel }
|
|
80
86
|
forceDisableBlockTools={ forceDisableBlockTools }
|
|
81
87
|
title={ title }
|
|
82
88
|
iframeProps={ iframeProps }
|