@wordpress/editor 14.8.6 → 14.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-settings-menu/content-only-settings-menu.js +15 -18
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build/components/document-tools/index.js +1 -6
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/header/index.js +22 -17
- package/build/components/header/index.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +8 -9
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +17 -18
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/use-post-content-blocks.js +34 -0
- package/build/components/provider/use-post-content-blocks.js.map +1 -0
- package/build/components/resizable-editor/resize-handle.js +4 -0
- package/build/components/resizable-editor/resize-handle.js.map +1 -1
- package/build/components/zoom-out-toggle/index.js +1 -1
- package/build/components/zoom-out-toggle/index.js.map +1 -1
- package/build/dataviews/store/private-actions.js +2 -7
- package/build/dataviews/store/private-actions.js.map +1 -1
- package/build/store/actions.js +20 -5
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +14 -18
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
- package/build-module/components/document-tools/index.js +1 -6
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/header/index.js +22 -17
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +8 -9
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +17 -18
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/use-post-content-blocks.js +27 -0
- package/build-module/components/provider/use-post-content-blocks.js.map +1 -0
- package/build-module/components/resizable-editor/resize-handle.js +4 -0
- package/build-module/components/resizable-editor/resize-handle.js.map +1 -1
- package/build-module/components/zoom-out-toggle/index.js +1 -1
- package/build-module/components/zoom-out-toggle/index.js.map +1 -1
- package/build-module/dataviews/store/private-actions.js +4 -8
- package/build-module/dataviews/store/private-actions.js.map +1 -1
- package/build-module/store/actions.js +18 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -1
- package/build-style/style.css +10 -1
- package/build-types/components/document-tools/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
- package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
- package/build-types/components/provider/use-post-content-blocks.d.ts +2 -0
- package/build-types/components/provider/use-post-content-blocks.d.ts.map +1 -0
- package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +1 -13
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +2 -2
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/package.json +37 -37
- package/src/components/block-settings-menu/content-only-settings-menu.js +19 -19
- package/src/components/document-tools/index.js +1 -4
- package/src/components/header/index.js +30 -14
- package/src/components/inserter-sidebar/index.js +8 -11
- package/src/components/provider/disable-non-page-content-blocks.js +20 -34
- package/src/components/provider/use-post-content-blocks.js +42 -0
- package/src/components/resizable-editor/resize-handle.js +5 -0
- package/src/components/zoom-out-toggle/index.js +1 -1
- package/src/dataviews/store/private-actions.ts +7 -7
- package/src/store/actions.js +23 -6
- package/src/store/private-selectors.js +2 -2
- package/src/store/test/actions.js +76 -0
- package/src/store/test/reducer.js +0 -22
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dataviews/actions/delete-post.js +0 -98
- package/build/dataviews/actions/delete-post.js.map +0 -1
- package/build/dataviews/actions/rename-post.js +0 -125
- package/build/dataviews/actions/rename-post.js.map +0 -1
- package/build/dataviews/actions/reset-post.js +0 -113
- package/build/dataviews/actions/reset-post.js.map +0 -1
- package/build/dataviews/actions/restore-post.js +0 -112
- package/build/dataviews/actions/restore-post.js.map +0 -1
- package/build/dataviews/actions/trash-post.js +0 -144
- package/build/dataviews/actions/trash-post.js.map +0 -1
- package/build/dataviews/fields/index.js +0 -32
- package/build/dataviews/fields/index.js.map +0 -1
- package/build-module/dataviews/actions/delete-post.js +0 -89
- package/build-module/dataviews/actions/delete-post.js.map +0 -1
- package/build-module/dataviews/actions/rename-post.js +0 -118
- package/build-module/dataviews/actions/rename-post.js.map +0 -1
- package/build-module/dataviews/actions/reset-post.js +0 -106
- package/build-module/dataviews/actions/reset-post.js.map +0 -1
- package/build-module/dataviews/actions/restore-post.js +0 -104
- package/build-module/dataviews/actions/restore-post.js.map +0 -1
- package/build-module/dataviews/actions/trash-post.js +0 -137
- package/build-module/dataviews/actions/trash-post.js.map +0 -1
- package/build-module/dataviews/fields/index.js +0 -26
- package/build-module/dataviews/fields/index.js.map +0 -1
- package/build-types/dataviews/actions/delete-post.d.ts +0 -5
- package/build-types/dataviews/actions/delete-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/rename-post.d.ts +0 -5
- package/build-types/dataviews/actions/rename-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/reset-post.d.ts +0 -5
- package/build-types/dataviews/actions/reset-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/restore-post.d.ts +0 -5
- package/build-types/dataviews/actions/restore-post.d.ts.map +0 -1
- package/build-types/dataviews/actions/trash-post.d.ts +0 -5
- package/build-types/dataviews/actions/trash-post.d.ts.map +0 -1
- package/build-types/dataviews/fields/index.d.ts +0 -8
- package/build-types/dataviews/fields/index.d.ts.map +0 -1
- package/src/dataviews/actions/delete-post.tsx +0 -109
- package/src/dataviews/actions/rename-post.tsx +0 -146
- package/src/dataviews/actions/reset-post.tsx +0 -147
- package/src/dataviews/actions/restore-post.tsx +0 -134
- package/src/dataviews/actions/trash-post.tsx +0 -198
- package/src/dataviews/fields/index.ts +0 -26
|
@@ -12,6 +12,7 @@ import { __, _x } from '@wordpress/i18n';
|
|
|
12
12
|
*/
|
|
13
13
|
import { store as editorStore } from '../../store';
|
|
14
14
|
import { unlock } from '../../lock-unlock';
|
|
15
|
+
import usePostContentBlocks from '../provider/use-post-content-blocks';
|
|
15
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
17
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -19,36 +20,31 @@ function ContentOnlySettingsMenuItems({
|
|
|
19
20
|
clientId,
|
|
20
21
|
onClose
|
|
21
22
|
}) {
|
|
23
|
+
const postContentBlocks = usePostContentBlocks();
|
|
22
24
|
const {
|
|
23
25
|
entity,
|
|
24
26
|
onNavigateToEntityRecord,
|
|
25
27
|
canEditTemplates
|
|
26
28
|
} = useSelect(select => {
|
|
27
29
|
const {
|
|
28
|
-
getBlockEditingMode,
|
|
29
30
|
getBlockParentsByBlockName,
|
|
30
31
|
getSettings,
|
|
31
|
-
getBlockAttributes
|
|
32
|
+
getBlockAttributes,
|
|
33
|
+
getBlockParents
|
|
32
34
|
} = select(blockEditorStore);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
35
|
+
const {
|
|
36
|
+
getCurrentTemplateId,
|
|
37
|
+
getRenderingMode
|
|
38
|
+
} = select(editorStore);
|
|
37
39
|
const patternParent = getBlockParentsByBlockName(clientId, 'core/block', true)[0];
|
|
38
40
|
let record;
|
|
39
41
|
if (patternParent) {
|
|
40
42
|
record = select(coreStore).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
|
|
41
|
-
} else {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const {
|
|
47
|
-
getContentLockingParent
|
|
48
|
-
} = unlock(select(blockEditorStore));
|
|
49
|
-
if (!getContentLockingParent(clientId) && templateId) {
|
|
50
|
-
record = select(coreStore).getEntityRecord('postType', 'wp_template', templateId);
|
|
51
|
-
}
|
|
43
|
+
} else if (getRenderingMode() === 'template-locked' && !getBlockParents(clientId).some(parent => postContentBlocks.includes(parent))) {
|
|
44
|
+
record = select(coreStore).getEntityRecord('postType', 'wp_template', getCurrentTemplateId());
|
|
45
|
+
}
|
|
46
|
+
if (!record) {
|
|
47
|
+
return {};
|
|
52
48
|
}
|
|
53
49
|
const _canEditTemplates = select(coreStore).canUser('create', {
|
|
54
50
|
kind: 'postType',
|
|
@@ -59,7 +55,7 @@ function ContentOnlySettingsMenuItems({
|
|
|
59
55
|
entity: record,
|
|
60
56
|
onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
|
|
61
57
|
};
|
|
62
|
-
}, [clientId]);
|
|
58
|
+
}, [clientId, postContentBlocks]);
|
|
63
59
|
if (!entity) {
|
|
64
60
|
return /*#__PURE__*/_jsx(TemplateLockContentOnlyMenuItems, {
|
|
65
61
|
clientId: clientId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlockSettingsMenuControls","__unstableBlockSettingsMenuFirstItem","BlockSettingsMenuFirstItem","store","blockEditorStore","useBlockDisplayInformation","coreStore","__experimentalText","Text","MenuItem","useSelect","useDispatch","__","_x","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ContentOnlySettingsMenuItems","clientId","onClose","entity","onNavigateToEntityRecord","canEditTemplates","select","getBlockEditingMode","getBlockParentsByBlockName","getSettings","getBlockAttributes","contentOnly","patternParent","record","getEntityRecord","ref","getCurrentTemplateId","templateId","getContentLockingParent","_canEditTemplates","canUser","kind","name","TemplateLockContentOnlyMenuItems","isPattern","type","helpText","children","onClick","postId","id","postType","disabled","variant","as","className","contentLockingParent","blockDisplayInformation","blockEditorActions","title","modifyContentLockBlock","ContentOnlySettingsMenu","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst contentOnly =\n\t\t\t\tgetBlockEditingMode( clientId ) === 'contentOnly';\n\t\t\tif ( ! contentOnly ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst { getCurrentTemplateId } = select( editorStore );\n\t\t\t\tconst templateId = getCurrentTemplateId();\n\t\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t);\n\t\t\t\tif ( ! getContentLockingParent( clientId ) && templateId ) {\n\t\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_template',\n\t\t\t\t\t\ttemplateId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t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ACRyC,OAAO,EAAGA,CAAA,KAAM;UACfY,sBAAsB,CAAEJ,oBAAqB,CAAC;UAC9ClC,OAAO,CAAC,CAAC;QACV,CAAG;QAAAyB,QAAA,EAEDpC,EAAE,CAAE,QAAQ,EAAE,8BAA+B;MAAC,CACvC;IAAC,CACgB,CAAC,eAC7BI,IAAA,CAACT,IAAI;MACJ+C,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,SAAS,EAAC,gDAAgD;MAAAR,QAAA,EAExDrC,EAAE,CACH,4FACD;IAAC,CACI,CAAC;EAAA,CACN,CAAC;AAEL;AAEA,eAAe,SAASmD,uBAAuBA,CAAA,EAAG;EACjD,oBACC9C,IAAA,CAACjB,yBAAyB;IAAAiD,QAAA,EACvBA,CAAE;MAAEe,iBAAiB;MAAExC;IAAQ,CAAC,KACjCwC,iBAAiB,CAACC,MAAM,KAAK,CAAC,iBAC7BhD,IAAA,CAACK,4BAA4B;MAC5BC,QAAQ,EAAGyC,iBAAiB,CAAE,CAAC,CAAI;MACnCxC,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["BlockSettingsMenuControls","__unstableBlockSettingsMenuFirstItem","BlockSettingsMenuFirstItem","store","blockEditorStore","useBlockDisplayInformation","coreStore","__experimentalText","Text","MenuItem","useSelect","useDispatch","__","_x","editorStore","unlock","usePostContentBlocks","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ContentOnlySettingsMenuItems","clientId","onClose","postContentBlocks","entity","onNavigateToEntityRecord","canEditTemplates","select","getBlockParentsByBlockName","getSettings","getBlockAttributes","getBlockParents","getCurrentTemplateId","getRenderingMode","patternParent","record","getEntityRecord","ref","some","parent","includes","_canEditTemplates","canUser","kind","name","TemplateLockContentOnlyMenuItems","isPattern","type","helpText","children","onClick","postId","id","postType","disabled","variant","as","className","contentLockingParent","getContentLockingParent","blockDisplayInformation","blockEditorActions","title","modifyContentLockBlock","ContentOnlySettingsMenu","selectedClientIds","length"],"sources":["@wordpress/editor/src/components/block-settings-menu/content-only-settings-menu.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport usePostContentBlocks from '../provider/use-post-content-blocks';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst postContentBlocks = usePostContentBlocks();\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockParents,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getCurrentTemplateId, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tgetRenderingMode() === 'template-locked' &&\n\t\t\t\t! getBlockParents( clientId ).some( ( parent ) =>\n\t\t\t\t\tpostContentBlocks.includes( parent )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tgetCurrentTemplateId()\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( ! record ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId, postContentBlocks ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds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C,QAAA,gBACClC,IAAA,CAAChB,0BAA0B;MAAAkD,QAAA,eAC1BlC,IAAA,CAACT,QAAQ;QACR4C,OAAO,EAAGA,CAAA,KAAM;UACfa,sBAAsB,CAAEL,oBAAqB,CAAC;UAC9CpC,OAAO,CAAC,CAAC;QACV,CAAG;QAAA2B,QAAA,EAEDvC,EAAE,CAAE,QAAQ,EAAE,8BAA+B;MAAC,CACvC;IAAC,CACgB,CAAC,eAC7BK,IAAA,CAACV,IAAI;MACJkD,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,SAAS,EAAC,gDAAgD;MAAAR,QAAA,EAExDxC,EAAE,CACH,4FACD;IAAC,CACI,CAAC;EAAA,CACN,CAAC;AAEL;AAEA,eAAe,SAASuD,uBAAuBA,CAAA,EAAG;EACjD,oBACCjD,IAAA,CAAClB,yBAAyB;IAAAoD,QAAA,EACvBA,CAAE;MAAEgB,iBAAiB;MAAE3C;IAAQ,CAAC,KACjC2C,iBAAiB,CAACC,MAAM,KAAK,CAAC,iBAC7BnD,IAAA,CAACK,4BAA4B;MAC5BC,QAAQ,EAAG4C,iBAAiB,CAAE,CAAC,CAAI;MACnC3C,OAAO,EAAGA;IAAS,CACnB;EACD,CAEwB,CAAC;AAE9B","ignoreList":[]}
|
|
@@ -41,12 +41,8 @@ function DocumentTools({
|
|
|
41
41
|
listViewShortcut,
|
|
42
42
|
inserterSidebarToggleRef,
|
|
43
43
|
listViewToggleRef,
|
|
44
|
-
hasFixedToolbar,
|
|
45
44
|
showIconLabels
|
|
46
45
|
} = useSelect(select => {
|
|
47
|
-
const {
|
|
48
|
-
getSettings
|
|
49
|
-
} = select(blockEditorStore);
|
|
50
46
|
const {
|
|
51
47
|
get
|
|
52
48
|
} = select(preferencesStore);
|
|
@@ -68,7 +64,6 @@ function DocumentTools({
|
|
|
68
64
|
listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
|
|
69
65
|
inserterSidebarToggleRef: getInserterSidebarToggleRef(),
|
|
70
66
|
listViewToggleRef: getListViewToggleRef(),
|
|
71
|
-
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
72
67
|
showIconLabels: get('core', 'showIconLabels'),
|
|
73
68
|
isDistractionFree: get('core', 'distractionFree'),
|
|
74
69
|
isVisualMode: getEditorMode() === 'visual',
|
|
@@ -124,7 +119,7 @@ function DocumentTools({
|
|
|
124
119
|
showTooltip: !showIconLabels,
|
|
125
120
|
"aria-expanded": isInserterOpened
|
|
126
121
|
}), (isWideViewport || !showIconLabels) && /*#__PURE__*/_jsxs(_Fragment, {
|
|
127
|
-
children: [isLargeViewport &&
|
|
122
|
+
children: [isLargeViewport && /*#__PURE__*/_jsx(ToolbarItem, {
|
|
128
123
|
as: ToolSelector,
|
|
129
124
|
showTooltip: !showIconLabels,
|
|
130
125
|
variant: showIconLabels ? 'tertiary' : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","Button","ToolbarItem","listView","plus","useCallback","keyboardShortcutsStore","preferencesStore","unlock","editorStore","EditorHistoryRedo","EditorHistoryUndo","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DocumentTools","className","disableBlockTools","setIsInserterOpened","setIsListViewOpened","isDistractionFree","isInserterOpened","isListViewOpen","listViewShortcut","inserterSidebarToggleRef","listViewToggleRef","hasFixedToolbar","showIconLabels","select","getSettings","get","isListViewOpened","getEditorMode","getInserterSidebarToggleRef","getListViewToggleRef","getShortcutRepresentation","__unstableGetEditorMode","isVisualMode","isZoomedOutView","preventDefault","event","isLargeViewport","isWideViewport","toolbarAriaLabel","toggleListView","toggleInserter","longLabel","shortLabel","variant","children","ref","as","isPressed","onMouseDown","onClick","disabled","icon","label","showTooltip","undefined","size","shortcut"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nfunction DocumentTools( { className, disableBlockTools = false } ) {\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisDistractionFree,\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t\thasFixedToolbar,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst preventDefault = ( event ) => {\n\t\t// Because the inserter behaves like a dialog,\n\t\t// if the inserter is opened already then when we click on the toggle button\n\t\t// then the initial click event will close the inserter and then be propagated\n\t\t// to the inserter toggle and it will open it again.\n\t\t// To prevent this we need to stop the propagation of the event.\n\t\t// This won't be necessary when the inserter no longer behaves like a dialog.\n\n\t\tif ( isInserterOpened ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpened ),\n\t\t[ isInserterOpened, setIsInserterOpened ]\n\t);\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SACCC,gBAAgB,EAChBC,YAAY,EACZC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,MAAM,EAAEC,WAAW,QAA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AU,GAAGgC,SAAW;YACnDC,IAAI,EAAC;UAAS,CACd,CAAC,eACFlD,IAAA,CAACX,WAAW;YACXoD,EAAE,EAAG5C,iBAAmB;YACxBmD,WAAW,EAAG,CAAE/B,cAAgB;YAChCqB,OAAO,EAAGrB,cAAc,GAAG,UAAU,GAAGgC,SAAW;YACnDC,IAAI,EAAC;UAAS,CACd,CAAC,EACA,CAAExC,iBAAiB,iBACpBV,IAAA,CAACX,WAAW;YACXoD,EAAE,EAAGrD,MAAQ;YACbkB,SAAS,EAAC,iDAAiD;YAC3DwC,IAAI,EAAGxD,QAAU;YACjBuD,QAAQ,EAAGtC,iBAAmB;YAC9BmC,SAAS,EAAG9B;YACZ;YACAmC,KAAK,EAAGjE,EAAE,CAAE,mBAAoB,CAAG;YACnC8D,OAAO,EAAGV,cAAgB;YAC1BiB,QAAQ,EAAGtC,gBAAkB;YAC7BmC,WAAW,EAAG,CAAE/B,cAAgB;YAChCqB,OAAO,EACNrB,cAAc,GAAG,UAAU,GAAGgC,SAC9B;YACD,iBAAgBrC,cAAgB;YAChC4B,GAAG,EAAGzB,iBAAmB;YACzBmC,IAAI,EAAC;UAAS,CACd,CACD;QAAA,CACA,CACF;MAAA,CACG;IAAC,CACW;EAAC;AAErB;AAEA,eAAe7C,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useViewportMatch","useSelect","useDispatch","__","_x","NavigableToolbar","ToolSelector","store","blockEditorStore","Button","ToolbarItem","listView","plus","useCallback","keyboardShortcutsStore","preferencesStore","unlock","editorStore","EditorHistoryRedo","EditorHistoryUndo","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","DocumentTools","className","disableBlockTools","setIsInserterOpened","setIsListViewOpened","isDistractionFree","isInserterOpened","isListViewOpen","listViewShortcut","inserterSidebarToggleRef","listViewToggleRef","showIconLabels","select","get","isListViewOpened","getEditorMode","getInserterSidebarToggleRef","getListViewToggleRef","getShortcutRepresentation","__unstableGetEditorMode","isVisualMode","isZoomedOutView","preventDefault","event","isLargeViewport","isWideViewport","toolbarAriaLabel","toggleListView","toggleInserter","longLabel","shortLabel","variant","children","ref","as","isPressed","onMouseDown","onClick","disabled","icon","label","showTooltip","undefined","size","shortcut"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nfunction DocumentTools( { className, disableBlockTools = false } ) {\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisDistractionFree,\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst {\n\t\t\tisListViewOpened,\n\t\t\tgetEditorMode,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisVisualMode: getEditorMode() === 'visual',\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst preventDefault = ( event ) => {\n\t\t// Because the inserter behaves like a dialog,\n\t\t// if the inserter is opened already then when we click on the toggle button\n\t\t// then the initial click event will close the inserter and then be propagated\n\t\t// to the inserter toggle and it will open it again.\n\t\t// To prevent this we need to stop the propagation of the event.\n\t\t// This won't be necessary when the inserter no longer behaves like a dialog.\n\n\t\tif ( isInserterOpened ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpened ),\n\t\t[ isInserterOpened, setIsInserterOpened ]\n\t);\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ clsx(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ __( 'Document Overview' ) }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC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W;YACnDC,IAAI,EAAC;UAAS,CACd,CAAC,eACFhD,IAAA,CAACX,WAAW;YACXkD,EAAE,EAAG1C,iBAAmB;YACxBiD,WAAW,EAAG,CAAE9B,cAAgB;YAChCoB,OAAO,EAAGpB,cAAc,GAAG,UAAU,GAAG+B,SAAW;YACnDC,IAAI,EAAC;UAAS,CACd,CAAC,EACA,CAAEtC,iBAAiB,iBACpBV,IAAA,CAACX,WAAW;YACXkD,EAAE,EAAGnD,MAAQ;YACbkB,SAAS,EAAC,iDAAiD;YAC3DsC,IAAI,EAAGtD,QAAU;YACjBqD,QAAQ,EAAGpC,iBAAmB;YAC9BiC,SAAS,EAAG5B;YACZ;YACAiC,KAAK,EAAG/D,EAAE,CAAE,mBAAoB,CAAG;YACnC4D,OAAO,EAAGV,cAAgB;YAC1BiB,QAAQ,EAAGpC,gBAAkB;YAC7BiC,WAAW,EAAG,CAAE9B,cAAgB;YAChCoB,OAAO,EACNpB,cAAc,GAAG,UAAU,GAAG+B,SAC9B;YACD,iBAAgBnC,cAAgB;YAChC0B,GAAG,EAAGvB,iBAAmB;YACzBiC,IAAI,EAAC;UAAS,CACd,CACD;QAAA,CACA,CACF;MAAA,CACG;IAAC,CACW;EAAC;AAErB;AAEA,eAAe3C,aAAa","ignoreList":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
4
5
|
import { useSelect } from '@wordpress/data';
|
|
5
6
|
import { useMediaQuery, useViewportMatch } from '@wordpress/compose';
|
|
6
7
|
import { __unstableMotion as motion } from '@wordpress/components';
|
|
7
8
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
8
9
|
import { useState } from '@wordpress/element';
|
|
9
10
|
import { PinnedItems } from '@wordpress/interface';
|
|
10
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
@@ -72,10 +72,12 @@ function Header({
|
|
|
72
72
|
const isLargeViewport = useViewportMatch('medium');
|
|
73
73
|
const isTooNarrowForDocumentBar = useMediaQuery('(max-width: 403px)');
|
|
74
74
|
const {
|
|
75
|
+
postType,
|
|
75
76
|
isTextEditor,
|
|
76
77
|
isPublishSidebarOpened,
|
|
77
78
|
showIconLabels,
|
|
78
79
|
hasFixedToolbar,
|
|
80
|
+
hasBlockSelection,
|
|
79
81
|
isNestedEntity
|
|
80
82
|
} = useSelect(select => {
|
|
81
83
|
const {
|
|
@@ -84,26 +86,27 @@ function Header({
|
|
|
84
86
|
const {
|
|
85
87
|
getEditorMode,
|
|
86
88
|
getEditorSettings,
|
|
89
|
+
getCurrentPostType,
|
|
87
90
|
isPublishSidebarOpened: _isPublishSidebarOpened
|
|
88
91
|
} = select(editorStore);
|
|
89
|
-
const {
|
|
90
|
-
__unstableGetEditorMode
|
|
91
|
-
} = select(blockEditorStore);
|
|
92
92
|
return {
|
|
93
|
+
postType: getCurrentPostType(),
|
|
93
94
|
isTextEditor: getEditorMode() === 'text',
|
|
94
95
|
isPublishSidebarOpened: _isPublishSidebarOpened(),
|
|
95
96
|
showIconLabels: getPreference('core', 'showIconLabels'),
|
|
96
97
|
hasFixedToolbar: getPreference('core', 'fixedToolbar'),
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
hasBlockSelection: !!select(blockEditorStore).getBlockSelectionStart(),
|
|
99
|
+
isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord
|
|
99
100
|
};
|
|
100
101
|
}, []);
|
|
102
|
+
const canBeZoomedOut = ['post', 'page', 'wp_template'].includes(postType);
|
|
101
103
|
const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = useState(true);
|
|
102
|
-
const hasCenter = isBlockToolsCollapsed && !isTooNarrowForDocumentBar;
|
|
104
|
+
const hasCenter = (!hasBlockSelection || isBlockToolsCollapsed) && !isTooNarrowForDocumentBar;
|
|
103
105
|
const hasBackButton = useHasBackButton();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
/*
|
|
107
|
+
* The edit-post-header classname is only kept for backward compatability
|
|
108
|
+
* as some plugins might be relying on its presence.
|
|
109
|
+
*/
|
|
107
110
|
return /*#__PURE__*/_jsxs("div", {
|
|
108
111
|
className: "editor-header edit-post-header",
|
|
109
112
|
children: [hasBackButton && /*#__PURE__*/_jsx(motion.div, {
|
|
@@ -142,20 +145,22 @@ function Header({
|
|
|
142
145
|
className: "editor-header__settings",
|
|
143
146
|
children: [!customSaveButton && !isPublishSidebarOpened &&
|
|
144
147
|
/*#__PURE__*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
/*
|
|
149
|
+
* This button isn't completely hidden by the publish sidebar.
|
|
150
|
+
* We can't hide the whole toolbar when the publish sidebar is open because
|
|
151
|
+
* we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
|
|
152
|
+
* We track that DOM node to return focus to the PostPublishButtonOrToggle
|
|
153
|
+
* when the publish sidebar has been closed.
|
|
154
|
+
*/
|
|
150
155
|
_jsx(PostSavedState, {
|
|
151
156
|
forceIsDirty: forceIsDirty
|
|
152
|
-
}), /*#__PURE__*/_jsx(PreviewDropdown, {
|
|
157
|
+
}), canBeZoomedOut && isEditorIframed && isWideViewport && /*#__PURE__*/_jsx(ZoomOutToggle, {}), /*#__PURE__*/_jsx(PreviewDropdown, {
|
|
153
158
|
forceIsAutosaveable: forceIsDirty,
|
|
154
159
|
disabled: isNestedEntity
|
|
155
160
|
}), /*#__PURE__*/_jsx(PostPreviewButton, {
|
|
156
161
|
className: "editor-header__post-preview-button",
|
|
157
162
|
forceIsAutosaveable: forceIsDirty
|
|
158
|
-
}), /*#__PURE__*/_jsx(PostViewLink, {}),
|
|
163
|
+
}), /*#__PURE__*/_jsx(PostViewLink, {}), (isWideViewport || !showIconLabels) && /*#__PURE__*/_jsx(PinnedItems.Slot, {
|
|
159
164
|
scope: "core"
|
|
160
165
|
}), !customSaveButton && /*#__PURE__*/_jsx(PostPublishButtonOrToggle, {
|
|
161
166
|
forceIsDirty: forceIsDirty,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useMediaQuery","useViewportMatch","__unstableMotion","motion","store","preferencesStore","useState","PinnedItems","blockEditorStore","BackButton","useHasBackButton","CollapsibleBlockToolbar","DocumentBar","DocumentTools","MoreMenu","PostPreviewButton","PostPublishButtonOrToggle","PostSavedState","PostViewLink","PreviewDropdown","ZoomOutToggle","editorStore","jsx","_jsx","jsxs","_jsxs","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isEditorIframed","isWideViewport","isLargeViewport","isTooNarrowForDocumentBar","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","isNestedEntity","select","get","getPreference","getEditorMode","getEditorSettings","_isPublishSidebarOpened","__unstableGetEditorMode","onNavigateToPreviousEntityRecord","isZoomedOutView","isBlockToolsCollapsed","setIsBlockToolsCollapsed","hasCenter","hasBackButton","className","children","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","scope"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n\tisEditorIframed,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\tisNestedEntity,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetEditorSettings,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\tisNestedEntity:\n\t\t\t\t!! getEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter = isBlockToolsCollapsed && ! isTooNarrowForDocumentBar;\n\tconst hasBackButton = useHasBackButton();\n\n\t// The edit-post-header classname is only kept for backward compatibilty\n\t// as some plugins might be relying on its presence.\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ isNestedEntity }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t{ isEditorIframed && isWideViewport && <ZoomOutToggle /> }\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,oBAAoB;AACpE,SAASC,gBAAgB,IAAIC,MAAM,QAAQ,uBAAuB;AAClE,SAASC,KAAK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AA;MAC/C;MACA;MACA;MACA;MACA;MACAvB,IAAA,CAACN,cAAc;QAACoB,YAAY,EAAGA;MAAc,CAAE,CAC/C,eACDd,IAAA,CAACJ,eAAe;QACfsD,mBAAmB,EAAGpC,YAAc;QACpCqC,QAAQ,EAAGzB;MAAgB,CAC3B,CAAC,eACF1B,IAAA,CAACR,iBAAiB;QACjBgD,SAAS,EAAC,oCAAoC;QAC9CU,mBAAmB,EAAGpC;MAAc,CACpC,CAAC,eACFd,IAAA,CAACL,YAAY,IAAE,CAAC,EAEduB,eAAe,IAAIC,cAAc,iBAAInB,IAAA,CAACH,aAAa,IAAE,CAAC,EAEtD,CAAEsB,cAAc,IAAI,CAAEK,cAAc,kBACrCxB,IAAA,CAAChB,WAAW,CAAC8D,IAAI;QAACM,KAAK,EAAC;MAAM,CAAE,CAChC,EAEC,CAAEvC,gBAAgB,iBACnBb,IAAA,CAACP,yBAAyB;QACzBqB,YAAY,EAAGA,YAAc;QAC7BE,8BAA8B,EAC7BA;MACA,CACD,CACD,EAECH,gBAAgB,eAClBb,IAAA,CAACT,QAAQ,IAAE,CAAC;IAAA,CACD,CAAC;EAAA,CACT,CAAC;AAER;AAEA,eAAeqB,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["store","blockEditorStore","useSelect","useMediaQuery","useViewportMatch","__unstableMotion","motion","preferencesStore","useState","PinnedItems","BackButton","useHasBackButton","CollapsibleBlockToolbar","DocumentBar","DocumentTools","MoreMenu","PostPreviewButton","PostPublishButtonOrToggle","PostSavedState","PostViewLink","PreviewDropdown","ZoomOutToggle","editorStore","jsx","_jsx","jsxs","_jsxs","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isEditorIframed","isWideViewport","isLargeViewport","isTooNarrowForDocumentBar","postType","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","hasBlockSelection","isNestedEntity","select","get","getPreference","getEditorMode","getEditorSettings","getCurrentPostType","_isPublishSidebarOpened","getBlockSelectionStart","onNavigateToPreviousEntityRecord","canBeZoomedOut","includes","isBlockToolsCollapsed","setIsBlockToolsCollapsed","hasCenter","hasBackButton","className","children","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","scope"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n\tisEditorIframed,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tpostType,\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\thasBlockSelection,\n\t\tisNestedEntity,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetEditorSettings,\n\t\t\tgetCurrentPostType,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t\tisNestedEntity:\n\t\t\t\t!! getEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t};\n\t}, [] );\n\n\tconst canBeZoomedOut = [ 'post', 'page', 'wp_template' ].includes(\n\t\tpostType\n\t);\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter =\n\t\t( ! hasBlockSelection || isBlockToolsCollapsed ) &&\n\t\t! isTooNarrowForDocumentBar;\n\tconst hasBackButton = useHasBackButton();\n\t/*\n\t * The edit-post-header classname is only kept for backward compatability\n\t * as some plugins might be relying on its presence.\n\t */\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t/*\n\t\t\t\t\t * This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t * We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t * we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t * We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t * when the publish sidebar has been closed.\n\t\t\t\t\t */\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\n\t\t\t\t{ canBeZoomedOut && isEditorIframed && isWideViewport && (\n\t\t\t\t\t<ZoomOutToggle />\n\t\t\t\t) }\n\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ isNestedEntity }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,oBAAoB;AACpE,SAASC,gBAAgB,IAAIC,MAAM,QAAQ,uBAAuB;AAClE,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,wBAAwB;AAClE,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,WAAW,QAAQ,sBAAsB;;AAElD;AACA;AACA;AACA,OAAOC,UAAU,IAAIC,gBAAgB,QAAQ,eAAe;AAC5D,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,OAAOC,WAAW,MAAM,iBAAiB;AACzC,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,QAAQ,MAAM,cAA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AACH,aAAa,IAAE,CAChB,eAEDG,IAAA,CAACJ,eAAe;QACf0D,mBAAmB,EAAGxC,YAAc;QACpCyC,QAAQ,EAAG3B;MAAgB,CAC3B,CAAC,eACF5B,IAAA,CAACR,iBAAiB;QACjBoD,SAAS,EAAC,oCAAoC;QAC9CU,mBAAmB,EAAGxC;MAAc,CACpC,CAAC,eACFd,IAAA,CAACL,YAAY,IAAE,CAAC,EAEd,CAAEwB,cAAc,IAAI,CAAEM,cAAc,kBACrCzB,IAAA,CAACf,WAAW,CAACiE,IAAI;QAACM,KAAK,EAAC;MAAM,CAAE,CAChC,EAEC,CAAE3C,gBAAgB,iBACnBb,IAAA,CAACP,yBAAyB;QACzBqB,YAAY,EAAGA,YAAc;QAC7BE,8BAA8B,EAC7BA;MACA,CACD,CACD,EAECH,gBAAgB,eAClBb,IAAA,CAACT,QAAQ,IAAE,CAAC;IAAA,CACD,CAAC;EAAA,CACT,CAAC;AAER;AAEA,eAAeqB,MAAM","ignoreList":[]}
|
|
@@ -22,13 +22,13 @@ export default function InserterSidebar() {
|
|
|
22
22
|
const {
|
|
23
23
|
blockSectionRootClientId,
|
|
24
24
|
inserterSidebarToggleRef,
|
|
25
|
-
|
|
25
|
+
inserter,
|
|
26
26
|
showMostUsedBlocks,
|
|
27
27
|
sidebarIsOpened
|
|
28
28
|
} = useSelect(select => {
|
|
29
29
|
const {
|
|
30
30
|
getInserterSidebarToggleRef,
|
|
31
|
-
|
|
31
|
+
getInserter,
|
|
32
32
|
isPublishSidebarOpened
|
|
33
33
|
} = unlock(select(editorStore));
|
|
34
34
|
const {
|
|
@@ -53,7 +53,7 @@ export default function InserterSidebar() {
|
|
|
53
53
|
};
|
|
54
54
|
return {
|
|
55
55
|
inserterSidebarToggleRef: getInserterSidebarToggleRef(),
|
|
56
|
-
|
|
56
|
+
inserter: getInserter(),
|
|
57
57
|
showMostUsedBlocks: get('core', 'mostUsedBlocks'),
|
|
58
58
|
blockSectionRootClientId: getBlockSectionRootClientId(),
|
|
59
59
|
sidebarIsOpened: !!(getActiveComplementaryArea('core') || isPublishSidebarOpened())
|
|
@@ -85,12 +85,11 @@ export default function InserterSidebar() {
|
|
|
85
85
|
showMostUsedBlocks: showMostUsedBlocks,
|
|
86
86
|
showInserterHelpPanel: true,
|
|
87
87
|
shouldFocusBlock: isMobileViewport,
|
|
88
|
-
rootClientId: blockSectionRootClientId
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
__experimentalFilterValue: insertionPoint.filterValue,
|
|
88
|
+
rootClientId: blockSectionRootClientId,
|
|
89
|
+
onSelect: inserter.onSelect,
|
|
90
|
+
__experimentalInitialTab: inserter.tab,
|
|
91
|
+
__experimentalInitialCategory: inserter.category,
|
|
92
|
+
__experimentalFilterValue: inserter.filterValue,
|
|
94
93
|
onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea('core') : undefined,
|
|
95
94
|
ref: libraryRef,
|
|
96
95
|
onClose: closeInserterSidebar
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useSelect","store","blockEditorStore","privateApis","blockEditorPrivateApis","useViewportMatch","useCallback","useRef","preferencesStore","ESCAPE","interfaceStore","unlock","editorStore","jsx","_jsx","PrivateInserterLibrary","InserterSidebar","blockSectionRootClientId","inserterSidebarToggleRef","
|
|
1
|
+
{"version":3,"names":["useDispatch","useSelect","store","blockEditorStore","privateApis","blockEditorPrivateApis","useViewportMatch","useCallback","useRef","preferencesStore","ESCAPE","interfaceStore","unlock","editorStore","jsx","_jsx","PrivateInserterLibrary","InserterSidebar","blockSectionRootClientId","inserterSidebarToggleRef","inserter","showMostUsedBlocks","sidebarIsOpened","select","getInserterSidebarToggleRef","getInserter","isPublishSidebarOpened","getBlockRootClientId","__unstableGetEditorMode","getSectionRootClientId","get","getActiveComplementaryArea","getBlockSectionRootClientId","sectionRootClientId","setIsInserterOpened","disableComplementaryArea","isMobileViewport","libraryRef","closeInserterSidebar","current","focus","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","inserterContents","className","children","showInserterHelpPanel","shouldFocusBlock","rootClientId","onSelect","__experimentalInitialTab","tab","__experimentalInitialCategory","category","__experimentalFilterValue","filterValue","onPatternCategorySelection","undefined","ref","onClose","onKeyDown"],"sources":["@wordpress/editor/src/components/inserter-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nconst { PrivateInserterLibrary } = unlock( blockEditorPrivateApis );\n\nexport default function InserterSidebar() {\n\tconst {\n\t\tblockSectionRootClientId,\n\t\tinserterSidebarToggleRef,\n\t\tinserter,\n\t\tshowMostUsedBlocks,\n\t\tsidebarIsOpened,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tgetInserter,\n\t\t\tisPublishSidebarOpened,\n\t\t} = unlock( select( editorStore ) );\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\t__unstableGetEditorMode,\n\t\t\tgetSectionRootClientId,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { getActiveComplementaryArea } = select( interfaceStore );\n\t\tconst getBlockSectionRootClientId = () => {\n\t\t\tif ( __unstableGetEditorMode() === 'zoom-out' ) {\n\t\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\n\t\t\t\tif ( sectionRootClientId ) {\n\t\t\t\t\treturn sectionRootClientId;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn getBlockRootClientId();\n\t\t};\n\t\treturn {\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tinserter: getInserter(),\n\t\t\tshowMostUsedBlocks: get( 'core', 'mostUsedBlocks' ),\n\t\t\tblockSectionRootClientId: getBlockSectionRootClientId(),\n\t\t\tsidebarIsOpened: !! (\n\t\t\t\tgetActiveComplementaryArea( 'core' ) || isPublishSidebarOpened()\n\t\t\t),\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editorStore );\n\tconst { disableComplementaryArea } = useDispatch( interfaceStore );\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst libraryRef = useRef();\n\n\t// When closing the inserter, focus should return to the toggle button.\n\tconst closeInserterSidebar = useCallback( () => {\n\t\tsetIsInserterOpened( false );\n\t\tinserterSidebarToggleRef.current?.focus();\n\t}, [ inserterSidebarToggleRef, setIsInserterOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseInserterSidebar();\n\t\t\t}\n\t\t},\n\t\t[ closeInserterSidebar ]\n\t);\n\n\tconst inserterContents = (\n\t\t<div className=\"editor-inserter-sidebar__content\">\n\t\t\t<PrivateInserterLibrary\n\t\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t\tshowInserterHelpPanel\n\t\t\t\tshouldFocusBlock={ isMobileViewport }\n\t\t\t\trootClientId={ blockSectionRootClientId }\n\t\t\t\tonSelect={ inserter.onSelect }\n\t\t\t\t__experimentalInitialTab={ inserter.tab }\n\t\t\t\t__experimentalInitialCategory={ inserter.category }\n\t\t\t\t__experimentalFilterValue={ inserter.filterValue }\n\t\t\t\tonPatternCategorySelection={\n\t\t\t\t\tsidebarIsOpened\n\t\t\t\t\t\t? () => disableComplementaryArea( 'core' )\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tref={ libraryRef }\n\t\t\t\tonClose={ closeInserterSidebar }\n\t\t\t/>\n\t\t</div>\n\t);\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div onKeyDown={ closeOnEscape } className=\"editor-inserter-sidebar\">\n\t\t\t{ inserterContents }\n\t\t</div>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,wBAAwB;AAClE,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASR,KAAK,IAAIS,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASV,KAAK,IAAIW,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnD,MAAM;EAAEC;AAAuB,CAAC,GAAGJ,MAAM,CAAEP,sBAAuB,CAAC;AAEnE,eAAe,SAASY,eAAeA,CAAA,EAAG;EACzC,MAAM;IACLC,wBAAwB;IACxBC,wBAAwB;IACxBC,QAAQ;IACRC,kBAAkB;IAClBC;EACD,CAAC,GAAGrB,SAAS,CAAIsB,MAAM,IAAM;IAC5B,MAAM;MACLC,2BAA2B;MAC3BC,WAAW;MACXC;IACD,CAAC,GAAGd,MAAM,CAAEW,MAAM,CAAEV,WAAY,CAAE,CAAC;IACnC,MAAM;MACLc,oBAAoB;MACpBC,uBAAuB;MACvBC;IACD,CAAC,GAAGjB,MAAM,CAAEW,MAAM,CAAEpB,gBAAiB,CAAE,CAAC;IACxC,MAAM;MAAE2B;IAAI,CAAC,GAAGP,MAAM,CAAEd,gBAAiB,CA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AEgC,KAAK,CAACE,gBAAgB,EAAG;MAC3DF,KAAK,CAACG,cAAc,CAAC,CAAC;MACtBP,oBAAoB,CAAC,CAAC;IACvB;EACD,CAAC,EACD,CAAEA,oBAAoB,CACvB,CAAC;EAED,MAAMQ,gBAAgB,gBACrB/B,IAAA;IAAKgC,SAAS,EAAC,kCAAkC;IAAAC,QAAA,eAChDjC,IAAA,CAACC,sBAAsB;MACtBK,kBAAkB,EAAGA,kBAAoB;MACzC4B,qBAAqB;MACrBC,gBAAgB,EAAGd,gBAAkB;MACrCe,YAAY,EAAGjC,wBAA0B;MACzCkC,QAAQ,EAAGhC,QAAQ,CAACgC,QAAU;MAC9BC,wBAAwB,EAAGjC,QAAQ,CAACkC,GAAK;MACzCC,6BAA6B,EAAGnC,QAAQ,CAACoC,QAAU;MACnDC,yBAAyB,EAAGrC,QAAQ,CAACsC,WAAa;MAClDC,0BAA0B,EACzBrC,eAAe,GACZ,MAAMa,wBAAwB,CAAE,MAAO,CAAC,GACxCyB,SACH;MACDC,GAAG,EAAGxB,UAAY;MAClByB,OAAO,EAAGxB;IAAsB,CAChC;EAAC,CACE,CACL;EAED;IAAA;IACC;IACAvB,IAAA;MAAKgD,SAAS,EAAGtB,aAAe;MAACM,SAAS,EAAC,yBAAyB;MAAAC,QAAA,EACjEF;IAAgB,CACd;EAAC;AAER","ignoreList":[]}
|
|
@@ -3,38 +3,31 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useRegistry } from '@wordpress/data';
|
|
5
5
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
-
import { useEffect
|
|
7
|
-
import { applyFilters } from '@wordpress/hooks';
|
|
6
|
+
import { useEffect } from '@wordpress/element';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Internal dependencies
|
|
11
10
|
*/
|
|
12
|
-
import
|
|
13
|
-
import { unlock } from '../../lock-unlock';
|
|
14
|
-
const POST_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
|
|
11
|
+
import usePostContentBlocks from './use-post-content-blocks';
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* Component that when rendered, makes it so that the site editor allows only
|
|
18
15
|
* page content to be edited.
|
|
19
16
|
*/
|
|
20
17
|
export default function DisableNonPageContentBlocks() {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
// Note that there are two separate subscriptions because the result for each
|
|
24
|
-
// returns a new array.
|
|
25
|
-
const contentOnlyIds = useSelect(select => {
|
|
18
|
+
const contentOnlyIds = usePostContentBlocks();
|
|
19
|
+
const templateParts = useSelect(select => {
|
|
26
20
|
const {
|
|
27
|
-
|
|
28
|
-
} =
|
|
29
|
-
return
|
|
30
|
-
}, [
|
|
21
|
+
getBlocksByName
|
|
22
|
+
} = select(blockEditorStore);
|
|
23
|
+
return getBlocksByName('core/template-part');
|
|
24
|
+
}, []);
|
|
31
25
|
const disabledIds = useSelect(select => {
|
|
32
26
|
const {
|
|
33
|
-
getBlocksByName,
|
|
34
27
|
getBlockOrder
|
|
35
28
|
} = select(blockEditorStore);
|
|
36
|
-
return
|
|
37
|
-
}, []);
|
|
29
|
+
return templateParts.flatMap(clientId => getBlockOrder(clientId));
|
|
30
|
+
}, [templateParts]);
|
|
38
31
|
const registry = useRegistry();
|
|
39
32
|
useEffect(() => {
|
|
40
33
|
const {
|
|
@@ -46,6 +39,9 @@ export default function DisableNonPageContentBlocks() {
|
|
|
46
39
|
for (const clientId of contentOnlyIds) {
|
|
47
40
|
setBlockEditingMode(clientId, 'contentOnly');
|
|
48
41
|
}
|
|
42
|
+
for (const clientId of templateParts) {
|
|
43
|
+
setBlockEditingMode(clientId, 'contentOnly');
|
|
44
|
+
}
|
|
49
45
|
for (const clientId of disabledIds) {
|
|
50
46
|
setBlockEditingMode(clientId, 'disabled');
|
|
51
47
|
}
|
|
@@ -56,12 +52,15 @@ export default function DisableNonPageContentBlocks() {
|
|
|
56
52
|
for (const clientId of contentOnlyIds) {
|
|
57
53
|
unsetBlockEditingMode(clientId);
|
|
58
54
|
}
|
|
55
|
+
for (const clientId of templateParts) {
|
|
56
|
+
unsetBlockEditingMode(clientId);
|
|
57
|
+
}
|
|
59
58
|
for (const clientId of disabledIds) {
|
|
60
59
|
unsetBlockEditingMode(clientId);
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
62
|
};
|
|
64
|
-
}, [contentOnlyIds, disabledIds, registry]);
|
|
63
|
+
}, [templateParts, contentOnlyIds, disabledIds, registry]);
|
|
65
64
|
return null;
|
|
66
65
|
}
|
|
67
66
|
//# sourceMappingURL=disable-non-page-content-blocks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useRegistry","store","blockEditorStore","useEffect","
|
|
1
|
+
{"version":3,"names":["useSelect","useRegistry","store","blockEditorStore","useEffect","usePostContentBlocks","DisableNonPageContentBlocks","contentOnlyIds","templateParts","select","getBlocksByName","disabledIds","getBlockOrder","flatMap","clientId","registry","setBlockEditingMode","unsetBlockEditingMode","dispatch","batch"],"sources":["@wordpress/editor/src/components/provider/disable-non-page-content-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useRegistry } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport usePostContentBlocks from './use-post-content-blocks';\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\tconst contentOnlyIds = usePostContentBlocks();\n\tconst templateParts = useSelect( ( select ) => {\n\t\tconst { getBlocksByName } = select( blockEditorStore );\n\t\treturn getBlocksByName( 'core/template-part' );\n\t}, [] );\n\tconst disabledIds = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockOrder } = select( blockEditorStore );\n\t\t\treturn templateParts.flatMap( ( clientId ) =>\n\t\t\t\tgetBlockOrder( clientId )\n\t\t\t);\n\t\t},\n\t\t[ templateParts ]\n\t);\n\n\tconst registry = useRegistry();\n\n\tuseEffect( () => {\n\t\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\t\tregistry.dispatch( blockEditorStore );\n\n\t\tregistry.batch( () => {\n\t\t\tsetBlockEditingMode( '', 'disabled' );\n\t\t\tfor ( const clientId of contentOnlyIds ) {\n\t\t\t\tsetBlockEditingMode( clientId, 'contentOnly' );\n\t\t\t}\n\t\t\tfor ( const clientId of templateParts ) {\n\t\t\t\tsetBlockEditingMode( clientId, 'contentOnly' );\n\t\t\t}\n\t\t\tfor ( const clientId of disabledIds ) {\n\t\t\t\tsetBlockEditingMode( clientId, 'disabled' );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tregistry.batch( () => {\n\t\t\t\tunsetBlockEditingMode( '' );\n\t\t\t\tfor ( const clientId of contentOnlyIds ) {\n\t\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t\t}\n\t\t\t\tfor ( const clientId of templateParts ) {\n\t\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t\t}\n\t\t\t\tfor ( const clientId of disabledIds ) {\n\t\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t\t}\n\t\t\t} );\n\t\t};\n\t}, [ templateParts, contentOnlyIds, disabledIds, registry ] );\n\n\treturn null;\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;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,2BAA2B;;AAE5D;AACA;AACA;AACA;AACA,eAAe,SAASC,2BAA2BA,CAAA,EAAG;EACrD,MAAMC,cAAc,GAAGF,oBAAoB,CAAC,CAAC;EAC7C,MAAMG,aAAa,GAAGR,SAAS,CAAIS,MAAM,IAAM;IAC9C,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,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AEH,QAAS,CAAC;QAClC;MACD,CAAE,CAAC;IACJ,CAAC;EACF,CAAC,EAAE,CAAEN,aAAa,EAAED,cAAc,EAAEI,WAAW,EAAEI,QAAQ,CAAG,CAAC;EAE7D,OAAO,IAAI;AACZ","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useMemo } from '@wordpress/element';
|
|
6
|
+
import { applyFilters } from '@wordpress/hooks';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as editorStore } from '../../store';
|
|
12
|
+
import { unlock } from '../../lock-unlock';
|
|
13
|
+
const POST_CONTENT_BLOCK_TYPES = ['core/post-title', 'core/post-featured-image', 'core/post-content'];
|
|
14
|
+
export default function usePostContentBlocks() {
|
|
15
|
+
const contentOnlyBlockTypes = useMemo(() => [...applyFilters('editor.postContentBlockTypes', POST_CONTENT_BLOCK_TYPES)], []);
|
|
16
|
+
|
|
17
|
+
// Note that there are two separate subscriptions because the result for each
|
|
18
|
+
// returns a new array.
|
|
19
|
+
const contentOnlyIds = useSelect(select => {
|
|
20
|
+
const {
|
|
21
|
+
getPostBlocksByName
|
|
22
|
+
} = unlock(select(editorStore));
|
|
23
|
+
return getPostBlocksByName(contentOnlyBlockTypes);
|
|
24
|
+
}, [contentOnlyBlockTypes]);
|
|
25
|
+
return contentOnlyIds;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=use-post-content-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useSelect","useMemo","applyFilters","store","editorStore","unlock","POST_CONTENT_BLOCK_TYPES","usePostContentBlocks","contentOnlyBlockTypes","contentOnlyIds","select","getPostBlocksByName"],"sources":["@wordpress/editor/src/components/provider/use-post-content-blocks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst POST_CONTENT_BLOCK_TYPES = [\n\t'core/post-title',\n\t'core/post-featured-image',\n\t'core/post-content',\n];\n\nexport default function usePostContentBlocks() {\n\tconst contentOnlyBlockTypes = useMemo(\n\t\t() => [\n\t\t\t...applyFilters(\n\t\t\t\t'editor.postContentBlockTypes',\n\t\t\t\tPOST_CONTENT_BLOCK_TYPES\n\t\t\t),\n\t\t],\n\t\t[]\n\t);\n\n\t// Note that there are two separate subscriptions because the result for each\n\t// returns a new array.\n\tconst contentOnlyIds = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPostBlocksByName } = unlock( select( editorStore ) );\n\t\t\treturn getPostBlocksByName( contentOnlyBlockTypes );\n\t\t},\n\t\t[ contentOnlyBlockTypes ]\n\t);\n\n\treturn contentOnlyIds;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAMC,wBAAwB,GAAG,CAChC,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,CACnB;AAED,eAAe,SAASC,oBAAoBA,CAAA,EAAG;EAC9C,MAAMC,qBAAqB,GAAGP,OAAO,CACpC,MAAM,CACL,GAAGC,YAAY,CACd,8BAA8B,EAC9BI,wBACD,CAAC,CACD,EACD,EACD,CAAC;;EAED;EACA;EACA,MAAMG,cAAc,GAAGT,SAAS,CAC7BU,MAAM,IAAM;IACb,MAAM;MAAEC;IAAoB,CAAC,GAAGN,MAAM,CAAEK,MAAM,CAAEN,WAAY,CAAE,CAAC;IAC/D,OAAOO,mBAAmB,CAAEH,qBAAsB,CAAC;EACpD,CAAC,EACD,CAAEA,qBAAqB,CACxB,CAAC;EAED,OAAOC,cAAc;AACtB","ignoreList":[]}
|
|
@@ -17,6 +17,10 @@ export default function ResizeHandle({
|
|
|
17
17
|
const {
|
|
18
18
|
keyCode
|
|
19
19
|
} = event;
|
|
20
|
+
if (keyCode !== LEFT && keyCode !== RIGHT) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
event.preventDefault();
|
|
20
24
|
if (direction === 'left' && keyCode === LEFT || direction === 'right' && keyCode === RIGHT) {
|
|
21
25
|
resizeWidthBy(DELTA_DISTANCE);
|
|
22
26
|
} else if (direction === 'left' && keyCode === RIGHT || direction === 'right' && keyCode === LEFT) {
|