@wordpress/edit-site 4.0.1 → 4.0.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 +4 -1
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/error-boundary/index.js +11 -27
- package/build/components/error-boundary/index.js.map +1 -1
- package/build/components/error-boundary/warning.js +70 -0
- package/build/components/error-boundary/warning.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +7 -27
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +5 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +21 -4
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/list/table.js +3 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-sidebar/navigation-toggle/index.js +15 -4
- package/build/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build/components/routes/redirect-to-homepage.js +22 -3
- package/build/components/routes/redirect-to-homepage.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -11
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build/index.js +15 -1
- package/build/index.js.map +1 -1
- package/build/store/actions.js +191 -155
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -3
- package/build/store/index.js.map +1 -1
- package/build/store/selectors.js +3 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +4 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/error-boundary/index.js +9 -26
- package/build-module/components/error-boundary/index.js.map +1 -1
- package/build-module/components/error-boundary/warning.js +60 -0
- package/build-module/components/error-boundary/warning.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +8 -28
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +6 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +20 -4
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/list/table.js +2 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js +12 -4
- package/build-module/components/navigation-sidebar/navigation-toggle/index.js.map +1 -1
- package/build-module/components/routes/redirect-to-homepage.js +22 -3
- package/build-module/components/routes/redirect-to-homepage.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -12
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js +4 -1
- package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
- package/build-module/index.js +13 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +170 -145
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/selectors.js +3 -2
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +11 -10
- package/build-style/style.css +11 -10
- package/package.json +18 -18
- package/src/components/add-new-template/new-template-part.js +7 -1
- package/src/components/error-boundary/index.js +11 -28
- package/src/components/error-boundary/warning.js +59 -0
- package/src/components/global-styles/navigation-button.js +6 -25
- package/src/components/global-styles/typography-panel.js +12 -5
- package/src/components/global-styles/use-global-styles-output.js +19 -3
- package/src/components/list/table.js +5 -2
- package/src/components/navigation-sidebar/navigation-toggle/index.js +13 -4
- package/src/components/navigation-sidebar/navigation-toggle/style.scss +32 -31
- package/src/components/routes/redirect-to-homepage.js +27 -4
- package/src/components/secondary-sidebar/list-view-sidebar.js +1 -11
- package/src/components/template-part-converter/convert-to-template-part.js +6 -1
- package/src/index.js +17 -1
- package/src/store/actions.js +161 -205
- package/src/store/index.js +0 -2
- package/src/store/selectors.js +3 -0
- package/src/store/test/actions.js +186 -92
- package/src/store/test/selectors.js +8 -1
package/build/store/index.js
CHANGED
|
@@ -9,8 +9,6 @@ exports.storeConfig = exports.store = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _data = require("@wordpress/data");
|
|
11
11
|
|
|
12
|
-
var _dataControls = require("@wordpress/data-controls");
|
|
13
|
-
|
|
14
12
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
15
13
|
|
|
16
14
|
var actions = _interopRequireWildcard(require("./actions"));
|
|
@@ -34,7 +32,6 @@ const storeConfig = {
|
|
|
34
32
|
reducer: _reducer.default,
|
|
35
33
|
actions,
|
|
36
34
|
selectors,
|
|
37
|
-
controls: _dataControls.controls,
|
|
38
35
|
persist: ['preferences']
|
|
39
36
|
};
|
|
40
37
|
exports.storeConfig = storeConfig;
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["storeConfig","reducer","actions","selectors","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["storeConfig","reducer","actions","selectors","persist","store","STORE_NAME"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMO,MAAMA,WAAW,GAAG;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA,SAH0B;AAI1BC,EAAAA,OAAO,EAAE,CAAE,aAAF;AAJiB,CAApB;;AAOA,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8BN,WAA9B,CAAd,C,CAEP;AACA;;;AACA,yBAAeM,qBAAf,EAA2BN,WAA3B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\nexport const storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n\tpersist: [ 'preferences' ],\n};\n\nexport const store = createReduxStore( STORE_NAME, storeConfig );\n\n// Once we build a more generic persistence plugin that works across types of stores\n// we'd be able to replace this with a register call.\nregisterStore( STORE_NAME, storeConfig );\n"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -118,7 +118,8 @@ const getSettings = (0, _rememo.default)((state, setIsInserterOpen) => {
|
|
|
118
118
|
focusMode: isFeatureActive(state, 'focusMode'),
|
|
119
119
|
hasFixedToolbar: isFeatureActive(state, 'fixedToolbar'),
|
|
120
120
|
__experimentalSetIsInserterOpened: setIsInserterOpen,
|
|
121
|
-
__experimentalReusableBlocks: getReusableBlocks(state)
|
|
121
|
+
__experimentalReusableBlocks: getReusableBlocks(state),
|
|
122
|
+
__experimentalPreferPatternsOnRoot: 'wp_template' === getEditedPostType(state)
|
|
122
123
|
};
|
|
123
124
|
const canUserCreateMedia = getCanUserCreateMedia(state);
|
|
124
125
|
|
|
@@ -144,7 +145,7 @@ const getSettings = (0, _rememo.default)((state, setIsInserterOpen) => {
|
|
|
144
145
|
};
|
|
145
146
|
|
|
146
147
|
return settings;
|
|
147
|
-
}, state => [getCanUserCreateMedia(state), state.settings, isFeatureActive(state, 'focusMode'), isFeatureActive(state, 'fixedToolbar'), getReusableBlocks(state)]);
|
|
148
|
+
}, state => [getCanUserCreateMedia(state), state.settings, isFeatureActive(state, 'focusMode'), isFeatureActive(state, 'fixedToolbar'), getReusableBlocks(state), getEditedPostType(state)]);
|
|
148
149
|
/**
|
|
149
150
|
* Returns the current home template ID.
|
|
150
151
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["isFeatureActive","state","feature","preferences","features","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","select","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","homeTemplateId","getCurrentEditedPost","editedPost","getEditedPostType","type","getEditedPostId","id","getPage","page","getNavigationPanelActiveMenu","navigationPanel","menu","getCurrentTemplateNavigationPanelSubMenu","templateType","templateId","template","getEntityRecord","MENU_ROOT","find","submenu","area","MENU_TEMPLATE_PARTS","templates","showOnFront","getEditedEntityRecord","show_on_front","slug","MENU_TEMPLATES_UNUSED","isNavigationOpened","isOpen","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","getCurrentTemplateTemplateParts","templateParts","templatePartsById","templatePart","blocks","filter","block","map","attributes","theme","templatePartId","getEditorMode","editorMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AAxBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;;AAYA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,KAA1B,EAAiCC,OAAjC,EAA2C;AACjD,SAAO,iBAAKD,KAAK,CAACE,WAAN,CAAkBC,QAAvB,EAAiC,CAAEF,OAAF,CAAjC,EAA8C,KAA9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,kCAAT,CAA6CJ,KAA7C,EAAqD;AAC3D,SAAOA,KAAK,CAACK,UAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,kCAA0BC,MAAF,IAAc,MAC1EA,MAAM,CAAEC,eAAF,CAAN,CAAwBC,OAAxB,CAAiC,QAAjC,EAA2C,OAA3C,CADoC,CAA9B;AAIP;AAC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,KAAP;AAIA,GAbK,EAcLD,MAdK,CAcG;AAAA,QAAE;AAAEF,MAAAA;AAAF,KAAF;AAAA,WAAwB,CAAC,CAAEA,YAA3B;AAAA,GAdH,CAAP;AAeA,CAjC6C,CAAxC;AAoCP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASQ,aAAT,CAAwBjF,KAAxB,EAAgC;AACtC,SAAOA,KAAK,CAACE,WAAN,CAAkBgF,UAAlB,IAAgC,QAAvC;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, map, keyBy } from 'lodash';\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_TEMPLATES_UNUSED,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../components/navigation-sidebar/navigation-panel/constants';\nimport {\n\tgetTemplateLocation,\n\tisTemplateSuperseded,\n} from '../components/navigation-sidebar/navigation-panel/template-hierarchy';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\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( ( select ) => () =>\n\tselect( 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: isFeatureActive( state, 'focusMode' ),\n\t\t\thasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( 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\tisFeatureActive( state, 'focusMode' ),\n\t\tisFeatureActive( state, 'fixedToolbar' ),\n\t\tgetReusableBlocks( state ),\n\t]\n);\n\n/**\n * Returns the current home template ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Home template ID.\n */\nexport function getHomeTemplateId( state ) {\n\treturn state.homeTemplateId;\n}\n\nfunction getCurrentEditedPost( state ) {\n\treturn state.editedPost;\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 getCurrentEditedPost( state ).type;\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 getCurrentEditedPost( state ).id;\n}\n\n/**\n * Returns the current page object.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn getCurrentEditedPost( state ).page;\n}\n\n/**\n * Returns the active menu in the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Active menu.\n */\nexport function getNavigationPanelActiveMenu( state ) {\n\treturn state.navigationPanel.menu;\n}\n\n/**\n * Returns the current template or template part's corresponding\n * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} The current template or template part's sub menu.\n */\nexport const getCurrentTemplateNavigationPanelSubMenu = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = templateId\n\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\ttemplateId\n\t\t\t )\n\t\t\t: null;\n\n\t\tif ( ! template ) {\n\t\t\treturn MENU_ROOT;\n\t\t}\n\n\t\tif ( 'wp_template_part' === templateType ) {\n\t\t\treturn (\n\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t\t\t( submenu ) => submenu.area === template?.area\n\t\t\t\t)?.menu || MENU_TEMPLATE_PARTS\n\t\t\t);\n\t\t}\n\n\t\tconst templates = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\tconst showOnFront = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t).show_on_front;\n\n\t\tif (\n\t\t\tisTemplateSuperseded(\n\t\t\t\ttemplate.slug,\n\t\t\t\tmap( templates, 'slug' ),\n\t\t\t\tshowOnFront\n\t\t\t)\n\t\t) {\n\t\t\treturn MENU_TEMPLATES_UNUSED;\n\t\t}\n\n\t\treturn getTemplateLocation( template.slug );\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the navigation panel should be open; false if closed.\n */\nexport function isNavigationOpened( state ) {\n\treturn state.navigationPanel.isOpen;\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 {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.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 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(\n\t\t\tcoreDataStore\n\t\t).getEntityRecords( 'postType', 'wp_template_part', { per_page: -1 } );\n\t\tconst templatePartsById = keyBy(\n\t\t\ttemplateParts,\n\t\t\t( templatePart ) => templatePart.id\n\t\t);\n\n\t\treturn ( template.blocks ?? [] )\n\t\t\t.filter( ( block ) => isTemplatePart( block ) )\n\t\t\t.map( ( block ) => {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\treturn {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( { templatePart } ) => !! templatePart );\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 state.preferences.editorMode || 'visual';\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["isFeatureActive","state","feature","preferences","features","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","select","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","homeTemplateId","getCurrentEditedPost","editedPost","type","getEditedPostId","id","getPage","page","getNavigationPanelActiveMenu","navigationPanel","menu","getCurrentTemplateNavigationPanelSubMenu","templateType","templateId","template","getEntityRecord","MENU_ROOT","find","submenu","area","MENU_TEMPLATE_PARTS","templates","showOnFront","getEditedEntityRecord","show_on_front","slug","MENU_TEMPLATES_UNUSED","isNavigationOpened","isOpen","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","getCurrentTemplateTemplateParts","templateParts","templatePartsById","templatePart","blocks","filter","block","map","attributes","theme","templatePartId","getEditorMode","editorMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AAxBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;;AAYA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,KAA1B,EAAiCC,OAAjC,EAA2C;AACjD,SAAO,iBAAKD,KAAK,CAACE,WAAN,CAAkBC,QAAvB,EAAiC,CAAEF,OAAF,CAAjC,EAA8C,KAA9C,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,kCAAT,CAA6CJ,KAA7C,EAAqD;AAC3D,SAAOA,KAAK,CAACK,UAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,kCAA0BC,MAAF,IAAc,MAC1EA,MAAM,CAAEC,eAAF,CAAN,CAAwBC,OAAxB,CAAiC,QAAjC,EAA2C,OAA3C,CADoC,CAA9B;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,iBAAiB,GAAG,kCAA0BH,MAAF,IAAc,MAAM;AAC5E,QAAMI,KAAK,GAAGC,kBAASC,EAAT,KAAgB,KAA9B;AACA,SAAOF,KAAK,GACTJ,MAAM,CAAEC,eAAF,CAAN,CAAwBM,gBAAxB,CAA0C,UAA1C,EAAsD,UAAtD,EAAkE;AAClEC,IAAAA,QAAQ,EAAE,CAAC;AADuD,GAAlE,CADS,GAIT,EAJH;AAKA,CAPgC,CAA1B;AASP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,WAAW,GAAG,qBAC1B,CAAEhB,KAAF,EAASiB,iBAAT,KAAgC;AAC/B,QAAMC,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} from 'lodash';\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { isTemplatePart } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tMENU_ROOT,\n\tMENU_TEMPLATE_PARTS,\n\tMENU_TEMPLATES_UNUSED,\n\tTEMPLATE_PARTS_SUB_MENUS,\n} from '../components/navigation-sidebar/navigation-panel/constants';\nimport {\n\tgetTemplateLocation,\n\tisTemplateSuperseded,\n} from '../components/navigation-sidebar/navigation-panel/template-hierarchy';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\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( ( select ) => () =>\n\tselect( 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: isFeatureActive( state, 'focusMode' ),\n\t\t\thasFixedToolbar: isFeatureActive( state, 'fixedToolbar' ),\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\tisFeatureActive( state, 'focusMode' ),\n\t\tisFeatureActive( state, 'fixedToolbar' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * Returns the current home template ID.\n *\n * @param {Object} state Global application state.\n *\n * @return {number?} Home template ID.\n */\nexport function getHomeTemplateId( state ) {\n\treturn state.homeTemplateId;\n}\n\nfunction getCurrentEditedPost( state ) {\n\treturn state.editedPost;\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 getCurrentEditedPost( state ).type;\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 getCurrentEditedPost( state ).id;\n}\n\n/**\n * Returns the current page object.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn getCurrentEditedPost( state ).page;\n}\n\n/**\n * Returns the active menu in the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Active menu.\n */\nexport function getNavigationPanelActiveMenu( state ) {\n\treturn state.navigationPanel.menu;\n}\n\n/**\n * Returns the current template or template part's corresponding\n * navigation panel's sub menu, to be used with `openNavigationPanelToMenu`.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} The current template or template part's sub menu.\n */\nexport const getCurrentTemplateNavigationPanelSubMenu = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = templateId\n\t\t\t? select( coreDataStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplateType,\n\t\t\t\t\ttemplateId\n\t\t\t )\n\t\t\t: null;\n\n\t\tif ( ! template ) {\n\t\t\treturn MENU_ROOT;\n\t\t}\n\n\t\tif ( 'wp_template_part' === templateType ) {\n\t\t\treturn (\n\t\t\t\tTEMPLATE_PARTS_SUB_MENUS.find(\n\t\t\t\t\t( submenu ) => submenu.area === template?.area\n\t\t\t\t)?.menu || MENU_TEMPLATE_PARTS\n\t\t\t);\n\t\t}\n\n\t\tconst templates = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template'\n\t\t);\n\t\tconst showOnFront = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t).show_on_front;\n\n\t\tif (\n\t\t\tisTemplateSuperseded(\n\t\t\t\ttemplate.slug,\n\t\t\t\tmap( templates, 'slug' ),\n\t\t\t\tshowOnFront\n\t\t\t)\n\t\t) {\n\t\t\treturn MENU_TEMPLATES_UNUSED;\n\t\t}\n\n\t\treturn getTemplateLocation( template.slug );\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the navigation panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the navigation panel should be open; false if closed.\n */\nexport function isNavigationOpened( state ) {\n\treturn state.navigationPanel.isOpen;\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 {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.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 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(\n\t\t\tcoreDataStore\n\t\t).getEntityRecords( 'postType', 'wp_template_part', { per_page: -1 } );\n\t\tconst templatePartsById = keyBy(\n\t\t\ttemplateParts,\n\t\t\t( templatePart ) => templatePart.id\n\t\t);\n\n\t\treturn ( template.blocks ?? [] )\n\t\t\t.filter( ( block ) => isTemplatePart( block ) )\n\t\t\t.map( ( block ) => {\n\t\t\t\tconst {\n\t\t\t\t\tattributes: { theme, slug },\n\t\t\t\t} = block;\n\t\t\t\tconst templatePartId = `${ theme }//${ slug }`;\n\t\t\t\tconst templatePart = templatePartsById[ templatePartId ];\n\n\t\t\t\treturn {\n\t\t\t\t\ttemplatePart,\n\t\t\t\t\tblock,\n\t\t\t\t};\n\t\t\t} )\n\t\t\t.filter( ( { templatePart } ) => !! templatePart );\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 state.preferences.editorMode || 'visual';\n}\n"]}
|
|
@@ -50,8 +50,11 @@ export default function NewTemplatePart(_ref) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
try {
|
|
53
|
+
// Currently template parts only allow latin chars.
|
|
54
|
+
// Fallback slug will receive suffix by default.
|
|
55
|
+
const cleanSlug = kebabCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
|
|
53
56
|
const templatePart = await saveEntityRecord('postType', 'wp_template_part', {
|
|
54
|
-
slug:
|
|
57
|
+
slug: cleanSlug,
|
|
55
58
|
title,
|
|
56
59
|
content: '',
|
|
57
60
|
area
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["kebabCase","useState","useSelect","useDispatch","Button","__","store","noticesStore","coreStore","useHistory","CreateTemplatePartModal","NewTemplatePart","postType","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","getLastEntitySaveError","createTemplatePart","title","area","type","templatePart","slug","content","lastEntitySaveError","id","push","postId","error","errorMessage","message","code","labels","add_new"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,WAA3B;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AAEA,eAAe,SAASC,eAAT,OAAyC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACvD,QAAMC,OAAO,GAAGJ,UAAU,EAA1B;AACA,QAAM,CAAEK,WAAF,EAAeC,cAAf,IAAkCd,QAAQ,CAAE,KAAF,CAAhD;AACA,QAAM;AAAEe,IAAAA;AAAF,MAAwBb,WAAW,CAAEI,YAAF,CAAzC;AACA,QAAM;AAAEU,IAAAA;AAAF,MAAuBd,WAAW,CAAEK,SAAF,CAAxC;AACA,QAAM;AAAEU,IAAAA;AAAF,MAA6BhB,SAAS,CAAEM,SAAF,CAA5C;;AAEA,iBAAeW,kBAAf,QAAqD;AAAA,QAAlB;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,KAAkB;;AACpD,QAAK,CAAED,KAAP,EAAe;AACdJ,MAAAA,iBAAiB,CAAEX,EAAE,CAAE,uBAAF,CAAJ,EAAiC;AACjDiB,QAAAA,IAAI,EAAE;AAD2C,OAAjC,CAAjB;AAGA;AACA;;AAED,QAAI;AACH,YAAMC,YAAY,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/add-new-template/new-template-part.js"],"names":["kebabCase","useState","useSelect","useDispatch","Button","__","store","noticesStore","coreStore","useHistory","CreateTemplatePartModal","NewTemplatePart","postType","history","isModalOpen","setIsModalOpen","createErrorNotice","saveEntityRecord","getLastEntitySaveError","createTemplatePart","title","area","type","cleanSlug","replace","templatePart","slug","content","lastEntitySaveError","id","push","postId","error","errorMessage","message","code","labels","add_new"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,SAAT,EAAoBC,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AmB,GAAGV,sBAAsB,CACjD,UADiD,EAEjD,kBAFiD,EAGjDO,YAAY,CAACI,EAHoC,CAAlD;;AAKA,UAAKD,mBAAL,EAA2B;AAC1B,cAAMA,mBAAN;AACA;;AAEDb,MAAAA,cAAc,CAAE,KAAF,CAAd,CA3BG,CA6BH;;AACAF,MAAAA,OAAO,CAACiB,IAAR,CAAc;AACbC,QAAAA,MAAM,EAAEN,YAAY,CAACI,EADR;AAEbjB,QAAAA,QAAQ,EAAEa,YAAY,CAACH;AAFV,OAAd,EA9BG,CAmCH;AACA,KApCD,CAoCE,OAAQU,KAAR,EAAgB;AACjB,YAAMC,YAAY,GACjBD,KAAK,CAACE,OAAN,IAAiBF,KAAK,CAACG,IAAN,KAAe,eAAhC,GACGH,KAAK,CAACE,OADT,GAEG7B,EAAE,CACF,qDADE,CAHN;AAOAW,MAAAA,iBAAiB,CAAEiB,YAAF,EAAgB;AAAEX,QAAAA,IAAI,EAAE;AAAR,OAAhB,CAAjB;AAEAP,MAAAA,cAAc,CAAE,KAAF,CAAd;AACA;AACD;;AAED,SACC,8BACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfA,MAAAA,cAAc,CAAE,IAAF,CAAd;AACA;AAJF,KAMGH,QAAQ,CAACwB,MAAT,CAAgBC,OANnB,CADD,EASGvB,WAAW,IACZ,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,KAAF,CADlC;AAEC,IAAA,QAAQ,EAAGI;AAFZ,IAVF,CADD;AAkBA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useSelect, 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';\n\n/**\n * Internal dependencies\n */\nimport { useHistory } from '../routes';\nimport CreateTemplatePartModal from '../create-template-part-modal';\n\nexport default function NewTemplatePart( { postType } ) {\n\tconst history = useHistory();\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst { getLastEntitySaveError } = useSelect( coreStore );\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\t// Currently template parts only allow latin chars.\n\t\t\t// Fallback slug will receive suffix by default.\n\t\t\tconst cleanSlug =\n\t\t\t\tkebabCase( title ).replace( /[^\\w-]+/g, '' ) ||\n\t\t\t\t'wp-custom-part';\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,\n\t\t\t\t\tcontent: '',\n\t\t\t\t\tarea,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst lastEntitySaveError = getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePart.id\n\t\t\t);\n\t\t\tif ( lastEntitySaveError ) {\n\t\t\t\tthrow lastEntitySaveError;\n\t\t\t}\n\n\t\t\tsetIsModalOpen( false );\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\tvariant=\"primary\"\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetIsModalOpen( true );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ 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"]}
|
|
@@ -5,22 +5,11 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
*/
|
|
6
6
|
import { Component } from '@wordpress/element';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function CopyButton(_ref) {
|
|
13
|
-
let {
|
|
14
|
-
text,
|
|
15
|
-
children
|
|
16
|
-
} = _ref;
|
|
17
|
-
const ref = useCopyToClipboard(text);
|
|
18
|
-
return createElement(Button, {
|
|
19
|
-
variant: "secondary",
|
|
20
|
-
ref: ref
|
|
21
|
-
}, children);
|
|
22
|
-
}
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
23
11
|
|
|
12
|
+
import ErrorBoundaryWarning from './warning';
|
|
24
13
|
export default class ErrorBoundary extends Component {
|
|
25
14
|
constructor() {
|
|
26
15
|
super(...arguments);
|
|
@@ -49,17 +38,11 @@ export default class ErrorBoundary extends Component {
|
|
|
49
38
|
return this.props.children;
|
|
50
39
|
}
|
|
51
40
|
|
|
52
|
-
return createElement(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
variant: "secondary"
|
|
58
|
-
}, __('Attempt Recovery')), createElement(CopyButton, {
|
|
59
|
-
key: "copy-error",
|
|
60
|
-
text: error.stack
|
|
61
|
-
}, __('Copy Error'))]
|
|
62
|
-
}, __('The editor has encountered an unexpected error.'));
|
|
41
|
+
return createElement(ErrorBoundaryWarning, {
|
|
42
|
+
message: __('The editor has encountered an unexpected error.'),
|
|
43
|
+
error: error,
|
|
44
|
+
reboot: this.reboot
|
|
45
|
+
});
|
|
63
46
|
}
|
|
64
47
|
|
|
65
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/error-boundary/index.js"],"names":["Component","__","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/error-boundary/index.js"],"names":["Component","__","ErrorBoundaryWarning","ErrorBoundary","constructor","arguments","reboot","bind","state","error","getDerivedStateFromError","props","onError","render","children"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,WAAjC;AAEA,eAAe,MAAMC,aAAN,SAA4BH,SAA5B,CAAsC;AACpDI,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAE8B,SAAxBC,wBAAwB,CAAED,KAAF,EAAU;AACxC,WAAO;AAAEA,MAAAA;AAAF,KAAP;AACA;;AAEDH,EAAAA,MAAM,GAAG;AACR,SAAKK,KAAL,CAAWC,OAAX;AACA;;AAEDC,EAAAA,MAAM,GAAG;AACR,UAAM;AAAEJ,MAAAA;AAAF,QAAY,KAAKD,KAAvB;;AACA,QAAK,CAAEC,KAAP,EAAe;AACd,aAAO,KAAKE,KAAL,CAAWG,QAAlB;AACA;;AAED,WACC,cAAC,oBAAD;AACC,MAAA,OAAO,EAAGb,EAAE,CACX,iDADW,CADb;AAIC,MAAA,KAAK,EAAGQ,KAJT;AAKC,MAAA,MAAM,EAAG,KAAKH;AALf,MADD;AASA;;AAlCmD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ErrorBoundaryWarning from './warning';\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.reboot = this.reboot.bind( this );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\treboot() {\n\t\tthis.props.onError();\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<ErrorBoundaryWarning\n\t\t\t\tmessage={ __(\n\t\t\t\t\t'The editor has encountered an unexpected error.'\n\t\t\t\t) }\n\t\t\t\terror={ error }\n\t\t\t\treboot={ this.reboot }\n\t\t\t/>\n\t\t);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { Button } from '@wordpress/components';
|
|
8
|
+
import { Warning } from '@wordpress/block-editor';
|
|
9
|
+
import { useCopyToClipboard } from '@wordpress/compose';
|
|
10
|
+
|
|
11
|
+
function CopyButton(_ref) {
|
|
12
|
+
let {
|
|
13
|
+
text,
|
|
14
|
+
children
|
|
15
|
+
} = _ref;
|
|
16
|
+
const ref = useCopyToClipboard(text);
|
|
17
|
+
return createElement(Button, {
|
|
18
|
+
variant: "secondary",
|
|
19
|
+
ref: ref
|
|
20
|
+
}, children);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function ErrorBoundaryWarning(_ref2) {
|
|
24
|
+
let {
|
|
25
|
+
message,
|
|
26
|
+
error,
|
|
27
|
+
reboot,
|
|
28
|
+
dashboardLink
|
|
29
|
+
} = _ref2;
|
|
30
|
+
const actions = [];
|
|
31
|
+
|
|
32
|
+
if (reboot) {
|
|
33
|
+
actions.push(createElement(Button, {
|
|
34
|
+
key: "recovery",
|
|
35
|
+
onClick: reboot,
|
|
36
|
+
variant: "secondary"
|
|
37
|
+
}, __('Attempt Recovery')));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (error) {
|
|
41
|
+
actions.push(createElement(CopyButton, {
|
|
42
|
+
key: "copy-error",
|
|
43
|
+
text: error.stack
|
|
44
|
+
}, __('Copy Error')));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (dashboardLink) {
|
|
48
|
+
actions.push(createElement(Button, {
|
|
49
|
+
key: "back-to-dashboard",
|
|
50
|
+
variant: "secondary",
|
|
51
|
+
href: dashboardLink
|
|
52
|
+
}, __('Back to dashboard')));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return createElement(Warning, {
|
|
56
|
+
className: "editor-error-boundary",
|
|
57
|
+
actions: actions
|
|
58
|
+
}, message);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=warning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/error-boundary/warning.js"],"names":["__","Button","Warning","useCopyToClipboard","CopyButton","text","children","ref","ErrorBoundaryWarning","message","error","reboot","dashboardLink","actions","push","stack"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,OAAT,QAAwB,yBAAxB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;;AAEA,SAASC,UAAT,OAA0C;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AACzC,QAAMC,GAAG,GAAGJ,kBAAkB,CAAEE,IAAF,CAA9B;AACA,SACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,eAAe,SAASE,oBAAT,QAKX;AAAA,MAL0C;AAC7CC,IAAAA,OAD6C;AAE7CC,IAAAA,KAF6C;AAG7CC,IAAAA,MAH6C;AAI7CC,IAAAA;AAJ6C,GAK1C;AACH,QAAMC,OAAO,GAAG,EAAhB;;AAEA,MAAKF,MAAL,EAAc;AACbE,IAAAA,OAAO,CAACC,IAAR,CACC,cAAC,MAAD;AAAQ,MAAA,GAAG,EAAC,UAAZ;AAAuB,MAAA,OAAO,EAAGH,MAAjC;AAA0C,MAAA,OAAO,EAAC;AAAlD,OACGX,EAAE,CAAE,kBAAF,CADL,CADD;AAKA;;AAED,MAAKU,KAAL,EAAa;AACZG,IAAAA,OAAO,CAACC,IAAR,CACC,cAAC,UAAD;AAAY,MAAA,GAAG,EAAC,YAAhB;AAA6B,MAAA,IAAI,EAAGJ,KAAK,CAACK;AAA1C,OACGf,EAAE,CAAE,YAAF,CADL,CADD;AAKA;;AAED,MAAKY,aAAL,EAAqB;AACpBC,IAAAA,OAAO,CAACC,IAAR,CACC,cAAC,MAAD;AACC,MAAA,GAAG,EAAC,mBADL;AAEC,MAAA,OAAO,EAAC,WAFT;AAGC,MAAA,IAAI,EAAGF;AAHR,OAKGZ,EAAE,CAAE,mBAAF,CALL,CADD;AASA;;AAED,SACC,cAAC,OAAD;AAAS,IAAA,SAAS,EAAC,uBAAnB;AAA2C,IAAA,OAAO,EAAGa;AAArD,KACGJ,OADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default function ErrorBoundaryWarning( {\n\tmessage,\n\terror,\n\treboot,\n\tdashboardLink,\n} ) {\n\tconst actions = [];\n\n\tif ( reboot ) {\n\t\tactions.push(\n\t\t\t<Button key=\"recovery\" onClick={ reboot } variant=\"secondary\">\n\t\t\t\t{ __( 'Attempt Recovery' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\tif ( error ) {\n\t\tactions.push(\n\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t</CopyButton>\n\t\t);\n\t}\n\n\tif ( dashboardLink ) {\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\tkey=\"back-to-dashboard\"\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\thref={ dashboardLink }\n\t\t\t>\n\t\t\t\t{ __( 'Back to dashboard' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Warning className=\"editor-error-boundary\" actions={ actions }>\n\t\t\t{ message }\n\t\t</Warning>\n\t);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { __experimentalNavigatorButton as NavigatorButton, __experimentalNavigatorBackButton as NavigatorBackButton, __experimentalItem as Item, FlexItem, __experimentalHStack as HStack } from '@wordpress/components';
|
|
8
8
|
import { Icon } from '@wordpress/icons';
|
|
9
9
|
|
|
10
10
|
function GenericNavigationButton(_ref) {
|
|
@@ -21,35 +21,15 @@ function GenericNavigationButton(_ref) {
|
|
|
21
21
|
})), createElement(FlexItem, null, children)), !icon && children);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function NavigationButton(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} = _ref2;
|
|
29
|
-
const {
|
|
30
|
-
goTo
|
|
31
|
-
} = useNavigator();
|
|
32
|
-
const dataAttrName = 'data-navigator-focusable-id';
|
|
33
|
-
const dataAttrValue = path;
|
|
34
|
-
const dataAttrCssSelector = `[${dataAttrName}="${dataAttrValue}"]`;
|
|
35
|
-
const buttonProps = { ...props,
|
|
36
|
-
[dataAttrName]: dataAttrValue
|
|
37
|
-
};
|
|
38
|
-
return createElement(GenericNavigationButton, _extends({
|
|
39
|
-
onClick: () => goTo(path, {
|
|
40
|
-
focusTargetSelector: dataAttrCssSelector
|
|
41
|
-
})
|
|
42
|
-
}, buttonProps));
|
|
24
|
+
function NavigationButton(props) {
|
|
25
|
+
return createElement(NavigatorButton, _extends({
|
|
26
|
+
as: GenericNavigationButton
|
|
27
|
+
}, props));
|
|
43
28
|
}
|
|
44
29
|
|
|
45
|
-
function NavigationBackButton(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const {
|
|
49
|
-
goBack
|
|
50
|
-
} = useNavigator();
|
|
51
|
-
return createElement(GenericNavigationButton, _extends({
|
|
52
|
-
onClick: goBack
|
|
30
|
+
function NavigationBackButton(props) {
|
|
31
|
+
return createElement(NavigatorBackButton, _extends({
|
|
32
|
+
as: GenericNavigationButton
|
|
53
33
|
}, props));
|
|
54
34
|
}
|
|
55
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/navigation-button.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/navigation-button.js"],"names":["__experimentalNavigatorButton","NavigatorButton","__experimentalNavigatorBackButton","NavigatorBackButton","__experimentalItem","Item","FlexItem","__experimentalHStack","HStack","Icon","GenericNavigationButton","icon","children","props","NavigationButton","NavigationBackButton"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,iCAAiC,IAAIC,mBAFtC,EAGCC,kBAAkB,IAAIC,IAHvB,EAICC,QAJD,EAKCC,oBAAoB,IAAIC,MALzB,QAMO,uBANP;AAOA,SAASC,IAAT,QAAqB,kBAArB;;AAEA,SAASC,uBAAT,OAAiE;AAAA,MAA/B;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkB,OAAGC;AAArB,GAA+B;AAChE,SACC,cAAC,IAAD,EAAWA,KAAX,EACGF,IAAI,IACL,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC;AAAhB,KACC,cAAC,QAAD,QACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGA,IAAb;AAAoB,IAAA,IAAI,EAAG;AAA3B,IADD,CADD,EAIC,cAAC,QAAD,QAAYC,QAAZ,CAJD,CAFF,EASG,CAAED,IAAF,IAAUC,QATb,CADD;AAaA;;AAED,SAASE,gBAAT,CAA2BD,KAA3B,EAAmC;AAClC,SAAO,cAAC,eAAD;AAAiB,IAAA,EAAE,EAAGH;AAAtB,KAAqDG,KAArD,EAAP;AACA;;AAED,SAASE,oBAAT,CAA+BF,KAA/B,EAAuC;AACtC,SAAO,cAAC,mBAAD;AAAqB,IAAA,EAAE,EAAGH;AAA1B,KAAyDG,KAAzD,EAAP;AACA;;AAED,SAASC,gBAAT,EAA2BC,oBAA3B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalNavigatorButton as NavigatorButton,\n\t__experimentalNavigatorBackButton as NavigatorBackButton,\n\t__experimentalItem as Item,\n\tFlexItem,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { Icon } from '@wordpress/icons';\n\nfunction GenericNavigationButton( { icon, children, ...props } ) {\n\treturn (\n\t\t<Item { ...props }>\n\t\t\t{ icon && (\n\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Icon icon={ icon } size={ 24 } />\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>{ children }</FlexItem>\n\t\t\t\t</HStack>\n\t\t\t) }\n\t\t\t{ ! icon && children }\n\t\t</Item>\n\t);\n}\n\nfunction NavigationButton( props ) {\n\treturn <NavigatorButton as={ GenericNavigationButton } { ...props } />;\n}\n\nfunction NavigationBackButton( props ) {\n\treturn <NavigatorBackButton as={ GenericNavigationButton } { ...props } />;\n}\n\nexport { NavigationButton, NavigationBackButton };\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { LineHeightControl, __experimentalFontFamilyControl as FontFamilyControl, __experimentalFontAppearanceControl as FontAppearanceControl, __experimentalLetterSpacingControl as LetterSpacingControl } from '@wordpress/block-editor';
|
|
7
|
-
import { PanelBody, FontSizePicker } from '@wordpress/components';
|
|
7
|
+
import { PanelBody, FontSizePicker, __experimentalSpacer as Spacer } from '@wordpress/components';
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
@@ -86,10 +86,13 @@ export default function TypographyPanel(_ref) {
|
|
|
86
86
|
onChange: setFontSize,
|
|
87
87
|
fontSizes: fontSizes,
|
|
88
88
|
disableCustomFontSizes: disableCustomFontSizes
|
|
89
|
-
}), hasLineHeightEnabled && createElement(
|
|
89
|
+
}), hasLineHeightEnabled && createElement(Spacer, {
|
|
90
|
+
marginBottom: 6
|
|
91
|
+
}, createElement(LineHeightControl, {
|
|
92
|
+
__nextHasNoMarginBottom: true,
|
|
90
93
|
value: lineHeight,
|
|
91
94
|
onChange: setLineHeight
|
|
92
|
-
}), hasAppearanceControl && createElement(FontAppearanceControl, {
|
|
95
|
+
})), hasAppearanceControl && createElement(FontAppearanceControl, {
|
|
93
96
|
value: {
|
|
94
97
|
fontStyle,
|
|
95
98
|
fontWeight
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/typography-panel.js"],"names":["LineHeightControl","__experimentalFontFamilyControl","FontFamilyControl","__experimentalFontAppearanceControl","FontAppearanceControl","__experimentalLetterSpacingControl","LetterSpacingControl","PanelBody","FontSizePicker","getSupportedGlobalStylesPanels","useSetting","useStyle","useHasTypographyPanel","name","hasLineHeight","useHasLineHeightControl","hasFontAppearance","useHasAppearanceControl","hasLetterSpacing","useHasLetterSpacingControl","supports","includes","hasFontStyles","hasFontWeights","TypographyPanel","element","prefix","fontSizes","disableCustomFontSizes","fontFamilies","hasLineHeightEnabled","hasAppearanceControl","hasLetterSpacingControl","fontFamily","setFontFamily","fontSize","setFontSize","fontStyle","setFontStyle","fontWeight","setFontWeight","lineHeight","setLineHeight","letterSpacing","setLetterSpacing","backgroundColor","gradientValue","color","extraStyles","textDecoration","background","newFontStyle","newFontWeight"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iBADD,EAECC,+BAA+B,IAAIC,iBAFpC,EAGCC,mCAAmC,IAAIC,qBAHxC,EAICC,kCAAkC,IAAIC,oBAJvC,QAKO,yBALP;AAMA,SAASC,SAAT,EAAoBC,cAApB,QAA0C,uBAA1C;AAEA;AACA;AACA;;AACA,SAASC,8BAAT,EAAyCC,UAAzC,EAAqDC,QAArD,QAAqE,SAArE;AAEA,OAAO,SAASC,qBAAT,CAAgCC,IAAhC,EAAuC;AAC7C,QAAMC,aAAa,GAAGC,uBAAuB,CAAEF,IAAF,CAA7C;AACA,QAAMG,iBAAiB,GAAGC,uBAAuB,CAAEJ,IAAF,CAAjD;AACA,QAAMK,gBAAgB,GAAGC,0BAA0B,CAAEN,IAAF,CAAnD;AACA,QAAMO,QAAQ,GAAGX,8BAA8B,CAAEI,IAAF,CAA/C;AACA,SACCC,aAAa,IACbE,iBADA,IAEAE,gBAFA,IAGAE,QAAQ,CAACC,QAAT,CAAmB,UAAnB,CAJD;AAMA;;AAED,SAASN,uBAAT,CAAkCF,IAAlC,EAAyC;AACxC,QAAMO,QAAQ,GAAGX,8BAA8B,CAAEI,IAAF,CAA/C;AACA,SACCH,UAAU,CAAE,uB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AAAA,UAHM;AACZF,QAAAA,SAAS,EAAEc,YADC;AAEZZ,QAAAA,UAAU,EAAEa;AAFA,OAGN;AACNd,MAAAA,YAAY,CAAEa,YAAF,CAAZ;AACAX,MAAAA,aAAa,CAAEY,aAAF,CAAb;AACA,KAXF;AAYC,IAAA,aAAa,EAAG9B,aAZjB;AAaC,IAAA,cAAc,EAAGC;AAblB,IAvCF,EAuDGS,uBAAuB,IACxB,cAAC,oBAAD;AACC,IAAA,KAAK,EAAGW,aADT;AAEC,IAAA,QAAQ,EAAGC;AAFZ,IAxDF,CADD;AAgEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tLineHeightControl,\n\t__experimentalFontFamilyControl as FontFamilyControl,\n\t__experimentalFontAppearanceControl as FontAppearanceControl,\n\t__experimentalLetterSpacingControl as LetterSpacingControl,\n} from '@wordpress/block-editor';\nimport { PanelBody, FontSizePicker } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';\n\nexport function useHasTypographyPanel( name ) {\n\tconst hasLineHeight = useHasLineHeightControl( name );\n\tconst hasFontAppearance = useHasAppearanceControl( name );\n\tconst hasLetterSpacing = useHasLetterSpacingControl( name );\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\thasLineHeight ||\n\t\thasFontAppearance ||\n\t\thasLetterSpacing ||\n\t\tsupports.includes( 'fontSize' )\n\t);\n}\n\nfunction useHasLineHeightControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.lineHeight', name )[ 0 ] &&\n\t\tsupports.includes( 'lineHeight' )\n\t);\n}\n\nfunction useHasAppearanceControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\treturn hasFontStyles || hasFontWeights;\n}\n\nfunction useHasLetterSpacingControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.letterSpacing', name )[ 0 ] &&\n\t\tsupports.includes( 'letterSpacing' )\n\t);\n}\n\nexport default function TypographyPanel( { name, element } ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst prefix =\n\t\telement === 'text' || ! element ? '' : `elements.${ element }.`;\n\tconst [ fontSizes ] = useSetting( 'typography.fontSizes', name );\n\tconst disableCustomFontSizes = ! useSetting(\n\t\t'typography.customFontSize',\n\t\tname\n\t)[ 0 ];\n\tconst [ fontFamilies ] = useSetting( 'typography.fontFamilies', name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\tconst hasLineHeightEnabled = useHasLineHeightControl( name );\n\tconst hasAppearanceControl = useHasAppearanceControl( name );\n\tconst hasLetterSpacingControl = useHasLetterSpacingControl( name );\n\n\tconst [ fontFamily, setFontFamily ] = useStyle(\n\t\tprefix + 'typography.fontFamily',\n\t\tname\n\t);\n\tconst [ fontSize, setFontSize ] = useStyle(\n\t\tprefix + 'typography.fontSize',\n\t\tname\n\t);\n\n\tconst [ fontStyle, setFontStyle ] = useStyle(\n\t\tprefix + 'typography.fontStyle',\n\t\tname\n\t);\n\tconst [ fontWeight, setFontWeight ] = useStyle(\n\t\tprefix + 'typography.fontWeight',\n\t\tname\n\t);\n\tconst [ lineHeight, setLineHeight ] = useStyle(\n\t\tprefix + 'typography.lineHeight',\n\t\tname\n\t);\n\tconst [ letterSpacing, setLetterSpacing ] = useStyle(\n\t\tprefix + 'typography.letterSpacing',\n\t\tname\n\t);\n\tconst [ backgroundColor ] = useStyle( prefix + 'color.background', name );\n\tconst [ gradientValue ] = useStyle( prefix + 'color.gradient', name );\n\tconst [ color ] = useStyle( prefix + 'color.text', name );\n\tconst extraStyles =\n\t\telement === 'link'\n\t\t\t? {\n\t\t\t\t\ttextDecoration: 'underline',\n\t\t\t }\n\t\t\t: {};\n\n\treturn (\n\t\t<PanelBody className=\"edit-site-typography-panel\" initialOpen={ true }>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-typography-panel__preview\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tfontFamily: fontFamily ?? 'serif',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcolor,\n\t\t\t\t\tfontSize,\n\t\t\t\t\tfontStyle,\n\t\t\t\t\tfontWeight,\n\t\t\t\t\tletterSpacing,\n\t\t\t\t\t...extraStyles,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\tAa\n\t\t\t</div>\n\n\t\t\t{ supports.includes( 'fontFamily' ) && (\n\t\t\t\t<FontFamilyControl\n\t\t\t\t\tfontFamilies={ fontFamilies }\n\t\t\t\t\tvalue={ fontFamily }\n\t\t\t\t\tonChange={ setFontFamily }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ supports.includes( 'fontSize' ) && (\n\t\t\t\t<FontSizePicker\n\t\t\t\t\tvalue={ fontSize }\n\t\t\t\t\tonChange={ setFontSize }\n\t\t\t\t\tfontSizes={ fontSizes }\n\t\t\t\t\tdisableCustomFontSizes={ disableCustomFontSizes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLineHeightEnabled && (\n\t\t\t\t<LineHeightControl\n\t\t\t\t\tvalue={ lineHeight }\n\t\t\t\t\tonChange={ setLineHeight }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasAppearanceControl && (\n\t\t\t\t<FontAppearanceControl\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\tfontStyle,\n\t\t\t\t\t\tfontWeight,\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\tfontStyle: newFontStyle,\n\t\t\t\t\t\tfontWeight: newFontWeight,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\tsetFontStyle( newFontStyle );\n\t\t\t\t\t\tsetFontWeight( newFontWeight );\n\t\t\t\t\t} }\n\t\t\t\t\thasFontStyles={ hasFontStyles }\n\t\t\t\t\thasFontWeights={ hasFontWeights }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLetterSpacingControl && (\n\t\t\t\t<LetterSpacingControl\n\t\t\t\t\tvalue={ letterSpacing }\n\t\t\t\t\tonChange={ setLetterSpacing }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/typography-panel.js"],"names":["LineHeightControl","__experimentalFontFamilyControl","FontFamilyControl","__experimentalFontAppearanceControl","FontAppearanceControl","__experimentalLetterSpacingControl","LetterSpacingControl","PanelBody","FontSizePicker","__experimentalSpacer","Spacer","getSupportedGlobalStylesPanels","useSetting","useStyle","useHasTypographyPanel","name","hasLineHeight","useHasLineHeightControl","hasFontAppearance","useHasAppearanceControl","hasLetterSpacing","useHasLetterSpacingControl","supports","includes","hasFontStyles","hasFontWeights","TypographyPanel","element","prefix","fontSizes","disableCustomFontSizes","fontFamilies","hasLineHeightEnabled","hasAppearanceControl","hasLetterSpacingControl","fontFamily","setFontFamily","fontSize","setFontSize","fontStyle","setFontStyle","fontWeight","setFontWeight","lineHeight","setLineHeight","letterSpacing","setLetterSpacing","backgroundColor","gradientValue","color","extraStyles","textDecoration","background","newFontStyle","newFontWeight"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iBADD,EAECC,+BAA+B,IAAIC,iBAFpC,EAGCC,mCAAmC,IAAIC,qBAHxC,EAICC,kCAAkC,IAAIC,oBAJvC,QAKO,yBALP;AAMA,SACCC,SADD,EAECC,cAFD,EAGCC,oBAAoB,IAAIC,MAHzB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,CAACC,QAAT,CAAmB,YAAnB,KACD,cAAC,iBAAD;AACC,IAAA,YAAY,EAAGQ,YADhB;AAEC,IAAA,KAAK,EAAGI,UAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAlBF,EAwBGd,QAAQ,CAACC,QAAT,CAAmB,UAAnB,KACD,cAAC,cAAD;AACC,IAAA,KAAK,EAAGc,QADT;AAEC,IAAA,QAAQ,EAAGC,WAFZ;AAGC,IAAA,SAAS,EAAGT,SAHb;AAIC,IAAA,sBAAsB,EAAGC;AAJ1B,IAzBF,EAgCGE,oBAAoB,IACrB,cAAC,MAAD;AAAQ,IAAA,YAAY,EAAG;AAAvB,KACC,cAAC,iBAAD;AACC,IAAA,uBAAuB,EAAG,IAD3B;AAEC,IAAA,KAAK,EAAGW,UAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CAjCF,EAyCGX,oBAAoB,IACrB,cAAC,qBAAD;AACC,IAAA,KAAK,EAAG;AACPM,MAAAA,SADO;AAEPE,MAAAA;AAFO,KADT;AAKC,IAAA,QAAQ,EAAG,SAGJ;AAAA,UAHM;AACZF,QAAAA,SAAS,EAAEc,YADC;AAEZZ,QAAAA,UAAU,EAAEa;AAFA,OAGN;AACNd,MAAAA,YAAY,CAAEa,YAAF,CAAZ;AACAX,MAAAA,aAAa,CAAEY,aAAF,CAAb;AACA,KAXF;AAYC,IAAA,aAAa,EAAG9B,aAZjB;AAaC,IAAA,cAAc,EAAGC;AAblB,IA1CF,EA0DGS,uBAAuB,IACxB,cAAC,oBAAD;AACC,IAAA,KAAK,EAAGW,aADT;AAEC,IAAA,QAAQ,EAAGC;AAFZ,IA3DF,CADD;AAmEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tLineHeightControl,\n\t__experimentalFontFamilyControl as FontFamilyControl,\n\t__experimentalFontAppearanceControl as FontAppearanceControl,\n\t__experimentalLetterSpacingControl as LetterSpacingControl,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\tFontSizePicker,\n\t__experimentalSpacer as Spacer,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels, useSetting, useStyle } from './hooks';\n\nexport function useHasTypographyPanel( name ) {\n\tconst hasLineHeight = useHasLineHeightControl( name );\n\tconst hasFontAppearance = useHasAppearanceControl( name );\n\tconst hasLetterSpacing = useHasLetterSpacingControl( name );\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\thasLineHeight ||\n\t\thasFontAppearance ||\n\t\thasLetterSpacing ||\n\t\tsupports.includes( 'fontSize' )\n\t);\n}\n\nfunction useHasLineHeightControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.lineHeight', name )[ 0 ] &&\n\t\tsupports.includes( 'lineHeight' )\n\t);\n}\n\nfunction useHasAppearanceControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\treturn hasFontStyles || hasFontWeights;\n}\n\nfunction useHasLetterSpacingControl( name ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\treturn (\n\t\tuseSetting( 'typography.letterSpacing', name )[ 0 ] &&\n\t\tsupports.includes( 'letterSpacing' )\n\t);\n}\n\nexport default function TypographyPanel( { name, element } ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst prefix =\n\t\telement === 'text' || ! element ? '' : `elements.${ element }.`;\n\tconst [ fontSizes ] = useSetting( 'typography.fontSizes', name );\n\tconst disableCustomFontSizes = ! useSetting(\n\t\t'typography.customFontSize',\n\t\tname\n\t)[ 0 ];\n\tconst [ fontFamilies ] = useSetting( 'typography.fontFamilies', name );\n\tconst hasFontStyles =\n\t\tuseSetting( 'typography.fontStyle', name )[ 0 ] &&\n\t\tsupports.includes( 'fontStyle' );\n\tconst hasFontWeights =\n\t\tuseSetting( 'typography.fontWeight', name )[ 0 ] &&\n\t\tsupports.includes( 'fontWeight' );\n\tconst hasLineHeightEnabled = useHasLineHeightControl( name );\n\tconst hasAppearanceControl = useHasAppearanceControl( name );\n\tconst hasLetterSpacingControl = useHasLetterSpacingControl( name );\n\n\tconst [ fontFamily, setFontFamily ] = useStyle(\n\t\tprefix + 'typography.fontFamily',\n\t\tname\n\t);\n\tconst [ fontSize, setFontSize ] = useStyle(\n\t\tprefix + 'typography.fontSize',\n\t\tname\n\t);\n\n\tconst [ fontStyle, setFontStyle ] = useStyle(\n\t\tprefix + 'typography.fontStyle',\n\t\tname\n\t);\n\tconst [ fontWeight, setFontWeight ] = useStyle(\n\t\tprefix + 'typography.fontWeight',\n\t\tname\n\t);\n\tconst [ lineHeight, setLineHeight ] = useStyle(\n\t\tprefix + 'typography.lineHeight',\n\t\tname\n\t);\n\tconst [ letterSpacing, setLetterSpacing ] = useStyle(\n\t\tprefix + 'typography.letterSpacing',\n\t\tname\n\t);\n\tconst [ backgroundColor ] = useStyle( prefix + 'color.background', name );\n\tconst [ gradientValue ] = useStyle( prefix + 'color.gradient', name );\n\tconst [ color ] = useStyle( prefix + 'color.text', name );\n\tconst extraStyles =\n\t\telement === 'link'\n\t\t\t? {\n\t\t\t\t\ttextDecoration: 'underline',\n\t\t\t }\n\t\t\t: {};\n\n\treturn (\n\t\t<PanelBody className=\"edit-site-typography-panel\" initialOpen={ true }>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-typography-panel__preview\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tfontFamily: fontFamily ?? 'serif',\n\t\t\t\t\tbackground: gradientValue ?? backgroundColor,\n\t\t\t\t\tcolor,\n\t\t\t\t\tfontSize,\n\t\t\t\t\tfontStyle,\n\t\t\t\t\tfontWeight,\n\t\t\t\t\tletterSpacing,\n\t\t\t\t\t...extraStyles,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\tAa\n\t\t\t</div>\n\n\t\t\t{ supports.includes( 'fontFamily' ) && (\n\t\t\t\t<FontFamilyControl\n\t\t\t\t\tfontFamilies={ fontFamilies }\n\t\t\t\t\tvalue={ fontFamily }\n\t\t\t\t\tonChange={ setFontFamily }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ supports.includes( 'fontSize' ) && (\n\t\t\t\t<FontSizePicker\n\t\t\t\t\tvalue={ fontSize }\n\t\t\t\t\tonChange={ setFontSize }\n\t\t\t\t\tfontSizes={ fontSizes }\n\t\t\t\t\tdisableCustomFontSizes={ disableCustomFontSizes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLineHeightEnabled && (\n\t\t\t\t<Spacer marginBottom={ 6 }>\n\t\t\t\t\t<LineHeightControl\n\t\t\t\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\t\t\t\tvalue={ lineHeight }\n\t\t\t\t\t\tonChange={ setLineHeight }\n\t\t\t\t\t/>\n\t\t\t\t</Spacer>\n\t\t\t) }\n\t\t\t{ hasAppearanceControl && (\n\t\t\t\t<FontAppearanceControl\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\tfontStyle,\n\t\t\t\t\t\tfontWeight,\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( {\n\t\t\t\t\t\tfontStyle: newFontStyle,\n\t\t\t\t\t\tfontWeight: newFontWeight,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\tsetFontStyle( newFontStyle );\n\t\t\t\t\t\tsetFontWeight( newFontWeight );\n\t\t\t\t\t} }\n\t\t\t\t\thasFontStyles={ hasFontStyles }\n\t\t\t\t\thasFontWeights={ hasFontWeights }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ hasLetterSpacingControl && (\n\t\t\t\t<LetterSpacingControl\n\t\t\t\t\tvalue={ letterSpacing }\n\t\t\t\t\tonChange={ setLetterSpacing }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</PanelBody>\n\t);\n}\n"]}
|
|
@@ -8,6 +8,7 @@ import { first, forEach, get, isEmpty, isString, kebabCase, pickBy, reduce, set,
|
|
|
8
8
|
|
|
9
9
|
import { __EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY, __EXPERIMENTAL_ELEMENTS as ELEMENTS, getBlockTypes } from '@wordpress/blocks';
|
|
10
10
|
import { useEffect, useState, useContext } from '@wordpress/element';
|
|
11
|
+
import { getCSSRules } from '@wordpress/style-engine';
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
13
14
|
*/
|
|
@@ -135,14 +136,15 @@ function flattenTree() {
|
|
|
135
136
|
|
|
136
137
|
function getStylesDeclarations() {
|
|
137
138
|
let blockStyles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
138
|
-
|
|
139
|
+
const output = reduce(STYLE_PROPERTY, (declarations, _ref5, key) => {
|
|
139
140
|
let {
|
|
140
141
|
value,
|
|
141
|
-
properties
|
|
142
|
+
properties,
|
|
143
|
+
useEngine
|
|
142
144
|
} = _ref5;
|
|
143
145
|
const pathToValue = value;
|
|
144
146
|
|
|
145
|
-
if (first(pathToValue) === 'elements') {
|
|
147
|
+
if (first(pathToValue) === 'elements' || useEngine) {
|
|
146
148
|
return declarations;
|
|
147
149
|
}
|
|
148
150
|
|
|
@@ -167,7 +169,21 @@ function getStylesDeclarations() {
|
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
return declarations;
|
|
170
|
-
}, []);
|
|
172
|
+
}, []); // The goal is to move everything to server side generated engine styles
|
|
173
|
+
// This is temporary as we absorb more and more styles into the engine.
|
|
174
|
+
|
|
175
|
+
const extraRules = getCSSRules(blockStyles, {
|
|
176
|
+
selector: 'self'
|
|
177
|
+
});
|
|
178
|
+
extraRules.forEach(rule => {
|
|
179
|
+
if (rule.selector !== 'self') {
|
|
180
|
+
throw "This style can't be added as inline style";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const cssProperty = rule.key.startsWith('--') ? rule.key : kebabCase(rule.key);
|
|
184
|
+
output.push(`${cssProperty}: ${compileStyleValue(rule.value)}`);
|
|
185
|
+
});
|
|
186
|
+
return output;
|
|
171
187
|
}
|
|
172
188
|
|
|
173
189
|
export const getNodesWithStyles = (tree, blockSelectors) => {
|