@wordpress/edit-site 6.11.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/app/index.js +0 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build/components/editor/index.js +9 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor/use-editor-title.js +29 -12
- package/build/components/editor/use-editor-title.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +24 -22
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +2 -3
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +42 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +6 -8
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/layout/hooks.js +1 -10
- package/build/components/layout/hooks.js.map +1 -1
- package/build/components/layout/index.js +1 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-patterns/fields.js +3 -7
- package/build/components/page-patterns/fields.js.map +1 -1
- package/build/components/page-templates/fields.js +1 -2
- package/build/components/page-templates/fields.js.map +1 -1
- package/build/components/post-edit/index.js +14 -8
- package/build/components/post-edit/index.js.map +1 -1
- package/build/components/post-fields/index.js +3 -197
- package/build/components/post-fields/index.js.map +1 -1
- package/build/components/post-list/index.js +11 -1
- package/build/components/post-list/index.js.map +1 -1
- package/build/components/sidebar/index.js +11 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-global-styles-wrapper/index.js +129 -0
- package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +14 -72
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +43 -42
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/site-editor-routes/styles-edit.js +6 -1
- package/build/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build/components/site-editor-routes/styles-view.js +8 -2
- package/build/components/site-editor-routes/styles-view.js.map +1 -1
- package/build/components/site-hub/index.js +19 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/constants.js +10 -3
- package/build/components/style-book/constants.js.map +1 -1
- package/build/components/style-book/examples.js +71 -1
- package/build/components/style-book/examples.js.map +1 -1
- package/build/components/style-book/index.js +70 -11
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/welcome-guide/index.js +4 -2
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/page.js +1 -9
- package/build/components/welcome-guide/page.js.map +1 -1
- package/build/components/welcome-guide/template.js +1 -12
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +15 -15
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/posts.js +1 -0
- package/build/posts.js.map +1 -1
- package/build-module/components/app/index.js +0 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/use-editor-iframe-props.js +6 -8
- package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
- package/build-module/components/editor/index.js +9 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor/use-editor-title.js +29 -12
- package/build-module/components/editor/use-editor-title.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +25 -23
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +2 -3
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +43 -3
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +6 -8
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/layout/hooks.js +1 -9
- package/build-module/components/layout/hooks.js.map +1 -1
- package/build-module/components/layout/index.js +1 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-patterns/fields.js +4 -8
- package/build-module/components/page-patterns/fields.js.map +1 -1
- package/build-module/components/page-templates/fields.js +1 -2
- package/build-module/components/page-templates/fields.js.map +1 -1
- package/build-module/components/post-edit/index.js +14 -8
- package/build-module/components/post-edit/index.js.map +1 -1
- package/build-module/components/post-fields/index.js +7 -202
- package/build-module/components/post-fields/index.js.map +1 -1
- package/build-module/components/post-list/index.js +11 -1
- package/build-module/components/post-list/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +11 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-global-styles-wrapper/index.js +121 -0
- package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +15 -73
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +43 -43
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-edit.js +6 -1
- package/build-module/components/site-editor-routes/styles-edit.js.map +1 -1
- package/build-module/components/site-editor-routes/styles-view.js +8 -2
- package/build-module/components/site-editor-routes/styles-view.js.map +1 -1
- package/build-module/components/site-hub/index.js +19 -6
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/constants.js +10 -3
- package/build-module/components/style-book/constants.js.map +1 -1
- package/build-module/components/style-book/examples.js +71 -1
- package/build-module/components/style-book/examples.js.map +1 -1
- package/build-module/components/style-book/index.js +71 -12
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +4 -2
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/page.js +1 -9
- package/build-module/components/welcome-guide/page.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -11
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +15 -15
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/posts.js +1 -0
- package/build-module/posts.js.map +1 -1
- package/build-style/posts-rtl.css +54 -5
- package/build-style/posts.css +54 -5
- package/build-style/style-rtl.css +109 -28
- package/build-style/style.css +109 -28
- package/package.json +3 -4
- package/src/components/app/index.js +0 -2
- package/src/components/block-editor/use-editor-iframe-props.js +2 -3
- package/src/components/editor/index.js +16 -4
- package/src/components/editor/use-editor-title.js +37 -13
- package/src/components/editor-canvas-container/style.scss +0 -1
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +28 -31
- package/src/components/global-styles/screen-revisions/style.scss +11 -17
- package/src/components/global-styles/shadows-edit-panel.js +4 -2
- package/src/components/global-styles/ui.js +42 -2
- package/src/components/global-styles-renderer/index.js +4 -10
- package/src/components/layout/hooks.js +1 -7
- package/src/components/layout/index.js +6 -1
- package/src/components/page-patterns/fields.js +6 -12
- package/src/components/page-patterns/style.scss +0 -5
- package/src/components/page-templates/fields.js +2 -3
- package/src/components/post-edit/index.js +38 -30
- package/src/components/post-edit/style.scss +7 -0
- package/src/components/post-fields/index.js +19 -273
- package/src/components/post-list/index.js +9 -3
- package/src/components/post-list/style.scss +29 -3
- package/src/components/sidebar/index.js +23 -7
- package/src/components/sidebar-global-styles-wrapper/index.js +150 -0
- package/src/components/sidebar-global-styles-wrapper/style.scss +35 -0
- package/src/components/sidebar-navigation-item/style.scss +2 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +13 -88
- package/src/components/sidebar-navigation-screen-main/index.js +46 -45
- package/src/components/site-editor-routes/styles-edit.js +10 -1
- package/src/components/site-editor-routes/styles-view.js +11 -1
- package/src/components/site-hub/index.js +33 -16
- package/src/components/site-icon/style.scss +16 -0
- package/src/components/style-book/constants.ts +11 -3
- package/src/components/style-book/examples.tsx +105 -1
- package/src/components/style-book/index.js +86 -8
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +54 -64
- package/src/components/welcome-guide/index.js +3 -3
- package/src/components/welcome-guide/page.js +1 -7
- package/src/components/welcome-guide/template.js +1 -8
- package/src/hooks/commands/use-common-commands.js +253 -246
- package/src/index.js +1 -0
- package/src/posts.js +1 -0
- package/src/style.scss +2 -3
- package/build/components/async/index.js +0 -51
- package/build/components/async/index.js.map +0 -1
- package/build/components/use-edited-entity-record/index.js +0 -60
- package/build/components/use-edited-entity-record/index.js.map +0 -1
- package/build/hooks/commands/use-edit-mode-commands.js +0 -179
- package/build/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/build-module/components/async/index.js +0 -44
- package/build-module/components/async/index.js.map +0 -1
- package/build-module/components/use-edited-entity-record/index.js +0 -53
- package/build-module/components/use-edited-entity-record/index.js.map +0 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +0 -171
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +0 -1
- package/src/components/async/index.js +0 -43
- package/src/components/use-edited-entity-record/index.js +0 -58
- package/src/hooks/commands/use-edit-mode-commands.js +0 -168
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useEditedEntityRecord;
|
|
7
|
-
var _data = require("@wordpress/data");
|
|
8
|
-
var _coreData = require("@wordpress/core-data");
|
|
9
|
-
var _editor = require("@wordpress/editor");
|
|
10
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
11
|
-
var _store = require("../../store");
|
|
12
|
-
/**
|
|
13
|
-
* WordPress dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
function useEditedEntityRecord(postType, postId) {
|
|
21
|
-
const {
|
|
22
|
-
record,
|
|
23
|
-
title,
|
|
24
|
-
description,
|
|
25
|
-
isLoaded,
|
|
26
|
-
icon
|
|
27
|
-
} = (0, _data.useSelect)(select => {
|
|
28
|
-
const {
|
|
29
|
-
getEditedPostType,
|
|
30
|
-
getEditedPostId
|
|
31
|
-
} = select(_store.store);
|
|
32
|
-
const {
|
|
33
|
-
getEditedEntityRecord,
|
|
34
|
-
hasFinishedResolution
|
|
35
|
-
} = select(_coreData.store);
|
|
36
|
-
const {
|
|
37
|
-
__experimentalGetTemplateInfo: getTemplateInfo
|
|
38
|
-
} = select(_editor.store);
|
|
39
|
-
const usedPostType = postType !== null && postType !== void 0 ? postType : getEditedPostType();
|
|
40
|
-
const usedPostId = postId !== null && postId !== void 0 ? postId : getEditedPostId();
|
|
41
|
-
const _record = getEditedEntityRecord('postType', usedPostType, usedPostId);
|
|
42
|
-
const _isLoaded = usedPostId && hasFinishedResolution('getEditedEntityRecord', ['postType', usedPostType, usedPostId]);
|
|
43
|
-
const templateInfo = getTemplateInfo(_record);
|
|
44
|
-
return {
|
|
45
|
-
record: _record,
|
|
46
|
-
title: templateInfo.title,
|
|
47
|
-
description: templateInfo.description,
|
|
48
|
-
isLoaded: _isLoaded,
|
|
49
|
-
icon: templateInfo.icon
|
|
50
|
-
};
|
|
51
|
-
}, [postType, postId]);
|
|
52
|
-
return {
|
|
53
|
-
isLoaded,
|
|
54
|
-
icon,
|
|
55
|
-
record,
|
|
56
|
-
getTitle: () => title ? (0, _htmlEntities.decodeEntities)(title) : null,
|
|
57
|
-
getDescription: () => description ? (0, _htmlEntities.decodeEntities)(description) : null
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_coreData","_editor","_htmlEntities","_store","useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","useSelect","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","hasFinishedResolution","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","decodeEntities","getDescription"],"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord( postType, postId ) {\n\tconst { record, title, description, isLoaded, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst usedPostType = postType ?? getEditedPostType();\n\t\t\tconst usedPostId = postId ?? getEditedPostId();\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tusedPostType,\n\t\t\t\tusedPostId\n\t\t\t);\n\t\t\tconst _isLoaded =\n\t\t\t\tusedPostId &&\n\t\t\t\thasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tusedPostType,\n\t\t\t\t\tusedPostId,\n\t\t\t\t] );\n\t\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\t\treturn {\n\t\t\t\trecord: _record,\n\t\t\t\ttitle: templateInfo.title,\n\t\t\t\tdescription: templateInfo.description,\n\t\t\t\tisLoaded: _isLoaded,\n\t\t\t\ticon: templateInfo.icon,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn {\n\t\tisLoaded,\n\t\ticon,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAXA;AACA;AACA;;AAMA;AACA;AACA;;AAGe,SAASK,qBAAqBA,CAAEC,QAAQ,EAAEC,MAAM,EAAG;EACjE,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAK,CAAC,GAAG,IAAAC,eAAS,EAC7DC,MAAM,IAAM;IACb,MAAM;MAAEC,iBAAiB;MAAEC;IAAgB,CAAC,GAC3CF,MAAM,CAAEG,YAAc,CAAC;IACxB,MAAM;MAAEC,qBAAqB;MAAEC;IAAsB,CAAC,GACrDL,MAAM,CAAEM,eAAU,CAAC;IACpB,MAAM;MAAEC,6BAA6B,EAAEC;IAAgB,CAAC,GACvDR,MAAM,CAAES,aAAY,CAAC;IACtB,MAAMC,YAAY,GAAGlB,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAIS,iBAAiB,CAAC,CAAC;IACpD,MAAMU,UAAU,GAAGlB,MAAM,aAANA,MAAM,cAANA,MAAM,GAAIS,eAAe,CAAC,CAAC;IAC9C,MAAMU,OAAO,GAAGR,qBAAqB,CACpC,UAAU,EACVM,YAAY,EACZC,UACD,CAAC;IACD,MAAME,SAAS,GACdF,UAAU,IACVN,qBAAqB,CAAE,uBAAuB,EAAE,CAC/C,UAAU,EACVK,YAAY,EACZC,UAAU,CACT,CAAC;IACJ,MAAMG,YAAY,GAAGN,eAAe,CAAEI,OAAQ,CAAC;IAE/C,OAAO;MACNlB,MAAM,EAAEkB,OAAO;MACfjB,KAAK,EAAEmB,YAAY,CAACnB,KAAK;MACzBC,WAAW,EAAEkB,YAAY,CAAClB,WAAW;MACrCC,QAAQ,EAAEgB,SAAS;MACnBf,IAAI,EAAEgB,YAAY,CAAChB;IACpB,CAAC;EACF,CAAC,EACD,CAAEN,QAAQ,EAAEC,MAAM,CACnB,CAAC;EAED,OAAO;IACNI,QAAQ;IACRC,IAAI;IACJJ,MAAM;IACNqB,QAAQ,EAAEA,CAAA,KAAQpB,KAAK,GAAG,IAAAqB,4BAAc,EAAErB,KAAM,CAAC,GAAG,IAAM;IAC1DsB,cAAc,EAAEA,CAAA,KACfrB,WAAW,GAAG,IAAAoB,4BAAc,EAAEpB,WAAY,CAAC,GAAG;EAChD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.useEditModeCommands = useEditModeCommands;
|
|
8
|
-
var _data = require("@wordpress/data");
|
|
9
|
-
var _i18n = require("@wordpress/i18n");
|
|
10
|
-
var _icons = require("@wordpress/icons");
|
|
11
|
-
var _commands = require("@wordpress/commands");
|
|
12
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
13
|
-
var _router = require("@wordpress/router");
|
|
14
|
-
var _editor = require("@wordpress/editor");
|
|
15
|
-
var _store = require("../../store");
|
|
16
|
-
var _useEditedEntityRecord = _interopRequireDefault(require("../../components/use-edited-entity-record"));
|
|
17
|
-
var _isTemplateRemovable = _interopRequireDefault(require("../../utils/is-template-removable"));
|
|
18
|
-
var _isTemplateRevertable = _interopRequireDefault(require("../../utils/is-template-revertable"));
|
|
19
|
-
var _lockUnlock = require("../../lock-unlock");
|
|
20
|
-
var _constants = require("../../utils/constants");
|
|
21
|
-
var _link = require("../../components/routes/link");
|
|
22
|
-
/**
|
|
23
|
-
* WordPress dependencies
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Internal dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
const {
|
|
31
|
-
useHistory,
|
|
32
|
-
useLocation
|
|
33
|
-
} = (0, _lockUnlock.unlock)(_router.privateApis);
|
|
34
|
-
function usePageContentFocusCommands() {
|
|
35
|
-
const {
|
|
36
|
-
record: template
|
|
37
|
-
} = (0, _useEditedEntityRecord.default)();
|
|
38
|
-
const {
|
|
39
|
-
params
|
|
40
|
-
} = useLocation();
|
|
41
|
-
const {
|
|
42
|
-
canvas = 'view'
|
|
43
|
-
} = params;
|
|
44
|
-
const {
|
|
45
|
-
isPage,
|
|
46
|
-
templateId,
|
|
47
|
-
currentPostType
|
|
48
|
-
} = (0, _data.useSelect)(select => {
|
|
49
|
-
const {
|
|
50
|
-
isPage: _isPage
|
|
51
|
-
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
52
|
-
const {
|
|
53
|
-
getCurrentPostType,
|
|
54
|
-
getCurrentTemplateId
|
|
55
|
-
} = select(_editor.store);
|
|
56
|
-
return {
|
|
57
|
-
isPage: _isPage(),
|
|
58
|
-
templateId: getCurrentTemplateId(),
|
|
59
|
-
currentPostType: getCurrentPostType()
|
|
60
|
-
};
|
|
61
|
-
}, []);
|
|
62
|
-
const {
|
|
63
|
-
onClick: editTemplate
|
|
64
|
-
} = (0, _link.useLink)({
|
|
65
|
-
postType: 'wp_template',
|
|
66
|
-
postId: templateId
|
|
67
|
-
});
|
|
68
|
-
const {
|
|
69
|
-
setRenderingMode
|
|
70
|
-
} = (0, _data.useDispatch)(_editor.store);
|
|
71
|
-
if (!isPage || canvas !== 'edit') {
|
|
72
|
-
return {
|
|
73
|
-
isLoading: false,
|
|
74
|
-
commands: []
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
const commands = [];
|
|
78
|
-
if (currentPostType !== 'wp_template') {
|
|
79
|
-
commands.push({
|
|
80
|
-
name: 'core/switch-to-template-focus',
|
|
81
|
-
label: (0, _i18n.sprintf)(/* translators: %s: template title */
|
|
82
|
-
(0, _i18n.__)('Edit template: %s'), (0, _htmlEntities.decodeEntities)(template.title)),
|
|
83
|
-
icon: _icons.layout,
|
|
84
|
-
callback: ({
|
|
85
|
-
close
|
|
86
|
-
}) => {
|
|
87
|
-
editTemplate();
|
|
88
|
-
close();
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
} else {
|
|
92
|
-
commands.push({
|
|
93
|
-
name: 'core/switch-to-page-focus',
|
|
94
|
-
label: (0, _i18n.__)('Back to page'),
|
|
95
|
-
icon: _icons.page,
|
|
96
|
-
callback: ({
|
|
97
|
-
close
|
|
98
|
-
}) => {
|
|
99
|
-
setRenderingMode('template-locked');
|
|
100
|
-
close();
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
isLoading: false,
|
|
106
|
-
commands
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function useManipulateDocumentCommands() {
|
|
110
|
-
const {
|
|
111
|
-
isLoaded,
|
|
112
|
-
record: template
|
|
113
|
-
} = (0, _useEditedEntityRecord.default)();
|
|
114
|
-
const {
|
|
115
|
-
removeTemplate,
|
|
116
|
-
revertTemplate
|
|
117
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
118
|
-
const history = useHistory();
|
|
119
|
-
const isEditingPage = (0, _data.useSelect)(select => select(_store.store).isPage() && select(_editor.store).getCurrentPostType() !== 'wp_template', []);
|
|
120
|
-
if (!isLoaded) {
|
|
121
|
-
return {
|
|
122
|
-
isLoading: true,
|
|
123
|
-
commands: []
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
const commands = [];
|
|
127
|
-
if ((0, _isTemplateRevertable.default)(template) && !isEditingPage) {
|
|
128
|
-
const label = template.type === _constants.TEMPLATE_POST_TYPE ? (0, _i18n.sprintf)(/* translators: %s: template title */
|
|
129
|
-
(0, _i18n.__)('Reset template: %s'), (0, _htmlEntities.decodeEntities)(template.title)) : (0, _i18n.sprintf)(/* translators: %s: template part title */
|
|
130
|
-
(0, _i18n.__)('Reset template part: %s'), (0, _htmlEntities.decodeEntities)(template.title));
|
|
131
|
-
commands.push({
|
|
132
|
-
name: 'core/reset-template',
|
|
133
|
-
label,
|
|
134
|
-
icon: (0, _i18n.isRTL)() ? _icons.rotateRight : _icons.rotateLeft,
|
|
135
|
-
callback: ({
|
|
136
|
-
close
|
|
137
|
-
}) => {
|
|
138
|
-
revertTemplate(template);
|
|
139
|
-
close();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
if ((0, _isTemplateRemovable.default)(template) && !isEditingPage) {
|
|
144
|
-
const label = template.type === _constants.TEMPLATE_POST_TYPE ? (0, _i18n.sprintf)(/* translators: %s: template title */
|
|
145
|
-
(0, _i18n.__)('Delete template: %s'), (0, _htmlEntities.decodeEntities)(template.title)) : (0, _i18n.sprintf)(/* translators: %s: template part title */
|
|
146
|
-
(0, _i18n.__)('Delete template part: %s'), (0, _htmlEntities.decodeEntities)(template.title));
|
|
147
|
-
commands.push({
|
|
148
|
-
name: 'core/remove-template',
|
|
149
|
-
label,
|
|
150
|
-
icon: _icons.trash,
|
|
151
|
-
callback: ({
|
|
152
|
-
close
|
|
153
|
-
}) => {
|
|
154
|
-
removeTemplate(template);
|
|
155
|
-
// Navigate to the template list
|
|
156
|
-
history.push({
|
|
157
|
-
postType: template.type
|
|
158
|
-
});
|
|
159
|
-
close();
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
isLoading: !isLoaded,
|
|
165
|
-
commands
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function useEditModeCommands() {
|
|
169
|
-
(0, _commands.useCommandLoader)({
|
|
170
|
-
name: 'core/edit-site/page-content-focus',
|
|
171
|
-
hook: usePageContentFocusCommands,
|
|
172
|
-
context: 'entity-edit'
|
|
173
|
-
});
|
|
174
|
-
(0, _commands.useCommandLoader)({
|
|
175
|
-
name: 'core/edit-site/manipulate-document',
|
|
176
|
-
hook: useManipulateDocumentCommands
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=use-edit-mode-commands.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_i18n","_icons","_commands","_htmlEntities","_router","_editor","_store","_useEditedEntityRecord","_interopRequireDefault","_isTemplateRemovable","_isTemplateRevertable","_lockUnlock","_constants","_link","useHistory","useLocation","unlock","routerPrivateApis","usePageContentFocusCommands","record","template","useEditedEntityRecord","params","canvas","isPage","templateId","currentPostType","useSelect","select","_isPage","editSiteStore","getCurrentPostType","getCurrentTemplateId","editorStore","onClick","editTemplate","useLink","postType","postId","setRenderingMode","useDispatch","isLoading","commands","push","name","label","sprintf","__","decodeEntities","title","icon","layout","callback","close","page","useManipulateDocumentCommands","isLoaded","removeTemplate","revertTemplate","history","isEditingPage","isTemplateRevertable","type","TEMPLATE_POST_TYPE","isRTL","rotateRight","rotateLeft","isTemplateRemovable","trash","useEditModeCommands","useCommandLoader","hook","context"],"sources":["@wordpress/edit-site/src/hooks/commands/use-edit-mode-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf, isRTL } from '@wordpress/i18n';\nimport { trash, rotateLeft, rotateRight, layout, page } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport useEditedEntityRecord from '../../components/use-edited-entity-record';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { unlock } from '../../lock-unlock';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { useLink } from '../../components/routes/link';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nfunction usePageContentFocusCommands() {\n\tconst { record: template } = useEditedEntityRecord();\n\tconst { params } = useLocation();\n\tconst { canvas = 'view' } = params;\n\tconst { isPage, templateId, currentPostType } = useSelect( ( select ) => {\n\t\tconst { isPage: _isPage } = unlock( select( editSiteStore ) );\n\t\tconst { getCurrentPostType, getCurrentTemplateId } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisPage: _isPage(),\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tcurrentPostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { onClick: editTemplate } = useLink( {\n\t\tpostType: 'wp_template',\n\t\tpostId: templateId,\n\t} );\n\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tif ( ! isPage || canvas !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( currentPostType !== 'wp_template' ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-template-focus',\n\t\t\tlabel: sprintf(\n\t\t\t\t/* translators: %s: template title */\n\t\t\t\t__( 'Edit template: %s' ),\n\t\t\t\tdecodeEntities( template.title )\n\t\t\t),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\teditTemplate();\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t} else {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-page-focus',\n\t\t\tlabel: __( 'Back to page' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetRenderingMode( 'template-locked' );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nfunction useManipulateDocumentCommands() {\n\tconst { isLoaded, record: template } = useEditedEntityRecord();\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst history = useHistory();\n\tconst isEditingPage = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editSiteStore ).isPage() &&\n\t\t\tselect( editorStore ).getCurrentPostType() !== 'wp_template',\n\t\t[]\n\t);\n\n\tif ( ! isLoaded ) {\n\t\treturn { isLoading: true, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( isTemplateRevertable( template ) && ! isEditingPage ) {\n\t\tconst label =\n\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: template title */\n\t\t\t\t\t\t__( 'Reset template: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Reset template part: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t );\n\t\tcommands.push( {\n\t\t\tname: 'core/reset-template',\n\t\t\tlabel,\n\t\t\ticon: isRTL() ? rotateRight : rotateLeft,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\trevertTemplate( template );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( isTemplateRemovable( template ) && ! isEditingPage ) {\n\t\tconst label =\n\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: template title */\n\t\t\t\t\t\t__( 'Delete template: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Delete template part: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t );\n\t\tcommands.push( {\n\t\t\tname: 'core/remove-template',\n\t\t\tlabel,\n\t\t\ticon: trash,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tremoveTemplate( template );\n\t\t\t\t// Navigate to the template list\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: template.type,\n\t\t\t\t} );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tisLoading: ! isLoaded,\n\t\tcommands,\n\t};\n}\n\nexport function useEditModeCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/page-content-focus',\n\t\thook: usePageContentFocusCommands,\n\t\tcontext: 'entity-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/manipulate-document',\n\t\thook: useManipulateDocumentCommands,\n\t} );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,sBAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,oBAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,qBAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,UAAA,GAAAb,OAAA;AACA,IAAAc,KAAA,GAAAd,OAAA;AApBA;AACA;AACA;;AASA;AACA;AACA;;AASA,MAAM;EAAEe,UAAU;EAAEC;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAE/D,SAASC,2BAA2BA,CAAA,EAAG;EACtC,MAAM;IAAEC,MAAM,EAAEC;EAAS,CAAC,GAAG,IAAAC,8BAAqB,EAAC,CAAC;EAC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ACJ;EAEA,OAAO;IACNZ,SAAS,EAAE,CAAEe,QAAQ;IACrBd;EACD,CAAC;AACF;AAEO,SAAS2B,mBAAmBA,CAAA,EAAG;EACrC,IAAAC,0BAAgB,EAAE;IACjB1B,IAAI,EAAE,mCAAmC;IACzC2B,IAAI,EAAErD,2BAA2B;IACjCsD,OAAO,EAAE;EACV,CAAE,CAAC;EAEH,IAAAF,0BAAgB,EAAE;IACjB1B,IAAI,EAAE,oCAAoC;IAC1C2B,IAAI,EAAEhB;EACP,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect, useState, flushSync } from '@wordpress/element';
|
|
5
|
-
import { createQueue } from '@wordpress/priority-queue';
|
|
6
|
-
const blockPreviewQueue = createQueue();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Renders a component at the next idle time.
|
|
10
|
-
* @param {*} props
|
|
11
|
-
*/
|
|
12
|
-
export function Async({
|
|
13
|
-
children,
|
|
14
|
-
placeholder
|
|
15
|
-
}) {
|
|
16
|
-
const [shouldRender, setShouldRender] = useState(false);
|
|
17
|
-
|
|
18
|
-
// In the future, we could try to use startTransition here, but currently
|
|
19
|
-
// react will batch all transitions, which means all previews will be
|
|
20
|
-
// rendered at the same time.
|
|
21
|
-
// https://react.dev/reference/react/startTransition#caveats
|
|
22
|
-
// > If there are multiple ongoing Transitions, React currently batches them
|
|
23
|
-
// > together. This is a limitation that will likely be removed in a future
|
|
24
|
-
// > release.
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const context = {};
|
|
28
|
-
blockPreviewQueue.add(context, () => {
|
|
29
|
-
// Synchronously run all renders so it consumes timeRemaining.
|
|
30
|
-
// See https://github.com/WordPress/gutenberg/pull/48238
|
|
31
|
-
flushSync(() => {
|
|
32
|
-
setShouldRender(true);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
return () => {
|
|
36
|
-
blockPreviewQueue.cancel(context);
|
|
37
|
-
};
|
|
38
|
-
}, []);
|
|
39
|
-
if (!shouldRender) {
|
|
40
|
-
return placeholder;
|
|
41
|
-
}
|
|
42
|
-
return children;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useState","flushSync","createQueue","blockPreviewQueue","Async","children","placeholder","shouldRender","setShouldRender","context","add","cancel"],"sources":["@wordpress/edit-site/src/components/async/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, flushSync } from '@wordpress/element';\nimport { createQueue } from '@wordpress/priority-queue';\n\nconst blockPreviewQueue = createQueue();\n\n/**\n * Renders a component at the next idle time.\n * @param {*} props\n */\nexport function Async( { children, placeholder } ) {\n\tconst [ shouldRender, setShouldRender ] = useState( false );\n\n\t// In the future, we could try to use startTransition here, but currently\n\t// react will batch all transitions, which means all previews will be\n\t// rendered at the same time.\n\t// https://react.dev/reference/react/startTransition#caveats\n\t// > If there are multiple ongoing Transitions, React currently batches them\n\t// > together. This is a limitation that will likely be removed in a future\n\t// > release.\n\n\tuseEffect( () => {\n\t\tconst context = {};\n\t\tblockPreviewQueue.add( context, () => {\n\t\t\t// Synchronously run all renders so it consumes timeRemaining.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/48238\n\t\t\tflushSync( () => {\n\t\t\t\tsetShouldRender( true );\n\t\t\t} );\n\t\t} );\n\t\treturn () => {\n\t\t\tblockPreviewQueue.cancel( context );\n\t\t};\n\t}, [] );\n\n\tif ( ! shouldRender ) {\n\t\treturn placeholder;\n\t}\n\n\treturn children;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACnE,SAASC,WAAW,QAAQ,2BAA2B;AAEvD,MAAMC,iBAAiB,GAAGD,WAAW,CAAC,CAAC;;AAEvC;AACA;AACA;AACA;AACA,OAAO,SAASE,KAAKA,CAAE;EAAEC,QAAQ;EAAEC;AAAY,CAAC,EAAG;EAClD,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAGR,QAAQ,CAAE,KAAM,CAAC;;EAE3D;EACA;EACA;EACA;EACA;EACA;EACA;;EAEAD,SAAS,CAAE,MAAM;IAChB,MAAMU,OAAO,GAAG,CAAC,CAAC;IAClBN,iBAAiB,CAACO,GAAG,CAAED,OAAO,EAAE,MAAM;MACrC;MACA;MACAR,SAAS,CAAE,MAAM;QAChBO,eAAe,CAAE,IAAK,CAAC;MACxB,CAAE,CAAC;IACJ,CAAE,CAAC;IACH,OAAO,MAAM;MACZL,iBAAiB,CAACQ,MAAM,CAAEF,OAAQ,CAAC;IACpC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEF,YAAY,EAAG;IACrB,OAAOD,WAAW;EACnB;EAEA,OAAOD,QAAQ;AAChB","ignoreList":[]}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
6
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
7
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import { store as editSiteStore } from '../../store';
|
|
13
|
-
export default function useEditedEntityRecord(postType, postId) {
|
|
14
|
-
const {
|
|
15
|
-
record,
|
|
16
|
-
title,
|
|
17
|
-
description,
|
|
18
|
-
isLoaded,
|
|
19
|
-
icon
|
|
20
|
-
} = useSelect(select => {
|
|
21
|
-
const {
|
|
22
|
-
getEditedPostType,
|
|
23
|
-
getEditedPostId
|
|
24
|
-
} = select(editSiteStore);
|
|
25
|
-
const {
|
|
26
|
-
getEditedEntityRecord,
|
|
27
|
-
hasFinishedResolution
|
|
28
|
-
} = select(coreStore);
|
|
29
|
-
const {
|
|
30
|
-
__experimentalGetTemplateInfo: getTemplateInfo
|
|
31
|
-
} = select(editorStore);
|
|
32
|
-
const usedPostType = postType !== null && postType !== void 0 ? postType : getEditedPostType();
|
|
33
|
-
const usedPostId = postId !== null && postId !== void 0 ? postId : getEditedPostId();
|
|
34
|
-
const _record = getEditedEntityRecord('postType', usedPostType, usedPostId);
|
|
35
|
-
const _isLoaded = usedPostId && hasFinishedResolution('getEditedEntityRecord', ['postType', usedPostType, usedPostId]);
|
|
36
|
-
const templateInfo = getTemplateInfo(_record);
|
|
37
|
-
return {
|
|
38
|
-
record: _record,
|
|
39
|
-
title: templateInfo.title,
|
|
40
|
-
description: templateInfo.description,
|
|
41
|
-
isLoaded: _isLoaded,
|
|
42
|
-
icon: templateInfo.icon
|
|
43
|
-
};
|
|
44
|
-
}, [postType, postId]);
|
|
45
|
-
return {
|
|
46
|
-
isLoaded,
|
|
47
|
-
icon,
|
|
48
|
-
record,
|
|
49
|
-
getTitle: () => title ? decodeEntities(title) : null,
|
|
50
|
-
getDescription: () => description ? decodeEntities(description) : null
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","store","coreStore","editorStore","decodeEntities","editSiteStore","useEditedEntityRecord","postType","postId","record","title","description","isLoaded","icon","select","getEditedPostType","getEditedPostId","getEditedEntityRecord","hasFinishedResolution","__experimentalGetTemplateInfo","getTemplateInfo","usedPostType","usedPostId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord( postType, postId ) {\n\tconst { record, title, description, isLoaded, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostType, getEditedPostId } =\n\t\t\t\tselect( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst usedPostType = postType ?? getEditedPostType();\n\t\t\tconst usedPostId = postId ?? getEditedPostId();\n\t\t\tconst _record = getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tusedPostType,\n\t\t\t\tusedPostId\n\t\t\t);\n\t\t\tconst _isLoaded =\n\t\t\t\tusedPostId &&\n\t\t\t\thasFinishedResolution( 'getEditedEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\tusedPostType,\n\t\t\t\t\tusedPostId,\n\t\t\t\t] );\n\t\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\t\treturn {\n\t\t\t\trecord: _record,\n\t\t\t\ttitle: templateInfo.title,\n\t\t\t\tdescription: templateInfo.description,\n\t\t\t\tisLoaded: _isLoaded,\n\t\t\t\ticon: templateInfo.icon,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\treturn {\n\t\tisLoaded,\n\t\ticon,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,WAAW,QAAQ,mBAAmB;AACxD,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASH,KAAK,IAA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GAAG,IAAM;IAC1DiB,cAAc,EAAEA,CAAA,KACfhB,WAAW,GAAGP,cAAc,CAAEO,WAAY,CAAC,GAAG;EAChD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import { __, sprintf, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import { trash, rotateLeft, rotateRight, layout, page } from '@wordpress/icons';
|
|
7
|
-
import { useCommandLoader } from '@wordpress/commands';
|
|
8
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
|
-
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
10
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { store as editSiteStore } from '../../store';
|
|
16
|
-
import useEditedEntityRecord from '../../components/use-edited-entity-record';
|
|
17
|
-
import isTemplateRemovable from '../../utils/is-template-removable';
|
|
18
|
-
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
19
|
-
import { unlock } from '../../lock-unlock';
|
|
20
|
-
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
21
|
-
import { useLink } from '../../components/routes/link';
|
|
22
|
-
const {
|
|
23
|
-
useHistory,
|
|
24
|
-
useLocation
|
|
25
|
-
} = unlock(routerPrivateApis);
|
|
26
|
-
function usePageContentFocusCommands() {
|
|
27
|
-
const {
|
|
28
|
-
record: template
|
|
29
|
-
} = useEditedEntityRecord();
|
|
30
|
-
const {
|
|
31
|
-
params
|
|
32
|
-
} = useLocation();
|
|
33
|
-
const {
|
|
34
|
-
canvas = 'view'
|
|
35
|
-
} = params;
|
|
36
|
-
const {
|
|
37
|
-
isPage,
|
|
38
|
-
templateId,
|
|
39
|
-
currentPostType
|
|
40
|
-
} = useSelect(select => {
|
|
41
|
-
const {
|
|
42
|
-
isPage: _isPage
|
|
43
|
-
} = unlock(select(editSiteStore));
|
|
44
|
-
const {
|
|
45
|
-
getCurrentPostType,
|
|
46
|
-
getCurrentTemplateId
|
|
47
|
-
} = select(editorStore);
|
|
48
|
-
return {
|
|
49
|
-
isPage: _isPage(),
|
|
50
|
-
templateId: getCurrentTemplateId(),
|
|
51
|
-
currentPostType: getCurrentPostType()
|
|
52
|
-
};
|
|
53
|
-
}, []);
|
|
54
|
-
const {
|
|
55
|
-
onClick: editTemplate
|
|
56
|
-
} = useLink({
|
|
57
|
-
postType: 'wp_template',
|
|
58
|
-
postId: templateId
|
|
59
|
-
});
|
|
60
|
-
const {
|
|
61
|
-
setRenderingMode
|
|
62
|
-
} = useDispatch(editorStore);
|
|
63
|
-
if (!isPage || canvas !== 'edit') {
|
|
64
|
-
return {
|
|
65
|
-
isLoading: false,
|
|
66
|
-
commands: []
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const commands = [];
|
|
70
|
-
if (currentPostType !== 'wp_template') {
|
|
71
|
-
commands.push({
|
|
72
|
-
name: 'core/switch-to-template-focus',
|
|
73
|
-
label: sprintf(/* translators: %s: template title */
|
|
74
|
-
__('Edit template: %s'), decodeEntities(template.title)),
|
|
75
|
-
icon: layout,
|
|
76
|
-
callback: ({
|
|
77
|
-
close
|
|
78
|
-
}) => {
|
|
79
|
-
editTemplate();
|
|
80
|
-
close();
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
} else {
|
|
84
|
-
commands.push({
|
|
85
|
-
name: 'core/switch-to-page-focus',
|
|
86
|
-
label: __('Back to page'),
|
|
87
|
-
icon: page,
|
|
88
|
-
callback: ({
|
|
89
|
-
close
|
|
90
|
-
}) => {
|
|
91
|
-
setRenderingMode('template-locked');
|
|
92
|
-
close();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
isLoading: false,
|
|
98
|
-
commands
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function useManipulateDocumentCommands() {
|
|
102
|
-
const {
|
|
103
|
-
isLoaded,
|
|
104
|
-
record: template
|
|
105
|
-
} = useEditedEntityRecord();
|
|
106
|
-
const {
|
|
107
|
-
removeTemplate,
|
|
108
|
-
revertTemplate
|
|
109
|
-
} = useDispatch(editSiteStore);
|
|
110
|
-
const history = useHistory();
|
|
111
|
-
const isEditingPage = useSelect(select => select(editSiteStore).isPage() && select(editorStore).getCurrentPostType() !== 'wp_template', []);
|
|
112
|
-
if (!isLoaded) {
|
|
113
|
-
return {
|
|
114
|
-
isLoading: true,
|
|
115
|
-
commands: []
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
const commands = [];
|
|
119
|
-
if (isTemplateRevertable(template) && !isEditingPage) {
|
|
120
|
-
const label = template.type === TEMPLATE_POST_TYPE ? sprintf(/* translators: %s: template title */
|
|
121
|
-
__('Reset template: %s'), decodeEntities(template.title)) : sprintf(/* translators: %s: template part title */
|
|
122
|
-
__('Reset template part: %s'), decodeEntities(template.title));
|
|
123
|
-
commands.push({
|
|
124
|
-
name: 'core/reset-template',
|
|
125
|
-
label,
|
|
126
|
-
icon: isRTL() ? rotateRight : rotateLeft,
|
|
127
|
-
callback: ({
|
|
128
|
-
close
|
|
129
|
-
}) => {
|
|
130
|
-
revertTemplate(template);
|
|
131
|
-
close();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (isTemplateRemovable(template) && !isEditingPage) {
|
|
136
|
-
const label = template.type === TEMPLATE_POST_TYPE ? sprintf(/* translators: %s: template title */
|
|
137
|
-
__('Delete template: %s'), decodeEntities(template.title)) : sprintf(/* translators: %s: template part title */
|
|
138
|
-
__('Delete template part: %s'), decodeEntities(template.title));
|
|
139
|
-
commands.push({
|
|
140
|
-
name: 'core/remove-template',
|
|
141
|
-
label,
|
|
142
|
-
icon: trash,
|
|
143
|
-
callback: ({
|
|
144
|
-
close
|
|
145
|
-
}) => {
|
|
146
|
-
removeTemplate(template);
|
|
147
|
-
// Navigate to the template list
|
|
148
|
-
history.push({
|
|
149
|
-
postType: template.type
|
|
150
|
-
});
|
|
151
|
-
close();
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
isLoading: !isLoaded,
|
|
157
|
-
commands
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
export function useEditModeCommands() {
|
|
161
|
-
useCommandLoader({
|
|
162
|
-
name: 'core/edit-site/page-content-focus',
|
|
163
|
-
hook: usePageContentFocusCommands,
|
|
164
|
-
context: 'entity-edit'
|
|
165
|
-
});
|
|
166
|
-
useCommandLoader({
|
|
167
|
-
name: 'core/edit-site/manipulate-document',
|
|
168
|
-
hook: useManipulateDocumentCommands
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=use-edit-mode-commands.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","sprintf","isRTL","trash","rotateLeft","rotateRight","layout","page","useCommandLoader","decodeEntities","privateApis","routerPrivateApis","store","editorStore","editSiteStore","useEditedEntityRecord","isTemplateRemovable","isTemplateRevertable","unlock","TEMPLATE_POST_TYPE","useLink","useHistory","useLocation","usePageContentFocusCommands","record","template","params","canvas","isPage","templateId","currentPostType","select","_isPage","getCurrentPostType","getCurrentTemplateId","onClick","editTemplate","postType","postId","setRenderingMode","isLoading","commands","push","name","label","title","icon","callback","close","useManipulateDocumentCommands","isLoaded","removeTemplate","revertTemplate","history","isEditingPage","type","useEditModeCommands","hook","context"],"sources":["@wordpress/edit-site/src/hooks/commands/use-edit-mode-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, sprintf, isRTL } from '@wordpress/i18n';\nimport { trash, rotateLeft, rotateRight, layout, page } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport useEditedEntityRecord from '../../components/use-edited-entity-record';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { unlock } from '../../lock-unlock';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport { useLink } from '../../components/routes/link';\n\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nfunction usePageContentFocusCommands() {\n\tconst { record: template } = useEditedEntityRecord();\n\tconst { params } = useLocation();\n\tconst { canvas = 'view' } = params;\n\tconst { isPage, templateId, currentPostType } = useSelect( ( select ) => {\n\t\tconst { isPage: _isPage } = unlock( select( editSiteStore ) );\n\t\tconst { getCurrentPostType, getCurrentTemplateId } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tisPage: _isPage(),\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t\tcurrentPostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\tconst { onClick: editTemplate } = useLink( {\n\t\tpostType: 'wp_template',\n\t\tpostId: templateId,\n\t} );\n\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tif ( ! isPage || canvas !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( currentPostType !== 'wp_template' ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-template-focus',\n\t\t\tlabel: sprintf(\n\t\t\t\t/* translators: %s: template title */\n\t\t\t\t__( 'Edit template: %s' ),\n\t\t\t\tdecodeEntities( template.title )\n\t\t\t),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\teditTemplate();\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t} else {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-page-focus',\n\t\t\tlabel: __( 'Back to page' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetRenderingMode( 'template-locked' );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nfunction useManipulateDocumentCommands() {\n\tconst { isLoaded, record: template } = useEditedEntityRecord();\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst history = useHistory();\n\tconst isEditingPage = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editSiteStore ).isPage() &&\n\t\t\tselect( editorStore ).getCurrentPostType() !== 'wp_template',\n\t\t[]\n\t);\n\n\tif ( ! isLoaded ) {\n\t\treturn { isLoading: true, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( isTemplateRevertable( template ) && ! isEditingPage ) {\n\t\tconst label =\n\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: template title */\n\t\t\t\t\t\t__( 'Reset template: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Reset template part: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t );\n\t\tcommands.push( {\n\t\t\tname: 'core/reset-template',\n\t\t\tlabel,\n\t\t\ticon: isRTL() ? rotateRight : rotateLeft,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\trevertTemplate( template );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( isTemplateRemovable( template ) && ! isEditingPage ) {\n\t\tconst label =\n\t\t\ttemplate.type === TEMPLATE_POST_TYPE\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %s: template title */\n\t\t\t\t\t\t__( 'Delete template: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: template part title */\n\t\t\t\t\t\t__( 'Delete template part: %s' ),\n\t\t\t\t\t\tdecodeEntities( template.title )\n\t\t\t\t );\n\t\tcommands.push( {\n\t\t\tname: 'core/remove-template',\n\t\t\tlabel,\n\t\t\ticon: trash,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tremoveTemplate( template );\n\t\t\t\t// Navigate to the template list\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostType: template.type,\n\t\t\t\t} );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tisLoading: ! isLoaded,\n\t\tcommands,\n\t};\n}\n\nexport function useEditModeCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/page-content-focus',\n\t\thook: usePageContentFocusCommands,\n\t\tcontext: 'entity-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/manipulate-document',\n\t\thook: useManipulateDocumentCommands,\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,OAAO,EAAEC,KAAK,QAAQ,iBAAiB;AACpD,SAASC,KAAK,EAAEC,UAAU,EAAEC,WAAW,EAAEC,MAAM,EAAEC,IAAI,QAAQ,kBAAkB;AAC/E,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,WAAW,IAAIC,iBAAiB,QAAQ,mBAAmB;AACpE,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,aAAa,QAAQ,aAAa;AACpD,OAAOC,qBAAqB,MAAM,2CAA2C;AAC7E,OAAOC,mBAAmB,MAAM,mCAAmC;AACnE,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,kBAA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AAEZ,QAAQ,CAAC8B;QACpB,CAAE,CAAC;QACHP,KAAK,CAAC,CAAC;MACR;IACD,CAAE,CAAC;EACJ;EAEA,OAAO;IACNR,SAAS,EAAE,CAAEU,QAAQ;IACrBT;EACD,CAAC;AACF;AAEA,OAAO,SAASe,mBAAmBA,CAAA,EAAG;EACrChD,gBAAgB,CAAE;IACjBmC,IAAI,EAAE,mCAAmC;IACzCc,IAAI,EAAElC,2BAA2B;IACjCmC,OAAO,EAAE;EACV,CAAE,CAAC;EAEHlD,gBAAgB,CAAE;IACjBmC,IAAI,EAAE,oCAAoC;IAC1Cc,IAAI,EAAER;EACP,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect, useState, flushSync } from '@wordpress/element';
|
|
5
|
-
import { createQueue } from '@wordpress/priority-queue';
|
|
6
|
-
|
|
7
|
-
const blockPreviewQueue = createQueue();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Renders a component at the next idle time.
|
|
11
|
-
* @param {*} props
|
|
12
|
-
*/
|
|
13
|
-
export function Async( { children, placeholder } ) {
|
|
14
|
-
const [ shouldRender, setShouldRender ] = useState( false );
|
|
15
|
-
|
|
16
|
-
// In the future, we could try to use startTransition here, but currently
|
|
17
|
-
// react will batch all transitions, which means all previews will be
|
|
18
|
-
// rendered at the same time.
|
|
19
|
-
// https://react.dev/reference/react/startTransition#caveats
|
|
20
|
-
// > If there are multiple ongoing Transitions, React currently batches them
|
|
21
|
-
// > together. This is a limitation that will likely be removed in a future
|
|
22
|
-
// > release.
|
|
23
|
-
|
|
24
|
-
useEffect( () => {
|
|
25
|
-
const context = {};
|
|
26
|
-
blockPreviewQueue.add( context, () => {
|
|
27
|
-
// Synchronously run all renders so it consumes timeRemaining.
|
|
28
|
-
// See https://github.com/WordPress/gutenberg/pull/48238
|
|
29
|
-
flushSync( () => {
|
|
30
|
-
setShouldRender( true );
|
|
31
|
-
} );
|
|
32
|
-
} );
|
|
33
|
-
return () => {
|
|
34
|
-
blockPreviewQueue.cancel( context );
|
|
35
|
-
};
|
|
36
|
-
}, [] );
|
|
37
|
-
|
|
38
|
-
if ( ! shouldRender ) {
|
|
39
|
-
return placeholder;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return children;
|
|
43
|
-
}
|