@wordpress/editor 14.8.5 → 14.8.7
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/api.js +2 -5
- package/build/bindings/api.js.map +1 -1
- package/build/bindings/pattern-overrides.js +7 -6
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/bindings/post-meta.js +16 -16
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/header/index.js +3 -1
- package/build/components/header/index.js.map +1 -1
- package/build/hooks/pattern-overrides.js +1 -4
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build-module/bindings/api.js +1 -4
- package/build-module/bindings/api.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +7 -6
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/bindings/post-meta.js +16 -16
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/header/index.js +3 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +1 -4
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-types/bindings/api.d.ts.map +1 -1
- package/build-types/bindings/pattern-overrides.d.ts +5 -4
- package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
- package/build-types/bindings/post-meta.d.ts +8 -8
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/bindings/api.js +1 -2
- package/src/bindings/pattern-overrides.js +27 -30
- package/src/bindings/post-meta.js +28 -30
- package/src/components/header/index.js +6 -1
- package/src/hooks/pattern-overrides.js +1 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -15,8 +15,8 @@ import { unlock } from '../lock-unlock';
|
|
|
15
15
|
* If the value is not available based on context, like in templates,
|
|
16
16
|
* it falls back to the default value, label, or key.
|
|
17
17
|
*
|
|
18
|
-
* @param {Object}
|
|
19
|
-
* @param {Object} context
|
|
18
|
+
* @param {Object} select The select function from the data store.
|
|
19
|
+
* @param {Object} context The context provided.
|
|
20
20
|
* @return {Object} List of post meta fields with their value and label.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
@@ -34,13 +34,13 @@ import { unlock } from '../lock-unlock';
|
|
|
34
34
|
* }
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
function getPostMetaFields(
|
|
37
|
+
function getPostMetaFields(select, context) {
|
|
38
38
|
const {
|
|
39
39
|
getEditedEntityRecord
|
|
40
|
-
} =
|
|
40
|
+
} = select(coreDataStore);
|
|
41
41
|
const {
|
|
42
42
|
getRegisteredPostMeta
|
|
43
|
-
} = unlock(
|
|
43
|
+
} = unlock(select(coreDataStore));
|
|
44
44
|
let entityMetaValues;
|
|
45
45
|
// Try to get the current entity meta values.
|
|
46
46
|
if (context?.postType && context?.postId) {
|
|
@@ -69,11 +69,11 @@ function getPostMetaFields(registry, context) {
|
|
|
69
69
|
export default {
|
|
70
70
|
name: 'core/post-meta',
|
|
71
71
|
getValues({
|
|
72
|
-
|
|
72
|
+
select,
|
|
73
73
|
context,
|
|
74
74
|
bindings
|
|
75
75
|
}) {
|
|
76
|
-
const metaFields = getPostMetaFields(
|
|
76
|
+
const metaFields = getPostMetaFields(select, context);
|
|
77
77
|
const newValues = {};
|
|
78
78
|
for (const [attributeName, source] of Object.entries(bindings)) {
|
|
79
79
|
var _ref;
|
|
@@ -88,7 +88,7 @@ export default {
|
|
|
88
88
|
return newValues;
|
|
89
89
|
},
|
|
90
90
|
setValues({
|
|
91
|
-
|
|
91
|
+
dispatch,
|
|
92
92
|
context,
|
|
93
93
|
bindings
|
|
94
94
|
}) {
|
|
@@ -99,12 +99,12 @@ export default {
|
|
|
99
99
|
}) => {
|
|
100
100
|
newMeta[args.key] = newValue;
|
|
101
101
|
});
|
|
102
|
-
|
|
102
|
+
dispatch(coreDataStore).editEntityRecord('postType', context?.postType, context?.postId, {
|
|
103
103
|
meta: newMeta
|
|
104
104
|
});
|
|
105
105
|
},
|
|
106
106
|
canUserEditValue({
|
|
107
|
-
|
|
107
|
+
select,
|
|
108
108
|
context,
|
|
109
109
|
args
|
|
110
110
|
}) {
|
|
@@ -112,25 +112,25 @@ export default {
|
|
|
112
112
|
if (context?.query || context?.queryId) {
|
|
113
113
|
return false;
|
|
114
114
|
}
|
|
115
|
-
const postType = context?.postType ||
|
|
115
|
+
const postType = context?.postType || select(editorStore).getCurrentPostType();
|
|
116
116
|
|
|
117
117
|
// Check that editing is happening in the post editor and not a template.
|
|
118
118
|
if (postType === 'wp_template') {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
|
-
const fieldValue = getPostMetaFields(
|
|
121
|
+
const fieldValue = getPostMetaFields(select, context)?.[args.key]?.value;
|
|
122
122
|
// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
|
|
123
123
|
if (fieldValue === undefined) {
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
126
|
// Check that custom fields metabox is not enabled.
|
|
127
|
-
const areCustomFieldsEnabled =
|
|
127
|
+
const areCustomFieldsEnabled = select(editorStore).getEditorSettings().enableCustomFields;
|
|
128
128
|
if (areCustomFieldsEnabled) {
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// Check that the user has the capability to edit post meta.
|
|
133
|
-
const canUserEdit =
|
|
133
|
+
const canUserEdit = select(coreDataStore).canUser('update', {
|
|
134
134
|
kind: 'postType',
|
|
135
135
|
name: context?.postType,
|
|
136
136
|
id: context?.postId
|
|
@@ -141,10 +141,10 @@ export default {
|
|
|
141
141
|
return true;
|
|
142
142
|
},
|
|
143
143
|
getFieldsList({
|
|
144
|
-
|
|
144
|
+
select,
|
|
145
145
|
context
|
|
146
146
|
}) {
|
|
147
|
-
return getPostMetaFields(
|
|
147
|
+
return getPostMetaFields(select, context);
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
//# sourceMappingURL=post-meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","coreDataStore","editorStore","unlock","getPostMetaFields","
|
|
1
|
+
{"version":3,"names":["store","coreDataStore","editorStore","unlock","getPostMetaFields","select","context","getEditedEntityRecord","getRegisteredPostMeta","entityMetaValues","postType","postId","meta","registeredFields","metaFields","Object","entries","forEach","key","props","charAt","_entityMetaValues$key","label","title","value","default","undefined","keys","length","name","getValues","bindings","newValues","attributeName","source","_ref","fieldKey","args","fieldValue","fieldLabel","setValues","dispatch","newMeta","values","newValue","editEntityRecord","canUserEditValue","query","queryId","getCurrentPostType","areCustomFieldsEnabled","getEditorSettings","enableCustomFields","canUserEdit","canUser","kind","id","getFieldsList"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Gets a list of post meta fields with their values and labels\n * to be consumed in the needed callbacks.\n * If the value is not available based on context, like in templates,\n * it falls back to the default value, label, or key.\n *\n * @param {Object} select The select function from the data store.\n * @param {Object} context The context provided.\n * @return {Object} List of post meta fields with their value and label.\n *\n * @example\n * ```js\n * {\n * field_1_key: {\n * label: 'Field 1 Label',\n * value: 'Field 1 Value',\n * },\n * field_2_key: {\n * label: 'Field 2 Label',\n * value: 'Field 2 Value',\n * },\n * ...\n * }\n * ```\n */\nfunction getPostMetaFields( select, context ) {\n\tconst { getEditedEntityRecord } = select( coreDataStore );\n\tconst { getRegisteredPostMeta } = unlock( select( coreDataStore ) );\n\n\tlet entityMetaValues;\n\t// Try to get the current entity meta values.\n\tif ( context?.postType && context?.postId ) {\n\t\tentityMetaValues = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId\n\t\t).meta;\n\t}\n\n\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\tconst metaFields = {};\n\tObject.entries( registeredFields || {} ).forEach( ( [ key, props ] ) => {\n\t\t// Don't include footnotes or private fields.\n\t\tif ( key !== 'footnotes' && key.charAt( 0 ) !== '_' ) {\n\t\t\tmetaFields[ key ] = {\n\t\t\t\tlabel: props.title || key,\n\t\t\t\tvalue:\n\t\t\t\t\t// When using the entity value, an empty string IS a valid value.\n\t\t\t\t\tentityMetaValues?.[ key ] ??\n\t\t\t\t\t// When using the default, an empty string IS NOT a valid value.\n\t\t\t\t\t( props.default || undefined ),\n\t\t\t};\n\t\t}\n\t} );\n\n\tif ( ! Object.keys( metaFields || {} ).length ) {\n\t\treturn null;\n\t}\n\n\treturn metaFields;\n}\n\nexport default {\n\tname: 'core/post-meta',\n\tgetValues( { select, context, bindings } ) {\n\t\tconst metaFields = getPostMetaFields( select, context );\n\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the value, the field label, or the field key.\n\t\t\tconst fieldKey = source.args.key;\n\t\t\tconst { value: fieldValue, label: fieldLabel } =\n\t\t\t\tmetaFields?.[ fieldKey ] || {};\n\t\t\tnewValues[ attributeName ] = fieldValue ?? fieldLabel ?? fieldKey;\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { dispatch, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\n\t\tdispatch( coreDataStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId,\n\t\t\t{\n\t\t\t\tmeta: newMeta,\n\t\t\t}\n\t\t);\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fieldValue = getPostMetaFields( select, context )?.[ args.key ]\n\t\t\t?.value;\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Check that custom fields metabox is not enabled.\n\t\tconst areCustomFieldsEnabled =\n\t\t\tselect( editorStore ).getEditorSettings().enableCustomFields;\n\t\tif ( areCustomFieldsEnabled ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { select, context } ) {\n\t\treturn getPostMetaFields( select, context );\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;;AAE7D;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAAEC,MAAM,EAAEC,OAAO,EAAG;EAC7C,MAAM;IAAEC;EAAsB,CAAC,GAAGF,MAAM,CAAEJ,aAAc,CAAC;EACzD,MAAM;IAAEO;EAAsB,CAAC,GAAGL,MAAM,CAAEE,MAAM,CAAEJ,aAAc,CAAE,CAAC;EAEnE,IAAIQ,gBAAgB;EACpB;EACA,IAAKH,OAAO,EAAEI,QAAQ,IAAIJ,OAAO,EAAEK,MAAM,EAAG;IAC3CF,gBAAgB,GAAGF,qBAAqB,CACvC,UAAU,EACVD,OAAO,EAAEI,QAAQ,EACjBJ,OAAO,E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IACA,IAAKc,UAAU,KAAKZ,SAAS,EAAG;MAC/B,OAAO,KAAK;IACb;IACA;IACA,MAAMwB,sBAAsB,GAC3B7C,MAAM,CAAEH,WAAY,CAAC,CAACiD,iBAAiB,CAAC,CAAC,CAACC,kBAAkB;IAC7D,IAAKF,sBAAsB,EAAG;MAC7B,OAAO,KAAK;IACb;;IAEA;IACA,MAAMG,WAAW,GAAGhD,MAAM,CAAEJ,aAAc,CAAC,CAACqD,OAAO,CAAE,QAAQ,EAAE;MAC9DC,IAAI,EAAE,UAAU;MAChB1B,IAAI,EAAEvB,OAAO,EAAEI,QAAQ;MACvB8C,EAAE,EAAElD,OAAO,EAAEK;IACd,CAAE,CAAC;IACH,IAAK,CAAE0C,WAAW,EAAG;MACpB,OAAO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ,CAAC;EACDI,aAAaA,CAAE;IAAEpD,MAAM;IAAEC;EAAQ,CAAC,EAAG;IACpC,OAAOF,iBAAiB,CAAEC,MAAM,EAAEC,OAAQ,CAAC;EAC5C;AACD,CAAC","ignoreList":[]}
|
|
@@ -76,6 +76,7 @@ function Header({
|
|
|
76
76
|
isPublishSidebarOpened,
|
|
77
77
|
showIconLabels,
|
|
78
78
|
hasFixedToolbar,
|
|
79
|
+
hasBlockSelection,
|
|
79
80
|
isNestedEntity
|
|
80
81
|
} = useSelect(select => {
|
|
81
82
|
const {
|
|
@@ -94,12 +95,13 @@ function Header({
|
|
|
94
95
|
isPublishSidebarOpened: _isPublishSidebarOpened(),
|
|
95
96
|
showIconLabels: getPreference('core', 'showIconLabels'),
|
|
96
97
|
hasFixedToolbar: getPreference('core', 'fixedToolbar'),
|
|
98
|
+
hasBlockSelection: !!select(blockEditorStore).getBlockSelectionStart(),
|
|
97
99
|
isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord,
|
|
98
100
|
isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
|
|
99
101
|
};
|
|
100
102
|
}, []);
|
|
101
103
|
const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = useState(true);
|
|
102
|
-
const hasCenter = isBlockToolsCollapsed && !isTooNarrowForDocumentBar;
|
|
104
|
+
const hasCenter = (!hasBlockSelection || isBlockToolsCollapsed) && !isTooNarrowForDocumentBar;
|
|
103
105
|
const hasBackButton = useHasBackButton();
|
|
104
106
|
|
|
105
107
|
// The edit-post-header classname is only kept for backward compatibilty
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useMediaQuery","useViewportMatch","__unstableMotion","motion","store","preferencesStore","useState","PinnedItems","blockEditorStore","BackButton","useHasBackButton","CollapsibleBlockToolbar","DocumentBar","DocumentTools","MoreMenu","PostPreviewButton","PostPublishButtonOrToggle","PostSavedState","PostViewLink","PreviewDropdown","ZoomOutToggle","editorStore","jsx","_jsx","jsxs","_jsxs","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isEditorIframed","isWideViewport","isLargeViewport","isTooNarrowForDocumentBar","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","isNestedEntity","select","get","getPreference","getEditorMode","getEditorSettings","_isPublishSidebarOpened","__unstableGetEditorMode","onNavigateToPreviousEntityRecord","isZoomedOutView","isBlockToolsCollapsed","setIsBlockToolsCollapsed","hasCenter","hasBackButton","className","children","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","scope"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n\tisEditorIframed,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\tisNestedEntity,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetEditorSettings,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\tisNestedEntity:\n\t\t\t\t!! getEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter = isBlockToolsCollapsed && ! isTooNarrowForDocumentBar;\n\tconst hasBackButton = useHasBackButton();\n\n\t// The edit-post-header classname is only kept for backward compatibilty\n\t// as some plugins might be relying on its presence.\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ isNestedEntity }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t{ isEditorIframed && isWideViewport && <ZoomOutToggle /> }\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QA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U,EAAG;QAAEC,IAAI,EAAE;MAAQ,CAAG;MAChCL,SAAS,EAAC,yBAAyB;MAAAC,QAAA,GAEjC,CAAE5B,gBAAgB,IAAI,CAAEU,sBAAsB;MAAA;MAC/C;MACA;MACA;MACA;MACA;MACAvB,IAAA,CAACN,cAAc;QAACoB,YAAY,EAAGA;MAAc,CAAE,CAC/C,eACDd,IAAA,CAACJ,eAAe;QACfsD,mBAAmB,EAAGpC,YAAc;QACpCqC,QAAQ,EAAGzB;MAAgB,CAC3B,CAAC,eACF1B,IAAA,CAACR,iBAAiB;QACjBgD,SAAS,EAAC,oCAAoC;QAC9CU,mBAAmB,EAAGpC;MAAc,CACpC,CAAC,eACFd,IAAA,CAACL,YAAY,IAAE,CAAC,EAEduB,eAAe,IAAIC,cAAc,iBAAInB,IAAA,CAACH,aAAa,IAAE,CAAC,EAEtD,CAAEsB,cAAc,IAAI,CAAEK,cAAc,kBACrCxB,IAAA,CAAChB,WAAW,CAAC8D,IAAI;QAACM,KAAK,EAAC;MAAM,CAAE,CAChC,EAEC,CAAEvC,gBAAgB,iBACnBb,IAAA,CAACP,yBAAyB;QACzBqB,YAAY,EAAGA,YAAc;QAC7BE,8BAA8B,EAC7BA;MACA,CACD,CACD,EAECH,gBAAgB,eAClBb,IAAA,CAACT,QAAQ,IAAE,CAAC;IAAA,CACD,CAAC;EAAA,CACT,CAAC;AAER;AAEA,eAAeqB,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useSelect","useMediaQuery","useViewportMatch","__unstableMotion","motion","store","preferencesStore","useState","PinnedItems","blockEditorStore","BackButton","useHasBackButton","CollapsibleBlockToolbar","DocumentBar","DocumentTools","MoreMenu","PostPreviewButton","PostPublishButtonOrToggle","PostSavedState","PostViewLink","PreviewDropdown","ZoomOutToggle","editorStore","jsx","_jsx","jsxs","_jsxs","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isEditorIframed","isWideViewport","isLargeViewport","isTooNarrowForDocumentBar","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","hasBlockSelection","isNestedEntity","select","get","getPreference","getEditorMode","getEditorSettings","_isPublishSidebarOpened","__unstableGetEditorMode","getBlockSelectionStart","onNavigateToPreviousEntityRecord","isZoomedOutView","isBlockToolsCollapsed","setIsBlockToolsCollapsed","hasCenter","hasBackButton","className","children","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","scope"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n\tisEditorIframed,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\thasBlockSelection,\n\t\tisNestedEntity,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetEditorSettings,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t\tisNestedEntity:\n\t\t\t\t!! getEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter =\n\t\t( ! hasBlockSelection || isBlockToolsCollapsed ) &&\n\t\t! isTooNarrowForDocumentBar;\n\tconst hasBackButton = useHasBackButton();\n\n\t// The edit-post-header classname is only kept for backward compatibilty\n\t// as some plugins might be relying on its presence.\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ isNestedEntity }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t{ isEditorIframed && isWideViewport && <ZoomOutToggle /> }\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,oBAAoB;AACpE,SAASC,gBAAgB,IAAIC,MAAM,QAAQ,uBAAuB;AAClE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASH,KAAK,IAAII,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,OAAOC,UAAU,IAAIC,gBAAgB,QAAQ,eAAe;AAC5D,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,QAAQ,MAAM,cA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AAiB;QACjBkD,SAAS,EAAC,oCAAoC;QAC9CU,mBAAmB,EAAGtC;MAAc,CACpC,CAAC,eACFd,IAAA,CAACL,YAAY,IAAE,CAAC,EAEduB,eAAe,IAAIC,cAAc,iBAAInB,IAAA,CAACH,aAAa,IAAE,CAAC,EAEtD,CAAEsB,cAAc,IAAI,CAAEK,cAAc,kBACrCxB,IAAA,CAAChB,WAAW,CAACgE,IAAI;QAACM,KAAK,EAAC;MAAM,CAAE,CAChC,EAEC,CAAEzC,gBAAgB,iBACnBb,IAAA,CAACP,yBAAyB;QACzBqB,YAAY,EAAGA,YAAc;QAC7BE,8BAA8B,EAC7BA;MACA,CACD,CACD,EAECH,gBAAgB,eAClBb,IAAA,CAACT,QAAQ,IAAE,CAAC;IAAA,CACD,CAAC;EAAA,CACT,CAAC;AAER;AAEA,eAAeqB,MAAM","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
|
6
6
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
7
7
|
import { useBlockEditingMode } from '@wordpress/block-editor';
|
|
8
8
|
import { useSelect } from '@wordpress/data';
|
|
9
|
-
import {
|
|
9
|
+
import { getBlockBindingsSource } from '@wordpress/blocks';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
@@ -55,9 +55,6 @@ function ControlsWithStoreSubscription(props) {
|
|
|
55
55
|
hasPatternOverridesSource,
|
|
56
56
|
isEditingSyncedPattern
|
|
57
57
|
} = useSelect(select => {
|
|
58
|
-
const {
|
|
59
|
-
getBlockBindingsSource
|
|
60
|
-
} = unlock(select(blocksStore));
|
|
61
58
|
const {
|
|
62
59
|
getCurrentPostType,
|
|
63
60
|
getEditedPostAttribute
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","
|
|
1
|
+
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","getBlockBindingsSource","store","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","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 { getBlockBindingsSource } 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 key=\"edit\" { ...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 { 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,sBAAsB,QAAQ,mBAAmB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,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,CAC3DoB,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GACrB,CAAC,CAAEL,gCAAgC,CAAEI,KAAK,CAACE,IAAI,CAAE;EAElD,oBACCX,KAAA,CAAAF,SAAA;IAAAc,QAAA,gBACChB,IAAA,CAACY,SAAS;MAAA,GAAiBC;IAAK,GAAjB,MAAqB,CAAC,EACnCA,KAAK,CAAC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kBAAkB;EAEnB,IAAK,CAAEX,yBAAyB,EAAG;IAClC,OAAO,IAAI;EACZ;EAEA,oBACChB,KAAA,CAAAF,SAAA;IAAAc,QAAA,GACGqB,kCAAkC,iBACnCrC,IAAA,CAACK,wBAAwB;MAAA,GAAMQ;IAAK,CAAI,CACxC,EACCyB,+BAA+B,iBAChCtC,IAAA,CAACM,qBAAqB;MAAA,GAAMO;IAAK,CAAI,CACrC;EAAA,CACA,CAAC;AAEL;AAEAxB,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5CsB,2BACD,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/bindings/api.js"],"names":[],"mappings":"AAgBA;;;;;;;;;GASG;AACH,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/bindings/api.js"],"names":[],"mappings":"AAgBA;;;;;;;;;GASG;AACH,yDAGC;AAED;;;;;;;;;;;GAWG;AACH,iEATW,MAAM,QAqBhB"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
declare namespace _default {
|
|
2
2
|
let name: string;
|
|
3
|
-
function getValues({
|
|
4
|
-
|
|
3
|
+
function getValues({ select, clientId, context, bindings }: {
|
|
4
|
+
select: any;
|
|
5
5
|
clientId: any;
|
|
6
6
|
context: any;
|
|
7
7
|
bindings: any;
|
|
8
8
|
}): {};
|
|
9
|
-
function setValues({
|
|
10
|
-
|
|
9
|
+
function setValues({ select, dispatch, clientId, bindings }: {
|
|
10
|
+
select: any;
|
|
11
|
+
dispatch: any;
|
|
11
12
|
clientId: any;
|
|
12
13
|
bindings: any;
|
|
13
14
|
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pattern-overrides.d.ts","sourceRoot":"","sources":["../../src/bindings/pattern-overrides.js"],"names":[],"mappings":";;IASC;;;;;WAwBC;IACD
|
|
1
|
+
{"version":3,"file":"pattern-overrides.d.ts","sourceRoot":"","sources":["../../src/bindings/pattern-overrides.js"],"names":[],"mappings":";;IASC;;;;;WAwBC;IACD;;;;;aA+DC;IACiB,qCAAU"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
declare namespace _default {
|
|
2
2
|
let name: string;
|
|
3
|
-
function getValues({
|
|
4
|
-
|
|
3
|
+
function getValues({ select, context, bindings }: {
|
|
4
|
+
select: any;
|
|
5
5
|
context: any;
|
|
6
6
|
bindings: any;
|
|
7
7
|
}): {};
|
|
8
|
-
function setValues({
|
|
9
|
-
|
|
8
|
+
function setValues({ dispatch, context, bindings }: {
|
|
9
|
+
dispatch: any;
|
|
10
10
|
context: any;
|
|
11
11
|
bindings: any;
|
|
12
12
|
}): void;
|
|
13
|
-
function canUserEditValue({
|
|
14
|
-
|
|
13
|
+
function canUserEditValue({ select, context, args }: {
|
|
14
|
+
select: any;
|
|
15
15
|
context: any;
|
|
16
16
|
args: any;
|
|
17
17
|
}): boolean;
|
|
18
|
-
function getFieldsList({
|
|
19
|
-
|
|
18
|
+
function getFieldsList({ select, context }: {
|
|
19
|
+
select: any;
|
|
20
20
|
context: any;
|
|
21
21
|
}): Object;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-meta.d.ts","sourceRoot":"","sources":["../../src/bindings/post-meta.js"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"post-meta.d.ts","sourceRoot":"","sources":["../../src/bindings/post-meta.js"],"names":[],"mappings":";;IA2EC;;;;WAYC;IACD;;;;aAcC;IACD;;;;gBAsCC;IACD;;;eAEC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/header/index.js"],"names":[],"mappings":";AA2CA;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/header/index.js"],"names":[],"mappings":";AA2CA;;;;;;;gCAgIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "14.8.
|
|
3
|
+
"version": "14.8.7",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,35 +35,35 @@
|
|
|
35
35
|
"@wordpress/a11y": "^4.8.2",
|
|
36
36
|
"@wordpress/api-fetch": "^7.8.2",
|
|
37
37
|
"@wordpress/blob": "^4.8.1",
|
|
38
|
-
"@wordpress/block-editor": "^14.3.
|
|
39
|
-
"@wordpress/blocks": "^13.8.
|
|
40
|
-
"@wordpress/commands": "^1.8.
|
|
41
|
-
"@wordpress/components": "^28.8.
|
|
38
|
+
"@wordpress/block-editor": "^14.3.5",
|
|
39
|
+
"@wordpress/blocks": "^13.8.4",
|
|
40
|
+
"@wordpress/commands": "^1.8.5",
|
|
41
|
+
"@wordpress/components": "^28.8.5",
|
|
42
42
|
"@wordpress/compose": "^7.8.3",
|
|
43
|
-
"@wordpress/core-data": "^7.8.
|
|
43
|
+
"@wordpress/core-data": "^7.8.5",
|
|
44
44
|
"@wordpress/data": "^10.8.3",
|
|
45
|
-
"@wordpress/dataviews": "^4.4.
|
|
45
|
+
"@wordpress/dataviews": "^4.4.5",
|
|
46
46
|
"@wordpress/date": "^5.8.2",
|
|
47
47
|
"@wordpress/deprecated": "^4.8.2",
|
|
48
48
|
"@wordpress/dom": "^4.8.2",
|
|
49
49
|
"@wordpress/element": "^6.8.1",
|
|
50
|
-
"@wordpress/fields": "^0.0.
|
|
50
|
+
"@wordpress/fields": "^0.0.6",
|
|
51
51
|
"@wordpress/hooks": "^4.8.2",
|
|
52
52
|
"@wordpress/html-entities": "^4.8.1",
|
|
53
53
|
"@wordpress/i18n": "^5.8.2",
|
|
54
54
|
"@wordpress/icons": "^10.8.2",
|
|
55
|
-
"@wordpress/interface": "^6.8.
|
|
55
|
+
"@wordpress/interface": "^6.8.5",
|
|
56
56
|
"@wordpress/keyboard-shortcuts": "^5.8.3",
|
|
57
57
|
"@wordpress/keycodes": "^4.8.2",
|
|
58
58
|
"@wordpress/media-utils": "^5.8.2",
|
|
59
59
|
"@wordpress/notices": "^5.8.3",
|
|
60
|
-
"@wordpress/patterns": "^2.8.
|
|
61
|
-
"@wordpress/plugins": "^7.8.
|
|
62
|
-
"@wordpress/preferences": "^4.8.
|
|
60
|
+
"@wordpress/patterns": "^2.8.5",
|
|
61
|
+
"@wordpress/plugins": "^7.8.5",
|
|
62
|
+
"@wordpress/preferences": "^4.8.5",
|
|
63
63
|
"@wordpress/private-apis": "^1.8.1",
|
|
64
|
-
"@wordpress/reusable-blocks": "^5.8.
|
|
64
|
+
"@wordpress/reusable-blocks": "^5.8.5",
|
|
65
65
|
"@wordpress/rich-text": "^7.8.3",
|
|
66
|
-
"@wordpress/server-side-render": "^5.8.
|
|
66
|
+
"@wordpress/server-side-render": "^5.8.5",
|
|
67
67
|
"@wordpress/url": "^4.8.1",
|
|
68
68
|
"@wordpress/warning": "^3.8.1",
|
|
69
69
|
"@wordpress/wordcount": "^4.8.1",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "21b3c2e9abda74edab42455041edc6e82fccc388"
|
|
90
90
|
}
|
package/src/bindings/api.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
|
-
privateApis as blocksPrivateApis,
|
|
6
5
|
store as blocksStore,
|
|
6
|
+
registerBlockBindingsSource,
|
|
7
7
|
} from '@wordpress/blocks';
|
|
8
8
|
import { dispatch } from '@wordpress/data';
|
|
9
9
|
|
|
@@ -25,7 +25,6 @@ import { unlock } from '../lock-unlock';
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export function registerCoreBlockBindingsSources() {
|
|
28
|
-
const { registerBlockBindingsSource } = unlock( blocksPrivateApis );
|
|
29
28
|
registerBlockBindingsSource( patternOverrides );
|
|
30
29
|
registerBlockBindingsSource( postMeta );
|
|
31
30
|
}
|
|
@@ -7,9 +7,9 @@ const CONTENT = 'content';
|
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
name: 'core/pattern-overrides',
|
|
10
|
-
getValues( {
|
|
10
|
+
getValues( { select, clientId, context, bindings } ) {
|
|
11
11
|
const patternOverridesContent = context[ 'pattern/overrides' ];
|
|
12
|
-
const { getBlockAttributes } =
|
|
12
|
+
const { getBlockAttributes } = select( blockEditorStore );
|
|
13
13
|
const currentBlockAttributes = getBlockAttributes( clientId );
|
|
14
14
|
|
|
15
15
|
const overridesValues = {};
|
|
@@ -32,9 +32,9 @@ export default {
|
|
|
32
32
|
}
|
|
33
33
|
return overridesValues;
|
|
34
34
|
},
|
|
35
|
-
setValues( {
|
|
35
|
+
setValues( { select, dispatch, clientId, bindings } ) {
|
|
36
36
|
const { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =
|
|
37
|
-
|
|
37
|
+
select( blockEditorStore );
|
|
38
38
|
const currentBlockAttributes = getBlockAttributes( clientId );
|
|
39
39
|
const blockName = currentBlockAttributes?.metadata?.name;
|
|
40
40
|
if ( ! blockName ) {
|
|
@@ -61,12 +61,10 @@ export default {
|
|
|
61
61
|
const syncBlocksWithSameName = ( blocks ) => {
|
|
62
62
|
for ( const block of blocks ) {
|
|
63
63
|
if ( block.attributes?.metadata?.name === blockName ) {
|
|
64
|
-
|
|
65
|
-
.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
attributes
|
|
69
|
-
);
|
|
64
|
+
dispatch( blockEditorStore ).updateBlockAttributes(
|
|
65
|
+
block.clientId,
|
|
66
|
+
attributes
|
|
67
|
+
);
|
|
70
68
|
}
|
|
71
69
|
syncBlocksWithSameName( block.innerBlocks );
|
|
72
70
|
}
|
|
@@ -77,27 +75,26 @@ export default {
|
|
|
77
75
|
}
|
|
78
76
|
const currentBindingValue =
|
|
79
77
|
getBlockAttributes( patternClientId )?.[ CONTENT ];
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
[ blockName ]
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
),
|
|
98
|
-
},
|
|
78
|
+
|
|
79
|
+
dispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {
|
|
80
|
+
[ CONTENT ]: {
|
|
81
|
+
...currentBindingValue,
|
|
82
|
+
[ blockName ]: {
|
|
83
|
+
...currentBindingValue?.[ blockName ],
|
|
84
|
+
...Object.entries( attributes ).reduce(
|
|
85
|
+
( acc, [ key, value ] ) => {
|
|
86
|
+
// TODO: We need a way to represent `undefined` in the serialized overrides.
|
|
87
|
+
// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
|
|
88
|
+
// We use an empty string to represent undefined for now until
|
|
89
|
+
// we support a richer format for overrides and the block bindings API.
|
|
90
|
+
acc[ key ] = value === undefined ? '' : value;
|
|
91
|
+
return acc;
|
|
92
|
+
},
|
|
93
|
+
{}
|
|
94
|
+
),
|
|
99
95
|
},
|
|
100
|
-
}
|
|
96
|
+
},
|
|
97
|
+
} );
|
|
101
98
|
},
|
|
102
99
|
canUserEditValue: () => true,
|
|
103
100
|
};
|