@wordpress/editor 13.22.0 → 13.24.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 +4 -0
- package/build/components/entities-saved-states/index.js +15 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/index.js +32 -0
- package/build/components/index.js.map +1 -1
- package/build/components/page-attributes/order.js +1 -0
- package/build/components/page-attributes/order.js.map +1 -1
- package/build/components/post-author/panel.js +24 -0
- package/build/components/post-author/panel.js.map +1 -0
- package/build/components/post-featured-image/index.js +3 -1
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-panel-row/index.js +36 -0
- package/build/components/post-panel-row/index.js.map +1 -0
- package/build/components/post-saved-state/index.js +21 -16
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/panel.js +67 -0
- package/build/components/post-schedule/panel.js.map +1 -0
- package/build/components/post-sync-status/index.js +9 -5
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-title/constants.js +11 -0
- package/build/components/post-title/constants.js.map +1 -0
- package/build/components/post-title/index.js +61 -90
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-title/post-title-raw.js +92 -0
- package/build/components/post-title/post-title-raw.js.map +1 -0
- package/build/components/post-title/use-post-title-focus.js +64 -0
- package/build/components/post-title/use-post-title-focus.js.map +1 -0
- package/build/components/post-title/use-post-title.js +41 -0
- package/build/components/post-title/use-post-title.js.map +1 -0
- package/build/components/post-url/panel.js +70 -0
- package/build/components/post-url/panel.js.map +1 -0
- package/build/components/provider/constants.js +9 -0
- package/build/components/provider/constants.js.map +1 -0
- package/build/components/provider/disable-non-page-content-blocks.js +63 -0
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -0
- package/build/components/provider/index.js +126 -14
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +22 -17
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.native.js +2 -2
- package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build/private-apis.js +7 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +23 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +10 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +16 -2
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/index.js +4 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/page-attributes/order.js +1 -0
- package/build-module/components/page-attributes/order.js.map +1 -1
- package/build-module/components/post-author/panel.js +14 -0
- package/build-module/components/post-author/panel.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +3 -1
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-panel-row/index.js +27 -0
- package/build-module/components/post-panel-row/index.js.map +1 -0
- package/build-module/components/post-saved-state/index.js +22 -17
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +59 -0
- package/build-module/components/post-schedule/panel.js.map +1 -0
- package/build-module/components/post-sync-status/index.js +10 -7
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-title/constants.js +3 -0
- package/build-module/components/post-title/constants.js.map +1 -0
- package/build-module/components/post-title/index.js +62 -92
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/index.native.js +3 -3
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js +83 -0
- package/build-module/components/post-title/post-title-raw.js.map +1 -0
- package/build-module/components/post-title/use-post-title-focus.js +57 -0
- package/build-module/components/post-title/use-post-title-focus.js.map +1 -0
- package/build-module/components/post-title/use-post-title.js +33 -0
- package/build-module/components/post-title/use-post-title.js.map +1 -0
- package/build-module/components/post-url/panel.js +62 -0
- package/build-module/components/post-url/panel.js.map +1 -0
- package/build-module/components/provider/constants.js +2 -0
- package/build-module/components/provider/constants.js.map +1 -0
- package/build-module/components/provider/disable-non-page-content-blocks.js +56 -0
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -0
- package/build-module/components/provider/index.js +127 -15
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +22 -17
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.native.js +2 -2
- package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
- package/build-module/private-apis.js +6 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +21 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +9 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +11 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +70 -10
- package/build-style/style.css +70 -10
- package/package.json +31 -31
- package/src/components/entities-saved-states/index.js +16 -1
- package/src/components/index.js +4 -0
- package/src/components/page-attributes/order.js +1 -0
- package/src/components/post-author/panel.js +18 -0
- package/src/components/post-author/style.scss +7 -0
- package/src/components/post-featured-image/index.js +3 -1
- package/src/components/post-panel-row/index.js +26 -0
- package/src/components/post-panel-row/style.scss +21 -0
- package/src/components/post-saved-state/index.js +46 -37
- package/src/components/post-schedule/panel.js +65 -0
- package/src/components/post-schedule/style.scss +23 -0
- package/src/components/post-sync-status/index.js +10 -8
- package/src/components/post-sync-status/style.scss +3 -18
- package/src/components/post-title/constants.js +4 -0
- package/src/components/post-title/index.js +56 -88
- package/src/components/post-title/index.native.js +4 -8
- package/src/components/post-title/post-title-raw.js +82 -0
- package/src/components/post-title/style.scss +5 -0
- package/src/components/post-title/use-post-title-focus.js +50 -0
- package/src/components/post-title/use-post-title.js +25 -0
- package/src/components/post-url/panel.js +60 -0
- package/src/components/post-url/style.scss +19 -0
- package/src/components/provider/README.md +37 -0
- package/src/components/provider/constants.js +5 -0
- package/src/components/provider/disable-non-page-content-blocks.js +55 -0
- package/src/components/provider/index.js +200 -14
- package/src/components/provider/use-block-editor-settings.js +54 -35
- package/src/components/provider/use-block-editor-settings.native.js +2 -2
- package/src/private-apis.js +6 -0
- package/src/store/actions.js +21 -0
- package/src/store/reducer.js +10 -0
- package/src/store/selectors.js +11 -0
- package/src/style.scss +4 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { store as editorStore } from '../../store';
|
|
9
|
+
export default function usePostTitle() {
|
|
10
|
+
const {
|
|
11
|
+
editPost
|
|
12
|
+
} = useDispatch(editorStore);
|
|
13
|
+
const {
|
|
14
|
+
title
|
|
15
|
+
} = useSelect(select => {
|
|
16
|
+
const {
|
|
17
|
+
getEditedPostAttribute
|
|
18
|
+
} = select(editorStore);
|
|
19
|
+
return {
|
|
20
|
+
title: getEditedPostAttribute('title')
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
function updateTitle(newTitle) {
|
|
24
|
+
editPost({
|
|
25
|
+
title: newTitle
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
title,
|
|
30
|
+
setTitle: updateTitle
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=use-post-title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","store","editorStore","usePostTitle","editPost","title","select","getEditedPostAttribute","updateTitle","newTitle","setTitle"],"sources":["@wordpress/editor/src/components/post-title/use-post-title.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function usePostTitle() {\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { title } = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t};\n\t}, [] );\n\n\tfunction updateTitle( newTitle ) {\n\t\teditPost( { title: newTitle } );\n\t}\n\n\treturn { title, setTitle: updateTitle };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC;EAAS,CAAC,GAAGJ,WAAW,CAAEE,WAAY,CAAC;EAC/C,MAAM;IAAEG;EAAM,CAAC,GAAGN,SAAS,CAAIO,MAAM,IAAM;IAC1C,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEJ,WAAY,CAAC;IAExD,OAAO;MACNG,KAAK,EAAEE,sBAAsB,CAAE,OAAQ;IACxC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,SAASC,WAAWA,CAAEC,QAAQ,EAAG;IAChCL,QAAQ,CAAE;MAAEC,KAAK,EAAEI;IAAS,CAAE,CAAC;EAChC;EAEA,OAAO;IAAEJ,KAAK;IAAEK,QAAQ,EAAEF;EAAY,CAAC;AACxC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
6
|
+
import { Dropdown, Button } from '@wordpress/components';
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import PostURLCheck from './check';
|
|
13
|
+
import PostURL from './index';
|
|
14
|
+
import { usePostURLLabel } from './label';
|
|
15
|
+
import PostPanelRow from '../post-panel-row';
|
|
16
|
+
export default function PostURLPanel() {
|
|
17
|
+
// Use internal state instead of a ref to make sure that the component
|
|
18
|
+
// re-renders when the popover's anchor updates.
|
|
19
|
+
const [popoverAnchor, setPopoverAnchor] = useState(null);
|
|
20
|
+
// Memoize popoverProps to avoid returning a new object every time.
|
|
21
|
+
const popoverProps = useMemo(() => ({
|
|
22
|
+
anchor: popoverAnchor,
|
|
23
|
+
placement: 'bottom-end'
|
|
24
|
+
}), [popoverAnchor]);
|
|
25
|
+
return createElement(PostURLCheck, null, createElement(PostPanelRow, {
|
|
26
|
+
label: __('URL'),
|
|
27
|
+
ref: setPopoverAnchor
|
|
28
|
+
}, createElement(Dropdown, {
|
|
29
|
+
popoverProps: popoverProps,
|
|
30
|
+
className: "editor-post-url__panel-dropdown",
|
|
31
|
+
contentClassName: "editor-post-url__panel-dialog",
|
|
32
|
+
focusOnMount: true,
|
|
33
|
+
renderToggle: ({
|
|
34
|
+
isOpen,
|
|
35
|
+
onToggle
|
|
36
|
+
}) => createElement(PostURLToggle, {
|
|
37
|
+
isOpen: isOpen,
|
|
38
|
+
onClick: onToggle
|
|
39
|
+
}),
|
|
40
|
+
renderContent: ({
|
|
41
|
+
onClose
|
|
42
|
+
}) => createElement(PostURL, {
|
|
43
|
+
onClose: onClose
|
|
44
|
+
})
|
|
45
|
+
})));
|
|
46
|
+
}
|
|
47
|
+
function PostURLToggle({
|
|
48
|
+
isOpen,
|
|
49
|
+
onClick
|
|
50
|
+
}) {
|
|
51
|
+
const label = usePostURLLabel();
|
|
52
|
+
return createElement(Button, {
|
|
53
|
+
className: "editor-post-url__panel-toggle",
|
|
54
|
+
variant: "tertiary",
|
|
55
|
+
"aria-expanded": isOpen
|
|
56
|
+
// translators: %s: Current post URL.
|
|
57
|
+
,
|
|
58
|
+
"aria-label": sprintf(__('Change URL: %s'), label),
|
|
59
|
+
onClick: onClick
|
|
60
|
+
}, label);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useState","Dropdown","Button","__","sprintf","PostURLCheck","PostURL","usePostURLLabel","PostPanelRow","PostURLPanel","popoverAnchor","setPopoverAnchor","popoverProps","anchor","placement","createElement","label","ref","className","contentClassName","focusOnMount","renderToggle","isOpen","onToggle","PostURLToggle","onClick","renderContent","onClose","variant"],"sources":["@wordpress/editor/src/components/post-url/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PostURLCheck from './check';\nimport PostURL from './index';\nimport { usePostURLLabel } from './label';\nimport PostPanelRow from '../post-panel-row';\n\nexport default function PostURLPanel() {\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( { anchor: popoverAnchor, placement: 'bottom-end' } ),\n\t\t[ popoverAnchor ]\n\t);\n\n\treturn (\n\t\t<PostURLCheck>\n\t\t\t<PostPanelRow label={ __( 'URL' ) } ref={ setPopoverAnchor }>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\tclassName=\"editor-post-url__panel-dropdown\"\n\t\t\t\t\tcontentClassName=\"editor-post-url__panel-dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostURLToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostURL onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PostPanelRow>\n\t\t</PostURLCheck>\n\t);\n}\n\nfunction PostURLToggle( { isOpen, onClick } ) {\n\tconst label = usePostURLLabel();\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"editor-post-url__panel-toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post URL.\n\t\t\taria-label={ sprintf( __( 'Change URL: %s' ), label ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACtD,SAASC,QAAQ,EAAEC,MAAM,QAAQ,uBAAuB;AACxD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,SAAS;AAClC,OAAOC,OAAO,MAAM,SAAS;AAC7B,SAASC,eAAe,QAAQ,SAAS;AACzC,OAAOC,YAAY,MAAM,mBAAmB;AAE5C,eAAe,SAASC,YAAYA,CAAA,EAAG;EACtC;EACA;EACA,MAAM,CAAEC,aAAa,EAAEC,gBAAgB,CAAE,GAAGX,QAAQ,CAAE,IAAK,CAAC;EAC5D;EACA,MAAMY,YAAY,GAAGb,OAAO,CAC3B,OAAQ;IAAEc,MAAM,EAAEH,aAAa;IAAEI,SAAS,EAAE;EAAa,CAAC,CAAE,EAC5D,CAAEJ,aAAa,CAChB,CAAC;EAED,OACCK,aAAA,CAACV,YAAY,QACZU,aAAA,CAACP,YAAY;IAACQ,KAAK,EAAGb,EAAE,CAAE,KAAM,CAAG;IAACc,GAAG,EAAGN;EAAkB,GAC3DI,aAAA,CAACd,QAAQ;IACRW,YAAY,EAAGA,YAAc;IAC7BM,SAAS,EAAC,iCAAiC;IAC3CC,gBAAgB,EAAC,+BAA+B;IAChDC,YAAY;IACZC,YAAY,EAAGA,CAAE;MAAEC,MAAM;MAAEC;IAAS,CAAC,KACpCR,aAAA,CAACS,aAAa;MAACF,MAAM,EAAGA,MAAQ;MAACG,OAAO,EAAGF;IAAU,CAAE,CACrD;IACHG,aAAa,EAAGA,CAAE;MAAEC;IAAQ,CAAC,KAC5BZ,aAAA,CAACT,OAAO;MAACqB,OAAO,EAAGA;IAAS,CAAE;EAC5B,CACH,CACY,CACD,CAAC;AAEjB;AAEA,SAASH,aAAaA,CAAE;EAAEF,MAAM;EAAEG;AAAQ,CAAC,EAAG;EAC7C,MAAMT,KAAK,GAAGT,eAAe,CAAC,CAAC;EAC/B,OACCQ,aAAA,CAACb,MAAM;IACNgB,SAAS,EAAC,+BAA+B;IACzCU,OAAO,EAAC,UAAU;IAClB,iBAAgBN;IAChB;IAAA;IACA,cAAalB,OAAO,CAAED,EAAE,CAAE,gBAAiB,CAAC,EAAEa,KAAM,CAAG;IACvDS,OAAO,EAAGA;EAAS,GAEjBT,KACK,CAAC;AAEX"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
import { useBlockEditingMode, store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { useEffect } from '@wordpress/element';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { PAGE_CONTENT_BLOCK_TYPES } from './constants';
|
|
13
|
+
function DisableBlock({
|
|
14
|
+
clientId
|
|
15
|
+
}) {
|
|
16
|
+
const isDescendentOfQueryLoop = useSelect(select => {
|
|
17
|
+
const {
|
|
18
|
+
getBlockParentsByBlockName
|
|
19
|
+
} = select(blockEditorStore);
|
|
20
|
+
return getBlockParentsByBlockName(clientId, 'core/query').length !== 0;
|
|
21
|
+
}, [clientId]);
|
|
22
|
+
const mode = isDescendentOfQueryLoop ? undefined : 'contentOnly';
|
|
23
|
+
const {
|
|
24
|
+
setBlockEditingMode,
|
|
25
|
+
unsetBlockEditingMode
|
|
26
|
+
} = useDispatch(blockEditorStore);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (mode) {
|
|
29
|
+
setBlockEditingMode(clientId, mode);
|
|
30
|
+
return () => {
|
|
31
|
+
unsetBlockEditingMode(clientId);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}, [clientId, mode, setBlockEditingMode, unsetBlockEditingMode]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Component that when rendered, makes it so that the site editor allows only
|
|
39
|
+
* page content to be edited.
|
|
40
|
+
*/
|
|
41
|
+
export default function DisableNonPageContentBlocks() {
|
|
42
|
+
useBlockEditingMode('disabled');
|
|
43
|
+
const clientIds = useSelect(select => {
|
|
44
|
+
const {
|
|
45
|
+
__experimentalGetGlobalBlocksByName
|
|
46
|
+
} = select(blockEditorStore);
|
|
47
|
+
return __experimentalGetGlobalBlocksByName(PAGE_CONTENT_BLOCK_TYPES);
|
|
48
|
+
}, []);
|
|
49
|
+
return clientIds.map(clientId => {
|
|
50
|
+
return createElement(DisableBlock, {
|
|
51
|
+
key: clientId,
|
|
52
|
+
clientId: clientId
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=disable-non-page-content-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useBlockEditingMode","store","blockEditorStore","useEffect","PAGE_CONTENT_BLOCK_TYPES","DisableBlock","clientId","isDescendentOfQueryLoop","select","getBlockParentsByBlockName","length","mode","undefined","setBlockEditingMode","unsetBlockEditingMode","DisableNonPageContentBlocks","clientIds","__experimentalGetGlobalBlocksByName","map","createElement","key"],"sources":["@wordpress/editor/src/components/provider/disable-non-page-content-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nfunction DisableBlock( { clientId } ) {\n\tconst isDescendentOfQueryLoop = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParentsByBlockName } = select( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tgetBlockParentsByBlockName( clientId, 'core/query' ).length !==\n\t\t\t\t0\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst mode = isDescendentOfQueryLoop ? undefined : 'contentOnly';\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tif ( mode ) {\n\t\t\tsetBlockEditingMode( clientId, mode );\n\t\t\treturn () => {\n\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t};\n\t\t}\n\t}, [ clientId, mode, 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\tuseBlockEditingMode( 'disabled' );\n\tconst clientIds = useSelect( ( select ) => {\n\t\tconst { __experimentalGetGlobalBlocksByName } =\n\t\t\tselect( blockEditorStore );\n\t\treturn __experimentalGetGlobalBlocksByName( PAGE_CONTENT_BLOCK_TYPES );\n\t}, [] );\n\n\treturn clientIds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BAAyB,CAAC;EACvE,CAAC,EAAE,EAAG,CAAC;EAEP,OAAOY,SAAS,CAACE,GAAG,CAAIZ,QAAQ,IAAM;IACrC,OAAOa,aAAA,CAACd,YAAY;MAACe,GAAG,EAAGd,QAAU;MAACA,QAAQ,EAAGA;IAAU,CAAE,CAAC;EAC/D,CAAE,CAAC;AACJ"}
|
|
@@ -6,9 +6,10 @@ import { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';
|
|
|
6
6
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';
|
|
9
|
-
import { BlockEditorProvider, BlockContextProvider, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
9
|
+
import { BlockEditorProvider, BlockContextProvider, privateApis as blockEditorPrivateApis, store as blockEditorStore } from '@wordpress/block-editor';
|
|
10
10
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
11
|
import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';
|
|
12
|
+
import { createBlock } from '@wordpress/blocks';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
@@ -17,30 +18,143 @@ import withRegistryProvider from './with-registry-provider';
|
|
|
17
18
|
import { store as editorStore } from '../../store';
|
|
18
19
|
import useBlockEditorSettings from './use-block-editor-settings';
|
|
19
20
|
import { unlock } from '../../lock-unlock';
|
|
21
|
+
import DisableNonPageContentBlocks from './disable-non-page-content-blocks';
|
|
22
|
+
import { PAGE_CONTENT_BLOCK_TYPES } from './constants';
|
|
20
23
|
const {
|
|
21
24
|
ExperimentalBlockEditorProvider
|
|
22
25
|
} = unlock(blockEditorPrivateApis);
|
|
23
26
|
const {
|
|
24
27
|
PatternsMenuItems
|
|
25
28
|
} = unlock(editPatternsPrivateApis);
|
|
29
|
+
const noop = () => {};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* For the Navigation block editor, we need to force the block editor to contentOnly for that block.
|
|
33
|
+
*
|
|
34
|
+
* Set block editing mode to contentOnly when entering Navigation focus mode.
|
|
35
|
+
* this ensures that non-content controls on the block will be hidden and thus
|
|
36
|
+
* the user can focus on editing the Navigation Menu content only.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} navigationBlockClientId ClientId.
|
|
39
|
+
*/
|
|
40
|
+
function useForceFocusModeForNavigation(navigationBlockClientId) {
|
|
41
|
+
const {
|
|
42
|
+
setBlockEditingMode,
|
|
43
|
+
unsetBlockEditingMode
|
|
44
|
+
} = useDispatch(blockEditorStore);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!navigationBlockClientId) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
setBlockEditingMode(navigationBlockClientId, 'contentOnly');
|
|
50
|
+
return () => {
|
|
51
|
+
unsetBlockEditingMode(navigationBlockClientId);
|
|
52
|
+
};
|
|
53
|
+
}, [navigationBlockClientId, unsetBlockEditingMode, setBlockEditingMode]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Helper method to extract the post content block types from a template.
|
|
58
|
+
*
|
|
59
|
+
* @param {Array} blocks Template blocks.
|
|
60
|
+
*
|
|
61
|
+
* @return {Array} Flattened object.
|
|
62
|
+
*/
|
|
63
|
+
function extractPageContentBlockTypesFromTemplateBlocks(blocks) {
|
|
64
|
+
const result = [];
|
|
65
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
66
|
+
// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,
|
|
67
|
+
// we skip it because we only want to render stand-alone page content blocks in the block list.
|
|
68
|
+
if (blocks[i].name === 'core/query') {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (PAGE_CONTENT_BLOCK_TYPES.includes(blocks[i].name)) {
|
|
72
|
+
result.push(createBlock(blocks[i].name));
|
|
73
|
+
}
|
|
74
|
+
if (blocks[i].innerBlocks.length) {
|
|
75
|
+
result.push(...extractPageContentBlockTypesFromTemplateBlocks(blocks[i].innerBlocks));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Depending on the post, template and template mode,
|
|
83
|
+
* returns the appropriate blocks and change handlers for the block editor provider.
|
|
84
|
+
*
|
|
85
|
+
* @param {Array} post Block list.
|
|
86
|
+
* @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.
|
|
87
|
+
* @param {string} mode Rendering mode.
|
|
88
|
+
* @return {Array} Block editor props.
|
|
89
|
+
*/
|
|
90
|
+
function useBlockEditorProps(post, template, mode) {
|
|
91
|
+
const rootLevelPost = mode === 'post-only' || !template ? 'post' : 'template';
|
|
92
|
+
const [postBlocks, onInput, onChange] = useEntityBlockEditor('postType', post.type, {
|
|
93
|
+
id: post.id
|
|
94
|
+
});
|
|
95
|
+
const [templateBlocks, onInputTemplate, onChangeTemplate] = useEntityBlockEditor('postType', template?.type, {
|
|
96
|
+
id: template?.id
|
|
97
|
+
});
|
|
98
|
+
const blocks = useMemo(() => {
|
|
99
|
+
if (post.type === 'wp_navigation') {
|
|
100
|
+
return [createBlock('core/navigation', {
|
|
101
|
+
ref: post.id,
|
|
102
|
+
// As the parent editor is locked with `templateLock`, the template locking
|
|
103
|
+
// must be explicitly "unset" on the block itself to allow the user to modify
|
|
104
|
+
// the block's content.
|
|
105
|
+
templateLock: false
|
|
106
|
+
})];
|
|
107
|
+
}
|
|
108
|
+
if (mode === 'post-only') {
|
|
109
|
+
const postContentBlocks = extractPageContentBlockTypesFromTemplateBlocks(templateBlocks);
|
|
110
|
+
return [createBlock('core/group', {
|
|
111
|
+
layout: {
|
|
112
|
+
type: 'constrained'
|
|
113
|
+
},
|
|
114
|
+
style: {
|
|
115
|
+
spacing: {
|
|
116
|
+
margin: {
|
|
117
|
+
top: '4em' // Mimics the post editor.
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, postContentBlocks.length ? postContentBlocks : [createBlock('core/post-title'), createBlock('core/post-content')])];
|
|
122
|
+
}
|
|
123
|
+
if (rootLevelPost === 'template') {
|
|
124
|
+
return templateBlocks;
|
|
125
|
+
}
|
|
126
|
+
return postBlocks;
|
|
127
|
+
}, [templateBlocks, postBlocks, rootLevelPost, post.type, post.id, mode]);
|
|
128
|
+
const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation' || mode === 'post-only';
|
|
129
|
+
const navigationBlockClientId = post.type === 'wp_navigation' && blocks && blocks[0]?.clientId;
|
|
130
|
+
useForceFocusModeForNavigation(navigationBlockClientId);
|
|
131
|
+
if (disableRootLevelChanges) {
|
|
132
|
+
return [blocks, noop, noop];
|
|
133
|
+
}
|
|
134
|
+
return [blocks, rootLevelPost === 'post' ? onInput : onInputTemplate, rootLevelPost === 'post' ? onChange : onChangeTemplate];
|
|
135
|
+
}
|
|
26
136
|
export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
27
|
-
__unstableTemplate,
|
|
28
137
|
post,
|
|
29
138
|
settings,
|
|
30
139
|
recovery,
|
|
31
140
|
initialEdits,
|
|
32
141
|
children,
|
|
33
|
-
BlockEditorProviderComponent = ExperimentalBlockEditorProvider
|
|
142
|
+
BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
|
|
143
|
+
__unstableTemplate: template
|
|
34
144
|
}) => {
|
|
145
|
+
const mode = useSelect(select => select(editorStore).getRenderingMode(), []);
|
|
146
|
+
const shouldRenderTemplate = !!template && mode !== 'post-only';
|
|
147
|
+
const rootLevelPost = shouldRenderTemplate ? template : post;
|
|
35
148
|
const defaultBlockContext = useMemo(() => {
|
|
36
|
-
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
149
|
+
const postContext = rootLevelPost.type !== 'wp_template' || shouldRenderTemplate && mode !== 'template-only' ? {
|
|
40
150
|
postId: post.id,
|
|
41
151
|
postType: post.type
|
|
152
|
+
} : {};
|
|
153
|
+
return {
|
|
154
|
+
...postContext,
|
|
155
|
+
templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined
|
|
42
156
|
};
|
|
43
|
-
}, [post.id, post.type]);
|
|
157
|
+
}, [mode, post.id, post.type, rootLevelPost.type, rootLevelPost?.slug, shouldRenderTemplate]);
|
|
44
158
|
const {
|
|
45
159
|
editorSettings,
|
|
46
160
|
selection,
|
|
@@ -60,11 +174,9 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
60
174
|
const {
|
|
61
175
|
id,
|
|
62
176
|
type
|
|
63
|
-
} =
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
const blockEditorSettings = useBlockEditorSettings(editorSettings, !!__unstableTemplate);
|
|
177
|
+
} = rootLevelPost;
|
|
178
|
+
const blockEditorSettings = useBlockEditorSettings(editorSettings, type, id);
|
|
179
|
+
const [blocks, onInput, onChange] = useBlockEditorProps(post, template, mode);
|
|
68
180
|
const {
|
|
69
181
|
updatePostLock,
|
|
70
182
|
setupEditor,
|
|
@@ -101,7 +213,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
101
213
|
// Synchronize the editor settings as they change.
|
|
102
214
|
useEffect(() => {
|
|
103
215
|
updateEditorSettings(settings);
|
|
104
|
-
}, [settings]);
|
|
216
|
+
}, [settings, updateEditorSettings]);
|
|
105
217
|
if (!isReady) {
|
|
106
218
|
return null;
|
|
107
219
|
}
|
|
@@ -121,7 +233,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
121
233
|
selection: selection,
|
|
122
234
|
settings: blockEditorSettings,
|
|
123
235
|
useSubRegistry: false
|
|
124
|
-
}, children, createElement(PatternsMenuItems, null)))));
|
|
236
|
+
}, children, createElement(PatternsMenuItems, null), ['post-only', 'template-locked'].includes(mode) && createElement(DisableNonPageContentBlocks, null)))));
|
|
125
237
|
});
|
|
126
238
|
export function EditorProvider(props) {
|
|
127
239
|
return createElement(ExperimentalEditorProvider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","noticesStore","editPatternsPrivateApis","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","ExperimentalBlockEditorProvider","PatternsMenuItems","ExperimentalEditorProvider","__unstableTemplate","post","settings","recovery","initialEdits","children","BlockEditorProviderComponent","defaultBlockContext","type","postId","id","postType","editorSettings","selection","isReady","select","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blocks","onInput","onChange","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","__experimentalTearDownEditor","createWarningNotice","postLock","template","autosave","actions","label","url","editLink","createElement","kind","value","useSubRegistry","EditorProvider","props"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\t__unstableTemplate,\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t} ) => {\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tif ( post.type === 'wp_template' ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\treturn { postId: post.id, postType: post.type };\n\t\t}, [ post.id, post.type ] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = __unstableTemplate ?? post;\n\t\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t\t'postType',\n\t\t\ttype,\n\t\t\t{ id }\n\t\t);\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\t!! __unstableTemplate\n\t\t);\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\t__experimentalTearDownEditor,\n\t\t} = useDispatch( editorStore );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Initialize and tear down the editor.\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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}\n\n\t\t\treturn () => {\n\t\t\t\t__experimentalTearDownEditor();\n\t\t\t};\n\t\t}, [] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n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,QAAQ,CAAC4B,QAAQ,CAACI;QACxB,CAAC;MAEH,CACD,CAAC;IACF;IAEA,OAAO,MAAM;MACZR,4BAA4B,CAAC,CAAC;IAC/B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;;EAEP;EACAhD,SAAS,CAAE,MAAM;IAChB+C,oBAAoB,CAAEvB,QAAS,CAAC;EACjC,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjB,IAAK,CAAEY,OAAO,EAAG;IAChB,OAAO,IAAI;EACZ;EAEA,OACCqB,aAAA,CAACnD,cAAc;IAACoD,IAAI,EAAC,MAAM;IAAC5B,IAAI,EAAC;EAAM,GACtC2B,aAAA,CAACnD,cAAc;IACdoD,IAAI,EAAC,UAAU;IACf5B,IAAI,EAAGP,IAAI,CAACO,IAAM;IAClBE,EAAE,EAAGT,IAAI,CAACS;EAAI,GAEdyB,aAAA,CAAChD,oBAAoB;IAACkD,KAAK,EAAG9B;EAAqB,GAClD4B,aAAA,CAAC7B,4BAA4B;IAC5B+B,KAAK,EAAGlB,MAAQ;IAChBE,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnBP,SAAS,EAAGA,SAAW;IACvBX,QAAQ,EAAGoB,mBAAqB;IAChCgB,cAAc,EAAG;EAAO,GAEtBjC,QAAQ,EACV8B,aAAA,CAACrC,iBAAiB,MAAE,CACS,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAED,OAAO,SAASyC,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACCL,aAAA,CAACpC,0BAA0B;IAAA,GACrByC,KAAK;IACVlC,4BAA4B,EAAGpB;EAAqB,GAElDsD,KAAK,CAACnC,QACmB,CAAC;AAE/B;AAEA,eAAekC,cAAc"}
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","blockEditorStore","noticesStore","editPatternsPrivateApis","createBlock","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","DisableNonPageContentBlocks","PAGE_CONTENT_BLOCK_TYPES","ExperimentalBlockEditorProvider","PatternsMenuItems","noop","useForceFocusModeForNavigation","navigationBlockClientId","setBlockEditingMode","unsetBlockEditingMode","extractPageContentBlockTypesFromTemplateBlocks","blocks","result","i","length","name","includes","push","innerBlocks","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","type","id","templateBlocks","onInputTemplate","onChangeTemplate","ref","templateLock","postContentBlocks","layout","style","spacing","margin","top","disableRootLevelChanges","clientId","ExperimentalEditorProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","select","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","__experimentalTearDownEditor","createWarningNotice","postLock","autosave","actions","label","url","editLink","createElement","kind","value","useSubRegistry","EditorProvider","props"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * For the Navigation block editor, we need to force the block editor to contentOnly for that block.\n *\n * Set block editing mode to contentOnly when entering Navigation focus mode.\n * this ensures that non-content controls on the block will be hidden and thus\n * the user can focus on editing the Navigation Menu content only.\n *\n * @param {string} navigationBlockClientId ClientId.\n */\nfunction useForceFocusModeForNavigation( navigationBlockClientId ) {\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! navigationBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetBlockEditingMode( navigationBlockClientId, 'contentOnly' );\n\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( navigationBlockClientId );\n\t\t};\n\t}, [\n\t\tnavigationBlockClientId,\n\t\tunsetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t] );\n}\n\n/**\n * Helper method to extract the post content block types from a template.\n *\n * @param {Array} blocks Template blocks.\n *\n * @return {Array} Flattened object.\n */\nfunction extractPageContentBlockTypesFromTemplateBlocks( blocks ) {\n\tconst result = [];\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\t// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,\n\t\t// we skip it because we only want to render stand-alone page content blocks in the block list.\n\t\tif ( blocks[ i ].name === 'core/query' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( PAGE_CONTENT_BLOCK_TYPES.includes( blocks[ i ].name ) ) {\n\t\t\tresult.push( createBlock( blocks[ i ].name ) );\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tresult.push(\n\t\t\t\t...extractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost =\n\t\tmode === 'post-only' || ! template ? 'post' : 'template';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst blocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\n\t\tif ( mode === 'post-only' ) {\n\t\t\tconst postContentBlocks =\n\t\t\t\textractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\ttemplateBlocks\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: { type: 'constrained' },\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\ttop: '4em', // Mimics the post editor.\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpostContentBlocks.length\n\t\t\t\t\t\t? postContentBlocks\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-title' ),\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-content' ),\n\t\t\t\t\t\t ]\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [\n\t\ttemplateBlocks,\n\t\tpostBlocks,\n\t\trootLevelPost,\n\t\tpost.type,\n\t\tpost.id,\n\t\tmode,\n\t] );\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation' ||\n\t\tmode === 'post-only';\n\tconst navigationBlockClientId =\n\t\tpost.type === 'wp_navigation' && blocks && blocks[ 0 ]?.clientId;\n\tuseForceFocusModeForNavigation( navigationBlockClientId );\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst mode = useSelect(\n\t\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t\t[]\n\t\t);\n\t\tconst shouldRenderTemplate = !! template && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext =\n\t\t\t\trootLevelPost.type !== 'wp_template' ||\n\t\t\t\t( shouldRenderTemplate && mode !== 'template-only' )\n\t\t\t\t\t? { postId: post.id, postType: post.type }\n\t\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tmode,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost?.slug,\n\t\t\tshouldRenderTemplate,\n\t\t] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\t__experimentalTearDownEditor,\n\t\t} = useDispatch( editorStore );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Initialize and tear down the editor.\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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}\n\n\t\t\treturn () => {\n\t\t\t\t__experimentalTearDownEditor();\n\t\t\t};\n\t\t}, [] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t{ [ 'post-only', 'template-locked' ].includes(\n\t\t\t\t\t\t\t\tmode\n\t\t\t\t\t\t\t) && <DisableNonPageContentBlocks /> }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,eAAe,EAAEC,OAAO,QAAQ,oBAAoB;AACxE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC3E,SACCC,mBAAmB,EACnBC,oBAAoB,EACpBC,WAAW,IAAIC,sBAAsB,EACrCC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASJ,WAAW,IAAIK,uBAAuB,QAAQ,qBAAqB;AAC5E,SAASC,WAAW,QAAQ,mBAAmB;;AAE/C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASL,KAAK,IAAIM,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,MAAM;EAAEC;AAAgC,CAAC,GAAGH,MAAM,CAAET,sBAAuB,CAAC;AAC5E,MAAM;EAAEa;AAAkB,CAAC,GAAGJ,MAAM,CAAEL,uBAAwB,CAAC;AAE/D,MAAMU,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,8BAA8BA,CAAEC,uBAAuB,EAAG;EAClE,MAAM;IAAEC,mBAAmB;IAAEC;EAAsB,CAAC,GACnD1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AA,CAAC5E,2BAA2B,MAAE,CACN,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAED,OAAO,SAASgF,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACCL,aAAA,CAACnC,0BAA0B;IAAA,GACrBwC,KAAK;IACVnC,4BAA4B,EAAG3D;EAAqB,GAElD8F,KAAK,CAACpC,QACmB,CAAC;AAE/B;AAEA,eAAemC,cAAc"}
|
|
@@ -13,17 +13,18 @@ import inserterMediaCategories from '../media-categories';
|
|
|
13
13
|
import { mediaUpload } from '../../utils';
|
|
14
14
|
import { store as editorStore } from '../../store';
|
|
15
15
|
const EMPTY_BLOCKS_LIST = [];
|
|
16
|
-
const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'focusMode', 'distractionFree', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasInlineToolbar', 'isDistractionFree', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'locale', 'maxWidth', 'onUpdateDefaultBlockStyles', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', '
|
|
16
|
+
const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'focusMode', 'distractionFree', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasInlineToolbar', 'isDistractionFree', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'locale', 'maxWidth', 'onUpdateDefaultBlockStyles', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme', '__experimentalArchiveTitleTypeLabel', '__experimentalArchiveTitleNameLabel'];
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* React hook used to compute the block editor settings to use for the post editor.
|
|
20
20
|
*
|
|
21
|
-
* @param {Object}
|
|
22
|
-
* @param {
|
|
21
|
+
* @param {Object} settings EditorProvider settings prop.
|
|
22
|
+
* @param {string} postType Editor root level post type.
|
|
23
|
+
* @param {string} postId Editor root level post ID.
|
|
23
24
|
*
|
|
24
25
|
* @return {Object} Block Editor Settings.
|
|
25
26
|
*/
|
|
26
|
-
function useBlockEditorSettings(settings,
|
|
27
|
+
function useBlockEditorSettings(settings, postType, postId) {
|
|
27
28
|
var _settings$__experimen, _settings$__experimen2;
|
|
28
29
|
const {
|
|
29
30
|
reusableBlocks,
|
|
@@ -32,24 +33,21 @@ function useBlockEditorSettings(settings, hasTemplate) {
|
|
|
32
33
|
userCanCreatePages,
|
|
33
34
|
pageOnFront,
|
|
34
35
|
pageForPosts,
|
|
35
|
-
postType,
|
|
36
36
|
userPatternCategories
|
|
37
37
|
} = useSelect(select => {
|
|
38
38
|
var _canUser;
|
|
39
|
-
const {
|
|
40
|
-
canUserUseUnfilteredHTML,
|
|
41
|
-
getCurrentPostType
|
|
42
|
-
} = select(editorStore);
|
|
43
39
|
const isWeb = Platform.OS === 'web';
|
|
44
40
|
const {
|
|
45
41
|
canUser,
|
|
42
|
+
getRawEntityRecord,
|
|
46
43
|
getEntityRecord,
|
|
47
|
-
getUserPatternCategories
|
|
44
|
+
getUserPatternCategories,
|
|
45
|
+
getEntityRecords
|
|
48
46
|
} = select(coreStore);
|
|
49
47
|
const siteSettings = canUser('read', 'settings') ? getEntityRecord('root', 'site') : undefined;
|
|
50
48
|
return {
|
|
51
|
-
canUseUnfilteredHTML:
|
|
52
|
-
reusableBlocks: isWeb ?
|
|
49
|
+
canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'),
|
|
50
|
+
reusableBlocks: isWeb ? getEntityRecords('postType', 'wp_block', {
|
|
53
51
|
per_page: -1
|
|
54
52
|
}) : EMPTY_BLOCKS_LIST,
|
|
55
53
|
// Reusable blocks are fetched in the native version of this hook.
|
|
@@ -57,10 +55,9 @@ function useBlockEditorSettings(settings, hasTemplate) {
|
|
|
57
55
|
userCanCreatePages: canUser('create', 'pages'),
|
|
58
56
|
pageOnFront: siteSettings?.page_on_front,
|
|
59
57
|
pageForPosts: siteSettings?.page_for_posts,
|
|
60
|
-
postType: getCurrentPostType(),
|
|
61
58
|
userPatternCategories: getUserPatternCategories()
|
|
62
59
|
};
|
|
63
|
-
}, []);
|
|
60
|
+
}, [postType, postId]);
|
|
64
61
|
const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen :
|
|
65
62
|
// WP 6.0
|
|
66
63
|
settings.__experimentalBlockPatterns; // WP 5.9
|
|
@@ -113,15 +110,23 @@ function useBlockEditorSettings(settings, hasTemplate) {
|
|
|
113
110
|
__experimentalFetchLinkSuggestions: (search, searchOptions) => fetchLinkSuggestions(search, searchOptions, settings),
|
|
114
111
|
inserterMediaCategories,
|
|
115
112
|
__experimentalFetchRichUrlData: fetchUrlData,
|
|
113
|
+
// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
|
|
114
|
+
// This might be better as a generic "canUser" selector.
|
|
116
115
|
__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
|
|
116
|
+
//Todo: this is only needed for native and should probably be removed.
|
|
117
117
|
__experimentalUndo: undo,
|
|
118
|
-
|
|
118
|
+
// Check whether we want all site editor frames to have outlines
|
|
119
|
+
// including the navigation / pattern / parts editors.
|
|
120
|
+
outlineMode: postType === 'wp_template',
|
|
121
|
+
// Check these two properties: they were not present in the site editor.
|
|
119
122
|
__experimentalCreatePageEntity: createPageEntity,
|
|
120
123
|
__experimentalUserCanCreatePages: userCanCreatePages,
|
|
121
124
|
pageOnFront,
|
|
122
125
|
pageForPosts,
|
|
123
|
-
__experimentalPreferPatternsOnRoot:
|
|
124
|
-
|
|
126
|
+
__experimentalPreferPatternsOnRoot: postType === 'wp_template',
|
|
127
|
+
templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock,
|
|
128
|
+
template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template
|
|
129
|
+
}), [settings, hasUploadPermissions, reusableBlocks, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType]);
|
|
125
130
|
}
|
|
126
131
|
export default useBlockEditorSettings;
|
|
127
132
|
//# sourceMappingURL=use-block-editor-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","useMemo","useCallback","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","inserterMediaCategories","mediaUpload","editorStore","EMPTY_BLOCKS_LIST","BLOCK_EDITOR_SETTINGS","useBlockEditorSettings","settings","hasTemplate","_settings$__experimen","_settings$__experimen2","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","pageForPosts","postType","userPatternCategories","select","_canUser","canUserUseUnfilteredHTML","getCurrentPostType","isWeb","OS","canUser","getEntityRecord","getUserPatternCategories","siteSettings","undefined","getEntityRecords","per_page","page_on_front","page_for_posts","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","Object","fromEntries","entries","key","__experimentalReusableBlocks","__experimentalUserPatternCategories","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot"],"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_BLOCKS_LIST = [];\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'__experimentalPreferredStyleVariations',\n\t'__experimentalSetIsInserterOpened',\n\t'__unstableGalleryWithImageBlocks',\n\t'alignWide',\n\t'allowedBlockTypes',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'focusMode',\n\t'distractionFree',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'hasFixedToolbar',\n\t'hasInlineToolbar',\n\t'isDistractionFree',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'keepCaretInsideBlock',\n\t'locale',\n\t'maxWidth',\n\t'onUpdateDefaultBlockStyles',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'template',\n\t'templateLock',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n];\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {boolean} hasTemplate Whether template mode is enabled.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, hasTemplate ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tpostType,\n\t\tuserPatternCategories,\n\t} = useSelect( ( select ) => {\n\t\tconst { canUserUseUnfilteredHTML, getCurrentPostType } =\n\t\t\tselect( editorStore );\n\t\tconst isWeb = Platform.OS === 'web';\n\t\tconst { canUser, getEntityRecord, getUserPatternCategories } =\n\t\t\tselect( coreStore );\n\n\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanUseUnfilteredHTML: canUserUseUnfilteredHTML(),\n\t\t\treusableBlocks: isWeb\n\t\t\t\t? select( coreStore ).getEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_block',\n\t\t\t\t\t\t{ per_page: -1 }\n\t\t\t\t )\n\t\t\t\t: EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.\n\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t};\n\t}, [] );\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t__experimentalUndo: undo,\n\t\t\toutlineMode: hasTemplate,\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: hasTemplate,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tuserPatternCategories,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\thasTemplate,\n\t\t\tcreatePageEntity,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,KAAK,IAAIC,SAAS,EAClBC,kCAAkC,IAAIC,oBAAoB,EAC1DC,0BAA0B,IAAIC,YAAY,QACpC,sBAAsB;AAC7B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,qBAAqB;AACzD,SAASC,WAAW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EACH,CACCD,QAAQ,EACRK,oBAAoB,EACpBD,cAAc,EACdO,qBAAqB,EACrB0B,aAAa,EACbY,sBAAsB,EACtB3C,oBAAoB,EACpB4C,IAAI,EACJjD,WAAW,EACXmD,gBAAgB,EAChB7C,kBAAkB,EAClBC,WAAW,EACXC,YAAY,CAEd,CAAC;AACF;AAEA,eAAeV,sBAAsB"}
|
|
1
|
+
{"version":3,"names":["Platform","useMemo","useCallback","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","inserterMediaCategories","mediaUpload","editorStore","EMPTY_BLOCKS_LIST","BLOCK_EDITOR_SETTINGS","useBlockEditorSettings","settings","postType","postId","_settings$__experimen","_settings$__experimen2","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","pageForPosts","userPatternCategories","select","_canUser","isWeb","OS","canUser","getRawEntityRecord","getEntityRecord","getUserPatternCategories","getEntityRecords","siteSettings","undefined","_links","hasOwnProperty","per_page","page_on_front","page_for_posts","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","Object","fromEntries","entries","key","__experimentalReusableBlocks","__experimentalUserPatternCategories","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot","templateLock","template"],"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_BLOCKS_LIST = [];\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'__experimentalPreferredStyleVariations',\n\t'__experimentalSetIsInserterOpened',\n\t'__unstableGalleryWithImageBlocks',\n\t'alignWide',\n\t'allowedBlockTypes',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'focusMode',\n\t'distractionFree',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'hasFixedToolbar',\n\t'hasInlineToolbar',\n\t'isDistractionFree',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'keepCaretInsideBlock',\n\t'locale',\n\t'maxWidth',\n\t'onUpdateDefaultBlockStyles',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n\t'__experimentalArchiveTitleTypeLabel',\n\t'__experimentalArchiveTitleNameLabel',\n];\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetEntityRecords,\n\t\t\t} = select( coreStore );\n\n\t\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\treusableBlocks: isWeb\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.\n\t\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tuserPatternCategories,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\tcreatePageEntity,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\tpostType,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,KAAK,IAAIC,SAAS,EAClBC,kCAAkC,IAAIC,oBAAoB,EAC1DC,0BAA0B,IAAIC,YAAY,QACpC,sBAAsB;AAC7B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,qBAAqB;AACzD,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASR,KAAK,IAAIS,WAAW,QAAQ,aAAa;AAElD,MAAMC,iBAAiB,GAAG,EAAE;AAE5B,MAAMC,qBAAqB,GAAG,CAC7B,8BAA8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,sCAAsC,EACtC,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EAC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