@wordpress/editor 14.8.5 → 14.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/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/block-settings-menu/content-only-settings-menu.js +15 -18
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/document-tools/index.js +1 -6
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +22 -17
- package/build/components/header/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +8 -9
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +17 -18
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/use-post-content-blocks.js +34 -0
- package/build/components/provider/use-post-content-blocks.js.map +1 -0
- package/build/components/resizable-editor/resize-handle.js +4 -0
- package/build/components/resizable-editor/resize-handle.js.map +1 -1
- package/build/components/zoom-out-toggle/index.js +1 -1
- package/build/components/zoom-out-toggle/index.js.map +1 -1
- package/build/dataviews/store/private-actions.js +2 -7
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/hooks/pattern-overrides.js +1 -4
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/store/actions.js +20 -5
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.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/block-settings-menu/content-only-settings-menu.js +14 -18
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/document-tools/index.js +1 -6
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +22 -17
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +8 -9
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +17 -18
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/use-post-content-blocks.js +27 -0
- package/build-module/components/provider/use-post-content-blocks.js.map +1 -0
- package/build-module/components/resizable-editor/resize-handle.js +4 -0
- package/build-module/components/resizable-editor/resize-handle.js.map +1 -1
- package/build-module/components/zoom-out-toggle/index.js +1 -1
- package/build-module/components/zoom-out-toggle/index.js.map +1 -1
- package/build-module/dataviews/store/private-actions.js +4 -8
- package/build-module/dataviews/store/private-actions.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-module/store/actions.js +18 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -1
- package/build-style/style.css +10 -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/document-tools/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
- package/build-types/components/provider/use-post-content-blocks.d.ts +2 -0
- package/build-types/components/provider/use-post-content-blocks.d.ts.map +1 -0
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +1 -13
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +2 -2
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/package.json +37 -37
- 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/block-settings-menu/content-only-settings-menu.js +19 -19
- package/src/components/document-tools/index.js +1 -4
- package/src/components/header/index.js +30 -14
- package/src/components/inserter-sidebar/index.js +8 -11
- package/src/components/provider/disable-non-page-content-blocks.js +20 -34
- package/src/components/provider/use-post-content-blocks.js +42 -0
- package/src/components/resizable-editor/resize-handle.js +5 -0
- package/src/components/zoom-out-toggle/index.js +1 -1
- package/src/dataviews/store/private-actions.ts +7 -7
- package/src/hooks/pattern-overrides.js +1 -2
- package/src/store/actions.js +23 -6
- package/src/store/private-selectors.js +2 -2
- package/src/store/test/actions.js +76 -0
- package/src/store/test/reducer.js +0 -22
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dataviews/actions/delete-post.js +0 -98
- package/build/dataviews/actions/delete-post.js.map +0 -1
- package/build/dataviews/actions/rename-post.js +0 -125
- package/build/dataviews/actions/rename-post.js.map +0 -1
- package/build/dataviews/actions/reset-post.js +0 -113
- package/build/dataviews/actions/reset-post.js.map +0 -1
- package/build/dataviews/actions/restore-post.js +0 -112
- package/build/dataviews/actions/restore-post.js.map +0 -1
- package/build/dataviews/actions/trash-post.js +0 -144
- package/build/dataviews/actions/trash-post.js.map +0 -1
- package/build/dataviews/fields/index.js +0 -32
- package/build/dataviews/fields/index.js.map +0 -1
- package/build-module/dataviews/actions/delete-post.js +0 -89
- package/build-module/dataviews/actions/delete-post.js.map +0 -1
- package/build-module/dataviews/actions/rename-post.js +0 -118
- package/build-module/dataviews/actions/rename-post.js.map +0 -1
- package/build-module/dataviews/actions/reset-post.js +0 -106
- package/build-module/dataviews/actions/reset-post.js.map +0 -1
- package/build-module/dataviews/actions/restore-post.js +0 -104
- package/build-module/dataviews/actions/restore-post.js.map +0 -1
- package/build-module/dataviews/actions/trash-post.js +0 -137
- package/build-module/dataviews/actions/trash-post.js.map +0 -1
- package/build-module/dataviews/fields/index.js +0 -26
- package/build-module/dataviews/fields/index.js.map +0 -1
- package/build-types/dataviews/actions/delete-post.d.ts +0 -5
- package/build-types/dataviews/actions/delete-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/rename-post.d.ts +0 -5
- package/build-types/dataviews/actions/rename-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/reset-post.d.ts +0 -5
- package/build-types/dataviews/actions/reset-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/restore-post.d.ts +0 -5
- package/build-types/dataviews/actions/restore-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/trash-post.d.ts +0 -5
- package/build-types/dataviews/actions/trash-post.d.ts.map +0 -1
- package/build-types/dataviews/fields/index.d.ts +0 -8
- package/build-types/dataviews/fields/index.d.ts.map +0 -1
- package/src/dataviews/actions/delete-post.tsx +0 -109
- package/src/dataviews/actions/rename-post.tsx +0 -146
- package/src/dataviews/actions/reset-post.tsx +0 -147
- package/src/dataviews/actions/restore-post.tsx +0 -134
- package/src/dataviews/actions/trash-post.tsx +0 -198
- package/src/dataviews/fields/index.ts +0 -26
package/CHANGELOG.md
CHANGED
package/build/bindings/api.js
CHANGED
|
@@ -30,11 +30,8 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
function registerCoreBlockBindingsSources() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = (0, _lockUnlock.unlock)(_blocks.privateApis);
|
|
36
|
-
registerBlockBindingsSource(_patternOverrides.default);
|
|
37
|
-
registerBlockBindingsSource(_postMeta.default);
|
|
33
|
+
(0, _blocks.registerBlockBindingsSource)(_patternOverrides.default);
|
|
34
|
+
(0, _blocks.registerBlockBindingsSource)(_postMeta.default);
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_data","_patternOverrides","_interopRequireDefault","_postMeta","_lockUnlock","registerCoreBlockBindingsSources","registerBlockBindingsSource","
|
|
1
|
+
{"version":3,"names":["_blocks","require","_data","_patternOverrides","_interopRequireDefault","_postMeta","_lockUnlock","registerCoreBlockBindingsSources","registerBlockBindingsSource","patternOverrides","postMeta","bootstrapBlockBindingsSourcesFromServer","sources","addBootstrappedBlockBindingsSource","unlock","dispatch","blocksStore","name","args","Object","entries"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tregisterBlockBindingsSource,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Function to register core block bindings sources provided by the editor.\n *\n * @example\n * ```js\n * import { registerCoreBlockBindingsSources } from '@wordpress/editor';\n *\n * registerCoreBlockBindingsSources();\n * ```\n */\nexport function registerCoreBlockBindingsSources() {\n\tregisterBlockBindingsSource( patternOverrides );\n\tregisterBlockBindingsSource( postMeta );\n}\n\n/**\n * Function to bootstrap core block bindings sources defined in the server.\n *\n * @param {Object} sources Object containing the sources to bootstrap.\n *\n * @example\n * ```js\n * import { bootstrapBlockBindingsSourcesFromServer } from '@wordpress/editor';\n *\n * bootstrapBlockBindingsSourcesFromServer( sources );\n * ```\n */\nexport function bootstrapBlockBindingsSourcesFromServer( sources ) {\n\tif ( sources ) {\n\t\tconst { addBootstrappedBlockBindingsSource } = unlock(\n\t\t\tdispatch( blocksStore )\n\t\t);\n\t\tfor ( const [ name, args ] of Object.entries( sources ) ) {\n\t\t\taddBootstrappedBlockBindingsSource( {\n\t\t\t\tname,\n\t\t\t\t...args,\n\t\t\t} );\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAdA;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,gCAAgCA,CAAA,EAAG;EAClD,IAAAC,mCAA2B,EAAEC,yBAAiB,CAAC;EAC/C,IAAAD,mCAA2B,EAAEE,iBAAS,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uCAAuCA,CAAEC,OAAO,EAAG;EAClE,IAAKA,OAAO,EAAG;IACd,MAAM;MAAEC;IAAmC,CAAC,GAAG,IAAAC,kBAAM,EACpD,IAAAC,cAAQ,EAAEC,aAAY,CACvB,CAAC;IACD,KAAM,MAAM,CAAEC,IAAI,EAAEC,IAAI,CAAE,IAAIC,MAAM,CAACC,OAAO,CAAER,OAAQ,CAAC,EAAG;MACzDC,kCAAkC,CAAE;QACnCI,IAAI;QACJ,GAAGC;MACJ,CAAE,CAAC;IACJ;EACD;AACD","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ const CONTENT = 'content';
|
|
|
13
13
|
var _default = exports.default = {
|
|
14
14
|
name: 'core/pattern-overrides',
|
|
15
15
|
getValues({
|
|
16
|
-
|
|
16
|
+
select,
|
|
17
17
|
clientId,
|
|
18
18
|
context,
|
|
19
19
|
bindings
|
|
@@ -21,7 +21,7 @@ var _default = exports.default = {
|
|
|
21
21
|
const patternOverridesContent = context['pattern/overrides'];
|
|
22
22
|
const {
|
|
23
23
|
getBlockAttributes
|
|
24
|
-
} =
|
|
24
|
+
} = select(_blockEditor.store);
|
|
25
25
|
const currentBlockAttributes = getBlockAttributes(clientId);
|
|
26
26
|
const overridesValues = {};
|
|
27
27
|
for (const attributeName of Object.keys(bindings)) {
|
|
@@ -39,7 +39,8 @@ var _default = exports.default = {
|
|
|
39
39
|
return overridesValues;
|
|
40
40
|
},
|
|
41
41
|
setValues({
|
|
42
|
-
|
|
42
|
+
select,
|
|
43
|
+
dispatch,
|
|
43
44
|
clientId,
|
|
44
45
|
bindings
|
|
45
46
|
}) {
|
|
@@ -47,7 +48,7 @@ var _default = exports.default = {
|
|
|
47
48
|
getBlockAttributes,
|
|
48
49
|
getBlockParentsByBlockName,
|
|
49
50
|
getBlocks
|
|
50
|
-
} =
|
|
51
|
+
} = select(_blockEditor.store);
|
|
51
52
|
const currentBlockAttributes = getBlockAttributes(clientId);
|
|
52
53
|
const blockName = currentBlockAttributes?.metadata?.name;
|
|
53
54
|
if (!blockName) {
|
|
@@ -68,7 +69,7 @@ var _default = exports.default = {
|
|
|
68
69
|
const syncBlocksWithSameName = blocks => {
|
|
69
70
|
for (const block of blocks) {
|
|
70
71
|
if (block.attributes?.metadata?.name === blockName) {
|
|
71
|
-
|
|
72
|
+
dispatch(_blockEditor.store).updateBlockAttributes(block.clientId, attributes);
|
|
72
73
|
}
|
|
73
74
|
syncBlocksWithSameName(block.innerBlocks);
|
|
74
75
|
}
|
|
@@ -77,7 +78,7 @@ var _default = exports.default = {
|
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
|
|
80
|
-
|
|
81
|
+
dispatch(_blockEditor.store).updateBlockAttributes(patternClientId, {
|
|
81
82
|
[CONTENT]: {
|
|
82
83
|
...currentBindingValue,
|
|
83
84
|
[blockName]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","CONTENT","_default","exports","default","name","getValues","
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","CONTENT","_default","exports","default","name","getValues","select","clientId","context","bindings","patternOverridesContent","getBlockAttributes","blockEditorStore","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","dispatch","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { select, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been overriden, return the original value.\n\t\t\t// Check undefined because empty string is a valid value.\n\t\t\tif ( overridableValue === undefined ) {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\tcurrentBlockAttributes[ attributeName ];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\toverridableValue === '' ? undefined : overridableValue;\n\t\t\t}\n\t\t}\n\t\treturn overridesValues;\n\t},\n\tsetValues( { select, dispatch, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tselect( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// Extract the updated attributes from the source bindings.\n\t\tconst attributes = Object.entries( bindings ).reduce(\n\t\t\t( attrs, [ key, { newValue } ] ) => {\n\t\t\t\tattrs[ key ] = newValue;\n\t\t\t\treturn attrs;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tdispatch( blockEditorStore ).updateBlockAttributes(\n\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\n\t\tdispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: {\n\t\t\t\t...currentBindingValue,\n\t\t\t\t[ blockName ]: {\n\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\treturn acc;\n\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\t} );\n\t},\n\tcanUserE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AAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAER,GAAG,CAAE,GAAGS,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACJ,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
|
|
@@ -21,8 +21,8 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
21
21
|
* If the value is not available based on context, like in templates,
|
|
22
22
|
* it falls back to the default value, label, or key.
|
|
23
23
|
*
|
|
24
|
-
* @param {Object}
|
|
25
|
-
* @param {Object} context
|
|
24
|
+
* @param {Object} select The select function from the data store.
|
|
25
|
+
* @param {Object} context The context provided.
|
|
26
26
|
* @return {Object} List of post meta fields with their value and label.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
@@ -40,13 +40,13 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
40
40
|
* }
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
function getPostMetaFields(
|
|
43
|
+
function getPostMetaFields(select, context) {
|
|
44
44
|
const {
|
|
45
45
|
getEditedEntityRecord
|
|
46
|
-
} =
|
|
46
|
+
} = select(_coreData.store);
|
|
47
47
|
const {
|
|
48
48
|
getRegisteredPostMeta
|
|
49
|
-
} = (0, _lockUnlock.unlock)(
|
|
49
|
+
} = (0, _lockUnlock.unlock)(select(_coreData.store));
|
|
50
50
|
let entityMetaValues;
|
|
51
51
|
// Try to get the current entity meta values.
|
|
52
52
|
if (context?.postType && context?.postId) {
|
|
@@ -75,11 +75,11 @@ function getPostMetaFields(registry, context) {
|
|
|
75
75
|
var _default = exports.default = {
|
|
76
76
|
name: 'core/post-meta',
|
|
77
77
|
getValues({
|
|
78
|
-
|
|
78
|
+
select,
|
|
79
79
|
context,
|
|
80
80
|
bindings
|
|
81
81
|
}) {
|
|
82
|
-
const metaFields = getPostMetaFields(
|
|
82
|
+
const metaFields = getPostMetaFields(select, context);
|
|
83
83
|
const newValues = {};
|
|
84
84
|
for (const [attributeName, source] of Object.entries(bindings)) {
|
|
85
85
|
var _ref;
|
|
@@ -94,7 +94,7 @@ var _default = exports.default = {
|
|
|
94
94
|
return newValues;
|
|
95
95
|
},
|
|
96
96
|
setValues({
|
|
97
|
-
|
|
97
|
+
dispatch,
|
|
98
98
|
context,
|
|
99
99
|
bindings
|
|
100
100
|
}) {
|
|
@@ -105,12 +105,12 @@ var _default = exports.default = {
|
|
|
105
105
|
}) => {
|
|
106
106
|
newMeta[args.key] = newValue;
|
|
107
107
|
});
|
|
108
|
-
|
|
108
|
+
dispatch(_coreData.store).editEntityRecord('postType', context?.postType, context?.postId, {
|
|
109
109
|
meta: newMeta
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
112
|
canUserEditValue({
|
|
113
|
-
|
|
113
|
+
select,
|
|
114
114
|
context,
|
|
115
115
|
args
|
|
116
116
|
}) {
|
|
@@ -118,25 +118,25 @@ var _default = exports.default = {
|
|
|
118
118
|
if (context?.query || context?.queryId) {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
|
-
const postType = context?.postType ||
|
|
121
|
+
const postType = context?.postType || select(_store.store).getCurrentPostType();
|
|
122
122
|
|
|
123
123
|
// Check that editing is happening in the post editor and not a template.
|
|
124
124
|
if (postType === 'wp_template') {
|
|
125
125
|
return false;
|
|
126
126
|
}
|
|
127
|
-
const fieldValue = getPostMetaFields(
|
|
127
|
+
const fieldValue = getPostMetaFields(select, context)?.[args.key]?.value;
|
|
128
128
|
// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
|
|
129
129
|
if (fieldValue === undefined) {
|
|
130
130
|
return false;
|
|
131
131
|
}
|
|
132
132
|
// Check that custom fields metabox is not enabled.
|
|
133
|
-
const areCustomFieldsEnabled =
|
|
133
|
+
const areCustomFieldsEnabled = select(_store.store).getEditorSettings().enableCustomFields;
|
|
134
134
|
if (areCustomFieldsEnabled) {
|
|
135
135
|
return false;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// Check that the user has the capability to edit post meta.
|
|
139
|
-
const canUserEdit =
|
|
139
|
+
const canUserEdit = select(_coreData.store).canUser('update', {
|
|
140
140
|
kind: 'postType',
|
|
141
141
|
name: context?.postType,
|
|
142
142
|
id: context?.postId
|
|
@@ -147,10 +147,10 @@ var _default = exports.default = {
|
|
|
147
147
|
return true;
|
|
148
148
|
},
|
|
149
149
|
getFieldsList({
|
|
150
|
-
|
|
150
|
+
select,
|
|
151
151
|
context
|
|
152
152
|
}) {
|
|
153
|
-
return getPostMetaFields(
|
|
153
|
+
return getPostMetaFields(select, context);
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
//# sourceMappingURL=post-meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_store","_lockUnlock","getPostMetaFields","
|
|
1
|
+
{"version":3,"names":["_coreData","require","_store","_lockUnlock","getPostMetaFields","select","context","getEditedEntityRecord","coreDataStore","getRegisteredPostMeta","unlock","entityMetaValues","postType","postId","meta","registeredFields","metaFields","Object","entries","forEach","key","props","charAt","_entityMetaValues$key","label","title","value","default","undefined","keys","length","_default","exports","name","getValues","bindings","newValues","attributeName","source","_ref","fieldKey","args","fieldValue","fieldLabel","setValues","dispatch","newMeta","values","newValue","editEntityRecord","canUserEditValue","query","queryId","editorStore","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":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AATA;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ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -11,6 +12,7 @@ var _data = require("@wordpress/data");
|
|
|
11
12
|
var _i18n = require("@wordpress/i18n");
|
|
12
13
|
var _store = require("../../store");
|
|
13
14
|
var _lockUnlock = require("../../lock-unlock");
|
|
15
|
+
var _usePostContentBlocks = _interopRequireDefault(require("../provider/use-post-content-blocks"));
|
|
14
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
17
|
/**
|
|
16
18
|
* WordPress dependencies
|
|
@@ -24,36 +26,31 @@ function ContentOnlySettingsMenuItems({
|
|
|
24
26
|
clientId,
|
|
25
27
|
onClose
|
|
26
28
|
}) {
|
|
29
|
+
const postContentBlocks = (0, _usePostContentBlocks.default)();
|
|
27
30
|
const {
|
|
28
31
|
entity,
|
|
29
32
|
onNavigateToEntityRecord,
|
|
30
33
|
canEditTemplates
|
|
31
34
|
} = (0, _data.useSelect)(select => {
|
|
32
35
|
const {
|
|
33
|
-
getBlockEditingMode,
|
|
34
36
|
getBlockParentsByBlockName,
|
|
35
37
|
getSettings,
|
|
36
|
-
getBlockAttributes
|
|
38
|
+
getBlockAttributes,
|
|
39
|
+
getBlockParents
|
|
37
40
|
} = select(_blockEditor.store);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
41
|
+
const {
|
|
42
|
+
getCurrentTemplateId,
|
|
43
|
+
getRenderingMode
|
|
44
|
+
} = select(_store.store);
|
|
42
45
|
const patternParent = getBlockParentsByBlockName(clientId, 'core/block', true)[0];
|
|
43
46
|
let record;
|
|
44
47
|
if (patternParent) {
|
|
45
48
|
record = select(_coreData.store).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
|
|
46
|
-
} else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const {
|
|
52
|
-
getContentLockingParent
|
|
53
|
-
} = (0, _lockUnlock.unlock)(select(_blockEditor.store));
|
|
54
|
-
if (!getContentLockingParent(clientId) && templateId) {
|
|
55
|
-
record = select(_coreData.store).getEntityRecord('postType', 'wp_template', templateId);
|
|
56
|
-
}
|
|
49
|
+
} else if (getRenderingMode() === 'template-locked' && !getBlockParents(clientId).some(parent => postContentBlocks.includes(parent))) {
|
|
50
|
+
record = select(_coreData.store).getEntityRecord('postType', 'wp_template', getCurrentTemplateId());
|
|
51
|
+
}
|
|
52
|
+
if (!record) {
|
|
53
|
+
return {};
|
|
57
54
|
}
|
|
58
55
|
const _canEditTemplates = select(_coreData.store).canUser('create', {
|
|
59
56
|
kind: 'postType',
|
|
@@ -64,7 +61,7 @@ function ContentOnlySettingsMenuItems({
|
|
|
64
61
|
entity: record,
|
|
65
62
|
onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
|
|
66
63
|
};
|
|
67
|
-
}, [clientId]);
|
|
64
|
+
}, [clientId, postContentBlocks]);
|
|
68
65
|
if (!entity) {
|
|
69
66
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(TemplateLockContentOnlyMenuItems, {
|
|
70
67
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","_coreData","_components","_data","_i18n","_store","_lockUnlock","_jsxRuntime","ContentOnlySettingsMenuItems","clientId","onClose","entity","onNavigateToEntityRecord","canEditTemplates","useSelect","select","getBlockEditingMode","getBlockParentsByBlockName","getSettings","getBlockAttributes","blockEditorStore","contentOnly","patternParent","record","coreStore","getEntityRecord","ref","getCurrentTemplateId","editorStore","templateId","getContentLockingParent","unlock","_canEditTemplates","canUser","kind","name","jsx","TemplateLockContentOnlyMenuItems","isPattern","type","helpText","__","jsxs","Fragment","children","__unstableBlockSettingsMenuFirstItem","MenuItem","onClick","postId","id","postType","disabled","__experimentalText","variant","as","className","contentLockingParent","blockDisplayInformation","useBlockDisplayInformation","blockEditorActions","useDispatch","title","modifyContentLockBlock","_x","ContentOnlySettingsMenu","BlockSettingsMenuControls","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst contentOnly =\n\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly';\n\t\t\tif ( ! contentOnly ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { getCurrentTemplateId } = select( editorStore );\n\t\t\t\tconst templateId = getCurrentTemplateId();\n\t\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t);\n\t\t\t\tif ( ! getContentLockingParent( clientId ) && templateId ) {\n\t\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\ttemplateId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAA2C,IAAAO,WAAA,GAAAP,OAAA;AAlB3C;AACA;AACA;;AAYA;AACA;AACA;;AAIA,SAASQ,4BAA4BA,CAAE;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAG;EAC9D,MAAM;IAAEC,MAAM;IAAEC,wBAAwB;IAAEC;EAAiB,CAAC,GAAG,IAAAC,eAAS,EACrEC,MAAM,IAAM;IACb,MAAM;MACLC,mBAAmB;MACnBC,0BAA0B;MAC1BC,WAAW;MACXC;IACD,CAAC,GAAGJ,MAAM,CAAEK,kBAAiB,CAAC;IAC9B,MAAMC,WAAW,GAChBL,mBAAmB,CAAEP,QAAS,CAAC,KAAK,aAAa;IAClD,IAAK,CAAEY,WAAW,EAAG;MACpB,OAAO,CAAC,CAAC;IACV;IACA,MAAMC,aAAa,GAAGL,0BAA0B,CAC/CR,QAAQ,EACR,YAAY,EACZ,IACD,CAAC,CAAE,CAAC,CAAE;IAEN,IAAIc,MAAM;IACV,IAAKD,aAAa,EAAG;MACpBC,MAAM,GAAGR,MAAM,CAAES,eAAU,CAAC,CAACC,eAAe,CAC3C,UAAU,EACV,UAAU,EACVN,kBAAkB,CAAEG,aAAc,CAAC,CAACI,GACrC,CAAC;IACF,C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AG,IAAA/B,kBAAM,EAAE4B,kBAAmB,CAAC;EAE/D,oBACC,IAAApD,WAAA,CAAAmC,IAAA,EAAAnC,WAAA,CAAAoC,QAAA;IAAAC,QAAA,gBACC,IAAArC,WAAA,CAAA6B,GAAA,EAACrC,YAAA,CAAA8C,oCAA0B;MAAAD,QAAA,eAC1B,IAAArC,WAAA,CAAA6B,GAAA,EAAClC,WAAA,CAAA4C,QAAQ;QACRC,OAAO,EAAGA,CAAA,KAAM;UACfe,sBAAsB,CAAEN,oBAAqB,CAAC;UAC9C9C,OAAO,CAAC,CAAC;QACV,CAAG;QAAAkC,QAAA,EAED,IAAAmB,QAAE,EAAE,QAAQ,EAAE,8BAA+B;MAAC,CACvC;IAAC,CACgB,CAAC,eAC7B,IAAAxD,WAAA,CAAA6B,GAAA,EAAClC,WAAA,CAAAkD,kBAAI;MACJC,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,SAAS,EAAC,gDAAgD;MAAAX,QAAA,EAExD,IAAAH,QAAE,EACH,4FACD;IAAC,CACI,CAAC;EAAA,CACN,CAAC;AAEL;AAEe,SAASuB,uBAAuBA,CAAA,EAAG;EACjD,oBACC,IAAAzD,WAAA,CAAA6B,GAAA,EAACrC,YAAA,CAAAkE,yBAAyB;IAAArB,QAAA,EACvBA,CAAE;MAAEsB,iBAAiB;MAAExD;IAAQ,CAAC,KACjCwD,iBAAiB,CAACC,MAAM,KAAK,CAAC,iBAC7B,IAAA5D,WAAA,CAAA6B,GAAA,EAAC5B,4BAA4B;MAC5BC,QAAQ,EAAGyD,iBAAiB,CAAE,CAAC,CAAI;MACnCxD,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","_coreData","_components","_data","_i18n","_store","_lockUnlock","_usePostContentBlocks","_interopRequireDefault","_jsxRuntime","ContentOnlySettingsMenuItems","clientId","onClose","postContentBlocks","usePostContentBlocks","entity","onNavigateToEntityRecord","canEditTemplates","useSelect","select","getBlockParentsByBlockName","getSettings","getBlockAttributes","getBlockParents","blockEditorStore","getCurrentTemplateId","getRenderingMode","editorStore","patternParent","record","coreStore","getEntityRecord","ref","some","parent","includes","_canEditTemplates","canUser","kind","name","jsx","TemplateLockContentOnlyMenuItems","isPattern","type","helpText","__","jsxs","Fragment","children","__unstableBlockSettingsMenuFirstItem","MenuItem","onClick","postId","id","postType","disabled","__experimentalText","variant","as","className","contentLockingParent","getContentLockingParent","unlock","blockDisplayInformation","useBlockDisplayInformation","blockEditorActions","useDispatch","title","modifyContentLockBlock","_x","ContentOnlySettingsMenu","BlockSettingsMenuControls","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport usePostContentBlocks from '../provider/use-post-content-blocks';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst postContentBlocks = usePostContentBlocks();\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockParents,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getCurrentTemplateId, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tgetRenderingMode() === 'template-locked' &&\n\t\t\t\t! getBlockParents( clientId ).some( ( parent ) =>\n\t\t\t\t\tpostContentBlocks.includes( parent )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tgetCurrentTemplateId()\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( ! record ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId, postContentBlocks ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,qBAAA,GAAAC,sBAAA,CAAAR,OAAA;AAAuE,IAAAS,WAAA,GAAAT,OAAA;AAnBvE;AACA;AACA;;AAYA;AACA;AACA;;AAKA,SAASU,4BAA4BA,CAAE;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAG;EAC9D,MAAMC,iBAAiB,GAAG,IAAAC,6BAAoB,EAAC,CAAC;EAChD,MAAM;IAAEC,MAAM;IAAEC,wBAAwB;IAAEC;EAAiB,CAAC,GAAG,IAAAC,eAAS,EACrEC,MAAM,IAAM;IACb,MAAM;MACLC,0BAA0B;MAC1BC,WAAW;MACXC,kBAAkB;MAClBC;IACD,CAAC,GAAGJ,MAAM,CAAEK,kBAAiB,CAAC;IAC9B,MAAM;MAAEC,oBAAoB;MA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WAAA,CAAA+B,GAAA,EAAC9B,4BAA4B;MAC5BC,QAAQ,EAAG6D,iBAAiB,CAAE,CAAC,CAAI;MACnC5D,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
|
|
@@ -47,12 +47,8 @@ function DocumentTools({
|
|
|
47
47
|
listViewShortcut,
|
|
48
48
|
inserterSidebarToggleRef,
|
|
49
49
|
listViewToggleRef,
|
|
50
|
-
hasFixedToolbar,
|
|
51
50
|
showIconLabels
|
|
52
51
|
} = (0, _data.useSelect)(select => {
|
|
53
|
-
const {
|
|
54
|
-
getSettings
|
|
55
|
-
} = select(_blockEditor.store);
|
|
56
52
|
const {
|
|
57
53
|
get
|
|
58
54
|
} = select(_preferences.store);
|
|
@@ -74,7 +70,6 @@ function DocumentTools({
|
|
|
74
70
|
listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
|
|
75
71
|
inserterSidebarToggleRef: getInserterSidebarToggleRef(),
|
|
76
72
|
listViewToggleRef: getListViewToggleRef(),
|
|
77
|
-
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
78
73
|
showIconLabels: get('core', 'showIconLabels'),
|
|
79
74
|
isDistractionFree: get('core', 'distractionFree'),
|
|
80
75
|
isVisualMode: getEditorMode() === 'visual',
|
|
@@ -130,7 +125,7 @@ function DocumentTools({
|
|
|
130
125
|
showTooltip: !showIconLabels,
|
|
131
126
|
"aria-expanded": isInserterOpened
|
|
132
127
|
}), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
133
|
-
children: [isLargeViewport &&
|
|
128
|
+
children: [isLargeViewport && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToolbarItem, {
|
|
134
129
|
as: _blockEditor.ToolSelector,
|
|
135
130
|
showTooltip: !showIconLabels,
|
|
136
131
|
variant: showIconLabels ? 'tertiary' : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_data","_i18n","_blockEditor","_components","_icons","_element","_keyboardShortcuts","_preferences","_lockUnlock","_store","_redo","_undo","_jsxRuntime","DocumentTools","className","disableBlockTools","setIsInserterOpened","setIsListViewOpened","useDispatch","editorStore","isDistractionFree","isInserterOpened","isListViewOpen","listViewShortcut","inserterSidebarToggleRef","listViewToggleRef","hasFixedToolbar","showIconLabels","useSelect","select","getSettings","blockEditorStore","get","preferencesStore","isListViewOpened","getEditorMode","getInserterSidebarToggleRef","getListViewToggleRef","unlock","getShortcutRepresentation","keyboardShortcutsStore","__unstableGetEditorMode","isVisualMode","isZoomedOutView","preventDefault","event","isLargeViewport","useViewportMatch","isWideViewport","toolbarAriaLabel","__","toggleListView","useCallback","toggleInserter","longLabel","_x","shortLabel","jsx","NavigableToolbar","clsx","variant","children","jsxs","ToolbarItem","ref","as","Button","isPressed","onMouseDown","onClick","disabled","icon","plus","label","showTooltip","Fragment","ToolSelector","undefined","size","EditorHistoryUndo","EditorHistoryRedo","listView","shortcut","_default","exports","default"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nfunction DocumentTools( { className, disableBlockTools = false } ) {\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisDistractionFree,\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t\thasFixedToolbar,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst preventDefault = ( event ) => {\n\t\t// Because the inserter behaves like a dialog,\n\t\t// if the inserter is opened already then when we click on the toggle button\n\t\t// then the initial click event will close the inserter and then be propagated\n\t\t// to the inserter toggle and it will open it again.\n\t\t// To prevent this we need to stop the propagation of the event.\n\t\t// This won't be necessary when the inserter no longer behaves like a dialog.\n\n\t\tif ( isInserterOpened ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpened ),\n\t\t[ isInserterOpened, setIsInserterOpened ]\n\t);\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AAKA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,KAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,KAAA,GAAAd,sBAAA,CAAAC,OAAA;AAAuD,IAAAc,WAAA,GAAAd,OAAA;AA5BvD;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;;AAMA,SAASe,aAAaA,CAAE;EAAEC,SAAS;EAAEC,iBAAiB,GAAG;AAAM,CAAC,EAAG;EAClE,MAAM;IAAEC,mBAAmB;IAAEC;EAAoB,CAAC,GACjD,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC3B,MAAM;IACLC,iBAAiB;IACj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AC3DyD,IAAI,EAAGU,eAAU;YACjBX,QAAQ,EAAGvD,iBAAmB;YAC9BoD,SAAS,EAAG7C;YACZ;YACAmD,KAAK,EAAG,IAAAvB,QAAE,EAAE,mBAAoB,CAAG;YACnCmB,OAAO,EAAGlB,cAAgB;YAC1B+B,QAAQ,EAAG3D,gBAAkB;YAC7BmD,WAAW,EAAG,CAAE/C,cAAgB;YAChCiC,OAAO,EACNjC,cAAc,GAAG,UAAU,GAAGkD,SAC9B;YACD,iBAAgBvD,cAAgB;YAChC0C,GAAG,EAAGvC,iBAAmB;YACzBqD,IAAI,EAAC;UAAS,CACd,CACD;QAAA,CACA,CACF;MAAA,CACG;IAAC,CACW;EAAC;AAErB;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcxE,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_compose","_data","_i18n","_blockEditor","_components","_icons","_element","_keyboardShortcuts","_preferences","_lockUnlock","_store","_redo","_undo","_jsxRuntime","DocumentTools","className","disableBlockTools","setIsInserterOpened","setIsListViewOpened","useDispatch","editorStore","isDistractionFree","isInserterOpened","isListViewOpen","listViewShortcut","inserterSidebarToggleRef","listViewToggleRef","showIconLabels","useSelect","select","get","preferencesStore","isListViewOpened","getEditorMode","getInserterSidebarToggleRef","getListViewToggleRef","unlock","getShortcutRepresentation","keyboardShortcutsStore","__unstableGetEditorMode","blockEditorStore","isVisualMode","isZoomedOutView","preventDefault","event","isLargeViewport","useViewportMatch","isWideViewport","toolbarAriaLabel","__","toggleListView","useCallback","toggleInserter","longLabel","_x","shortLabel","jsx","NavigableToolbar","clsx","variant","children","jsxs","ToolbarItem","ref","as","Button","isPressed","onMouseDown","onClick","disabled","icon","plus","label","showTooltip","Fragment","ToolSelector","undefined","size","EditorHistoryUndo","EditorHistoryRedo","listView","shortcut","_default","exports","default"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nfunction DocumentTools( { className, disableBlockTools = false } ) {\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisDistractionFree,\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst preventDefault = ( event ) => {\n\t\t// Because the inserter behaves like a dialog,\n\t\t// if the inserter is opened already then when we click on the toggle button\n\t\t// then the initial click event will close the inserter and then be propagated\n\t\t// to the inserter toggle and it will open it again.\n\t\t// To prevent this we need to stop the propagation of the event.\n\t\t// This won't be necessary when the inserter no longer behaves like a dialog.\n\n\t\tif ( isInserterOpened ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpened ),\n\t\t[ isInserterOpened, setIsInserterOpened ]\n\t);\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AAKA,IAAAU,WAAA,GAAAV,OAA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AAE9C,cAAgB;YAChCgC,OAAO,EAAGhC,cAAc,GAAG,UAAU,GAAGiD,SAAW;YACnDC,IAAI,EAAC;UAAS,CACd,CAAC,EACA,CAAExD,iBAAiB,iBACpB,IAAAR,WAAA,CAAA2C,GAAA,EAACpD,WAAA,CAAA0D,WAAW;YACXE,EAAE,EAAGC,kBAAQ;YACblD,SAAS,EAAC,iDAAiD;YAC3DuD,IAAI,EAAGU,eAAU;YACjBX,QAAQ,EAAGrD,iBAAmB;YAC9BkD,SAAS,EAAG3C;YACZ;YACAiD,KAAK,EAAG,IAAAvB,QAAE,EAAE,mBAAoB,CAAG;YACnCmB,OAAO,EAAGlB,cAAgB;YAC1B+B,QAAQ,EAAGzD,gBAAkB;YAC7BiD,WAAW,EAAG,CAAE9C,cAAgB;YAChCgC,OAAO,EACNhC,cAAc,GAAG,UAAU,GAAGiD,SAC9B;YACD,iBAAgBrD,cAAgB;YAChCwC,GAAG,EAAGrC,iBAAmB;YACzBmD,IAAI,EAAC;UAAS,CACd,CACD;QAAA,CACA,CACF;MAAA,CACG;IAAC,CACW;EAAC;AAErB;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEctE,aAAa","ignoreList":[]}
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
8
9
|
var _data = require("@wordpress/data");
|
|
9
10
|
var _compose = require("@wordpress/compose");
|
|
10
11
|
var _components = require("@wordpress/components");
|
|
11
12
|
var _preferences = require("@wordpress/preferences");
|
|
12
13
|
var _element = require("@wordpress/element");
|
|
13
14
|
var _interface = require("@wordpress/interface");
|
|
14
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
15
15
|
var _backButton = _interopRequireWildcard(require("./back-button"));
|
|
16
16
|
var _collapsibleBlockToolbar = _interopRequireDefault(require("../collapsible-block-toolbar"));
|
|
17
17
|
var _documentBar = _interopRequireDefault(require("../document-bar"));
|
|
@@ -81,10 +81,12 @@ function Header({
|
|
|
81
81
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
82
82
|
const isTooNarrowForDocumentBar = (0, _compose.useMediaQuery)('(max-width: 403px)');
|
|
83
83
|
const {
|
|
84
|
+
postType,
|
|
84
85
|
isTextEditor,
|
|
85
86
|
isPublishSidebarOpened,
|
|
86
87
|
showIconLabels,
|
|
87
88
|
hasFixedToolbar,
|
|
89
|
+
hasBlockSelection,
|
|
88
90
|
isNestedEntity
|
|
89
91
|
} = (0, _data.useSelect)(select => {
|
|
90
92
|
const {
|
|
@@ -93,26 +95,27 @@ function Header({
|
|
|
93
95
|
const {
|
|
94
96
|
getEditorMode,
|
|
95
97
|
getEditorSettings,
|
|
98
|
+
getCurrentPostType,
|
|
96
99
|
isPublishSidebarOpened: _isPublishSidebarOpened
|
|
97
100
|
} = select(_store.store);
|
|
98
|
-
const {
|
|
99
|
-
__unstableGetEditorMode
|
|
100
|
-
} = select(_blockEditor.store);
|
|
101
101
|
return {
|
|
102
|
+
postType: getCurrentPostType(),
|
|
102
103
|
isTextEditor: getEditorMode() === 'text',
|
|
103
104
|
isPublishSidebarOpened: _isPublishSidebarOpened(),
|
|
104
105
|
showIconLabels: getPreference('core', 'showIconLabels'),
|
|
105
106
|
hasFixedToolbar: getPreference('core', 'fixedToolbar'),
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
hasBlockSelection: !!select(_blockEditor.store).getBlockSelectionStart(),
|
|
108
|
+
isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord
|
|
108
109
|
};
|
|
109
110
|
}, []);
|
|
111
|
+
const canBeZoomedOut = ['post', 'page', 'wp_template'].includes(postType);
|
|
110
112
|
const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0, _element.useState)(true);
|
|
111
|
-
const hasCenter = isBlockToolsCollapsed && !isTooNarrowForDocumentBar;
|
|
113
|
+
const hasCenter = (!hasBlockSelection || isBlockToolsCollapsed) && !isTooNarrowForDocumentBar;
|
|
112
114
|
const hasBackButton = (0, _backButton.useHasBackButton)();
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
/*
|
|
116
|
+
* The edit-post-header classname is only kept for backward compatability
|
|
117
|
+
* as some plugins might be relying on its presence.
|
|
118
|
+
*/
|
|
116
119
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
117
120
|
className: "editor-header edit-post-header",
|
|
118
121
|
children: [hasBackButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__unstableMotion.div, {
|
|
@@ -151,20 +154,22 @@ function Header({
|
|
|
151
154
|
className: "editor-header__settings",
|
|
152
155
|
children: [!customSaveButton && !isPublishSidebarOpened &&
|
|
153
156
|
/*#__PURE__*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
/*
|
|
158
|
+
* This button isn't completely hidden by the publish sidebar.
|
|
159
|
+
* We can't hide the whole toolbar when the publish sidebar is open because
|
|
160
|
+
* we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
|
|
161
|
+
* We track that DOM node to return focus to the PostPublishButtonOrToggle
|
|
162
|
+
* when the publish sidebar has been closed.
|
|
163
|
+
*/
|
|
159
164
|
(0, _jsxRuntime.jsx)(_postSavedState.default, {
|
|
160
165
|
forceIsDirty: forceIsDirty
|
|
161
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_previewDropdown.default, {
|
|
166
|
+
}), canBeZoomedOut && isEditorIframed && isWideViewport && /*#__PURE__*/(0, _jsxRuntime.jsx)(_zoomOutToggle.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_previewDropdown.default, {
|
|
162
167
|
forceIsAutosaveable: forceIsDirty,
|
|
163
168
|
disabled: isNestedEntity
|
|
164
169
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPreviewButton.default, {
|
|
165
170
|
className: "editor-header__post-preview-button",
|
|
166
171
|
forceIsAutosaveable: forceIsDirty
|
|
167
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_postViewLink.default, {}),
|
|
172
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_postViewLink.default, {}), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_interface.PinnedItems.Slot, {
|
|
168
173
|
scope: "core"
|
|
169
174
|
}), !customSaveButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_postPublishButtonOrToggle.default, {
|
|
170
175
|
forceIsDirty: forceIsDirty,
|