@wordpress/editor 13.25.0 → 13.26.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 +6 -0
- package/LICENSE.md +1 -1
- package/build/components/document-bar/index.js +19 -7
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/index.js +82 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +160 -0
- package/build/components/document-tools/index.js.map +1 -0
- package/build/components/editor-canvas/index.js +10 -4
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/entities-saved-states/index.js +3 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +12 -2
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +56 -8
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +77 -0
- package/build/components/inserter-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/index.js +150 -0
- package/build/components/list-view-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/list-view-outline.js +28 -0
- package/build/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build/components/offline-status/index.native.js +85 -0
- package/build/components/offline-status/index.native.js.map +1 -0
- package/build/components/page-attributes/panel.js +63 -0
- package/build/components/page-attributes/panel.js.map +1 -0
- package/build/components/post-discussion/panel.js +59 -0
- package/build/components/post-discussion/panel.js.map +1 -0
- package/build/components/post-excerpt/check.js +19 -0
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/panel.js +55 -0
- package/build/components/post-excerpt/panel.js.map +1 -0
- package/build/components/post-excerpt/plugin.js +72 -0
- package/build/components/post-excerpt/plugin.js.map +1 -0
- package/build/components/post-featured-image/index.js +5 -8
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +60 -0
- package/build/components/post-featured-image/panel.js.map +1 -0
- package/build/components/post-last-revision/panel.js +27 -0
- package/build/components/post-last-revision/panel.js.map +1 -0
- package/build/components/post-saved-state/index.js +12 -8
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-taxonomies/panel.js +68 -0
- package/build/components/post-taxonomies/panel.js.map +1 -0
- package/build/components/post-template/block-theme.js +2 -1
- package/build/components/post-template/block-theme.js.map +1 -1
- package/build/components/post-template/hooks.js +6 -6
- package/build/components/post-template/hooks.js.map +1 -1
- package/build/components/post-template/panel.js +1 -2
- package/build/components/post-template/panel.js.map +1 -1
- package/build/components/post-template/swap-template-button.js +4 -2
- package/build/components/post-template/swap-template-button.js.map +1 -1
- package/build/components/post-title/index.native.js +25 -14
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-view-link/index.js +58 -0
- package/build/components/post-view-link/index.js.map +1 -0
- package/build/components/post-visibility/check.js +5 -17
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/preview-dropdown/index.js +8 -3
- package/build/components/preview-dropdown/index.js.map +1 -1
- package/build/components/provider/index.native.js +19 -0
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +29 -5
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/private-apis.js +10 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +102 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-selectors.js +52 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +78 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +76 -2
- package/build/store/selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +8 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +19 -7
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +82 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +151 -0
- package/build-module/components/document-tools/index.js.map +1 -0
- package/build-module/components/editor-canvas/index.js +10 -4
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +3 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +12 -2
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +6 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +70 -0
- package/build-module/components/inserter-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/index.js +142 -0
- package/build-module/components/list-view-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js +20 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build-module/components/offline-status/index.native.js +77 -0
- package/build-module/components/offline-status/index.native.js.map +1 -0
- package/build-module/components/page-attributes/panel.js +53 -0
- package/build-module/components/page-attributes/panel.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +50 -0
- package/build-module/components/post-discussion/panel.js.map +1 -0
- package/build-module/components/post-excerpt/check.js +19 -0
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +48 -0
- package/build-module/components/post-excerpt/panel.js.map +1 -0
- package/build-module/components/post-excerpt/plugin.js +64 -0
- package/build-module/components/post-excerpt/plugin.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +5 -8
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js +51 -0
- package/build-module/components/post-featured-image/panel.js.map +1 -0
- package/build-module/components/post-last-revision/panel.js +18 -0
- package/build-module/components/post-last-revision/panel.js.map +1 -0
- package/build-module/components/post-saved-state/index.js +12 -8
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-taxonomies/panel.js +59 -0
- package/build-module/components/post-taxonomies/panel.js.map +1 -0
- package/build-module/components/post-template/block-theme.js +2 -1
- package/build-module/components/post-template/block-theme.js.map +1 -1
- package/build-module/components/post-template/hooks.js +6 -6
- package/build-module/components/post-template/hooks.js.map +1 -1
- package/build-module/components/post-template/panel.js +1 -2
- package/build-module/components/post-template/panel.js.map +1 -1
- package/build-module/components/post-template/swap-template-button.js +4 -2
- package/build-module/components/post-template/swap-template-button.js.map +1 -1
- package/build-module/components/post-title/index.native.js +26 -15
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-view-link/index.js +51 -0
- package/build-module/components/post-view-link/index.js.map +1 -0
- package/build-module/components/post-visibility/check.js +6 -16
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +8 -3
- package/build-module/components/preview-dropdown/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +19 -0
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +29 -5
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/private-apis.js +10 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +94 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-selectors.js +43 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +74 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +67 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +8 -2
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +251 -0
- package/build-style/style.css +251 -0
- package/package.json +32 -32
- package/src/components/document-bar/index.js +39 -28
- package/src/components/document-outline/index.js +48 -1
- package/src/components/document-outline/style.scss +12 -0
- package/src/components/document-tools/index.js +177 -0
- package/src/components/document-tools/style.scss +98 -0
- package/src/components/editor-canvas/index.js +12 -7
- package/src/components/editor-canvas/style.scss +5 -0
- package/src/components/entities-saved-states/index.js +3 -1
- package/src/components/entities-saved-states/style.scss +4 -0
- package/src/components/global-keyboard-shortcuts/index.js +12 -2
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +10 -0
- package/src/components/index.js +6 -0
- package/src/components/index.native.js +1 -0
- package/src/components/inserter-sidebar/index.js +73 -0
- package/src/components/inserter-sidebar/style.scss +22 -0
- package/src/components/list-view-sidebar/index.js +169 -0
- package/src/components/list-view-sidebar/list-view-outline.js +37 -0
- package/src/components/list-view-sidebar/style.scss +84 -0
- package/src/components/offline-status/index.native.js +101 -0
- package/src/components/offline-status/style.native.scss +28 -0
- package/src/components/offline-status/test/index.native.js +108 -0
- package/src/components/page-attributes/panel.js +62 -0
- package/src/components/post-discussion/panel.js +57 -0
- package/src/components/post-excerpt/check.js +18 -0
- package/src/components/post-excerpt/panel.js +57 -0
- package/src/components/post-excerpt/plugin.js +61 -0
- package/src/components/post-excerpt/test/plugin.js +36 -0
- package/src/components/post-featured-image/index.js +3 -7
- package/src/components/post-featured-image/panel.js +55 -0
- package/src/components/post-last-revision/panel.js +22 -0
- package/src/components/post-last-revision/style.scss +10 -0
- package/src/components/post-saved-state/index.js +8 -8
- package/src/components/post-taxonomies/panel.js +66 -0
- package/src/components/post-template/block-theme.js +2 -1
- package/src/components/post-template/hooks.js +6 -6
- package/src/components/post-template/panel.js +1 -2
- package/src/components/post-template/swap-template-button.js +7 -4
- package/src/components/post-title/index.native.js +32 -17
- package/src/components/post-title/style.scss +1 -0
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +25 -0
- package/src/components/post-title/test/index.native.js +78 -0
- package/src/components/post-view-link/index.js +47 -0
- package/src/components/post-visibility/check.js +10 -15
- package/src/components/post-visibility/test/check.js +24 -13
- package/src/components/preview-dropdown/index.js +7 -10
- package/src/components/provider/index.native.js +29 -2
- package/src/components/provider/use-block-editor-settings.js +36 -8
- package/src/private-apis.js +10 -0
- package/src/store/actions.js +109 -0
- package/src/store/index.js +2 -0
- package/src/store/private-selectors.js +51 -0
- package/src/store/reducer.js +72 -0
- package/src/store/selectors.js +80 -0
- package/src/store/test/actions.js +56 -0
- package/src/store/test/reducer.js +98 -0
- package/src/store/test/selectors.js +49 -0
- package/src/style.scss +4 -0
- package/src/utils/media-upload/index.js +9 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","PanelBody","PanelRow","useSelect","useDispatch","store","coreStore","editorStore","PageAttributesCheck","PageAttributesOrder","PageAttributesParent","PANEL_NAME","PageAttributesPanel","_postType$labels$attr","isEnabled","isOpened","postType","select","getEditedPostAttribute","isEditorPanelEnabled","isEditorPanelOpened","getPostType","toggleEditorPanelOpened","onTogglePanel","args","createElement","title","labels","attributes","opened","onToggle"],"sources":["@wordpress/editor/src/components/page-attributes/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, PanelRow } from '@wordpress/components';\n\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PageAttributesCheck from './check';\nimport PageAttributesOrder from './order';\nimport PageAttributesParent from './parent';\n\nconst PANEL_NAME = 'page-attributes';\n\nexport function PageAttributesPanel() {\n\tconst { isEnabled, isOpened, postType } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tisEditorPanelEnabled,\n\t\t\tisEditorPanelOpened,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled || ! postType ) {\n\t\treturn null;\n\t}\n\n\tconst onTogglePanel = ( ...args ) =>\n\t\ttoggleEditorPanelOpened( PANEL_NAME, ...args );\n\n\treturn (\n\t\t<PageAttributesCheck>\n\t\t\t<PanelBody\n\t\t\t\ttitle={\n\t\t\t\t\tpostType?.labels?.attributes ?? __( 'Page attributes' )\n\t\t\t\t}\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ onTogglePanel }\n\t\t\t>\n\t\t\t\t<PageAttributesParent />\n\t\t\t\t<PanelRow>\n\t\t\t\t\t<PageAttributesOrder />\n\t\t\t\t</PanelRow>\n\t\t\t</PanelBody>\n\t\t</PageAttributesCheck>\n\t);\n}\n\nexport default PageAttributesPanel;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AAE3D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,OAAOC,mBAAmB,MAAM,SAAS;AACzC,OAAOC,mBAAmB,MAAM,SAAS;AACzC,OAAOC,oBAAoB,MAAM,UAAU;AAE3C,MAAMC,UAAU,GAAG,iBAAiB;AAEpC,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EAAA,IAAAC,qBAAA;EACrC,MAAM;IAAEC,SAAS;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGb,SAAS,CAAIc,MAAM,IAAM;IAClE,MAAM;MACLC,sBAAsB;MACtBC,oBAAoB;MACpBC;IACD,CAAC,GAAGH,MAAM,CAAEV,WAAY,CAAC;IACzB,MAAM;MAAEc;IAAY,CAAC,GAAGJ,MAAM,CAAEX,SAAU,CAAC;IAC3C,OAAO;MACNQ,SAAS,EAAEK,oBAAoB,CAAER,UAAW,CAAC;MAC7CI,QAAQ,EAAEK,mBAAmB,CAAET,UAAW,CAAC;MAC3CK,QAAQ,EAAEK,WAAW,CAAEH,sBAAsB,CAAE,MAAO,CAAE;IACzD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAEI;EAAwB,CAAC,GAAGlB,WAAW,CAAEG,WAAY,CAAC;EAE9D,IAAK,CAAEO,SAAS,IAAI,CAAEE,QAAQ,EAAG;IAChC,OAAO,IAAI;EACZ;EAEA,MAAMO,aAAa,GAAGA,CAAE,GAAGC,IAAI,KAC9BF,uBAAuB,CAAEX,UAAU,EAAE,GAAGa,IAAK,CAAC;EAE/C,OACCC,aAAA,CAACjB,mBAAmB,QACnBiB,aAAA,CAACxB,SAAS;IACTyB,KAAK,GAAAb,qBAAA,GACJG,QAAQ,EAAEW,MAAM,EAAEC,UAAU,cAAAf,qBAAA,cAAAA,qBAAA,GAAIb,EAAE,CAAE,iBAAkB,CACtD;IACD6B,MAAM,EAAGd,QAAU;IACnBe,QAAQ,EAAGP;EAAe,GAE1BE,aAAA,CAACf,oBAAoB,MAAE,CAAC,EACxBe,aAAA,CAACvB,QAAQ,QACRuB,aAAA,CAAChB,mBAAmB,MAAE,CACb,CACA,CACS,CAAC;AAExB;AAEA,eAAeG,mBAAmB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { PanelBody, PanelRow } from '@wordpress/components';
|
|
7
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as editorStore } from '../../store';
|
|
13
|
+
import PostTypeSupportCheck from '../post-type-support-check';
|
|
14
|
+
import PostComments from '../post-comments';
|
|
15
|
+
import PostPingbacks from '../post-pingbacks';
|
|
16
|
+
const PANEL_NAME = 'discussion-panel';
|
|
17
|
+
function PostDiscussionPanel() {
|
|
18
|
+
const {
|
|
19
|
+
isEnabled,
|
|
20
|
+
isOpened
|
|
21
|
+
} = useSelect(select => {
|
|
22
|
+
const {
|
|
23
|
+
isEditorPanelEnabled,
|
|
24
|
+
isEditorPanelOpened
|
|
25
|
+
} = select(editorStore);
|
|
26
|
+
return {
|
|
27
|
+
isEnabled: isEditorPanelEnabled(PANEL_NAME),
|
|
28
|
+
isOpened: isEditorPanelOpened(PANEL_NAME)
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
const {
|
|
32
|
+
toggleEditorPanelOpened
|
|
33
|
+
} = useDispatch(editorStore);
|
|
34
|
+
if (!isEnabled) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return createElement(PostTypeSupportCheck, {
|
|
38
|
+
supportKeys: ['comments', 'trackbacks']
|
|
39
|
+
}, createElement(PanelBody, {
|
|
40
|
+
title: __('Discussion'),
|
|
41
|
+
opened: isOpened,
|
|
42
|
+
onToggle: () => toggleEditorPanelOpened(PANEL_NAME)
|
|
43
|
+
}, createElement(PostTypeSupportCheck, {
|
|
44
|
+
supportKeys: "comments"
|
|
45
|
+
}, createElement(PanelRow, null, createElement(PostComments, null))), createElement(PostTypeSupportCheck, {
|
|
46
|
+
supportKeys: "trackbacks"
|
|
47
|
+
}, createElement(PanelRow, null, createElement(PostPingbacks, null)))));
|
|
48
|
+
}
|
|
49
|
+
export default PostDiscussionPanel;
|
|
50
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","PanelBody","PanelRow","useDispatch","useSelect","store","editorStore","PostTypeSupportCheck","PostComments","PostPingbacks","PANEL_NAME","PostDiscussionPanel","isEnabled","isOpened","select","isEditorPanelEnabled","isEditorPanelOpened","toggleEditorPanelOpened","createElement","supportKeys","title","opened","onToggle"],"sources":["@wordpress/editor/src/components/post-discussion/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody, PanelRow } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport PostComments from '../post-comments';\nimport PostPingbacks from '../post-pingbacks';\n\nconst PANEL_NAME = 'discussion-panel';\n\nfunction PostDiscussionPanel() {\n\tconst { isEnabled, isOpened } = useSelect( ( select ) => {\n\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ __( 'Discussion' ) }\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }\n\t\t\t>\n\t\t\t\t<PostTypeSupportCheck supportKeys=\"comments\">\n\t\t\t\t\t<PanelRow>\n\t\t\t\t\t\t<PostComments />\n\t\t\t\t\t</PanelRow>\n\t\t\t\t</PostTypeSupportCheck>\n\n\t\t\t\t<PostTypeSupportCheck supportKeys=\"trackbacks\">\n\t\t\t\t\t<PanelRow>\n\t\t\t\t\t\t<PostPingbacks />\n\t\t\t\t\t</PanelRow>\n\t\t\t\t</PostTypeSupportCheck>\n\t\t\t</PanelBody>\n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CAAC,EAEvBU,aAAA,CAACX,oBAAoB;IAACY,WAAW,EAAC;EAAY,GAC7CD,aAAA,CAAChB,QAAQ,QACRgB,aAAA,CAACT,aAAa,MAAE,CACP,CACW,CACZ,CACU,CAAC;AAEzB;AAEA,eAAeE,mBAAmB"}
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* Internal dependencies
|
|
4
9
|
*/
|
|
5
10
|
import PostTypeSupportCheck from '../post-type-support-check';
|
|
11
|
+
import { store as editorStore } from '../../store';
|
|
6
12
|
function PostExcerptCheck({
|
|
7
13
|
children
|
|
8
14
|
}) {
|
|
15
|
+
const postType = useSelect(select => {
|
|
16
|
+
const {
|
|
17
|
+
getEditedPostAttribute
|
|
18
|
+
} = select(editorStore);
|
|
19
|
+
return getEditedPostAttribute('type');
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
// This special case is unfortunate, but the REST API of wp_template and wp_template_part
|
|
23
|
+
// support the excerpt field throught the "description" field rather than "excerpt" which means
|
|
24
|
+
// the default ExcerptPanel won't work for these.
|
|
25
|
+
if (['wp_template', 'wp_template_part'].includes(postType)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
9
28
|
return createElement(PostTypeSupportCheck, {
|
|
10
29
|
supportKeys: "excerpt"
|
|
11
30
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PostTypeSupportCheck","PostExcerptCheck","children","createElement","supportKeys"],"sources":["@wordpress/editor/src/components/post-excerpt/check.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\n\nfunction PostExcerptCheck( { children } ) {\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"excerpt\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nexport default PostExcerptCheck;\n"],"mappings":";AAAA;AACA;AACA;AACA,
|
|
1
|
+
{"version":3,"names":["useSelect","PostTypeSupportCheck","store","editorStore","PostExcerptCheck","children","postType","select","getEditedPostAttribute","includes","createElement","supportKeys"],"sources":["@wordpress/editor/src/components/post-excerpt/check.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport { store as editorStore } from '../../store';\n\nfunction PostExcerptCheck( { children } ) {\n\tconst postType = useSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( editorStore );\n\t\treturn getEditedPostAttribute( 'type' );\n\t}, [] );\n\n\t// This special case is unfortunate, but the REST API of wp_template and wp_template_part\n\t// support the excerpt field throught the \"description\" field rather than \"excerpt\" which means\n\t// the default ExcerptPanel won't work for these.\n\tif ( [ 'wp_template', 'wp_template_part' ].includes( postType ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"excerpt\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nexport default PostExcerptCheck;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAElD,SAASC,gBAAgBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACzC,MAAMC,QAAQ,GAAGN,SAAS,CAAIO,MAAM,IAAM;IACzC,MAAM;MAAEC;IAAuB,CAAC,GAAGD,MAAM,CAAEJ,WAAY,CAAC;IACxD,OAAOK,sBAAsB,CAAE,MAAO,CAAC;EACxC,CAAC,EAAE,EAAG,CAAC;;EAEP;EACA;EACA;EACA,IAAK,CAAE,aAAa,EAAE,kBAAkB,CAAE,CAACC,QAAQ,CAAEH,QAAS,CAAC,EAAG;IACjE,OAAO,IAAI;EACZ;EAEA,OACCI,aAAA,CAACT,oBAAoB;IAACU,WAAW,EAAC;EAAS,GACxCN,QACmB,CAAC;AAEzB;AAEA,eAAeD,gBAAgB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { PanelBody } from '@wordpress/components';
|
|
7
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import PostExcerptForm from './index';
|
|
13
|
+
import PostExcerptCheck from './check';
|
|
14
|
+
import PluginPostExcerpt from './plugin';
|
|
15
|
+
import { store as editorStore } from '../../store';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Module Constants
|
|
19
|
+
*/
|
|
20
|
+
const PANEL_NAME = 'post-excerpt';
|
|
21
|
+
export default function PostExcerptPanel() {
|
|
22
|
+
const {
|
|
23
|
+
isOpened,
|
|
24
|
+
isEnabled
|
|
25
|
+
} = useSelect(select => {
|
|
26
|
+
const {
|
|
27
|
+
isEditorPanelOpened,
|
|
28
|
+
isEditorPanelEnabled
|
|
29
|
+
} = select(editorStore);
|
|
30
|
+
return {
|
|
31
|
+
isOpened: isEditorPanelOpened(PANEL_NAME),
|
|
32
|
+
isEnabled: isEditorPanelEnabled(PANEL_NAME)
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
const {
|
|
36
|
+
toggleEditorPanelOpened
|
|
37
|
+
} = useDispatch(editorStore);
|
|
38
|
+
const toggleExcerptPanel = () => toggleEditorPanelOpened(PANEL_NAME);
|
|
39
|
+
if (!isEnabled) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return createElement(PostExcerptCheck, null, createElement(PanelBody, {
|
|
43
|
+
title: __('Excerpt'),
|
|
44
|
+
opened: isOpened,
|
|
45
|
+
onToggle: toggleExcerptPanel
|
|
46
|
+
}, createElement(PluginPostExcerpt.Slot, null, fills => createElement(Fragment, null, createElement(PostExcerptForm, null), fills))));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","PanelBody","useDispatch","useSelect","PostExcerptForm","PostExcerptCheck","PluginPostExcerpt","store","editorStore","PANEL_NAME","PostExcerptPanel","isOpened","isEnabled","select","isEditorPanelOpened","isEditorPanelEnabled","toggleEditorPanelOpened","toggleExcerptPanel","createElement","title","opened","onToggle","Slot","fills","Fragment"],"sources":["@wordpress/editor/src/components/post-excerpt/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport PostExcerptForm from './index';\nimport PostExcerptCheck from './check';\nimport PluginPostExcerpt from './plugin';\nimport { store as editorStore } from '../../store';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-excerpt';\n\nexport default function PostExcerptPanel() {\n\tconst { isOpened, isEnabled } = useSelect( ( select ) => {\n\t\tconst { isEditorPanelOpened, isEditorPanelEnabled } =\n\t\t\tselect( editorStore );\n\n\t\treturn {\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\tconst toggleExcerptPanel = () => toggleEditorPanelOpened( PANEL_NAME );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostExcerptCheck>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ __( 'Excerpt' ) }\n\t\t\t\topened={ isOp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B,SAAS;IACTkB,KAAK,EAAGnB,EAAE,CAAE,SAAU,CAAG;IACzBoB,MAAM,EAAGT,QAAU;IACnBU,QAAQ,EAAGJ;EAAoB,GAE/BC,aAAA,CAACZ,iBAAiB,CAACgB,IAAI,QAClBC,KAAK,IACRL,aAAA,CAAAM,QAAA,QACCN,aAAA,CAACd,eAAe,MAAE,CAAC,EACjBmB,KACD,CAEoB,CACd,CACM,CAAC;AAErB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Defines as extensibility slot for the Excerpt panel.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createSlotFill, PanelRow } from '@wordpress/components';
|
|
10
|
+
const {
|
|
11
|
+
Fill,
|
|
12
|
+
Slot
|
|
13
|
+
} = createSlotFill('PluginPostExcerpt');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Renders a post excerpt panel in the post sidebar.
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} props Component properties.
|
|
19
|
+
* @param {string} [props.className] An optional class name added to the row.
|
|
20
|
+
* @param {Element} props.children Children to be rendered.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```js
|
|
24
|
+
* // Using ES5 syntax
|
|
25
|
+
* var __ = wp.i18n.__;
|
|
26
|
+
* var PluginPostExcerpt = wp.editPost.PluginPostExcerpt;
|
|
27
|
+
*
|
|
28
|
+
* function MyPluginPostExcerpt() {
|
|
29
|
+
* return React.createElement(
|
|
30
|
+
* PluginPostExcerpt,
|
|
31
|
+
* {
|
|
32
|
+
* className: 'my-plugin-post-excerpt',
|
|
33
|
+
* },
|
|
34
|
+
* __( 'Post excerpt custom content' )
|
|
35
|
+
* )
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```jsx
|
|
41
|
+
* // Using ESNext syntax
|
|
42
|
+
* import { __ } from '@wordpress/i18n';
|
|
43
|
+
* import { PluginPostExcerpt } from '@wordpress/edit-post';
|
|
44
|
+
*
|
|
45
|
+
* const MyPluginPostExcerpt = () => (
|
|
46
|
+
* <PluginPostExcerpt className="my-plugin-post-excerpt">
|
|
47
|
+
* { __( 'Post excerpt custom content' ) }
|
|
48
|
+
* </PluginPostExcerpt>
|
|
49
|
+
* );
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @return {Component} The component to be rendered.
|
|
53
|
+
*/
|
|
54
|
+
const PluginPostExcerpt = ({
|
|
55
|
+
children,
|
|
56
|
+
className
|
|
57
|
+
}) => {
|
|
58
|
+
return createElement(Fill, null, createElement(PanelRow, {
|
|
59
|
+
className: className
|
|
60
|
+
}, children));
|
|
61
|
+
};
|
|
62
|
+
PluginPostExcerpt.Slot = Slot;
|
|
63
|
+
export default PluginPostExcerpt;
|
|
64
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSlotFill","PanelRow","Fill","Slot","PluginPostExcerpt","children","className","createElement"],"sources":["@wordpress/editor/src/components/post-excerpt/plugin.js"],"sourcesContent":["/**\n * Defines as extensibility slot for the Excerpt panel.\n */\n\n/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelRow } from '@wordpress/components';\n\nconst { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );\n\n/**\n * Renders a post excerpt panel in the post sidebar.\n *\n * @param {Object} props Component properties.\n * @param {string} [props.className] An optional class name added to the row.\n * @param {Element} props.children Children to be rendered.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var PluginPostExcerpt = wp.editPost.PluginPostExcerpt;\n *\n * function MyPluginPostExcerpt() {\n * \treturn React.createElement(\n * \t\tPluginPostExcerpt,\n * \t\t{\n * \t\t\tclassName: 'my-plugin-post-excerpt',\n * \t\t},\n * \t\t__( 'Post excerpt custom content' )\n * \t)\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PluginPostExcerpt } from '@wordpress/edit-post';\n *\n * const MyPluginPostExcerpt = () => (\n * \t<PluginPostExcerpt className=\"my-plugin-post-excerpt\">\n * \t\t{ __( 'Post excerpt custom content' ) }\n * \t</PluginPostExcerpt>\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nconst PluginPostExcerpt = ( { children, className } ) => {\n\treturn (\n\t\t<Fill>\n\t\t\t<PanelRow className={ className }>{ children }</PanelRow>\n\t\t</Fill>\n\t);\n};\n\nPluginPostExcerpt.Slot = Slot;\n\nexport default PluginPostExcerpt;\n"],"mappings":";AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,cAAc,EAAEC,QAAQ,QAAQ,uBAAuB;AAEhE,MAAM;EAAEC,IAAI;EAAEC;AAAK,CAAC,GAAGH,cAAc,CAAE,mBAAoB,CAAC;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,iBAAiB,GAAGA,CAAE;EAAEC,QAAQ;EAAEC;AAAU,CAAC,KAAM;EACxD,OACCC,aAAA,CAACL,IAAI,QACJK,aAAA,CAACN,QAAQ;IAACK,SAAS,EAAGA;EAAW,GAAGD,QAAoB,CACnD,CAAC;AAET,CAAC;AAEDD,iBAAiB,CAACD,IAAI,GAAGA,IAAI;AAE7B,eAAeC,iBAAiB"}
|
|
@@ -66,17 +66,17 @@ function PostFeaturedImage({
|
|
|
66
66
|
}) {
|
|
67
67
|
const toggleRef = useRef();
|
|
68
68
|
const [isLoading, setIsLoading] = useState(false);
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
}
|
|
69
|
+
const {
|
|
70
|
+
getSettings
|
|
71
|
+
} = useSelect(blockEditorStore);
|
|
72
72
|
const {
|
|
73
73
|
mediaWidth,
|
|
74
74
|
mediaHeight,
|
|
75
75
|
mediaSourceUrl
|
|
76
76
|
} = getMediaDetails(media, currentPostId);
|
|
77
77
|
function onDropFiles(filesList) {
|
|
78
|
-
mediaUpload({
|
|
79
|
-
allowedTypes:
|
|
78
|
+
getSettings().mediaUpload({
|
|
79
|
+
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
80
80
|
filesList,
|
|
81
81
|
onFileChange([image]) {
|
|
82
82
|
if (isBlobURL(image?.url)) {
|
|
@@ -133,9 +133,6 @@ function PostFeaturedImage({
|
|
|
133
133
|
}, createElement(Button, {
|
|
134
134
|
className: "editor-post-featured-image__action",
|
|
135
135
|
onClick: open
|
|
136
|
-
// Prefer that screen readers use the .editor-post-featured-image__preview button.
|
|
137
|
-
,
|
|
138
|
-
"aria-hidden": "true"
|
|
139
136
|
}, __('Replace')), createElement(Button, {
|
|
140
137
|
className: "editor-post-featured-image__action",
|
|
141
138
|
onClick: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","applyFilters","DropZone","Button","Spinner","ResponsiveWrapper","withNotices","withFilters","__experimentalHStack","HStack","isBlobURL","useState","useRef","compose","useSelect","withDispatch","withSelect","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","createElement","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","toggleRef","isLoading","setIsLoading","mediaUpload","select","getSettings","onDropFiles","filesList","allowedTypes","onFileChange","image","url","onError","message","removeAllNotices","createErrorNotice","className","alt_text","full","file","slug","fallback","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","ref","onClick","naturalWidth","naturalHeight","isInline","src","alt","set_featured_image","current","focus","onFilesDrop","value","applyWithSelect","getMedia","getPostType","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","editPost","featured_media","onDropImage"],"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\tResponsiveWrapper,\n\twithNotices,\n\twithFilters,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState, useRef } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n} ) {\n\tconst toggleRef = useRef();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst mediaUpload = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).getSettings().mediaUpload;\n\t}, [] );\n\tconst { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails(\n\t\tmedia,\n\t\tcurrentPostId\n\t);\n\n\tfunction onDropFiles( filesList ) {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( image ) {\n\t\t\t\t\tonUpdateImage( image );\n\t\t\t\t}\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image filename.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tmedia.media_details.sizes?.full?.file ||\n\t\t\t\t\t\t\t\t\tmedia.slug\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tref={ toggleRef }\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Edit or replace the image' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t<ResponsiveWrapper\n\t\t\t\t\t\t\t\t\t\t\tnaturalWidth={ mediaWidth }\n\t\t\t\t\t\t\t\t\t\t\tnaturalHeight={ mediaHeight }\n\t\t\t\t\t\t\t\t\t\t\tisInline\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ResponsiveWrapper>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ isLoading && <Spinner /> }\n\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t( postType?.labels\n\t\t\t\t\t\t\t\t\t\t\t?.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t\t\t\t\t<HStack className=\"editor-post-featured-image__actions\">\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t\t// Prefer that screen readers use the .editor-post-featured-image__preview button.\n\t\t\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tonRemoveImage();\n\t\t\t\t\t\t\t\t\t\t\t\ttoggleRef.current.focus();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType } = select( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,iBAAiB,EACjBC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Y,EAAE,CAAE,OAAO,CAAE;QACzBD,SAAS;QACTE,YAAYA,CAAE,CAAEC,KAAK,CAAE,EAAG;UACzBwC,QAAQ,CAAE;YAAEC,cAAc,EAAEzC,KAAK,CAAC5B;UAAG,CAAE,CAAC;QACzC,CAAC;QACD8B,OAAOA,CAAEC,OAAO,EAAG;UAClBd,gBAAgB,CAACe,gBAAgB,CAAC,CAAC;UACnCf,gBAAgB,CAACgB,iBAAiB,CAAEF,OAAQ,CAAC;QAC9C;MACD,CAAE,CAAC;IACL,CAAC;IACDjB,aAAaA,CAAA,EAAG;MACfsD,QAAQ,CAAE;QAAEC,cAAc,EAAE;MAAE,CAAE,CAAC;IAClC;EACD,CAAC;AACF,CACD,CAAC;AAED,eAAe3F,OAAO,CACrBP,WAAW,EACXyF,eAAe,EACfM,iBAAiB,EACjB9F,WAAW,CAAE,0BAA2B,CACzC,CAAC,CAAEsC,iBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"names":["__","sprintf","applyFilters","DropZone","Button","Spinner","ResponsiveWrapper","withNotices","withFilters","__experimentalHStack","HStack","isBlobURL","useState","useRef","compose","useSelect","withDispatch","withSelect","MediaUpload","MediaUploadCheck","store","blockEditorStore","coreStore","PostFeaturedImageCheck","editorStore","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","createElement","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","toggleRef","isLoading","setIsLoading","getSettings","onDropFiles","filesList","mediaUpload","allowedTypes","onFileChange","image","url","onError","message","removeAllNotices","createErrorNotice","className","alt_text","full","file","slug","fallback","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","ref","onClick","naturalWidth","naturalHeight","isInline","src","alt","set_featured_image","current","focus","onFilesDrop","value","applyWithSelect","select","getMedia","getPostType","getCurrentPostId","getEditedPostAttribute","context","applyWithDispatch","dispatch","editPost","featured_media","onDropImage"],"sources":["@wordpress/editor/src/components/post-featured-image/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { applyFilters } from '@wordpress/hooks';\nimport {\n\tDropZone,\n\tButton,\n\tSpinner,\n\tResponsiveWrapper,\n\twithNotices,\n\twithFilters,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { isBlobURL } from '@wordpress/blob';\nimport { useState, useRef } from '@wordpress/element';\nimport { compose } from '@wordpress/compose';\nimport { useSelect, withDispatch, withSelect } from '@wordpress/data';\nimport {\n\tMediaUpload,\n\tMediaUploadCheck,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostFeaturedImageCheck from './check';\nimport { store as editorStore } from '../../store';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\n// Used when labels from post type were not yet loaded or when they are not present.\nconst DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );\nconst DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );\n\nconst instructions = (\n\t<p>\n\t\t{ __(\n\t\t\t'To edit the featured image, you need permission to upload media.'\n\t\t) }\n\t</p>\n);\n\nfunction getMediaDetails( media, postId ) {\n\tif ( ! media ) {\n\t\treturn {};\n\t}\n\n\tconst defaultSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'large',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( defaultSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ defaultSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ defaultSize ].height,\n\t\t\tmediaSourceUrl: media.media_details.sizes[ defaultSize ].source_url,\n\t\t};\n\t}\n\n\t// Use fallbackSize when defaultSize is not available.\n\tconst fallbackSize = applyFilters(\n\t\t'editor.PostFeaturedImage.imageSize',\n\t\t'thumbnail',\n\t\tmedia.id,\n\t\tpostId\n\t);\n\tif ( fallbackSize in ( media?.media_details?.sizes ?? {} ) ) {\n\t\treturn {\n\t\t\tmediaWidth: media.media_details.sizes[ fallbackSize ].width,\n\t\t\tmediaHeight: media.media_details.sizes[ fallbackSize ].height,\n\t\t\tmediaSourceUrl:\n\t\t\t\tmedia.media_details.sizes[ fallbackSize ].source_url,\n\t\t};\n\t}\n\n\t// Use full image size when fallbackSize and defaultSize are not available.\n\treturn {\n\t\tmediaWidth: media.media_details.width,\n\t\tmediaHeight: media.media_details.height,\n\t\tmediaSourceUrl: media.source_url,\n\t};\n}\n\nfunction PostFeaturedImage( {\n\tcurrentPostId,\n\tfeaturedImageId,\n\tonUpdateImage,\n\tonRemoveImage,\n\tmedia,\n\tpostType,\n\tnoticeUI,\n\tnoticeOperations,\n} ) {\n\tconst toggleRef = useRef();\n\tconst [ isLoading, setIsLoading ] = useState( false );\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst { mediaWidth, mediaHeight, mediaSourceUrl } = getMediaDetails(\n\t\tmedia,\n\t\tcurrentPostId\n\t);\n\n\tfunction onDropFiles( filesList ) {\n\t\tgetSettings().mediaUpload( {\n\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\tsetIsLoading( true );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( image ) {\n\t\t\t\t\tonUpdateImage( image );\n\t\t\t\t}\n\t\t\t\tsetIsLoading( false );\n\t\t\t},\n\t\t\tonError( message ) {\n\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t{ noticeUI }\n\t\t\t<div className=\"editor-post-featured-image\">\n\t\t\t\t{ media && (\n\t\t\t\t\t<div\n\t\t\t\t\t\tid={ `editor-post-featured-image-${ featuredImageId }-describedby` }\n\t\t\t\t\t\tclassName=\"hidden\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image alt text.\n\t\t\t\t\t\t\t\t__( 'Current image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! media.alt_text &&\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// Translators: %s: The selected image filename.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'The current image has no alternative text. The file name is: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tmedia.media_details.sizes?.full?.file ||\n\t\t\t\t\t\t\t\t\tmedia.slug\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<MediaUploadCheck fallback={ instructions }>\n\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\tpostType?.labels?.featured_image ||\n\t\t\t\t\t\t\tDEFAULT_FEATURE_IMAGE_LABEL\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={ onUpdateImage }\n\t\t\t\t\t\tunstableFeaturedImageFlow\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\tmodalClass=\"editor-post-featured-image__media-modal\"\n\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t<div className=\"editor-post-featured-image__container\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tref={ toggleRef }\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? 'editor-post-featured-image__toggle'\n\t\t\t\t\t\t\t\t\t\t\t: 'editor-post-featured-image__preview'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Edit or replace the image' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t! featuredImageId\n\t\t\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t\t\t: `editor-post-featured-image-${ featuredImageId }-describedby`\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ !! featuredImageId && media && (\n\t\t\t\t\t\t\t\t\t\t<ResponsiveWrapper\n\t\t\t\t\t\t\t\t\t\t\tnaturalWidth={ mediaWidth }\n\t\t\t\t\t\t\t\t\t\t\tnaturalHeight={ mediaHeight }\n\t\t\t\t\t\t\t\t\t\t\tisInline\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ mediaSourceUrl }\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</ResponsiveWrapper>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ isLoading && <Spinner /> }\n\t\t\t\t\t\t\t\t\t{ ! featuredImageId &&\n\t\t\t\t\t\t\t\t\t\t! isLoading &&\n\t\t\t\t\t\t\t\t\t\t( postType?.labels\n\t\t\t\t\t\t\t\t\t\t\t?.set_featured_image ||\n\t\t\t\t\t\t\t\t\t\t\tDEFAULT_SET_FEATURE_IMAGE_LABEL ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t{ !! featuredImageId && (\n\t\t\t\t\t\t\t\t\t<HStack className=\"editor-post-featured-image__actions\">\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"editor-post-featured-image__action\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tonRemoveImage();\n\t\t\t\t\t\t\t\t\t\t\t\ttoggleRef.current.focus();\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<DropZone onFilesDrop={ onDropFiles } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tvalue={ featuredImageId }\n\t\t\t\t\t/>\n\t\t\t\t</MediaUploadCheck>\n\t\t\t</div>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nconst applyWithSelect = withSelect( ( select ) => {\n\tconst { getMedia, getPostType } = select( coreStore );\n\tconst { getCurrentPostId, getEditedPostAttribute } = select( editorStore );\n\tconst featuredImageId = getEditedPostAttribute( 'featured_media' );\n\n\treturn {\n\t\tmedia: featuredImageId\n\t\t\t? getMedia( featuredImageId, { context: 'view' } )\n\t\t\t: null,\n\t\tcurrentPostId: getCurrentPostId(),\n\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\tfeaturedImageId,\n\t};\n} );\n\nconst applyWithDispatch = withDispatch(\n\t( dispatch, { noticeOperations }, { select } ) => {\n\t\tconst { editPost } = dispatch( editorStore );\n\t\treturn {\n\t\t\tonUpdateImage( image ) {\n\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t},\n\t\t\tonDropImage( filesList ) {\n\t\t\t\tselect( blockEditorStore )\n\t\t\t\t\t.getSettings()\n\t\t\t\t\t.mediaUpload( {\n\t\t\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t\t\t\tfilesList,\n\t\t\t\t\t\tonFileChange( [ image ] ) {\n\t\t\t\t\t\t\teditPost( { featured_media: image.id } );\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonError( message ) {\n\t\t\t\t\t\t\tnoticeOperations.removeAllNotices();\n\t\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tonRemoveImage() {\n\t\t\t\teditPost( { featured_media: 0 } );\n\t\t\t},\n\t\t};\n\t}\n);\n\nexport default compose(\n\twithNotices,\n\tapplyWithSelect,\n\tapplyWithDispatch,\n\twithFilters( 'editor.PostFeaturedImage' )\n)( PostFeaturedImage );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACCC,QAAQ,EACRC,MAAM,EACNC,OAAO,EACPC,iBAAiB,EACjBC,WAAW,EACXC,WAAW,EACXC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,QAAQ,EAAEC,MAAM,QAAQ,oBAAoB;AACrD,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,EAAEC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AACrE,SACCC,WAAW,EACXC,g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,CAAE;QAAEC,cAAc,EAAE;MAAE,CAAE,CAAC;IAClC;EACD,CAAC;AACF,CACD,CAAC;AAED,eAAe3F,OAAO,CACrBP,WAAW,EACXwF,eAAe,EACfO,iBAAiB,EACjB9F,WAAW,CAAE,0BAA2B,CACzC,CAAC,CAAEsC,iBAAkB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { PanelBody } from '@wordpress/components';
|
|
7
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { store as editorStore } from '../../store';
|
|
14
|
+
import PostFeaturedImage from './index';
|
|
15
|
+
import PostFeaturedImageCheck from './check';
|
|
16
|
+
const PANEL_NAME = 'featured-image';
|
|
17
|
+
function FeaturedImage() {
|
|
18
|
+
var _postType$labels$feat;
|
|
19
|
+
const {
|
|
20
|
+
postType,
|
|
21
|
+
isEnabled,
|
|
22
|
+
isOpened
|
|
23
|
+
} = useSelect(select => {
|
|
24
|
+
const {
|
|
25
|
+
getEditedPostAttribute,
|
|
26
|
+
isEditorPanelEnabled,
|
|
27
|
+
isEditorPanelOpened
|
|
28
|
+
} = select(editorStore);
|
|
29
|
+
const {
|
|
30
|
+
getPostType
|
|
31
|
+
} = select(coreStore);
|
|
32
|
+
return {
|
|
33
|
+
postType: getPostType(getEditedPostAttribute('type')),
|
|
34
|
+
isEnabled: isEditorPanelEnabled(PANEL_NAME),
|
|
35
|
+
isOpened: isEditorPanelOpened(PANEL_NAME)
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
const {
|
|
39
|
+
toggleEditorPanelOpened
|
|
40
|
+
} = useDispatch(editorStore);
|
|
41
|
+
if (!isEnabled) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return createElement(PostFeaturedImageCheck, null, createElement(PanelBody, {
|
|
45
|
+
title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : __('Featured image'),
|
|
46
|
+
opened: isOpened,
|
|
47
|
+
onToggle: () => toggleEditorPanelOpened(PANEL_NAME)
|
|
48
|
+
}, createElement(PostFeaturedImage, null)));
|
|
49
|
+
}
|
|
50
|
+
export default FeaturedImage;
|
|
51
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__","PanelBody","useSelect","useDispatch","store","coreStore","editorStore","PostFeaturedImage","PostFeaturedImageCheck","PANEL_NAME","FeaturedImage","_postType$labels$feat","postType","isEnabled","isOpened","select","getEditedPostAttribute","isEditorPanelEnabled","isEditorPanelOpened","getPostType","toggleEditorPanelOpened","createElement","title","labels","featured_image","opened","onToggle"],"sources":["@wordpress/editor/src/components/post-featured-image/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostFeaturedImage from './index';\nimport PostFeaturedImageCheck from './check';\n\nconst PANEL_NAME = 'featured-image';\n\nfunction FeaturedImage() {\n\tconst { postType, isEnabled, isOpened } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetEditedPostAttribute,\n\t\t\tisEditorPanelEnabled,\n\t\t\tisEditorPanelOpened,\n\t\t} = select( editorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\tpostType: getPostType( getEditedPostAttribute( 'type' ) ),\n\t\t\tisEnabled: isEditorPanelEnabled( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t};\n\t}, [] );\n\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostFeaturedImageCheck>\n\t\t\t<PanelBody\n\t\t\t\ttitle={\n\t\t\t\t\tpostType?.labels?.featured_image ?? __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }\n\t\t\t>\n\t\t\t\t<PostFeaturedImage />\n\t\t\t</PanelBody>\n\t\t</PostFeaturedImageCheck>\n\t);\n}\n\nexport default FeaturedImage;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,OAAOC,iBAAiB,MAAM,SAAS;AACvC,OAAOC,sBAAsB,MAAM,SAAS;AAE5C,MAAMC,UAAU,GAAG,gBAAgB;AAEnC,SAASC,aAAaA,CAAA,EAAG;EAAA,IAAAC,qBAAA;EACxB,MAAM;IAAEC,QAAQ;IAAEC,SAAS;IAAEC;EAAS,CAAC,GAAGZ,SAAS,CAAIa,MAAM,IAAM;IAClE,MAAM;MACLC,sBAAsB;MACtBC,oBAAoB;MACpBC;IACD,CAAC,GAAGH,MAAM,CAAET,WAAY,CAAC;IACzB,MAAM;MAAEa;IAAY,CAAC,GAAGJ,MAAM,CAAEV,SAAU,CAAC;IAE3C,OAAO;MACNO,QAAQ,EAAEO,WAAW,CAAEH,sBAAsB,CAAE,MAAO,CAAE,CAAC;MACzDH,SAAS,EAAEI,oBAAoB,CAAER,UAAW,CAAC;MAC7CK,QAAQ,EAAEI,mBAAmB,CAAET,UAAW;IAC3C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAEW;EAAwB,CAAC,GAAGjB,WAAW,CAAEG,WAAY,CAAC;EAE9D,IAAK,CAAEO,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OACCQ,aAAA,CAACb,sBAAsB,QACtBa,aAAA,CAACpB,SAAS;IACTqB,KAAK,GAAAX,qBAAA,GACJC,QAAQ,EAAEW,MAAM,EAAEC,cAAc,cAAAb,qBAAA,cAAAA,qBAAA,GAAIX,EAAE,CAAE,gBAAiB,CACzD;IACDyB,MAAM,EAAGX,QAAU;IACnBY,QAAQ,EAAGA,CAAA,KAAMN,uBAAuB,CAAEX,UAAW;EAAG,GAExDY,aAAA,CAACd,iBAAiB,MAAE,CACV,CACY,CAAC;AAE3B;AAEA,eAAeG,aAAa"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { PanelBody } from '@wordpress/components';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import PostLastRevision from './';
|
|
11
|
+
import PostLastRevisionCheck from './check';
|
|
12
|
+
function PostLastRevisionPanel() {
|
|
13
|
+
return createElement(PostLastRevisionCheck, null, createElement(PanelBody, {
|
|
14
|
+
className: "editor-post-last-revision__panel"
|
|
15
|
+
}, createElement(PostLastRevision, null)));
|
|
16
|
+
}
|
|
17
|
+
export default PostLastRevisionPanel;
|
|
18
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PanelBody","PostLastRevision","PostLastRevisionCheck","PostLastRevisionPanel","createElement","className"],"sources":["@wordpress/editor/src/components/post-last-revision/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport PostLastRevision from './';\nimport PostLastRevisionCheck from './check';\n\nfunction PostLastRevisionPanel() {\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PanelBody className=\"editor-post-last-revision__panel\">\n\t\t\t\t<PostLastRevision />\n\t\t\t</PanelBody>\n\t\t</PostLastRevisionCheck>\n\t);\n}\n\nexport default PostLastRevisionPanel;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,uBAAuB;;AAEjD;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,IAAI;AACjC,OAAOC,qBAAqB,MAAM,SAAS;AAE3C,SAASC,qBAAqBA,CAAA,EAAG;EAChC,OACCC,aAAA,CAACF,qBAAqB,QACrBE,aAAA,CAACJ,SAAS;IAACK,SAAS,EAAC;EAAkC,GACtDD,aAAA,CAACH,gBAAgB,MAAE,CACT,CACW,CAAC;AAE1B;AAEA,eAAeE,qBAAqB"}
|
|
@@ -14,6 +14,7 @@ import { useEffect, useState } from '@wordpress/element';
|
|
|
14
14
|
import { __ } from '@wordpress/i18n';
|
|
15
15
|
import { Icon, check, cloud, cloudUpload } from '@wordpress/icons';
|
|
16
16
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
17
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
@@ -24,15 +25,13 @@ import { store as editorStore } from '../../store';
|
|
|
24
25
|
* Component showing whether the post is saved or not and providing save
|
|
25
26
|
* buttons.
|
|
26
27
|
*
|
|
27
|
-
* @param {Object} props
|
|
28
|
-
* @param {?boolean} props.forceIsDirty
|
|
29
|
-
*
|
|
30
|
-
* @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons
|
|
28
|
+
* @param {Object} props Component props.
|
|
29
|
+
* @param {?boolean} props.forceIsDirty Whether to force the post to be marked
|
|
30
|
+
* as dirty.
|
|
31
31
|
* @return {import('react').ComponentType} The component.
|
|
32
32
|
*/
|
|
33
33
|
export default function PostSavedState({
|
|
34
|
-
forceIsDirty
|
|
35
|
-
showIconLabels = false
|
|
34
|
+
forceIsDirty
|
|
36
35
|
}) {
|
|
37
36
|
const [forceSavedMessage, setForceSavedMessage] = useState(false);
|
|
38
37
|
const isLargeViewport = useViewportMatch('small');
|
|
@@ -45,7 +44,8 @@ export default function PostSavedState({
|
|
|
45
44
|
isSaveable,
|
|
46
45
|
isSaving,
|
|
47
46
|
isScheduled,
|
|
48
|
-
hasPublishAction
|
|
47
|
+
hasPublishAction,
|
|
48
|
+
showIconLabels
|
|
49
49
|
} = useSelect(select => {
|
|
50
50
|
var _getCurrentPost$_link;
|
|
51
51
|
const {
|
|
@@ -59,6 +59,9 @@ export default function PostSavedState({
|
|
|
59
59
|
isAutosavingPost,
|
|
60
60
|
getEditedPostAttribute
|
|
61
61
|
} = select(editorStore);
|
|
62
|
+
const {
|
|
63
|
+
get
|
|
64
|
+
} = select(preferencesStore);
|
|
62
65
|
return {
|
|
63
66
|
isAutosaving: isAutosavingPost(),
|
|
64
67
|
isDirty: forceIsDirty || isEditedPostDirty(),
|
|
@@ -68,7 +71,8 @@ export default function PostSavedState({
|
|
|
68
71
|
isSaving: isSavingPost(),
|
|
69
72
|
isSaveable: isEditedPostSaveable(),
|
|
70
73
|
isScheduled: isCurrentPostScheduled(),
|
|
71
|
-
hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
|
|
74
|
+
hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
|
|
75
|
+
showIconLabels: get('core', 'showIconLabels')
|
|
72
76
|
};
|
|
73
77
|
}, [forceIsDirty]);
|
|
74
78
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__unstableGetAnimateClassName","getAnimateClassName","Button","Tooltip","usePrevious","useViewportMatch","useDispatch","useSelect","useEffect","useState","__","Icon","check","cloud","cloudUpload","displayShortcut","store","editorStore","PostSavedState","forceIsDirty","showIconLabels","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","select","_getCurrentPost$_link","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","buttonAccessibleLabel","tooltipProps","undefined","shortcut","primary","createElement","className","type","onClick","variant","size","icon"],"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n\tTooltip,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons\n * @return {import('react').ComponentType} The component.\n */\nexport default function PostSavedState( {\n\tforceIsDirty,\n\tshowIconLabels = false,\n} ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPending,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t} = select( editorStore );\n\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPending: 'pending' === getEditedPostAttribute( 'status' ),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty ]\n\t);\n\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\tif ( isPublished || isScheduled ) {\n\t\treturn null;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\tconst buttonAccessibleLabel = text || label;\n\n\t/**\n\t * The tooltip needs to be enabled only if the button is not disabled. When\n\t * relying on the internal Button tooltip functionality, this causes the\n\t * resulting `button` element to be always removed and re-added to the DOM,\n\t * causing focus loss. An alternative approach to circumvent the issue\n\t * is not to use the `label` and `shortcut` props on `Button` (which would\n\t * trigger the tooltip), and instead manually wrap the `Button` in a separate\n\t * `Tooltip` component.\n\t */\n\tconst tooltipProps = isDisabled\n\t\t? undefined\n\t\t: {\n\t\t\t\ttext: buttonAccessibleLabel,\n\t\t\t\tshortcut: displayShortcut.primary( 's' ),\n\t\t };\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Tooltip { ...tooltipProps }>\n\t\t\t<Button\n\t\t\t\tclassName={\n\t\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t\t? classnames( {\n\t\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t\t } )\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\t\t// Make sure the aria-label has always a value, as the default `text` is undefined on small screens.\n\t\t\t\taria-label={ buttonAccessibleLabel }\n\t\t\t\taria-disabled={ isDisabled }\n\t\t\t>\n\t\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t\t{ text }\n\t\t\t</Button>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,6BAA6B,IAAIC,mBAAmB,EACpDC,MAAM,EACNC,OAAO,QACD,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,gBAAgB,QAAQ,oBAAoB;AAClE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,KAAK,EAAEC,KAAK,EAAEC,WAAW,QAAQ,kBAAkB;AAClE,SAASC,eAAe,QAAQ,qBAAqB;;AAErD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAAE;EACvCC,YAAY;EACZC,cAAc,GAAG;AAClB,CAAC,EAAG;EACH,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGb,QAAQ,CAAE,KAAM,CAAC;EACrE,MAAMc,eAAe,GAAGlB,gBAAgB,CAAE,OAAQ,CAAC;EAEnD,MAAM;IACLmB,YAAY;IACZC,OAAO;IACPC,KAAK;IACLC,SAAS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A,GAAMsD;EAAY,GACzBI,aAAA,CAAC3D,MAAM;IACN4D,SAAS,EACRjC,UAAU,IAAIC,QAAQ,GACnB/B,UAAU,CAAE;MACZ,wBAAwB,EAAE,CAAEsD,YAAY;MACxC,yBAAyB,EAAEA,YAAY;MACvC,WAAW,EAAEvB,QAAQ;MACrB,eAAe,EAAEN,YAAY;MAC7B,UAAU,EAAE4B,OAAO;MACnB,CAAEnD,mBAAmB,CAAE;QACtB8D,IAAI,EAAE;MACP,CAAE,CAAC,GAAIjC;IACP,CAAE,CAAC,GACH4B,SACH;IACDM,OAAO,EAAGV,UAAU,GAAGI,SAAS,GAAG,MAAMb,QAAQ,CAAC,CAAG;IACrDoB,OAAO,EAAC,UAAU;IAClBC,IAAI,EAAC,SAAS;IACdC,IAAI,EAAG5C,eAAe,GAAGmC,SAAS,GAAG5C;IACrC;IAAA;IACA,cAAa0C,qBAAuB;IACpC,iBAAgBF;EAAY,GAE1BD,YAAY,IAAIQ,aAAA,CAAClD,IAAI;IAACwD,IAAI,EAAGf,OAAO,GAAGxC,KAAK,GAAGC;EAAO,CAAE,CAAC,EACzD0C,IACK,CACA,CAAC;AAEZ"}
|
|
1
|
+
{"version":3,"names":["classnames","__unstableGetAnimateClassName","getAnimateClassName","Button","Tooltip","usePrevious","useViewportMatch","useDispatch","useSelect","useEffect","useState","__","Icon","check","cloud","cloudUpload","displayShortcut","store","preferencesStore","editorStore","PostSavedState","forceIsDirty","forceSavedMessage","setForceSavedMessage","isLargeViewport","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","showIconLabels","select","_getCurrentPost$_link","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","get","_links","savePost","wasSaving","timeoutId","setTimeout","clearTimeout","label","shortLabel","isSaved","isSavedState","isDisabled","text","buttonAccessibleLabel","tooltipProps","undefined","shortcut","primary","createElement","className","type","onClick","variant","size","icon"],"sources":["@wordpress/editor/src/components/post-saved-state/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__unstableGetAnimateClassName as getAnimateClassName,\n\tButton,\n\tTooltip,\n} from '@wordpress/components';\nimport { usePrevious, useViewportMatch } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, check, cloud, cloudUpload } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component showing whether the post is saved or not and providing save\n * buttons.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.forceIsDirty Whether to force the post to be marked\n * as dirty.\n * @return {import('react').ComponentType} The component.\n */\nexport default function PostSavedState( { forceIsDirty } ) {\n\tconst [ forceSavedMessage, setForceSavedMessage ] = useState( false );\n\tconst isLargeViewport = useViewportMatch( 'small' );\n\n\tconst {\n\t\tisAutosaving,\n\t\tisDirty,\n\t\tisNew,\n\t\tisPending,\n\t\tisPublished,\n\t\tisSaveable,\n\t\tisSaving,\n\t\tisScheduled,\n\t\thasPublishAction,\n\t\tshowIconLabels,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisEditedPostNew,\n\t\t\t\tisCurrentPostPublished,\n\t\t\t\tisCurrentPostScheduled,\n\t\t\t\tisEditedPostDirty,\n\t\t\t\tisSavingPost,\n\t\t\t\tisEditedPostSaveable,\n\t\t\t\tgetCurrentPost,\n\t\t\t\tisAutosavingPost,\n\t\t\t\tgetEditedPostAttribute,\n\t\t\t} = select( editorStore );\n\t\t\tconst { get } = select( preferencesStore );\n\n\t\t\treturn {\n\t\t\t\tisAutosaving: isAutosavingPost(),\n\t\t\t\tisDirty: forceIsDirty || isEditedPostDirty(),\n\t\t\t\tisNew: isEditedPostNew(),\n\t\t\t\tisPending: 'pending' === getEditedPostAttribute( 'status' ),\n\t\t\t\tisPublished: isCurrentPostPublished(),\n\t\t\t\tisSaving: isSavingPost(),\n\t\t\t\tisSaveable: isEditedPostSaveable(),\n\t\t\t\tisScheduled: isCurrentPostScheduled(),\n\t\t\t\thasPublishAction:\n\t\t\t\t\tgetCurrentPost()?._links?.[ 'wp:action-publish' ] ?? false,\n\t\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\t};\n\t\t},\n\t\t[ forceIsDirty ]\n\t);\n\n\tconst { savePost } = useDispatch( editorStore );\n\n\tconst wasSaving = usePrevious( isSaving );\n\n\tuseEffect( () => {\n\t\tlet timeoutId;\n\n\t\tif ( wasSaving && ! isSaving ) {\n\t\t\tsetForceSavedMessage( true );\n\t\t\ttimeoutId = setTimeout( () => {\n\t\t\t\tsetForceSavedMessage( false );\n\t\t\t}, 1000 );\n\t\t}\n\n\t\treturn () => clearTimeout( timeoutId );\n\t}, [ isSaving ] );\n\n\t// Once the post has been submitted for review this button\n\t// is not needed for the contributor role.\n\tif ( ! hasPublishAction && isPending ) {\n\t\treturn null;\n\t}\n\n\tif ( isPublished || isScheduled ) {\n\t\treturn null;\n\t}\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst shortLabel = __( 'Save' );\n\n\tconst isSaved = forceSavedMessage || ( ! isNew && ! isDirty );\n\tconst isSavedState = isSaving || isSaved;\n\tconst isDisabled = isSaving || isSaved || ! isSaveable;\n\n\tlet text;\n\n\tif ( isSaving ) {\n\t\ttext = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );\n\t} else if ( isSaved ) {\n\t\ttext = __( 'Saved' );\n\t} else if ( isLargeViewport ) {\n\t\ttext = label;\n\t} else if ( showIconLabels ) {\n\t\ttext = shortLabel;\n\t}\n\n\tconst buttonAccessibleLabel = text || label;\n\n\t/**\n\t * The tooltip needs to be enabled only if the button is not disabled. When\n\t * relying on the internal Button tooltip functionality, this causes the\n\t * resulting `button` element to be always removed and re-added to the DOM,\n\t * causing focus loss. An alternative approach to circumvent the issue\n\t * is not to use the `label` and `shortcut` props on `Button` (which would\n\t * trigger the tooltip), and instead manually wrap the `Button` in a separate\n\t * `Tooltip` component.\n\t */\n\tconst tooltipProps = isDisabled\n\t\t? undefined\n\t\t: {\n\t\t\t\ttext: buttonAccessibleLabel,\n\t\t\t\tshortcut: displayShortcut.primary( 's' ),\n\t\t };\n\n\t// Use common Button instance for all saved states so that focus is not\n\t// lost.\n\treturn (\n\t\t<Tooltip { ...tooltipProps }>\n\t\t\t<Button\n\t\t\t\tclassName={\n\t\t\t\t\tisSaveable || isSaving\n\t\t\t\t\t\t? classnames( {\n\t\t\t\t\t\t\t\t'editor-post-save-draft': ! isSavedState,\n\t\t\t\t\t\t\t\t'editor-post-saved-state': isSavedState,\n\t\t\t\t\t\t\t\t'is-saving': isSaving,\n\t\t\t\t\t\t\t\t'is-autosaving': isAutosaving,\n\t\t\t\t\t\t\t\t'is-saved': isSaved,\n\t\t\t\t\t\t\t\t[ getAnimateClassName( {\n\t\t\t\t\t\t\t\t\ttype: 'loading',\n\t\t\t\t\t\t\t\t} ) ]: isSaving,\n\t\t\t\t\t\t } )\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tonClick={ isDisabled ? undefined : () => savePost() }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ isLargeViewport ? undefined : cloudUpload }\n\t\t\t\t// Make sure the aria-label has always a value, as the default `text` is undefined on small screens.\n\t\t\t\taria-label={ buttonAccessibleLabel }\n\t\t\t\taria-disabled={ isDisabled }\n\t\t\t>\n\t\t\t\t{ isSavedState && <Icon icon={ isSaved ? check : cloud } /> }\n\t\t\t\t{ text }\n\t\t\t</Button>\n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AY;MAC7B,UAAU,EAAE8B,OAAO;MACnB,CAAErD,mBAAmB,CAAE;QACtBgE,IAAI,EAAE;MACP,CAAE,CAAC,GAAInC;IACP,CAAE,CAAC,GACH8B,SACH;IACDM,OAAO,EAAGV,UAAU,GAAGI,SAAS,GAAG,MAAMb,QAAQ,CAAC,CAAG;IACrDoB,OAAO,EAAC,UAAU;IAClBC,IAAI,EAAC,SAAS;IACdC,IAAI,EAAG9C,eAAe,GAAGqC,SAAS,GAAG9C;IACrC;IAAA;IACA,cAAa4C,qBAAuB;IACpC,iBAAgBF;EAAY,GAE1BD,YAAY,IAAIQ,aAAA,CAACpD,IAAI;IAAC0D,IAAI,EAAGf,OAAO,GAAG1C,KAAK,GAAGC;EAAO,CAAE,CAAC,EACzD4C,IACK,CACA,CAAC;AAEZ"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { PanelBody } from '@wordpress/components';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as editorStore } from '../../store';
|
|
12
|
+
import PostTaxonomiesForm from './index';
|
|
13
|
+
import PostTaxonomiesCheck from './check';
|
|
14
|
+
function TaxonomyPanel({
|
|
15
|
+
taxonomy,
|
|
16
|
+
children
|
|
17
|
+
}) {
|
|
18
|
+
const slug = taxonomy?.slug;
|
|
19
|
+
const panelName = slug ? `taxonomy-panel-${slug}` : '';
|
|
20
|
+
const {
|
|
21
|
+
isEnabled,
|
|
22
|
+
isOpened
|
|
23
|
+
} = useSelect(select => {
|
|
24
|
+
const {
|
|
25
|
+
isEditorPanelEnabled,
|
|
26
|
+
isEditorPanelOpened
|
|
27
|
+
} = select(editorStore);
|
|
28
|
+
return {
|
|
29
|
+
isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
|
|
30
|
+
isOpened: slug ? isEditorPanelOpened(panelName) : false
|
|
31
|
+
};
|
|
32
|
+
}, [panelName, slug]);
|
|
33
|
+
const {
|
|
34
|
+
toggleEditorPanelOpened
|
|
35
|
+
} = useDispatch(editorStore);
|
|
36
|
+
if (!isEnabled) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const taxonomyMenuName = taxonomy?.labels?.menu_name;
|
|
40
|
+
if (!taxonomyMenuName) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return createElement(PanelBody, {
|
|
44
|
+
title: taxonomyMenuName,
|
|
45
|
+
opened: isOpened,
|
|
46
|
+
onToggle: () => toggleEditorPanelOpened(panelName)
|
|
47
|
+
}, children);
|
|
48
|
+
}
|
|
49
|
+
function PostTaxonomies() {
|
|
50
|
+
return createElement(PostTaxonomiesCheck, null, createElement(PostTaxonomiesForm, {
|
|
51
|
+
taxonomyWrapper: (content, taxonomy) => {
|
|
52
|
+
return createElement(TaxonomyPanel, {
|
|
53
|
+
taxonomy: taxonomy
|
|
54
|
+
}, content);
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
export default PostTaxonomies;
|
|
59
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PanelBody","useSelect","useDispatch","store","editorStore","PostTaxonomiesForm","PostTaxonomiesCheck","TaxonomyPanel","taxonomy","children","slug","panelName","isEnabled","isOpened","select","isEditorPanelEnabled","isEditorPanelOpened","toggleEditorPanelOpened","taxonomyMenuName","labels","menu_name","createElement","title","opened","onToggle","PostTaxonomies","taxonomyWrapper","content"],"sources":["@wordpress/editor/src/components/post-taxonomies/panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostTaxonomiesForm from './index';\nimport PostTaxonomiesCheck from './check';\n\nfunction TaxonomyPanel( { taxonomy, children } ) {\n\tconst slug = taxonomy?.slug;\n\tconst panelName = slug ? `taxonomy-panel-${ slug }` : '';\n\tconst { isEnabled, isOpened } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorPanelEnabled, isEditorPanelOpened } =\n\t\t\t\tselect( editorStore );\n\t\t\treturn {\n\t\t\t\tisEnabled: slug ? isEditorPanelEnabled( panelName ) : false,\n\t\t\t\tisOpened: slug ? isEditorPanelOpened( panelName ) : false,\n\t\t\t};\n\t\t},\n\t\t[ panelName, slug ]\n\t);\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst taxonomyMenuName = taxonomy?.labels?.menu_name;\n\tif ( ! taxonomyMenuName ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody\n\t\t\ttitle={ taxonomyMenuName }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ () => toggleEditorPanelOpened( panelName ) }\n\t\t>\n\t\t\t{ children }\n\t\t</PanelBody>\n\t);\n}\n\nfunction PostTaxonomies() {\n\treturn (\n\t\t<PostTaxonomiesCheck>\n\t\t\t<PostTaxonomiesForm\n\t\t\t\ttaxonomyWrapper={ ( content, taxonomy ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TaxonomyPanel taxonomy={ taxonomy }>\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</TaxonomyPanel>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t</PostTaxonomiesCheck>\n\t);\n}\n\nexport default PostTaxonomies;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,aAAa;AAClD,OAAOC,kBAAk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