@wordpress/editor 13.28.3 → 13.28.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bindings/index.js +2 -2
- package/build/bindings/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +23 -30
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/bindings/index.js +2 -2
- package/build-module/bindings/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +24 -31
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/package.json +12 -12
- package/src/bindings/index.js +2 -2
- package/src/components/provider/disable-non-page-content-blocks.js +34 -36
- package/src/components/provider/test/disable-non-page-content-blocks.js +90 -0
- package/build/components/provider/constants.js +0 -8
- package/build/components/provider/constants.js.map +0 -1
- package/build-module/components/provider/constants.js +0 -2
- package/build-module/components/provider/constants.js.map +0 -1
- package/src/components/provider/constants.js +0 -5
package/build/bindings/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var
|
|
4
|
+
var _blocks = require("@wordpress/blocks");
|
|
5
5
|
var _data = require("@wordpress/data");
|
|
6
6
|
var _lockUnlock = require("../lock-unlock");
|
|
7
7
|
var _patternOverrides = _interopRequireDefault(require("./pattern-overrides"));
|
|
@@ -16,7 +16,7 @@ var _postMeta = _interopRequireDefault(require("./post-meta"));
|
|
|
16
16
|
|
|
17
17
|
const {
|
|
18
18
|
registerBlockBindingsSource
|
|
19
|
-
} = (0, _lockUnlock.unlock)((0, _data.dispatch)(
|
|
19
|
+
} = (0, _lockUnlock.unlock)((0, _data.dispatch)(_blocks.store));
|
|
20
20
|
registerBlockBindingsSource(_patternOverrides.default);
|
|
21
21
|
registerBlockBindingsSource(_postMeta.default);
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_blocks","require","_data","_lockUnlock","_patternOverrides","_interopRequireDefault","_postMeta","registerBlockBindingsSource","unlock","dispatch","blocksStore","patternOverrides","postMeta"],"sources":["@wordpress/editor/src/bindings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\n\nconst { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );\nregisterBlockBindingsSource( patternOverrides );\nregisterBlockBindingsSource( postMeta );\n"],"mappings":";;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAIA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAM;EAAEM;AAA4B,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,cAAQ,EAAEC,aAAY,CAAE,CAAC;AACzEH,2BAA2B,CAAEI,yBAAiB,CAAC;AAC/CJ,2BAA2B,CAAEK,iBAAS,CAAC"}
|
|
@@ -4,41 +4,43 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = DisableNonPageContentBlocks;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _data = require("@wordpress/data");
|
|
9
8
|
var _blockEditor = require("@wordpress/block-editor");
|
|
10
9
|
var _element = require("@wordpress/element");
|
|
11
|
-
var _constants = require("./constants");
|
|
12
10
|
/**
|
|
13
11
|
* WordPress dependencies
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function DisableBlock({
|
|
21
|
-
clientId
|
|
22
|
-
}) {
|
|
23
|
-
const isDescendentOfQueryLoop = (0, _data.useSelect)(select => {
|
|
14
|
+
const PAGE_CONTENT_BLOCKS = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
|
|
15
|
+
function useDisableNonPageContentBlocks() {
|
|
16
|
+
const contentIds = (0, _data.useSelect)(select => {
|
|
24
17
|
const {
|
|
25
|
-
|
|
18
|
+
getBlocksByName,
|
|
19
|
+
getBlockParents,
|
|
20
|
+
getBlockName
|
|
26
21
|
} = select(_blockEditor.store);
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
return getBlocksByName(PAGE_CONTENT_BLOCKS).filter(clientId => getBlockParents(clientId).every(parentClientId => {
|
|
23
|
+
const parentBlockName = getBlockName(parentClientId);
|
|
24
|
+
return parentBlockName !== 'core/query' && !PAGE_CONTENT_BLOCKS.includes(parentBlockName);
|
|
25
|
+
}));
|
|
26
|
+
}, []);
|
|
30
27
|
const {
|
|
31
28
|
setBlockEditingMode,
|
|
32
29
|
unsetBlockEditingMode
|
|
33
30
|
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
34
31
|
(0, _element.useEffect)(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
32
|
+
setBlockEditingMode('', 'disabled'); // Disable editing at the root level.
|
|
33
|
+
|
|
34
|
+
for (const contentId of contentIds) {
|
|
35
|
+
setBlockEditingMode(contentId, 'contentOnly'); // Re-enable each content block.
|
|
40
36
|
}
|
|
41
|
-
|
|
37
|
+
return () => {
|
|
38
|
+
unsetBlockEditingMode('');
|
|
39
|
+
for (const contentId of contentIds) {
|
|
40
|
+
unsetBlockEditingMode(contentId);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}, [contentIds, setBlockEditingMode, unsetBlockEditingMode]);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
/**
|
|
@@ -46,15 +48,6 @@ function DisableBlock({
|
|
|
46
48
|
* page content to be edited.
|
|
47
49
|
*/
|
|
48
50
|
function DisableNonPageContentBlocks() {
|
|
49
|
-
(
|
|
50
|
-
const clientIds = (0, _data.useSelect)(select => {
|
|
51
|
-
return select(_blockEditor.store).getBlocksByName(_constants.PAGE_CONTENT_BLOCK_TYPES);
|
|
52
|
-
}, []);
|
|
53
|
-
return clientIds.map(clientId => {
|
|
54
|
-
return (0, _react.createElement)(DisableBlock, {
|
|
55
|
-
key: clientId,
|
|
56
|
-
clientId: clientId
|
|
57
|
-
});
|
|
58
|
-
});
|
|
51
|
+
useDisableNonPageContentBlocks();
|
|
59
52
|
}
|
|
60
53
|
//# sourceMappingURL=disable-non-page-content-blocks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blockEditor","_element","
|
|
1
|
+
{"version":3,"names":["_data","require","_blockEditor","_element","PAGE_CONTENT_BLOCKS","useDisableNonPageContentBlocks","contentIds","useSelect","select","getBlocksByName","getBlockParents","getBlockName","blockEditorStore","filter","clientId","every","parentClientId","parentBlockName","includes","setBlockEditingMode","unsetBlockEditingMode","useDispatch","useEffect","contentId","DisableNonPageContentBlocks"],"sources":["@wordpress/editor/src/components/provider/disable-non-page-content-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\n\nconst PAGE_CONTENT_BLOCKS = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n\nfunction useDisableNonPageContentBlocks() {\n\tconst contentIds = useSelect( ( select ) => {\n\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\treturn getBlocksByName( PAGE_CONTENT_BLOCKS ).filter( ( clientId ) =>\n\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\treturn (\n\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t! PAGE_CONTENT_BLOCKS.includes( parentBlockName )\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t}, [] );\n\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tsetBlockEditingMode( '', 'disabled' ); // Disable editing at the root level.\n\n\t\tfor ( const contentId of contentIds ) {\n\t\t\tsetBlockEditingMode( contentId, 'contentOnly' ); // Re-enable each content block.\n\t\t}\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( '' );\n\t\t\tfor ( const contentId of contentIds ) {\n\t\t\t\tunsetBlockEditingMode( contentId );\n\t\t\t}\n\t\t};\n\t}, [ contentIds, setBlockEditingMode, unsetBlockEditingMode ] );\n}\n\n/**\n * Component that when rendered, makes it so that the site editor allows only\n * page content to be edited.\n */\nexport default function DisableNonPageContentBlocks() {\n\tuseDisableNonPageContentBlocks();\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AALA;AACA;AACA;;AAKA,MAAMG,mBAAmB,GAAG,CAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,CACnB;AAED,SAASC,8BAA8BA,CAAA,EAAG;EACzC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC3C,MAAM;MAAEC,eAAe;MAAEC,eAAe;MAAEC;IAAa,CAAC,GACvDH,MAAM,CAAEI,kBAAiB,CAAC;IAC3B,OAAOH,eAAe,CAAEL,mBAAoB,CAAC,CAACS,MAAM,CAAIC,QAAQ,IAC/DJ,eAAe,CAAEI,QAAS,CAAC,CAACC,KAAK,CAAIC,cAAc,IAAM;MACxD,MAAMC,eAAe,GAAGN,YAAY,CAAEK,cAAe,CAAC;MACtD,OACCC,eAAe,KAAK,YAAY,IAChC,CAAEb,mBAAmB,CAACc,QAAQ,CAAED,eAAgB,CAAC;IAEnD,CAAE,CACH,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAEE,mBAAmB;IAAEC;EAAsB,CAAC,GACnD,IAAAC,iBAAW,EAAET,kBAAiB,CAAC;EAEhC,IAAAU,kBAAS,EAAE,MAAM;IAChBH,mBAAmB,CAAE,EAAE,EAAE,UAAW,CAAC,CAAC,CAAC;;IAEvC,KAAM,MAAMI,SAAS,IAAIjB,UAAU,EAAG;MACrCa,mBAAmB,CAAEI,SAAS,EAAE,aAAc,CAAC,CAAC,CAAC;IAClD;IACA,OAAO,MAAM;MACZH,qBAAqB,CAAE,EAAG,CAAC;MAC3B,KAAM,MAAMG,SAAS,IAAIjB,UAAU,EAAG;QACrCc,qBAAqB,CAAEG,SAAU,CAAC;MACnC;IACD,CAAC;EACF,CAAC,EAAE,CAAEjB,UAAU,EAAEa,mBAAmB,EAAEC,qBAAqB,CAAG,CAAC;AAChE;;AAEA;AACA;AACA;AACA;AACe,SAASI,2BAA2BA,CAAA,EAAG;EACrDnB,8BAA8B,CAAC,CAAC;AACjC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { store as
|
|
4
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import { dispatch } from '@wordpress/data';
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -11,7 +11,7 @@ import patternOverrides from './pattern-overrides';
|
|
|
11
11
|
import postMeta from './post-meta';
|
|
12
12
|
const {
|
|
13
13
|
registerBlockBindingsSource
|
|
14
|
-
} = unlock(dispatch(
|
|
14
|
+
} = unlock(dispatch(blocksStore));
|
|
15
15
|
registerBlockBindingsSource(patternOverrides);
|
|
16
16
|
registerBlockBindingsSource(postMeta);
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","
|
|
1
|
+
{"version":3,"names":["store","blocksStore","dispatch","unlock","patternOverrides","postMeta","registerBlockBindingsSource"],"sources":["@wordpress/editor/src/bindings/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\n\nconst { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );\nregisterBlockBindingsSource( patternOverrides );\nregisterBlockBindingsSource( postMeta );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;AACvC,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,QAAQ,MAAM,aAAa;AAElC,MAAM;EAAEC;AAA4B,CAAC,GAAGH,MAAM,CAAED,QAAQ,CAAED,WAAY,CAAE,CAAC;AACzEK,2BAA2B,CAAEF,gBAAiB,CAAC;AAC/CE,2BAA2B,CAAED,QAAS,CAAC"}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
5
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import {
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
6
|
import { useEffect } from '@wordpress/element';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
import { PAGE_CONTENT_BLOCK_TYPES } from './constants';
|
|
13
|
-
function DisableBlock({
|
|
14
|
-
clientId
|
|
15
|
-
}) {
|
|
16
|
-
const isDescendentOfQueryLoop = useSelect(select => {
|
|
7
|
+
const PAGE_CONTENT_BLOCKS = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
|
|
8
|
+
function useDisableNonPageContentBlocks() {
|
|
9
|
+
const contentIds = useSelect(select => {
|
|
17
10
|
const {
|
|
18
|
-
|
|
11
|
+
getBlocksByName,
|
|
12
|
+
getBlockParents,
|
|
13
|
+
getBlockName
|
|
19
14
|
} = select(blockEditorStore);
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
return getBlocksByName(PAGE_CONTENT_BLOCKS).filter(clientId => getBlockParents(clientId).every(parentClientId => {
|
|
16
|
+
const parentBlockName = getBlockName(parentClientId);
|
|
17
|
+
return parentBlockName !== 'core/query' && !PAGE_CONTENT_BLOCKS.includes(parentBlockName);
|
|
18
|
+
}));
|
|
19
|
+
}, []);
|
|
23
20
|
const {
|
|
24
21
|
setBlockEditingMode,
|
|
25
22
|
unsetBlockEditingMode
|
|
26
23
|
} = useDispatch(blockEditorStore);
|
|
27
24
|
useEffect(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
25
|
+
setBlockEditingMode('', 'disabled'); // Disable editing at the root level.
|
|
26
|
+
|
|
27
|
+
for (const contentId of contentIds) {
|
|
28
|
+
setBlockEditingMode(contentId, 'contentOnly'); // Re-enable each content block.
|
|
33
29
|
}
|
|
34
|
-
|
|
30
|
+
return () => {
|
|
31
|
+
unsetBlockEditingMode('');
|
|
32
|
+
for (const contentId of contentIds) {
|
|
33
|
+
unsetBlockEditingMode(contentId);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, [contentIds, setBlockEditingMode, unsetBlockEditingMode]);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/**
|
|
@@ -39,15 +41,6 @@ function DisableBlock({
|
|
|
39
41
|
* page content to be edited.
|
|
40
42
|
*/
|
|
41
43
|
export default function DisableNonPageContentBlocks() {
|
|
42
|
-
|
|
43
|
-
const clientIds = useSelect(select => {
|
|
44
|
-
return select(blockEditorStore).getBlocksByName(PAGE_CONTENT_BLOCK_TYPES);
|
|
45
|
-
}, []);
|
|
46
|
-
return clientIds.map(clientId => {
|
|
47
|
-
return createElement(DisableBlock, {
|
|
48
|
-
key: clientId,
|
|
49
|
-
clientId: clientId
|
|
50
|
-
});
|
|
51
|
-
});
|
|
44
|
+
useDisableNonPageContentBlocks();
|
|
52
45
|
}
|
|
53
46
|
//# sourceMappingURL=disable-non-page-content-blocks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","store","blockEditorStore","useEffect","PAGE_CONTENT_BLOCKS","useDisableNonPageContentBlocks","contentIds","select","getBlocksByName","getBlockParents","getBlockName","filter","clientId","every","parentClientId","parentBlockName","includes","setBlockEditingMode","unsetBlockEditingMode","contentId","DisableNonPageContentBlocks"],"sources":["@wordpress/editor/src/components/provider/disable-non-page-content-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\n\nconst PAGE_CONTENT_BLOCKS = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n\nfunction useDisableNonPageContentBlocks() {\n\tconst contentIds = useSelect( ( select ) => {\n\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\tselect( blockEditorStore );\n\t\treturn getBlocksByName( PAGE_CONTENT_BLOCKS ).filter( ( clientId ) =>\n\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\treturn (\n\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t! PAGE_CONTENT_BLOCKS.includes( parentBlockName )\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t}, [] );\n\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tsetBlockEditingMode( '', 'disabled' ); // Disable editing at the root level.\n\n\t\tfor ( const contentId of contentIds ) {\n\t\t\tsetBlockEditingMode( contentId, 'contentOnly' ); // Re-enable each content block.\n\t\t}\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( '' );\n\t\t\tfor ( const contentId of contentIds ) {\n\t\t\t\tunsetBlockEditingMode( contentId );\n\t\t\t}\n\t\t};\n\t}, [ contentIds, setBlockEditingMode, unsetBlockEditingMode ] );\n}\n\n/**\n * Component that when rendered, makes it so that the site editor allows only\n * page content to be edited.\n */\nexport default function DisableNonPageContentBlocks() {\n\tuseDisableNonPageContentBlocks();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,SAAS,QAAQ,oBAAoB;AAE9C,MAAMC,mBAAmB,GAAG,CAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,CACnB;AAED,SAASC,8BAA8BA,CAAA,EAAG;EACzC,MAAMC,UAAU,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IAC3C,MAAM;MAAEC,eAAe;MAAEC,eAAe;MAAEC;IAAa,CAAC,GACvDH,MAAM,CAAEL,gBAAiB,CAAC;IAC3B,OAAOM,eAAe,CAAEJ,mBAAoB,CAAC,CAACO,MAAM,CAAIC,QAAQ,IAC/DH,eAAe,CAAEG,QAAS,CAAC,CAACC,KAAK,CAAIC,cAAc,IAAM;MACxD,MAAMC,eAAe,GAAGL,YAAY,CAAEI,cAAe,CAAC;MACtD,OACCC,eAAe,KAAK,YAAY,IAChC,CAAEX,mBAAmB,CAACY,QAAQ,CAAED,eAAgB,CAAC;IAEnD,CAAE,CACH,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAEE,mBAAmB;IAAEC;EAAsB,CAAC,GACnDlB,WAAW,CAAEE,gBAAiB,CAAC;EAEhCC,SAAS,CAAE,MAAM;IAChBc,mBAAmB,CAAE,EAAE,EAAE,UAAW,CAAC,CAAC,CAAC;;IAEvC,KAAM,MAAME,SAAS,IAAIb,UAAU,EAAG;MACrCW,mBAAmB,CAAEE,SAAS,EAAE,aAAc,CAAC,CAAC,CAAC;IAClD;IACA,OAAO,MAAM;MACZD,qBAAqB,CAAE,EAAG,CAAC;MAC3B,KAAM,MAAMC,SAAS,IAAIb,UAAU,EAAG;QACrCY,qBAAqB,CAAEC,SAAU,CAAC;MACnC;IACD,CAAC;EACF,CAAC,EAAE,CAAEb,UAAU,EAAEW,mBAAmB,EAAEC,qBAAqB,CAAG,CAAC;AAChE;;AAEA;AACA;AACA;AACA;AACA,eAAe,SAASE,2BAA2BA,CAAA,EAAG;EACrDf,8BAA8B,CAAC,CAAC;AACjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/editor",
|
|
3
|
-
"version": "13.28.
|
|
3
|
+
"version": "13.28.4",
|
|
4
4
|
"description": "Enhanced block editor for WordPress posts.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"@wordpress/a11y": "^3.51.1",
|
|
35
35
|
"@wordpress/api-fetch": "^6.48.1",
|
|
36
36
|
"@wordpress/blob": "^3.51.1",
|
|
37
|
-
"@wordpress/block-editor": "^12.19.
|
|
38
|
-
"@wordpress/blocks": "^12.28.
|
|
39
|
-
"@wordpress/commands": "^0.22.
|
|
40
|
-
"@wordpress/components": "^26.0.
|
|
37
|
+
"@wordpress/block-editor": "^12.19.4",
|
|
38
|
+
"@wordpress/blocks": "^12.28.4",
|
|
39
|
+
"@wordpress/commands": "^0.22.3",
|
|
40
|
+
"@wordpress/components": "^26.0.3",
|
|
41
41
|
"@wordpress/compose": "^6.28.1",
|
|
42
|
-
"@wordpress/core-data": "^6.28.
|
|
42
|
+
"@wordpress/core-data": "^6.28.4",
|
|
43
43
|
"@wordpress/data": "^9.21.1",
|
|
44
44
|
"@wordpress/date": "^4.51.1",
|
|
45
45
|
"@wordpress/deprecated": "^3.51.1",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"@wordpress/hooks": "^3.51.1",
|
|
49
49
|
"@wordpress/html-entities": "^3.51.1",
|
|
50
50
|
"@wordpress/i18n": "^4.51.1",
|
|
51
|
-
"@wordpress/icons": "^9.42.
|
|
51
|
+
"@wordpress/icons": "^9.42.2",
|
|
52
52
|
"@wordpress/keyboard-shortcuts": "^4.28.1",
|
|
53
53
|
"@wordpress/keycodes": "^3.51.1",
|
|
54
54
|
"@wordpress/media-utils": "^4.42.1",
|
|
55
55
|
"@wordpress/notices": "^4.19.1",
|
|
56
|
-
"@wordpress/patterns": "^1.12.
|
|
57
|
-
"@wordpress/preferences": "^3.28.
|
|
56
|
+
"@wordpress/patterns": "^1.12.4",
|
|
57
|
+
"@wordpress/preferences": "^3.28.3",
|
|
58
58
|
"@wordpress/private-apis": "^0.33.1",
|
|
59
|
-
"@wordpress/reusable-blocks": "^4.28.
|
|
59
|
+
"@wordpress/reusable-blocks": "^4.28.4",
|
|
60
60
|
"@wordpress/rich-text": "^6.28.2",
|
|
61
|
-
"@wordpress/server-side-render": "^4.28.
|
|
61
|
+
"@wordpress/server-side-render": "^4.28.4",
|
|
62
62
|
"@wordpress/url": "^3.52.1",
|
|
63
63
|
"@wordpress/wordcount": "^3.51.1",
|
|
64
64
|
"classnames": "^2.3.1",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "864c1c553cb284def3bd5c907998da45f5c143ea"
|
|
79
79
|
}
|
package/src/bindings/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { store as
|
|
4
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
5
|
import { dispatch } from '@wordpress/data';
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -10,6 +10,6 @@ import { unlock } from '../lock-unlock';
|
|
|
10
10
|
import patternOverrides from './pattern-overrides';
|
|
11
11
|
import postMeta from './post-meta';
|
|
12
12
|
|
|
13
|
-
const { registerBlockBindingsSource } = unlock( dispatch(
|
|
13
|
+
const { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) );
|
|
14
14
|
registerBlockBindingsSource( patternOverrides );
|
|
15
15
|
registerBlockBindingsSource( postMeta );
|
|
@@ -2,39 +2,46 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import {
|
|
6
|
-
useBlockEditingMode,
|
|
7
|
-
store as blockEditorStore,
|
|
8
|
-
} from '@wordpress/block-editor';
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
6
|
import { useEffect } from '@wordpress/element';
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const PAGE_CONTENT_BLOCKS = [
|
|
9
|
+
'core/post-title',
|
|
10
|
+
'core/post-featured-image',
|
|
11
|
+
'core/post-content',
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function useDisableNonPageContentBlocks() {
|
|
15
|
+
const contentIds = useSelect( ( select ) => {
|
|
16
|
+
const { getBlocksByName, getBlockParents, getBlockName } =
|
|
17
|
+
select( blockEditorStore );
|
|
18
|
+
return getBlocksByName( PAGE_CONTENT_BLOCKS ).filter( ( clientId ) =>
|
|
19
|
+
getBlockParents( clientId ).every( ( parentClientId ) => {
|
|
20
|
+
const parentBlockName = getBlockName( parentClientId );
|
|
21
|
+
return (
|
|
22
|
+
parentBlockName !== 'core/query' &&
|
|
23
|
+
! PAGE_CONTENT_BLOCKS.includes( parentBlockName )
|
|
24
|
+
);
|
|
25
|
+
} )
|
|
26
|
+
);
|
|
27
|
+
}, [] );
|
|
15
28
|
|
|
16
|
-
function DisableBlock( { clientId } ) {
|
|
17
|
-
const isDescendentOfQueryLoop = useSelect(
|
|
18
|
-
( select ) => {
|
|
19
|
-
const { getBlockParentsByBlockName } = select( blockEditorStore );
|
|
20
|
-
return (
|
|
21
|
-
getBlockParentsByBlockName( clientId, 'core/query' ).length !==
|
|
22
|
-
0
|
|
23
|
-
);
|
|
24
|
-
},
|
|
25
|
-
[ clientId ]
|
|
26
|
-
);
|
|
27
|
-
const mode = isDescendentOfQueryLoop ? undefined : 'contentOnly';
|
|
28
29
|
const { setBlockEditingMode, unsetBlockEditingMode } =
|
|
29
30
|
useDispatch( blockEditorStore );
|
|
31
|
+
|
|
30
32
|
useEffect( () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
33
|
+
setBlockEditingMode( '', 'disabled' ); // Disable editing at the root level.
|
|
34
|
+
|
|
35
|
+
for ( const contentId of contentIds ) {
|
|
36
|
+
setBlockEditingMode( contentId, 'contentOnly' ); // Re-enable each content block.
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
return () => {
|
|
39
|
+
unsetBlockEditingMode( '' );
|
|
40
|
+
for ( const contentId of contentIds ) {
|
|
41
|
+
unsetBlockEditingMode( contentId );
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [ contentIds, setBlockEditingMode, unsetBlockEditingMode ] );
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
/**
|
|
@@ -42,14 +49,5 @@ function DisableBlock( { clientId } ) {
|
|
|
42
49
|
* page content to be edited.
|
|
43
50
|
*/
|
|
44
51
|
export default function DisableNonPageContentBlocks() {
|
|
45
|
-
|
|
46
|
-
const clientIds = useSelect( ( select ) => {
|
|
47
|
-
return select( blockEditorStore ).getBlocksByName(
|
|
48
|
-
PAGE_CONTENT_BLOCK_TYPES
|
|
49
|
-
);
|
|
50
|
-
}, [] );
|
|
51
|
-
|
|
52
|
-
return clientIds.map( ( clientId ) => {
|
|
53
|
-
return <DisableBlock key={ clientId } clientId={ clientId } />;
|
|
54
|
-
} );
|
|
52
|
+
useDisableNonPageContentBlocks();
|
|
55
53
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createRegistry, RegistryProvider } from '@wordpress/data';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import DisableNonPageContentBlocks from '../disable-non-page-content-blocks';
|
|
15
|
+
|
|
16
|
+
describe( 'DisableNonPageContentBlocks', () => {
|
|
17
|
+
it( 'disables page content blocks', () => {
|
|
18
|
+
const testBlocks = {
|
|
19
|
+
0: 'core/template-part',
|
|
20
|
+
/**/ '00': 'core/site-title',
|
|
21
|
+
/**/ '01': 'core/navigation',
|
|
22
|
+
1: 'core/group',
|
|
23
|
+
/**/ 10: 'core/post-title',
|
|
24
|
+
/**/ 11: 'core/post-featured-image',
|
|
25
|
+
/**/ 12: 'core/post-content',
|
|
26
|
+
/**/ /**/ 120: 'core/paragraph',
|
|
27
|
+
/**/ /**/ 121: 'core/post-featured-image',
|
|
28
|
+
2: 'core/query',
|
|
29
|
+
/**/ 20: 'core/post-title',
|
|
30
|
+
/**/ 21: 'core/post-featured-image',
|
|
31
|
+
/**/ 22: 'core/post-content',
|
|
32
|
+
3: 'core/template-part',
|
|
33
|
+
/**/ 30: 'core/paragraph',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const setBlockEditingMode = jest.fn( () => ( {
|
|
37
|
+
type: 'SET_BLOCK_EDITING_MODE',
|
|
38
|
+
} ) );
|
|
39
|
+
const unsetBlockEditingMode = jest.fn( () => ( {
|
|
40
|
+
type: 'UNSET_BLOCK_EDITING_MODE',
|
|
41
|
+
} ) );
|
|
42
|
+
|
|
43
|
+
const registry = createRegistry( {
|
|
44
|
+
'core/block-editor': {
|
|
45
|
+
reducer: () => {},
|
|
46
|
+
selectors: {
|
|
47
|
+
getBlocksByName( state, blockNames ) {
|
|
48
|
+
return Object.keys( testBlocks ).filter( ( clientId ) =>
|
|
49
|
+
blockNames.includes( testBlocks[ clientId ] )
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
getBlockParents( state, clientId ) {
|
|
53
|
+
return clientId.slice( 0, -1 ).split( '' );
|
|
54
|
+
},
|
|
55
|
+
getBlockName( state, clientId ) {
|
|
56
|
+
return testBlocks[ clientId ];
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
actions: {
|
|
60
|
+
setBlockEditingMode,
|
|
61
|
+
unsetBlockEditingMode,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
} );
|
|
65
|
+
|
|
66
|
+
const { unmount } = render(
|
|
67
|
+
<RegistryProvider value={ registry }>
|
|
68
|
+
<DisableNonPageContentBlocks />
|
|
69
|
+
</RegistryProvider>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expect( setBlockEditingMode.mock.calls ).toEqual( [
|
|
73
|
+
[ '', 'disabled' ], // root
|
|
74
|
+
[ '10', 'contentOnly' ], // post-title
|
|
75
|
+
[ '11', 'contentOnly' ], // post-featured-image
|
|
76
|
+
[ '12', 'contentOnly' ], // post-content
|
|
77
|
+
// NOT the post-featured-image nested within post-content
|
|
78
|
+
// NOT any of the content blocks within query
|
|
79
|
+
] );
|
|
80
|
+
|
|
81
|
+
unmount();
|
|
82
|
+
|
|
83
|
+
expect( unsetBlockEditingMode.mock.calls ).toEqual( [
|
|
84
|
+
[ '' ], // root
|
|
85
|
+
[ '10' ], // post-title
|
|
86
|
+
[ '11' ], // post-featured-image
|
|
87
|
+
[ '12' ], // post-content
|
|
88
|
+
] );
|
|
89
|
+
} );
|
|
90
|
+
} );
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PAGE_CONTENT_BLOCK_TYPES = void 0;
|
|
7
|
-
const PAGE_CONTENT_BLOCK_TYPES = exports.PAGE_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
|
|
8
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["PAGE_CONTENT_BLOCK_TYPES","exports"],"sources":["@wordpress/editor/src/components/provider/constants.js"],"sourcesContent":["export const PAGE_CONTENT_BLOCK_TYPES = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n"],"mappings":";;;;;;AAAO,MAAMA,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,CACvC,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,CACnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["PAGE_CONTENT_BLOCK_TYPES"],"sources":["@wordpress/editor/src/components/provider/constants.js"],"sourcesContent":["export const PAGE_CONTENT_BLOCK_TYPES = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,GAAG,CACvC,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,CACnB"}
|