@wordpress/edit-site 5.6.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/add-new-template/new-template-part.js +3 -11
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +7 -7
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +1 -1
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +7 -10
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +6 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +35 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +8 -11
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +11 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +53 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +45 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/global-styles-provider.js +7 -4
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -58
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview.js +4 -5
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +17 -12
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +22 -211
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +1 -1
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-effects.js +15 -7
- package/build/components/global-styles/screen-effects.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +2 -2
- package/build/components/global-styles/screen-filters.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -118
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +149 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -0
- package/build/components/global-styles/ui.js +51 -37
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +1 -2
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +1 -1
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -137
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +8 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +4 -0
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +6 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +4 -0
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +8 -6
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js +5 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/site-hub/index.js +4 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/start-template-options/index.js +44 -9
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/style-book/index.js +6 -7
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +1 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/hooks/commands/index.js +19 -0
- package/build/hooks/commands/index.js.map +1 -0
- package/build/hooks/commands/use-navigation-commands.js +117 -0
- package/build/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build/hooks/commands/use-wp-admin-commands.js +94 -0
- package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +2 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +3 -9
- 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 -7
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +1 -1
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +8 -11
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +6 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +34 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +8 -8
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +11 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +43 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +35 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/global-styles-provider.js +8 -5
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -52
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview.js +4 -5
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +16 -11
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +23 -208
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +1 -1
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-effects.js +13 -4
- package/build-module/components/global-styles/screen-effects.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +2 -2
- package/build-module/components/global-styles/screen-filters.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +11 -114
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +130 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -0
- package/build-module/components/global-styles/ui.js +49 -33
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +1 -2
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -135
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +6 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -0
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -2
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -0
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +9 -7
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -3
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +45 -10
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/style-book/index.js +7 -8
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +1 -1
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/hooks/commands/index.js +10 -0
- package/build-module/hooks/commands/index.js.map +1 -0
- package/build-module/hooks/commands/use-navigation-commands.js +101 -0
- package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js +79 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +2 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +24 -63
- package/build-style/style.css +24 -63
- package/package.json +33 -31
- package/src/components/add-new-template/new-template-part.js +1 -6
- package/src/components/add-new-template/new-template.js +3 -6
- package/src/components/add-new-template/utils.js +1 -1
- package/src/components/block-editor/editor-canvas.js +13 -23
- package/src/components/editor/index.js +11 -3
- package/src/components/global-styles/border-panel.js +32 -1
- package/src/components/global-styles/context-menu.js +8 -8
- package/src/components/global-styles/dimensions-panel.js +11 -0
- package/src/components/global-styles/effects-panel.js +40 -0
- package/src/components/global-styles/filters-panel.js +33 -0
- package/src/components/global-styles/global-styles-provider.js +4 -4
- package/src/components/global-styles/hooks.js +1 -78
- package/src/components/global-styles/preview.js +2 -2
- package/src/components/global-styles/screen-block-list.js +11 -7
- package/src/components/global-styles/screen-colors.js +25 -229
- package/src/components/global-styles/screen-css.js +1 -1
- package/src/components/global-styles/screen-effects.js +12 -5
- package/src/components/global-styles/screen-filters.js +2 -2
- package/src/components/global-styles/screen-style-variations.js +10 -129
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +6 -0
- package/src/components/global-styles/stories/index.js +425 -0
- package/src/components/global-styles/style-variations-container.js +136 -0
- package/src/components/global-styles/style.scss +4 -57
- package/src/components/global-styles/ui.js +50 -33
- package/src/components/global-styles-renderer/index.js +1 -2
- package/src/components/header-edit-mode/more-menu/index.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -155
- package/src/components/layout/index.js +4 -0
- package/src/components/preferences-modal/index.js +7 -0
- package/src/components/secondary-sidebar/list-view-sidebar.js +4 -3
- package/src/components/sidebar/index.js +4 -0
- package/src/components/sidebar-navigation-screen/index.js +10 -5
- package/src/components/sidebar-navigation-screen/style.scss +20 -5
- package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/src/components/sidebar-navigation-screen-main/index.js +9 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
- package/src/components/site-hub/index.js +3 -3
- package/src/components/start-template-options/index.js +40 -8
- package/src/components/start-template-options/style.scss +7 -14
- package/src/components/style-book/index.js +10 -16
- package/src/components/style-book/style.scss +1 -1
- package/src/components/welcome-guide/styles.js +1 -1
- package/src/hooks/commands/index.js +10 -0
- package/src/hooks/commands/use-navigation-commands.js +103 -0
- package/src/hooks/commands/use-wp-admin-commands.js +77 -0
- package/src/hooks/push-changes-to-global-styles/index.js +1 -0
- package/src/hooks/template-part-edit.js +1 -0
- package/src/index.js +1 -0
- package/src/store/selectors.js +2 -1
- package/build/components/global-styles/color-utils.js +0 -17
- package/build/components/global-styles/color-utils.js.map +0 -1
- package/build/components/global-styles/duotone-panel.js +0 -78
- package/build/components/global-styles/duotone-panel.js.map +0 -1
- package/build/components/global-styles/filter-utils.js +0 -17
- package/build/components/global-styles/filter-utils.js.map +0 -1
- package/build/components/global-styles/screen-background-color.js +0 -114
- package/build/components/global-styles/screen-background-color.js.map +0 -1
- package/build/components/global-styles/screen-button-color.js +0 -88
- package/build/components/global-styles/screen-button-color.js.map +0 -1
- package/build/components/global-styles/screen-heading-color.js +0 -165
- package/build/components/global-styles/screen-heading-color.js.map +0 -1
- package/build/components/global-styles/screen-link-color.js +0 -105
- package/build/components/global-styles/screen-link-color.js.map +0 -1
- package/build/components/global-styles/screen-text-color.js +0 -71
- package/build/components/global-styles/screen-text-color.js.map +0 -1
- package/build/components/global-styles/shadow-panel.js +0 -197
- package/build/components/global-styles/shadow-panel.js.map +0 -1
- package/build-module/components/global-styles/color-utils.js +0 -9
- package/build-module/components/global-styles/color-utils.js.map +0 -1
- package/build-module/components/global-styles/duotone-panel.js +0 -67
- package/build-module/components/global-styles/duotone-panel.js.map +0 -1
- package/build-module/components/global-styles/filter-utils.js +0 -9
- package/build-module/components/global-styles/filter-utils.js.map +0 -1
- package/build-module/components/global-styles/screen-background-color.js +0 -97
- package/build-module/components/global-styles/screen-background-color.js.map +0 -1
- package/build-module/components/global-styles/screen-button-color.js +0 -73
- package/build-module/components/global-styles/screen-button-color.js.map +0 -1
- package/build-module/components/global-styles/screen-heading-color.js +0 -149
- package/build-module/components/global-styles/screen-heading-color.js.map +0 -1
- package/build-module/components/global-styles/screen-link-color.js +0 -89
- package/build-module/components/global-styles/screen-link-color.js.map +0 -1
- package/build-module/components/global-styles/screen-text-color.js +0 -56
- package/build-module/components/global-styles/screen-text-color.js.map +0 -1
- package/build-module/components/global-styles/shadow-panel.js +0 -178
- package/build-module/components/global-styles/shadow-panel.js.map +0 -1
- package/src/components/global-styles/color-utils.js +0 -14
- package/src/components/global-styles/duotone-panel.js +0 -82
- package/src/components/global-styles/filter-utils.js +0 -9
- package/src/components/global-styles/screen-background-color.js +0 -132
- package/src/components/global-styles/screen-button-color.js +0 -104
- package/src/components/global-styles/screen-heading-color.js +0 -206
- package/src/components/global-styles/screen-link-color.js +0 -124
- package/src/components/global-styles/screen-text-color.js +0 -62
- package/src/components/global-styles/shadow-panel.js +0 -178
|
@@ -213,15 +213,14 @@ function StyleBook(_ref) {
|
|
|
213
213
|
tabs: tabs
|
|
214
214
|
}, tab => (0, _element.createElement)(_blockEditor.__unstableIframe, {
|
|
215
215
|
className: "edit-site-style-book__iframe",
|
|
216
|
-
head: (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.__unstableEditorStyles, {
|
|
217
|
-
styles: settings.styles
|
|
218
|
-
}), (0, _element.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing.
|
|
219
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
220
|
-
`.is-root-container { display: flow-root; }
|
|
221
|
-
body { position: relative; padding: 32px !important; }` + STYLE_BOOK_IFRAME_STYLES)),
|
|
222
216
|
name: "style-book-canvas",
|
|
223
217
|
tabIndex: 0
|
|
224
|
-
},
|
|
218
|
+
}, (0, _element.createElement)(_blockEditor.__unstableEditorStyles, {
|
|
219
|
+
styles: settings.styles
|
|
220
|
+
}), (0, _element.createElement)("style", null, // Forming a "block formatting context" to prevent margin collapsing.
|
|
221
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
222
|
+
`.is-root-container { display: flow-root; }
|
|
223
|
+
body { position: relative; padding: 32px !important; }` + STYLE_BOOK_IFRAME_STYLES), (0, _element.createElement)(Examples, {
|
|
225
224
|
className: (0, _classnames.default)('edit-site-style-book__examples', {
|
|
226
225
|
'is-wide': sizes.width > 600
|
|
227
226
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/style-book/index.js"],"names":["ExperimentalBlockEditorProvider","useGlobalStyle","blockEditorPrivateApis","SLOT_FILL_NAME","Slot","StyleBookSlot","Fill","StyleBookFill","STYLE_BOOK_IFRAME_STYLES","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","supports","inserter","map","StyleBook","isSelected","onSelect","onClose","resizeObserver","sizes","focusOnMountRef","sectionFocusReturnRef","textColor","backgroundColor","examples","tabs","some","slug","icon","originalSettings","select","blockEditorStore","getSettings","settings","__unstableIsPreviewMode","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","preventDefault","width","color","background","closeSmall","tab","styles","svgFilters","Examples","className","label","composite","orientation","Example","id","onClick","renderedBlocks","Array","isArray","useHasStyleBook","fills","length"],"mappings":";;;;;;;;;;AAwCA;;;;AArCA;;AAKA;;AAUA;;AACA;;AAMA;;AAOA;;AACA;;AACA;;AAOA;;AAKA;;AA9CA;AACA;AACA;;AAGA;AACA;AACA;;AAoCA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA,+BAAF;AAAmCC,EAAAA;AAAnC,IAAsD,yBAC3DC,wBAD2D,CAA5D;AAIA,MAAMC,cAAc,GAAG,mBAAvB;AACA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IACL,gCAAgBJ,cAAhB,CADD,C,CAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMK,wBAAwB,GAAI;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AAf;AAAuD;AAAvD,KACC,4BAAC,oBAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,4BAAC,+BAAD;AACC,IAAA,KAAK,EAAGsD,cADT;AAEC,IAAA,QAAQ,EAAGvB;AAFZ,KAIC,4BAAC,sBAAD;AAAW,IAAA,cAAc,EAAG;AAA5B,IAJD,CADD,CADD,CAlBD,CADD;AA+BA,CA/CD;;AAiDA,SAAS0B,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAG,4CAAcnE,cAAd,CAAd;AACA,SAAO,CAAC,EAAEmE,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,MAAT,CAAR;AACA;;AAED/C,SAAS,CAACpB,IAAV,GAAiBC,aAAjB;eACemB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n\tDisabled,\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\tBlockList,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\nimport {\n\tuseResizeObserver,\n\tuseFocusOnMount,\n\tuseFocusReturn,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\n\nconst SLOT_FILL_NAME = 'EditSiteStyleBook';\nconst { Slot: StyleBookSlot, Fill: StyleBookFill } =\n\tcreateSlotFill( SLOT_FILL_NAME );\n\n// The content area of the Style Book is rendered within an iframe so that global styles\n// are applied to elements within the entire content area. To support elements that are\n// not part of the block previews, such as headings and layout for the block previews,\n// additional CSS rules need to be passed into the iframe. These are hard-coded below.\n// Note that button styles are unset, and then focus rules from the `Button` component are\n// applied to the `button` element, targeted via `.edit-site-style-book__example`.\n// This is to ensure that browser default styles for buttons are not applied to the previews.\nconst STYLE_BOOK_IFRAME_STYLES = `\n\t.edit-site-style-book__examples {\n\t\tmax-width: 900px;\n\t\tmargin: 0 auto;\n\t}\n\n\t.edit-site-style-book__example {\n\t\tborder-radius: 2px;\n\t\tcursor: pointer;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 40px;\n\t\tmargin-bottom: 40px;\n\t\tpadding: 16px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.edit-site-style-book__example.is-selected {\n\t\tbox-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t}\n\n\t.edit-site-style-book__example:focus:not(:disabled) {\n\t\tbox-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t\toutline: 3px solid transparent;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example {\n\t\tflex-direction: row;\n\t}\n\n\t.edit-site-style-book__example-title {\n\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\tfont-size: 11px;\n\t\tfont-weight: 500;\n\t\tline-height: normal;\n\t\tmargin: 0;\n\t\ttext-align: left;\n\t\ttext-transform: uppercase;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {\n\t\ttext-align: right;\n\t\twidth: 120px;\n\t}\n\n\t.edit-site-style-book__example-preview {\n\t\twidth: 100%;\n\t}\n\n\t.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,\n\t.edit-site-style-book__example-preview .block-list-appender {\n\t\tdisplay: none;\n\t}\n\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {\n\t\tmargin-top: 0;\n\t}\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {\n\t\tmargin-bottom: 0;\n\t}\n`;\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 focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst sectionFocusReturnRef = useFocusReturn();\n\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\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tevent.preventDefault();\n\t\t\tonClose();\n\t\t}\n\t}\n\n\treturn (\n\t\t<StyleBookFill>\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\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\tonKeyDown={ closeOnEscape }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tsectionFocusReturnRef,\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t] ) }\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\tshowTooltip={ false }\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<Iframe\n\t\t\t\t\t\t\tclassName=\"edit-site-style-book__iframe\"\n\t\t\t\t\t\t\thead={\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t\t\t\t\t`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\t\t\t\t\tbody { position: relative; padding: 32px !important; }` +\n\t\t\t\t\t\t\t\t\t\t\t\tSTYLE_BOOK_IFRAME_STYLES\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tname=\"style-book-canvas\"\n\t\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ /* Filters need to be rendered before children to avoid Safari rendering issues. */ }\n\t\t\t\t\t\t\t{ settings.svgFilters }\n\t\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'edit-site-style-book__examples',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: Category of blocks, e.g. Text.\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Examples of blocks in the %s category'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\ttab.title\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Iframe>\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(\n\t( { className, examples, category, label, isSelected, onSelect } ) => {\n\t\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\t\treturn (\n\t\t\t<Composite\n\t\t\t\t{ ...composite }\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ label }\n\t\t\t>\n\t\t\t\t{ examples\n\t\t\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t\t\t.map( ( example ) => (\n\t\t\t\t\t\t<Example\n\t\t\t\t\t\t\tkey={ example.name }\n\t\t\t\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonSelect( example.name );\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</Composite>\n\t\t);\n\t}\n);\n\nconst Example = ( { composite, id, title, blocks, isSelected, onClick } ) => {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\t// Cache the list of blocks to avoid additional processing when the component is re-rendered.\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t{ ...composite }\n\t\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tid={ id }\n\t\t\taria-label={ sprintf(\n\t\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\t\ttitle\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t\trole=\"button\"\n\t\t\tas=\"div\"\n\t\t>\n\t\t\t<span className=\"edit-site-style-book__example-title\">\n\t\t\t\t{ title }\n\t\t\t</span>\n\t\t\t<div className=\"edit-site-style-book__example-preview\" aria-hidden>\n\t\t\t\t<Disabled className=\"edit-site-style-book__example-preview__content\">\n\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\tvalue={ renderedBlocks }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockList renderAppender={ false } />\n\t\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</CompositeItem>\n\t);\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":["ExperimentalBlockEditorProvider","useGlobalStyle","blockEditorPrivateApis","SLOT_FILL_NAME","Slot","StyleBookSlot","Fill","StyleBookFill","STYLE_BOOK_IFRAME_STYLES","getExamples","headingsExample","name","title","category","blocks","content","level","otherExamples","filter","blockType","example","supports","inserter","map","StyleBook","isSelected","onSelect","onClose","resizeObserver","sizes","focusOnMountRef","sectionFocusReturnRef","textColor","backgroundColor","examples","tabs","some","slug","icon","originalSettings","select","blockEditorStore","getSettings","settings","__unstableIsPreviewMode","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","preventDefault","width","color","background","closeSmall","tab","styles","Examples","className","label","composite","orientation","Example","id","onClick","renderedBlocks","Array","isArray","useHasStyleBook","fills","length"],"mappings":";;;;;;;;;;AAwCA;;;;AArCA;;AAKA;;AAUA;;AACA;;AAMA;;AAOA;;AACA;;AACA;;AAOA;;AAKA;;AA9CA;AACA;AACA;;AAGA;AACA;AACA;;AAoCA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA,+BAAF;AAAmCC,EAAAA;AAAnC,IAAsD,yBAC3DC,wBAD2D,CAA5D;AAIA,MAAMC,cAAc,GAAG,mBAAvB;AACA,MAAM;AAAEC,EAAAA,IAAI,EAAEC,aAAR;AAAuBC,EAAAA,IAAI,EAAEC;AAA7B,IACL,gCAAgBJ,cAAhB,CADD,C,CAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMK,wBAAwB,GAAI;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAA,cAAc,EAAG;AAA5B,IAJD,CADD,CADD,CAlBD,CADD;AA+BA,CA/CD;;AAiDA,SAASyB,eAAT,GAA2B;AAC1B,QAAMC,KAAK,GAAG,4CAAclE,cAAd,CAAd;AACA,SAAO,CAAC,EAAEkE,KAAF,aAAEA,KAAF,eAAEA,KAAK,CAAEC,MAAT,CAAR;AACA;;AAED9C,SAAS,CAACpB,IAAV,GAAiBC,aAAjB;eACemB,S","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__unstableComposite as Composite,\n\t__unstableUseCompositeState as useCompositeState,\n\t__unstableCompositeItem as CompositeItem,\n\tDisabled,\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\tBlockList,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n\t__unstableEditorStyles as EditorStyles,\n\t__unstableIframe as Iframe,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { closeSmall } from '@wordpress/icons';\nimport {\n\tuseResizeObserver,\n\tuseFocusOnMount,\n\tuseFocusReturn,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useMemo, memo } from '@wordpress/element';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\n\nconst SLOT_FILL_NAME = 'EditSiteStyleBook';\nconst { Slot: StyleBookSlot, Fill: StyleBookFill } =\n\tcreateSlotFill( SLOT_FILL_NAME );\n\n// The content area of the Style Book is rendered within an iframe so that global styles\n// are applied to elements within the entire content area. To support elements that are\n// not part of the block previews, such as headings and layout for the block previews,\n// additional CSS rules need to be passed into the iframe. These are hard-coded below.\n// Note that button styles are unset, and then focus rules from the `Button` component are\n// applied to the `button` element, targeted via `.edit-site-style-book__example`.\n// This is to ensure that browser default styles for buttons are not applied to the previews.\nconst STYLE_BOOK_IFRAME_STYLES = `\n\t.edit-site-style-book__examples {\n\t\tmax-width: 900px;\n\t\tmargin: 0 auto;\n\t}\n\n\t.edit-site-style-book__example {\n\t\tborder-radius: 2px;\n\t\tcursor: pointer;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tgap: 40px;\n\t\tmargin-bottom: 40px;\n\t\tpadding: 16px;\n\t\twidth: 100%;\n\t\tbox-sizing: border-box;\n\t}\n\n\t.edit-site-style-book__example.is-selected {\n\t\tbox-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t}\n\n\t.edit-site-style-book__example:focus:not(:disabled) {\n\t\tbox-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));\n\t\toutline: 3px solid transparent;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example {\n\t\tflex-direction: row;\n\t}\n\n\t.edit-site-style-book__example-title {\n\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\tfont-size: 11px;\n\t\tfont-weight: 500;\n\t\tline-height: normal;\n\t\tmargin: 0;\n\t\ttext-align: left;\n\t\ttext-transform: uppercase;\n\t}\n\n\t.edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {\n\t\ttext-align: right;\n\t\twidth: 120px;\n\t}\n\n\t.edit-site-style-book__example-preview {\n\t\twidth: 100%;\n\t}\n\n\t.edit-site-style-book__example-preview .block-editor-block-list__insertion-point,\n\t.edit-site-style-book__example-preview .block-list-appender {\n\t\tdisplay: none;\n\t}\n\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {\n\t\tmargin-top: 0;\n\t}\n\t.edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {\n\t\tmargin-bottom: 0;\n\t}\n`;\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 focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst sectionFocusReturnRef = useFocusReturn();\n\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\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tevent.preventDefault();\n\t\t\tonClose();\n\t\t}\n\t}\n\n\treturn (\n\t\t<StyleBookFill>\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\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\tonKeyDown={ closeOnEscape }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tsectionFocusReturnRef,\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t] ) }\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\tshowTooltip={ false }\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<Iframe\n\t\t\t\t\t\t\tclassName=\"edit-site-style-book__iframe\"\n\t\t\t\t\t\t\tname=\"style-book-canvas\"\n\t\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<EditorStyles styles={ settings.styles } />\n\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t\t\t\t`.is-root-container { display: flow-root; }\n\t\t\t\t\t\t\t\t\t\t\tbody { position: relative; padding: 32px !important; }` +\n\t\t\t\t\t\t\t\t\t\tSTYLE_BOOK_IFRAME_STYLES\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t<Examples\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'edit-site-style-book__examples',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-wide': sizes.width > 600,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\texamples={ examples }\n\t\t\t\t\t\t\t\tcategory={ tab.name }\n\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: Category of blocks, e.g. Text.\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Examples of blocks in the %s category'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\ttab.title\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Iframe>\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(\n\t( { className, examples, category, label, isSelected, onSelect } ) => {\n\t\tconst composite = useCompositeState( { orientation: 'vertical' } );\n\t\treturn (\n\t\t\t<Composite\n\t\t\t\t{ ...composite }\n\t\t\t\tclassName={ className }\n\t\t\t\taria-label={ label }\n\t\t\t>\n\t\t\t\t{ examples\n\t\t\t\t\t.filter( ( example ) => example.category === category )\n\t\t\t\t\t.map( ( example ) => (\n\t\t\t\t\t\t<Example\n\t\t\t\t\t\t\tkey={ example.name }\n\t\t\t\t\t\t\tid={ `example-${ example.name }` }\n\t\t\t\t\t\t\tcomposite={ composite }\n\t\t\t\t\t\t\ttitle={ example.title }\n\t\t\t\t\t\t\tblocks={ example.blocks }\n\t\t\t\t\t\t\tisSelected={ isSelected( example.name ) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tonSelect( example.name );\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</Composite>\n\t\t);\n\t}\n);\n\nconst Example = ( { composite, id, title, blocks, isSelected, onClick } ) => {\n\tconst originalSettings = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings(),\n\t\t[]\n\t);\n\tconst settings = useMemo(\n\t\t() => ( { ...originalSettings, __unstableIsPreviewMode: true } ),\n\t\t[ originalSettings ]\n\t);\n\n\t// Cache the list of blocks to avoid additional processing when the component is re-rendered.\n\tconst renderedBlocks = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\n\t);\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t{ ...composite }\n\t\t\tclassName={ classnames( 'edit-site-style-book__example', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tid={ id }\n\t\t\taria-label={ sprintf(\n\t\t\t\t// translators: %s: Title of a block, e.g. Heading.\n\t\t\t\t__( 'Open %s styles in Styles panel' ),\n\t\t\t\ttitle\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t\trole=\"button\"\n\t\t\tas=\"div\"\n\t\t>\n\t\t\t<span className=\"edit-site-style-book__example-title\">\n\t\t\t\t{ title }\n\t\t\t</span>\n\t\t\t<div className=\"edit-site-style-book__example-preview\" aria-hidden>\n\t\t\t\t<Disabled className=\"edit-site-style-book__example-preview__content\">\n\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\tvalue={ renderedBlocks }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockList renderAppender={ false } />\n\t\t\t\t\t</ExperimentalBlockEditorProvider>\n\t\t\t\t</Disabled>\n\t\t\t</div>\n\t\t</CompositeItem>\n\t);\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"]}
|
|
@@ -94,7 +94,7 @@ function WelcomeGuideStyles() {
|
|
|
94
94
|
}, (0, _i18n.__)('Learn more')), (0, _element.createElement)("p", {
|
|
95
95
|
className: "edit-site-welcome-guide__text"
|
|
96
96
|
}, (0, _i18n.__)('New to block themes and styling your site? '), (0, _element.createElement)(_components.ExternalLink, {
|
|
97
|
-
href: (0, _i18n.__)('https://wordpress.org/
|
|
97
|
+
href: (0, _i18n.__)('https://wordpress.org/documentation/article/styles-overview/')
|
|
98
98
|
}, (0, _i18n.__)('Here’s a detailed guide to learn how to make the most of it.'))))
|
|
99
99
|
}]
|
|
100
100
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/welcome-guide/styles.js"],"names":["WelcomeGuideStyles","toggle","preferencesStore","isActive","isStylesOpen","select","sidebar","interfaceStore","getActiveComplementaryArea","editSiteStore","name","get","image","content"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIe,SAASA,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA;AAAF,MAAa,uBAAaC,kBAAb,CAAnB;AAEA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAA6B,qBAAaC,MAAF,IAAc;AAC3D,UAAMC,OAAO,GAAGD,MAAM,CAAEE,gBAAF,CAAN,CAAyBC,0BAAzB,CACfC,aAAcC,IADC,CAAhB;AAIA,WAAO;AACNP,MAAAA,QAAQ,EAAE,CAAC,CAAEE,MAAM,CAAEH,kBAAF,CAAN,CAA2BS,GAA3B,CACZ,gBADY,EAEZ,oBAFY,CADP;AAKNP,MAAAA,YAAY,EAAEE,OAAO,KAAK;AALpB,KAAP;AAOA,GAZkC,EAYhC,EAZgC,CAAnC;;AAcA,MAAK,CAAEH,QAAF,IAAc,CAAEC,YAArB,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,yBADX;AAEC,IAAA,YAAY,EAAG,cAAI,mBAAJ,CAFhB;AAGC,IAAA,gBAAgB,EAAG,cAAI,aAAJ,CAHpB;AAIC,IAAA,QAAQ,EAAG,MAAMH,MAAM,CAAE,gBAAF,EAAoB,oBAApB,CAJxB;AAKC,IAAA,KAAK,EAAG,CACP;AACCW,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,6DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,mBAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,2KADC,CADH,CAJD;AARF,KADO,EAqBP;AACCD,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,0DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,gBAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,8JADC,CADH,CAJD;AARF,KArBO,EAyCP;AACCD,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,8DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,oBAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,qLADC,CADH,CAJD;AARF,KAzCO,EA6DP;AACCD,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,+DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,YAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,6CADC,CADH,EAIC,4BAAC,wBAAD;AACC,QAAA,IAAI,EAAG,cACN,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/welcome-guide/styles.js"],"names":["WelcomeGuideStyles","toggle","preferencesStore","isActive","isStylesOpen","select","sidebar","interfaceStore","getActiveComplementaryArea","editSiteStore","name","get","image","content"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIe,S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AAd,SACG,cAAI,gBAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,8JADC,CADH,CAJD;AARF,KArBO,EAyCP;AACCD,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,8DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,oBAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,qLADC,CADH,CAJD;AARF,KAzCO,EA6DP;AACCD,MAAAA,KAAK,EACJ,4BAAC,cAAD;AACC,QAAA,cAAc,EAAC,+DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,YAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,6CADC,CADH,EAIC,4BAAC,wBAAD;AACC,QAAA,IAAI,EAAG,cACN,8DADM;AADR,SAKG,cACD,8DADC,CALH,CAJD,CAJD;AARF,KA7DO;AALT,IADD;AAmGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideImage from './image';\nimport { store as editSiteStore } from '../../store';\n\nexport default function WelcomeGuideStyles() {\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tconst { isActive, isStylesOpen } = useSelect( ( select ) => {\n\t\tconst sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\teditSiteStore.name\n\t\t);\n\n\t\treturn {\n\t\t\tisActive: !! select( preferencesStore ).get(\n\t\t\t\t'core/edit-site',\n\t\t\t\t'welcomeGuideStyles'\n\t\t\t),\n\t\t\tisStylesOpen: sidebar === 'edit-site/global-styles',\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive || ! isStylesOpen ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-site-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to styles' ) }\n\t\t\tfinishButtonText={ __( 'Get Started' ) }\n\t\t\tonFinish={ () => toggle( 'core/edit-site', 'welcomeGuideStyles' ) }\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-to-styles.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-to-styles.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to Styles' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Tweak your site, or give it a whole new look! Get creative — how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/set-the-design.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/set-the-design.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Set the design' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle! '\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/personalize-blocks.svg?1\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/personalize-blocks.gif?1\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Personalize blocks' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'You can adjust your blocks to ensure a cohesive experience across your site — add your unique colors to a branded Button block, or adjust the Heading block to your preferred size.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-site-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn more' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-site-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'New to block themes and styling your site? '\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/styles-overview/'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'Here’s a detailed guide to learn how to make the most of it.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t</p>\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);\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCommands = useCommands;
|
|
7
|
+
|
|
8
|
+
var _useNavigationCommands = require("./use-navigation-commands");
|
|
9
|
+
|
|
10
|
+
var _useWpAdminCommands = require("./use-wp-admin-commands");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
function useCommands() {
|
|
16
|
+
(0, _useWpAdminCommands.useWPAdminCommands)();
|
|
17
|
+
(0, _useNavigationCommands.useNavigationCommands)();
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/index.js"],"names":["useCommands"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIO,SAASA,WAAT,GAAuB;AAC7B;AACA;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useNavigationCommands } from './use-navigation-commands';\nimport { useWPAdminCommands } from './use-wp-admin-commands';\n\nexport function useCommands() {\n\tuseWPAdminCommands();\n\tuseNavigationCommands();\n}\n"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useNavigationCommands = useNavigationCommands;
|
|
7
|
+
|
|
8
|
+
var _commands = require("@wordpress/commands");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _element = require("@wordpress/element");
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _coreData = require("@wordpress/core-data");
|
|
17
|
+
|
|
18
|
+
var _store = require("../../store");
|
|
19
|
+
|
|
20
|
+
var _privateApis = require("../../private-apis");
|
|
21
|
+
|
|
22
|
+
var _routes = require("../../components/routes");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* WordPress dependencies
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal dependencies
|
|
30
|
+
*/
|
|
31
|
+
const {
|
|
32
|
+
useCommandLoader
|
|
33
|
+
} = (0, _privateApis.unlock)(_commands.privateApis);
|
|
34
|
+
|
|
35
|
+
const getNavigationCommandLoaderPerPostType = postType => function useNavigationCommandLoader(_ref) {
|
|
36
|
+
let {
|
|
37
|
+
search
|
|
38
|
+
} = _ref;
|
|
39
|
+
const supportsSearch = !['wp_template', 'wp_template_part'].includes(postType);
|
|
40
|
+
const deps = supportsSearch ? [search] : [];
|
|
41
|
+
const history = (0, _routes.useHistory)();
|
|
42
|
+
const {
|
|
43
|
+
canvasMode,
|
|
44
|
+
records,
|
|
45
|
+
isLoading
|
|
46
|
+
} = (0, _data.useSelect)(select => {
|
|
47
|
+
const {
|
|
48
|
+
getEntityRecords
|
|
49
|
+
} = select(_coreData.store);
|
|
50
|
+
const query = supportsSearch ? {
|
|
51
|
+
search: !!search ? search : undefined,
|
|
52
|
+
per_page: 10,
|
|
53
|
+
orderby: search ? 'relevance' : 'date'
|
|
54
|
+
} : {
|
|
55
|
+
per_page: -1
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
records: getEntityRecords('postType', postType, query),
|
|
59
|
+
isLoading: !select(_coreData.store).hasFinishedResolution('getEntityRecords', ['postType', postType, query]),
|
|
60
|
+
canvasMode: (0, _privateApis.unlock)(select(_store.store)).getCanvasMode()
|
|
61
|
+
};
|
|
62
|
+
}, deps);
|
|
63
|
+
const commands = (0, _element.useMemo)(() => {
|
|
64
|
+
return (records !== null && records !== void 0 ? records : []).slice(0, 10).map(record => {
|
|
65
|
+
var _record$title, _record$title2, _record$title3;
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
name: ((_record$title = record.title) === null || _record$title === void 0 ? void 0 : _record$title.rendered) + ' ' + record.id,
|
|
69
|
+
label: (_record$title2 = record.title) !== null && _record$title2 !== void 0 && _record$title2.rendered ? (_record$title3 = record.title) === null || _record$title3 === void 0 ? void 0 : _record$title3.rendered : (0, _i18n.__)('(no title)'),
|
|
70
|
+
callback: _ref2 => {
|
|
71
|
+
let {
|
|
72
|
+
close
|
|
73
|
+
} = _ref2;
|
|
74
|
+
history.push({
|
|
75
|
+
postType,
|
|
76
|
+
postId: record.id,
|
|
77
|
+
canvas: canvasMode === 'edit' ? canvasMode : undefined
|
|
78
|
+
});
|
|
79
|
+
close();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}, [records, history, canvasMode]);
|
|
84
|
+
return {
|
|
85
|
+
commands,
|
|
86
|
+
isLoading
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const usePageNavigationCommandLoader = getNavigationCommandLoaderPerPostType('page');
|
|
91
|
+
const usePostNavigationCommandLoader = getNavigationCommandLoaderPerPostType('post');
|
|
92
|
+
const useTemplateNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template');
|
|
93
|
+
const useTemplatePartNavigationCommandLoader = getNavigationCommandLoaderPerPostType('wp_template_part');
|
|
94
|
+
|
|
95
|
+
function useNavigationCommands() {
|
|
96
|
+
useCommandLoader({
|
|
97
|
+
name: 'core/edit-site/navigate-pages',
|
|
98
|
+
group: (0, _i18n.__)('Pages'),
|
|
99
|
+
hook: usePageNavigationCommandLoader
|
|
100
|
+
});
|
|
101
|
+
useCommandLoader({
|
|
102
|
+
name: 'core/edit-site/navigate-posts',
|
|
103
|
+
group: (0, _i18n.__)('Posts'),
|
|
104
|
+
hook: usePostNavigationCommandLoader
|
|
105
|
+
});
|
|
106
|
+
useCommandLoader({
|
|
107
|
+
name: 'core/edit-site/navigate-templates',
|
|
108
|
+
group: (0, _i18n.__)('Templates'),
|
|
109
|
+
hook: useTemplateNavigationCommandLoader
|
|
110
|
+
});
|
|
111
|
+
useCommandLoader({
|
|
112
|
+
name: 'core/edit-site/navigate-template-parts',
|
|
113
|
+
group: (0, _i18n.__)('Template Parts'),
|
|
114
|
+
hook: useTemplatePartNavigationCommandLoader
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=use-navigation-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-navigation-commands.js"],"names":["useCommandLoader","privateApis","getNavigationCommandLoaderPerPostType","postType","useNavigationCommandLoader","search","supportsSearch","includes","deps","history","canvasMode","records","isLoading","select","getEntityRecords","coreStore","query","undefined","per_page","orderby","hasFinishedResolution","editSiteStore","getCanvasMode","commands","slice","map","record","name","title","rendered","id","label","callback","close","push","postId","canvas","usePageNavigationCommandLoader","usePostNavigationCommandLoader","useTemplateNavigationCommandLoader","useTemplatePartNavigationCommandLoader","useNavigationCommands","group","hook"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAdA;AACA;AACA;;AAOA;AACA;AACA;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAuB,yBAAQC,qBAAR,CAA7B;;AAEA,MAAMC,qCAAqC,GAAKC,QAAF,IAC7C,SAASC,0BAAT,OAAkD;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AACjD,QAAMC,cAAc,GAAG,CAAE,CAAE,aAAF,EAAiB,kBAAjB,EAAsCC,QAAtC,CACxBJ,QADwB,CAAzB;AAGA,QAAMK,IAAI,GAAGF,cAAc,GAAG,CAAED,MAAF,CAAH,GAAgB,EAA3C;AACA,QAAMI,OAAO,GAAG,yBAAhB;AACA,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,OAAd;AAAuBC,IAAAA;AAAvB,MAAqC,qBAAaC,MAAF,IAAc;AACnE,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,UAAMC,KAAK,GAAGV,cAAc,GACzB;AACAD,MAAAA,MAAM,EAAE,CAAC,CAAEA,MAAH,GAAYA,MAAZ,GAAqBY,SAD7B;AAEAC,MAAAA,QAAQ,EAAE,EAFV;AAGAC,MAAAA,OAAO,EAAEd,MAAM,GAAG,WAAH,GAAiB;AAHhC,KADyB,GAMzB;AACAa,MAAAA,QAAQ,EAAE,CAAC;AADX,KANH;AASA,WAAO;AACNP,MAAAA,OAAO,EAAEG,gBAAgB,CAAE,UAAF,EAAcX,QAAd,EAAwBa,KAAxB,CADnB;AAENJ,MAAAA,SAAS,EAAE,CAAEC,MAAM,CAAEE,eAAF,CAAN,CAAoBK,qBAApB,CACZ,kBADY,EAEZ,CAAE,UAAF,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ACvCrC,qCAAqC,CAAE,aAAF,CADtC;AAEA,MAAMsC,sCAAsC,GAC3CtC,qCAAqC,CAAE,kBAAF,CADtC;;AAGO,SAASuC,qBAAT,GAAiC;AACvCzC,EAAAA,gBAAgB,CAAE;AACjB2B,IAAAA,IAAI,EAAE,+BADW;AAEjBe,IAAAA,KAAK,EAAE,cAAI,OAAJ,CAFU;AAGjBC,IAAAA,IAAI,EAAEN;AAHW,GAAF,CAAhB;AAKArC,EAAAA,gBAAgB,CAAE;AACjB2B,IAAAA,IAAI,EAAE,+BADW;AAEjBe,IAAAA,KAAK,EAAE,cAAI,OAAJ,CAFU;AAGjBC,IAAAA,IAAI,EAAEL;AAHW,GAAF,CAAhB;AAKAtC,EAAAA,gBAAgB,CAAE;AACjB2B,IAAAA,IAAI,EAAE,mCADW;AAEjBe,IAAAA,KAAK,EAAE,cAAI,WAAJ,CAFU;AAGjBC,IAAAA,IAAI,EAAEJ;AAHW,GAAF,CAAhB;AAKAvC,EAAAA,gBAAgB,CAAE;AACjB2B,IAAAA,IAAI,EAAE,wCADW;AAEjBe,IAAAA,KAAK,EAAE,cAAI,gBAAJ,CAFU;AAGjBC,IAAAA,IAAI,EAAEH;AAHW,GAAF,CAAhB;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/commands';\nimport { __ } from '@wordpress/i18n';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\nimport { useHistory } from '../../components/routes';\n\nconst { useCommandLoader } = unlock( privateApis );\n\nconst getNavigationCommandLoaderPerPostType = ( postType ) =>\n\tfunction useNavigationCommandLoader( { search } ) {\n\t\tconst supportsSearch = ! [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tpostType\n\t\t);\n\t\tconst deps = supportsSearch ? [ search ] : [];\n\t\tconst history = useHistory();\n\t\tconst { canvasMode, records, isLoading } = useSelect( ( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst query = supportsSearch\n\t\t\t\t? {\n\t\t\t\t\t\tsearch: !! search ? search : undefined,\n\t\t\t\t\t\tper_page: 10,\n\t\t\t\t\t\torderby: search ? 'relevance' : 'date',\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t };\n\t\t\treturn {\n\t\t\t\trecords: getEntityRecords( 'postType', postType, query ),\n\t\t\t\tisLoading: ! select( coreStore ).hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\t[ 'postType', postType, query ]\n\t\t\t\t),\n\t\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t\t};\n\t\t}, deps );\n\n\t\tconst commands = useMemo( () => {\n\t\t\treturn ( records ?? [] ).slice( 0, 10 ).map( ( record ) => {\n\t\t\t\treturn {\n\t\t\t\t\tname: record.title?.rendered + ' ' + record.id,\n\t\t\t\t\tlabel: record.title?.rendered\n\t\t\t\t\t\t? record.title?.rendered\n\t\t\t\t\t\t: __( '(no title)' ),\n\t\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\tpostType,\n\t\t\t\t\t\t\tpostId: record.id,\n\t\t\t\t\t\t\tcanvas:\n\t\t\t\t\t\t\t\tcanvasMode === 'edit' ? canvasMode : undefined,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tclose();\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t} );\n\t\t}, [ records, history, canvasMode ] );\n\n\t\treturn {\n\t\t\tcommands,\n\t\t\tisLoading,\n\t\t};\n\t};\n\nconst usePageNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'page' );\nconst usePostNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'post' );\nconst useTemplateNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template' );\nconst useTemplatePartNavigationCommandLoader =\n\tgetNavigationCommandLoaderPerPostType( 'wp_template_part' );\n\nexport function useNavigationCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-pages',\n\t\tgroup: __( 'Pages' ),\n\t\thook: usePageNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-posts',\n\t\tgroup: __( 'Posts' ),\n\t\thook: usePostNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-templates',\n\t\tgroup: __( 'Templates' ),\n\t\thook: useTemplateNavigationCommandLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/navigate-template-parts',\n\t\tgroup: __( 'Template Parts' ),\n\t\thook: useTemplatePartNavigationCommandLoader,\n\t} );\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useWPAdminCommands = useWPAdminCommands;
|
|
7
|
+
|
|
8
|
+
var _commands = require("@wordpress/commands");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
|
|
14
|
+
var _url = require("@wordpress/url");
|
|
15
|
+
|
|
16
|
+
var _element = require("@wordpress/element");
|
|
17
|
+
|
|
18
|
+
var _store = require("../../store");
|
|
19
|
+
|
|
20
|
+
var _privateApis = require("../../private-apis");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
const {
|
|
30
|
+
useCommandLoader
|
|
31
|
+
} = (0, _privateApis.unlock)(_commands.privateApis);
|
|
32
|
+
|
|
33
|
+
const getWPAdminAddCommandLoader = postType => function useAddCommandLoader(_ref) {
|
|
34
|
+
let {
|
|
35
|
+
search
|
|
36
|
+
} = _ref;
|
|
37
|
+
let label;
|
|
38
|
+
|
|
39
|
+
if (postType === 'post') {
|
|
40
|
+
label = (0, _i18n.__)('Add a new post');
|
|
41
|
+
} else if (postType === 'page') {
|
|
42
|
+
label = (0, _i18n.__)('Add a new page');
|
|
43
|
+
} else {
|
|
44
|
+
throw 'unsupported post type ' + postType;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const hasRecordTitle = !!search && !label.toLowerCase().includes(search.toLowerCase());
|
|
48
|
+
|
|
49
|
+
if (postType === 'post' && hasRecordTitle) {
|
|
50
|
+
/* translators: %s: Post title placeholder */
|
|
51
|
+
label = (0, _i18n.sprintf)((0, _i18n.__)('Add a new post "%s"'), search);
|
|
52
|
+
} else if (postType === 'page' && hasRecordTitle) {
|
|
53
|
+
/* translators: %s: Page title placeholder */
|
|
54
|
+
label = (0, _i18n.sprintf)((0, _i18n.__)('Add a new page "%s"'), search);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const newPostLink = (0, _data.useSelect)(select => {
|
|
58
|
+
var _getSettings$newPostL;
|
|
59
|
+
|
|
60
|
+
const {
|
|
61
|
+
getSettings
|
|
62
|
+
} = (0, _privateApis.unlock)(select(_store.store));
|
|
63
|
+
return (_getSettings$newPostL = getSettings().newPostLink) !== null && _getSettings$newPostL !== void 0 ? _getSettings$newPostL : 'post-new.php';
|
|
64
|
+
}, []);
|
|
65
|
+
const commands = (0, _element.useMemo)(() => [{
|
|
66
|
+
name: 'core/wp-admin/add-' + postType,
|
|
67
|
+
label,
|
|
68
|
+
callback: () => {
|
|
69
|
+
document.location.href = (0, _url.addQueryArgs)(newPostLink, {
|
|
70
|
+
post_type: postType,
|
|
71
|
+
post_title: hasRecordTitle ? search : undefined
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}], [newPostLink, hasRecordTitle, search, label]);
|
|
75
|
+
return {
|
|
76
|
+
isLoading: false,
|
|
77
|
+
commands
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const useAddPostLoader = getWPAdminAddCommandLoader('post');
|
|
82
|
+
const useAddPageLoader = getWPAdminAddCommandLoader('page');
|
|
83
|
+
|
|
84
|
+
function useWPAdminCommands() {
|
|
85
|
+
useCommandLoader({
|
|
86
|
+
name: 'core/wp-admin/add-post-loader',
|
|
87
|
+
hook: useAddPostLoader
|
|
88
|
+
});
|
|
89
|
+
useCommandLoader({
|
|
90
|
+
name: 'core/wp-admin/add-page-loader',
|
|
91
|
+
hook: useAddPageLoader
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=use-wp-admin-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-wp-admin-commands.js"],"names":["useCommandLoader","privateApis","getWPAdminAddCommandLoader","postType","useAddCommandLoader","search","label","hasRecordTitle","toLowerCase","includes","newPostLink","select","getSettings","editSiteStore","commands","name","callback","document","location","href","post_type","post_title","undefined","isLoading","useAddPostLoader","useAddPageLoader","useWPAdminCommands","hook"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAbA;AACA;AACA;;AAOA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAuB,yBAAQC,qBAAR,CAA7B;;AAEA,MAAMC,0BAA0B,GAAKC,QAAF,IAClC,SAASC,mBAAT,OAA2C;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AAC1C,MAAIC,KAAJ;;AACA,MAAKH,QAAQ,KAAK,MAAlB,EAA2B;AAC1BG,IAAAA,KAAK,GAAG,cAAI,gBAAJ,CAAR;AACA,GAFD,MAEO,IAAKH,QAAQ,KAAK,MAAlB,EAA2B;AACjCG,IAAAA,KAAK,GAAG,cAAI,gBAAJ,CAAR;AACA,GA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CAAE,MAAF,CAAnD;AACA,MAAMuB,gBAAgB,GAAGvB,0BAA0B,CAAE,MAAF,CAAnD;;AAEO,SAASwB,kBAAT,GAA8B;AACpC1B,EAAAA,gBAAgB,CAAE;AACjBe,IAAAA,IAAI,EAAE,+BADW;AAEjBY,IAAAA,IAAI,EAAEH;AAFW,GAAF,CAAhB;AAIAxB,EAAAA,gBAAgB,CAAE;AACjBe,IAAAA,IAAI,EAAE,+BADW;AAEjBY,IAAAA,IAAI,EAAEF;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/commands';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../private-apis';\n\nconst { useCommandLoader } = unlock( privateApis );\n\nconst getWPAdminAddCommandLoader = ( postType ) =>\n\tfunction useAddCommandLoader( { search } ) {\n\t\tlet label;\n\t\tif ( postType === 'post' ) {\n\t\t\tlabel = __( 'Add a new post' );\n\t\t} else if ( postType === 'page' ) {\n\t\t\tlabel = __( 'Add a new page' );\n\t\t} else {\n\t\t\tthrow 'unsupported post type ' + postType;\n\t\t}\n\t\tconst hasRecordTitle =\n\t\t\t!! search && ! label.toLowerCase().includes( search.toLowerCase() );\n\t\tif ( postType === 'post' && hasRecordTitle ) {\n\t\t\t/* translators: %s: Post title placeholder */\n\t\t\tlabel = sprintf( __( 'Add a new post \"%s\"' ), search );\n\t\t} else if ( postType === 'page' && hasRecordTitle ) {\n\t\t\t/* translators: %s: Page title placeholder */\n\t\t\tlabel = sprintf( __( 'Add a new page \"%s\"' ), search );\n\t\t}\n\n\t\tconst newPostLink = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\t\treturn getSettings().newPostLink ?? 'post-new.php';\n\t\t}, [] );\n\n\t\tconst commands = useMemo(\n\t\t\t() => [\n\t\t\t\t{\n\t\t\t\t\tname: 'core/wp-admin/add-' + postType,\n\t\t\t\t\tlabel,\n\t\t\t\t\tcallback: () => {\n\t\t\t\t\t\tdocument.location.href = addQueryArgs( newPostLink, {\n\t\t\t\t\t\t\tpost_type: postType,\n\t\t\t\t\t\t\tpost_title: hasRecordTitle ? search : undefined,\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\t[ newPostLink, hasRecordTitle, search, label ]\n\t\t);\n\n\t\treturn {\n\t\t\tisLoading: false,\n\t\t\tcommands,\n\t\t};\n\t};\n\nconst useAddPostLoader = getWPAdminAddCommandLoader( 'post' );\nconst useAddPageLoader = getWPAdminAddCommandLoader( 'page' );\n\nexport function useWPAdminCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/wp-admin/add-post-loader',\n\t\thook: useAddPostLoader,\n\t} );\n\tuseCommandLoader( {\n\t\tname: 'core/wp-admin/add-page-loader',\n\t\thook: useAddPageLoader,\n\t} );\n}\n"]}
|
|
@@ -52,6 +52,7 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
|
52
52
|
'elements.button.color.background': 'color',
|
|
53
53
|
'elements.button.typography.fontFamily': 'font-family',
|
|
54
54
|
'elements.button.typography.fontSize': 'font-size',
|
|
55
|
+
'elements.caption.color.text': 'color',
|
|
55
56
|
'elements.heading.color': 'color',
|
|
56
57
|
'elements.heading.color.background': 'color',
|
|
57
58
|
'elements.heading.typography.fontFamily': 'font-family',
|
|
@@ -1 +1 @@
|
|
|
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","useChangesToPush","name","attributes","supports","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,a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ent":["/**\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 { useSupportedStyles } 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 useChangesToPush( name, attributes ) {\n\tconst supports = useSupportedStyles( name );\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupports.flatMap( ( key ) => {\n\t\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\t\tconst presetAttributeValue =\n\t\t\t\t\tattributes[\n\t\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[\n\t\t\t\t\t\t\tpresetAttributeKey\n\t\t\t\t\t\t]\n\t\t\t\t\t];\n\t\t\t\tconst value = presetAttributeValue\n\t\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t\t: get( attributes.style, path );\n\t\t\t\treturn value ? [ { path, value } ] : [];\n\t\t\t} ),\n\t\t[ supports, name, attributes ]\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 = useChangesToPush( name, attributes );\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","useChangesToPush","name","attributes","supports","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,iCAA+B,OAXI;AAYnC,4BAA0B,OAZS;AAanC,uCAAqC,OAbF;AAcnC,4CAA0C,aAdP;AAenC,+BAA6B,UAfM;AAgBnC,qCAAmC,UAhBA;AAiBnC,uBAAqB,OAjBc;AAkBnC,kCAAgC,OAlBG;AAmBnC,uCAAqC,aAnBF;AAoBnC,gCAA8B,UApBK;AAqBnC,uBAAqB,OArBc;AAsBnC,kCAAgC,OAtBG;AAuBnC,uCAAqC,aAvBF;AAwBnC,gCAA8B,UAxBK;AAyBnC,uBAAqB,OAzBc;AA0BnC,kCAAgC,OA1BG;AA2BnC,uCAAqC,aA3BF;AA4BnC,gCAA8B,UA5BK;AA6BnC,uBAAqB,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A,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 { useSupportedStyles } 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.caption.color.text': 'color',\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 useChangesToPush( name, attributes ) {\n\tconst supports = useSupportedStyles( name );\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupports.flatMap( ( key ) => {\n\t\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\t\tconst presetAttributeValue =\n\t\t\t\t\tattributes[\n\t\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[\n\t\t\t\t\t\t\tpresetAttributeKey\n\t\t\t\t\t\t]\n\t\t\t\t\t];\n\t\t\t\tconst value = presetAttributeValue\n\t\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t\t: get( attributes.style, path );\n\t\t\t\treturn value ? [ { path, value } ] : [];\n\t\t\t} ),\n\t\t[ supports, name, attributes ]\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 = useChangesToPush( name, attributes );\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"]}
|
|
@@ -53,7 +53,8 @@ function EditTemplatePartMenuItem(_ref) {
|
|
|
53
53
|
}, [theme, slug]);
|
|
54
54
|
const linkProps = (0, _link.useLink)({
|
|
55
55
|
postId: templatePart === null || templatePart === void 0 ? void 0 : templatePart.id,
|
|
56
|
-
postType: templatePart === null || templatePart === void 0 ? void 0 : templatePart.type
|
|
56
|
+
postType: templatePart === null || templatePart === void 0 ? void 0 : templatePart.type,
|
|
57
|
+
canvas: 'edit'
|
|
57
58
|
}, {
|
|
58
59
|
fromTemplateId: params.postId
|
|
59
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/hooks/template-part-edit.js"],"names":["EditTemplatePartMenuItem","attributes","theme","slug","params","templatePart","select","coreStore","getEntityRecord","linkProps","postId","id","postType","type","fromTemplateId","event","onClick","withEditBlockControls","BlockEdit","props","name","isDisplayed"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,wBAAT,OAAoD;AAAA,MAAjB;AAAEC,IAAAA;AAAF,GAAiB;AACnD,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAkBF,UAAxB;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,YAAY,GAAG,qBAClBC,MAAF,IAAc;AACb,WAAOA,MAAM,CAAEC,eAAF,CAAN,CAAoBC,eAApB,CACN,UADM,EAEN,kBAFM,EAGN;AACC,OAAGN,KAAO,KAAKC,IAAM,EAJhB,CAAP;AAMA,GARmB,EASpB,CAAED,KAAF,EAASC,IAAT,CAToB,CAArB;AAYA,QAAMM,SAAS,GAAG,mBACjB;AACCC,IAAAA,MAAM,EAAEL,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEM,EADvB;AAECC,IAAAA,QAAQ,EAAEP,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEQ;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/template-part-edit.js"],"names":["EditTemplatePartMenuItem","attributes","theme","slug","params","templatePart","select","coreStore","getEntityRecord","linkProps","postId","id","postType","type","canvas","fromTemplateId","event","onClick","withEditBlockControls","BlockEdit","props","name","isDisplayed"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AASA;AACA;AACA;AAIA,SAASA,wBAAT,OAAoD;AAAA,MAAjB;AAAEC,IAAAA;AAAF,GAAiB;AACnD,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAkBF,UAAxB;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAa,0BAAnB;AACA,QAAMC,YAAY,GAAG,qBAClBC,MAAF,IAAc;AACb,WAAOA,MAAM,CAAEC,eAAF,CAAN,CAAoBC,eAApB,CACN,UADM,EAEN,kBAFM,EAGN;AACC,OAAGN,KAAO,KAAKC,IAAM,EAJhB,CAAP;AAMA,GARmB,EASpB,CAAED,KAAF,EAASC,IAAT,CAToB,CAArB;AAYA,QAAMM,SAAS,GAAG,mBACjB;AACCC,IAAAA,MAAM,EAAEL,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEM,EADvB;AAECC,IAAAA,QAAQ,EAAEP,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEQ,IAFzB;AAGCC,IAAAA,MAAM,EAAE;AAHT,GADiB,EAMjB;AACCC,IAAAA,cAAc,EAAEX,MAAM,CAACM;AADxB,GANiB,CAAlB;;AAWA,MAAK,CAAEL,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,0BAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,4BAAC,yBAAD,6BACMI,SADN;AAEC,IAAA,OAAO,EAAKO,KAAF,IAAa;AACtBP,MAAAA,SAAS,CAACQ,OAAV,CAAmBD,KAAnB;AACA;AAJF,MAMG,cAAI,MAAJ,CANH,CADD,CADD;AAYA;;AAEM,MAAME,qBAAqB,GAAG,yCAClCC,SAAF,IAAmBC,KAAF,IAAa;AAC7B,QAAM;AAAEnB,IAAAA,UAAF;AAAcoB,IAAAA;AAAd,MAAuBD,KAA7B;AACA,QAAME,WAAW,GAAGD,IAAI,KAAK,oBAAT,IAAiCpB,UAAU,CAACE,IAAhE;AAEA,SACC,qDACC,4BAAC,SAAD,EAAgBiB,KAAhB,CADD,EAEGE,WAAW,IACZ,4BAAC,wBAAD;AAA0B,IAAA,UAAU,EAAGrB;AAAvC,IAHF,CADD;AAQA,CAbmC,EAcpC,uBAdoC,CAA9B;;AAiBP,sBACC,kBADD,EAEC,0CAFD,EAGCiB,qBAHD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { BlockControls } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { ToolbarButton } from '@wordpress/components';\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useLocation } from '../components/routes';\nimport { useLink } from '../components/routes/link';\n\nfunction EditTemplatePartMenuItem( { attributes } ) {\n\tconst { theme, slug } = attributes;\n\tconst { params } = useLocation();\n\tconst templatePart = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( coreStore ).getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t// Ideally this should be an official public API.\n\t\t\t\t`${ theme }//${ slug }`\n\t\t\t);\n\t\t},\n\t\t[ theme, slug ]\n\t);\n\n\tconst linkProps = useLink(\n\t\t{\n\t\t\tpostId: templatePart?.id,\n\t\t\tpostType: templatePart?.type,\n\t\t\tcanvas: 'edit',\n\t\t},\n\t\t{\n\t\t\tfromTemplateId: params.postId,\n\t\t}\n\t);\n\n\tif ( ! templatePart ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"other\">\n\t\t\t<ToolbarButton\n\t\t\t\t{ ...linkProps }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tlinkProps.onClick( event );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Edit' ) }\n\t\t\t</ToolbarButton>\n\t\t</BlockControls>\n\t);\n}\n\nexport const withEditBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { attributes, name } = props;\n\t\tconst isDisplayed = name === 'core/template-part' && attributes.slug;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ isDisplayed && (\n\t\t\t\t\t<EditTemplatePartMenuItem attributes={ attributes } />\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withEditBlockControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/template-part-edit-button',\n\twithEditBlockControls\n);\n"]}
|
package/build/index.js
CHANGED
|
@@ -112,7 +112,8 @@ function initializeEditor(id, settings) {
|
|
|
112
112
|
keepCaretInsideBlock: false,
|
|
113
113
|
welcomeGuide: true,
|
|
114
114
|
welcomeGuideStyles: true,
|
|
115
|
-
showListViewByDefault: false
|
|
115
|
+
showListViewByDefault: false,
|
|
116
|
+
showBlockBreadcrumbs: true
|
|
116
117
|
});
|
|
117
118
|
(0, _data.dispatch)(_interface.store).setDefaultComplementaryArea('core/edit-site', 'edit-site/template');
|
|
118
119
|
(0, _data.dispatch)(_store.store).updateSettings(settings); // Keep the defaultTemplateTypes in the core/editor settings too,
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["initializeEditor","id","settings","target","document","getElementById","root","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","blocksStore","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","name","setFreeformFallbackBlockName","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","preferencesStore","setDefaults","editorMode","fixedToolbar","focusMode","keepCaretInsideBlock","welcomeGuide","welcomeGuideStyles","showListViewByDefault","interfaceStore","setDefaultComplementaryArea","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","reinitializeEditor","since","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;AARA;;AACA;;AAKA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["initializeEditor","id","settings","target","document","getElementById","root","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","blocksStore","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","name","setFreeformFallbackBlockName","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","preferencesStore","setDefaults","editorMode","fixedToolbar","focusMode","keepCaretInsideBlock","welcomeGuide","welcomeGuideStyles","showListViewByDefault","showBlockBreadcrumbs","interfaceStore","setDefaultComplementaryArea","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","reinitializeEditor","since","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;AARA;;AACA;;AAKA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AA2EA;;AACA;;AACA;;AA1GA;AACA;AACA;;AAsBA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,EAA3B,EAA+BC,QAA/B,EAA0C;AAChD,QAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAT,CAAyBJ,EA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AACA;AACA;;AACA,sBAAUmC,aAAV,EAAwBC,oBAAxB,CAA8C;AAC7CC,IAAAA,oBAAoB,EAAErC,QAAQ,CAACqC,oBADc;AAE7CC,IAAAA,wBAAwB,EAAEtC,QAAQ,CAACsC;AAFU,GAA9C,EA9CgD,CAmDhD;;AACAC,EAAAA,MAAM,CAACC,gBAAP,CAAyB,UAAzB,EAAuCC,CAAF,IAASA,CAAC,CAACC,cAAF,EAA9C,EAAkE,KAAlE;AACAH,EAAAA,MAAM,CAACC,gBAAP,CAAyB,MAAzB,EAAmCC,CAAF,IAASA,CAAC,CAACC,cAAF,EAA1C,EAA8D,KAA9D;AAEAtC,EAAAA,IAAI,CAACuC,MAAL,CAAa,4BAAC,YAAD,OAAb;AAEA,SAAOvC,IAAP;AACA;;AAEM,SAASwC,kBAAT,GAA8B;AACpC,2BAAY,gCAAZ,EAA8C;AAC7CC,IAAAA,KAAK,EAAE,KADsC;AAE7CC,IAAAA,OAAO,EAAE;AAFoC,GAA9C;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport App from './components/app';\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tkeepCaretInsideBlock: false,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\tshowListViewByDefault: false,\n\t\tshowBlockBreadcrumbs: true,\n\t} );\n\n\tdispatch( interfaceStore ).setDefaultComplementaryArea(\n\t\t'core/edit-site',\n\t\t'edit-site/template'\n\t);\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render( <App /> );\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header-edit-mode/plugin-more-menu-item';\n"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -69,6 +69,7 @@ const __unstableGetPreference = (0, _data.createRegistrySelector)(select => (sta
|
|
|
69
69
|
/**
|
|
70
70
|
* Returns whether the given feature is enabled or not.
|
|
71
71
|
*
|
|
72
|
+
* @deprecated
|
|
72
73
|
* @param {Object} state Global application state.
|
|
73
74
|
* @param {string} featureName Feature slug.
|
|
74
75
|
*
|
|
@@ -79,7 +80,7 @@ const __unstableGetPreference = (0, _data.createRegistrySelector)(select => (sta
|
|
|
79
80
|
exports.__unstableGetPreference = __unstableGetPreference;
|
|
80
81
|
|
|
81
82
|
function isFeatureActive(state, featureName) {
|
|
82
|
-
(0, _deprecated.default)(`select( 'core/
|
|
83
|
+
(0, _deprecated.default)(`select( 'core/edit-site' ).isFeatureActive`, {
|
|
83
84
|
since: '6.0',
|
|
84
85
|
alternative: `select( 'core/preferences' ).get`
|
|
85
86
|
});
|