@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,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = PostExcerptPanel;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _i18n = require("@wordpress/i18n");
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
var _data = require("@wordpress/data");
|
|
12
|
+
var _index = _interopRequireDefault(require("./index"));
|
|
13
|
+
var _check = _interopRequireDefault(require("./check"));
|
|
14
|
+
var _plugin = _interopRequireDefault(require("./plugin"));
|
|
15
|
+
var _store = require("../../store");
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Module Constants
|
|
26
|
+
*/
|
|
27
|
+
const PANEL_NAME = 'post-excerpt';
|
|
28
|
+
function PostExcerptPanel() {
|
|
29
|
+
const {
|
|
30
|
+
isOpened,
|
|
31
|
+
isEnabled
|
|
32
|
+
} = (0, _data.useSelect)(select => {
|
|
33
|
+
const {
|
|
34
|
+
isEditorPanelOpened,
|
|
35
|
+
isEditorPanelEnabled
|
|
36
|
+
} = select(_store.store);
|
|
37
|
+
return {
|
|
38
|
+
isOpened: isEditorPanelOpened(PANEL_NAME),
|
|
39
|
+
isEnabled: isEditorPanelEnabled(PANEL_NAME)
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
const {
|
|
43
|
+
toggleEditorPanelOpened
|
|
44
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
45
|
+
const toggleExcerptPanel = () => toggleEditorPanelOpened(PANEL_NAME);
|
|
46
|
+
if (!isEnabled) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return (0, _react.createElement)(_check.default, null, (0, _react.createElement)(_components.PanelBody, {
|
|
50
|
+
title: (0, _i18n.__)('Excerpt'),
|
|
51
|
+
opened: isOpened,
|
|
52
|
+
onToggle: toggleExcerptPanel
|
|
53
|
+
}, (0, _react.createElement)(_plugin.default.Slot, null, fills => (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_index.default, null), fills))));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_data","_index","_interopRequireDefault","_check","_plugin","_store","PANEL_NAME","PostExcerptPanel","isOpened","isEnabled","useSelect","select","isEditorPanelOpened","isEditorPanelEnabled","editorStore","toggleEditorPanelOpened","useDispatch","toggleExcerptPanel","_react","createElement","default","PanelBody","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={ isOpened }\n\t\t\t\tonToggle={ toggleExcerptPanel }\n\t\t\t>\n\t\t\t\t<PluginPostExcerpt.Slot>\n\t\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<PostExcerptForm />\n\t\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PluginPostExcerpt.Slot>\n\t\t\t</PanelBody>\n\t\t</PostExcerptCheck>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,OAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAbA;AACA;AACA;;AAKA;AACA;AACA;;AAMA;AACA;AACA;AACA,MAAMQ,UAAU,GAAG,cAAc;AAElB,SAASC,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACxD,MAAM;MAAEC,mBAAmB;MAAEC;IAAqB,CAAC,GAClDF,MAAM,CAAEG,YAAY,CAAC;IAEtB,OAAO;MACNN,QAAQ,EAAEI,mBAAmB,CAAEN,UAAW,CAAC;MAC3CG,SAAS,EAAEI,oBAAoB,CAAEP,UAAW;IAC7C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAM;IAAES;EAAwB,CAAC,GAAG,IAAAC,iBAAW,EAAEF,YAAY,CAAC;EAC9D,MAAMG,kBAAkB,GAAGA,CAAA,KAAMF,uBAAuB,CAAET,UAAW,CAAC;EAEtE,IAAK,CAAEG,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,OACC,IAAAS,MAAA,CAAAC,aAAA,EAAChB,MAAA,CAAAiB,OAAgB,QAChB,IAAAF,MAAA,CAAAC,aAAA,EAACpB,WAAA,CAAAsB,SAAS;IACTC,KAAK,EAAG,IAAAC,QAAE,EAAE,SAAU,CAAG;IACzBC,MAAM,EAAGhB,QAAU;IACnBiB,QAAQ,EAAGR;EAAoB,GAE/B,IAAAC,MAAA,CAAAC,aAAA,EAACf,OAAA,CAAAgB,OAAiB,CAACM,IAAI,QAClBC,KAAK,IACR,IAAAT,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAU,QAAA,QACC,IAAAV,MAAA,CAAAC,aAAA,EAAClB,MAAA,CAAAmB,OAAe,MAAE,CAAC,EACjBO,KACD,CAEoB,CACd,CACM,CAAC;AAErB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _components = require("@wordpress/components");
|
|
9
|
+
/**
|
|
10
|
+
* Defines as extensibility slot for the Excerpt panel.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* WordPress dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
Fill,
|
|
19
|
+
Slot
|
|
20
|
+
} = (0, _components.createSlotFill)('PluginPostExcerpt');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Renders a post excerpt panel in the post sidebar.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} props Component properties.
|
|
26
|
+
* @param {string} [props.className] An optional class name added to the row.
|
|
27
|
+
* @param {Element} props.children Children to be rendered.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```js
|
|
31
|
+
* // Using ES5 syntax
|
|
32
|
+
* var __ = wp.i18n.__;
|
|
33
|
+
* var PluginPostExcerpt = wp.editPost.PluginPostExcerpt;
|
|
34
|
+
*
|
|
35
|
+
* function MyPluginPostExcerpt() {
|
|
36
|
+
* return React.createElement(
|
|
37
|
+
* PluginPostExcerpt,
|
|
38
|
+
* {
|
|
39
|
+
* className: 'my-plugin-post-excerpt',
|
|
40
|
+
* },
|
|
41
|
+
* __( 'Post excerpt custom content' )
|
|
42
|
+
* )
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```jsx
|
|
48
|
+
* // Using ESNext syntax
|
|
49
|
+
* import { __ } from '@wordpress/i18n';
|
|
50
|
+
* import { PluginPostExcerpt } from '@wordpress/edit-post';
|
|
51
|
+
*
|
|
52
|
+
* const MyPluginPostExcerpt = () => (
|
|
53
|
+
* <PluginPostExcerpt className="my-plugin-post-excerpt">
|
|
54
|
+
* { __( 'Post excerpt custom content' ) }
|
|
55
|
+
* </PluginPostExcerpt>
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @return {Component} The component to be rendered.
|
|
60
|
+
*/
|
|
61
|
+
const PluginPostExcerpt = ({
|
|
62
|
+
children,
|
|
63
|
+
className
|
|
64
|
+
}) => {
|
|
65
|
+
return (0, _react.createElement)(Fill, null, (0, _react.createElement)(_components.PanelRow, {
|
|
66
|
+
className: className
|
|
67
|
+
}, children));
|
|
68
|
+
};
|
|
69
|
+
PluginPostExcerpt.Slot = Slot;
|
|
70
|
+
var _default = PluginPostExcerpt;
|
|
71
|
+
exports.default = _default;
|
|
72
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","Fill","Slot","createSlotFill","PluginPostExcerpt","children","className","_react","createElement","PanelRow","_default","exports","default"],"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":";;;;;;;AAOA,IAAAA,WAAA,GAAAC,OAAA;AAPA;AACA;AACA;;AAEA;AACA;AACA;;AAGA,MAAM;EAAEC,IAAI;EAAEC;AAAK,CAAC,GAAG,IAAAC,0BAAc,EAAE,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,MAAMC,iBAAiB,GAAGA,CAAE;EAAEC,QAAQ;EAAEC;AAAU,CAAC,KAAM;EACxD,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACP,IAAI,QACJ,IAAAM,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAU,QAAQ;IAACH,SAAS,EAAGA;EAAW,GAAGD,QAAoB,CACnD,CAAC;AAET,CAAC;AAEDD,iBAAiB,CAACF,IAAI,GAAGA,IAAI;AAAC,IAAAQ,QAAA,GAEfN,iBAAiB;AAAAO,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -74,17 +74,17 @@ function PostFeaturedImage({
|
|
|
74
74
|
}) {
|
|
75
75
|
const toggleRef = (0, _element.useRef)();
|
|
76
76
|
const [isLoading, setIsLoading] = (0, _element.useState)(false);
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
},
|
|
77
|
+
const {
|
|
78
|
+
getSettings
|
|
79
|
+
} = (0, _data.useSelect)(_blockEditor.store);
|
|
80
80
|
const {
|
|
81
81
|
mediaWidth,
|
|
82
82
|
mediaHeight,
|
|
83
83
|
mediaSourceUrl
|
|
84
84
|
} = getMediaDetails(media, currentPostId);
|
|
85
85
|
function onDropFiles(filesList) {
|
|
86
|
-
mediaUpload({
|
|
87
|
-
allowedTypes:
|
|
86
|
+
getSettings().mediaUpload({
|
|
87
|
+
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
88
88
|
filesList,
|
|
89
89
|
onFileChange([image]) {
|
|
90
90
|
if ((0, _blob.isBlobURL)(image?.url)) {
|
|
@@ -141,9 +141,6 @@ function PostFeaturedImage({
|
|
|
141
141
|
}, (0, _react.createElement)(_components.Button, {
|
|
142
142
|
className: "editor-post-featured-image__action",
|
|
143
143
|
onClick: open
|
|
144
|
-
// Prefer that screen readers use the .editor-post-featured-image__preview button.
|
|
145
|
-
,
|
|
146
|
-
"aria-hidden": "true"
|
|
147
144
|
}, (0, _i18n.__)('Replace')), (0, _react.createElement)(_components.Button, {
|
|
148
145
|
className: "editor-post-featured-image__action",
|
|
149
146
|
onClick: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_hooks","_components","_blob","_element","_compose","_data","_blockEditor","_coreData","_check","_interopRequireDefault","_store","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","__","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","_react","createElement","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","applyFilters","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","toggleRef","useRef","isLoading","setIsLoading","useState","mediaUpload","useSelect","select","blockEditorStore","getSettings","onDropFiles","filesList","allowedTypes","onFileChange","image","isBlobURL","url","onError","message","removeAllNotices","createErrorNotice","default","className","alt_text","sprintf","full","file","slug","MediaUploadCheck","fallback","MediaUpload","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","Button","ref","onClick","ResponsiveWrapper","naturalWidth","naturalHeight","isInline","src","alt","Spinner","set_featured_image","__experimentalHStack","current","focus","DropZone","onFilesDrop","value","applyWithSelect","withSelect","getMedia","getPostType","coreStore","getCurrentPostId","getEditedPostAttribute","editorStore","context","applyWithDispatch","withDispatch","dispatch","editPost","featured_media","onDropImage","_default","compose","withNotices","withFilters","exports"],"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":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAKA,IAAAQ,SAAA,GAAAR,OAAA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EAAEvD,KAAK,CAAChC;MAAG,CAAE,CAAC;IACzC,CAAC;IACDwF,WAAWA,CAAE3D,SAAS,EAAG;MACxBJ,MAAM,CAAEC,kBAAiB,CAAC,CACxBC,WAAW,CAAC,CAAC,CACbJ,WAAW,CAAE;QACbO,YAAY,EAAE,CAAE,OAAO,CAAE;QACzBD,SAAS;QACTE,YAAYA,CAAE,CAAEC,KAAK,CAAE,EAAG;UACzBsD,QAAQ,CAAE;YAAEC,cAAc,EAAEvD,KAAK,CAAChC;UAAG,CAAE,CAAC;QACzC,CAAC;QACDmC,OAAOA,CAAEC,OAAO,EAAG;UAClBnB,gBAAgB,CAACoB,gBAAgB,CAAC,CAAC;UACnCpB,gBAAgB,CAACqB,iBAAiB,CAAEF,OAAQ,CAAC;QAC9C;MACD,CAAE,CAAC;IACL,CAAC;IACDtB,aAAaA,CAAA,EAAG;MACfwE,QAAQ,CAAE;QAAEC,cAAc,EAAE;MAAE,CAAE,CAAC;IAClC;EACD,CAAC;AACF,CACD,CAAC;AAAC,IAAAE,QAAA,GAEa,IAAAC,gBAAO,EACrBC,uBAAW,EACXjB,eAAe,EACfS,iBAAiB,EACjB,IAAAS,uBAAW,EAAE,0BAA2B,CACzC,CAAC,CAAElF,iBAAkB,CAAC;AAAAmF,OAAA,CAAAtD,OAAA,GAAAkD,QAAA"}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_hooks","_components","_blob","_element","_compose","_data","_blockEditor","_coreData","_check","_interopRequireDefault","_store","ALLOWED_MEDIA_TYPES","DEFAULT_FEATURE_IMAGE_LABEL","__","DEFAULT_SET_FEATURE_IMAGE_LABEL","instructions","_react","createElement","getMediaDetails","media","postId","_media$media_details$","_media$media_details$2","defaultSize","applyFilters","id","media_details","sizes","mediaWidth","width","mediaHeight","height","mediaSourceUrl","source_url","fallbackSize","PostFeaturedImage","currentPostId","featuredImageId","onUpdateImage","onRemoveImage","postType","noticeUI","noticeOperations","toggleRef","useRef","isLoading","setIsLoading","useState","getSettings","useSelect","blockEditorStore","onDropFiles","filesList","mediaUpload","allowedTypes","onFileChange","image","isBlobURL","url","onError","message","removeAllNotices","createErrorNotice","default","className","alt_text","sprintf","full","file","slug","MediaUploadCheck","fallback","MediaUpload","title","labels","featured_image","onSelect","unstableFeaturedImageFlow","modalClass","render","open","Button","ref","onClick","ResponsiveWrapper","naturalWidth","naturalHeight","isInline","src","alt","Spinner","set_featured_image","__experimentalHStack","current","focus","DropZone","onFilesDrop","value","applyWithSelect","withSelect","select","getMedia","getPostType","coreStore","getCurrentPostId","getEditedPostAttribute","editorStore","context","applyWithDispatch","withDispatch","dispatch","editPost","featured_media","onDropImage","_default","compose","withNotices","withFilters","exports"],"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":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,IAAAG,KAA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pE,aAAaA,CAAEkB,KAAK,EAAG;MACtBuD,QAAQ,CAAE;QAAEC,cAAc,EAAExD,KAAK,CAAC/B;MAAG,CAAE,CAAC;IACzC,CAAC;IACDwF,WAAWA,CAAE7D,SAAS,EAAG;MACxBgD,MAAM,CAAElD,kBAAiB,CAAC,CACxBF,WAAW,CAAC,CAAC,CACbK,WAAW,CAAE;QACbC,YAAY,EAAE,CAAE,OAAO,CAAE;QACzBF,SAAS;QACTG,YAAYA,CAAE,CAAEC,KAAK,CAAE,EAAG;UACzBuD,QAAQ,CAAE;YAAEC,cAAc,EAAExD,KAAK,CAAC/B;UAAG,CAAE,CAAC;QACzC,CAAC;QACDkC,OAAOA,CAAEC,OAAO,EAAG;UAClBlB,gBAAgB,CAACmB,gBAAgB,CAAC,CAAC;UACnCnB,gBAAgB,CAACoB,iBAAiB,CAAEF,OAAQ,CAAC;QAC9C;MACD,CAAE,CAAC;IACL,CAAC;IACDrB,aAAaA,CAAA,EAAG;MACfwE,QAAQ,CAAE;QAAEC,cAAc,EAAE;MAAE,CAAE,CAAC;IAClC;EACD,CAAC;AACF,CACD,CAAC;AAAC,IAAAE,QAAA,GAEa,IAAAC,gBAAO,EACrBC,uBAAW,EACXlB,eAAe,EACfU,iBAAiB,EACjB,IAAAS,uBAAW,EAAE,0BAA2B,CACzC,CAAC,CAAElF,iBAAkB,CAAC;AAAAmF,OAAA,CAAAvD,OAAA,GAAAmD,QAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _i18n = require("@wordpress/i18n");
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
var _data = require("@wordpress/data");
|
|
12
|
+
var _coreData = require("@wordpress/core-data");
|
|
13
|
+
var _store = require("../../store");
|
|
14
|
+
var _index = _interopRequireDefault(require("./index"));
|
|
15
|
+
var _check = _interopRequireDefault(require("./check"));
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const PANEL_NAME = 'featured-image';
|
|
25
|
+
function FeaturedImage() {
|
|
26
|
+
var _postType$labels$feat;
|
|
27
|
+
const {
|
|
28
|
+
postType,
|
|
29
|
+
isEnabled,
|
|
30
|
+
isOpened
|
|
31
|
+
} = (0, _data.useSelect)(select => {
|
|
32
|
+
const {
|
|
33
|
+
getEditedPostAttribute,
|
|
34
|
+
isEditorPanelEnabled,
|
|
35
|
+
isEditorPanelOpened
|
|
36
|
+
} = select(_store.store);
|
|
37
|
+
const {
|
|
38
|
+
getPostType
|
|
39
|
+
} = select(_coreData.store);
|
|
40
|
+
return {
|
|
41
|
+
postType: getPostType(getEditedPostAttribute('type')),
|
|
42
|
+
isEnabled: isEditorPanelEnabled(PANEL_NAME),
|
|
43
|
+
isOpened: isEditorPanelOpened(PANEL_NAME)
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
const {
|
|
47
|
+
toggleEditorPanelOpened
|
|
48
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
49
|
+
if (!isEnabled) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return (0, _react.createElement)(_check.default, null, (0, _react.createElement)(_components.PanelBody, {
|
|
53
|
+
title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : (0, _i18n.__)('Featured image'),
|
|
54
|
+
opened: isOpened,
|
|
55
|
+
onToggle: () => toggleEditorPanelOpened(PANEL_NAME)
|
|
56
|
+
}, (0, _react.createElement)(_index.default, null)));
|
|
57
|
+
}
|
|
58
|
+
var _default = FeaturedImage;
|
|
59
|
+
exports.default = _default;
|
|
60
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_data","_coreData","_store","_index","_interopRequireDefault","_check","PANEL_NAME","FeaturedImage","_postType$labels$feat","postType","isEnabled","isOpened","useSelect","select","getEditedPostAttribute","isEditorPanelEnabled","isEditorPanelOpened","editorStore","getPostType","coreStore","toggleEditorPanelOpened","useDispatch","_react","createElement","default","PanelBody","title","labels","featured_image","__","opened","onToggle","_default","exports"],"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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,aAAA,EAACxB,WAAA,CAAA0B,SAAS;IACTC,KAAK,GAAAlB,qBAAA,GACJC,QAAQ,EAAEkB,MAAM,EAAEC,cAAc,cAAApB,qBAAA,cAAAA,qBAAA,GAAI,IAAAqB,QAAE,EAAE,gBAAiB,CACzD;IACDC,MAAM,EAAGnB,QAAU;IACnBoB,QAAQ,EAAGA,CAAA,KAAMX,uBAAuB,CAAEd,UAAW;EAAG,GAExD,IAAAgB,MAAA,CAAAC,aAAA,EAACpB,MAAA,CAAAqB,OAAiB,MAAE,CACV,CACY,CAAC;AAE3B;AAAC,IAAAQ,QAAA,GAEczB,aAAa;AAAA0B,OAAA,CAAAT,OAAA,GAAAQ,QAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
10
|
+
var _ = _interopRequireDefault(require("./"));
|
|
11
|
+
var _check = _interopRequireDefault(require("./check"));
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function PostLastRevisionPanel() {
|
|
21
|
+
return (0, _react.createElement)(_check.default, null, (0, _react.createElement)(_components.PanelBody, {
|
|
22
|
+
className: "editor-post-last-revision__panel"
|
|
23
|
+
}, (0, _react.createElement)(_.default, null)));
|
|
24
|
+
}
|
|
25
|
+
var _default = PostLastRevisionPanel;
|
|
26
|
+
exports.default = _default;
|
|
27
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_","_interopRequireDefault","_check","PostLastRevisionPanel","_react","createElement","default","PanelBody","className","_default","exports"],"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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,CAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASI,qBAAqBA,CAAA,EAAG;EAChC,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACH,MAAA,CAAAI,OAAqB,QACrB,IAAAF,MAAA,CAAAC,aAAA,EAACP,WAAA,CAAAS,SAAS;IAACC,SAAS,EAAC;EAAkC,GACtD,IAAAJ,MAAA,CAAAC,aAAA,EAACL,CAAA,CAAAM,OAAgB,MAAE,CACT,CACW,CAAC;AAE1B;AAAC,IAAAG,QAAA,GAEcN,qBAAqB;AAAAO,OAAA,CAAAJ,OAAA,GAAAG,QAAA"}
|
|
@@ -14,6 +14,7 @@ var _element = require("@wordpress/element");
|
|
|
14
14
|
var _i18n = require("@wordpress/i18n");
|
|
15
15
|
var _icons = require("@wordpress/icons");
|
|
16
16
|
var _keycodes = require("@wordpress/keycodes");
|
|
17
|
+
var _preferences = require("@wordpress/preferences");
|
|
17
18
|
var _store = require("../../store");
|
|
18
19
|
/**
|
|
19
20
|
* External dependencies
|
|
@@ -31,15 +32,13 @@ var _store = require("../../store");
|
|
|
31
32
|
* Component showing whether the post is saved or not and providing save
|
|
32
33
|
* buttons.
|
|
33
34
|
*
|
|
34
|
-
* @param {Object} props
|
|
35
|
-
* @param {?boolean} props.forceIsDirty
|
|
36
|
-
*
|
|
37
|
-
* @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons
|
|
35
|
+
* @param {Object} props Component props.
|
|
36
|
+
* @param {?boolean} props.forceIsDirty Whether to force the post to be marked
|
|
37
|
+
* as dirty.
|
|
38
38
|
* @return {import('react').ComponentType} The component.
|
|
39
39
|
*/
|
|
40
40
|
function PostSavedState({
|
|
41
|
-
forceIsDirty
|
|
42
|
-
showIconLabels = false
|
|
41
|
+
forceIsDirty
|
|
43
42
|
}) {
|
|
44
43
|
const [forceSavedMessage, setForceSavedMessage] = (0, _element.useState)(false);
|
|
45
44
|
const isLargeViewport = (0, _compose.useViewportMatch)('small');
|
|
@@ -52,7 +51,8 @@ function PostSavedState({
|
|
|
52
51
|
isSaveable,
|
|
53
52
|
isSaving,
|
|
54
53
|
isScheduled,
|
|
55
|
-
hasPublishAction
|
|
54
|
+
hasPublishAction,
|
|
55
|
+
showIconLabels
|
|
56
56
|
} = (0, _data.useSelect)(select => {
|
|
57
57
|
var _getCurrentPost$_link;
|
|
58
58
|
const {
|
|
@@ -66,6 +66,9 @@ function PostSavedState({
|
|
|
66
66
|
isAutosavingPost,
|
|
67
67
|
getEditedPostAttribute
|
|
68
68
|
} = select(_store.store);
|
|
69
|
+
const {
|
|
70
|
+
get
|
|
71
|
+
} = select(_preferences.store);
|
|
69
72
|
return {
|
|
70
73
|
isAutosaving: isAutosavingPost(),
|
|
71
74
|
isDirty: forceIsDirty || isEditedPostDirty(),
|
|
@@ -75,7 +78,8 @@ function PostSavedState({
|
|
|
75
78
|
isSaving: isSavingPost(),
|
|
76
79
|
isSaveable: isEditedPostSaveable(),
|
|
77
80
|
isScheduled: isCurrentPostScheduled(),
|
|
78
|
-
hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
|
|
81
|
+
hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
|
|
82
|
+
showIconLabels: get('core', 'showIconLabels')
|
|
79
83
|
};
|
|
80
84
|
}, [forceIsDirty]);
|
|
81
85
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_components","_compose","_data","_element","_i18n","_icons","_keycodes","_store","PostSavedState","forceIsDirty","showIconLabels","forceSavedMessage","setForceSavedMessage","useState","isLargeViewport","useViewportMatch","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","useSelect","select","_getCurrentPost$_link","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","editorStore","_links","savePost","useDispatch","wasSaving","usePrevious","useEffect","timeoutId","setTimeout","clearTimeout","label","__","shortLabel","isSaved","isSavedState","isDisabled","text","buttonAccessibleLabel","tooltipProps","undefined","shortcut","displayShortcut","primary","_react","createElement","Tooltip","Button","className","classnames","getAnimateClassName","type","onClick","variant","size","icon","cloudUpload","Icon","check","cloud"],"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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,MAAA,GAAAR,OAAA;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASS,cAAcA,CAAE;EACvCC,YAAY;E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AClB;EAEA,MAAMK,qBAAqB,GAAGD,IAAI,IAAIN,KAAK;;EAE3C;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMQ,YAAY,GAAGH,UAAU,GAC5BI,SAAS,GACT;IACAH,IAAI,EAAEC,qBAAqB;IAC3BG,QAAQ,EAAEC,yBAAe,CAACC,OAAO,CAAE,GAAI;EACvC,CAAC;;EAEJ;EACA;EACA,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAC7D,WAAA,CAAA8D,OAAO;IAAA,GAAMP;EAAY,GACzB,IAAAK,MAAA,CAAAC,aAAA,EAAC7D,WAAA,CAAA+D,MAAM;IACNC,SAAS,EACR3C,UAAU,IAAIC,QAAQ,GACnB,IAAA2C,mBAAU,EAAE;MACZ,wBAAwB,EAAE,CAAEd,YAAY;MACxC,yBAAyB,EAAEA,YAAY;MACvC,WAAW,EAAE7B,QAAQ;MACrB,eAAe,EAAEN,YAAY;MAC7B,UAAU,EAAEkC,OAAO;MACnB,CAAE,IAAAgB,yCAAmB,EAAE;QACtBC,IAAI,EAAE;MACP,CAAE,CAAC,GAAI7C;IACP,CAAE,CAAC,GACHkC,SACH;IACDY,OAAO,EAAGhB,UAAU,GAAGI,SAAS,GAAG,MAAMjB,QAAQ,CAAC,CAAG;IACrD8B,OAAO,EAAC,UAAU;IAClBC,IAAI,EAAC,SAAS;IACdC,IAAI,EAAGzD,eAAe,GAAG0C,SAAS,GAAGgB;IACrC;IAAA;IACA,cAAalB,qBAAuB;IACpC,iBAAgBF;EAAY,GAE1BD,YAAY,IAAI,IAAAS,MAAA,CAAAC,aAAA,EAACxD,MAAA,CAAAoE,IAAI;IAACF,IAAI,EAAGrB,OAAO,GAAGwB,YAAK,GAAGC;EAAO,CAAE,CAAC,EACzDtB,IACK,CACA,CAAC;AAEZ"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_components","_compose","_data","_element","_i18n","_icons","_keycodes","_preferences","_store","PostSavedState","forceIsDirty","forceSavedMessage","setForceSavedMessage","useState","isLargeViewport","useViewportMatch","isAutosaving","isDirty","isNew","isPending","isPublished","isSaveable","isSaving","isScheduled","hasPublishAction","showIconLabels","useSelect","select","_getCurrentPost$_link","isEditedPostNew","isCurrentPostPublished","isCurrentPostScheduled","isEditedPostDirty","isSavingPost","isEditedPostSaveable","getCurrentPost","isAutosavingPost","getEditedPostAttribute","editorStore","get","preferencesStore","_links","savePost","useDispatch","wasSaving","usePrevious","useEffect","timeoutId","setTimeout","clearTimeout","label","__","shortLabel","isSaved","isSavedState","isDisabled","text","buttonAccessibleLabel","tooltipProps","undefined","shortcut","displayShortcut","primary","_react","createElement","Tooltip","Button","className","classnames","getAnimateClassName","type","onClick","variant","size","icon","cloudUpload","Icon","check","cloud"],"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\t\t</Tooltip>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASU,cAAcA,CAAE;EAAEC;AAAa,CAAC,EAAG;EAC1D,MAAM,CAAEC,iBAAiB,EAAEC,oBAAoB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACrE,MAAMC,eAAe,GAAG,IAAAC,yBAAgB,EAAE,OAAQ,CAAC;EAEnD,MAAM;IACLC,YAAY;IACZC,OAAO;IACPC,KAAK;IACLC,SAAS;IACTC,WAAW;IACXC,UAAU;IACVC,QAAQ;IACRC,WA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,SAAS,GACT;IACAH,IAAI,EAAEC,qBAAqB;IAC3BG,QAAQ,EAAEC,yBAAe,CAACC,OAAO,CAAE,GAAI;EACvC,CAAC;;EAEJ;EACA;EACA,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAChE,WAAA,CAAAiE,OAAO;IAAA,GAAMP;EAAY,GACzB,IAAAK,MAAA,CAAAC,aAAA,EAAChE,WAAA,CAAAkE,MAAM;IACNC,SAAS,EACR9C,UAAU,IAAIC,QAAQ,GACnB,IAAA8C,mBAAU,EAAE;MACZ,wBAAwB,EAAE,CAAEd,YAAY;MACxC,yBAAyB,EAAEA,YAAY;MACvC,WAAW,EAAEhC,QAAQ;MACrB,eAAe,EAAEN,YAAY;MAC7B,UAAU,EAAEqC,OAAO;MACnB,CAAE,IAAAgB,yCAAmB,EAAE;QACtBC,IAAI,EAAE;MACP,CAAE,CAAC,GAAIhD;IACP,CAAE,CAAC,GACHqC,SACH;IACDY,OAAO,EAAGhB,UAAU,GAAGI,SAAS,GAAG,MAAMjB,QAAQ,CAAC,CAAG;IACrD8B,OAAO,EAAC,UAAU;IAClBC,IAAI,EAAC,SAAS;IACdC,IAAI,EAAG5D,eAAe,GAAG6C,SAAS,GAAGgB;IACrC;IAAA;IACA,cAAalB,qBAAuB;IACpC,iBAAgBF;EAAY,GAE1BD,YAAY,IAAI,IAAAS,MAAA,CAAAC,aAAA,EAAC3D,MAAA,CAAAuE,IAAI;IAACF,IAAI,EAAGrB,OAAO,GAAGwB,YAAK,GAAGC;EAAO,CAAE,CAAC,EACzDtB,IACK,CACA,CAAC;AAEZ"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
10
|
+
var _data = require("@wordpress/data");
|
|
11
|
+
var _store = require("../../store");
|
|
12
|
+
var _index = _interopRequireDefault(require("./index"));
|
|
13
|
+
var _check = _interopRequireDefault(require("./check"));
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function TaxonomyPanel({
|
|
23
|
+
taxonomy,
|
|
24
|
+
children
|
|
25
|
+
}) {
|
|
26
|
+
const slug = taxonomy?.slug;
|
|
27
|
+
const panelName = slug ? `taxonomy-panel-${slug}` : '';
|
|
28
|
+
const {
|
|
29
|
+
isEnabled,
|
|
30
|
+
isOpened
|
|
31
|
+
} = (0, _data.useSelect)(select => {
|
|
32
|
+
const {
|
|
33
|
+
isEditorPanelEnabled,
|
|
34
|
+
isEditorPanelOpened
|
|
35
|
+
} = select(_store.store);
|
|
36
|
+
return {
|
|
37
|
+
isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
|
|
38
|
+
isOpened: slug ? isEditorPanelOpened(panelName) : false
|
|
39
|
+
};
|
|
40
|
+
}, [panelName, slug]);
|
|
41
|
+
const {
|
|
42
|
+
toggleEditorPanelOpened
|
|
43
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
44
|
+
if (!isEnabled) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const taxonomyMenuName = taxonomy?.labels?.menu_name;
|
|
48
|
+
if (!taxonomyMenuName) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return (0, _react.createElement)(_components.PanelBody, {
|
|
52
|
+
title: taxonomyMenuName,
|
|
53
|
+
opened: isOpened,
|
|
54
|
+
onToggle: () => toggleEditorPanelOpened(panelName)
|
|
55
|
+
}, children);
|
|
56
|
+
}
|
|
57
|
+
function PostTaxonomies() {
|
|
58
|
+
return (0, _react.createElement)(_check.default, null, (0, _react.createElement)(_index.default, {
|
|
59
|
+
taxonomyWrapper: (content, taxonomy) => {
|
|
60
|
+
return (0, _react.createElement)(TaxonomyPanel, {
|
|
61
|
+
taxonomy: taxonomy
|
|
62
|
+
}, content);
|
|
63
|
+
}
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
var _default = PostTaxonomies;
|
|
67
|
+
exports.default = _default;
|
|
68
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_components","require","_data","_store","_index","_interopRequireDefault","_check","TaxonomyPanel","taxonomy","children","slug","panelName","isEnabled","isOpened","useSelect","select","isEditorPanelEnabled","isEditorPanelOpened","editorStore","toggleEditorPanelOpened","useDispatch","taxonomyMenuName","labels","menu_name","_react","createElement","PanelBody","title","opened","onToggle","PostTaxonomies","default","taxonomyWrapper","content","_default","exports"],"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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAD,sBAAA,CAAAJ,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,SAASM,aAAaA,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EAChD,MAAMC,IAAI,GAAGF,QAAQ,EAAEE,IAAI;EAC3B,MAAMC,SAAS,GAAGD,IAAI,GAAI,kBAAkBA,IAAM,EAAC,GAAG,EAAE;EACxD,MAAM;IAAEE,SAAS;IAAEC;EAAS,CAAC,GAAG,IAAAC,eAAS,EACtCC,MAAM,IAAM;IACb,MAAM;MAAEC,oBAAoB;MAAEC;IAAoB,CAAC,GAClDF,MAAM,CAAEG,YAAY,CAAC;IACtB,OAAO;MACNN,SAAS,EAAEF,IAAI,GAAGM,oBAAoB,CAAEL,SAAU,CAAC,GAAG,KAAK;MAC3DE,QAAQ,EAAEH,IAAI,GAAGO,mBAAmB,CAAEN,SAAU,CAAC,GAAG;IACrD,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,EAAED,IAAI,CAClB,CAAC;EACD,MAAM;IAAES;EAAwB,CAAC,GAAG,IAAAC,iBAAW,EAAEF,YAAY,CAAC;EAE9D,IAAK,CAAEN,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,MAAMS,gBAAgB,GAAGb,QAAQ,EAAEc,MAAM,EAAEC,SAAS;EACpD,IAAK,CAAEF,gBAAgB,EAAG;IACzB,OAAO,IAAI;EACZ;EAEA,OACC,IAAAG,MAAA,CAAAC,aAAA,EAACzB,WAAA,CAAA0B,SAAS;IACTC,KAAK,EAAGN,gBAAkB;IAC1BO,MAAM,EAAGf,QAAU;IACnBgB,QAAQ,EAAGA,CAAA,KAAMV,uBAAuB,CAAER,SAAU;EAAG,GAErDF,QACQ,CAAC;AAEd;AAEA,SAASqB,cAAcA,CAAA,EAAG;EACzB,OACC,IAAAN,MAAA,CAAAC,aAAA,EAACnB,MAAA,CAAAyB,OAAmB,QACnB,IAAAP,MAAA,CAAAC,aAAA,EAACrB,MAAA,CAAA2B,OAAkB;IAClBC,eAAe,EAAGA,CAAEC,OAAO,EAAEzB,QAAQ,KAAM;MAC1C,OACC,IAAAgB,MAAA,CAAAC,aAAA,EAAClB,aAAa;QAACC,QAAQ,EAAGA;MAAU,GACjCyB,OACY,CAAC;IAElB;EAAG,CACH,CACmB,CAAC;AAExB;AAAC,IAAAC,QAAA,GAEcJ,cAAc;AAAAK,OAAA,CAAAJ,OAAA,GAAAG,QAAA"}
|
|
@@ -90,7 +90,8 @@ function BlockThemeControl({
|
|
|
90
90
|
onClick: onClose
|
|
91
91
|
})), (0, _react.createElement)(_components.MenuGroup, null, (0, _react.createElement)(_components.MenuItem, {
|
|
92
92
|
icon: !isTemplateHidden ? _icons.check : undefined,
|
|
93
|
-
|
|
93
|
+
isSelected: !isTemplateHidden,
|
|
94
|
+
role: "menuitemcheckbox",
|
|
94
95
|
onClick: () => {
|
|
95
96
|
setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
|
|
96
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_htmlEntities","_components","_i18n","_coreData","_icons","_notices","_store","_swapTemplateButton","_interopRequireDefault","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","useSelect","select","getRenderingMode","unlock","editorStore","editedRecord","template","hasResolved","useEntityRecord","getEditorSettings","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","_react","createElement","DropdownMenu","popoverProps","focusOnMount","toggleProps","variant","label","__","text","decodeEntities","title","icon","onClose","Fragment","MenuGroup","MenuItem","onClick","type","actions","defaultRenderingMode","default","check","undefined","
|
|
1
|
+
{"version":3,"names":["_data","require","_htmlEntities","_components","_i18n","_coreData","_icons","_notices","_store","_swapTemplateButton","_interopRequireDefault","_resetDefaultTemplate","_lockUnlock","_createNewTemplate","POPOVER_PROPS","className","placement","BlockThemeControl","id","isTemplateHidden","useSelect","select","getRenderingMode","unlock","editorStore","editedRecord","template","hasResolved","useEntityRecord","getEditorSettings","createSuccessNotice","useDispatch","noticesStore","setRenderingMode","_react","createElement","DropdownMenu","popoverProps","focusOnMount","toggleProps","variant","label","__","text","decodeEntities","title","icon","onClose","Fragment","MenuGroup","MenuItem","onClick","type","actions","defaultRenderingMode","default","check","undefined","isSelected","role"],"sources":["@wordpress/editor/src/components/post-template/block-theme.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport SwapTemplateButton from './swap-template-button';\nimport ResetDefaultTemplate from './reset-default-template';\nimport { unlock } from '../../lock-unlock';\nimport CreateNewTemplate from './create-new-template';\n\nconst POPOVER_PROPS = {\n\tclassName: 'editor-post-template__dropdown',\n\tplacement: 'bottom-start',\n};\n\nexport default function BlockThemeControl( { id } ) {\n\tconst { isTemplateHidden } = useSelect( ( select ) => {\n\t\tconst { getRenderingMode } = unlock( select( editorStore ) );\n\t\treturn {\n\t\t\tisTemplateHidden: getRenderingMode() === 'post-only',\n\t\t};\n\t}, [] );\n\tconst { editedRecord: template, hasResolved } = useEntityRecord(\n\t\t'postType',\n\t\t'wp_template',\n\t\tid\n\t);\n\tconst { getEditorSettings } = useSelect( editorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tfocusOnMount\n\t\t\ttoggleProps={ {\n\t\t\t\tvariant: 'tertiary',\n\t\t\t} }\n\t\t\tlabel={ __( 'Template options' ) }\n\t\t\ttext={ decodeEntities( template.title ) }\n\t\t\ticon={ null }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Editing template. Changes made here affect all posts and pages that use the template.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tgetEditorSettings()\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\t\t\t\t\t\t\t\t\t\t\t\t),\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}\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<SwapTemplateButton onClick={ onClose } />\n\t\t\t\t\t\t<ResetDefaultTemplate onClick={ onClose } />\n\t\t\t\t\t\t<CreateNewTemplate onClick={ onClose } />\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ ! isTemplateHidden ? check : undefined }\n\t\t\t\t\t\t\tisSelected={ ! isTemplateHidden }\n\t\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetRenderingMode(\n\t\t\t\t\t\t\t\t\tisTemplateHidden\n\t\t\t\t\t\t\t\t\t\t? 'template-locked'\n\t\t\t\t\t\t\t\t\t\t: 'post-only'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Template preview' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA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