@wordpress/edit-site 5.3.2 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/build/components/add-new-template/new-template-part.js +8 -5
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +8 -5
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +3 -3
- 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 +25 -23
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -2
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +2 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/custom-css.js +2 -2
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/global-styles-provider.js +2 -2
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +2 -2
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/header.js +1 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/navigation-button.js +1 -1
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +2 -2
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +2 -2
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +2 -2
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +2 -2
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +2 -2
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +5 -5
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-heading-color.js +2 -2
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +2 -2
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-root.js +2 -2
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -2
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +2 -2
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +2 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +2 -2
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +2 -2
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-preview.js +2 -2
- package/build/components/global-styles/typography-preview.js.map +1 -1
- package/build/components/global-styles/ui.js +3 -10
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +2 -2
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +6 -3
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/layout/index.js +10 -23
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +1 -1
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/list/table.js +1 -0
- package/build/components/list/table.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +2 -2
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/save-panel/index.js +4 -3
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar/index.js +17 -3
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +28 -7
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +72 -0
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-template/index.js +70 -0
- package/build/components/sidebar-navigation-screen-template/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +32 -82
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-templates-browse/index.js +43 -0
- package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
- package/build/components/site-hub/index.js +14 -49
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/style-book/index.js +10 -3
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +55 -20
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +3 -3
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +12 -12
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
- package/build/components/use-edited-entity-record/index.js +6 -2
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +2 -2
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/{experiments.js → private-apis.js} +3 -3
- package/build/private-apis.js.map +1 -0
- package/build/store/index.js +3 -3
- package/build/store/index.js.map +1 -1
- package/build/utils/get-is-list-page.js +5 -6
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +7 -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 +7 -4
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -1
- 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 +25 -24
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -3
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +3 -3
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +3 -3
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -3
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/global-styles-provider.js +3 -3
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +3 -3
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -2
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -3
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/navigation-button.js +2 -2
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +3 -3
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +3 -3
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +3 -3
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +3 -3
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +3 -3
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +5 -5
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-heading-color.js +3 -3
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +3 -3
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +3 -3
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +3 -3
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +3 -3
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -3
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +3 -3
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +3 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-preview.js +3 -3
- package/build-module/components/global-styles/typography-preview.js.map +1 -1
- package/build-module/components/global-styles/ui.js +4 -11
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +3 -3
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +6 -3
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/layout/index.js +10 -23
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +1 -1
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/list/table.js +1 -0
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +3 -3
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/save-panel/index.js +3 -2
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +14 -3
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +27 -9
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +55 -0
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +2 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-template/index.js +53 -0
- package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +34 -81
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
- package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -0
- package/build-module/components/site-hub/index.js +14 -46
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/style-book/index.js +11 -4
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +55 -21
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +11 -11
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -0
- package/build-module/components/use-edited-entity-record/index.js +6 -2
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +3 -3
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/{experiments.js → private-apis.js} +2 -2
- package/build-module/private-apis.js.map +1 -0
- package/build-module/store/index.js +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +5 -6
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-style/style-rtl.css +18 -37
- package/build-style/style.css +18 -37
- package/package.json +20 -20
- package/src/components/add-new-template/new-template-part.js +7 -4
- package/src/components/add-new-template/new-template.js +8 -6
- package/src/components/block-editor/editor-canvas.js +1 -1
- package/src/components/block-editor/index.js +3 -3
- package/src/components/editor/index.js +29 -28
- package/src/components/global-styles/border-panel.js +3 -3
- package/src/components/global-styles/color-palette-panel.js +3 -3
- package/src/components/global-styles/custom-css.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +3 -3
- package/src/components/global-styles/global-styles-provider.js +3 -3
- package/src/components/global-styles/gradients-palette-panel.js +3 -3
- package/src/components/global-styles/header.js +2 -2
- package/src/components/global-styles/hooks.js +3 -3
- package/src/components/global-styles/navigation-button.js +4 -2
- package/src/components/global-styles/palette.js +3 -3
- package/src/components/global-styles/preview.js +3 -3
- package/src/components/global-styles/screen-background-color.js +3 -3
- package/src/components/global-styles/screen-button-color.js +3 -3
- package/src/components/global-styles/screen-colors.js +3 -3
- package/src/components/global-styles/screen-css.js +14 -7
- package/src/components/global-styles/screen-heading-color.js +3 -3
- package/src/components/global-styles/screen-link-color.js +3 -3
- package/src/components/global-styles/screen-root.js +3 -3
- package/src/components/global-styles/screen-style-variations.js +3 -3
- package/src/components/global-styles/screen-text-color.js +3 -3
- package/src/components/global-styles/screen-typography.js +3 -3
- package/src/components/global-styles/shadow-panel.js +3 -3
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/global-styles/typography-panel.js +3 -3
- package/src/components/global-styles/typography-preview.js +3 -3
- package/src/components/global-styles/ui.js +3 -8
- package/src/components/global-styles-renderer/index.js +3 -3
- package/src/components/header-edit-mode/index.js +6 -3
- package/src/components/keyboard-shortcut-help-modal/config.js +1 -1
- package/src/components/layout/index.js +35 -48
- package/src/components/layout/style.scss +11 -23
- package/src/components/list/actions/rename-menu-item.js +1 -1
- package/src/components/list/table.js +4 -0
- package/src/components/navigation-inspector/navigation-menu.js +3 -3
- package/src/components/save-panel/index.js +4 -1
- package/src/components/sidebar/index.js +10 -2
- package/src/components/sidebar-navigation-screen/index.js +27 -11
- package/src/components/sidebar-navigation-screen/style.scss +4 -6
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +52 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +1 -1
- package/src/components/sidebar-navigation-screen-template/index.js +52 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +49 -83
- package/src/components/sidebar-navigation-screen-templates-browse/index.js +31 -0
- package/src/components/site-hub/index.js +67 -122
- package/src/components/site-hub/style.scss +1 -11
- package/src/components/style-book/index.js +11 -7
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +48 -14
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +1 -1
- package/src/components/sync-state-with-url/{use-sync-sidebar-path-with-url.js → use-sync-path-with-url.js} +10 -10
- package/src/components/use-edited-entity-record/index.js +6 -2
- package/src/hooks/push-changes-to-global-styles/index.js +3 -3
- package/src/{experiments.js → private-apis.js} +1 -1
- package/src/store/index.js +1 -1
- package/src/utils/get-is-list-page.js +5 -5
- package/build/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
- package/build/experiments.js.map +0 -1
- package/build-module/components/sync-state-with-url/use-sync-sidebar-path-with-url.js.map +0 -1
- package/build-module/experiments.js.map +0 -1
|
@@ -24,7 +24,7 @@ var _icons = require("@wordpress/icons");
|
|
|
24
24
|
|
|
25
25
|
var _compose = require("@wordpress/compose");
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _privateApis = require("../../private-apis");
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* External dependencies
|
|
@@ -39,7 +39,7 @@ var _experiments = require("../../experiments");
|
|
|
39
39
|
*/
|
|
40
40
|
const {
|
|
41
41
|
useGlobalStyle
|
|
42
|
-
} = (0,
|
|
42
|
+
} = (0, _privateApis.unlock)(_blockEditor.privateApis);
|
|
43
43
|
const SLOT_FILL_NAME = 'EditSiteStyleBook';
|
|
44
44
|
const {
|
|
45
45
|
Slot: StyleBookSlot,
|
|
@@ -70,7 +70,14 @@ function getExamples() {
|
|
|
70
70
|
level: 5
|
|
71
71
|
})]
|
|
72
72
|
};
|
|
73
|
-
const otherExamples = (0, _blocks.getBlockTypes)().filter(blockType =>
|
|
73
|
+
const otherExamples = (0, _blocks.getBlockTypes)().filter(blockType => {
|
|
74
|
+
const {
|
|
75
|
+
name,
|
|
76
|
+
example,
|
|
77
|
+
supports
|
|
78
|
+
} = blockType;
|
|
79
|
+
return name !== 'core/heading' && !!example && supports.inserter !== false;
|
|
80
|
+
}).map(blockType => ({
|
|
74
81
|
name: blockType.name,
|
|
75
82
|
title: blockType.title,
|
|
76
83
|
category: blockType.category,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["useGlobalStyle","blockEditorExperiments","SLOT_FILL_NAME","Slot","StyleBookSlot","Fill","StyleBookFill","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","map","StyleBook","isSelected","onSelect","onClose","resizeObserver","sizes","textColor","backgroundColor","examples","tabs","some","slug","icon","width","color","background","closeSmall","tab","Examples","Example","onClick","css","useHasStyleBook","fills","length"],"mappings":";;;;;;;;;;AA2BA;;AAxBA;;AAKA;;AAMA;;AACA;;AAMA;;AAIA;;AACA;;AAMA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAqB,yBAAQC,wBAAR,CAA3B;AAEA,MAAMC,cAAc,GAAG,mBAAvB;AACA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IACL,gCAAgBJ,cAAhB,CADD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CAJd;AASC,IAAA,OAAO,EAAG8B;AATX,KAWC;AAAM,IAAA,SAAS,EAAC;AAAhB,KAAwD9B,KAAxD,CAXD,EAYC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,MAAM,EAAGE,MADV;AAEC,IAAA,aAAa,EAAG,CAFjB;AAGC,IAAA,gBAAgB,EAAG,CAClB;AACC6B,MAAAA,GAAG,EACF,6CACA;AAHF,KADkB;AAHpB,IADD,CAZD,CADqB;AAAA,CAAN,CAAhB;;AA6BA,SAASC,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAG,4CAAczC,cAAd,CAAd;AACA,SAAO,CAAC,EAAEyC,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,MAAT,CAAR;AACA;;AAEDxB,SAAS,CAACjB,IAAV,GAAiBC,aAAjB;eACegB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTabPanel,\n\tcreateSlotFill,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetCategories,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport { closeSmall } from '@wordpress/icons';\nimport { useResizeObserver } from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../experiments';\n\nconst { useGlobalStyle } = unlock( blockEditorExperiments );\n\nconst SLOT_FILL_NAME = 'EditSiteStyleBook';\nconst { Slot: StyleBookSlot, Fill: StyleBookFill } =\n\tcreateSlotFill( SLOT_FILL_NAME );\n\nfunction getExamples() {\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 1,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 2,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 3,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 4,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 5,\n\t\t\t} ),\n\t\t],\n\t};\n\n\tconst otherExamples = getBlockTypes()\n\t\t.filter(\n\t\t\t( blockType ) =>\n\t\t\t\tblockType.name !== 'core/heading' && !! blockType.example\n\t\t)\n\t\t.map( ( blockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\tblocks: getBlockFromExample( blockType.name, blockType.example ),\n\t\t} ) );\n\n\treturn [ headingsExample, ...otherExamples ];\n}\n\nfunction StyleBook( { isSelected, onSelect, onClose } ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ textColor ] = useGlobalStyle( 'color.text' );\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst examples = useMemo( getExamples, [] );\n\tconst tabs = useMemo(\n\t\t() =>\n\t\t\tgetCategories()\n\t\t\t\t.filter( ( category ) =>\n\t\t\t\t\texamples.some(\n\t\t\t\t\t\t( example ) => example.category === category.slug\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( category ) => ( {\n\t\t\t\t\tname: category.slug,\n\t\t\t\t\ttitle: category.title,\n\t\t\t\t\ticon: category.icon,\n\t\t\t\t} ) ),\n\t\t[ examples ]\n\t);\n\treturn (\n\t\t<StyleBookFill>\n\t\t\t<section\n\t\t\t\tclassName={ classnames( 'edit-site-style-book', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcolor: textColor,\n\t\t\t\t\tbackground: backgroundColor,\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Style Book' ) }\n\t\t\t>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-style-book__close-button\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close Style Book' ) }\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t/>\n\t\t\t\t<TabPanel\n\t\t\t\t\tclassName=\"edit-site-style-book__tab-panel\"\n\t\t\t\t\ttabs={ tabs }\n\t\t\t\t>\n\t\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TabPanel>\n\t\t\t</section>\n\t\t</StyleBookFill>\n\t);\n}\n\nconst Examples = memo( ( { examples, category, isSelected, onSelect } ) => (\n\t<div className=\"edit-site-style-book__examples\">\n\t\t{ examples\n\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t.map( ( example ) => (\n\t\t\t\t<Example\n\t\t\t\t\tkey={ example.name }\n\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSelect( example.name );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t</div>\n) );\n\nconst Example = memo( ( { title, blocks, isSelected, onClick } ) => (\n\t<button\n\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t'is-selected': isSelected,\n\t\t} ) }\n\t\taria-label={ sprintf(\n\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\ttitle\n\t\t) }\n\t\tonClick={ onClick }\n\t>\n\t\t<span className=\"edit-site-style-book__example-title\">{ title }</span>\n\t\t<div className=\"edit-site-style-book__example-preview\">\n\t\t\t<BlockPreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tviewportWidth={ 0 }\n\t\t\t\tadditionalStyles={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tcss:\n\t\t\t\t\t\t\t'.wp-block:first-child { margin-top: 0; }' +\n\t\t\t\t\t\t\t'.wp-block:last-child { margin-bottom: 0; }',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t/>\n\t\t</div>\n\t</button>\n) );\n\nfunction useHasStyleBook() {\n\tconst fills = useSlotFills( SLOT_FILL_NAME );\n\treturn !! fills?.length;\n}\n\nStyleBook.Slot = StyleBookSlot;\nexport default StyleBook;\nexport { useHasStyleBook };\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["useGlobalStyle","blockEditorPrivateApis","SLOT_FILL_NAME","Slot","StyleBookSlot","Fill","StyleBookFill","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","supports","inserter","map","StyleBook","isSelected","onSelect","onClose","resizeObserver","sizes","textColor","backgroundColor","examples","tabs","some","slug","icon","width","color","background","closeSmall","tab","Examples","Example","onClick","css","useHasStyleBook","fills","length"],"mappings":";;;;;;;;;;AA2BA;;AAxBA;;AAKA;;AAMA;;AACA;;AAMA;;AAIA;;AACA;;AAMA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAqB,yBAA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AAO,GAAG,mBAAM;AAAA,MAAE;AAAE/B,IAAAA,KAAF;AAASE,IAAAA,MAAT;AAAiBW,IAAAA,UAAjB;AAA6BmB,IAAAA;AAA7B,GAAF;AAAA,SACrB;AACC,IAAA,SAAS,EAAG,yBAAY,+BAAZ,EAA6C;AACxD,qBAAenB;AADyC,KAA7C,CADb;AAIC,kBAAa,oBACZ;AACA,kBAAI,gCAAJ,CAFY,EAGZb,KAHY,CAJd;AASC,IAAA,OAAO,EAAGgC;AATX,KAWC;AAAM,IAAA,SAAS,EAAC;AAAhB,KAAwDhC,KAAxD,CAXD,EAYC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,yBAAD;AACC,IAAA,MAAM,EAAGE,MADV;AAEC,IAAA,aAAa,EAAG,CAFjB;AAGC,IAAA,gBAAgB,EAAG,CAClB;AACC+B,MAAAA,GAAG,EACF,6CACA;AAHF,KADkB;AAHpB,IADD,CAZD,CADqB;AAAA,CAAN,CAAhB;;AA6BA,SAASC,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAG,4CAAc3C,cAAd,CAAd;AACA,SAAO,CAAC,EAAE2C,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,MAAT,CAAR;AACA;;AAEDxB,SAAS,CAACnB,IAAV,GAAiBC,aAAjB;eACekB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTabPanel,\n\tcreateSlotFill,\n\t__experimentalUseSlotFills as useSlotFills,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tgetCategories,\n\tgetBlockTypes,\n\tgetBlockFromExample,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { closeSmall } from '@wordpress/icons';\nimport { useResizeObserver } from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\n\nconst SLOT_FILL_NAME = 'EditSiteStyleBook';\nconst { Slot: StyleBookSlot, Fill: StyleBookFill } =\n\tcreateSlotFill( SLOT_FILL_NAME );\n\nfunction getExamples() {\n\t// Use our own example for the Heading block so that we can show multiple\n\t// heading levels.\n\tconst headingsExample = {\n\t\tname: 'core/heading',\n\t\ttitle: __( 'Headings' ),\n\t\tcategory: 'text',\n\t\tblocks: [\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 1,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 2,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 3,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 4,\n\t\t\t} ),\n\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\tcontent: __( 'Code Is Poetry' ),\n\t\t\t\tlevel: 5,\n\t\t\t} ),\n\t\t],\n\t};\n\n\tconst otherExamples = getBlockTypes()\n\t\t.filter( ( blockType ) => {\n\t\t\tconst { name, example, supports } = blockType;\n\t\t\treturn (\n\t\t\t\tname !== 'core/heading' &&\n\t\t\t\t!! example &&\n\t\t\t\tsupports.inserter !== false\n\t\t\t);\n\t\t} )\n\t\t.map( ( blockType ) => ( {\n\t\t\tname: blockType.name,\n\t\t\ttitle: blockType.title,\n\t\t\tcategory: blockType.category,\n\t\t\tblocks: getBlockFromExample( blockType.name, blockType.example ),\n\t\t} ) );\n\n\treturn [ headingsExample, ...otherExamples ];\n}\n\nfunction StyleBook( { isSelected, onSelect, onClose } ) {\n\tconst [ resizeObserver, sizes ] = useResizeObserver();\n\tconst [ textColor ] = useGlobalStyle( 'color.text' );\n\tconst [ backgroundColor ] = useGlobalStyle( 'color.background' );\n\tconst examples = useMemo( getExamples, [] );\n\tconst tabs = useMemo(\n\t\t() =>\n\t\t\tgetCategories()\n\t\t\t\t.filter( ( category ) =>\n\t\t\t\t\texamples.some(\n\t\t\t\t\t\t( example ) => example.category === category.slug\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t.map( ( category ) => ( {\n\t\t\t\t\tname: category.slug,\n\t\t\t\t\ttitle: category.title,\n\t\t\t\t\ticon: category.icon,\n\t\t\t\t} ) ),\n\t\t[ examples ]\n\t);\n\treturn (\n\t\t<StyleBookFill>\n\t\t\t<section\n\t\t\t\tclassName={ classnames( 'edit-site-style-book', {\n\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t} ) }\n\t\t\t\tstyle={ {\n\t\t\t\t\tcolor: textColor,\n\t\t\t\t\tbackground: backgroundColor,\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Style Book' ) }\n\t\t\t>\n\t\t\t\t{ resizeObserver }\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-style-book__close-button\"\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close Style Book' ) }\n\t\t\t\t\tonClick={ onClose }\n\t\t\t\t/>\n\t\t\t\t<TabPanel\n\t\t\t\t\tclassName=\"edit-site-style-book__tab-panel\"\n\t\t\t\t\ttabs={ tabs }\n\t\t\t\t>\n\t\t\t\t\t{ ( tab ) => (\n\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TabPanel>\n\t\t\t</section>\n\t\t</StyleBookFill>\n\t);\n}\n\nconst Examples = memo( ( { examples, category, isSelected, onSelect } ) => (\n\t<div className=\"edit-site-style-book__examples\">\n\t\t{ examples\n\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t.map( ( example ) => (\n\t\t\t\t<Example\n\t\t\t\t\tkey={ example.name }\n\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonSelect( example.name );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) ) }\n\t</div>\n) );\n\nconst Example = memo( ( { title, blocks, isSelected, onClick } ) => (\n\t<button\n\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t'is-selected': isSelected,\n\t\t} ) }\n\t\taria-label={ sprintf(\n\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\ttitle\n\t\t) }\n\t\tonClick={ onClick }\n\t>\n\t\t<span className=\"edit-site-style-book__example-title\">{ title }</span>\n\t\t<div className=\"edit-site-style-book__example-preview\">\n\t\t\t<BlockPreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tviewportWidth={ 0 }\n\t\t\t\tadditionalStyles={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tcss:\n\t\t\t\t\t\t\t'.wp-block:first-child { margin-top: 0; }' +\n\t\t\t\t\t\t\t'.wp-block:last-child { margin-bottom: 0; }',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t/>\n\t\t</div>\n\t</button>\n) );\n\nfunction useHasStyleBook() {\n\tconst fills = useSlotFills( SLOT_FILL_NAME );\n\treturn !! fills?.length;\n}\n\nStyleBook.Slot = StyleBookSlot;\nexport default StyleBook;\nexport { useHasStyleBook };\n"]}
|
|
@@ -9,6 +9,8 @@ var _element = require("@wordpress/element");
|
|
|
9
9
|
|
|
10
10
|
var _data = require("@wordpress/data");
|
|
11
11
|
|
|
12
|
+
var _coreData = require("@wordpress/core-data");
|
|
13
|
+
|
|
12
14
|
var _routes = require("../routes");
|
|
13
15
|
|
|
14
16
|
var _store = require("../../store");
|
|
@@ -21,33 +23,66 @@ var _store = require("../../store");
|
|
|
21
23
|
* Internal dependencies
|
|
22
24
|
*/
|
|
23
25
|
function useInitEditedEntityFromURL() {
|
|
26
|
+
const {
|
|
27
|
+
params: {
|
|
28
|
+
postId,
|
|
29
|
+
postType,
|
|
30
|
+
path = '/'
|
|
31
|
+
} = {}
|
|
32
|
+
} = (0, _routes.useLocation)();
|
|
33
|
+
const {
|
|
34
|
+
isRequestingSite,
|
|
35
|
+
homepageId
|
|
36
|
+
} = (0, _data.useSelect)(select => {
|
|
37
|
+
const {
|
|
38
|
+
getSite
|
|
39
|
+
} = select(_coreData.store);
|
|
40
|
+
const siteData = getSite();
|
|
41
|
+
return {
|
|
42
|
+
isRequestingSite: !siteData,
|
|
43
|
+
homepageId: (siteData === null || siteData === void 0 ? void 0 : siteData.show_on_front) === 'page' ? siteData.page_on_front : null
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
24
46
|
const {
|
|
25
47
|
setTemplate,
|
|
26
48
|
setTemplatePart,
|
|
27
49
|
setPage
|
|
28
50
|
} = (0, _data.useDispatch)(_store.store);
|
|
29
|
-
const {
|
|
30
|
-
params: {
|
|
31
|
-
postId,
|
|
32
|
-
postType
|
|
33
|
-
}
|
|
34
|
-
} = (0, _routes.useLocation)(); // Set correct entity on page navigation.
|
|
35
|
-
|
|
36
51
|
(0, _element.useEffect)(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
switch (path) {
|
|
53
|
+
case '/templates/single':
|
|
54
|
+
setTemplate(postId);
|
|
55
|
+
break;
|
|
56
|
+
|
|
57
|
+
case '/template-parts/single':
|
|
58
|
+
setTemplatePart(postId);
|
|
59
|
+
break;
|
|
60
|
+
|
|
61
|
+
case '/navigation/single':
|
|
62
|
+
setPage({
|
|
63
|
+
context: {
|
|
64
|
+
postType,
|
|
65
|
+
postId
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
break;
|
|
69
|
+
|
|
70
|
+
default:
|
|
71
|
+
{
|
|
72
|
+
if (homepageId) {
|
|
73
|
+
setPage({
|
|
74
|
+
context: {
|
|
75
|
+
postType: 'page',
|
|
76
|
+
postId: homepageId
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} else if (!isRequestingSite) {
|
|
80
|
+
setPage({
|
|
81
|
+
path: '/'
|
|
82
|
+
});
|
|
83
|
+
}
|
|
44
84
|
}
|
|
45
|
-
}); // Resolves correct template based on ID.
|
|
46
|
-
} else if ('wp_template' === postType) {
|
|
47
|
-
setTemplate(postId);
|
|
48
|
-
} else if ('wp_template_part' === postType) {
|
|
49
|
-
setTemplatePart(postId);
|
|
50
85
|
}
|
|
51
|
-
}, [postId,
|
|
86
|
+
}, [path, postId, homepageId, isRequestingSite, setPage, setTemplate, setTemplatePart]);
|
|
52
87
|
}
|
|
53
88
|
//# sourceMappingURL=use-init-edited-entity-from-url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js"],"names":["useInitEditedEntityFromURL","params","postId","postType","path","isRequestingSite","homepageId","select","getSite","coreDataStore","siteData","show_on_front","page_on_front","setTemplate","setTemplatePart","setPage","editSiteStore","context"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,0BAAT,GAAsC;AACpD,QAAM;AAAEC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,QAAV;AAAoBC,MAAAA,IAAI,GAAG;AAA3B,QAAmC;AAA7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OALE,EAMFF,WANE,EAOFC,eAPE,CAzBH;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../routes';\nimport { store as editSiteStore } from '../../store';\n\nexport default function useInitEditedEntityFromURL() {\n\tconst { params: { postId, postType, path = '/' } = {} } = useLocation();\n\tconst { isRequestingSite, homepageId } = useSelect( ( select ) => {\n\t\tconst { getSite } = select( coreDataStore );\n\t\tconst siteData = getSite();\n\n\t\treturn {\n\t\t\tisRequestingSite: ! siteData,\n\t\t\thomepageId:\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? siteData.page_on_front\n\t\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst { setTemplate, setTemplatePart, setPage } =\n\t\tuseDispatch( editSiteStore );\n\n\tuseEffect( () => {\n\t\tswitch ( path ) {\n\t\t\tcase '/templates/single':\n\t\t\t\tsetTemplate( postId );\n\t\t\t\tbreak;\n\t\t\tcase '/template-parts/single':\n\t\t\t\tsetTemplatePart( postId );\n\t\t\t\tbreak;\n\t\t\tcase '/navigation/single':\n\t\t\t\tsetPage( {\n\t\t\t\t\tcontext: { postType, postId },\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tif ( homepageId ) {\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tcontext: { postType: 'page', postId: homepageId },\n\t\t\t\t\t} );\n\t\t\t\t} else if ( ! isRequestingSite ) {\n\t\t\t\t\tsetPage( {\n\t\t\t\t\t\tpath: '/',\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [\n\t\tpath,\n\t\tpostId,\n\t\thomepageId,\n\t\tisRequestingSite,\n\t\tsetPage,\n\t\tsetTemplate,\n\t\tsetTemplatePart,\n\t] );\n}\n"]}
|
|
@@ -13,7 +13,7 @@ var _store = require("../../store");
|
|
|
13
13
|
|
|
14
14
|
var _routes = require("../routes");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _privateApis = require("../../private-apis");
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* WordPress dependencies
|
|
@@ -27,10 +27,10 @@ function useSyncCanvasModeWithURL() {
|
|
|
27
27
|
const {
|
|
28
28
|
params
|
|
29
29
|
} = (0, _routes.useLocation)();
|
|
30
|
-
const canvasMode = (0, _data.useSelect)(select => (0,
|
|
30
|
+
const canvasMode = (0, _data.useSelect)(select => (0, _privateApis.unlock)(select(_store.store)).getCanvasMode(), []);
|
|
31
31
|
const {
|
|
32
32
|
setCanvasMode
|
|
33
|
-
} = (0,
|
|
33
|
+
} = (0, _privateApis.unlock)((0, _data.useDispatch)(_store.store));
|
|
34
34
|
const currentCanvasMode = (0, _element.useRef)(canvasMode);
|
|
35
35
|
const {
|
|
36
36
|
canvas: canvasInUrl = 'view'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js"],"names":["useSyncCanvasModeWithURL","history","params","canvasMode","select","editSiteStore","getCanvasMode","setCanvasMode","currentCanvasMode","canvas","canvasInUrl","currentCanvasInUrl","current","push"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,wBAAT,GAAoC;AAClD,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,UAAU,GAAG,qBAChBC,MAAF,IAAc,yBAAQA,MAAM,CAAEC,YAAF,CAAd,EAAkCC,aAAlC,EADI,EAElB,EAFkB,CAAnB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaF,YAAb,CAAR,CAA1B;AACA,QAAMG,iBAAiB,GAAG,qBAAQL,UAAR,CAA1B;AACA,QAAM;AAAEM,IAAAA,MAAM,EAAEC,WAAW,GAAG;AAAxB,MAAmCR,MAAzC;AACA,QAAMS,kBAAkB,GAAG,qBAAQD,WAAR,CAA3B;AACA,0BAAW,MAAM;AAChBF,IAAAA,iBAAiB,CAACI,OAAlB,GAA4BT,UAA5B;;AACA,QAAKK,iBAAiB,KAAKG,kBAA3B,EAAgD;AAC/CV,MAAAA,OAAO,CAACY,IAAR,CAAc,EACb,GAAGX,MADU;AAEbO,QAAAA,MAAM,EAAEN;AAFK,OAAd;AAIA;AACD,GARD,EAQG,CAAEA,UAAF,CARH;AAUA,0BAAW,MAAM;AAChBQ,IAAAA,kBAAkB,CAACC,OAAnB,GAA6BF,WAA7B;;AACA,QAAKA,WAAW,KAAKF,iBAAiB,CAACI,OAAvC,EAAiD;AAChDL,MAAAA,aAAa,CAAEG,WAAF,CAAb;AACA;AACD,GALD,EAKG,CAAEA,WAAF,CALH;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { useLocation, useHistory } from '../routes';\nimport { unlock } from '../../
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js"],"names":["useSyncCanvasModeWithURL","history","params","canvasMode","select","editSiteStore","getCanvasMode","setCanvasMode","currentCanvasMode","canvas","canvasInUrl","currentCanvasInUrl","current","push"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKe,SAASA,wBAAT,GAAoC;AAClD,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,UAAU,GAAG,qBAChBC,MAAF,IAAc,yBAAQA,MAAM,CAAEC,YAAF,CAAd,EAAkCC,aAAlC,EADI,EAElB,EAFkB,CAAnB;AAIA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,yBAAQ,uBAAaF,YAAb,CAAR,CAA1B;AACA,QAAMG,iBAAiB,GAAG,qBAAQL,UAAR,CAA1B;AACA,QAAM;AAAEM,IAAAA,MAAM,EAAEC,WAAW,GAAG;AAAxB,MAAmCR,MAAzC;AACA,QAAMS,kBAAkB,GAAG,qBAAQD,WAAR,CAA3B;AACA,0BAAW,MAAM;AAChBF,IAAAA,iBAAiB,CAACI,OAAlB,GAA4BT,UAA5B;;AACA,QAAKK,iBAAiB,KAAKG,kBAA3B,EAAgD;AAC/CV,MAAAA,OAAO,CAACY,IAAR,CAAc,EACb,GAAGX,MADU;AAEbO,QAAAA,MAAM,EAAEN;AAFK,OAAd;AAIA;AACD,GARD,EAQG,CAAEA,UAAF,CARH;AAUA,0BAAW,MAAM;AAChBQ,IAAAA,kBAAkB,CAACC,OAAnB,GAA6BF,WAA7B;;AACA,QAAKA,WAAW,KAAKF,iBAAiB,CAACI,OAAvC,EAAiD;AAChDL,MAAAA,aAAa,CAAEG,WAAF,CAAb;AACA;AACD,GALD,EAKG,CAAEA,WAAF,CALH;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { useLocation, useHistory } from '../routes';\nimport { unlock } from '../../private-apis';\n\nexport default function useSyncCanvasModeWithURL() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst canvasMode = useSelect(\n\t\t( select ) => unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t[]\n\t);\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst currentCanvasMode = useRef( canvasMode );\n\tconst { canvas: canvasInUrl = 'view' } = params;\n\tconst currentCanvasInUrl = useRef( canvasInUrl );\n\tuseEffect( () => {\n\t\tcurrentCanvasMode.current = canvasMode;\n\t\tif ( currentCanvasMode !== currentCanvasInUrl ) {\n\t\t\thistory.push( {\n\t\t\t\t...params,\n\t\t\t\tcanvas: canvasMode,\n\t\t\t} );\n\t\t}\n\t}, [ canvasMode ] );\n\n\tuseEffect( () => {\n\t\tcurrentCanvasInUrl.current = canvasInUrl;\n\t\tif ( canvasInUrl !== currentCanvasMode.current ) {\n\t\t\tsetCanvasMode( canvasInUrl );\n\t\t}\n\t}, [ canvasInUrl ] );\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = useSyncPathWithURL;
|
|
7
7
|
|
|
8
8
|
var _components = require("@wordpress/components");
|
|
9
9
|
|
|
@@ -18,36 +18,36 @@ var _routes = require("../routes");
|
|
|
18
18
|
/**
|
|
19
19
|
* Internal dependencies
|
|
20
20
|
*/
|
|
21
|
-
function
|
|
21
|
+
function useSyncPathWithURL() {
|
|
22
22
|
const history = (0, _routes.useHistory)();
|
|
23
23
|
const {
|
|
24
24
|
params
|
|
25
25
|
} = (0, _routes.useLocation)();
|
|
26
26
|
const {
|
|
27
|
-
|
|
27
|
+
path = '/'
|
|
28
28
|
} = params;
|
|
29
29
|
const {
|
|
30
30
|
location,
|
|
31
31
|
goTo
|
|
32
32
|
} = (0, _components.__experimentalUseNavigator)();
|
|
33
|
-
const
|
|
33
|
+
const currentPath = (0, _element.useRef)(path);
|
|
34
34
|
const currentNavigatorLocation = (0, _element.useRef)(location.path);
|
|
35
35
|
(0, _element.useEffect)(() => {
|
|
36
|
-
|
|
36
|
+
currentPath.current = path;
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
goTo(
|
|
38
|
+
if (path !== currentNavigatorLocation.current) {
|
|
39
|
+
goTo(path);
|
|
40
40
|
}
|
|
41
|
-
}, [
|
|
41
|
+
}, [path]);
|
|
42
42
|
(0, _element.useEffect)(() => {
|
|
43
43
|
currentNavigatorLocation.current = location.path;
|
|
44
44
|
|
|
45
|
-
if (location.path !==
|
|
45
|
+
if (location.path !== currentPath.current) {
|
|
46
46
|
history.push({ ...params,
|
|
47
|
-
|
|
47
|
+
path: location.path
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}, [location.path, history]);
|
|
51
|
-
return
|
|
51
|
+
return path;
|
|
52
52
|
}
|
|
53
|
-
//# sourceMappingURL=use-sync-
|
|
53
|
+
//# sourceMappingURL=use-sync-path-with-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sync-state-with-url/use-sync-path-with-url.js"],"names":["useSyncPathWithURL","history","params","path","location","goTo","currentPath","currentNavigatorLocation","current","push"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,kBAAT,GAA8B;AAC5C,QAAMC,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAM;AAAEC,IAAAA,IAAI,GAAG;AAAT,MAAiBD,MAAvB;AACA,QAAM;AAAEE,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAqB,6CAA3B;AACA,QAAMC,WAAW,GAAG,qBAAQH,IAAR,CAApB;AACA,QAAMI,wBAAwB,GAAG,qBAAQH,QAAQ,CAACD,IAAjB,CAAjC;AACA,0BAAW,MAAM;AAChBG,IAAAA,WAAW,CAACE,OAAZ,GAAsBL,IAAtB;;AACA,QAAKA,IAAI,KAAKI,wBAAwB,CAACC,OAAvC,EAAiD;AAChDH,MAAAA,IAAI,CAAEF,IAAF,CAAJ;AACA;AACD,GALD,EAKG,CAAEA,IAAF,CALH;AAMA,0BAAW,MAAM;AAChBI,IAAAA,wBAAwB,CAACC,OAAzB,GAAmCJ,QAAQ,CAACD,IAA5C;;AACA,QAAKC,QAAQ,CAACD,IAAT,KAAkBG,WAAW,CAACE,OAAnC,EAA6C;AAC5CP,MAAAA,OAAO,CAACQ,IAAR,CAAc,EACb,GAAGP,MADU;AAEbC,QAAAA,IAAI,EAAEC,QAAQ,CAACD;AAFF,OAAd;AAIA;AACD,GARD,EAQG,CAAEC,QAAQ,CAACD,IAAX,EAAiBF,OAAjB,CARH;AAUA,SAAOE,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUseNavigator as useNavigator } from '@wordpress/components';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useLocation, useHistory } from '../routes';\n\nexport default function useSyncPathWithURL() {\n\tconst history = useHistory();\n\tconst { params } = useLocation();\n\tconst { path = '/' } = params;\n\tconst { location, goTo } = useNavigator();\n\tconst currentPath = useRef( path );\n\tconst currentNavigatorLocation = useRef( location.path );\n\tuseEffect( () => {\n\t\tcurrentPath.current = path;\n\t\tif ( path !== currentNavigatorLocation.current ) {\n\t\t\tgoTo( path );\n\t\t}\n\t}, [ path ] );\n\tuseEffect( () => {\n\t\tcurrentNavigatorLocation.current = location.path;\n\t\tif ( location.path !== currentPath.current ) {\n\t\t\thistory.push( {\n\t\t\t\t...params,\n\t\t\t\tpath: location.path,\n\t\t\t} );\n\t\t}\n\t}, [ location.path, history ] );\n\n\treturn path;\n}\n"]}
|
|
@@ -26,6 +26,7 @@ function useEditedEntityRecord() {
|
|
|
26
26
|
const {
|
|
27
27
|
record,
|
|
28
28
|
title,
|
|
29
|
+
description,
|
|
29
30
|
isLoaded
|
|
30
31
|
} = (0, _data.useSelect)(select => {
|
|
31
32
|
const {
|
|
@@ -45,16 +46,19 @@ function useEditedEntityRecord() {
|
|
|
45
46
|
|
|
46
47
|
const _isLoaded = !!postId;
|
|
47
48
|
|
|
49
|
+
const templateInfo = getTemplateInfo(_record);
|
|
48
50
|
return {
|
|
49
51
|
record: _record,
|
|
50
|
-
title:
|
|
52
|
+
title: templateInfo.title,
|
|
53
|
+
description: templateInfo.description,
|
|
51
54
|
isLoaded: _isLoaded
|
|
52
55
|
};
|
|
53
56
|
}, []);
|
|
54
57
|
return {
|
|
55
58
|
isLoaded,
|
|
56
59
|
record,
|
|
57
|
-
getTitle: () => title ? (0, _htmlEntities.decodeEntities)(title) : null
|
|
60
|
+
getTitle: () => title ? (0, _htmlEntities.decodeEntities)(title) : null,
|
|
61
|
+
getDescription: () => description ? (0, _htmlEntities.decodeEntities)(description) : null
|
|
58
62
|
};
|
|
59
63
|
}
|
|
60
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","record","title","isLoaded","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","postType","postId","_record","_isLoaded","getTitle"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/use-edited-entity-record/index.js"],"names":["useEditedEntityRecord","record","title","description","isLoaded","select","getEditedPostType","getEditedPostId","editSiteStore","getEditedEntityRecord","coreStore","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","postType","postId","_record","_isLoaded","templateInfo","getTitle","getDescription"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAKA;;AAXA;AACA;AACA;;AAMA;AACA;AACA;AAGe,SAASA,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA,WAAjB;AAA8BC,IAAAA;AAA9B,MAA2C,qBAAaC,MAAF,IAAc;AACzE,UAAM;AAAEC,MAAAA,iBAAF;AAAqBC,MAAAA;AAArB,QAAyCF,MAAM,CAAEG,YAAF,CAArD;AACA,UAAM;AAAEC,MAAAA;AAAF,QAA4BJ,MAAM,CAAEK,eAAF,CAAxC;AACA,UAAM;AAAEC,MAAAA,6BAA6B,EAAEC;AAAjC,QACLP,MAAM,CAAEQ,aAAF,CADP;AAEA,UAAMC,QAAQ,GAAGR,iBAAiB,EAAlC;AACA,UAAMS,MAAM,GAAGR,eAAe,EAA9B;;AACA,UAAMS,OAAO,GAAGP,qBAAqB,CAAE,UAAF,EAAcK,QAAd,EAAwBC,MAAxB,CAArC;;AACA,UAAME,SAAS,GAAG,CAAC,CAAEF,MAArB;;AACA,UAAMG,YAAY,GAAGN,eAAe,CAAEI,OAAF,CAApC;AAEA,WAAO;AACNf,MAAAA,MAAM,EAAEe,OADF;AAENd,MAAAA,KAAK,EAAEgB,YAAY,CAAChB,KAFd;AAGNC,MAAAA,WAAW,EAAEe,YAAY,CAACf,WAHpB;AAINC,MAAAA,QAAQ,EAAEa;AAJJ,KAAP;AAMA,GAjBgD,EAiB9C,EAjB8C,CAAjD;AAmBA,SAAO;AACNb,IAAAA,QADM;AAENH,IAAAA,MAFM;AAGNkB,IAAAA,QAAQ,EAAE,MAAQjB,KAAK,GAAG,kCAAgBA,KAAhB,CAAH,GAA6B,IAH9C;AAINkB,IAAAA,cAAc,EAAE,MACfjB,WAAW,GAAG,kCAAgBA,WAAhB,CAAH,GAAmC;AALzC,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function useEditedEntityRecord() {\n\tconst { record, title, description, isLoaded } = useSelect( ( select ) => {\n\t\tconst { getEditedPostType, getEditedPostId } = select( editSiteStore );\n\t\tconst { getEditedEntityRecord } = select( coreStore );\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\t\tconst postType = getEditedPostType();\n\t\tconst postId = getEditedPostId();\n\t\tconst _record = getEditedEntityRecord( 'postType', postType, postId );\n\t\tconst _isLoaded = !! postId;\n\t\tconst templateInfo = getTemplateInfo( _record );\n\n\t\treturn {\n\t\t\trecord: _record,\n\t\t\ttitle: templateInfo.title,\n\t\t\tdescription: templateInfo.description,\n\t\t\tisLoaded: _isLoaded,\n\t\t};\n\t}, [] );\n\n\treturn {\n\t\tisLoaded,\n\t\trecord,\n\t\tgetTitle: () => ( title ? decodeEntities( title ) : null ),\n\t\tgetDescription: () =>\n\t\t\tdescription ? decodeEntities( description ) : null,\n\t};\n}\n"]}
|
|
@@ -22,7 +22,7 @@ var _notices = require("@wordpress/notices");
|
|
|
22
22
|
|
|
23
23
|
var _hooks2 = require("../../components/global-styles/hooks");
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var _privateApis = require("../../private-apis");
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* External dependencies
|
|
@@ -37,7 +37,7 @@ var _experiments = require("../../experiments");
|
|
|
37
37
|
*/
|
|
38
38
|
const {
|
|
39
39
|
GlobalStylesContext
|
|
40
|
-
} = (0,
|
|
40
|
+
} = (0, _privateApis.unlock)(_blockEditor.privateApis); // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
|
|
41
41
|
// removed by moving PushChangesToGlobalStylesControl to
|
|
42
42
|
// @wordpress/block-editor.
|
|
43
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["GlobalStylesContext","blockEditorExperiments","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","getChangesToPush","name","attributes","flatMap","key","STYLE_PROPERTY","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props"],"mappings":";;AAqBA;;AAlBA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAA0B,yBAAQC,wBAAR,CAAhC,C,CAEA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG;AACnC,sBAAoB,OADe;AAEnC,gBAAc,OAFqB;AAGnC,8BAA4B,OAHO;AAInC,qCAAmC,OAJA;AAKnC,yCAAuC,aALJ;AAMnC,uCAAqC,WANF;AAOnC,gCAA8B,OAPK;AAQnC,sCAAoC,OARD;AASnC,2CAAyC,aATN;AAUnC,yCAAuC,WAVJ;AAWnC,4BAA0B,OAXS;AAYnC,uCAAqC,OAZF;AAanC,4CAA0C,aAbP;AAcnC,+BAA6B,UAdM;AAenC,qCAAmC,UAfA;AAgBnC,uBAAqB,OAhBc;AAiBnC,kCAAgC,OAjBG;AAkBnC,uCAAqC,aAlBF;AAmBnC,gCAA8B,UAnBK;AAoBnC,uBAAqB,OApBc;AAqBnC,kCAAgC,OArBG;AAsBnC,uCAAqC,aAtBF;AAuBnC,gCAA8B,UAvBK;AAwBnC,uBAAqB,OAxBc;AAyBnC,kCAAgC,OAzBG;AA0BnC,uCAAqC,aA1BF;AA2BnC,gCAA8B,UA3BK;AA4BnC,uBAAqB,OA5Bc;AA6BnC,kCAAgC,OA7BG;AA8BnC,uCAAqC,aA9BF;AA+BnC,gCAA8B,UA/BK;AAgCnC,uBAAqB,OAhCc;AAiCnC,kCAAgC,OAjCG;AAkCnC,uCAAqC,aAlCF;AAmCnC,gCAA8B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I,oBAAJ,CAFD,EAGC,0BAAcxB,IAAd,EAAqBiC,KAHtB,CADkB,EAMlB;AACCC,MAAAA,IAAI,EAAE,UADP;AAECC,MAAAA,OAAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;;AAECC,QAAAA,OAAO,GAAG;AACTf,UAAAA,uCAAuC;;AACvCL,UAAAA,aAAa,CAAE;AAAEP,YAAAA,KAAK,EAAEkB;AAAT,WAAF,CAAb;AACAP,UAAAA,aAAa,CAAE,MAAMD,UAAR,EAAoB;AAChCY,YAAAA,UAAU,EAAE;AADoB,WAApB,CAAb;AAGA;;AARF,OADQ;AAFV,KANkB,CAAnB;AAsBA,GA7CmB,EA6CjB,CAAEd,OAAF,EAAWjB,UAAX,EAAuBmB,UAAvB,EAAmCpB,IAAnC,CA7CiB,CAApB;AA+CA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAG,oBACN;AACA,kBACC,wFADD,CAFM,EAKN,0BAAcA,IAAd,EAAqBiC,KALf;AAFR,KAUC,4BAAC,uBAAD,CAAa,WAAb,QACG,cAAI,QAAJ,CADH,CAVD,EAaC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,QAAQ,EAAGf,OAAO,CAACS,MAAR,KAAmB,CAF/B;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKG,cAAI,gBAAJ,CALH,CAbD,CADD;AAuBA;;AAED,MAAMY,6BAA6B,GAAG,yCACnCC,SAAF,IAAmBC,KAAF,IAEf,qDACC,4BAAC,SAAD,EAAgBA,KAAhB,CADD,EAEC,4BAAC,sCAAD,QACC,4BAAC,gCAAD,EAAuCA,KAAvC,CADD,CAFD,CAHmC,CAAtC;AAYA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\texperiments as blockEditorExperiments,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels } from '../../components/global-styles/hooks';\nimport { unlock } from '../../experiments';\n\nconst { GlobalStylesContext } = unlock( blockEditorExperiments );\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nfunction getChangesToPush( name, attributes ) {\n\treturn getSupportedGlobalStylesPanels( name ).flatMap( ( key ) => {\n\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\tconst presetAttributeKey = path.join( '.' );\n\t\tconst presetAttributeValue =\n\t\t\tattributes[\n\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t];\n\t\tconst value = presetAttributeValue\n\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t: get( attributes.style, path );\n\t\treturn value ? [ { path, value } ] : [];\n\t} );\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst changes = useMemo(\n\t\t() => getChangesToPush( name, attributes ),\n\t\t[ name, attributes ]\n\t);\n\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { style: blockStyles } = attributes;\n\n\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\tfor ( const { path, value } of changes ) {\n\t\t\tset( newBlockStyles, path, undefined );\n\t\t\tset( newUserConfig, [ 'styles', 'blocks', name, ...path ], value );\n\t\t}\n\n\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t// tracking and implement our own Undo button in the snackbar\n\t\t// notification.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { style: newBlockStyles } );\n\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\tsetAttributes( { style: blockStyles } );\n\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ changes, attributes, userConfig, name ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) =>\n\t\t(\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t</InspectorAdvancedControls>\n\t\t\t</>\n\t\t)\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["GlobalStylesContext","blockEditorPrivateApis","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","getChangesToPush","name","attributes","flatMap","key","STYLE_PROPERTY","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props"],"mappings":";;AAqBA;;AAlBA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAA0B,yBAAQC,wBAAR,CAAhC,C,CAEA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG;AACnC,sBAAoB,OADe;AAEnC,gBAAc,OAFqB;AAGnC,8BAA4B,OAHO;AAInC,qCAAmC,OAJA;AAKnC,yCAAuC,aALJ;AAMnC,uCAAqC,WANF;AAOnC,gCAA8B,OAPK;AAQnC,sCAAoC,OARD;AASnC,2CAAyC,aATN;AAUnC,yCAAuC,WAVJ;AAWnC,4BAA0B,OAXS;AAYnC,uCAAqC,OAZF;AAanC,4CAA0C,aAbP;AAcnC,+BAA6B,UAdM;AAenC,qCAAmC,UAfA;AAgBnC,uBAAqB,OAhBc;AAiBnC,kCAAgC,OAjBG;AAkBnC,uCAAqC,aAlBF;AAmBnC,gCAA8B,UAnBK;AAoBnC,uBAAqB,OApBc;AAqBnC,kCAAgC,OArBG;AAsBnC,uCAAqC,aAtBF;AAuBnC,gCAA8B,UAvBK;AAwBnC,uBAAqB,OAxBc;AAyBnC,kCAAgC,OAzBG;AA0BnC,uCAAqC,aA1BF;AA2BnC,gCAA8B,UA3BK;AA4BnC,uBAAqB,OA5Bc;AA6BnC,kCAAgC,OA7BG;AA8BnC,uCAAqC,aA9BF;AA+BnC,gCAA8B,UA/BK;AAgCnC,uBAAqB,OAhCc;AAiCnC,kCAAgC,OAjCG;AAkCnC,uCAAqC,aAlCF;AAmCnC,gCAA8B,UAnCK;AAoCnC,uBAAqB,OApCc;AAqCnC,kCAAgC,OArCG;AAsCnC,uCAA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;AACCC,MAAAA,IAAI,EAAE,UADP;AAECC,MAAAA,OAAO,EAAE,CACR;AACCC,QAAAA,KAAK,EAAE,cAAI,MAAJ,CADR;;AAECC,QAAAA,OAAO,GAAG;AACTf,UAAAA,uCAAuC;;AACvCL,UAAAA,aAAa,CAAE;AAAEP,YAAAA,KAAK,EAAEkB;AAAT,WAAF,CAAb;AACAP,UAAAA,aAAa,CAAE,MAAMD,UAAR,EAAoB;AAChCY,YAAAA,UAAU,EAAE;AADoB,WAApB,CAAb;AAGA;;AARF,OADQ;AAFV,KANkB,CAAnB;AAsBA,GA7CmB,EA6CjB,CAAEd,OAAF,EAAWjB,UAAX,EAAuBmB,UAAvB,EAAmCpB,IAAnC,CA7CiB,CAApB;AA+CA,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAG,oBACN;AACA,kBACC,wFADD,CAFM,EAKN,0BAAcA,IAAd,EAAqBiC,KALf;AAFR,KAUC,4BAAC,uBAAD,CAAa,WAAb,QACG,cAAI,QAAJ,CADH,CAVD,EAaC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,QAAQ,EAAGf,OAAO,CAACS,MAAR,KAAmB,CAF/B;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKG,cAAI,gBAAJ,CALH,CAbD,CADD;AAuBA;;AAED,MAAMY,6BAA6B,GAAG,yCACnCC,SAAF,IAAmBC,KAAF,IAEf,qDACC,4BAAC,SAAD,EAAgBA,KAAhB,CADD,EAEC,4BAAC,sCAAD,QACC,4BAAC,gCAAD,EAAuCA,KAAvC,CADD,CAFD,CAHmC,CAAtC;AAYA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { getSupportedGlobalStylesPanels } from '../../components/global-styles/hooks';\nimport { unlock } from '../../private-apis';\n\nconst { GlobalStylesContext } = unlock( blockEditorPrivateApis );\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nfunction getChangesToPush( name, attributes ) {\n\treturn getSupportedGlobalStylesPanels( name ).flatMap( ( key ) => {\n\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\tconst presetAttributeKey = path.join( '.' );\n\t\tconst presetAttributeValue =\n\t\t\tattributes[\n\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t];\n\t\tconst value = presetAttributeValue\n\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t: get( attributes.style, path );\n\t\treturn value ? [ { path, value } ] : [];\n\t} );\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst changes = useMemo(\n\t\t() => getChangesToPush( name, attributes ),\n\t\t[ name, attributes ]\n\t);\n\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { style: blockStyles } = attributes;\n\n\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\tfor ( const { path, value } of changes ) {\n\t\t\tset( newBlockStyles, path, undefined );\n\t\t\tset( newUserConfig, [ 'styles', 'blocks', name, ...path ], value );\n\t\t}\n\n\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t// tracking and implement our own Undo button in the snackbar\n\t\t// notification.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { style: newBlockStyles } );\n\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\tsetAttributes( { style: blockStyles } );\n\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t}\n\t\t);\n\t}, [ changes, attributes, userConfig, name ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) =>\n\t\t(\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t</InspectorAdvancedControls>\n\t\t\t</>\n\t\t)\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.unlock = exports.lock = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _privateApis = require("@wordpress/private-apis");
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* WordPress dependencies
|
|
@@ -13,7 +13,7 @@ var _experiments = require("@wordpress/experiments");
|
|
|
13
13
|
const {
|
|
14
14
|
lock,
|
|
15
15
|
unlock
|
|
16
|
-
} = (0,
|
|
16
|
+
} = (0, _privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', '@wordpress/edit-site');
|
|
17
17
|
exports.unlock = unlock;
|
|
18
18
|
exports.lock = lock;
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=private-apis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/private-apis.js"],"names":["lock","unlock"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAM;AAAEA,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IACZ,mEACC,8GADD,EAEC,sBAFD,CADM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',\n\t\t'@wordpress/edit-site'\n\t);\n"]}
|
package/build/store/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var privateSelectors = _interopRequireWildcard(require("./private-selectors"));
|
|
|
21
21
|
|
|
22
22
|
var _constants = require("./constants");
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _privateApis = require("../private-apis");
|
|
25
25
|
|
|
26
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
27
|
|
|
@@ -43,6 +43,6 @@ exports.storeConfig = storeConfig;
|
|
|
43
43
|
const store = (0, _data.createReduxStore)(_constants.STORE_NAME, storeConfig);
|
|
44
44
|
exports.store = store;
|
|
45
45
|
(0, _data.register)(store);
|
|
46
|
-
(0,
|
|
47
|
-
(0,
|
|
46
|
+
(0, _privateApis.unlock)(store).registerPrivateSelectors(privateSelectors);
|
|
47
|
+
(0, _privateApis.unlock)(store).registerPrivateActions(privateActions);
|
|
48
48
|
//# sourceMappingURL=index.js.map
|
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","store","STORE_NAME","registerPrivateSelectors","privateSelectors","registerPrivateActions","privateActions"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAdA;AACA;AACA;;AAGA;AACA;AACA;AASO,MAAMA,WAAW,GAAG;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA;AAH0B,CAApB;;AAMA,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8BL,WAA9B,CAAd;;AACP,oBAAUI,KAAV;AACA,yBAAQA,KAAR,EAAgBE,wBAAhB,CAA0CC,gBAA1C;AACA,yBAAQH,KAAR,EAAgBI,sBAAhB,CAAwCC,cAAxC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as privateActions from './private-actions';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/store/index.js"],"names":["storeConfig","reducer","actions","selectors","store","STORE_NAME","registerPrivateSelectors","privateSelectors","registerPrivateActions","privateActions"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAdA;AACA;AACA;;AAGA;AACA;AACA;AASO,MAAMA,WAAW,GAAG;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,OAF0B;AAG1BC,EAAAA;AAH0B,CAApB;;AAMA,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8BL,WAA9B,CAAd;;AACP,oBAAUI,KAAV;AACA,yBAAQA,KAAR,EAAgBE,wBAAhB,CAA0CC,gBAA1C;AACA,yBAAQH,KAAR,EAAgBI,sBAAhB,CAAwCC,cAAxC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as privateActions from './private-actions';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../private-apis';\n\nexport const storeConfig = {\n\treducer,\n\tactions,\n\tselectors,\n};\n\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\nunlock( store ).registerPrivateSelectors( privateSelectors );\nunlock( store ).registerPrivateActions( privateActions );\n"]}
|
|
@@ -8,16 +8,15 @@ exports.default = getIsListPage;
|
|
|
8
8
|
/**
|
|
9
9
|
* Returns if the params match the list page route.
|
|
10
10
|
*
|
|
11
|
-
* @param {Object} params
|
|
12
|
-
* @param {string} params.
|
|
13
|
-
*
|
|
11
|
+
* @param {Object} params The url params.
|
|
12
|
+
* @param {string} params.path The current path.
|
|
13
|
+
*
|
|
14
14
|
* @return {boolean} Is list page or not.
|
|
15
15
|
*/
|
|
16
16
|
function getIsListPage(_ref) {
|
|
17
17
|
let {
|
|
18
|
-
|
|
19
|
-
postType
|
|
18
|
+
path
|
|
20
19
|
} = _ref;
|
|
21
|
-
return
|
|
20
|
+
return path === '/templates/all' || path === '/template-parts/all';
|
|
22
21
|
}
|
|
23
22
|
//# sourceMappingURL=get-is-list-page.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/utils/get-is-list-page.js"],"names":["getIsListPage","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/utils/get-is-list-page.js"],"names":["getIsListPage","path"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,OAAmC;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACjD,SAAOA,IAAI,KAAK,gBAAT,IAA6BA,IAAI,KAAK,qBAA7C;AACA","sourcesContent":["/**\n * Returns if the params match the list page route.\n *\n * @param {Object} params The url params.\n * @param {string} params.path The current path.\n *\n * @return {boolean} Is list page or not.\n */\nexport default function getIsListPage( { path } ) {\n\treturn path === '/templates/all' || path === '/template-parts/all';\n}\n"]}
|
|
@@ -19,7 +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 '../../
|
|
22
|
+
import { unlock } from '../../private-apis';
|
|
23
23
|
export default function NewTemplatePart(_ref) {
|
|
24
24
|
let {
|
|
25
25
|
postType,
|
|
@@ -67,9 +67,12 @@ export default function NewTemplatePart(_ref) {
|
|
|
67
67
|
|
|
68
68
|
setCanvasMode('edit'); // Navigate to the created template part editor.
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
window.queueMicrotask(() => {
|
|
71
|
+
history.push({
|
|
72
|
+
postId: templatePart.id,
|
|
73
|
+
postType: 'wp_template_part',
|
|
74
|
+
path: '/template-parts/single'
|
|
75
|
+
});
|
|
73
76
|
}); // TODO: Add a success notice?
|
|
74
77
|
} catch (error) {
|
|
75
78
|
const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : __('An error occurred while creating the template part.');
|
|
@@ -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","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,
|
|
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","window","queueMicrotask","push","postId","id","path","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;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OARrC,CADD,EAWG3B,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 '../../private-apis';\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\twindow.queueMicrotask( () => {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpostId: templatePart.id,\n\t\t\t\t\tpostType: 'wp_template_part',\n\t\t\t\t\tpath: '/template-parts/single',\n\t\t\t\t} );\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,7 +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 '../../
|
|
25
|
+
import { unlock } from '../../private-apis';
|
|
26
26
|
const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'single', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'taxonomy', 'search', '404'];
|
|
27
27
|
const TEMPLATE_ICONS = {
|
|
28
28
|
'front-page': home,
|
|
@@ -108,9 +108,12 @@ export default function NewTemplate(_ref) {
|
|
|
108
108
|
|
|
109
109
|
setCanvasMode('edit'); // Navigate to the created template editor.
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
window.queueMicrotask(() => {
|
|
112
|
+
history.push({
|
|
113
|
+
postId: newTemplate.id,
|
|
114
|
+
postType: newTemplate.type,
|
|
115
|
+
path: '/templates/single'
|
|
116
|
+
});
|
|
114
117
|
});
|
|
115
118
|
createSuccessNotice(sprintf( // translators: %s: Title of the created template e.g: "Category".
|
|
116
119
|
__('"%s" successfully created.'), title), {
|