@wordpress/edit-site 5.9.0 → 5.11.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/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +7 -22
- package/build/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
- package/build/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +32 -27
- package/build/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
- package/build/components/add-new-template/new-template-part.js +8 -2
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +104 -68
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js +8 -2
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/back-button.js +10 -3
- package/build/components/block-editor/back-button.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +39 -6
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/index.js +1 -3
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +6 -7
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +20 -11
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +27 -6
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +1 -1
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +14 -3
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +17 -18
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/gradients-palette-panel.js +14 -3
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/root-menu.js +61 -0
- package/build/components/global-styles/root-menu.js.map +1 -0
- package/build/components/global-styles/screen-block-list.js +3 -1
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-block.js +235 -7
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +9 -26
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +20 -15
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +4 -17
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +141 -0
- package/build/components/global-styles/screen-revisions/index.js.map +1 -0
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +130 -0
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -0
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +121 -0
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -0
- package/build/components/global-styles/screen-root.js +6 -6
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +0 -3
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +11 -39
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +9 -18
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +7 -11
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +70 -117
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations-panel.js +4 -28
- package/build/components/global-styles/variations-panel.js.map +1 -1
- package/build/components/header-edit-mode/document-actions/index.js +28 -103
- package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +15 -2
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +1 -1
- package/build/components/keyboard-shortcuts/register.js.map +1 -1
- package/build/components/layout/hooks.js +54 -0
- package/build/components/layout/hooks.js.map +1 -0
- package/build/components/layout/index.js +57 -104
- package/build/components/layout/index.js.map +1 -1
- package/build/components/list/actions/index.js +5 -2
- package/build/components/list/actions/index.js.map +1 -1
- package/build/components/list/index.js +9 -3
- package/build/components/list/index.js.map +1 -1
- package/build/components/list/table.js +1 -1
- package/build/components/list/table.js.map +1 -1
- package/build/components/plugin-template-setting-panel/index.js +44 -0
- package/build/components/plugin-template-setting-panel/index.js.map +1 -0
- package/build/components/resizable-frame/index.js +242 -0
- package/build/components/resizable-frame/index.js.map +1 -0
- package/build/components/revisions/index.js +96 -0
- package/build/components/revisions/index.js.map +1 -0
- package/build/components/routes/link.js +17 -2
- package/build/components/routes/link.js.map +1 -1
- package/build/components/routes/use-title.js +8 -2
- package/build/components/routes/use-title.js.map +1 -1
- package/build/components/save-button/index.js +31 -6
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +14 -31
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/save-panel/index.js +20 -7
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +6 -10
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +19 -5
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +9 -3
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +9 -2
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js +40 -0
- package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +1 -0
- package/build/components/sidebar-edit-mode/template-card/index.js +1 -8
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/{template-card/last-revision.js → template-revisions/index.js} +2 -2
- package/build/components/sidebar-edit-mode/template-revisions/index.js.map +1 -0
- package/build/components/sidebar-navigation-item/index.js +5 -7
- package/build/components/sidebar-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +14 -4
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +75 -11
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-main/index.js +31 -23
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js +1 -1
- package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js +162 -0
- package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js +17 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +55 -93
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +87 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +14 -71
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +53 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
- package/build/components/sidebar-navigation-screen-page/index.js +67 -0
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-pages/index.js +74 -0
- package/build/components/sidebar-navigation-screen-pages/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-templates/index.js +39 -12
- package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build/components/sidebar-navigation-subtitle/index.js +18 -0
- package/build/components/sidebar-navigation-subtitle/index.js.map +1 -0
- package/build/components/site-hub/index.js +34 -6
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/start-template-options/index.js +12 -16
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/style-book/index.js +93 -19
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +8 -2
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +9 -4
- package/build/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +17 -3
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/components/use-edited-entity-record/index.js +8 -4
- package/build/components/use-edited-entity-record/index.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +105 -0
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -0
- package/build/hooks/template-part-edit.js +8 -2
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +5 -3
- package/build/store/actions.js.map +1 -1
- package/build/utils/is-previewing-theme.js +27 -0
- package/build/utils/is-previewing-theme.js.map +1 -0
- package/build/utils/use-activate-theme.js +46 -0
- package/build/utils/use-activate-theme.js.map +1 -0
- package/build-module/components/add-new-template/{add-custom-generic-template-modal.js → add-custom-generic-template-modal-content.js} +8 -20
- package/build-module/components/add-new-template/add-custom-generic-template-modal-content.js.map +1 -0
- package/build-module/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +34 -28
- package/build-module/components/add-new-template/add-custom-template-modal-content.js.map +1 -0
- package/build-module/components/add-new-template/new-template-part.js +5 -1
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +102 -68
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js +6 -2
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/back-button.js +6 -1
- package/build-module/components/block-editor/back-button.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +37 -6
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/index.js +1 -3
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +7 -8
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +18 -11
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +27 -8
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +1 -1
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +13 -3
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +17 -18
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/gradients-palette-panel.js +13 -3
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/root-menu.js +47 -0
- package/build-module/components/global-styles/root-menu.js.map +1 -0
- package/build-module/components/global-styles/screen-block-list.js +4 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-block.js +229 -7
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +9 -25
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +20 -15
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +4 -16
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +121 -0
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -0
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +118 -0
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -0
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +107 -0
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -0
- package/build-module/components/global-styles/screen-root.js +6 -6
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +0 -3
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +11 -37
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +10 -18
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +7 -11
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +71 -115
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations-panel.js +3 -22
- package/build-module/components/global-styles/variations-panel.js.map +1 -1
- package/build-module/components/header-edit-mode/document-actions/index.js +31 -107
- package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +16 -4
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +1 -1
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
- package/build-module/components/layout/hooks.js +41 -0
- package/build-module/components/layout/hooks.js.map +1 -0
- package/build-module/components/layout/index.js +53 -102
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/list/actions/index.js +6 -3
- package/build-module/components/list/actions/index.js.map +1 -1
- package/build-module/components/list/index.js +5 -1
- package/build-module/components/list/index.js.map +1 -1
- package/build-module/components/list/table.js +1 -1
- package/build-module/components/list/table.js.map +1 -1
- package/build-module/components/plugin-template-setting-panel/index.js +35 -0
- package/build-module/components/plugin-template-setting-panel/index.js.map +1 -0
- package/build-module/components/resizable-frame/index.js +228 -0
- package/build-module/components/resizable-frame/index.js.map +1 -0
- package/build-module/components/revisions/index.js +78 -0
- package/build-module/components/revisions/index.js.map +1 -0
- package/build-module/components/routes/link.js +13 -1
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/routes/use-title.js +5 -1
- package/build-module/components/routes/use-title.js.map +1 -1
- package/build-module/components/save-button/index.js +28 -6
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +13 -32
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +19 -7
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -11
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +14 -4
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +9 -3
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +10 -5
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js +29 -0
- package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +1 -0
- package/build-module/components/sidebar-edit-mode/template-card/index.js +2 -7
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/{template-card/last-revision.js → template-revisions/index.js} +2 -2
- package/build-module/components/sidebar-edit-mode/template-revisions/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-item/index.js +6 -8
- package/build-module/components/sidebar-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +13 -5
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +70 -14
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js +30 -24
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +141 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js +10 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +52 -93
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +71 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +13 -72
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +40 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigator-button.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-page/index.js +48 -0
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-pages/index.js +57 -0
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-templates/index.js +38 -12
- package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-subtitle/index.js +10 -0
- package/build-module/components/sidebar-navigation-subtitle/index.js.map +1 -0
- package/build-module/components/site-hub/index.js +32 -6
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +13 -17
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/style-book/index.js +93 -20
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +5 -1
- package/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +13 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/components/use-edited-entity-record/index.js +8 -4
- package/build-module/components/use-edited-entity-record/index.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +86 -0
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -0
- package/build-module/hooks/template-part-edit.js +5 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +5 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/is-previewing-theme.js +17 -0
- package/build-module/utils/is-previewing-theme.js.map +1 -0
- package/build-module/utils/use-activate-theme.js +36 -0
- package/build-module/utils/use-activate-theme.js.map +1 -0
- package/build-style/style-rtl.css +409 -265
- package/build-style/style.css +410 -265
- package/package.json +37 -35
- package/src/components/add-new-template/add-custom-generic-template-modal-content.js +82 -0
- package/src/components/add-new-template/{add-custom-template-modal.js → add-custom-template-modal-content.js} +44 -34
- package/src/components/add-new-template/new-template-part.js +4 -1
- package/src/components/add-new-template/new-template.js +142 -154
- package/src/components/add-new-template/style.scss +120 -103
- package/src/components/app/index.js +6 -3
- package/src/components/block-editor/back-button.js +4 -1
- package/src/components/block-editor/editor-canvas.js +36 -8
- package/src/components/block-editor/index.js +2 -3
- package/src/components/block-editor/style.scss +15 -8
- package/src/components/create-template-part-modal/index.js +19 -25
- package/src/components/editor/index.js +20 -8
- package/src/components/editor/style.scss +21 -6
- package/src/components/editor-canvas-container/index.js +43 -21
- package/src/components/global-styles/block-preview-panel.js +1 -1
- package/src/components/global-styles/color-palette-panel.js +9 -0
- package/src/components/global-styles/dimensions-panel.js +15 -15
- package/src/components/global-styles/gradients-palette-panel.js +8 -0
- package/src/components/global-styles/root-menu.js +66 -0
- package/src/components/global-styles/screen-block-list.js +2 -2
- package/src/components/global-styles/screen-block.js +255 -7
- package/src/components/global-styles/screen-colors.js +9 -16
- package/src/components/global-styles/screen-css.js +21 -21
- package/src/components/global-styles/screen-layout.js +5 -9
- package/src/components/global-styles/screen-revisions/index.js +169 -0
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +139 -0
- package/src/components/global-styles/screen-revisions/style.scss +100 -0
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +138 -0
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +99 -0
- package/src/components/global-styles/screen-root.js +7 -5
- package/src/components/global-styles/screen-typography-element.js +1 -3
- package/src/components/global-styles/screen-typography.js +44 -79
- package/src/components/global-styles/style-variations-container.js +17 -28
- package/src/components/global-styles/style.scss +4 -23
- package/src/components/global-styles/typography-panel.js +12 -13
- package/src/components/global-styles/ui.js +83 -110
- package/src/components/global-styles/variations-panel.js +3 -26
- package/src/components/header-edit-mode/document-actions/index.js +26 -129
- package/src/components/header-edit-mode/document-actions/style.scss +28 -59
- package/src/components/header-edit-mode/index.js +23 -2
- package/src/components/header-edit-mode/style.scss +1 -0
- package/src/components/keyboard-shortcuts/register.js +1 -1
- package/src/components/layout/hooks.js +46 -0
- package/src/components/layout/index.js +60 -125
- package/src/components/layout/style.scss +9 -5
- package/src/components/list/actions/index.js +12 -5
- package/src/components/list/index.js +4 -1
- package/src/components/list/style.scss +5 -0
- package/src/components/list/table.js +3 -1
- package/src/components/plugin-template-setting-panel/index.js +33 -0
- package/src/components/resizable-frame/index.js +253 -0
- package/src/components/resizable-frame/style.scss +69 -0
- package/src/components/revisions/index.js +105 -0
- package/src/components/routes/link.js +16 -1
- package/src/components/routes/use-title.js +4 -1
- package/src/components/save-button/index.js +27 -6
- package/src/components/save-hub/index.js +17 -35
- package/src/components/save-panel/index.js +15 -3
- package/src/components/secondary-sidebar/list-view-sidebar.js +4 -7
- package/src/components/sidebar/index.js +15 -4
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +9 -7
- package/src/components/sidebar-edit-mode/index.js +17 -6
- package/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js +26 -0
- package/src/components/sidebar-edit-mode/style.scss +10 -0
- package/src/components/sidebar-edit-mode/template-card/index.js +1 -9
- package/src/components/sidebar-edit-mode/{template-card/last-revision.js → template-revisions/index.js} +1 -2
- package/src/components/sidebar-navigation-item/index.js +13 -14
- package/src/components/sidebar-navigation-item/style.scss +17 -1
- package/src/components/sidebar-navigation-screen/index.js +26 -5
- package/src/components/sidebar-navigation-screen/style.scss +1 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +106 -21
- package/src/components/sidebar-navigation-screen-main/index.js +39 -35
- package/src/components/sidebar-navigation-screen-navigation-item/index.js +3 -9
- package/src/components/sidebar-navigation-screen-navigation-menu/index.js +157 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/constants.js +9 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +63 -105
- package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +83 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +8 -74
- package/src/components/sidebar-navigation-screen-navigation-menus/navigator-button.js +47 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +6 -20
- package/src/components/sidebar-navigation-screen-page/index.js +59 -0
- package/src/components/sidebar-navigation-screen-pages/index.js +82 -0
- package/src/components/sidebar-navigation-screen-pages/style.scss +4 -0
- package/src/components/sidebar-navigation-screen-templates/index.js +57 -14
- package/src/components/sidebar-navigation-subtitle/index.js +5 -0
- package/src/components/sidebar-navigation-subtitle/style.scss +7 -0
- package/src/components/site-hub/index.js +88 -58
- package/src/components/site-hub/style.scss +8 -0
- package/src/components/start-template-options/index.js +19 -27
- package/src/components/start-template-options/style.scss +28 -21
- package/src/components/style-book/index.js +132 -43
- package/src/components/style-book/style.scss +19 -0
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -1
- package/src/components/sync-state-with-url/use-sync-canvas-mode-with-url.js +3 -1
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +14 -1
- package/src/components/use-edited-entity-record/index.js +12 -3
- package/src/hooks/commands/use-edit-mode-commands.js +79 -0
- package/src/hooks/template-part-edit.js +4 -1
- package/src/index.js +1 -0
- package/src/store/actions.js +4 -5
- package/src/store/test/actions.js +6 -14
- package/src/store/test/utils.js +15 -5
- package/src/style.scss +5 -2
- package/src/utils/is-previewing-theme.js +18 -0
- package/src/utils/use-activate-theme.js +38 -0
- package/build/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
- package/build/components/add-new-template/add-custom-template-modal.js.map +0 -1
- package/build/components/global-styles/border-panel.js +0 -133
- package/build/components/global-styles/border-panel.js.map +0 -1
- package/build/components/global-styles/context-menu.js +0 -126
- package/build/components/global-styles/context-menu.js.map +0 -1
- package/build/components/global-styles/custom-css.js +0 -113
- package/build/components/global-styles/custom-css.js.map +0 -1
- package/build/components/global-styles/effects-panel.js +0 -53
- package/build/components/global-styles/effects-panel.js.map +0 -1
- package/build/components/global-styles/filters-panel.js +0 -50
- package/build/components/global-styles/filters-panel.js.map +0 -1
- package/build/components/global-styles/screen-border.js +0 -61
- package/build/components/global-styles/screen-border.js.map +0 -1
- package/build/components/global-styles/screen-effects.js +0 -61
- package/build/components/global-styles/screen-effects.js.map +0 -1
- package/build/components/global-styles/screen-filters.js +0 -46
- package/build/components/global-styles/screen-filters.js.map +0 -1
- package/build/components/global-styles/screen-variations.js +0 -71
- package/build/components/global-styles/screen-variations.js.map +0 -1
- package/build/components/navigate-to-link/index.js +0 -51
- package/build/components/navigate-to-link/index.js.map +0 -1
- package/build/components/routes/index.js +0 -60
- package/build/components/routes/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +0 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -19
- package/build/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
- package/build/components/template-details/edit-template-title.js +0 -42
- package/build/components/template-details/edit-template-title.js.map +0 -1
- package/build/components/template-details/index.js +0 -103
- package/build/components/template-details/index.js.map +0 -1
- package/build/components/template-details/template-areas.js +0 -160
- package/build/components/template-details/template-areas.js.map +0 -1
- package/build/components/template-details/template-part-area-selector.js +0 -48
- package/build/components/template-details/template-part-area-selector.js.map +0 -1
- package/build/hooks/commands/index.js +0 -19
- package/build/hooks/commands/index.js.map +0 -1
- package/build/hooks/commands/use-navigation-commands.js +0 -126
- package/build/hooks/commands/use-navigation-commands.js.map +0 -1
- package/build/hooks/commands/use-wp-admin-commands.js +0 -97
- package/build/hooks/commands/use-wp-admin-commands.js.map +0 -1
- package/build/utils/history.js +0 -41
- package/build/utils/history.js.map +0 -1
- package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +0 -1
- package/build-module/components/add-new-template/add-custom-template-modal.js.map +0 -1
- package/build-module/components/global-styles/border-panel.js +0 -123
- package/build-module/components/global-styles/border-panel.js.map +0 -1
- package/build-module/components/global-styles/context-menu.js +0 -107
- package/build-module/components/global-styles/context-menu.js.map +0 -1
- package/build-module/components/global-styles/custom-css.js +0 -98
- package/build-module/components/global-styles/custom-css.js.map +0 -1
- package/build-module/components/global-styles/effects-panel.js +0 -43
- package/build-module/components/global-styles/effects-panel.js.map +0 -1
- package/build-module/components/global-styles/filters-panel.js +0 -40
- package/build-module/components/global-styles/filters-panel.js.map +0 -1
- package/build-module/components/global-styles/screen-border.js +0 -44
- package/build-module/components/global-styles/screen-border.js.map +0 -1
- package/build-module/components/global-styles/screen-effects.js +0 -44
- package/build-module/components/global-styles/screen-effects.js.map +0 -1
- package/build-module/components/global-styles/screen-filters.js +0 -33
- package/build-module/components/global-styles/screen-filters.js.map +0 -1
- package/build-module/components/global-styles/screen-variations.js +0 -54
- package/build-module/components/global-styles/screen-variations.js.map +0 -1
- package/build-module/components/navigate-to-link/index.js +0 -39
- package/build-module/components/navigate-to-link/index.js.map +0 -1
- package/build-module/components/routes/index.js +0 -47
- package/build-module/components/routes/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/loader.js.map +0 -1
- package/build-module/components/template-details/edit-template-title.js +0 -33
- package/build-module/components/template-details/edit-template-title.js.map +0 -1
- package/build-module/components/template-details/index.js +0 -83
- package/build-module/components/template-details/index.js.map +0 -1
- package/build-module/components/template-details/template-areas.js +0 -141
- package/build-module/components/template-details/template-areas.js.map +0 -1
- package/build-module/components/template-details/template-part-area-selector.js +0 -36
- package/build-module/components/template-details/template-part-area-selector.js.map +0 -1
- package/build-module/hooks/commands/index.js +0 -10
- package/build-module/hooks/commands/index.js.map +0 -1
- package/build-module/hooks/commands/use-navigation-commands.js +0 -109
- package/build-module/hooks/commands/use-navigation-commands.js.map +0 -1
- package/build-module/hooks/commands/use-wp-admin-commands.js +0 -81
- package/build-module/hooks/commands/use-wp-admin-commands.js.map +0 -1
- package/build-module/utils/history.js +0 -31
- package/build-module/utils/history.js.map +0 -1
- package/src/components/add-new-template/add-custom-generic-template-modal.js +0 -101
- package/src/components/global-styles/border-panel.js +0 -112
- package/src/components/global-styles/context-menu.js +0 -175
- package/src/components/global-styles/custom-css.js +0 -131
- package/src/components/global-styles/effects-panel.js +0 -40
- package/src/components/global-styles/filters-panel.js +0 -39
- package/src/components/global-styles/screen-border.js +0 -35
- package/src/components/global-styles/screen-effects.js +0 -35
- package/src/components/global-styles/screen-filters.js +0 -27
- package/src/components/global-styles/screen-variations.js +0 -46
- package/src/components/navigate-to-link/index.js +0 -46
- package/src/components/routes/index.js +0 -53
- package/src/components/sidebar-navigation-screen-navigation-menus/loader.js +0 -9
- package/src/components/template-details/edit-template-title.js +0 -41
- package/src/components/template-details/index.js +0 -113
- package/src/components/template-details/style.scss +0 -72
- package/src/components/template-details/template-areas.js +0 -164
- package/src/components/template-details/template-part-area-selector.js +0 -39
- package/src/hooks/commands/index.js +0 -10
- package/src/hooks/commands/use-navigation-commands.js +0 -112
- package/src/hooks/commands/use-wp-admin-commands.js +0 -79
- package/src/utils/history.js +0 -39
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { useState, useRef, useEffect } from '@wordpress/element';
|
|
12
|
+
import { ResizableBox, __unstableMotion as motion } from '@wordpress/components';
|
|
13
|
+
import { useDispatch } from '@wordpress/data';
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { unlock } from '../../private-apis';
|
|
19
|
+
import { store as editSiteStore } from '../../store'; // Removes the inline styles in the drag handles.
|
|
20
|
+
|
|
21
|
+
const HANDLE_STYLES_OVERRIDE = {
|
|
22
|
+
position: undefined,
|
|
23
|
+
userSelect: undefined,
|
|
24
|
+
cursor: undefined,
|
|
25
|
+
width: undefined,
|
|
26
|
+
height: undefined,
|
|
27
|
+
top: undefined,
|
|
28
|
+
right: undefined,
|
|
29
|
+
bottom: undefined,
|
|
30
|
+
left: undefined
|
|
31
|
+
}; // The minimum width of the frame (in px) while resizing.
|
|
32
|
+
|
|
33
|
+
const FRAME_MIN_WIDTH = 340; // The reference width of the frame (in px) used to calculate the aspect ratio.
|
|
34
|
+
|
|
35
|
+
const FRAME_REFERENCE_WIDTH = 1300; // 9 : 19.5 is the target aspect ratio enforced (when possible) while resizing.
|
|
36
|
+
|
|
37
|
+
const FRAME_TARGET_ASPECT_RATIO = 9 / 19.5; // The minimum distance (in px) between the frame resize handle and the
|
|
38
|
+
// viewport's edge. If the frame is resized to be closer to the viewport's edge
|
|
39
|
+
// than this distance, then "canvas mode" will be enabled.
|
|
40
|
+
|
|
41
|
+
const SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200;
|
|
42
|
+
|
|
43
|
+
function calculateNewHeight(width, initialAspectRatio) {
|
|
44
|
+
const lerp = (a, b, amount) => {
|
|
45
|
+
return a + (b - a) * amount;
|
|
46
|
+
}; // Calculate the intermediate aspect ratio based on the current width.
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const lerpFactor = 1 - Math.max(0, Math.min(1, (width - FRAME_MIN_WIDTH) / (FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH))); // Calculate the height based on the intermediate aspect ratio
|
|
50
|
+
// ensuring the frame arrives at the target aspect ratio.
|
|
51
|
+
|
|
52
|
+
const intermediateAspectRatio = lerp(initialAspectRatio, FRAME_TARGET_ASPECT_RATIO, lerpFactor);
|
|
53
|
+
return width / intermediateAspectRatio;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ResizableFrame(_ref2) {
|
|
57
|
+
let {
|
|
58
|
+
isFullWidth,
|
|
59
|
+
isReady,
|
|
60
|
+
children,
|
|
61
|
+
oversizedClassName
|
|
62
|
+
} = _ref2;
|
|
63
|
+
const [frameSize, setFrameSize] = useState({
|
|
64
|
+
width: '100%',
|
|
65
|
+
height: '100%'
|
|
66
|
+
}); // The width of the resizable frame when a new resize gesture starts.
|
|
67
|
+
|
|
68
|
+
const [startingWidth, setStartingWidth] = useState();
|
|
69
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
70
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
71
|
+
const [isOversized, setIsOversized] = useState(false);
|
|
72
|
+
const [resizeRatio, setResizeRatio] = useState(1);
|
|
73
|
+
const {
|
|
74
|
+
setCanvasMode
|
|
75
|
+
} = unlock(useDispatch(editSiteStore));
|
|
76
|
+
const initialAspectRatioRef = useRef(null); // The width of the resizable frame on initial render.
|
|
77
|
+
|
|
78
|
+
const initialComputedWidthRef = useRef(null);
|
|
79
|
+
const FRAME_TRANSITION = {
|
|
80
|
+
type: 'tween',
|
|
81
|
+
duration: isResizing ? 0 : 0.5
|
|
82
|
+
};
|
|
83
|
+
const frameRef = useRef(null); // Remember frame dimensions on initial render.
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const {
|
|
87
|
+
offsetWidth,
|
|
88
|
+
offsetHeight
|
|
89
|
+
} = frameRef.current.resizable;
|
|
90
|
+
initialComputedWidthRef.current = offsetWidth;
|
|
91
|
+
initialAspectRatioRef.current = offsetWidth / offsetHeight;
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
const handleResizeStart = (_event, _direction, ref) => {
|
|
95
|
+
// Remember the starting width so we don't have to get `ref.offsetWidth` on
|
|
96
|
+
// every resize event thereafter, which will cause layout thrashing.
|
|
97
|
+
setStartingWidth(ref.offsetWidth);
|
|
98
|
+
setIsResizing(true);
|
|
99
|
+
}; // Calculate the frame size based on the window width as its resized.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
const handleResize = (_event, _direction, _ref, delta) => {
|
|
103
|
+
const normalizedDelta = delta.width / resizeRatio;
|
|
104
|
+
const deltaAbs = Math.abs(normalizedDelta);
|
|
105
|
+
const maxDoubledDelta = delta.width < 0 // is shrinking
|
|
106
|
+
? deltaAbs : (initialComputedWidthRef.current - startingWidth) / 2;
|
|
107
|
+
const deltaToDouble = Math.min(deltaAbs, maxDoubledDelta);
|
|
108
|
+
const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs;
|
|
109
|
+
const singleSegment = 1 - doubleSegment;
|
|
110
|
+
setResizeRatio(singleSegment + doubleSegment * 2);
|
|
111
|
+
const updatedWidth = startingWidth + delta.width;
|
|
112
|
+
setIsOversized(updatedWidth > initialComputedWidthRef.current); // Width will be controlled by the library (via `resizeRatio`),
|
|
113
|
+
// so we only need to update the height.
|
|
114
|
+
|
|
115
|
+
setFrameSize({
|
|
116
|
+
height: isOversized ? '100%' : calculateNewHeight(updatedWidth, initialAspectRatioRef.current)
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const handleResizeStop = (_event, _direction, ref) => {
|
|
121
|
+
setIsResizing(false);
|
|
122
|
+
|
|
123
|
+
if (!isOversized) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
setIsOversized(false);
|
|
128
|
+
const remainingWidth = ref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth;
|
|
129
|
+
|
|
130
|
+
if (remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD) {
|
|
131
|
+
// Reset the initial aspect ratio if the frame is resized slightly
|
|
132
|
+
// above the sidebar but not far enough to trigger full screen.
|
|
133
|
+
setFrameSize({
|
|
134
|
+
width: '100%',
|
|
135
|
+
height: '100%'
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
// Trigger full screen if the frame is resized far enough to the left.
|
|
139
|
+
setCanvasMode('edit');
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const frameAnimationVariants = {
|
|
144
|
+
default: {
|
|
145
|
+
flexGrow: 0,
|
|
146
|
+
height: frameSize.height
|
|
147
|
+
},
|
|
148
|
+
fullWidth: {
|
|
149
|
+
flexGrow: 1,
|
|
150
|
+
height: frameSize.height
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return createElement(ResizableBox, {
|
|
154
|
+
as: motion.div,
|
|
155
|
+
ref: frameRef,
|
|
156
|
+
initial: false,
|
|
157
|
+
variants: frameAnimationVariants,
|
|
158
|
+
animate: isFullWidth ? 'fullWidth' : 'default',
|
|
159
|
+
onAnimationComplete: definition => {
|
|
160
|
+
if (definition === 'fullWidth') setFrameSize({
|
|
161
|
+
width: '100%',
|
|
162
|
+
height: '100%'
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
transition: FRAME_TRANSITION,
|
|
166
|
+
size: frameSize,
|
|
167
|
+
enable: {
|
|
168
|
+
top: false,
|
|
169
|
+
right: false,
|
|
170
|
+
bottom: false,
|
|
171
|
+
// Resizing will be disabled until the editor content is loaded.
|
|
172
|
+
left: isReady,
|
|
173
|
+
topRight: false,
|
|
174
|
+
bottomRight: false,
|
|
175
|
+
bottomLeft: false,
|
|
176
|
+
topLeft: false
|
|
177
|
+
},
|
|
178
|
+
resizeRatio: resizeRatio,
|
|
179
|
+
handleClasses: undefined,
|
|
180
|
+
handleStyles: {
|
|
181
|
+
left: HANDLE_STYLES_OVERRIDE,
|
|
182
|
+
right: HANDLE_STYLES_OVERRIDE
|
|
183
|
+
},
|
|
184
|
+
minWidth: FRAME_MIN_WIDTH,
|
|
185
|
+
maxWidth: isFullWidth ? '100%' : '150%',
|
|
186
|
+
maxHeight: '100%',
|
|
187
|
+
onMouseOver: () => setIsHovering(true),
|
|
188
|
+
onMouseOut: () => setIsHovering(false),
|
|
189
|
+
handleComponent: {
|
|
190
|
+
left: isHovering || isResizing ? createElement(motion.div, {
|
|
191
|
+
key: "handle",
|
|
192
|
+
className: "edit-site-resizable-frame__handle",
|
|
193
|
+
title: "Drag to resize",
|
|
194
|
+
initial: {
|
|
195
|
+
opacity: 0,
|
|
196
|
+
left: 0
|
|
197
|
+
},
|
|
198
|
+
animate: {
|
|
199
|
+
opacity: 1,
|
|
200
|
+
left: -15
|
|
201
|
+
},
|
|
202
|
+
exit: {
|
|
203
|
+
opacity: 0,
|
|
204
|
+
left: 0
|
|
205
|
+
},
|
|
206
|
+
whileHover: {
|
|
207
|
+
scale: 1.1
|
|
208
|
+
}
|
|
209
|
+
}) : null
|
|
210
|
+
},
|
|
211
|
+
onResizeStart: handleResizeStart,
|
|
212
|
+
onResize: handleResize,
|
|
213
|
+
onResizeStop: handleResizeStop,
|
|
214
|
+
className: classnames('edit-site-resizable-frame__inner', {
|
|
215
|
+
'is-resizing': isResizing,
|
|
216
|
+
[oversizedClassName]: isOversized
|
|
217
|
+
})
|
|
218
|
+
}, createElement(motion.div, {
|
|
219
|
+
className: "edit-site-resizable-frame__inner-content",
|
|
220
|
+
animate: {
|
|
221
|
+
borderRadius: isFullWidth ? 0 : 8
|
|
222
|
+
},
|
|
223
|
+
transition: FRAME_TRANSITION
|
|
224
|
+
}, children));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export default ResizableFrame;
|
|
228
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/resizable-frame/index.js"],"names":["classnames","useState","useRef","useEffect","ResizableBox","__unstableMotion","motion","useDispatch","unlock","store","editSiteStore","HANDLE_STYLES_OVERRIDE","position","undefined","userSelect","cursor","width","height","top","right","bottom","left","FRAME_MIN_WIDTH","FRAME_REFERENCE_WIDTH","FRAME_TARGET_ASPECT_RATIO","SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD","calculateNewHeight","initialAspectRatio","lerp","a","b","amount","lerpFactor","Math","max","min","intermediateAspectRatio","ResizableFrame","isFullWidth","isReady","children","oversizedClassName","frameSize","setFrameSize","startingWidth","setStartingWidth","isResizing","setIsResizing","isHovering","setIsHovering","isOversized","setIsOversized","resizeRatio","setResizeRatio","setCanvasMode","initialAspectRatioRef","initialComputedWidthRef","FRAME_TRANSITION","type","duration","frameRef","offsetWidth","offsetHeight","current","resizable","handleResizeStart","_event","_direction","ref","handleResize","_ref","delta","normalizedDelta","deltaAbs","abs","maxDoubledDelta","deltaToDouble","doubleSegment","singleSegment","updatedWidth","handleResizeStop","remainingWidth","ownerDocument","documentElement","frameAnimationVariants","default","flexGrow","fullWidth","div","definition","topRight","bottomRight","bottomLeft","topLeft","opacity","scale","borderRadius"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SACCC,YADD,EAECC,gBAAgB,IAAIC,MAFrB,QAGO,uBAHP;AAIA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SA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A,KAAK,EAAE;AAAT;AAhBd,QADD,GAmBI;AArBY,KAlCnB;AAyDC,IAAA,aAAa,EAAG9B,iBAzDjB;AA0DC,IAAA,QAAQ,EAAGI,YA1DZ;AA2DC,IAAA,YAAY,EAAGW,gBA3DhB;AA4DC,IAAA,SAAS,EAAGhF,UAAU,CAAE,kCAAF,EAAsC;AAC3D,qBAAe8C,UAD4C;AAE3D,OAAEL,kBAAF,GAAwBS;AAFmC,KAAtC;AA5DvB,KAiEC,cAAC,MAAD,CAAQ,GAAR;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,OAAO,EAAG;AACT8C,MAAAA,YAAY,EAAE1D,WAAW,GAAG,CAAH,GAAO;AADvB,KAFX;AAKC,IAAA,UAAU,EAAGmB;AALd,KAOGjB,QAPH,CAjED,CADD;AA6EA;;AAED,eAAeH,cAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport {\n\tResizableBox,\n\t__unstableMotion as motion,\n} from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport { store as editSiteStore } from '../../store';\n\n// Removes the inline styles in the drag handles.\nconst HANDLE_STYLES_OVERRIDE = {\n\tposition: undefined,\n\tuserSelect: undefined,\n\tcursor: undefined,\n\twidth: undefined,\n\theight: undefined,\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\n// The minimum width of the frame (in px) while resizing.\nconst FRAME_MIN_WIDTH = 340;\n// The reference width of the frame (in px) used to calculate the aspect ratio.\nconst FRAME_REFERENCE_WIDTH = 1300;\n// 9 : 19.5 is the target aspect ratio enforced (when possible) while resizing.\nconst FRAME_TARGET_ASPECT_RATIO = 9 / 19.5;\n// The minimum distance (in px) between the frame resize handle and the\n// viewport's edge. If the frame is resized to be closer to the viewport's edge\n// than this distance, then \"canvas mode\" will be enabled.\nconst SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200;\n\nfunction calculateNewHeight( width, initialAspectRatio ) {\n\tconst lerp = ( a, b, amount ) => {\n\t\treturn a + ( b - a ) * amount;\n\t};\n\n\t// Calculate the intermediate aspect ratio based on the current width.\n\tconst lerpFactor =\n\t\t1 -\n\t\tMath.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\t1,\n\t\t\t\t( width - FRAME_MIN_WIDTH ) /\n\t\t\t\t\t( FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH )\n\t\t\t)\n\t\t);\n\n\t// Calculate the height based on the intermediate aspect ratio\n\t// ensuring the frame arrives at the target aspect ratio.\n\tconst intermediateAspectRatio = lerp(\n\t\tinitialAspectRatio,\n\t\tFRAME_TARGET_ASPECT_RATIO,\n\t\tlerpFactor\n\t);\n\n\treturn width / intermediateAspectRatio;\n}\n\nfunction ResizableFrame( {\n\tisFullWidth,\n\tisReady,\n\tchildren,\n\toversizedClassName,\n} ) {\n\tconst [ frameSize, setFrameSize ] = useState( {\n\t\twidth: '100%',\n\t\theight: '100%',\n\t} );\n\t// The width of the resizable frame when a new resize gesture starts.\n\tconst [ startingWidth, setStartingWidth ] = useState();\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ isHovering, setIsHovering ] = useState( false );\n\tconst [ isOversized, setIsOversized ] = useState( false );\n\tconst [ resizeRatio, setResizeRatio ] = useState( 1 );\n\tconst { setCanvasMode } = unlock( useDispatch( editSiteStore ) );\n\tconst initialAspectRatioRef = useRef( null );\n\t// The width of the resizable frame on initial render.\n\tconst initialComputedWidthRef = useRef( null );\n\tconst FRAME_TRANSITION = { type: 'tween', duration: isResizing ? 0 : 0.5 };\n\tconst frameRef = useRef( null );\n\n\t// Remember frame dimensions on initial render.\n\tuseEffect( () => {\n\t\tconst { offsetWidth, offsetHeight } = frameRef.current.resizable;\n\t\tinitialComputedWidthRef.current = offsetWidth;\n\t\tinitialAspectRatioRef.current = offsetWidth / offsetHeight;\n\t}, [] );\n\n\tconst handleResizeStart = ( _event, _direction, ref ) => {\n\t\t// Remember the starting width so we don't have to get `ref.offsetWidth` on\n\t\t// every resize event thereafter, which will cause layout thrashing.\n\t\tsetStartingWidth( ref.offsetWidth );\n\t\tsetIsResizing( true );\n\t};\n\n\t// Calculate the frame size based on the window width as its resized.\n\tconst handleResize = ( _event, _direction, _ref, delta ) => {\n\t\tconst normalizedDelta = delta.width / resizeRatio;\n\t\tconst deltaAbs = Math.abs( normalizedDelta );\n\t\tconst maxDoubledDelta =\n\t\t\tdelta.width < 0 // is shrinking\n\t\t\t\t? deltaAbs\n\t\t\t\t: ( initialComputedWidthRef.current - startingWidth ) / 2;\n\t\tconst deltaToDouble = Math.min( deltaAbs, maxDoubledDelta );\n\t\tconst doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs;\n\t\tconst singleSegment = 1 - doubleSegment;\n\n\t\tsetResizeRatio( singleSegment + doubleSegment * 2 );\n\n\t\tconst updatedWidth = startingWidth + delta.width;\n\n\t\tsetIsOversized( updatedWidth > initialComputedWidthRef.current );\n\n\t\t// Width will be controlled by the library (via `resizeRatio`),\n\t\t// so we only need to update the height.\n\t\tsetFrameSize( {\n\t\t\theight: isOversized\n\t\t\t\t? '100%'\n\t\t\t\t: calculateNewHeight(\n\t\t\t\t\t\tupdatedWidth,\n\t\t\t\t\t\tinitialAspectRatioRef.current\n\t\t\t\t ),\n\t\t} );\n\t};\n\n\tconst handleResizeStop = ( _event, _direction, ref ) => {\n\t\tsetIsResizing( false );\n\n\t\tif ( ! isOversized ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsOversized( false );\n\n\t\tconst remainingWidth =\n\t\t\tref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth;\n\n\t\tif ( remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD ) {\n\t\t\t// Reset the initial aspect ratio if the frame is resized slightly\n\t\t\t// above the sidebar but not far enough to trigger full screen.\n\t\t\tsetFrameSize( { width: '100%', height: '100%' } );\n\t\t} else {\n\t\t\t// Trigger full screen if the frame is resized far enough to the left.\n\t\t\tsetCanvasMode( 'edit' );\n\t\t}\n\t};\n\n\tconst frameAnimationVariants = {\n\t\tdefault: {\n\t\t\tflexGrow: 0,\n\t\t\theight: frameSize.height,\n\t\t},\n\t\tfullWidth: {\n\t\t\tflexGrow: 1,\n\t\t\theight: frameSize.height,\n\t\t},\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tas={ motion.div }\n\t\t\tref={ frameRef }\n\t\t\tinitial={ false }\n\t\t\tvariants={ frameAnimationVariants }\n\t\t\tanimate={ isFullWidth ? 'fullWidth' : 'default' }\n\t\t\tonAnimationComplete={ ( definition ) => {\n\t\t\t\tif ( definition === 'fullWidth' )\n\t\t\t\t\tsetFrameSize( { width: '100%', height: '100%' } );\n\t\t\t} }\n\t\t\ttransition={ FRAME_TRANSITION }\n\t\t\tsize={ frameSize }\n\t\t\tenable={ {\n\t\t\t\ttop: false,\n\t\t\t\tright: false,\n\t\t\t\tbottom: false,\n\t\t\t\t// Resizing will be disabled until the editor content is loaded.\n\t\t\t\tleft: isReady,\n\t\t\t\ttopRight: false,\n\t\t\t\tbottomRight: false,\n\t\t\t\tbottomLeft: false,\n\t\t\t\ttopLeft: false,\n\t\t\t} }\n\t\t\tresizeRatio={ resizeRatio }\n\t\t\thandleClasses={ undefined }\n\t\t\thandleStyles={ {\n\t\t\t\tleft: HANDLE_STYLES_OVERRIDE,\n\t\t\t\tright: HANDLE_STYLES_OVERRIDE,\n\t\t\t} }\n\t\t\tminWidth={ FRAME_MIN_WIDTH }\n\t\t\tmaxWidth={ isFullWidth ? '100%' : '150%' }\n\t\t\tmaxHeight={ '100%' }\n\t\t\tonMouseOver={ () => setIsHovering( true ) }\n\t\t\tonMouseOut={ () => setIsHovering( false ) }\n\t\t\thandleComponent={ {\n\t\t\t\tleft:\n\t\t\t\t\tisHovering || isResizing ? (\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tkey=\"handle\"\n\t\t\t\t\t\t\tclassName=\"edit-site-resizable-frame__handle\"\n\t\t\t\t\t\t\ttitle=\"Drag to resize\"\n\t\t\t\t\t\t\tinitial={ {\n\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\tleft: 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t\t\tleft: -15,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\texit={ {\n\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\tleft: 0,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\twhileHover={ { scale: 1.1 } }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null,\n\t\t\t} }\n\t\t\tonResizeStart={ handleResizeStart }\n\t\t\tonResize={ handleResize }\n\t\t\tonResizeStop={ handleResizeStop }\n\t\t\tclassName={ classnames( 'edit-site-resizable-frame__inner', {\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t[ oversizedClassName ]: isOversized,\n\t\t\t} ) }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tclassName=\"edit-site-resizable-frame__inner-content\"\n\t\t\t\tanimate={ {\n\t\t\t\t\tborderRadius: isFullWidth ? 0 : 8,\n\t\t\t\t} }\n\t\t\t\ttransition={ FRAME_TRANSITION }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</motion.div>\n\t\t</ResizableBox>\n\t);\n}\n\nexport default ResizableFrame;\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { isEmpty } from 'lodash';
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Disabled } from '@wordpress/components';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
import { BlockList, privateApis as blockEditorPrivateApis, store as blockEditorStore, __unstableEditorStyles as EditorStyles, __unstableIframe as Iframe } from '@wordpress/block-editor';
|
|
14
|
+
import { useSelect } from '@wordpress/data';
|
|
15
|
+
import { useMemo } from '@wordpress/element';
|
|
16
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { unlock } from '../../private-apis';
|
|
22
|
+
import { mergeBaseAndUserConfigs } from '../global-styles/global-styles-provider';
|
|
23
|
+
import EditorCanvasContainer from '../editor-canvas-container';
|
|
24
|
+
const {
|
|
25
|
+
ExperimentalBlockEditorProvider,
|
|
26
|
+
useGlobalStylesOutputWithConfig
|
|
27
|
+
} = unlock(blockEditorPrivateApis);
|
|
28
|
+
|
|
29
|
+
function Revisions(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
onClose,
|
|
32
|
+
userConfig,
|
|
33
|
+
blocks
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
baseConfig
|
|
37
|
+
} = useSelect(select => ({
|
|
38
|
+
baseConfig: select(coreStore).__experimentalGetCurrentThemeBaseGlobalStyles()
|
|
39
|
+
}), []);
|
|
40
|
+
const mergedConfig = useMemo(() => {
|
|
41
|
+
if (!isEmpty(userConfig) && !isEmpty(baseConfig)) {
|
|
42
|
+
return mergeBaseAndUserConfigs(baseConfig, userConfig);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {};
|
|
46
|
+
}, [baseConfig, userConfig]);
|
|
47
|
+
const renderedBlocksArray = useMemo(() => Array.isArray(blocks) ? blocks : [blocks], [blocks]);
|
|
48
|
+
const originalSettings = useSelect(select => select(blockEditorStore).getSettings(), []);
|
|
49
|
+
const settings = useMemo(() => ({ ...originalSettings,
|
|
50
|
+
__unstableIsPreviewMode: true
|
|
51
|
+
}), [originalSettings]);
|
|
52
|
+
const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig);
|
|
53
|
+
const editorStyles = !isEmpty(globalStyles) && !isEmpty(userConfig) ? globalStyles : settings.styles;
|
|
54
|
+
return createElement(EditorCanvasContainer, {
|
|
55
|
+
title: __('Revisions'),
|
|
56
|
+
onClose: onClose,
|
|
57
|
+
closeButtonLabel: __('Close revisions'),
|
|
58
|
+
enableResizing: true
|
|
59
|
+
}, createElement(Iframe, {
|
|
60
|
+
className: "edit-site-revisions__iframe",
|
|
61
|
+
name: "revisions",
|
|
62
|
+
tabIndex: 0
|
|
63
|
+
}, createElement(EditorStyles, {
|
|
64
|
+
styles: editorStyles
|
|
65
|
+
}), createElement("style", null, // Forming a "block formatting context" to prevent margin collapsing.
|
|
66
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
67
|
+
`.is-root-container { display: flow-root; } body { position: relative; padding: 32px; }`), createElement(Disabled, {
|
|
68
|
+
className: "edit-site-revisions__example-preview__content"
|
|
69
|
+
}, createElement(ExperimentalBlockEditorProvider, {
|
|
70
|
+
value: renderedBlocksArray,
|
|
71
|
+
settings: settings
|
|
72
|
+
}, createElement(BlockList, {
|
|
73
|
+
renderAppender: false
|
|
74
|
+
})))));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default Revisions;
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/revisions/index.js"],"names":["isEmpty","Disabled","__","BlockList","privateApis","blockEditorPrivateApis","store","blockEditorStore","__unstableEditorStyles","EditorStyles","__unstableIframe","Iframe","useSelect","useMemo","coreStore","unlock","mergeBaseAndUserConfigs","EditorCanvasContainer","ExperimentalBlockEditorProvider","useGlobalStylesOutputWithConfig","Revisions","onClose","userConfig","blocks","baseConfig","select","__experimentalGetCurrentThemeBaseGlobalStyles","mergedConfig","renderedBlocksArray","Array","isArray","originalSettings","getSettings","settings","__unstableIsPreviewMode","globalStyles","editorStyles","styles"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,SADD,EAECC,WAAW,IAAIC,sBAFhB,EAGCC,KAAK,IAAIC,gBAHV,EAICC,sBAAsB,IAAIC,YAJ3B,EAKCC,gBAAgB,IAAIC,MALrB,QAMO,yBANP;AAOA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASP,KAAK,IAAIQ,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AAEA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,uBAAT,QAAwC,yCAAxC;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,MAAM;AAAEC,EAAAA,+BAAF;AAAmCC,EAAAA;AAAnC,IACLJ,MAAM,CAAEV,sBAAF,CADP;;AAGA,SAASe,SAAT,OAAsD;AAAA,MAAlC;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,UAAX;AAAuBC,IAAAA;AAAvB,GAAkC;AACrD,QAAM;AAAEC,IAAAA;AAAF,MAAiBZ,SAAS,CAC7Ba,MAAF,KAAgB;AACfD,IAAAA,UAAU,EACTC,MAAM,CACLX,SADK,CAAN,CAEEY,6CAFF;AAFc,GAAhB,CAD+B,EAO/B,EAP+B,CAAhC;AAUA,QAAMC,YAAY,GAAGd,OAAO,CAAE,MAAM;AACnC,QAAK,CAAEb,OAAO,CAAEsB,UAAF,CAAT,IAA2B,CAAEtB,OAAO,CAAEwB,UAAF,CAAzC,EAA0D;AACzD,aAAOR,uBAAuB,CAAEQ,UAAF,EAAcF,UAAd,CAA9B;AACA;;AACD,WAAO,EAAP;AACA,GAL2B,EAKzB,CAAEE,UAAF,EAAcF,UAAd,CAL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JD,CADD,CAbD,CAND,CADD;AA+BA;;AAED,eAAeb,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Disabled } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\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 { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\n\nimport { unlock } from '../../private-apis';\nimport { mergeBaseAndUserConfigs } from '../global-styles/global-styles-provider';\nimport EditorCanvasContainer from '../editor-canvas-container';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStylesOutputWithConfig } =\n\tunlock( blockEditorPrivateApis );\n\nfunction Revisions( { onClose, userConfig, blocks } ) {\n\tconst { baseConfig } = useSelect(\n\t\t( select ) => ( {\n\t\t\tbaseConfig:\n\t\t\t\tselect(\n\t\t\t\t\tcoreStore\n\t\t\t\t).__experimentalGetCurrentThemeBaseGlobalStyles(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst mergedConfig = useMemo( () => {\n\t\tif ( ! isEmpty( userConfig ) && ! isEmpty( baseConfig ) ) {\n\t\t\treturn mergeBaseAndUserConfigs( baseConfig, userConfig );\n\t\t}\n\t\treturn {};\n\t}, [ baseConfig, userConfig ] );\n\n\tconst renderedBlocksArray = useMemo(\n\t\t() => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),\n\t\t[ blocks ]\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\tconst [ globalStyles ] = useGlobalStylesOutputWithConfig( mergedConfig );\n\n\tconst editorStyles =\n\t\t! isEmpty( globalStyles ) && ! isEmpty( userConfig )\n\t\t\t? globalStyles\n\t\t\t: settings.styles;\n\n\treturn (\n\t\t<EditorCanvasContainer\n\t\t\ttitle={ __( 'Revisions' ) }\n\t\t\tonClose={ onClose }\n\t\t\tcloseButtonLabel={ __( 'Close revisions' ) }\n\t\t\tenableResizing={ true }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\tclassName=\"edit-site-revisions__iframe\"\n\t\t\t\tname=\"revisions\"\n\t\t\t\ttabIndex={ 0 }\n\t\t\t>\n\t\t\t\t<EditorStyles styles={ editorStyles } />\n\t\t\t\t<style>\n\t\t\t\t\t{\n\t\t\t\t\t\t// Forming a \"block formatting context\" to prevent margin collapsing.\n\t\t\t\t\t\t// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context\n\t\t\t\t\t\t`.is-root-container { display: flow-root; } body { position: relative; padding: 32px; }`\n\t\t\t\t\t}\n\t\t\t\t</style>\n\t\t\t\t<Disabled className=\"edit-site-revisions__example-preview__content\">\n\t\t\t\t\t<ExperimentalBlockEditorProvider\n\t\t\t\t\t\tvalue={ renderedBlocksArray }\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</Iframe>\n\t\t</EditorCanvasContainer>\n\t);\n}\n\nexport default Revisions;\n"]}
|
|
@@ -5,11 +5,16 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
7
|
import { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
8
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
+
import { unlock } from '../../private-apis';
|
|
14
|
+
import { isPreviewingTheme, currentlyPreviewingTheme } from '../../utils/is-previewing-theme';
|
|
15
|
+
const {
|
|
16
|
+
useHistory
|
|
17
|
+
} = unlock(routerPrivateApis);
|
|
13
18
|
export function useLink() {
|
|
14
19
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15
20
|
let state = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -28,6 +33,13 @@ export function useLink() {
|
|
|
28
33
|
|
|
29
34
|
const currentArgs = getQueryArgs(window.location.href);
|
|
30
35
|
const currentUrlWithoutArgs = removeQueryArgs(window.location.href, ...Object.keys(currentArgs));
|
|
36
|
+
|
|
37
|
+
if (isPreviewingTheme()) {
|
|
38
|
+
params = { ...params,
|
|
39
|
+
theme_preview: currentlyPreviewingTheme()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
const newUrl = addQueryArgs(currentUrlWithoutArgs, params);
|
|
32
44
|
return {
|
|
33
45
|
href: newUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["addQueryArgs","getQueryArgs","removeQueryArgs","useHistory","useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","currentArgs","window","location","href","currentUrlWithoutArgs","Object","keys","newUrl","Link","children","props"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,YAAvB,EAAqCC,eAArC,QAA4D,gBAA5D;AAEA;AACA;AACA;;AACA,SAASC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/link.js"],"names":["addQueryArgs","getQueryArgs","removeQueryArgs","privateApis","routerPrivateApis","unlock","isPreviewingTheme","currentlyPreviewingTheme","useHistory","useLink","params","state","shouldReplace","history","onClick","event","preventDefault","replace","push","currentArgs","window","location","href","currentUrlWithoutArgs","Object","keys","theme_preview","newUrl","Link","children","props"],"mappings":";;;AAAA;AACA;AACA;AACA,S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0B;AAC7BlB,IAAAA,MAAM,GAAG,EADoB;AAE7BC,IAAAA,KAF6B;AAG7BM,IAAAA,OAAO,EAAEL,aAAa,GAAG,KAHI;AAI7BiB,IAAAA,QAJ6B;AAK7B,OAAGC;AAL0B,GAM1B;AACH,QAAM;AAAER,IAAAA,IAAF;AAAQR,IAAAA;AAAR,MAAoBL,OAAO,CAAEC,MAAF,EAAUC,KAAV,EAAiBC,aAAjB,CAAjC;AAEA,SACC;AAAG,IAAA,IAAI,EAAGU,IAAV;AAAiB,IAAA,OAAO,EAAGR;AAA3B,KAA0CgB,KAA1C,GACGD,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs, getQueryArgs, removeQueryArgs } from '@wordpress/url';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from '../../utils/is-previewing-theme';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport function useLink( params = {}, state, shouldReplace = false ) {\n\tconst history = useHistory();\n\n\tfunction onClick( event ) {\n\t\tevent.preventDefault();\n\n\t\tif ( shouldReplace ) {\n\t\t\thistory.replace( params, state );\n\t\t} else {\n\t\t\thistory.push( params, state );\n\t\t}\n\t}\n\n\tconst currentArgs = getQueryArgs( window.location.href );\n\tconst currentUrlWithoutArgs = removeQueryArgs(\n\t\twindow.location.href,\n\t\t...Object.keys( currentArgs )\n\t);\n\n\tif ( isPreviewingTheme() ) {\n\t\tparams = {\n\t\t\t...params,\n\t\t\ttheme_preview: currentlyPreviewingTheme(),\n\t\t};\n\t}\n\n\tconst newUrl = addQueryArgs( currentUrlWithoutArgs, params );\n\n\treturn {\n\t\thref: newUrl,\n\t\tonClick,\n\t};\n}\n\nexport default function Link( {\n\tparams = {},\n\tstate,\n\treplace: shouldReplace = false,\n\tchildren,\n\t...props\n} ) {\n\tconst { href, onClick } = useLink( params, state, shouldReplace );\n\n\treturn (\n\t\t<a href={ href } onClick={ onClick } { ...props }>\n\t\t\t{ children }\n\t\t</a>\n\t);\n}\n"]}
|
|
@@ -7,11 +7,15 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
7
7
|
import { __, sprintf } from '@wordpress/i18n';
|
|
8
8
|
import { speak } from '@wordpress/a11y';
|
|
9
9
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
10
|
+
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
|
-
import {
|
|
15
|
+
import { unlock } from '../../private-apis';
|
|
16
|
+
const {
|
|
17
|
+
useLocation
|
|
18
|
+
} = unlock(routerPrivateApis);
|
|
15
19
|
export default function useTitle(title) {
|
|
16
20
|
const location = useLocation();
|
|
17
21
|
const siteTitle = useSelect(select => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/use-title.js"],"names":["useEffect","useRef","useSelect","store","coreStore","__","sprintf","speak","decodeEntities","useLocation","useTitle","title","location","siteTitle","select","getEntityRecord","isInitialLocationRef","current","formattedTitle","document"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;AACA,SAASC,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/routes/use-title.js"],"names":["useEffect","useRef","useSelect","store","coreStore","__","sprintf","speak","decodeEntities","privateApis","routerPrivateApis","unlock","useLocation","useTitle","title","location","siteTitle","select","getEntityRecord","isInitialLocationRef","current","formattedTitle","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,CATyB,CAWzB;;AACAd,MAAAA,KAAK,CACJD,OAAO;AACN;AACAD,MAAAA,EAAE,CAAE,oBAAF,CAFI,EAGNiB,QAAQ,CAACR,KAHH,CADH,EAMJ,WANI,CAAL;AAQA;AACD,GA3BQ,EA2BN,CAAEA,KAAF,EAASE,SAAT,EAAoBD,QAApB,CA3BM,CAAT;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\n\nconst { useLocation } = unlock( routerPrivateApis );\n\nexport default function useTitle( title ) {\n\tconst location = useLocation();\n\tconst siteTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecord( 'root', 'site' )?.title,\n\t\t[]\n\t);\n\tconst isInitialLocationRef = useRef( true );\n\n\tuseEffect( () => {\n\t\tisInitialLocationRef.current = false;\n\t}, [ location ] );\n\n\tuseEffect( () => {\n\t\t// Don't update or announce the title for initial page load.\n\t\tif ( isInitialLocationRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( title && siteTitle ) {\n\t\t\t// @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68\n\t\t\tconst formattedTitle = sprintf(\n\t\t\t\t/* translators: Admin screen title. 1: Admin screen name, 2: Network or site name. */\n\t\t\t\t__( '%1$s ‹ %2$s — WordPress' ),\n\t\t\t\tdecodeEntities( title ),\n\t\t\t\tdecodeEntities( siteTitle )\n\t\t\t);\n\n\t\t\tdocument.title = formattedTitle;\n\n\t\t\t// Announce title on route change for screen readers.\n\t\t\tspeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: The page title that is currently displaying. */\n\t\t\t\t\t__( 'Now displaying: %s' ),\n\t\t\t\t\tdocument.title\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t}\n\t}, [ title, siteTitle, location ] );\n}\n"]}
|
|
@@ -13,7 +13,14 @@ import { displayShortcut } from '@wordpress/keycodes';
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { store as editSiteStore } from '../../store';
|
|
16
|
-
|
|
16
|
+
import { isPreviewingTheme } from '../../utils/is-previewing-theme';
|
|
17
|
+
export default function SaveButton(_ref) {
|
|
18
|
+
let {
|
|
19
|
+
className = 'edit-site-save-button__button',
|
|
20
|
+
variant = 'primary',
|
|
21
|
+
showTooltip = true,
|
|
22
|
+
icon
|
|
23
|
+
} = _ref;
|
|
17
24
|
const {
|
|
18
25
|
isDirty,
|
|
19
26
|
isSaving,
|
|
@@ -38,13 +45,27 @@ export default function SaveButton() {
|
|
|
38
45
|
const {
|
|
39
46
|
setIsSaveViewOpened
|
|
40
47
|
} = useDispatch(editSiteStore);
|
|
41
|
-
const
|
|
48
|
+
const activateSaveEnabled = isPreviewingTheme() || isDirty;
|
|
49
|
+
const disabled = isSaving || !activateSaveEnabled;
|
|
42
50
|
|
|
43
|
-
const
|
|
51
|
+
const getLabel = () => {
|
|
52
|
+
if (disabled) {
|
|
53
|
+
return __('Saved');
|
|
54
|
+
}
|
|
44
55
|
|
|
56
|
+
if (isPreviewingTheme() && isDirty) {
|
|
57
|
+
return __('Activate & Save');
|
|
58
|
+
} else if (isPreviewingTheme()) {
|
|
59
|
+
return __('Activate');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return __('Save');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const label = getLabel();
|
|
45
66
|
return createElement(Button, {
|
|
46
|
-
variant:
|
|
47
|
-
className:
|
|
67
|
+
variant: variant,
|
|
68
|
+
className: className,
|
|
48
69
|
"aria-disabled": disabled,
|
|
49
70
|
"aria-expanded": isSaveViewOpen,
|
|
50
71
|
isBusy: isSaving,
|
|
@@ -63,7 +84,8 @@ export default function SaveButton() {
|
|
|
63
84
|
& the tooltip is always rendered even when there's no keyboard shortcut.
|
|
64
85
|
*/
|
|
65
86
|
,
|
|
66
|
-
showTooltip:
|
|
87
|
+
showTooltip: showTooltip,
|
|
88
|
+
icon: icon
|
|
67
89
|
}, label);
|
|
68
90
|
}
|
|
69
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["useSelect","useDispatch","Button","__","store","coreStore","displayShortcut","editSiteStore","SaveButton","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","dirtyEntityRecords","isSaveViewOpened","length","some","record","kind","name","key","setIsSaveViewOpened","disabled","label","undefined","primary"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,UAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/save-button/index.js"],"names":["useSelect","useDispatch","Button","__","store","coreStore","displayShortcut","editSiteStore","isPreviewingTheme","SaveButton","className","variant","showTooltip","icon","isDirty","isSaving","isSaveViewOpen","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","dirtyEntityRecords","isSaveViewOpened","length","some","record","kind","name","key","setIsSaveViewOpened","activateSaveEnabled","disabled","getLabel","label","undefined","primary"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAAS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QAAME,QAAQ,GAAG,MAAM;AACtB,QAAKD,QAAL,EAAgB;AACf,aAAO3B,EAAE,CAAE,OAAF,CAAT;AACA;;AAED,QAAKK,iBAAiB,MAAMM,OAA5B,EAAsC;AACrC,aAAOX,EAAE,CAAE,iBAAF,CAAT;AACA,KAFD,MAEO,IAAKK,iBAAiB,EAAtB,EAA2B;AACjC,aAAOL,EAAE,CAAE,UAAF,CAAT;AACA;;AAED,WAAOA,EAAE,CAAE,MAAF,CAAT;AACA,GAZD;;AAaA,QAAM6B,KAAK,GAAGD,QAAQ,EAAtB;AAEA,SACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAGpB,OADX;AAEC,IAAA,SAAS,EAAGD,SAFb;AAGC,qBAAgBoB,QAHjB;AAIC,qBAAgBd,cAJjB;AAKC,IAAA,MAAM,EAAGD,QALV;AAMC,IAAA,OAAO,EAAGe,QAAQ,GAAGG,SAAH,GAAe,MAAML,mBAAmB,CAAE,IAAF,CAN3D;AAOC,IAAA,KAAK,EAAGI;AACR;AACH;AACA;AACA;AAXE;AAYC,IAAA,QAAQ,EAAGF,QAAQ,GAAGG,SAAH,GAAe3B,eAAe,CAAC4B,OAAhB,CAAyB,GAAzB;AAClC;AACH;AACA;AACA;AACA;AACA;AAlBE;AAmBC,IAAA,WAAW,EAAGtB,WAnBf;AAoBC,IAAA,IAAI,EAAGC;AApBR,KAsBGmB,KAtBH,CADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { displayShortcut } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { isPreviewingTheme } from '../../utils/is-previewing-theme';\n\nexport default function SaveButton( {\n\tclassName = 'edit-site-save-button__button',\n\tvariant = 'primary',\n\tshowTooltip = true,\n\ticon,\n} ) {\n\tconst { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\tconst { isSaveViewOpened } = select( editSiteStore );\n\t\treturn {\n\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t),\n\t\t\tisSaveViewOpen: isSaveViewOpened(),\n\t\t};\n\t}, [] );\n\tconst { setIsSaveViewOpened } = useDispatch( editSiteStore );\n\n\tconst activateSaveEnabled = isPreviewingTheme() || isDirty;\n\tconst disabled = isSaving || ! activateSaveEnabled;\n\n\tconst getLabel = () => {\n\t\tif ( disabled ) {\n\t\t\treturn __( 'Saved' );\n\t\t}\n\n\t\tif ( isPreviewingTheme() && isDirty ) {\n\t\t\treturn __( 'Activate & Save' );\n\t\t} else if ( isPreviewingTheme() ) {\n\t\t\treturn __( 'Activate' );\n\t\t}\n\n\t\treturn __( 'Save' );\n\t};\n\tconst label = getLabel();\n\n\treturn (\n\t\t<Button\n\t\t\tvariant={ variant }\n\t\t\tclassName={ className }\n\t\t\taria-disabled={ disabled }\n\t\t\taria-expanded={ isSaveViewOpen }\n\t\t\tisBusy={ isSaving }\n\t\t\tonClick={ disabled ? undefined : () => setIsSaveViewOpened( true ) }\n\t\t\tlabel={ label }\n\t\t\t/*\n\t\t\t * We want the tooltip to show the keyboard shortcut only when the\n\t\t\t * button does something, i.e. when it's not disabled.\n\t\t\t */\n\t\t\tshortcut={ disabled ? undefined : displayShortcut.primary( 's' ) }\n\t\t\t/*\n\t\t\t * Displaying the keyboard shortcut conditionally makes the tooltip\n\t\t\t * itself show conditionally. This would trigger a full-rerendering\n\t\t\t * of the button that we want to avoid. By setting `showTooltip`,\n\t\t\t & the tooltip is always rendered even when there's no keyboard shortcut.\n\t\t\t */\n\t\t\tshowTooltip={ showTooltip }\n\t\t\ticon={ icon }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
|
|
@@ -3,23 +3,22 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { useSelect
|
|
7
|
-
import {
|
|
8
|
-
import { sprintf,
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
7
|
+
import { __experimentalHStack as HStack } from '@wordpress/components';
|
|
8
|
+
import { sprintf, _n } from '@wordpress/i18n';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
-
import { displayShortcut } from '@wordpress/keycodes';
|
|
11
10
|
import { check } from '@wordpress/icons';
|
|
12
11
|
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
import
|
|
17
|
-
|
|
15
|
+
import SaveButton from '../save-button';
|
|
16
|
+
import { isPreviewingTheme } from '../../utils/is-previewing-theme';
|
|
17
|
+
export default function SaveHub() {
|
|
18
18
|
const {
|
|
19
19
|
countUnsavedChanges,
|
|
20
20
|
isDirty,
|
|
21
|
-
isSaving
|
|
22
|
-
isSaveViewOpen
|
|
21
|
+
isSaving
|
|
23
22
|
} = useSelect(select => {
|
|
24
23
|
const {
|
|
25
24
|
__experimentalGetDirtyEntityRecords,
|
|
@@ -28,41 +27,23 @@ export default function SaveButton() {
|
|
|
28
27
|
|
|
29
28
|
const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
|
|
30
29
|
|
|
31
|
-
const {
|
|
32
|
-
isSaveViewOpened
|
|
33
|
-
} = select(editSiteStore);
|
|
34
30
|
return {
|
|
35
31
|
isDirty: dirtyEntityRecords.length > 0,
|
|
36
32
|
isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)),
|
|
37
|
-
isSaveViewOpen: isSaveViewOpened(),
|
|
38
33
|
countUnsavedChanges: dirtyEntityRecords.length
|
|
39
34
|
};
|
|
40
35
|
}, []);
|
|
41
|
-
const
|
|
42
|
-
setIsSaveViewOpened
|
|
43
|
-
} = useDispatch(editSiteStore);
|
|
44
|
-
const disabled = !isDirty || isSaving;
|
|
45
|
-
const label = disabled ? __('Saved') : __('Save');
|
|
36
|
+
const disabled = isSaving || !isDirty && !isPreviewingTheme();
|
|
46
37
|
return createElement(HStack, {
|
|
47
38
|
className: "edit-site-save-hub",
|
|
48
39
|
alignment: "right",
|
|
49
40
|
spacing: 4
|
|
50
41
|
}, isDirty && createElement("span", null, sprintf( // translators: %d: number of unsaved changes (number).
|
|
51
|
-
_n('%d unsaved change', '%d unsaved changes', countUnsavedChanges), countUnsavedChanges)), createElement(
|
|
42
|
+
_n('%d unsaved change', '%d unsaved changes', countUnsavedChanges), countUnsavedChanges)), createElement(SaveButton, {
|
|
52
43
|
className: "edit-site-save-hub__button",
|
|
53
|
-
variant: disabled ?
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
onClick: disabled ? undefined : () => setIsSaveViewOpened(true),
|
|
58
|
-
label: label
|
|
59
|
-
/*
|
|
60
|
-
* We want the tooltip to show the keyboard shortcut only when the
|
|
61
|
-
* button does something, i.e. when it's not disabled.
|
|
62
|
-
*/
|
|
63
|
-
,
|
|
64
|
-
shortcut: disabled ? undefined : displayShortcut.primary('s'),
|
|
65
|
-
icon: disabled ? check : undefined
|
|
66
|
-
}, label));
|
|
44
|
+
variant: disabled ? null : 'primary',
|
|
45
|
+
showTooltip: false,
|
|
46
|
+
icon: disabled ? check : null
|
|
47
|
+
}));
|
|
67
48
|
}
|
|
68
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/save-hub/index.js"],"names":["useSelect","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/save-hub/index.js"],"names":["useSelect","__experimentalHStack","HStack","sprintf","_n","store","coreStore","check","SaveButton","isPreviewingTheme","SaveHub","countUnsavedChanges","isDirty","isSaving","select","__experimentalGetDirtyEntityRecords","isSavingEntityRecord","dirtyEntityRecords","length","some","record","kind","name","key","disabled"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,oBAAoB,IAAIC,MAAjC,QAA+C,uBAA/C;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,SAASC,iBAAT,QAAkC,iCAAlC;AAEA,eAAe,SAASC,OAAT,GAAmB;AACjC,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA,OAAvB;AAAgCC,IAAAA;AAAhC,MAA6Cb,SAAS,CACzDc,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,mCADK;AAELC,MAAAA;AAFK,QAGFF,MAAM,CAAER,SAAF,CAHV;;AAIA,UAAMW,kBAAkB,GAAGF,mCAAmC,EAA9D;;AACA,WAAO;AACNH,MAAAA,OAAO,EAAEK,kBAAkB,CAACC,MAAnB,GAA4B,CAD/B;AAENL,MAAAA,QAAQ,EAAEI,kBAAkB,CAACE,IAAnB,CAA2BC,MAAF,IAClCJ,oBAAoB,CAAEI,MAAM,CAACC,IAAT,EAAeD,MAAM,CAACE,IAAtB,EAA4BF,MAAM,CAACG,GAAnC,CADX,CAFJ;AAKNZ,MAAAA,mBAAmB,EAAEM,kBAAkB,CAACC;AALlC,KAAP;AAOA,GAd0D,EAe3D,EAf2D,CAA5D;AAkBA,QAAMM,QAAQ,GAAGX,QAAQ,IAAM,CAAED,OAAF,IAAa,CAAEH,iBAAiB,EAA/D;AAEA,SACC,cAAC,MAAD;AAAQ,IAAA,SAAS,EAAC,oBAAlB;AAAuC,IAAA,SAAS,EAAC,OAAjD;AAAyD,IAAA,OAAO,EAAG;AAAnE,KACGG,OAAO,IACR,4BACGT,OAAO,EACR;AACAC,EAAAA,EAAE,CACD,mBADC,EAED,oBAFC,EAGDO,mBAHC,CAFM,EAORA,mBAPQ,CADV,CAFF,EAcC,cAAC,UAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,OAAO,EAAGa,QAAQ,GAAG,IAAH,GAAU,SAF7B;AAGC,IAAA,WAAW,EAAG,KAHf;AAIC,IAAA,IAAI,EAAGA,QAAQ,GAAGjB,KAAH,GAAW;AAJ3B,IAdD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { sprintf, _n } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport SaveButton from '../save-button';\nimport { isPreviewingTheme } from '../../utils/is-previewing-theme';\n\nexport default function SaveHub() {\n\tconst { countUnsavedChanges, isDirty, isSaving } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\t__experimentalGetDirtyEntityRecords,\n\t\t\t\tisSavingEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\tconst dirtyEntityRecords = __experimentalGetDirtyEntityRecords();\n\t\t\treturn {\n\t\t\t\tisDirty: dirtyEntityRecords.length > 0,\n\t\t\t\tisSaving: dirtyEntityRecords.some( ( record ) =>\n\t\t\t\t\tisSavingEntityRecord( record.kind, record.name, record.key )\n\t\t\t\t),\n\t\t\t\tcountUnsavedChanges: dirtyEntityRecords.length,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst disabled = isSaving || ( ! isDirty && ! isPreviewingTheme() );\n\n\treturn (\n\t\t<HStack className=\"edit-site-save-hub\" alignment=\"right\" spacing={ 4 }>\n\t\t\t{ isDirty && (\n\t\t\t\t<span>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %d: number of unsaved changes (number).\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d unsaved change',\n\t\t\t\t\t\t\t'%d unsaved changes',\n\t\t\t\t\t\t\tcountUnsavedChanges\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcountUnsavedChanges\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t\t<SaveButton\n\t\t\t\tclassName=\"edit-site-save-hub__button\"\n\t\t\t\tvariant={ disabled ? null : 'primary' }\n\t\t\t\tshowTooltip={ false }\n\t\t\t\ticon={ disabled ? check : null }\n\t\t\t/>\n\t\t</HStack>\n\t);\n}\n"]}
|