@wordpress/edit-site 5.3.0 → 5.3.2
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/build/components/add-new-template/new-template-part.js +5 -4
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +5 -4
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +13 -2
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +3 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +6 -18
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +10 -12
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +9 -2
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/screen-border.js +0 -6
- package/build/components/global-styles/screen-border.js.map +1 -1
- package/build/components/global-styles/screen-effects.js +53 -0
- package/build/components/global-styles/screen-effects.js.map +1 -0
- package/build/components/global-styles/shadow-panel.js +1 -1
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +28 -2
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/layout/index.js +8 -4
- package/build/components/layout/index.js.map +1 -1
- package/build/components/navigation-inspector/index.js +8 -4
- package/build/components/navigation-inspector/index.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +4 -2
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/save-panel/index.js +77 -0
- package/build/components/save-panel/index.js.map +1 -0
- package/build/components/sidebar/index.js +25 -2
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +18 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/site-hub/index.js +9 -8
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +6 -4
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/store/actions.js +1 -27
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +8 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +40 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/private-selectors.js +18 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/selectors.js +0 -13
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +4 -4
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +4 -4
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +13 -3
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +3 -3
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +7 -20
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +10 -11
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +9 -3
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/screen-border.js +0 -5
- package/build-module/components/global-styles/screen-border.js.map +1 -1
- package/build-module/components/global-styles/screen-effects.js +35 -0
- package/build-module/components/global-styles/screen-effects.js.map +1 -0
- package/build-module/components/global-styles/shadow-panel.js +1 -1
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +26 -2
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/layout/index.js +6 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/navigation-inspector/index.js +8 -4
- package/build-module/components/navigation-inspector/index.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +4 -2
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/save-panel/index.js +63 -0
- package/build-module/components/save-panel/index.js.map +1 -0
- package/build-module/components/sidebar/index.js +22 -2
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +18 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/site-hub/index.js +8 -8
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +5 -4
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/store/actions.js +0 -23
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +5 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +29 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/private-selectors.js +11 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/selectors.js +0 -11
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +83 -26
- package/build-style/style.css +83 -26
- package/package.json +31 -31
- package/src/components/add-new-template/new-template-part.js +3 -2
- package/src/components/add-new-template/new-template.js +5 -3
- package/src/components/block-editor/editor-canvas.js +12 -2
- package/src/components/block-editor/index.js +4 -3
- package/src/components/block-editor/style.scss +1 -0
- package/src/components/editor/index.js +7 -46
- package/src/components/editor/style.scss +2 -2
- package/src/components/global-styles/block-preview-panel.js +8 -12
- package/src/components/global-styles/context-menu.js +14 -2
- package/src/components/global-styles/screen-border.js +0 -5
- package/src/components/global-styles/screen-effects.js +28 -0
- package/src/components/global-styles/shadow-panel.js +1 -1
- package/src/components/global-styles/style.scss +0 -4
- package/src/components/global-styles/ui.js +28 -4
- package/src/components/layout/index.js +6 -2
- package/src/components/layout/style.scss +25 -3
- package/src/components/navigation-inspector/index.js +5 -2
- package/src/components/navigation-inspector/navigation-menu.js +2 -2
- package/src/components/save-panel/index.js +65 -0
- package/src/components/save-panel/style.scss +5 -0
- package/src/components/sidebar/index.js +26 -6
- package/src/components/sidebar/style.scss +15 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +21 -1
- package/src/components/site-hub/index.js +7 -9
- package/src/components/site-hub/style.scss +1 -0
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +4 -3
- package/src/store/actions.js +0 -24
- package/src/store/index.js +5 -0
- package/src/store/private-actions.js +29 -0
- package/src/store/private-selectors.js +10 -0
- package/src/store/selectors.js +0 -11
- package/src/style.scss +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setCanvasMode = void 0;
|
|
7
|
+
|
|
8
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
9
|
+
|
|
10
|
+
var _preferences = require("@wordpress/preferences");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Action that switches the canvas mode.
|
|
18
|
+
*
|
|
19
|
+
* @param {?string} mode Canvas mode.
|
|
20
|
+
*/
|
|
21
|
+
const setCanvasMode = mode => _ref => {
|
|
22
|
+
let {
|
|
23
|
+
registry,
|
|
24
|
+
dispatch
|
|
25
|
+
} = _ref;
|
|
26
|
+
|
|
27
|
+
registry.dispatch(_blockEditor.store).__unstableSetEditorMode('edit');
|
|
28
|
+
|
|
29
|
+
dispatch({
|
|
30
|
+
type: 'SET_CANVAS_MODE',
|
|
31
|
+
mode
|
|
32
|
+
}); // Check if the block list view should be open by default.
|
|
33
|
+
|
|
34
|
+
if (mode === 'edit' && registry.select(_preferences.store).get('core/edit-site', 'showListViewByDefault')) {
|
|
35
|
+
dispatch.setIsListViewOpened(true);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.setCanvasMode = setCanvasMode;
|
|
40
|
+
//# sourceMappingURL=private-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/private-actions.js"],"names":["setCanvasMode","mode","registry","dispatch","blockEditorStore","__unstableSetEditorMode","type","select","preferencesStore","get","setIsListViewOpened"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,GACvBC,IAAF,IACA,QAA8B;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;;AAC7BD,EAAAA,QAAQ,CAACC,QAAT,CAAmBC,kBAAnB,EAAsCC,uBAAtC,CAA+D,MAA/D;;AACAF,EAAAA,QAAQ,CAAE;AACTG,IAAAA,IAAI,EAAE,iBADG;AAETL,IAAAA;AAFS,GAAF,CAAR,CAF6B,CAM7B;;AACA,MACCA,IAAI,KAAK,MAAT,IACAC,QAAQ,CACNK,MADF,CACUC,kBADV,EAEEC,GAFF,CAEO,gBAFP,EAEyB,uBAFzB,CAFD,EAKE;AACDN,IAAAA,QAAQ,CAACO,mBAAT,CAA8B,IAA9B;AACA;AACD,CAjBK","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Action that switches the canvas mode.\n *\n * @param {?string} mode Canvas mode.\n */\nexport const setCanvasMode =\n\t( mode ) =>\n\t( { registry, dispatch } ) => {\n\t\tregistry.dispatch( blockEditorStore ).__unstableSetEditorMode( 'edit' );\n\t\tdispatch( {\n\t\t\ttype: 'SET_CANVAS_MODE',\n\t\t\tmode,\n\t\t} );\n\t\t// Check if the block list view should be open by default.\n\t\tif (\n\t\t\tmode === 'edit' &&\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core/edit-site', 'showListViewByDefault' )\n\t\t) {\n\t\t\tdispatch.setIsListViewOpened( true );\n\t\t}\n\t};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCanvasMode = getCanvasMode;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns the current canvas mode.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} state Global application state.
|
|
12
|
+
*
|
|
13
|
+
* @return {string} Canvas mode.
|
|
14
|
+
*/
|
|
15
|
+
function getCanvasMode(state) {
|
|
16
|
+
return state.canvasMode;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=private-selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/private-selectors.js"],"names":["getCanvasMode","state","canvasMode"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,KAAxB,EAAgC;AACtC,SAAOA,KAAK,CAACC,UAAb;AACA","sourcesContent":["/**\n * Returns the current canvas mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Canvas mode.\n */\nexport function getCanvasMode( state ) {\n\treturn state.canvasMode;\n}\n"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.__experimentalGetInsertionPoint = __experimentalGetInsertionPoint;
|
|
9
9
|
exports.__experimentalGetPreviewDeviceType = __experimentalGetPreviewDeviceType;
|
|
10
|
-
exports.__unstableGetCanvasMode = __unstableGetCanvasMode;
|
|
11
10
|
exports.getCanUserCreateMedia = exports.__unstableGetPreference = void 0;
|
|
12
11
|
exports.getCurrentTemplateNavigationPanelSubMenu = getCurrentTemplateNavigationPanelSubMenu;
|
|
13
12
|
exports.getCurrentTemplateTemplateParts = void 0;
|
|
@@ -320,18 +319,6 @@ exports.getCurrentTemplateTemplateParts = getCurrentTemplateTemplateParts;
|
|
|
320
319
|
function getEditorMode(state) {
|
|
321
320
|
return __unstableGetPreference(state, 'editorMode');
|
|
322
321
|
}
|
|
323
|
-
/**
|
|
324
|
-
* Returns the current canvas mode.
|
|
325
|
-
*
|
|
326
|
-
* @param {Object} state Global application state.
|
|
327
|
-
*
|
|
328
|
-
* @return {string} Canvas mode.
|
|
329
|
-
*/
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
function __unstableGetCanvasMode(state) {
|
|
333
|
-
return state.canvasMode;
|
|
334
|
-
}
|
|
335
322
|
/**
|
|
336
323
|
* @deprecated
|
|
337
324
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["__unstableGetPreference","select","state","name","preferencesStore","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","blocks","getEditorMode","__unstableGetCanvasMode","canvasMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;A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AACA;AACA;;;AACO,SAASC,wCAAT,GAAoD;AAC1D,2BACC,uEADD,EAEC;AACC7D,IAAAA,KAAK,EAAE,KADR;AAECiC,IAAAA,OAAO,EAAE;AAFV,GAFD;AAOA;AAED;AACA;AACA;;;AACO,SAAS6B,4BAAT,GAAwC;AAC9C,2BAAY,2DAAZ,EAAyE;AACxE9D,IAAAA,KAAK,EAAE,KADiE;AAExEiC,IAAAA,OAAO,EAAE;AAF+D,GAAzE;AAIA;AAED;AACA;AACA;;;AACO,SAAS8B,kBAAT,GAA8B;AACpC,2BAAY,iDAAZ,EAA+D;AAC9D/D,IAAAA,KAAK,EAAE,KADuD;AAE9DiC,IAAAA,OAAO,EAAE;AAFqD,GAA/D;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/interface' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex, filterValue } =\n\t\tstate.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\treturn getFilteredTemplatePartBlocks( template.blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * Returns the current canvas mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Canvas mode.\n */\nexport function __unstableGetCanvasMode( state ) {\n\treturn state.canvasMode;\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["__unstableGetPreference","select","state","name","preferencesStore","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","blocks","getEditorMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AAC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AFV,GAFD;AAOA;AAED;AACA;AACA;;;AACO,SAAS2B,4BAAT,GAAwC;AAC9C,2BAAY,2DAAZ,EAAyE;AACxE5D,IAAAA,KAAK,EAAE,KADiE;AAExEiC,IAAAA,OAAO,EAAE;AAF+D,GAAzE;AAIA;AAED;AACA;AACA;;;AACO,SAAS4B,kBAAT,GAA8B;AACpC,2BAAY,iDAAZ,EAA+D;AAC9D7D,IAAAA,KAAK,EAAE,KADuD;AAE9DiC,IAAAA,OAAO,EAAE;AAFqD,GAA/D;AAIA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/interface' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex, filterValue } =\n\t\tstate.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\n}\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\treturn getFilteredTemplatePartBlocks( template.blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n"]}
|
|
@@ -19,6 +19,7 @@ import { useHistory } from '../routes';
|
|
|
19
19
|
import { store as editSiteStore } from '../../store';
|
|
20
20
|
import CreateTemplatePartModal from '../create-template-part-modal';
|
|
21
21
|
import { useExistingTemplateParts, getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from '../../utils/template-part-create';
|
|
22
|
+
import { unlock } from '../../experiments';
|
|
22
23
|
export default function NewTemplatePart(_ref) {
|
|
23
24
|
let {
|
|
24
25
|
postType,
|
|
@@ -34,8 +35,8 @@ export default function NewTemplatePart(_ref) {
|
|
|
34
35
|
saveEntityRecord
|
|
35
36
|
} = useDispatch(coreStore);
|
|
36
37
|
const {
|
|
37
|
-
|
|
38
|
-
} = useDispatch(editSiteStore);
|
|
38
|
+
setCanvasMode
|
|
39
|
+
} = unlock(useDispatch(editSiteStore));
|
|
39
40
|
const existingTemplateParts = useExistingTemplateParts();
|
|
40
41
|
|
|
41
42
|
async function createTemplatePart(_ref2) {
|
|
@@ -64,8 +65,7 @@ export default function NewTemplatePart(_ref) {
|
|
|
64
65
|
});
|
|
65
66
|
setIsModalOpen(false); // Switch to edit mode.
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
setCanvasMode('edit'); // Navigate to the created template part editor.
|
|
69
69
|
|
|
70
70
|
history.push({
|
|
71
71
|
postId: templatePart.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["useState","useDispatch","Button","__","store","noticesStore","coreStore","plus","useHistory","editSiteStore","CreateTemplatePartModal","useExistingTemplateParts","getUniqueTemplatePartTitle","getCleanTemplatePartSlug","NewTemplatePart","postType","showIcon","toggleProps","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["useState","useDispatch","Button","__","store","noticesStore","coreStore","plus","useHistory","editSiteStore","CreateTemplatePartModal","useExistingTemplateParts","getUniqueTemplatePartTitle","getCleanTemplatePartSlug","unlock","NewTemplatePart","postType","showIcon","toggleProps","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","setCanvasMode","existingTemplateParts","createTemplatePart","title","area","type","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","push","postId","id","error","errorMessage","message","code","labels","add_new"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AACA,SACCC,wBADD,EAECC,0BAFD,EAGCC,wBAHD,QAIO,kCAJP;AAKA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,eAAe,SAASC,eAAT,OAIX;AAAA,MAJqC;AACxCC,IAAAA,QADwC;AAExCC,IAAAA,QAAQ,GAAG,IAF6B;AAGxCC,IAAAA;AAHwC,GAIrC;AACH,QAAMC,OAAO,GAAGX,UAAU,EAA1B;AACA,QAAM,CAAEY,WAAF,EAAeC,cAAf,IAAkCrB,QAAQ,CAAE,KAAF,CAAhD;AACA,QAAM;AAAEsB,IAAAA;AAAF,MAAwBrB,WAAW,CAAEI,YAAF,CAAzC;AACA,Q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AK,CAACE,OADT,GAEGtC,EAAE,CACF,qDADE,CAHN;AAOAmB,MAAAA,iBAAiB,CAAEkB,YAAF,EAAgB;AAAEX,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AAEAR,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AACD;;AAED,SACC,8BACC,cAAC,MAAD,eACMH,WADN;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA,KAJF;AAKC,IAAA,IAAI,EAAGJ,QAAQ,GAAGV,IAAH,GAAU,IAL1B;AAMC,IAAA,KAAK,EAAGS,QAAQ,CAAC2B,MAAT,CAAgBC;AANzB,MAQG3B,QAAQ,GAAG,IAAH,GAAUD,QAAQ,CAAC2B,MAAT,CAAgBC,OARrC,CADD,EAWGxB,WAAW,IACZ,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGK;AAFZ,IAZF,CADD;AAoBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from '../../utils/template-part-create';\nimport { unlock } from '../../experiments';\n\nexport default function NewTemplatePart( {\n\tpostType,\n\tshowIcon = true,\n\ttoggleProps,\n} ) {\n\tconst history = useHistory();\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tasync function createTemplatePart( { title, area } ) {\n\t\tif ( ! title ) {\n\t\t\tcreateErrorNotice( __( 'Title is not defined.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: '',\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tsetIsModalOpen( false );\n\n\t\t\t// Switch to edit mode.\n\t\t\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template part editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: templatePart.id,\n\t\t\t\tpostType: templatePart.type,\n\t\t\t} );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tsetIsModalOpen( false );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\t{ ...toggleProps }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\tlabel={ postType.labels.add_new }\n\t\t\t>\n\t\t\t\t{ showIcon ? null : postType.labels.add_new }\n\t\t\t</Button>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setIsModalOpen( false ) }\n\t\t\t\t\tonCreate={ createTemplatePart }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -22,6 +22,7 @@ import AddCustomGenericTemplateModal from './add-custom-generic-template-modal';
|
|
|
22
22
|
import TemplateActionsLoadingScreen from './template-actions-loading-screen';
|
|
23
23
|
import { useHistory } from '../routes';
|
|
24
24
|
import { store as editSiteStore } from '../../store';
|
|
25
|
+
import { unlock } from '../../experiments';
|
|
25
26
|
const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'taxonomy', 'search', '404'];
|
|
26
27
|
const TEMPLATE_ICONS = {
|
|
27
28
|
'front-page': home,
|
|
@@ -58,8 +59,8 @@ export default function NewTemplate(_ref) {
|
|
|
58
59
|
} = useDispatch(noticesStore);
|
|
59
60
|
const {
|
|
60
61
|
setTemplate,
|
|
61
|
-
|
|
62
|
-
} = useDispatch(editSiteStore);
|
|
62
|
+
setCanvasMode
|
|
63
|
+
} = unlock(useDispatch(editSiteStore));
|
|
63
64
|
|
|
64
65
|
async function createTemplate(template) {
|
|
65
66
|
let isWPSuggestion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
@@ -105,8 +106,7 @@ export default function NewTemplate(_ref) {
|
|
|
105
106
|
|
|
106
107
|
setTemplate(newTemplate.id, newTemplate.slug); // Switch to edit mode.
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
setCanvasMode('edit'); // Navigate to the created template editor.
|
|
110
110
|
|
|
111
111
|
history.push({
|
|
112
112
|
postId: newTemplate.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["apiFetch","addQueryArgs","DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useState","useDispatch","store","coreStore","archive","blockMeta","category","home","list","media","notFound","page","plus","post","postAuthor","postDate","search","tag","layout","customGenericTemplateIcon","__","sprintf","noticesStore","AddCustomTemplateModal","useExistingTemplates","useDefaultTemplateTypes","useTaxonomiesMenuItems","usePostTypeMenuItems","useAuthorMenuItem","usePostTypeArchiveMenuItems","AddCustomGenericTemplateModal","TemplateActionsLoadingScreen","useHistory","editSiteStore","DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","single","index","author","taxonomy","date","attachment","NewTemplate","postType","toggleProps","showIcon","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","createErrorNotice","createSuccessNotice","setTemplate","__unstableSetCanvasMode","createTemplate","template","isWPSuggestion","title","description","slug","templatePrefix","templateContent","content","fallbackTemplate","path","is_custom","template_prefix","raw","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","labels","add_new","add_new_item","noArrow","map","onClick","icon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KA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,IAA1C,IACA/B,sBAAsB,CAACoF,OAAvB,CAAgCD,SAAS,CAACpD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMsB,gBAAgB,GAAG,CACxB,GAAGkB,mCADqB,EAExB,GAAG5E,2BAA2B,EAFN,EAGxB,GAAGgF,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOpB,gBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate, __unstableSetCanvasMode } =\n\t\tuseDispatch( editSiteStore );\n\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug, templatePrefix } = template;\n\t\t\tlet templateContent = template.content;\n\t\t\t// Try to find fallback content from existing templates.\n\t\t\tif ( ! templateContent ) {\n\t\t\t\tconst fallbackTemplate = await apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tis_custom: ! isWPSuggestion,\n\t\t\t\t\t\ttemplate_prefix: templatePrefix,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\ttemplateContent = fallbackTemplate.content.raw;\n\t\t\t}\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: templateContent,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\n\t\t\t// Switch to edit mode.\n\t\t\t__unstableSetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t} );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\ttext={ showIcon ? null : postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\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\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\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{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\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\t\t{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template.js"],"names":["apiFetch","addQueryArgs","DropdownMenu","MenuGroup","MenuItem","NavigableMenu","useState","useDispatch","store","coreStore","archive","blockMeta","category","home","list","media","notFound","page","plus","post","postAuthor","postDate","search","tag","layout","customGenericTemplateIcon","__","sprintf","noticesStore","AddCustomTemplateModal","useExistingTemplates","useDefaultTemplateTypes","useTaxonomiesMenuItems","usePostTypeMenuItems","useAuthorMenuItem","usePostTypeArchiveMenuItems","AddCustomGenericTemplateModal","TemplateActionsLoadingScreen","useHistory","editSiteStore","unlock","DEFAULT_TEMPLATE_SLUGS","TEMPLATE_ICONS","single","index","author","taxonomy","date","attachment","NewTemplate","postType","toggleProps","showIcon","showCustomTemplateModal","setShowCustomTemplateModal","showCustomGenericTemplateModal","setShowCustomGenericTemplateModal","entityForSuggestions","setEntityForSuggestions","isCreatingTemplate","setIsCreatingTemplate","history","saveEntityRecord","createErrorNotice","createSuccessNotice","setTemplate","setCanvasMode","createTemplate","template","isWPSuggestion","title","description","slug","templatePrefix","templateContent","content","fallbackTemplate","path","is_custom","template_prefix","raw","newTemplate","toString","status","is_wp_suggestion","throwOnError","id","push","postId","type","error","errorMessage","message","code","missingTemplates","useMissingTemplates","length","labels","add_new","add_new_item","noArrow","map","onClick","icon","existingTemplates","defaultTemplateTypes","existingTemplateSlugs","missingDefaultTemplates","filter","includes","onClickMenuItem","_entityForSuggestions","enhancedMissingDefaultTemplateTypes","defaultTaxonomiesMenuItems","taxonomiesMenuItems","defaultPostTypesMenuItems","postTypesMenuItems","authorMenuItem","forEach","menuItem","matchIndex","findIndex","sort","template1","template2","indexOf"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SACCC,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,aAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SACCC,OADD,EAECC,SAFD,EAGCC,QAHD,EAICC,IAJD,EAKCC,IALD,EAMCC,KAND,EAOCC,QAPD,EAQCC,IARD,EASCC,IATD,EAUCC,IAVD,EAWCC,UAXD,EAYCC,QAZD,EAaCC,MAbD,EAcCC,GAdD,EAeCC,MAAM,IAAIC,yBAfX,QAgBO,kBAhBP;AAiBA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASnB,KAAK,IAAIoB,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,sBAAP,MAAmC,6BAAnC;AACA,SACCC,oBADD,EAECC,uBAFD,EAGCC,sBAHD,EAICC,oBAJD,EAKCC,iBALD,EAMCC,2BAND,QAOO,SAPP;AAQA,OAAOC,6BAAP,MAA0C,qCAA1C;AACA,OAAOC,4BAAP,MAAyC,mCAAzC;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,SAAS9B,KAAK,IAAI+B,aAAlB,QAAuC,aAAvC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AAEA,MAAMC,sBAAsB,GAAG,CAC9B,YAD8B,EAE9B,QAF8B,EAG9B,MAH8B,EAI9B,OAJ8B,EAK9B,SAL8B,EAM9B,QAN8B,EAO9B,UAP8B,EAQ9B,MAR8B,EAS9B,KAT8B,EAU9B,UAV8B,EAW9B,QAX8B,EAY9B,KAZ8B,CAA/B;AAeA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;AACA,QAAKgD,UAAU,GAAG,CAAC,CAAnB,EAAuB;AACtBR,MAAAA,mCAAmC,CAAEQ,UAAF,CAAnC,GAAoDD,QAApD;AACA,KAFD,MAEO;AACNP,MAAAA,mCAAmC,CAACzB,IAApC,CAA0CgC,QAA1C;AACA;AACD,GArBD,EA1BC,CAgDD;;AACAP,EAAAA,mCAAmC,SAAnC,IAAAA,mCAAmC,WAAnC,YAAAA,mCAAmC,CAAEU,IAArC,CAA2C,CAAEC,SAAF,EAAaC,SAAb,KAA4B;AACtE,WACCnF,sBAAsB,CAACoF,OAAvB,CAAgCF,SAAS,CAACnD,IAA1C,IACA/B,sBAAsB,CAACoF,OAAvB,CAAgCD,SAAS,CAACpD,IAA1C,CAFD;AAIA,GALD;AAMA,QAAMsB,gBAAgB,GAAG,CACxB,GAAGkB,mCADqB,EAExB,GAAG7E,2BAA2B,EAFN,EAGxB,GAAGiF,kBAHqB,EAIxB,GAAGF,mBAJqB,CAAzB;AAMA,SAAOpB,gBAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tNavigableMenu,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tarchive,\n\tblockMeta,\n\tcategory,\n\thome,\n\tlist,\n\tmedia,\n\tnotFound,\n\tpage,\n\tplus,\n\tpost,\n\tpostAuthor,\n\tpostDate,\n\tsearch,\n\ttag,\n\tlayout as customGenericTemplateIcon,\n} from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport AddCustomTemplateModal from './add-custom-template-modal';\nimport {\n\tuseExistingTemplates,\n\tuseDefaultTemplateTypes,\n\tuseTaxonomiesMenuItems,\n\tusePostTypeMenuItems,\n\tuseAuthorMenuItem,\n\tusePostTypeArchiveMenuItems,\n} from './utils';\nimport AddCustomGenericTemplateModal from './add-custom-generic-template-modal';\nimport TemplateActionsLoadingScreen from './template-actions-loading-screen';\nimport { useHistory } from '../routes';\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../experiments';\n\nconst DEFAULT_TEMPLATE_SLUGS = [\n\t'front-page',\n\t'single',\n\t'page',\n\t'index',\n\t'archive',\n\t'author',\n\t'category',\n\t'date',\n\t'tag',\n\t'taxonomy',\n\t'search',\n\t'404',\n];\n\nconst TEMPLATE_ICONS = {\n\t'front-page': home,\n\tsingle: post,\n\tpage,\n\tarchive,\n\tsearch,\n\t404: notFound,\n\tindex: list,\n\tcategory,\n\tauthor: postAuthor,\n\ttaxonomy: blockMeta,\n\tdate: postDate,\n\ttag,\n\tattachment: media,\n};\n\nexport default function NewTemplate( {\n\tpostType,\n\ttoggleProps,\n\tshowIcon = true,\n} ) {\n\tconst [ showCustomTemplateModal, setShowCustomTemplateModal ] =\n\t\tuseState( false );\n\tconst [\n\t\tshowCustomGenericTemplateModal,\n\t\tsetShowCustomGenericTemplateModal,\n\t] = useState( false );\n\tconst [ entityForSuggestions, setEntityForSuggestions ] = useState( {} );\n\tconst [ isCreatingTemplate, setIsCreatingTemplate ] = useState( false );\n\n\tconst history = useHistory();\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\tconst { setTemplate, setCanvasMode } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\n\tasync function createTemplate( template, isWPSuggestion = true ) {\n\t\tif ( isCreatingTemplate ) {\n\t\t\treturn;\n\t\t}\n\t\tsetIsCreatingTemplate( true );\n\t\ttry {\n\t\t\tconst { title, description, slug, templatePrefix } = template;\n\t\t\tlet templateContent = template.content;\n\t\t\t// Try to find fallback content from existing templates.\n\t\t\tif ( ! templateContent ) {\n\t\t\t\tconst fallbackTemplate = await apiFetch( {\n\t\t\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', {\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\tis_custom: ! isWPSuggestion,\n\t\t\t\t\t\ttemplate_prefix: templatePrefix,\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t\ttemplateContent = fallbackTemplate.content.raw;\n\t\t\t}\n\t\t\tconst newTemplate = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tdescription,\n\t\t\t\t\t// Slugs need to be strings, so this is for template `404`\n\t\t\t\t\tslug: slug.toString(),\n\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\ttitle,\n\t\t\t\t\tcontent: templateContent,\n\t\t\t\t\t// This adds a post meta field in template that is part of `is_custom` value calculation.\n\t\t\t\t\tis_wp_suggestion: isWPSuggestion,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\t// Set template before navigating away to avoid initial stale value.\n\t\t\tsetTemplate( newTemplate.id, newTemplate.slug );\n\n\t\t\t// Switch to edit mode.\n\t\t\tsetCanvasMode( 'edit' );\n\n\t\t\t// Navigate to the created template editor.\n\t\t\thistory.push( {\n\t\t\t\tpostId: newTemplate.id,\n\t\t\t\tpostType: newTemplate.type,\n\t\t\t} );\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s: Title of the created template e.g: \"Category\".\n\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\ttitle\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while creating the template.' );\n\n\t\t\tcreateErrorNotice( errorMessage, {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} finally {\n\t\t\tsetIsCreatingTemplate( false );\n\t\t}\n\t}\n\n\tconst missingTemplates = useMissingTemplates(\n\t\tsetEntityForSuggestions,\n\t\tsetShowCustomTemplateModal\n\t);\n\tif ( ! missingTemplates.length ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-site-new-template-dropdown\"\n\t\t\t\ticon={ showIcon ? plus : null }\n\t\t\t\ttext={ showIcon ? null : postType.labels.add_new }\n\t\t\t\tlabel={ postType.labels.add_new_item }\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tnoArrow: false,\n\t\t\t\t} }\n\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isCreatingTemplate && (\n\t\t\t\t\t\t\t<TemplateActionsLoadingScreen />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<NavigableMenu className=\"edit-site-new-template-dropdown__popover\">\n\t\t\t\t\t\t\t<MenuGroup label={ postType.labels.add_new_item }>\n\t\t\t\t\t\t\t\t{ missingTemplates.map( ( template ) => {\n\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\t\tslug,\n\t\t\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\t\t\ticon,\n\t\t\t\t\t\t\t\t\t} = template;\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\ticon ||\n\t\t\t\t\t\t\t\t\t\t\t\tTEMPLATE_ICONS[ slug ] ||\n\t\t\t\t\t\t\t\t\t\t\t\tpost\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\t\t\tinfo={ description }\n\t\t\t\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t\t\t\t\tonClick={ () =>\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\t? onClick( template )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: createTemplate( template )\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{ title }\n\t\t\t\t\t\t\t\t\t\t</MenuItem>\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</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\ticon={ customGenericTemplateIcon }\n\t\t\t\t\t\t\t\t\ticonPosition=\"left\"\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tkey=\"custom-template\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowCustomGenericTemplateModal(\n\t\t\t\t\t\t\t\t\t\t\ttrue\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\t\t{ __( 'Custom template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</NavigableMenu>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t{ showCustomTemplateModal && (\n\t\t\t\t<AddCustomTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomTemplateModal( false ) }\n\t\t\t\t\tonSelect={ createTemplate }\n\t\t\t\t\tentityForSuggestions={ entityForSuggestions }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showCustomGenericTemplateModal && (\n\t\t\t\t<AddCustomGenericTemplateModal\n\t\t\t\t\tonClose={ () => setShowCustomGenericTemplateModal( false ) }\n\t\t\t\t\tcreateTemplate={ createTemplate }\n\t\t\t\t\tisCreatingTemplate={ isCreatingTemplate }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction useMissingTemplates(\n\tsetEntityForSuggestions,\n\tsetShowCustomTemplateModal\n) {\n\tconst existingTemplates = useExistingTemplates();\n\tconst defaultTemplateTypes = useDefaultTemplateTypes();\n\tconst existingTemplateSlugs = ( existingTemplates || [] ).map(\n\t\t( { slug } ) => slug\n\t);\n\tconst missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(\n\t\t( template ) =>\n\t\t\tDEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&\n\t\t\t! existingTemplateSlugs.includes( template.slug )\n\t);\n\tconst onClickMenuItem = ( _entityForSuggestions ) => {\n\t\tsetShowCustomTemplateModal( true );\n\t\tsetEntityForSuggestions( _entityForSuggestions );\n\t};\n\t// We need to replace existing default template types with\n\t// the create specific template functionality. The original\n\t// info (title, description, etc.) is preserved in the\n\t// used hooks.\n\tconst enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];\n\tconst { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =\n\t\tuseTaxonomiesMenuItems( onClickMenuItem );\n\tconst { defaultPostTypesMenuItems, postTypesMenuItems } =\n\t\tusePostTypeMenuItems( onClickMenuItem );\n\n\tconst authorMenuItem = useAuthorMenuItem( onClickMenuItem );\n\t[\n\t\t...defaultTaxonomiesMenuItems,\n\t\t...defaultPostTypesMenuItems,\n\t\tauthorMenuItem,\n\t].forEach( ( menuItem ) => {\n\t\tif ( ! menuItem ) {\n\t\t\treturn;\n\t\t}\n\t\tconst matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(\n\t\t\t( template ) => template.slug === menuItem.slug\n\t\t);\n\t\t// Some default template types might have been filtered above from\n\t\t// `missingDefaultTemplates` because they only check for the general\n\t\t// template. So here we either replace or append the item, augmented\n\t\t// with the check if it has available specific item to create a\n\t\t// template for.\n\t\tif ( matchIndex > -1 ) {\n\t\t\tenhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;\n\t\t} else {\n\t\t\tenhancedMissingDefaultTemplateTypes.push( menuItem );\n\t\t}\n\t} );\n\t// Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.\n\tenhancedMissingDefaultTemplateTypes?.sort( ( template1, template2 ) => {\n\t\treturn (\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template1.slug ) -\n\t\t\tDEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )\n\t\t);\n\t} );\n\tconst missingTemplates = [\n\t\t...enhancedMissingDefaultTemplateTypes,\n\t\t...usePostTypeArchiveMenuItems(),\n\t\t...postTypesMenuItems,\n\t\t...taxonomiesMenuItems,\n\t];\n\treturn missingTemplates;\n}\n"]}
|
|
@@ -5,11 +5,12 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
7
|
import { __experimentalUseResizeCanvas as useResizeCanvas, __unstableEditorStyles as EditorStyles, __unstableIframe as Iframe, __unstableUseMouseMoveTypingReset as useMouseMoveTypingReset, store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
|
-
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { unlock } from '../../experiments';
|
|
13
14
|
import { store as editSiteStore } from '../../store';
|
|
14
15
|
|
|
15
16
|
function EditorCanvas(_ref) {
|
|
@@ -20,12 +21,17 @@ function EditorCanvas(_ref) {
|
|
|
20
21
|
...props
|
|
21
22
|
} = _ref;
|
|
22
23
|
const {
|
|
24
|
+
canvasMode,
|
|
23
25
|
deviceType,
|
|
24
26
|
isZoomOutMode
|
|
25
27
|
} = useSelect(select => ({
|
|
26
28
|
deviceType: select(editSiteStore).__experimentalGetPreviewDeviceType(),
|
|
27
|
-
isZoomOutMode: select(blockEditorStore).__unstableGetEditorMode() === 'zoom-out'
|
|
29
|
+
isZoomOutMode: select(blockEditorStore).__unstableGetEditorMode() === 'zoom-out',
|
|
30
|
+
canvasMode: unlock(select(editSiteStore)).getCanvasMode()
|
|
28
31
|
}), []);
|
|
32
|
+
const {
|
|
33
|
+
setCanvasMode
|
|
34
|
+
} = unlock(useDispatch(editSiteStore));
|
|
29
35
|
const deviceStyles = useResizeCanvas(deviceType);
|
|
30
36
|
const mouseMoveTypingRef = useMouseMoveTypingReset();
|
|
31
37
|
return createElement(Iframe, _extends({
|
|
@@ -43,7 +49,11 @@ function EditorCanvas(_ref) {
|
|
|
43
49
|
ref: mouseMoveTypingRef,
|
|
44
50
|
name: "editor-canvas",
|
|
45
51
|
className: "edit-site-visual-editor__editor-canvas"
|
|
46
|
-
}, props
|
|
52
|
+
}, props, {
|
|
53
|
+
role: canvasMode === 'view' ? 'button' : undefined,
|
|
54
|
+
onClick: canvasMode === 'view' ? () => setCanvasMode('edit') : undefined,
|
|
55
|
+
readonly: canvasMode === 'view'
|
|
56
|
+
}), settings.svgFilters, children);
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
export default EditorCanvas;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/editor-canvas.js"],"names":["__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","store","blockEditorStore","useSelect","editSiteStore","EditorCanvas","enableResizing","settings","children","props","deviceType","isZoomOutMode","select","__experimentalGetPreviewDeviceType","__unstableGetEditorMode","deviceStyles","mouseMoveTypingRef","undefined","styles","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,SAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/editor-canvas.js"],"names":["__experimentalUseResizeCanvas","useResizeCanvas","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","__unstableUseMouseMoveTypingReset","useMouseMoveTypingReset","store","blockEditorStore","useSelect","useDispatch","unlock","editSiteStore","EditorCanvas","enableResizing","settings","children","props","canvasMode","deviceType","isZoomOutMode","select","__experimentalGetPreviewDeviceType","__unstableGetEditorMode","getCanvasMode","setCanvasMode","deviceStyles","mouseMoveTypingRef","undefined","styles","svgFilters"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,sBAAsB,IAAIC,YAF3B,EAGCC,gBAAgB,IAAIC,MAHrB,EAICC,iCAAiC,IAAIC,uBAJtC,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;;AAEA,SAASC,YAAT,OAA0E;AAAA,MAAnD;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,QAAlB;AAA4BC,IAAAA,QAA5B;AAAsC,OAAGC;AAAzC,GAAmD;AACzE,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,UAAd;AAA0BC,IAAAA;AAA1B,MAA4CX,SAAS,CACxDY,MAAF,KAAgB;AACfF,IAAAA,UAAU,EACTE,MAAM,CAAET,aAAF,CAAN,C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import {\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n\t__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../experiments';\nimport { store as editSiteStore } from '../../store';\n\nfunction EditorCanvas( { enableResizing, settings, children, ...props } ) {\n\tconst { canvasMode, deviceType, isZoomOutMode } = useSelect(\n\t\t( select ) => ( {\n\t\t\tdeviceType:\n\t\t\t\tselect( editSiteStore ).__experimentalGetPreviewDeviceType(),\n\t\t\tisZoomOutMode:\n\t\t\t\tselect( blockEditorStore ).__unstableGetEditorMode() ===\n\t\t\t\t'zoom-out',\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst mouseMoveTypingRef = useMouseMoveTypingReset();\n\treturn (\n\t\t<Iframe\n\t\t\tscale={ ( isZoomOutMode && 0.45 ) || undefined }\n\t\t\tframeSize={ isZoomOutMode ? 100 : undefined }\n\t\t\tstyle={ enableResizing ? {} : deviceStyles }\n\t\t\thead={\n\t\t\t\t<>\n\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t<style>{\n\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\tbody { position: relative; }`\n\t\t\t\t\t}</style>\n\t\t\t\t\t{ enableResizing && (\n\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t// Some themes will have `min-height: 100vh` for the root container,\n\t\t\t\t\t\t\t\t// which isn't a requirement in auto resize mode.\n\t\t\t\t\t\t\t\t`.is-root-container { min-height: 0 !important; }`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tref={ mouseMoveTypingRef }\n\t\t\tname=\"editor-canvas\"\n\t\t\tclassName=\"edit-site-visual-editor__editor-canvas\"\n\t\t\t{ ...props }\n\t\t\trole={ canvasMode === 'view' ? 'button' : undefined }\n\t\t\tonClick={\n\t\t\t\tcanvasMode === 'view'\n\t\t\t\t\t? () => setCanvasMode( 'edit' )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\treadonly={ canvasMode === 'view' }\n\t\t>\n\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t{ settings.svgFilters }\n\t\t\t{ children }\n\t\t</Iframe>\n\t);\n}\n\nexport default EditorCanvas;\n"]}
|
|
@@ -49,12 +49,12 @@ export default function BlockEditor() {
|
|
|
49
49
|
const {
|
|
50
50
|
getSettings,
|
|
51
51
|
getEditedPostType,
|
|
52
|
-
|
|
53
|
-
} = select(editSiteStore);
|
|
52
|
+
getCanvasMode
|
|
53
|
+
} = unlock(select(editSiteStore));
|
|
54
54
|
return {
|
|
55
55
|
storedSettings: getSettings(setIsInserterOpened),
|
|
56
56
|
templateType: getEditedPostType(),
|
|
57
|
-
canvasMode:
|
|
57
|
+
canvasMode: getCanvasMode()
|
|
58
58
|
};
|
|
59
59
|
}, [setIsInserterOpened]);
|
|
60
60
|
const settingsBlockPatterns = (_storedSettings$__exp = storedSettings.__experimentalAdditionalBlockPatterns) !== null && _storedSettings$__exp !== void 0 ? _storedSettings$__exp : // WP 6.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["classnames","useSelect","useDispatch","useMemo","useRef","useEntityBlockEditor","store","coreStore","BlockList","BlockInspector","BlockTools","__unstableUseClipboardHandler","useClipboardHandler","__unstableUseTypingObserver","useTypingObserver","BlockEditorKeyboardShortcuts","blockEditorStore","experiments","blockEditorExperiments","useMergeRefs","useViewportMatch","useResizeObserver","ReusableBlocksMenuItems","inserterMediaCategories","TemplatePartConverter","SidebarInspectorFill","editSiteStore","BackButton","ResizableEditor","EditorCanvas","StyleBook","unlock","ExperimentalBlockEditorProvider","LAYOUT","type","alignments","BlockEditor","setIsInserterOpened","storedSettings","templateType","canvasMode","select","getSettings","getEditedPostType","__unstableGetCanvasMode","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","settings","restStoredSettings","blocks","onInput","onChange","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","resizeObserver","sizes","isTemplatePart","hasBlocks","length","enableResizing","isViewMode","showBlockAppender","undefined","styleBook","event","target","currentTarget","height"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,oBAAhC;AACA,SAASC,oBAAT,EAA+BC,KAAK,IAAIC,SAAxC,QAAyD,sBAAzD;AACA,SACCC,SADD,EAECC,cAFD,EAGCC,UAHD,EAICC,6BAA6B,IAAIC,mBAJlC,EAKCC,2BAA2B,IAAIC,iBALhC,EAMCC,4BAND,EAOCT,KAAK,IAAIU,gBAPV,EAQCC,WAAW,IAAIC,sBARhB,QASO,yBATP;AAUA,SACCC,YADD,EAECC,gBAFD,EAGCC,iBAHD,QAIO,oBAJP;AAKA,SAASC,uBAAT,QAAwC,4BAAxC;AAEA;AACA;AACA;;AACA,OAAOC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n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport {\n\tuseMergeRefs,\n\tuseViewportMatch,\n\tuseResizeObserver,\n} from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from './inserter-media-categories';\nimport TemplatePartConverter from '../template-part-converter';\nimport { SidebarInspectorFill } from '../sidebar-edit-mode';\nimport { store as editSiteStore } from '../../store';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\nimport EditorCanvas from './editor-canvas';\nimport StyleBook from '../style-book';\nimport { unlock } from '../../experiments';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorExperiments );\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst { storedSettings, templateType, canvasMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedPostType, __unstableGetCanvasMode } =\n\t\t\t\tselect( editSiteStore );\n\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( setIsInserterOpened ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\tcanvasMode: __unstableGetCanvasMode(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpened ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tstoredSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tstoredSettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( templateType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, templateType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst settings = useMemo( () => {\n\t\tconst {\n\t\t\t__experimentalAdditionalBlockPatterns,\n\t\t\t__experimentalAdditionalBlockPatternCategories,\n\t\t\t...restStoredSettings\n\t\t} = storedSettings;\n\n\t\treturn {\n\t\t\t...restStoredSettings,\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t};\n\t}, [ storedSettings, blockPatterns, blockPatternCategories ] );\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [\n\t\tcontentRef,\n\t\tuseClipboardHandler(),\n\t\tuseTypingObserver(),\n\t] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\tconst hasBlocks = blocks.length !== 0;\n\tconst enableResizing =\n\t\tisTemplatePart &&\n\t\tcanvasMode !== 'view' &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport;\n\tconst isViewMode = canvasMode === 'view';\n\tconst showBlockAppender =\n\t\t( isTemplatePart && hasBlocks ) || isViewMode ? false : undefined;\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<TemplatePartConverter />\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t{ /* Potentially this could be a generic slot (e.g. EditorCanvas.Slot) if there are other uses for it. */ }\n\t\t\t<StyleBook.Slot>\n\t\t\t\t{ ( [ styleBook ] ) =>\n\t\t\t\t\tstyleBook ? (\n\t\t\t\t\t\t<div className=\"edit-site-visual-editor is-focus-mode\">\n\t\t\t\t\t\t\t<ResizableEditor enableResizing>\n\t\t\t\t\t\t\t\t{ styleBook }\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockTools\n\t\t\t\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t\t\t\t'is-focus-mode': isTemplatePart || !! styleBook,\n\t\t\t\t\t\t\t\t'is-view-mode': isViewMode,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\t\t\t\tclearSelectedBlock();\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<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t\t\t\t<BackButton />\n\t\t\t\t\t\t\t<ResizableEditor\n\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\theight={ sizes.height ?? '100%' }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditorCanvas\n\t\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t\t\t\t\t\treadonly={ canvasMode === 'view' }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ resizeObserver }\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\t\t\t\t\trenderAppender={ showBlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</EditorCanvas>\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</BlockTools>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</StyleBook.Slot>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/block-editor/index.js"],"names":["classnames","useSelect","useDispatch","useMemo","useRef","useEntityBlockEditor","store","coreStore","BlockList","BlockInspector","BlockTools","__unstableUseClipboardHandler","useClipboardHandler","__unstableUseTypingObserver","useTypingObserver","BlockEditorKeyboardShortcuts","blockEditorStore","experiments","blockEditorExperiments","useMergeRefs","useViewportMatch","useResizeObserver","ReusableBlocksMenuItems","inserterMediaCategories","TemplatePartConverter","SidebarInspectorFill","editSiteStore","BackButton","ResizableEditor","EditorCanvas","StyleBook","unlock","ExperimentalBlockEditorProvider","LAYOUT","type","alignments","BlockEditor","setIsInserterOpened","storedSettings","templateType","canvasMode","select","getSettings","getEditedPostType","getCanvasMode","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","settings","restStoredSettings","blocks","onInput","onChange","contentRef","mergedRefs","isMobileViewport","clearSelectedBlock","resizeObserver","sizes","isTemplatePart","hasBlocks","length","enableResizing","isViewMode","showBlockAppender","undefined","styleBook","event","target","currentTarget","height"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,OAAT,EAAkBC,MAAlB,QAAgC,oBAAhC;AACA,SAASC,oBAAT,EAA+BC,KAAK,IAAIC,SAAxC,QAAyD,sBAAzD;AACA,SACCC,SADD,EAECC,cAFD,EAGCC,UAHD,EAICC,6BAA6B,IAAIC,mBAJlC,EAKCC,2BAA2B,IAAIC,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AJ3B,OAMGqC,cANH,EAOC,cAAC,SAAD;AACC,MAAA,SAAS,EAAC,mDADX;AAEC,MAAA,oBAAoB,EAAG5C,MAFxB;AAGC,MAAA,cAAc,EAAGmD;AAHlB,MAPD,CAJD,CAfD,CARA;AAAA,GADH,CAZD,EA0DC,cAAC,uBAAD,OA1DD,CADD;AA8DA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo, useRef } from '@wordpress/element';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport {\n\tBlockList,\n\tBlockInspector,\n\tBlockTools,\n\t__unstableUseClipboardHandler as useClipboardHandler,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tBlockEditorKeyboardShortcuts,\n\tstore as blockEditorStore,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport {\n\tuseMergeRefs,\n\tuseViewportMatch,\n\tuseResizeObserver,\n} from '@wordpress/compose';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from './inserter-media-categories';\nimport TemplatePartConverter from '../template-part-converter';\nimport { SidebarInspectorFill } from '../sidebar-edit-mode';\nimport { store as editSiteStore } from '../../store';\nimport BackButton from './back-button';\nimport ResizableEditor from './resizable-editor';\nimport EditorCanvas from './editor-canvas';\nimport StyleBook from '../style-book';\nimport { unlock } from '../../experiments';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorExperiments );\n\nconst LAYOUT = {\n\ttype: 'default',\n\t// At the root level of the site editor, no alignments should be allowed.\n\talignments: [],\n};\n\nexport default function BlockEditor() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst { storedSettings, templateType, canvasMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, getEditedPostType, getCanvasMode } = unlock(\n\t\t\t\tselect( editSiteStore )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tstoredSettings: getSettings( setIsInserterOpened ),\n\t\t\t\ttemplateType: getEditedPostType(),\n\t\t\t\tcanvasMode: getCanvasMode(),\n\t\t\t};\n\t\t},\n\t\t[ setIsInserterOpened ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tstoredSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tstoredSettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tstoredSettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( templateType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, templateType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst settings = useMemo( () => {\n\t\tconst {\n\t\t\t__experimentalAdditionalBlockPatterns,\n\t\t\t__experimentalAdditionalBlockPatternCategories,\n\t\t\t...restStoredSettings\n\t\t} = storedSettings;\n\n\t\treturn {\n\t\t\t...restStoredSettings,\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t};\n\t}, [ storedSettings, blockPatterns, blockPatternCategories ] );\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\ttemplateType\n\t);\n\n\tconst contentRef = useRef();\n\tconst mergedRefs = useMergeRefs( [\n\t\tcontentRef,\n\t\tuseClipboardHandler(),\n\t\tuseTypingObserver(),\n\t] );\n\tconst isMobileViewport = useViewportMatch( 'small', '<' );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\n\tconst isTemplatePart = templateType === 'wp_template_part';\n\tconst hasBlocks = blocks.length !== 0;\n\tconst enableResizing =\n\t\tisTemplatePart &&\n\t\tcanvasMode !== 'view' &&\n\t\t// Disable resizing in mobile viewport.\n\t\t! isMobileViewport;\n\tconst isViewMode = canvasMode === 'view';\n\tconst showBlockAppender =\n\t\t( isTemplatePart && hasBlocks ) || isViewMode ? false : undefined;\n\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\tsettings={ settings }\n\t\t\tvalue={ blocks }\n\t\t\tonInput={ onInput }\n\t\t\tonChange={ onChange }\n\t\t\tuseSubRegistry={ false }\n\t\t>\n\t\t\t<TemplatePartConverter />\n\t\t\t<SidebarInspectorFill>\n\t\t\t\t<BlockInspector />\n\t\t\t</SidebarInspectorFill>\n\t\t\t{ /* Potentially this could be a generic slot (e.g. EditorCanvas.Slot) if there are other uses for it. */ }\n\t\t\t<StyleBook.Slot>\n\t\t\t\t{ ( [ styleBook ] ) =>\n\t\t\t\t\tstyleBook ? (\n\t\t\t\t\t\t<div className=\"edit-site-visual-editor is-focus-mode\">\n\t\t\t\t\t\t\t<ResizableEditor enableResizing>\n\t\t\t\t\t\t\t\t{ styleBook }\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockTools\n\t\t\t\t\t\t\tclassName={ classnames( 'edit-site-visual-editor', {\n\t\t\t\t\t\t\t\t'is-focus-mode': isTemplatePart || !! styleBook,\n\t\t\t\t\t\t\t\t'is-view-mode': isViewMode,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t__unstableContentRef={ contentRef }\n\t\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\t\t// Clear selected block when clicking on the gray background.\n\t\t\t\t\t\t\t\tif ( event.target === event.currentTarget ) {\n\t\t\t\t\t\t\t\t\tclearSelectedBlock();\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<BlockEditorKeyboardShortcuts.Register />\n\t\t\t\t\t\t\t<BackButton />\n\t\t\t\t\t\t\t<ResizableEditor\n\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\theight={ sizes.height ?? '100%' }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<EditorCanvas\n\t\t\t\t\t\t\t\t\tenableResizing={ enableResizing }\n\t\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\t\tcontentRef={ mergedRefs }\n\t\t\t\t\t\t\t\t\treadonly={ canvasMode === 'view' }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ resizeObserver }\n\t\t\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\t\t\tclassName=\"edit-site-block-editor__block-list wp-site-blocks\"\n\t\t\t\t\t\t\t\t\t\t__experimentalLayout={ LAYOUT }\n\t\t\t\t\t\t\t\t\t\trenderAppender={ showBlockAppender }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</EditorCanvas>\n\t\t\t\t\t\t\t</ResizableEditor>\n\t\t\t\t\t\t</BlockTools>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</StyleBook.Slot>\n\t\t\t<ReusableBlocksMenuItems />\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n"]}
|
|
@@ -5,12 +5,12 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
5
5
|
*/
|
|
6
6
|
import { useMemo } from '@wordpress/element';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import {
|
|
8
|
+
import { Notice } from '@wordpress/components';
|
|
9
9
|
import { EntityProvider, store as coreStore } from '@wordpress/core-data';
|
|
10
10
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
11
11
|
import { BlockContextProvider, BlockBreadcrumb, store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
12
|
import { InterfaceSkeleton, ComplementaryArea, store as interfaceStore } from '@wordpress/interface';
|
|
13
|
-
import { EditorNotices, EditorSnackbars
|
|
13
|
+
import { EditorNotices, EditorSnackbars } from '@wordpress/editor';
|
|
14
14
|
import { __ } from '@wordpress/i18n';
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -28,6 +28,7 @@ import { GlobalStylesRenderer } from '../global-styles-renderer';
|
|
|
28
28
|
import { GlobalStylesProvider } from '../global-styles/global-styles-provider';
|
|
29
29
|
import useTitle from '../routes/use-title';
|
|
30
30
|
import CanvasSpinner from '../canvas-spinner';
|
|
31
|
+
import { unlock } from '../../experiments';
|
|
31
32
|
const interfaceLabels = {
|
|
32
33
|
/* translators: accessibility text for the editor content landmark region. */
|
|
33
34
|
body: __('Editor content'),
|
|
@@ -54,7 +55,6 @@ export default function Editor() {
|
|
|
54
55
|
isRightSidebarOpen,
|
|
55
56
|
isInserterOpen,
|
|
56
57
|
isListViewOpen,
|
|
57
|
-
isSaveViewOpen,
|
|
58
58
|
showIconLabels
|
|
59
59
|
} = useSelect(select => {
|
|
60
60
|
const {
|
|
@@ -62,11 +62,10 @@ export default function Editor() {
|
|
|
62
62
|
getEditedPostId,
|
|
63
63
|
getEditedPostContext,
|
|
64
64
|
getEditorMode,
|
|
65
|
-
|
|
65
|
+
getCanvasMode,
|
|
66
66
|
isInserterOpened,
|
|
67
|
-
isListViewOpened
|
|
68
|
-
|
|
69
|
-
} = select(editSiteStore);
|
|
67
|
+
isListViewOpened
|
|
68
|
+
} = unlock(select(editSiteStore));
|
|
70
69
|
const {
|
|
71
70
|
hasFinishedResolution,
|
|
72
71
|
getEntityRecord
|
|
@@ -88,17 +87,15 @@ export default function Editor() {
|
|
|
88
87
|
context: getEditedPostContext(),
|
|
89
88
|
hasLoadedPost: postId ? hasFinishedResolution('getEntityRecord', ['postType', postType, postId]) : false,
|
|
90
89
|
editorMode: getEditorMode(),
|
|
91
|
-
canvasMode:
|
|
90
|
+
canvasMode: getCanvasMode(),
|
|
92
91
|
blockEditorMode: __unstableGetEditorMode(),
|
|
93
92
|
isInserterOpen: isInserterOpened(),
|
|
94
93
|
isListViewOpen: isListViewOpened(),
|
|
95
|
-
isSaveViewOpen: isSaveViewOpened(),
|
|
96
94
|
isRightSidebarOpen: getActiveComplementaryArea(editSiteStore.name),
|
|
97
95
|
showIconLabels: select(preferencesStore).get('core/edit-site', 'showIconLabels')
|
|
98
96
|
};
|
|
99
97
|
}, []);
|
|
100
98
|
const {
|
|
101
|
-
setIsSaveViewOpened,
|
|
102
99
|
setEditedPostContext
|
|
103
100
|
} = useDispatch(editSiteStore);
|
|
104
101
|
const isViewMode = canvasMode === 'view';
|
|
@@ -147,16 +144,6 @@ export default function Editor() {
|
|
|
147
144
|
sidebar: isEditMode && isRightSidebarOpen && createElement(ComplementaryArea.Slot, {
|
|
148
145
|
scope: "core/edit-site"
|
|
149
146
|
}),
|
|
150
|
-
actions: isEditMode && createElement(Fragment, null, isSaveViewOpen ? createElement(EntitiesSavedStates, {
|
|
151
|
-
close: () => setIsSaveViewOpened(false)
|
|
152
|
-
}) : createElement("div", {
|
|
153
|
-
className: "edit-site-editor__toggle-save-panel"
|
|
154
|
-
}, createElement(Button, {
|
|
155
|
-
variant: "secondary",
|
|
156
|
-
className: "edit-site-editor__toggle-save-panel-button",
|
|
157
|
-
onClick: () => setIsSaveViewOpened(true),
|
|
158
|
-
"aria-expanded": false
|
|
159
|
-
}, __('Open save panel')))),
|
|
160
147
|
footer: showBlockBreakcrumb && createElement(BlockBreadcrumb, {
|
|
161
148
|
rootLabelText: __('Template')
|
|
162
149
|
}),
|